@sekyro/node 0.1.0-rc.11 → 0.1.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @sekyro/node
2
2
 
3
+ ## 0.1.0-rc.13
4
+
5
+ ### Minor Changes
6
+
7
+ - a43e198: The connector claim carries the proven minimum age. `SekyroClaim` gains `age_over` (the minimum age of the flow that proved it, never the person's age) and `age_method` (`estimated`, `document`, `chip`, `registry` or `eid`), written from the result token's `sekyro.age` (or from the webhook's `age` when a session has no token), never the estimate or a birth date. The claim keeps the stronger proof of the same person: a birth date from identity data beats an estimate, then the higher minimum age wins; a session below the stored level that proved a stronger age writes the age alone (new merge rule `age_proved`), and a revocation or deletion clears it. Gates take `minAge` and `ageMethods`, and fail with `age_not_proven` (action `verify`) or `age_method_not_allowed` (action `step_up`). `AgeMethod` is exported from `@sekyro/node/connect`. Claims without the fields still parse and pass gates without `minAge`.
8
+
9
+ `@sekyro/connect-clerk` sends `age_over` and `age_method` as `null` when absent, so Clerk's deep merge never keeps a cleared age. Its peer range now requires `@sekyro/node` 0.1.0-rc.13 or later, the release that writes the age, so an older adapter cannot run next to a core that writes an age it would never clear.
10
+ - fcba7e9: AML screening. Sessions on a flow with an AML screening step return `screening` (`SessionScreening`: the lists searched, the dataset version, the best score and the matching list entries, or `{ unavailable }` when the lists could not be searched), on `sessions.get()` and in the `session.completed` and `session.failed` data. `people.screen(id, { lists })` screens a person again (billed as one AML screening; pass an `idempotencyKey`), and `people.screenings(id)`, `people.screeningsPage()` and `people.iterateScreenings()` list their history. `aml.match_flagged` is sent again, with a typed payload (`AmlMatchFlaggedEventData`). `CheckType` gains `aml_screening`, the `aml_screening` flow settings take `onHit: "signal"`, `PolicyFailureReason` gains `aml_hit` and `ReviewReason` gains `screening`.
11
+
12
+ ## 0.1.0-rc.12
13
+
14
+ ### Minor Changes
15
+
16
+ - 6bad03d: `SessionNetworkEvent.anonymizer` gains two optional flags, present only when true: `proxy` (a public open proxy) and `relay` (Apple iCloud Private Relay, a privacy relay that is not counted as an anonymizer). The existing `vpn`, `tor` and `hosting` flags are documented.
17
+ - 71ab282: Partner API contract and identity data. New: `sekyro.people` (`get`, `list`, `listPage`, `iterate`, `revoke`, `delete`, `createSession`) on the `/people` routes, with `per_` ids; `sessions.iterate` and `sessions.listPage` follow the list cursor, and `sessions.list` takes `flow`, `createdAfter`, `createdBefore`, `limit` and `cursor` (it still returns the first page); `sessions.cancel`, `sessions.resendLink` and `sessions.extendLink`; `sessions.media` and `sessions.mediaBytes` for the session's documents, portraits, selfie and clips; `identity` and `media` on sessions, people and the terminal webhooks; `decidedBy`, `personId` and `supersededBy` on sessions; the `person.*` webhook events; the `person` create key with `nationalities`, `document` and per-script `birthPlace`. Errors read the new `{ success: false, error: { requestId } }` envelope and the older one. The connector core handles `person.updated` and `person.deleted` and reads `personId` first.
18
+
19
+ Deprecated for one release, still working: `sekyro.subjects` (the same object as `sekyro.people`), the `Subject*` types, `sessions.portrait` (now served from the media list, scope `sessions:read`) and `portraitAvailable`, `subject` and the `nationality` / `documentNumber` keys, `subjectId` on sessions and webhooks, step `checkType` and `nodeId`, and the `subject.*`, `session.review_decided`, `session.step.completed`, `session.created` and `aml.match_flagged` events. Read `outcome: null` with `supersededBy` instead of `outcome: "superseded"`.
20
+
21
+ `personFromNationalRegistry()` returns a `PersonRecord` for the `person` key, with `nationalities: [code]`; `subjectFromNationalRegistry()`, `SubjectRecord` and `SubjectFromRegistryOptions` stay as deprecated names. `sessions.portrait()` is deprecated for `sessions.media()` and stays on the portrait route for this release. `people.listPage` and the connector's `userDeleted` keep only people whose `externalRefs` include the user id, and the connector handles a person's `subject.*` and `person.*` twin events once. `Session.createdAt` is optional and `Session.eid` is deprecated for `identity.eid`.
22
+
3
23
  ## 0.1.0-rc.11
4
24
 
5
25
  ### Minor Changes
package/README.md CHANGED
@@ -7,9 +7,8 @@ Three jobs, nothing else:
7
7
 
8
8
  1. **Sessions**: create a verification session from your backend and read its
9
9
  result. The API key never leaves your server.
10
- 2. **Webhooks**: verify the `x-sekyro-signature` header on deliveries (the
11
- legacy `x-ibtikar-signature` name is still sent) and get a typed envelope
12
- back.
10
+ 2. **Webhooks**: verify the `x-sekyro-signature` header on deliveries and get
11
+ a typed envelope back.
13
12
  3. **Result tokens**: verify the signed result token of a finished session
14
13
  (`verifyResultToken`) and read its level, assurance and outcome.
15
14
 
@@ -46,32 +45,39 @@ const sekyro = new Sekyro({
46
45
 
47
46
  // Create: returns the one-time client token your front end hands to @sekyro/web.
48
47
  // `flow` picks one of the app's flows (omit it for the default flow).
49
- // `subject.idNumber` BINDS the session to that identity: the browser never sends
50
- // the number (a different one is refused with 409 id_number_locked, formerly nni_locked).
48
+ // `person.idNumber` BINDS the session to that identity: the browser never sends
49
+ // the number (a different one is refused with a 409).
51
50
  const created = await sekyro.sessions.create(
52
51
  {
53
52
  flow: "default",
54
53
  locale: "ar",
55
- subject: { idNumber: { type: "national_id", issuingCountry: "<ISO alpha-2>", number: "<id number>" } },
54
+ person: { idNumber: { type: "national_id", issuingCountry: "<ISO alpha-2>", number: "<id number>" } },
56
55
  },
57
56
  { idempotencyKey: `signup:${userId}` },
58
57
  );
59
- created.id; // persist against your user before returning to the page
58
+ created.id; // `ses_…`: persist against your user before returning to the page
60
59
  created.clientToken; // give this to the browser; it is returned ONCE
61
60
  created.hostedUrl; // the hosted-flow link, if you use that path instead
62
61
  created.expiresAt; // ISO 8601
63
62
  created.flow; // { id, slug, version }: the flow version the session runs
64
- created.subjectUse; // 'reference' | 'prefill': whether the flow believes or checks your subject data
65
- created.warnings; // one { code: 'deprecated_field', field, replacement } per deprecated key you sent
63
+ created.subjectUse; // 'reference' | 'prefill': whether the flow believes or checks your person data
66
64
 
67
65
  // Read: the whitelisted session view (never contains the client token).
68
66
  const session = await sekyro.sessions.get(created.id);
69
67
  session.status; // 'created' | 'in_progress' | 'review_pending' | 'completed' | 'expired' | 'failed'
70
- session.outcome; // 'approved' | 'review' | 'rejected' | null
68
+ session.outcome; // 'approved' | 'review' | 'rejected' | null (null on a superseded session: see `supersededBy`)
69
+ session.decidedBy; // 'automatic' | 'review' on a completed or failed session
71
70
  session.flow; // { id: 'flw_…', slug: 'default', version: 3 }: the flow version the session runs
72
- session.steps; // [{ checkType, state, nodeId?, service?, handled?, reason?, calibratedScore? }]
71
+ session.steps; // [{ id, service, state, handled?, reason?, calibratedScore?, decision? }]
72
+ session.personId; // 'per_…' once the person passed a verification
73
+ session.identity; // what the session read: names, birth date, document, sources (see Identity data and media)
74
+ session.media; // the media kinds it has: ['document_front', 'selfie', …]
73
75
  ```
74
76
 
77
+ Ids are prefixed: `ses_` sessions, `per_` people, `flw_` flows. Every route also
78
+ accepts the bare 24 hexadecimal characters, so an id you stored before keeps
79
+ working.
80
+
75
81
  Your API key belongs to an **app**. The app's **flows**, designed in the Sekyro AI
76
82
  dashboard (app page → **Flows**), decide which steps run; a session runs the
77
83
  flow you name in `flow`, or the app's default flow. To list the published flows
@@ -87,8 +93,8 @@ Every field is optional:
87
93
  | `overrides` | `{ settings?, services? }`: changes the flow for this session only (see below; `403 override_widens_flow` for a looser change unless the flow allows it, `400 override_invalid` for an invalid one) |
88
94
  | `locale` | `ar`, `fr` or `en`: pins the hosted-flow language |
89
95
  | `ttlMinutes` | session lifetime, within the flow's link range (`400 ttl_out_of_policy` otherwise); omit for the flow default |
90
- | `subject` | what you know about the person: `idNumber` (`{ type, issuingCountry, number }`, binds the session), `fullName`, `names` (per script), `birthDate`, `birthPlace`, `sex`, `nationality`, `phone`, `email`, and for a reference record `photo`, `photoDate`, `fetchedAt`; your own id for them (`externalRef`), or `reuse` for a [returning user](#subjects). The flow decides whether the data is checked or believed (`created.subjectUse`) |
91
- | `input` | an open record of branch facts your flow's conditions read. Its person keys (`nni`, `phone`, `email`, `fullName`, `birthDate`, `suppliedIdentity`) are deprecated: send them in `subject` (`subject.nni` and `subject.documentNumber` are deprecated too, for `subject.idNumber`) |
96
+ | `person` | what you know about the person: `idNumber` (`{ type, issuingCountry, number }`, binds the session), `fullName`, `names` (per script), `birthDate`, `birthPlace` (a string or `[{ script, value }]`), `sex`, `nationalities`, `document` (`{ type, issuingCountry, number }`, compared with the capture), `phone`, `email`, and for a reference record `photo`, `photoDate`, `fetchedAt`; your own id for them (`externalRef`), or `reuse` for a [returning user](#people). The flow decides whether the data is checked or believed (`created.subjectUse`) |
97
+ | `input` | an open record of branch facts your flow's conditions read; facts about the person go in `person` |
92
98
  | `identityMethod` | `national_number`, `document_photo`, `document_chip` or `national_eid`: pre-chooses the option of the flow's identity choice |
93
99
  | `deliver` | `{ channel: "sms" \| "whatsapp", to: "+1555…" }`: also send the hosted link to the person |
94
100
 
@@ -112,39 +118,74 @@ changes a service's settings, keyed by service id (`liveness`, `phone_otp`,
112
118
  the flow stricter unless the flow allows widening; turning a service `'off'`
113
119
  always widens. The changed paths come back on `session.overriddenFields`.
114
120
 
115
- > **Sekyro flows breaking change.** The `profile` override is gone: use
116
- > `overrides`. `flow` is accepted again, now as the app's flow slug or id.
121
+ `flow` takes the app's flow slug or id.
117
122
 
118
123
  The session view also carries `failureReason` (a policy stop such as
119
124
  `location_not_allowed` or `underage`), `failureDetail` (why, when that reason
120
125
  is `camera_unavailable`: `denied` or `no_camera`), `overriddenFields`, `riskSignals`,
121
- `subjectId` / `externalRef`, `verifiedContacts`, `eid`, and the end user's
126
+ `personId` / `externalRef`, `verifiedContacts`, `eid`, and the end user's
122
127
  `network` and `device`. A step with `handled: true` failed, but the flow's
123
128
  fallback took over.
124
129
 
125
- Two more session calls:
130
+ More session calls:
126
131
 
127
132
  - `sekyro.sessions.selectMethod(id, method)` chooses the identity method of a
128
133
  session on the person's behalf (`POST /sessions/:id/method`): `409 choice_locked`
129
134
  once the flow's identity choice can no longer change, `409 choice_option_unavailable`
130
135
  for a method the flow does not offer this session, `409 choice_not_found` when the
131
136
  flow has no identity choice.
132
- - `sekyro.sessions.portrait(id)` returns a 5-minute link to the ICAO portrait of
133
- a session whose `portrait_icao` check passed (`portraitAvailable`; scope
134
- `portrait:read`).
137
+ - `sekyro.sessions.cancel(id)` stops a session that has not ended: the hosted link
138
+ stops working and one `session.failed` with `failureReason: 'cancelled_by_organization'`
139
+ is sent (`409 session_not_cancellable` once it ended).
140
+ - `sekyro.sessions.resendLink(id)` sends the hosted link again through the session's own
141
+ `deliver` channel, to the same destination; `sekyro.sessions.extendLink(id, { ttlMinutes })`
142
+ (or `{ expiresAt }`) gives the link a later expiry within the flow's bounds. Both need a
143
+ session created with `deliver` (`409 link_not_deliverable` otherwise).
144
+ - `sekyro.sessions.list(query)` returns the first page of your sessions, newest first
145
+ (50 by default, up to 100 with `limit`), filtered by `externalRef`, `status`, `flow`,
146
+ `createdAfter` and `createdBefore`. `sessions.iterate(query)` reads every page;
147
+ `sessions.listPage(query)` returns one page and its `nextCursor`.
148
+
149
+ ```ts
150
+ for await (const s of sekyro.sessions.iterate({ externalRef: userId, status: "completed" })) {
151
+ s.id; // newest first, page after page
152
+ }
153
+ ```
154
+
155
+ ### Identity data and media
156
+
157
+ `session.identity` holds what the session read, with the source of every value:
158
+ one `names[]` entry per source and script (`form`: `mrz`, `printed`, `chip`,
159
+ `registry`, `eid` or `supplied`), `birthDate`, `birthPlace[]`, `sex`,
160
+ `nationalities`, `idNumber`, `document` and `sources` (which sources agree on
161
+ each value). It is present once an identity step settled, whatever the outcome,
162
+ and it rides on `session.completed` and `session.failed` when that is enabled
163
+ for your organization.
164
+
165
+ ```ts
166
+ const { items } = await sekyro.sessions.media(id); // [{ kind, check, attempt?, decisive, contentType, url, expiresAt }]
167
+ const { contentType, bytes } = await sekyro.sessions.mediaBytes(id, "reference_portrait");
168
+ await sekyro.sessions.mediaBytes(id, "liveness_clip", { attempt: 2 });
169
+ ```
170
+
171
+ `url` is a download link valid 15 minutes, or the bytes route on this API (read
172
+ it with `mediaBytes`, which sends your key). Both need `sessions:read`. The
173
+ ICAO portrait is the `icao_portrait` media item.
135
174
 
136
175
  `sekyro.sessions` is a `SessionsApi`, exported as a type only: you get the
137
176
  instance from the client, never by constructing one.
138
177
 
139
178
  ### Person data
140
179
 
141
- Send what you know about the person in `subject`: `idNumber`
180
+ Send what you know about the person in `person`: `idNumber`
142
181
  (`{ type, issuingCountry, number }`), `fullName` or `names` (given, family and
143
- patronymic per ISO 15924 script), `birthDate`, `nationality`, `phone`, `email`,
144
- and for a flow that verifies identity from your data, `photo` and `fetchedAt`.
182
+ patronymic per ISO 15924 script), `birthDate`, `birthPlace` (a string or
183
+ `[{ script, value }]`), `sex`, `nationalities`, `document`
184
+ (`{ type, issuingCountry, number }`), `phone`, `email`, and for a flow that
185
+ verifies identity from your data, `photo` and `fetchedAt`.
145
186
  The session's flow decides how Sekyro AI uses it, never the request: when a step
146
- reads partner-supplied data (an environment Sekyro AI set to the `supplied`
147
- mode), the record is the **reference** to believe; otherwise it is a
187
+ reads partner-supplied data (a Partner-supplied identity step on the session's
188
+ path, available in every environment), the record is the **reference** to believe; otherwise it is a
148
189
  **prefill** checked against what the person shows. `created.subjectUse` says
149
190
  which (`"reference"` or `"prefill"`). The rules, the trust table and every
150
191
  error are on the [Person data](https://docs.sekyro.ai/en/guides/person-data)
@@ -153,7 +194,7 @@ page.
153
194
  ```ts
154
195
  // A prefill: the flow checks it against the registry or the document.
155
196
  await sekyro.sessions.create({
156
- subject: {
197
+ person: {
157
198
  externalRef: userId,
158
199
  idNumber: { type: "passport", issuingCountry: "<ISO alpha-2>", number: "<id number>" },
159
200
  birthDate: "<YYYY-MM-DD>",
@@ -162,42 +203,39 @@ await sekyro.sessions.create({
162
203
  ```
163
204
 
164
205
  If your data comes from your own call to a national registry,
165
- `subjectFromNationalRegistry()` converts that answer locally into the
206
+ `personFromNationalRegistry()` converts that answer locally into the
166
207
  reference keys. Sekyro AI treats the result as identity data supplied by your
167
- organization: it makes no registry call, and it never receives or stores any
168
- registry key.
208
+ organization: it makes no registry call and needs no registry key.
169
209
 
170
210
  ```ts
171
- import { subjectFromNationalRegistry } from "@sekyro/node";
211
+ import { personFromNationalRegistry } from "@sekyro/node";
172
212
 
173
213
  const answer = await myRegistryClient.lookup(idNumber); // your call, your key
174
214
  const receivedAt = new Date();
175
215
  const created = await sekyro.sessions.create({
176
- subject: {
216
+ person: {
177
217
  externalRef: userId,
178
218
  // fetchedAt: when YOUR system received this answer (required; > 24 h old is refused)
179
- ...subjectFromNationalRegistry("MR", answer, { fetchedAt: receivedAt }),
219
+ ...personFromNationalRegistry("MR", answer, { fetchedAt: receivedAt }),
180
220
  },
181
221
  });
182
- created.subjectUse; // "reference" in a supplied-mode environment whose flow reads it
222
+ created.subjectUse; // "reference" when the flow has a Partner-supplied identity step
183
223
  ```
184
224
 
185
225
  The first argument is the registry's country (ISO alpha-2) and types the
186
226
  answer: `"MR"` takes the ANRPTS `getPersonne` answer
187
- (`AnrptsPersonneResponse`). The result is a `SubjectRecord`: `idNumber`,
227
+ (`AnrptsPersonneResponse`). The result is a `PersonRecord`: `idNumber`,
188
228
  `names` (one entry per script found), `birthDate`, `birthPlace`, `sex`,
189
- `nationality` (alpha-2), `photo`, `photoDate` and `fetchedAt`. A record without
190
- a number, a birth date, a photo or any name, or with an invalid `fetchedAt`,
229
+ `nationalities` (`[code]`, alpha-2), `photo`, `photoDate` and `fetchedAt`. A
230
+ record without a number, a birth date, a photo or any name, or with an invalid `fetchedAt`,
191
231
  throws `SekyroConfigError` `invalid_registry_record` naming the field (never
192
232
  its value); a country without an adapter throws `registry_country_unsupported`.
193
233
  An answer that states a nationality none of whose values the SDK can map throws
194
234
  `registry_nationality_unmapped` (the message never carries the value): map it
195
235
  yourself and pass `options.nationality` (ISO alpha-2), so the stated nationality
196
236
  is never dropped.
197
- `subjectFromNationalRegistry()` replaces `registryFromAnrpts()`.
198
237
 
199
- Refusals of a reference, in this order: `403 supplied_identity_not_entitled`
200
- (the environment is not in `supplied` mode), `422 subject_record_incomplete`
238
+ Refusals of a reference, in this order: `422 subject_record_incomplete`
201
239
  (`error.details.fields` names the missing keys), `422 subject_record_stale`
202
240
  (obtained more than 24 h ago, or more than 5 min ahead) and
203
241
  `422 subject_photo_unusable` (not a JPEG or PNG of at most 1 MB within the size
@@ -209,20 +247,13 @@ the person consents, at the face match: a photo without one usable face fails th
209
247
  step with `no_face_reference` (or `low_quality_reference`). That step runs after liveness, so check
210
248
  that the photo shows exactly one clear face before you send it.
211
249
 
212
- Partner-supplied identity data is not billed: the identity step in `supplied` mode
250
+ Partner-supplied identity data is not billed: the Partner-supplied identity step
213
251
  records no usage event (other steps, such as the face match, bill as usual).
214
252
 
215
- **Deprecated keys.** `input.nni`, `input.fullName`, `input.birthDate`,
216
- `input.phone`, `input.email`, `input.suppliedIdentity`, `subject.nni`,
217
- `subject.documentNumber`, `subject.reuse.nni` and `subject.reuse.document`
218
- still work. A create that uses one gets a `Deprecation` header and one
219
- `created.warnings` entry per key (`{ code: "deprecated_field", field,
220
- replacement }`). The step reasons and codes about the number get generic names
221
- (`registry_record_not_found` for `nni_not_found`, `id_number_locked` for
222
- `nni_locked`, `document_id_number_mismatch` for `document_nni_mismatch`, ...):
223
- the API still sends the previous names, so accept both. The full migration
224
- table is on the [Person data](https://docs.sekyro.ai/en/guides/person-data#deprecated-keys)
225
- page.
253
+ The step reasons and codes about the number are `registry_record_not_found`,
254
+ `id_number_invalid`, `id_number_locked`, `document_id_number_mismatch` and
255
+ `sandbox_id_number_not_seeded`. See
256
+ [Person data](https://docs.sekyro.ai/en/guides/person-data).
226
257
 
227
258
  ### Errors
228
259
 
@@ -233,7 +264,7 @@ Every non-2xx response, network failure and timeout throws `SekyroApiError`:
233
264
  | `status` | HTTP status (`0` for network / timeout) |
234
265
  | `code` | API error code, or `network` / `timeout` / `http_error` / `malformed_response` |
235
266
  | `message` | human-readable, from the API when available |
236
- | `requestId` | the API's `request_id`, quote it to support |
267
+ | `requestId` | the API's `requestId`, quote it to support |
237
268
  | `details` | the API's `error.details` when sent, else `undefined`; typed for the flow codes through `isFlowError()` |
238
269
  | `retryable` | `true` for `network`, `timeout`, `429`, `5xx` and `idempotency_in_progress` |
239
270
  | `retryAfterSeconds` | seconds to wait from the response's `Retry-After` header (seconds or an HTTP date), else `undefined` |
@@ -242,7 +273,7 @@ Every non-2xx response, network failure and timeout throws `SekyroApiError`:
242
273
  import { SekyroApiError } from "@sekyro/node";
243
274
 
244
275
  try {
245
- await sekyro.sessions.create({ subject: { idNumber } });
276
+ await sekyro.sessions.create({ person: { idNumber } });
246
277
  } catch (err) {
247
278
  if (err instanceof SekyroApiError && err.retryable) {
248
279
  // wait err.retryAfterSeconds when set, else back off; retry with the SAME idempotencyKey
@@ -264,7 +295,7 @@ returns `false` when the details are missing or not in that shape, so read
264
295
  | `409 flow_not_published`, `409 flow_archived` | `sessions.create` | `issues`, `flow` |
265
296
  | `400 override_invalid` | `sessions.create` | `issues`, one per problem (`path: "overrides.services.liveness.attempts"`, …) |
266
297
  | `403 override_widens_flow` | `sessions.create` | `issues` (`field_widens_flow`), `fields` |
267
- | `409 reuse_disabled` | `sessions.create` with `subject.reuse` | `issues`, `flow` |
298
+ | `409 reuse_disabled` | `sessions.create` with `person.reuse` | `issues`, `flow` |
268
299
  | `409 choice_not_found`, `choice_locked`, `choice_option_unavailable` | `sessions.selectMethod` | `issues` |
269
300
 
270
301
  ```ts
@@ -281,54 +312,52 @@ try {
281
312
  }
282
313
  ```
283
314
 
284
- ## Subjects
315
+ ## People
285
316
 
286
- A **subject** is the same person across all of your apps. Reads need the
287
- `subjects:read` scope; `revoke` and `delete` need `subjects:write` (keys minted
288
- from the dashboard carry both; mint a new key if an older one answers
317
+ A **person** is the same person across all of your apps (`per_…` ids). Reads
318
+ need the `people:read` scope; `revoke` and `delete` need `people:write` (keys
319
+ minted from the dashboard carry both; mint a new key if one answers
289
320
  `403 insufficient_scope`).
290
321
 
291
322
  ```ts
292
- const subject = await sekyro.subjects.get(subjectId);
293
- subject.status; // 'active' | 'revoked'
294
- subject.reference; // { source: 'registry' | 'doc_registry' | 'chip' | 'document', capturedAt } | null
295
- subject.assurance; // 'registry_biometric' | 'chip_biometric' | 'document_biometric' | 'registry_only' | 'document_only' | null
296
- subject.returningReady; // a returning-user session can be created now
297
- subject.level; // the highest level proved: 0 | 1 | 2 | 3 (0 once revoked), null before any, absent on an older API
323
+ const person = await sekyro.people.get(personId);
324
+ person.status; // 'active' | 'revoked'
325
+ person.reference; // { source: 'registry' | 'doc_registry' | 'chip' | 'document', capturedAt } | null
326
+ person.assurance; // 'registry_biometric' | 'chip_biometric' | 'document_biometric' | 'registry_only' | 'document_only' | null
327
+ person.returningReady; // a returning-user session can be created now
328
+ person.level; // the highest level proved: 0 | 1 | 2 | 3 (0 once revoked), null before any
329
+ person.identity; // the identity of the latest approved session that read one
298
330
 
299
- const recent = await sekyro.sessions.list({ externalRef: userId, status: "completed" }); // newest first, at most 100; filters re-applied client-side
300
-
301
- const [byRef] = await sekyro.subjects.list({ externalRef: userId });
331
+ const [byRef] = await sekyro.people.list({ externalRef: userId }); // first page, newest first
332
+ for await (const p of sekyro.people.iterate()) p.id; // every page
302
333
 
303
334
  // Returning user: liveness + face match against the stored reference photo.
304
- // Name exactly one of subjectId, externalRef or idNumber (nni and document are deprecated).
305
- await sekyro.sessions.create({ subject: { reuse: { subjectId } } });
335
+ // Name exactly one of subjectId (the person id), externalRef or idNumber.
336
+ await sekyro.sessions.create({ person: { reuse: { subjectId: personId } } });
306
337
 
307
338
  // The same in one call, with a mode: `recheck` (verify the same person again)
308
- // or `step_up` (raise a level 1 subject to identity level). A 24-hex string is
309
- // a subject id; anything else is your external reference.
310
- await sekyro.subjects.createSession(userId, { mode: "step_up", flow: "identity" });
339
+ // or `step_up` (raise a level 1 person to identity level). A person id (`per_…`
340
+ // or 24 hexadecimal characters) names the person; anything else is your external reference.
341
+ await sekyro.people.createSession(userId, { mode: "step_up", flow: "identity" });
311
342
 
312
- await sekyro.subjects.revoke(subjectId, { reason: "account closed" }); // idempotent
313
- await sekyro.subjects.delete(subjectId); // photos, face templates and identifiers; cannot be undone
343
+ await sekyro.people.revoke(personId, { reason: "account closed" }); // idempotent
344
+ await sekyro.people.delete(personId); // photos, face templates, identifiers and their sessions' data; cannot be undone
314
345
  ```
315
346
 
316
- A subject is visible once the person has passed a verification. A subject that
317
- never passed, an unknown id and a subject of another organization or
318
- environment all answer the same `404 subject_not_found` on `get`, `revoke` and
319
- `delete`, and `list` leaves it out (the list can be empty while sessions with
320
- that `externalRef` exist).
347
+ A person is visible once they have passed a verification. A person who never
348
+ passed, an unknown id and a person of another organization or environment all
349
+ answer the same `404 subject_not_found` on `get`, `revoke` and `delete`, and
350
+ `list` leaves them out (the list can be empty while sessions with that
351
+ `externalRef` exist).
321
352
 
322
- `subject.enrolled` (first reference photo stored), `subject.updated` (a linked
323
- session finished, or `status: 'revoked'`) and `subject.deleted` webhooks are
324
- typed on the envelope.
353
+ `person.enrolled` (first reference photo stored), `person.updated` (a linked
354
+ session finished, or `status: 'revoked'`) and `person.deleted` webhooks are
355
+ typed on the envelope, with `personId`.
325
356
 
326
357
  ## Webhooks
327
358
 
328
359
  Verify with the **raw** request body (bytes as received, before any JSON
329
- parsing or re-serialisation) and the signature header: `x-sekyro-signature`
330
- (primary), falling back to the legacy `x-ibtikar-signature` while both are
331
- sent.
360
+ parsing or re-serialisation) and the signature header, `x-sekyro-signature`.
332
361
 
333
362
  ```ts
334
363
  import { verifyWebhook, signatureFromHeaders, SekyroWebhookError } from "@sekyro/node";
@@ -337,23 +366,21 @@ app.post("/webhooks/sekyro", express.raw({ type: "application/json" }), (req, re
337
366
  try {
338
367
  const envelope = verifyWebhook(
339
368
  req.body.toString("utf8"),
340
- signatureFromHeaders(req.headers), // x-sekyro-signature, else the legacy x-ibtikar-signature
369
+ signatureFromHeaders(req.headers), // the x-sekyro-signature header
341
370
  process.env.SEKYRO_WEBHOOK_SECRET!,
342
371
  );
343
372
  // The envelope is discriminated on `event`: narrowing it types `data`.
344
373
  switch (envelope.event) {
345
374
  case "session.completed":
346
375
  case "session.failed":
347
- envelope.data; // SessionLifecycleEventData: { sessionId, status, outcome, flow, steps, … }
348
- break;
349
- case "session.review_decided":
350
- envelope.data; // SessionReviewDecidedEventData: { sessionId, outcome: 'pass' | 'fail', reason, reasons, decision, flow, … }
376
+ // The one terminal event of a session: { sessionId, status, outcome, decidedBy, decision?, flow, steps, identity?, media?, … }
377
+ envelope.data; // SessionLifecycleEventData
351
378
  break;
352
379
  case "session.superseded":
353
- envelope.data; // SessionSupersededEventData: { sessionId, supersededBy, caseId, reason: 'superseded_by_retry' }
380
+ envelope.data; // SessionSupersededEventData: { sessionId, supersededBy, reason: 'superseded_by_retry' }
354
381
  break;
355
- case "session.step.completed":
356
- envelope.data; // SessionStepCompletedEventData: { sessionId, checkType, state, nodeId, service, flow }
382
+ case "person.updated":
383
+ envelope.data; // PersonUpdatedEventData: { personId, status, externalRefs, … }
357
384
  break;
358
385
  }
359
386
  res.sendStatus(200);
@@ -368,12 +395,9 @@ app.post("/webhooks/sekyro", express.raw({ type: "application/json" }), (req, re
368
395
  rotation Sekyro AI signs with both the current and the previous secret, so the
369
396
  delivery is accepted when **any** `v1` matches the secret you hold.
370
397
  - **Header names.** Deliveries carry the signature in `x-sekyro-signature`
371
- (`SEKYRO_SIGNATURE_HEADER`) and, for the transition, the identical legacy
372
- `x-ibtikar-signature` (`LEGACY_SIGNATURE_HEADER`). `signatureFromHeaders()`
373
- takes a Fetch `Headers` or a Node headers record and returns the branded
374
- header, else the legacy one. The event id/type travel the same way:
375
- `x-sekyro-event-id` / `x-sekyro-event-type` alongside their `x-ibtikar-*`
376
- twins.
398
+ (`SEKYRO_SIGNATURE_HEADER`). `signatureFromHeaders()` takes a Fetch `Headers`
399
+ or a Node headers record and returns it. The event id and type travel in
400
+ `x-sekyro-event-id` and `x-sekyro-event-type`.
377
401
  - Each `v1` is `HMAC-SHA256(secret, "<t>.<rawBody>")`, compared in constant time.
378
402
  - Deliveries older or newer than `toleranceSec` (default 300 s) are rejected as
379
403
  `stale`; pass `{ now }` to inject a clock in tests.
@@ -383,7 +407,8 @@ app.post("/webhooks/sekyro", express.raw({ type: "application/json" }), (req, re
383
407
 
384
408
  When a person decides a step, the step carries `decision`
385
409
  (`SessionStepDecision`) on `sekyro.sessions.get` and on the `steps` of the
386
- `session.*` webhooks, and `session.review_decided` carries it at the top level:
410
+ `session.*` webhooks, and `session.completed` / `session.failed` carry it at the
411
+ top level with `decidedBy: 'review'`:
387
412
  `{ source, mode, votes, agreement?, reasons, decidedAt, sessionId? }`.
388
413
  `source` is `review` (a reviewer) or `prior_review` (an earlier review of the
389
414
  same person, reference photo and face was reused; `sessionId` names your
@@ -393,18 +418,17 @@ formed it and `agreement` says whether two dual reviewers agreed. `reasons`
393
418
  `data_mismatch`, `other`) says what failed on a rejection, or what was
394
419
  overridden on an approval. The object never names a reviewer or a vote.
395
420
 
396
- `session.review_decided` also carries `reasons` and, when the decision ends the
397
- session, the terminal fields of `session.completed` / `session.failed`
398
- (`level`, `assurance`, `unit`, `resultToken`, …). A review that reaches its
399
- deadline sends `reason: 'review_timeout'`, or `review_split` when two reviewers
400
- disagreed and nobody settled it; those carry no `decision`.
421
+ A review that reaches its deadline ends with `session.failed`, `decidedBy:
422
+ 'automatic'` and `failureReason: 'review_timeout'`, or `review_split` when two
423
+ reviewers disagreed and nobody settled it; those carry no `decision`.
401
424
 
402
425
  Reason codes of these paths: `prior_review_approved` and
403
426
  `prior_review_rejected` on a face match settled by an earlier review
404
427
  (`PriorReviewReason`), and `superseded_by_retry` and `review_split` on any
405
428
  reviewed step (`ReviewOutcomeReason`). A session that waited for a review ends
406
- with outcome `superseded` when a newer attempt of the same person takes the
407
- review over: `session.superseded` names the newer session in `supersededBy`.
429
+ with `outcome: null` and `supersededBy` when a newer attempt of the same person
430
+ takes the review over: `session.superseded`, its one terminal event, names the
431
+ newer session in `supersededBy`.
408
432
 
409
433
  ## Result tokens
410
434
 
@@ -420,7 +444,7 @@ const result = await verifyResultToken(token, { appId: process.env.SEKYRO_APP_ID
420
444
  result.level; // 0 | 1 | 2 | 3 | null (1 human, 2 identity, 3 corroborated)
421
445
  result.assurance; // 'live_only' | 'document_biometric' | 'registry_biometric' | ...
422
446
  result.outcome; // 'approved' | 'rejected' | ...
423
- result.subjectId; // the person, when known
447
+ result.subjectId; // the person id without its per_ prefix, when known
424
448
  ```
425
449
 
426
450
  - Keys come from `https://api.sekyro.ai/.well-known/sekyro/jwks.json` and are
@@ -439,9 +463,9 @@ and `method` says how it was proved (`estimated` by the age check (selfie)
439
463
  step, or `document`, `chip`, `registry`, `eid`). The token never carries the
440
464
  estimated age; with the step's "Keep and show the estimated age" setting on,
441
465
  `estimate` and `sigma` arrive on the session (`sekyro.sessions.get`) and the
442
- `session.completed` / `session.failed` webhooks only. To carry the answer into
443
- an identity provider, map it to the claims `sekyro_age_over` (`result.age.over`)
444
- and `sekyro_age_method` (`result.age.method`).
466
+ `session.completed` / `session.failed` webhooks only. The connectors
467
+ (`@sekyro/node/connect`, see [Connect](#connect)) carry the answer into your
468
+ auth provider as `age_over` and `age_method` in the `sekyro` claim.
445
469
 
446
470
  `result.decision` is the `sekyro.decision` claim (`ResultDecision`, the same
447
471
  fields as a step's `decision`), when a person decided a step of the session.
@@ -526,13 +550,23 @@ app.get(
526
550
  // Next.js: sekyroGate() and gateRoute() from "@sekyro/node/connect/next".
527
551
  ```
528
552
 
529
- The claim (unix seconds; never a name, a document number, a photo or a score):
553
+ The claim (unix seconds; never a name, a document number, a photo, a score, a birth date or an estimated age):
530
554
 
531
555
  ```json
532
556
  { "v": 1, "level": 2, "assurance": "document_biometric", "verified_at": 1790000000, "rechecked_at": 1790003600,
533
- "session_id": "<session id>", "subject_id": "<subject id>", "env": "live", "flags": ["face_mismatch"] }
557
+ "session_id": "<session id>", "subject_id": "<subject id>", "env": "live", "flags": ["face_mismatch"],
558
+ "age_over": 18, "age_method": "document" }
534
559
  ```
535
560
 
561
+ `age_over` and `age_method` appear once a session of a flow with a minimum age
562
+ proved it: the flow's minimum age and how (`estimated`, or `document`, `chip`,
563
+ `registry`, `eid`). The claim keeps the stronger proof of the same person (a
564
+ birth date from identity data beats an estimate, then the higher minimum age).
565
+ Gate on it with `minAge`, and `ageMethods` when the route needs a proven birth
566
+ date: `{ level: 1, minAge: 18, ageMethods: ["document", "chip", "registry", "eid"] }`
567
+ fails with `age_not_proven` (action `verify`) or `age_method_not_allowed`
568
+ (action `step_up`).
569
+
536
570
  Trust rules:
537
571
 
538
572
  - A webhook writes only after its HMAC signature verified; retries are de-duplicated on the envelope id, which is never left recorded for a delivery whose handling failed (see the `store` contract in the guide).
@@ -541,13 +575,13 @@ Trust rules:
541
575
  - The return URL is a hint: store the session id with your `state` at start and compare both on return; `sync` then reads the session and its signed result token with your API key, verifies the token (your app ids, your environment) and refuses a session of another user, of another app or created without one.
542
576
  - Every input goes through one merge: a failed attempt never erases a proof, a weaker proof never lowers the level, an older result never overwrites a newer one, and a result from the other environment is refused.
543
577
  - Writes for one user are serialised: each one reads the stored claim, merges and writes it back through the adapter's optional `update` when it has one (the Firebase adapter does), otherwise under a lock per user inside the connector. That lock is per process: two server instances can still interleave for one user, and a re-check result read just before a revocation could write over it. When that matters, send the webhook route to one instance or queue its deliveries per user id.
544
- - A revocation or deletion of the subject sets the level to 0 with the `revoked` flag (a claim stored without `subject_id` too, when the event's `externalRefs` include the user's id); the gate blocks `revoked` and `face_mismatch` by default. A revoked claim stays revoked: a later result of the same subject, or one without a subject id, is `revoked_ignored`; only an approved session of another subject writes a level again.
578
+ - A revocation or deletion of the person (`person.updated` with `status: 'revoked'`, `person.deleted`) sets the level to 0 with the `revoked` flag (a claim stored without `subject_id` too, when the event's `externalRefs` include the user's id); the gate blocks `revoked` and `face_mismatch` by default. A revoked claim stays revoked: a later result of the same person, or one without a person id, is `revoked_ignored`; only an approved session of another person writes a level again.
545
579
 
546
580
  Telemetry: the six Sekyro provider packages tell Sekyro the connector is wired, so the dashboard's
547
581
  Connectors page can show it as connected. Every API call carries an `x-sekyro-connector` header
548
582
  (`<provider>/<version>`), and after each claim write, and each revocation the connector could not
549
583
  resolve to a user (`revocation_unresolved`), it posts an event with ids only: the event type, the
550
- provider, the session id, the subject id and the time. Never the claim, a token, a secret or user
584
+ provider, the session id, the person id and the time. Never the claim, a token, a secret or user
551
585
  data. Events go in the background with a 2-second timeout and no retry, and never slow or fail a
552
586
  webhook. A custom adapter sends nothing. Turn both off with `telemetry: false`:
553
587
 
@@ -557,10 +591,10 @@ const connector = createConnector({ /* ... */ provider, telemetry: false });
557
591
 
558
592
  Outside a connector, `new Sekyro({ apiKey, connector: { provider, version } })` sends the same header.
559
593
 
560
- Revocations it cannot resolve: when Sekyro revokes or deletes a subject and the connector finds no
594
+ Revocations it cannot resolve: when Sekyro revokes or deletes a person and the connector finds no
561
595
  user for it (no `externalRefs`, no `store` entry), no claim is cleared and the connector logs
562
596
  `revocation_unresolved`. Pass `onRevocationUnresolved` to act on it. The event carries ids only
563
- (`subjectId`, `provider`, `reason`: `revoked` or `deleted`), never provider data. It runs after the
597
+ (`personId`, `provider`, `reason`: `revoked` or `deleted`), never provider data. It runs after the
564
598
  log line and telemetry event, in the background; a throw or rejection is caught and reported to
565
599
  `logger` as `revocation_handler_failed`.
566
600
 
@@ -568,8 +602,8 @@ log line and telemetry event, in the background; a throw or rejection is caught
568
602
  const connector = createConnector({
569
603
  /* ... */
570
604
  provider,
571
- onRevocationUnresolved: async ({ subjectId, reason }) => {
572
- // Find the user for subjectId and remove their access.
605
+ onRevocationUnresolved: async ({ personId, reason }) => {
606
+ // Find the user for personId and remove their access.
573
607
  },
574
608
  });
575
609
  ```
@@ -1 +1 @@
1
- import{evaluateGate}from"./chunk-4JZXIGA6.js";function sekyroGate(source,tokenClaims,policy){let claims=tokenClaims??{};if("gate"in source)return source.gate(claims,policy);let effective=source.env!==void 0&&policy.env===void 0?{...policy,env:source.env}:policy;return evaluateGate(source.provider.readClaimFromToken(claims),effective)}function gateRoute(result,routes){if(result.ok)return null;switch(result.action){case"verify":return routes.verify;case"step_up":return routes.stepUp;case"recheck":return routes.recheck;case"block":return routes.block}}export{sekyroGate,gateRoute};
1
+ import{evaluateGate}from"./chunk-J6U2QY7M.js";function sekyroGate(source,tokenClaims,policy){let claims=tokenClaims??{};if("gate"in source)return source.gate(claims,policy);let effective=source.env!==void 0&&policy.env===void 0?{...policy,env:source.env}:policy;return evaluateGate(source.provider.readClaimFromToken(claims),effective)}function gateRoute(result,routes){if(result.ok)return null;switch(result.action){case"verify":return routes.verify;case"step_up":return routes.stepUp;case"recheck":return routes.recheck;case"block":return routes.block}}export{sekyroGate,gateRoute};
@@ -0,0 +1 @@
1
+ var CLAIM_VERSION=1,KNOWN_FLAGS=["face_mismatch","duplicate","revoked"],AGE_METHODS=["estimated","document","chip","registry","eid"];function ageProofOf(over,method){if(!(typeof over!="number"||!Number.isInteger(over)||over<=0)&&!(typeof method!="string"||!AGE_METHODS.includes(method)))return{over,method}}var ageRank=a=>a.method==="estimated"?0:1;function strongerAge(stored,next){if(!stored)return next;if(!next)return stored;let r=ageRank(next)-ageRank(stored);return r!==0?r>0?next:stored:next.over>stored.over?next:stored}var sameAge=(a,b)=>a?.over===b?.over&&a?.method===b?.method;function canonicalId(id){return id.replace(/^(ses|per)_/,"")}function isRecord(v){return typeof v=="object"&&v!==null&&!Array.isArray(v)}function isFiniteNumber(v){return typeof v=="number"&&Number.isFinite(v)}function build(c){let out={v:1,level:c.level,assurance:c.assurance,verified_at:c.verified_at};c.rechecked_at!==void 0&&(out.rechecked_at=c.rechecked_at),out.session_id=c.session_id,c.subject_id!==void 0&&(out.subject_id=canonicalId(c.subject_id)),out.env=c.env;let flags=new Set;for(let f of c.flags??[])KNOWN_FLAGS.includes(f)&&flags.add(f);flags.size>0&&(out.flags=[...flags].sort());let age=ageProofOf(c.age_over,c.age_method);return age&&(out.age_over=age.over,out.age_method=age.method),out}function ageFields(age){return{age_over:age?.over,age_method:age?.method}}function parseClaim(value){let v=value;if(typeof v=="string")try{v=JSON.parse(v)}catch{return null}if(!isRecord(v)||!isFiniteNumber(v.v))return null;if(v.v>1)return v;if(v.v!==1)return null;let level=v.level;return level!==0&&level!==1&&level!==2&&level!==3||typeof v.assurance!="string"||!isFiniteNumber(v.verified_at)||typeof v.session_id!="string"||v.env!=="live"&&v.env!=="sandbox"?null:build({level,assurance:v.assurance,verified_at:v.verified_at,rechecked_at:isFiniteNumber(v.rechecked_at)?v.rechecked_at:void 0,session_id:v.session_id,subject_id:typeof v.subject_id=="string"?v.subject_id:void 0,env:v.env,flags:Array.isArray(v.flags)?v.flags:void 0,age_over:v.age_over,age_method:v.age_method})}function toUnix(isoTime,now){let ms=Date.parse(isoTime);return Math.floor((Number.isFinite(ms)?ms:now())/1e3)}var same=(claim,rule)=>({claim,changed:!1,rule}),wrote=(claim,rule)=>({claim,changed:!0,rule});function mergeClaim(previous,event,opts){let now=opts.now??Date.now,prev=parseClaim(previous);if(prev&&prev.v>1)return same(prev,"unsupported_version");if(event.kind==="revoked"||event.kind==="deleted"){if(!prev)return same(null,"no_change");if(!(prev.subject_id===void 0?event.userInExternalRefs===!0:prev.subject_id===canonicalId(event.subjectId)))return same(prev,"subject_mismatch");if(prev.level===0&&prev.flags?.includes("revoked"))return same(prev,"no_change");let{rechecked_at:_cleared,age_over:_over,age_method:_method,...kept}=prev;return wrote(build({...kept,level:0,subject_id:event.subjectId,flags:["revoked"]}),"revoked")}let r=event.result;if(r.env!==opts.env)return same(prev,"env_mismatch");let t=toUnix(r.verifiedAt,now);if(prev&&t<prev.verified_at)return same(prev,"stale_ignored");let revokedPrev=prev?.flags?.includes("revoked")===!0;if(prev&&revokedPrev&&(r.subjectId===void 0||canonicalId(r.subjectId)===prev.subject_id))return same(prev,"revoked_ignored");if(r.outcome==="rejected"&&r.subjectConflict===!0)return!prev||prev.flags?.includes("face_mismatch")?same(prev,"no_change"):wrote(build({...prev,flags:[...prev.flags??[],"face_mismatch"]}),"face_mismatch");if(r.outcome!=="approved"||r.level===null||r.level===0)return same(prev,"not_approved");let level=r.level,assurance=r.assurance??"none",duplicate=r.duplicates===!0?["duplicate"]:[],nextAge=r.age?ageProofOf(r.age.over,r.age.method):void 0;if(!prev)return wrote(build({level,assurance,verified_at:t,session_id:r.sessionId,subject_id:r.subjectId,env:r.env,flags:duplicate,...ageFields(nextAge)}),"created");let prevAge=ageProofOf(prev.age_over,prev.age_method),otherPerson=prev.subject_id!==void 0&&r.subjectId!==void 0&&canonicalId(r.subjectId)!==prev.subject_id,mergedAge=otherPerson?prevAge:strongerAge(prevAge,nextAge);if(!revokedPrev&&(r.reuseMode==="recheck"||r.returning===!0&&level<=prev.level))return prev.rechecked_at!==void 0&&t<=prev.rechecked_at?same(prev,t<prev.rechecked_at?"stale_ignored":"no_change"):wrote(build({...prev,rechecked_at:t,subject_id:prev.subject_id??r.subjectId,...ageFields(mergedAge)}),"rechecked");if(level>prev.level){let kept=(prev.flags??[]).filter(f=>f!=="face_mismatch"&&f!=="revoked");return wrote(build({...prev,level,assurance,verified_at:t,session_id:r.sessionId,subject_id:r.subjectId??prev.subject_id,flags:[...kept,...duplicate],...ageFields(otherPerson?nextAge:mergedAge)}),"raised")}return level===prev.level&&t>prev.verified_at?wrote(build({...prev,assurance,verified_at:t,session_id:r.sessionId,subject_id:prev.subject_id??r.subjectId,flags:[...prev.flags??[],...duplicate],...ageFields(mergedAge)}),"renewed"):sameAge(mergedAge,prevAge)?same(prev,"no_change"):wrote(build({...prev,subject_id:prev.subject_id??r.subjectId,...ageFields(mergedAge)}),"age_proved")}var DEFAULT_DENY_FLAGS=["revoked","face_mismatch"],fail=(reason,action,claim)=>({ok:!1,reason,action,claim});function evaluateGate(claim,policy,nowSec=Math.floor(Date.now()/1e3)){let parsed=parseClaim(claim);if(!parsed)return fail("no_claim","verify",null);if(parsed.v>1)return fail("unsupported_version","verify",parsed);if(policy.env!==void 0&&parsed.env!==policy.env)return fail("wrong_env","verify",parsed);let deny=policy.denyFlags??DEFAULT_DENY_FLAGS;if(parsed.flags?.some(f=>deny.includes(f)))return fail("flagged","block",parsed);if(parsed.level<policy.level)return fail("level_too_low",parsed.level>=1?"step_up":"verify",parsed);if(policy.maxAgeDays!==void 0&&nowSec-parsed.verified_at>policy.maxAgeDays*86400)return fail("stale","recheck",parsed);if(policy.maxRecheckAgeMinutes!==void 0&&nowSec-(parsed.rechecked_at??parsed.verified_at)>policy.maxRecheckAgeMinutes*60)return fail("recheck_stale","recheck",parsed);if(policy.assurance&&!policy.assurance.includes(parsed.assurance))return fail("assurance_not_allowed","step_up",parsed);if(policy.minAge!==void 0){if(parsed.age_over===void 0||parsed.age_over<policy.minAge)return fail("age_not_proven","verify",parsed);if(policy.ageMethods&&(parsed.age_method===void 0||!policy.ageMethods.includes(parsed.age_method)))return fail("age_method_not_allowed","step_up",parsed)}return{ok:!0,claim:parsed}}export{CLAIM_VERSION,canonicalId,parseClaim,mergeClaim,evaluateGate};