import { initializeSdk } from'@ftid/sdk-web'// publicKey is a public locator, not a secret.// collectionOrigin is YOUR collection domain (https).const sdk = initializeSdk({
publicKey: 'pub_app_0123456789abcdef',
collectionOrigin: 'https://collect.yourcompany.com',
})
// ACCEPTED (202 PROCESSING on the wire): confirms receipt, not a result.const collection = await sdk.collect()
if (collection.status !== 'ACCEPTED') {
// Without collection the journey continues; the backend will get// INCONCLUSIVE / COLLECTOR_NOT_LOADED: no fake score.return continueWithoutToken()
}
// Create the event before sending the request to be assessed.const event = sdk.createEvent(collection.observation)
// Only a COMPLETED collection yields a token. The token goes in the POST// that YOUR backend makes; the decision never comes back here.const ctx = await sdk.getEventContext(event)
const token =
ctx.status === 'COMPLETED'
? ctx.eventContextToken
: null
X-FTID-Timestamp: 1791720000Epoch เป็นวินาที ยอมรับคลาดเคลื่อน ±300 s timestamp ในอนาคตไม่เคยยืดระยะเวลาการเก็บรักษา
X-FTID-Request-Id: <uuidv7>ใช้ได้ครั้งเดียวต่อความพยายาม จองไว้หลัง MAC ถูกต้อง การลองใหม่เชิงตรรกะต้องลงนาม request_id ใหม่ MAC ที่ไม่ถูกต้องไม่สร้างการจอง
X-FTID-External-Event-Id: evt:tag-0003ตรงกันทุกไบต์กับค่าใน body และในสตริงที่ลงนาม