@sekyro/node 0.1.0-rc.9 → 1.0.0-rc.16
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 +111 -0
- package/README.md +252 -106
- package/dist/{chunk-TAPXGI3Q.js → chunk-IM3UCVDB.js} +1 -1
- package/dist/chunk-J6U2QY7M.js +1 -0
- package/dist/client-BDULrZqs.d.cts +2444 -0
- package/dist/client-BDULrZqs.d.ts +2444 -0
- package/dist/connect/express/index.cjs +1 -1
- package/dist/connect/express/index.d.cts +2 -2
- package/dist/connect/express/index.d.ts +2 -2
- package/dist/connect/express/index.js +1 -1
- package/dist/connect/index.cjs +1 -1
- package/dist/connect/index.d.cts +2 -2
- package/dist/connect/index.d.ts +2 -2
- package/dist/connect/index.js +1 -1
- package/dist/connect/next/index.cjs +1 -1
- package/dist/connect/next/index.d.cts +2 -2
- package/dist/connect/next/index.d.ts +2 -2
- package/dist/connect/next/index.js +1 -1
- package/dist/{connector-Bo0P3ytq.d.cts → connector-B90Jh4fv.d.cts} +98 -15
- package/dist/{connector-B2vbywn2.d.ts → connector-BXzO5Wgf.d.ts} +98 -15
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +92 -29
- package/dist/index.d.ts +92 -29
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/sbom.cdx.json +7 -7
- package/dist/chunk-O5GJ3YJV.js +0 -1
- package/dist/client-BYoo67F-.d.cts +0 -1654
- package/dist/client-BYoo67F-.d.ts +0 -1654
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ServiceId, b as
|
|
2
|
-
export {
|
|
1
|
+
import { a as ServiceId, b as SessionPersonInput, c as WebhookEnvelope, R as ReviewReason, d as SekyroEnvironment, V as VerificationLevel, e as VerificationAssurance, f as SessionOutcome, g as VerificationUnit, h as SubjectReuseMode, i as ResultRisk, j as ResultCheckProofs, k as ResultDuplicate, A as AgeMethod, l as FailureIdentification, F as FetchLike } from './client-BDULrZqs.cjs';
|
|
2
|
+
export { m as AgeResult, n as AmlMatchFlaggedEventData, o as ApiKeyIdentity, B as Block, p as BlockCheck, q as BlockCheckInput, r as BlockDuration, s as BlockIdNumber, t as BlockKind, u as BlockReason, v as BlocksApi, w as CameraUnavailableCause, x as CheckState, y as CheckType, z as ConnectorIdentity, D as CreateBlockInput, E as CreateSessionInput, C as CreatedSession, G as DEFAULT_BASE_URL, H as DEFAULT_TIMEOUT_MS, I as DecidedBy, J as DecisionReason, K as DeepPartial, M as DeletedPerson, N as DeliverOptions, O as Device, P as DevicesApi, Q as DocumentSubstitutionSettings, T as EidResult, U as EligibilityReason, X as ExtendLinkInput, Y as FlowOverridableSettings, Z as FlowOverrides, _ as FlowServiceSettings, $ as FlowSummary, a0 as FlowsApi, a1 as IdNumberReason, a2 as Identity, a3 as IdentityBirthPlace, a4 as IdentityDocument, a5 as IdentityIdNumber, a6 as IdentityMethod, a7 as IdentityName, a8 as IdentityScalarKey, a9 as IdentitySource, aa as IdentitySources, ab as LevelTarget, ac as LiftBlockInput, ad as ListBlocksQuery, ae as ListPeopleQuery, af as ListScreeningsQuery, ag as ListSessionsQuery, L as Locale, ah as MatchReason, ai as MediaBytes, aj as MediaBytesOptions, ak as MediaItem, al as MediaKind, am as MediaList, an as NameForm, ao as Page, ap as PeopleApi, aq as Person, ar as PersonBirthPlaceInput, as as PersonDeletedEventData, at as PersonDocumentInput, au as PersonEnrolledEventData, av as PersonSession, aw as PersonSessionInput, ax as PersonSessionTarget, ay as PersonSuspiciousActivityEventData, az as PersonUpdatedEventData, aA as PolicyFailureReason, aB as PortraitReportEntry, aC as PriorReviewReason, aD as ProbeBindingReason, aE as ProbeQuality, aF as ProfileDocumentType, aG as RequestOptions, aH as ResultTokenResponse, aI as ReviewOutcomeReason, aJ as RevokePersonInput, aK as ScreenPersonInput, aL as Screening, aM as ScreeningHit, aN as ScreeningHitSummary, aO as ScreeningList, aP as ScreeningStatus, aQ as ScreeningTrigger, aR as ScreeningUnavailableReason, S as Sekyro, aS as SekyroOptions, aT as Session, aU as SessionDevice, aV as SessionDeviceSignal, aW as SessionFailureReason, aX as SessionFlowRef, aY as SessionLifecycleEventData, aZ as SessionLinkDelivery, a_ as SessionLinkExpiry, a$ as SessionLinkInput, b0 as SessionNetwork, b1 as SessionNetworkEvent, b2 as SessionScreening, b3 as SessionStatus, b4 as SessionStep, b5 as SessionStepDecision, b6 as SessionSupersededEventData, b7 as SessionsApi, b8 as SimulateSessionInput, b9 as SubjectAssurance, ba as SubjectIdNumber, bb as SubjectName, bc as SubjectReferenceSource, bd as SubjectReuseTarget, be as SubjectStatus, bf as UsageThresholdReachedEventData, bg as VerifiedContacts, bh as WebhookEnvelopeOf, bi as WebhookEventDataMap, W as WebhookEventType } from './client-BDULrZqs.cjs';
|
|
3
3
|
|
|
4
4
|
/** Why {@link verifyWebhook} rejected a delivery. @public */
|
|
5
5
|
type SekyroWebhookErrorCode = "invalid_signature" | "stale" | "malformed";
|
|
@@ -21,12 +21,13 @@ declare class SekyroWebhookError extends Error {
|
|
|
21
21
|
* - `wrong_audience`: issued for another app;
|
|
22
22
|
* - `wrong_issuer`: not issued by the expected issuer;
|
|
23
23
|
* - `wrong_env`: a sandbox token when you asked for live, or the reverse;
|
|
24
|
+
* - `env_required`: `env` is missing or is not `"live"` or `"sandbox"`;
|
|
24
25
|
* - `key_env_mismatch`: the environment claim does not match the key that signed it;
|
|
25
26
|
* - `jwks_unavailable`: the public key set could not be fetched;
|
|
26
27
|
* - `invalid_options`: a missing `appId` or an unsafe `jwksUrl`.
|
|
27
28
|
* @public
|
|
28
29
|
*/
|
|
29
|
-
type SekyroResultTokenErrorCode = "invalid_token" | "expired" | "wrong_audience" | "wrong_issuer" | "wrong_env" | "key_env_mismatch" | "jwks_unavailable" | "invalid_options";
|
|
30
|
+
type SekyroResultTokenErrorCode = "invalid_token" | "expired" | "wrong_audience" | "wrong_issuer" | "wrong_env" | "env_required" | "key_env_mismatch" | "jwks_unavailable" | "invalid_options";
|
|
30
31
|
/**
|
|
31
32
|
* Thrown by {@link verifyResultToken}. Do not use the token's content.
|
|
32
33
|
* @public
|
|
@@ -40,7 +41,7 @@ declare class SekyroResultTokenError extends Error {
|
|
|
40
41
|
type SekyroConfigErrorCode = "missing_api_key" | "invalid_base_url" | "invalid_registry_record" | "registry_country_unsupported" | "registry_nationality_unmapped";
|
|
41
42
|
/**
|
|
42
43
|
* Thrown synchronously by `new Sekyro(...)` for an unusable configuration, and by
|
|
43
|
-
* {@link
|
|
44
|
+
* {@link personFromNationalRegistry} for an unusable registry answer:
|
|
44
45
|
* before any request is made. Extends `TypeError` so existing
|
|
45
46
|
* `instanceof TypeError` guards keep working.
|
|
46
47
|
* @public
|
|
@@ -61,7 +62,7 @@ declare class SekyroConfigError extends TypeError {
|
|
|
61
62
|
* result that is not a valid flow;
|
|
62
63
|
* - `override_widens_flow` (403): the override makes the flow less strict
|
|
63
64
|
* (e.g. a service turned `'off'`) and the flow does not allow widening;
|
|
64
|
-
* - `reuse_disabled` (409): `
|
|
65
|
+
* - `reuse_disabled` (409): `person.reuse` on a flow whose returning-user
|
|
65
66
|
* sessions are turned off.
|
|
66
67
|
*
|
|
67
68
|
* On `sessions.selectMethod` (a flow session's identity-method choice):
|
|
@@ -83,7 +84,7 @@ interface FlowErrorIssue {
|
|
|
83
84
|
code: string;
|
|
84
85
|
/** A short plain English sentence. */
|
|
85
86
|
message: string;
|
|
86
|
-
/** The field of your request body, e.g. `overrides.services.liveness.attempts`, `flow`, `
|
|
87
|
+
/** The field of your request body, e.g. `overrides.services.liveness.attempts`, `flow`, `person.reuse`. */
|
|
87
88
|
path?: string;
|
|
88
89
|
/** A node of your app's flow. */
|
|
89
90
|
nodeId?: string;
|
|
@@ -137,6 +138,22 @@ type SekyroFlowError<C extends SekyroFlowErrorCode = SekyroFlowErrorCode> = C ex
|
|
|
137
138
|
* @public
|
|
138
139
|
*/
|
|
139
140
|
type SekyroApiErrorCode = SekyroClientErrorCode | SekyroFlowErrorCode | (string & {});
|
|
141
|
+
/**
|
|
142
|
+
* One field the API refused, from `details.fieldErrors` of a
|
|
143
|
+
* `validation_error`. Never carries a value you sent.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
interface SekyroFieldError {
|
|
147
|
+
/**
|
|
148
|
+
* Dotted path in your request body, e.g. `person.phone`. For `unknown_field`:
|
|
149
|
+
* the object that holds the key (`?` for the top level); the key is not repeated.
|
|
150
|
+
*/
|
|
151
|
+
field: string;
|
|
152
|
+
/** The validator's issue type, e.g. `picklist` or `min_length`, or `unknown_field` for a key the API does not accept. */
|
|
153
|
+
code: string;
|
|
154
|
+
/** What the schema accepts, for a picklist or a literal, e.g. `"ar" | "fr" | "en"`. */
|
|
155
|
+
expected?: string;
|
|
156
|
+
}
|
|
140
157
|
/** Constructor input of {@link SekyroApiError}. @public */
|
|
141
158
|
interface SekyroApiErrorInit {
|
|
142
159
|
/** HTTP status; `0` when no response was received (network / timeout). */
|
|
@@ -144,7 +161,7 @@ interface SekyroApiErrorInit {
|
|
|
144
161
|
/** API error code, or `network` | `timeout` | `http_error` | `malformed_response`. */
|
|
145
162
|
code: SekyroApiErrorCode;
|
|
146
163
|
message: string;
|
|
147
|
-
/** The API's `
|
|
164
|
+
/** The API's `requestId`, when the response carried one. */
|
|
148
165
|
requestId?: string;
|
|
149
166
|
/** The API's `error.details`, when the response carried them (the flow codes: {@link SekyroFlowErrorDetailsMap}). */
|
|
150
167
|
details?: unknown;
|
|
@@ -157,8 +174,8 @@ interface SekyroApiErrorInit {
|
|
|
157
174
|
type SekyroClientErrorCode = "network" | "timeout" | "http_error" | "malformed_response";
|
|
158
175
|
/**
|
|
159
176
|
* Any failed call through {@link Sekyro}: a non-2xx partner envelope
|
|
160
|
-
* `{
|
|
161
|
-
* response, a network failure or a timeout.
|
|
177
|
+
* `{ success: false, error: { code, message, requestId, details? } }`, a
|
|
178
|
+
* non-JSON response, a network failure or a timeout.
|
|
162
179
|
*
|
|
163
180
|
* `retryable` is `true` for `network`, `timeout`, HTTP 429, HTTP 5xx and the
|
|
164
181
|
* `idempotency_in_progress` code — retry with the SAME idempotency key.
|
|
@@ -175,6 +192,11 @@ declare class SekyroApiError extends Error {
|
|
|
175
192
|
* code's documented shape ({@link SekyroFlowErrorDetailsMap}).
|
|
176
193
|
*/
|
|
177
194
|
readonly details: unknown;
|
|
195
|
+
/**
|
|
196
|
+
* The fields a `validation_error` refused, from `details.fieldErrors`;
|
|
197
|
+
* `undefined` when the response names none.
|
|
198
|
+
*/
|
|
199
|
+
readonly fieldErrors: SekyroFieldError[] | undefined;
|
|
178
200
|
readonly retryable: boolean;
|
|
179
201
|
/**
|
|
180
202
|
* Seconds to wait before retrying, from the response's `Retry-After` header
|
|
@@ -238,10 +260,10 @@ interface NationalRegistryResponses {
|
|
|
238
260
|
/** Mauritania: the ANRPTS `getPersonne` answer `{ personne, photo, datePhoto? }`. */
|
|
239
261
|
MR: AnrptsPersonneResponse;
|
|
240
262
|
}
|
|
241
|
-
/** A country {@link
|
|
263
|
+
/** A country {@link personFromNationalRegistry} can map. @public */
|
|
242
264
|
type NationalRegistryCountry = keyof NationalRegistryResponses;
|
|
243
|
-
/** Options of {@link
|
|
244
|
-
interface
|
|
265
|
+
/** Options of {@link personFromNationalRegistry}. @public */
|
|
266
|
+
interface PersonFromRegistryOptions {
|
|
245
267
|
/**
|
|
246
268
|
* When YOUR system received this answer (not "now" when you map a cached
|
|
247
269
|
* answer). Required: records older than 24 h are refused at session create.
|
|
@@ -255,21 +277,21 @@ interface SubjectFromRegistryOptions {
|
|
|
255
277
|
nationality?: string;
|
|
256
278
|
}
|
|
257
279
|
/**
|
|
258
|
-
* The `
|
|
259
|
-
* `sessions.create({
|
|
280
|
+
* The `person` keys of a reference record, ready to spread into
|
|
281
|
+
* `sessions.create({ person })`.
|
|
260
282
|
* @public
|
|
261
283
|
*/
|
|
262
|
-
type
|
|
284
|
+
type PersonRecord = Required<Pick<SessionPersonInput, "idNumber" | "birthDate" | "photo" | "fetchedAt">> & Pick<SessionPersonInput, "fullName" | "names" | "birthPlace" | "sex" | "nationalities" | "photoDate">;
|
|
263
285
|
/**
|
|
264
286
|
* Convert a national registry answer that YOUR server already received, with
|
|
265
|
-
* your own access, into the `
|
|
287
|
+
* your own access, into the `person` reference keys of `sessions.create`. A
|
|
266
288
|
* pure, local mapping: it makes no network call, and Sekyro AI never sees,
|
|
267
289
|
* receives or stores any registry key, only the record and photo you pass.
|
|
268
290
|
*
|
|
269
291
|
* ```ts
|
|
270
292
|
* const answer = await myRegistryClient.lookup(number); // your call, your key
|
|
271
293
|
* await sekyro.sessions.create({
|
|
272
|
-
*
|
|
294
|
+
* person: { externalRef, ...personFromNationalRegistry("MR", answer, { fetchedAt: receivedAt }) },
|
|
273
295
|
* });
|
|
274
296
|
* ```
|
|
275
297
|
*
|
|
@@ -282,7 +304,7 @@ type SubjectRecord = Required<Pick<SessionSubjectInput, "idNumber" | "birthDate"
|
|
|
282
304
|
* `options.nationality`; the message never carries the value).
|
|
283
305
|
* @public
|
|
284
306
|
*/
|
|
285
|
-
declare function
|
|
307
|
+
declare function personFromNationalRegistry<C extends NationalRegistryCountry>(country: C, response: NationalRegistryResponses[C], options: PersonFromRegistryOptions): PersonRecord;
|
|
286
308
|
|
|
287
309
|
/**
|
|
288
310
|
* The HTTP header carrying the webhook signature:
|
|
@@ -356,10 +378,12 @@ interface VerifyResultTokenOptions {
|
|
|
356
378
|
/** Key set URL. Default `${issuer}/.well-known/sekyro/jwks.json`. Must be `https:` (plain `http:` only on a loopback host). */
|
|
357
379
|
jwksUrl?: string;
|
|
358
380
|
/**
|
|
359
|
-
* The environment you accept
|
|
360
|
-
*
|
|
381
|
+
* The environment you accept, required: `"live"` or `"sandbox"`. A sandbox
|
|
382
|
+
* token is refused when you ask for `live` (`wrong_env`), and the reverse.
|
|
383
|
+
* Read it from your configuration, so a Sandbox token can never pass in
|
|
384
|
+
* production. A missing or other value throws `env_required`.
|
|
361
385
|
*/
|
|
362
|
-
env
|
|
386
|
+
env: SekyroEnvironment;
|
|
363
387
|
/** Custom `fetch` for the key set (tests, proxies). Default `globalThis.fetch`. */
|
|
364
388
|
fetch?: FetchLike;
|
|
365
389
|
/** Clock returning epoch milliseconds. Default `Date.now`. */
|
|
@@ -367,6 +391,24 @@ interface VerifyResultTokenOptions {
|
|
|
367
391
|
/** Allowed clock skew in seconds for `exp` / `iat`. Default 30. */
|
|
368
392
|
clockToleranceSec?: number;
|
|
369
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* The `sekyro.decision` claim, in camelCase: the human decision that settled
|
|
396
|
+
* the session (the face match's when a person decided it, else the first step
|
|
397
|
+
* a person decided). Counts and enums only, never a reviewer or a vote.
|
|
398
|
+
* @public
|
|
399
|
+
*/
|
|
400
|
+
interface ResultDecision {
|
|
401
|
+
source: "review" | "prior_review";
|
|
402
|
+
mode: "single" | "dual";
|
|
403
|
+
votes: 1 | 2 | 3;
|
|
404
|
+
/** Dual review only: whether the first two reviewers agreed. */
|
|
405
|
+
agreement?: boolean;
|
|
406
|
+
reasons: ReviewReason[];
|
|
407
|
+
/** ISO 8601. */
|
|
408
|
+
decidedAt: string;
|
|
409
|
+
/** `prior_review` only: your earlier session whose review decided this one. */
|
|
410
|
+
sessionId?: string;
|
|
411
|
+
}
|
|
370
412
|
/**
|
|
371
413
|
* The verified content of a result token, in camelCase.
|
|
372
414
|
* @public
|
|
@@ -376,9 +418,18 @@ interface VerifiedResult {
|
|
|
376
418
|
orgId: string;
|
|
377
419
|
/** The app id the token was issued for (its `aud`), one of {@link VerifyResultTokenOptions.appId}. */
|
|
378
420
|
appId: string;
|
|
379
|
-
/**
|
|
421
|
+
/**
|
|
422
|
+
* The person the session is linked to, `per_` prefixed (as `personId` on the
|
|
423
|
+
* session and on `GET /people`), once that person has passed a verification
|
|
424
|
+
* (absent before that). The token's `sub` holds the same id, bare.
|
|
425
|
+
*/
|
|
426
|
+
personId?: string;
|
|
427
|
+
/**
|
|
428
|
+
* The same person, bare (the token's `sub`).
|
|
429
|
+
* @deprecated Read {@link VerifiedResult.personId}.
|
|
430
|
+
*/
|
|
380
431
|
subjectId?: string;
|
|
381
|
-
/** Your own id for the person, from `
|
|
432
|
+
/** Your own id for the person, from `person.externalRef` at create. */
|
|
382
433
|
externalRef?: string;
|
|
383
434
|
env: SekyroEnvironment;
|
|
384
435
|
level: VerificationLevel | null;
|
|
@@ -406,6 +457,14 @@ interface VerifiedResult {
|
|
|
406
457
|
over: number;
|
|
407
458
|
method: AgeMethod;
|
|
408
459
|
};
|
|
460
|
+
/** The `sekyro.decision` claim, when a person decided a step of the session. */
|
|
461
|
+
decision?: ResultDecision;
|
|
462
|
+
/**
|
|
463
|
+
* The `sekyro.failure_identification` claim, when the setting is on and the
|
|
464
|
+
* search found a match. A signal, never a decision; `other_identity` is
|
|
465
|
+
* informational only (see {@link FailureIdentification}).
|
|
466
|
+
*/
|
|
467
|
+
failureIdentification?: FailureIdentification;
|
|
409
468
|
}
|
|
410
469
|
/**
|
|
411
470
|
* Verify a Sekyro AI result token (the `resultToken` of a terminal webhook,
|
|
@@ -414,14 +473,18 @@ interface VerifiedResult {
|
|
|
414
473
|
* Checks the ES256 signature against the public key set (fetched from
|
|
415
474
|
* `${issuer}/.well-known/sekyro/jwks.json` and cached for 10 minutes; an
|
|
416
475
|
* unknown key id fetches it again), the issuer, the audience (your app id),
|
|
417
|
-
* the expiry,
|
|
418
|
-
* (sandbox keys have ids
|
|
419
|
-
* {@link SekyroResultTokenError} otherwise; never
|
|
420
|
-
* before this resolves.
|
|
476
|
+
* the expiry, that the token is for the `env` you pass, and that its
|
|
477
|
+
* environment claim matches the key that signed it (sandbox keys have ids
|
|
478
|
+
* starting `sbx-`). Throws {@link SekyroResultTokenError} otherwise; never
|
|
479
|
+
* trust the token's content before this resolves.
|
|
421
480
|
*
|
|
422
481
|
* @example
|
|
423
482
|
* ```ts
|
|
424
|
-
*
|
|
483
|
+
* // SEKYRO_ENV is "sandbox" until go-live, then "live".
|
|
484
|
+
* const result = await verifyResultToken(token, {
|
|
485
|
+
* appId: process.env.SEKYRO_APP_ID!,
|
|
486
|
+
* env: process.env.SEKYRO_ENV as "live" | "sandbox",
|
|
487
|
+
* });
|
|
425
488
|
* if (result.outcome === "approved" && (result.level ?? 0) >= 1) {
|
|
426
489
|
* // a verified real person
|
|
427
490
|
* }
|
|
@@ -430,4 +493,4 @@ interface VerifiedResult {
|
|
|
430
493
|
*/
|
|
431
494
|
declare function verifyResultToken(token: string, opts: VerifyResultTokenOptions): Promise<VerifiedResult>;
|
|
432
495
|
|
|
433
|
-
export { AgeMethod, type AnrptsPersonneResponse, DEFAULT_RESULT_TOKEN_ISSUER, FetchLike, type FlowErrorDetails, type FlowErrorIssue, type FlowRefErrorDetails, type FlowWidensErrorDetails, LEGACY_SIGNATURE_HEADER, type NationalRegistryCountry, type NationalRegistryResponses, RESULT_TOKEN_JWKS_PATH, ResultCheckProofs, ResultDuplicate, ResultRisk, SEKYRO_SIGNATURE_HEADER, SekyroApiError, type SekyroApiErrorCode, type SekyroApiErrorInit, type SekyroClientErrorCode, SekyroConfigError, type SekyroConfigErrorCode, SekyroEnvironment, type SekyroFlowError, type SekyroFlowErrorCode, type SekyroFlowErrorDetailsMap, SekyroResultTokenError, type SekyroResultTokenErrorCode, SekyroWebhookError, type SekyroWebhookErrorCode, ServiceId, SessionOutcome,
|
|
496
|
+
export { AgeMethod, type AnrptsPersonneResponse, DEFAULT_RESULT_TOKEN_ISSUER, FailureIdentification, FetchLike, type FlowErrorDetails, type FlowErrorIssue, type FlowRefErrorDetails, type FlowWidensErrorDetails, LEGACY_SIGNATURE_HEADER, type NationalRegistryCountry, type NationalRegistryResponses, type PersonFromRegistryOptions, type PersonRecord, RESULT_TOKEN_JWKS_PATH, ResultCheckProofs, type ResultDecision, ResultDuplicate, ResultRisk, ReviewReason, SEKYRO_SIGNATURE_HEADER, SekyroApiError, type SekyroApiErrorCode, type SekyroApiErrorInit, type SekyroClientErrorCode, SekyroConfigError, type SekyroConfigErrorCode, SekyroEnvironment, type SekyroFieldError, type SekyroFlowError, type SekyroFlowErrorCode, type SekyroFlowErrorDetailsMap, SekyroResultTokenError, type SekyroResultTokenErrorCode, SekyroWebhookError, type SekyroWebhookErrorCode, ServiceId, SessionOutcome, SessionPersonInput, SubjectReuseMode, VerificationAssurance, VerificationLevel, VerificationUnit, type VerifiedResult, type VerifyResultTokenOptions, type VerifyWebhookOptions, WebhookEnvelope, isFlowError, personFromNationalRegistry, signatureFromHeaders, verifyResultToken, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ServiceId, b as
|
|
2
|
-
export {
|
|
1
|
+
import { a as ServiceId, b as SessionPersonInput, c as WebhookEnvelope, R as ReviewReason, d as SekyroEnvironment, V as VerificationLevel, e as VerificationAssurance, f as SessionOutcome, g as VerificationUnit, h as SubjectReuseMode, i as ResultRisk, j as ResultCheckProofs, k as ResultDuplicate, A as AgeMethod, l as FailureIdentification, F as FetchLike } from './client-BDULrZqs.js';
|
|
2
|
+
export { m as AgeResult, n as AmlMatchFlaggedEventData, o as ApiKeyIdentity, B as Block, p as BlockCheck, q as BlockCheckInput, r as BlockDuration, s as BlockIdNumber, t as BlockKind, u as BlockReason, v as BlocksApi, w as CameraUnavailableCause, x as CheckState, y as CheckType, z as ConnectorIdentity, D as CreateBlockInput, E as CreateSessionInput, C as CreatedSession, G as DEFAULT_BASE_URL, H as DEFAULT_TIMEOUT_MS, I as DecidedBy, J as DecisionReason, K as DeepPartial, M as DeletedPerson, N as DeliverOptions, O as Device, P as DevicesApi, Q as DocumentSubstitutionSettings, T as EidResult, U as EligibilityReason, X as ExtendLinkInput, Y as FlowOverridableSettings, Z as FlowOverrides, _ as FlowServiceSettings, $ as FlowSummary, a0 as FlowsApi, a1 as IdNumberReason, a2 as Identity, a3 as IdentityBirthPlace, a4 as IdentityDocument, a5 as IdentityIdNumber, a6 as IdentityMethod, a7 as IdentityName, a8 as IdentityScalarKey, a9 as IdentitySource, aa as IdentitySources, ab as LevelTarget, ac as LiftBlockInput, ad as ListBlocksQuery, ae as ListPeopleQuery, af as ListScreeningsQuery, ag as ListSessionsQuery, L as Locale, ah as MatchReason, ai as MediaBytes, aj as MediaBytesOptions, ak as MediaItem, al as MediaKind, am as MediaList, an as NameForm, ao as Page, ap as PeopleApi, aq as Person, ar as PersonBirthPlaceInput, as as PersonDeletedEventData, at as PersonDocumentInput, au as PersonEnrolledEventData, av as PersonSession, aw as PersonSessionInput, ax as PersonSessionTarget, ay as PersonSuspiciousActivityEventData, az as PersonUpdatedEventData, aA as PolicyFailureReason, aB as PortraitReportEntry, aC as PriorReviewReason, aD as ProbeBindingReason, aE as ProbeQuality, aF as ProfileDocumentType, aG as RequestOptions, aH as ResultTokenResponse, aI as ReviewOutcomeReason, aJ as RevokePersonInput, aK as ScreenPersonInput, aL as Screening, aM as ScreeningHit, aN as ScreeningHitSummary, aO as ScreeningList, aP as ScreeningStatus, aQ as ScreeningTrigger, aR as ScreeningUnavailableReason, S as Sekyro, aS as SekyroOptions, aT as Session, aU as SessionDevice, aV as SessionDeviceSignal, aW as SessionFailureReason, aX as SessionFlowRef, aY as SessionLifecycleEventData, aZ as SessionLinkDelivery, a_ as SessionLinkExpiry, a$ as SessionLinkInput, b0 as SessionNetwork, b1 as SessionNetworkEvent, b2 as SessionScreening, b3 as SessionStatus, b4 as SessionStep, b5 as SessionStepDecision, b6 as SessionSupersededEventData, b7 as SessionsApi, b8 as SimulateSessionInput, b9 as SubjectAssurance, ba as SubjectIdNumber, bb as SubjectName, bc as SubjectReferenceSource, bd as SubjectReuseTarget, be as SubjectStatus, bf as UsageThresholdReachedEventData, bg as VerifiedContacts, bh as WebhookEnvelopeOf, bi as WebhookEventDataMap, W as WebhookEventType } from './client-BDULrZqs.js';
|
|
3
3
|
|
|
4
4
|
/** Why {@link verifyWebhook} rejected a delivery. @public */
|
|
5
5
|
type SekyroWebhookErrorCode = "invalid_signature" | "stale" | "malformed";
|
|
@@ -21,12 +21,13 @@ declare class SekyroWebhookError extends Error {
|
|
|
21
21
|
* - `wrong_audience`: issued for another app;
|
|
22
22
|
* - `wrong_issuer`: not issued by the expected issuer;
|
|
23
23
|
* - `wrong_env`: a sandbox token when you asked for live, or the reverse;
|
|
24
|
+
* - `env_required`: `env` is missing or is not `"live"` or `"sandbox"`;
|
|
24
25
|
* - `key_env_mismatch`: the environment claim does not match the key that signed it;
|
|
25
26
|
* - `jwks_unavailable`: the public key set could not be fetched;
|
|
26
27
|
* - `invalid_options`: a missing `appId` or an unsafe `jwksUrl`.
|
|
27
28
|
* @public
|
|
28
29
|
*/
|
|
29
|
-
type SekyroResultTokenErrorCode = "invalid_token" | "expired" | "wrong_audience" | "wrong_issuer" | "wrong_env" | "key_env_mismatch" | "jwks_unavailable" | "invalid_options";
|
|
30
|
+
type SekyroResultTokenErrorCode = "invalid_token" | "expired" | "wrong_audience" | "wrong_issuer" | "wrong_env" | "env_required" | "key_env_mismatch" | "jwks_unavailable" | "invalid_options";
|
|
30
31
|
/**
|
|
31
32
|
* Thrown by {@link verifyResultToken}. Do not use the token's content.
|
|
32
33
|
* @public
|
|
@@ -40,7 +41,7 @@ declare class SekyroResultTokenError extends Error {
|
|
|
40
41
|
type SekyroConfigErrorCode = "missing_api_key" | "invalid_base_url" | "invalid_registry_record" | "registry_country_unsupported" | "registry_nationality_unmapped";
|
|
41
42
|
/**
|
|
42
43
|
* Thrown synchronously by `new Sekyro(...)` for an unusable configuration, and by
|
|
43
|
-
* {@link
|
|
44
|
+
* {@link personFromNationalRegistry} for an unusable registry answer:
|
|
44
45
|
* before any request is made. Extends `TypeError` so existing
|
|
45
46
|
* `instanceof TypeError` guards keep working.
|
|
46
47
|
* @public
|
|
@@ -61,7 +62,7 @@ declare class SekyroConfigError extends TypeError {
|
|
|
61
62
|
* result that is not a valid flow;
|
|
62
63
|
* - `override_widens_flow` (403): the override makes the flow less strict
|
|
63
64
|
* (e.g. a service turned `'off'`) and the flow does not allow widening;
|
|
64
|
-
* - `reuse_disabled` (409): `
|
|
65
|
+
* - `reuse_disabled` (409): `person.reuse` on a flow whose returning-user
|
|
65
66
|
* sessions are turned off.
|
|
66
67
|
*
|
|
67
68
|
* On `sessions.selectMethod` (a flow session's identity-method choice):
|
|
@@ -83,7 +84,7 @@ interface FlowErrorIssue {
|
|
|
83
84
|
code: string;
|
|
84
85
|
/** A short plain English sentence. */
|
|
85
86
|
message: string;
|
|
86
|
-
/** The field of your request body, e.g. `overrides.services.liveness.attempts`, `flow`, `
|
|
87
|
+
/** The field of your request body, e.g. `overrides.services.liveness.attempts`, `flow`, `person.reuse`. */
|
|
87
88
|
path?: string;
|
|
88
89
|
/** A node of your app's flow. */
|
|
89
90
|
nodeId?: string;
|
|
@@ -137,6 +138,22 @@ type SekyroFlowError<C extends SekyroFlowErrorCode = SekyroFlowErrorCode> = C ex
|
|
|
137
138
|
* @public
|
|
138
139
|
*/
|
|
139
140
|
type SekyroApiErrorCode = SekyroClientErrorCode | SekyroFlowErrorCode | (string & {});
|
|
141
|
+
/**
|
|
142
|
+
* One field the API refused, from `details.fieldErrors` of a
|
|
143
|
+
* `validation_error`. Never carries a value you sent.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
interface SekyroFieldError {
|
|
147
|
+
/**
|
|
148
|
+
* Dotted path in your request body, e.g. `person.phone`. For `unknown_field`:
|
|
149
|
+
* the object that holds the key (`?` for the top level); the key is not repeated.
|
|
150
|
+
*/
|
|
151
|
+
field: string;
|
|
152
|
+
/** The validator's issue type, e.g. `picklist` or `min_length`, or `unknown_field` for a key the API does not accept. */
|
|
153
|
+
code: string;
|
|
154
|
+
/** What the schema accepts, for a picklist or a literal, e.g. `"ar" | "fr" | "en"`. */
|
|
155
|
+
expected?: string;
|
|
156
|
+
}
|
|
140
157
|
/** Constructor input of {@link SekyroApiError}. @public */
|
|
141
158
|
interface SekyroApiErrorInit {
|
|
142
159
|
/** HTTP status; `0` when no response was received (network / timeout). */
|
|
@@ -144,7 +161,7 @@ interface SekyroApiErrorInit {
|
|
|
144
161
|
/** API error code, or `network` | `timeout` | `http_error` | `malformed_response`. */
|
|
145
162
|
code: SekyroApiErrorCode;
|
|
146
163
|
message: string;
|
|
147
|
-
/** The API's `
|
|
164
|
+
/** The API's `requestId`, when the response carried one. */
|
|
148
165
|
requestId?: string;
|
|
149
166
|
/** The API's `error.details`, when the response carried them (the flow codes: {@link SekyroFlowErrorDetailsMap}). */
|
|
150
167
|
details?: unknown;
|
|
@@ -157,8 +174,8 @@ interface SekyroApiErrorInit {
|
|
|
157
174
|
type SekyroClientErrorCode = "network" | "timeout" | "http_error" | "malformed_response";
|
|
158
175
|
/**
|
|
159
176
|
* Any failed call through {@link Sekyro}: a non-2xx partner envelope
|
|
160
|
-
* `{
|
|
161
|
-
* response, a network failure or a timeout.
|
|
177
|
+
* `{ success: false, error: { code, message, requestId, details? } }`, a
|
|
178
|
+
* non-JSON response, a network failure or a timeout.
|
|
162
179
|
*
|
|
163
180
|
* `retryable` is `true` for `network`, `timeout`, HTTP 429, HTTP 5xx and the
|
|
164
181
|
* `idempotency_in_progress` code — retry with the SAME idempotency key.
|
|
@@ -175,6 +192,11 @@ declare class SekyroApiError extends Error {
|
|
|
175
192
|
* code's documented shape ({@link SekyroFlowErrorDetailsMap}).
|
|
176
193
|
*/
|
|
177
194
|
readonly details: unknown;
|
|
195
|
+
/**
|
|
196
|
+
* The fields a `validation_error` refused, from `details.fieldErrors`;
|
|
197
|
+
* `undefined` when the response names none.
|
|
198
|
+
*/
|
|
199
|
+
readonly fieldErrors: SekyroFieldError[] | undefined;
|
|
178
200
|
readonly retryable: boolean;
|
|
179
201
|
/**
|
|
180
202
|
* Seconds to wait before retrying, from the response's `Retry-After` header
|
|
@@ -238,10 +260,10 @@ interface NationalRegistryResponses {
|
|
|
238
260
|
/** Mauritania: the ANRPTS `getPersonne` answer `{ personne, photo, datePhoto? }`. */
|
|
239
261
|
MR: AnrptsPersonneResponse;
|
|
240
262
|
}
|
|
241
|
-
/** A country {@link
|
|
263
|
+
/** A country {@link personFromNationalRegistry} can map. @public */
|
|
242
264
|
type NationalRegistryCountry = keyof NationalRegistryResponses;
|
|
243
|
-
/** Options of {@link
|
|
244
|
-
interface
|
|
265
|
+
/** Options of {@link personFromNationalRegistry}. @public */
|
|
266
|
+
interface PersonFromRegistryOptions {
|
|
245
267
|
/**
|
|
246
268
|
* When YOUR system received this answer (not "now" when you map a cached
|
|
247
269
|
* answer). Required: records older than 24 h are refused at session create.
|
|
@@ -255,21 +277,21 @@ interface SubjectFromRegistryOptions {
|
|
|
255
277
|
nationality?: string;
|
|
256
278
|
}
|
|
257
279
|
/**
|
|
258
|
-
* The `
|
|
259
|
-
* `sessions.create({
|
|
280
|
+
* The `person` keys of a reference record, ready to spread into
|
|
281
|
+
* `sessions.create({ person })`.
|
|
260
282
|
* @public
|
|
261
283
|
*/
|
|
262
|
-
type
|
|
284
|
+
type PersonRecord = Required<Pick<SessionPersonInput, "idNumber" | "birthDate" | "photo" | "fetchedAt">> & Pick<SessionPersonInput, "fullName" | "names" | "birthPlace" | "sex" | "nationalities" | "photoDate">;
|
|
263
285
|
/**
|
|
264
286
|
* Convert a national registry answer that YOUR server already received, with
|
|
265
|
-
* your own access, into the `
|
|
287
|
+
* your own access, into the `person` reference keys of `sessions.create`. A
|
|
266
288
|
* pure, local mapping: it makes no network call, and Sekyro AI never sees,
|
|
267
289
|
* receives or stores any registry key, only the record and photo you pass.
|
|
268
290
|
*
|
|
269
291
|
* ```ts
|
|
270
292
|
* const answer = await myRegistryClient.lookup(number); // your call, your key
|
|
271
293
|
* await sekyro.sessions.create({
|
|
272
|
-
*
|
|
294
|
+
* person: { externalRef, ...personFromNationalRegistry("MR", answer, { fetchedAt: receivedAt }) },
|
|
273
295
|
* });
|
|
274
296
|
* ```
|
|
275
297
|
*
|
|
@@ -282,7 +304,7 @@ type SubjectRecord = Required<Pick<SessionSubjectInput, "idNumber" | "birthDate"
|
|
|
282
304
|
* `options.nationality`; the message never carries the value).
|
|
283
305
|
* @public
|
|
284
306
|
*/
|
|
285
|
-
declare function
|
|
307
|
+
declare function personFromNationalRegistry<C extends NationalRegistryCountry>(country: C, response: NationalRegistryResponses[C], options: PersonFromRegistryOptions): PersonRecord;
|
|
286
308
|
|
|
287
309
|
/**
|
|
288
310
|
* The HTTP header carrying the webhook signature:
|
|
@@ -356,10 +378,12 @@ interface VerifyResultTokenOptions {
|
|
|
356
378
|
/** Key set URL. Default `${issuer}/.well-known/sekyro/jwks.json`. Must be `https:` (plain `http:` only on a loopback host). */
|
|
357
379
|
jwksUrl?: string;
|
|
358
380
|
/**
|
|
359
|
-
* The environment you accept
|
|
360
|
-
*
|
|
381
|
+
* The environment you accept, required: `"live"` or `"sandbox"`. A sandbox
|
|
382
|
+
* token is refused when you ask for `live` (`wrong_env`), and the reverse.
|
|
383
|
+
* Read it from your configuration, so a Sandbox token can never pass in
|
|
384
|
+
* production. A missing or other value throws `env_required`.
|
|
361
385
|
*/
|
|
362
|
-
env
|
|
386
|
+
env: SekyroEnvironment;
|
|
363
387
|
/** Custom `fetch` for the key set (tests, proxies). Default `globalThis.fetch`. */
|
|
364
388
|
fetch?: FetchLike;
|
|
365
389
|
/** Clock returning epoch milliseconds. Default `Date.now`. */
|
|
@@ -367,6 +391,24 @@ interface VerifyResultTokenOptions {
|
|
|
367
391
|
/** Allowed clock skew in seconds for `exp` / `iat`. Default 30. */
|
|
368
392
|
clockToleranceSec?: number;
|
|
369
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* The `sekyro.decision` claim, in camelCase: the human decision that settled
|
|
396
|
+
* the session (the face match's when a person decided it, else the first step
|
|
397
|
+
* a person decided). Counts and enums only, never a reviewer or a vote.
|
|
398
|
+
* @public
|
|
399
|
+
*/
|
|
400
|
+
interface ResultDecision {
|
|
401
|
+
source: "review" | "prior_review";
|
|
402
|
+
mode: "single" | "dual";
|
|
403
|
+
votes: 1 | 2 | 3;
|
|
404
|
+
/** Dual review only: whether the first two reviewers agreed. */
|
|
405
|
+
agreement?: boolean;
|
|
406
|
+
reasons: ReviewReason[];
|
|
407
|
+
/** ISO 8601. */
|
|
408
|
+
decidedAt: string;
|
|
409
|
+
/** `prior_review` only: your earlier session whose review decided this one. */
|
|
410
|
+
sessionId?: string;
|
|
411
|
+
}
|
|
370
412
|
/**
|
|
371
413
|
* The verified content of a result token, in camelCase.
|
|
372
414
|
* @public
|
|
@@ -376,9 +418,18 @@ interface VerifiedResult {
|
|
|
376
418
|
orgId: string;
|
|
377
419
|
/** The app id the token was issued for (its `aud`), one of {@link VerifyResultTokenOptions.appId}. */
|
|
378
420
|
appId: string;
|
|
379
|
-
/**
|
|
421
|
+
/**
|
|
422
|
+
* The person the session is linked to, `per_` prefixed (as `personId` on the
|
|
423
|
+
* session and on `GET /people`), once that person has passed a verification
|
|
424
|
+
* (absent before that). The token's `sub` holds the same id, bare.
|
|
425
|
+
*/
|
|
426
|
+
personId?: string;
|
|
427
|
+
/**
|
|
428
|
+
* The same person, bare (the token's `sub`).
|
|
429
|
+
* @deprecated Read {@link VerifiedResult.personId}.
|
|
430
|
+
*/
|
|
380
431
|
subjectId?: string;
|
|
381
|
-
/** Your own id for the person, from `
|
|
432
|
+
/** Your own id for the person, from `person.externalRef` at create. */
|
|
382
433
|
externalRef?: string;
|
|
383
434
|
env: SekyroEnvironment;
|
|
384
435
|
level: VerificationLevel | null;
|
|
@@ -406,6 +457,14 @@ interface VerifiedResult {
|
|
|
406
457
|
over: number;
|
|
407
458
|
method: AgeMethod;
|
|
408
459
|
};
|
|
460
|
+
/** The `sekyro.decision` claim, when a person decided a step of the session. */
|
|
461
|
+
decision?: ResultDecision;
|
|
462
|
+
/**
|
|
463
|
+
* The `sekyro.failure_identification` claim, when the setting is on and the
|
|
464
|
+
* search found a match. A signal, never a decision; `other_identity` is
|
|
465
|
+
* informational only (see {@link FailureIdentification}).
|
|
466
|
+
*/
|
|
467
|
+
failureIdentification?: FailureIdentification;
|
|
409
468
|
}
|
|
410
469
|
/**
|
|
411
470
|
* Verify a Sekyro AI result token (the `resultToken` of a terminal webhook,
|
|
@@ -414,14 +473,18 @@ interface VerifiedResult {
|
|
|
414
473
|
* Checks the ES256 signature against the public key set (fetched from
|
|
415
474
|
* `${issuer}/.well-known/sekyro/jwks.json` and cached for 10 minutes; an
|
|
416
475
|
* unknown key id fetches it again), the issuer, the audience (your app id),
|
|
417
|
-
* the expiry,
|
|
418
|
-
* (sandbox keys have ids
|
|
419
|
-
* {@link SekyroResultTokenError} otherwise; never
|
|
420
|
-
* before this resolves.
|
|
476
|
+
* the expiry, that the token is for the `env` you pass, and that its
|
|
477
|
+
* environment claim matches the key that signed it (sandbox keys have ids
|
|
478
|
+
* starting `sbx-`). Throws {@link SekyroResultTokenError} otherwise; never
|
|
479
|
+
* trust the token's content before this resolves.
|
|
421
480
|
*
|
|
422
481
|
* @example
|
|
423
482
|
* ```ts
|
|
424
|
-
*
|
|
483
|
+
* // SEKYRO_ENV is "sandbox" until go-live, then "live".
|
|
484
|
+
* const result = await verifyResultToken(token, {
|
|
485
|
+
* appId: process.env.SEKYRO_APP_ID!,
|
|
486
|
+
* env: process.env.SEKYRO_ENV as "live" | "sandbox",
|
|
487
|
+
* });
|
|
425
488
|
* if (result.outcome === "approved" && (result.level ?? 0) >= 1) {
|
|
426
489
|
* // a verified real person
|
|
427
490
|
* }
|
|
@@ -430,4 +493,4 @@ interface VerifiedResult {
|
|
|
430
493
|
*/
|
|
431
494
|
declare function verifyResultToken(token: string, opts: VerifyResultTokenOptions): Promise<VerifiedResult>;
|
|
432
495
|
|
|
433
|
-
export { AgeMethod, type AnrptsPersonneResponse, DEFAULT_RESULT_TOKEN_ISSUER, FetchLike, type FlowErrorDetails, type FlowErrorIssue, type FlowRefErrorDetails, type FlowWidensErrorDetails, LEGACY_SIGNATURE_HEADER, type NationalRegistryCountry, type NationalRegistryResponses, RESULT_TOKEN_JWKS_PATH, ResultCheckProofs, ResultDuplicate, ResultRisk, SEKYRO_SIGNATURE_HEADER, SekyroApiError, type SekyroApiErrorCode, type SekyroApiErrorInit, type SekyroClientErrorCode, SekyroConfigError, type SekyroConfigErrorCode, SekyroEnvironment, type SekyroFlowError, type SekyroFlowErrorCode, type SekyroFlowErrorDetailsMap, SekyroResultTokenError, type SekyroResultTokenErrorCode, SekyroWebhookError, type SekyroWebhookErrorCode, ServiceId, SessionOutcome,
|
|
496
|
+
export { AgeMethod, type AnrptsPersonneResponse, DEFAULT_RESULT_TOKEN_ISSUER, FailureIdentification, FetchLike, type FlowErrorDetails, type FlowErrorIssue, type FlowRefErrorDetails, type FlowWidensErrorDetails, LEGACY_SIGNATURE_HEADER, type NationalRegistryCountry, type NationalRegistryResponses, type PersonFromRegistryOptions, type PersonRecord, RESULT_TOKEN_JWKS_PATH, ResultCheckProofs, type ResultDecision, ResultDuplicate, ResultRisk, ReviewReason, SEKYRO_SIGNATURE_HEADER, SekyroApiError, type SekyroApiErrorCode, type SekyroApiErrorInit, type SekyroClientErrorCode, SekyroConfigError, type SekyroConfigErrorCode, SekyroEnvironment, type SekyroFieldError, type SekyroFlowError, type SekyroFlowErrorCode, type SekyroFlowErrorDetailsMap, SekyroResultTokenError, type SekyroResultTokenErrorCode, SekyroWebhookError, type SekyroWebhookErrorCode, ServiceId, SessionOutcome, SessionPersonInput, SubjectReuseMode, VerificationAssurance, VerificationLevel, VerificationUnit, type VerifiedResult, type VerifyResultTokenOptions, type VerifyWebhookOptions, WebhookEnvelope, isFlowError, personFromNationalRegistry, signatureFromHeaders, verifyResultToken, verifyWebhook };
|