@splitin/verification-adapter-sdk 0.1.0-beta.0

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.
@@ -0,0 +1,388 @@
1
+ /** Public adapter contract version. Npm package versions remain 0.1.x-beta until sandbox certification. */
2
+ declare const VERIFICATION_ADAPTER_CONTRACT_VERSION: "1.0.0";
3
+ declare const ENGINE_CONTRACT_VERSION: "1.0.0";
4
+ declare const PROVIDER_MANIFEST_SCHEMA_URN = "urn:splitin:verification:provider-manifest:v1";
5
+ declare const STANDARD_PACKAGE_CODES: readonly ["human_idv", "business_kyb", "associated_person_idv", "ownership_review"];
6
+ type StandardPackageCode = (typeof STANDARD_PACKAGE_CODES)[number];
7
+ declare const STANDARD_WEBHOOK_PROTOCOLS: readonly ["none", "stripe_v1_hmac", "persona_hmac_sha256", "plaid_es256_jwk"];
8
+ type StandardWebhookProtocol = (typeof STANDARD_WEBHOOK_PROTOCOLS)[number];
9
+ declare const CANONICAL_STATUSES: readonly ["created", "pending_user_input", "paused", "processing", "manual_review_required", "verified", "declined", "failed", "expired", "canceled", "provider_unavailable", "redacted"];
10
+ type VerificationCanonicalStatus = (typeof CANONICAL_STATUSES)[number];
11
+ declare const TERMINAL_STATUSES: readonly ["verified", "declined", "failed", "expired", "canceled", "redacted"];
12
+ type TerminalVerificationStatus = (typeof TERMINAL_STATUSES)[number];
13
+ declare const LAUNCH_PRESENTATIONS: readonly ["embedded", "hosted", "qr", "none"];
14
+ type VerificationLaunchPresentation = (typeof LAUNCH_PRESENTATIONS)[number];
15
+ declare const PROVIDER_ENVIRONMENTS: readonly ["sandbox", "production"];
16
+ type VerificationProviderEnvironment = (typeof PROVIDER_ENVIRONMENTS)[number];
17
+ declare const PROVIDER_OPERATIONS: readonly ["create", "resume", "retrieve", "retry", "cancel", "redact", "webhook_verify", "webhook_normalize", "health"];
18
+ type ProviderOperation = (typeof PROVIDER_OPERATIONS)[number];
19
+ declare const STANDARD_RELATIONSHIP_KINDS: readonly ["ubo", "director", "officer", "authorized_representative", "associated_person"];
20
+ type StandardRelationshipKind = (typeof STANDARD_RELATIONSHIP_KINDS)[number];
21
+ /** Standard codes or namespaced custom codes such as `com.example.employee_check`. */
22
+ type VerificationPackageCode = StandardPackageCode | (string & {});
23
+ type WebhookProtocolId = StandardWebhookProtocol | (string & {});
24
+ type ProviderResourceType = string;
25
+ type VerificationProviderCode = string;
26
+ type VerificationLauncherKey = string;
27
+ declare function isProviderCode(value: string): boolean;
28
+ declare function isLauncherKey(value: string): boolean;
29
+ declare function isStandardPackageCode(value: string): value is StandardPackageCode;
30
+ declare function isCustomPackageCode(value: string): boolean;
31
+ declare function isPackageCode(value: string): value is VerificationPackageCode;
32
+ declare function assertPackageCode(value: string): VerificationPackageCode;
33
+ declare function isWebhookProtocol(value: string): value is WebhookProtocolId;
34
+ declare function isResourceType(value: string): value is ProviderResourceType;
35
+ declare function isCountryCode(value: string): boolean;
36
+ declare function isSemver(value: string): boolean;
37
+ declare function isCanonicalStatus(value: string): value is VerificationCanonicalStatus;
38
+ declare function isTerminalStatus(value: string): value is TerminalVerificationStatus;
39
+ declare function isOpaqueSubjectReference(value: string): boolean;
40
+ declare function metadataContainsForbiddenIdentifier(value: unknown): boolean;
41
+ declare function compareSemver(left: string, right: string): number;
42
+ declare function majorsCompatible(left: string, right: string): boolean;
43
+
44
+ type ProviderErrorCode = 'INVALID_CONFIGURATION' | 'UNSUPPORTED_CAPABILITY' | 'AUTHENTICATION_FAILED' | 'SIGNATURE_INVALID' | 'RATE_LIMITED' | 'TIMEOUT' | 'RETRYABLE_PROVIDER_FAILURE' | 'TERMINAL_INPUT_FAILURE' | 'UNKNOWN_PROVIDER_STATE' | 'PROVIDER_UNAVAILABLE';
45
+ interface ProviderErrorOptions {
46
+ retryable?: boolean;
47
+ safeCode?: string;
48
+ retryAfterSeconds?: number;
49
+ cause?: unknown;
50
+ }
51
+ /** Provider-safe error. Message and fields must never contain PII or secrets. */
52
+ declare class ProviderError extends Error {
53
+ readonly code: ProviderErrorCode;
54
+ readonly retryable: boolean;
55
+ readonly safeCode: string;
56
+ readonly retryAfterSeconds?: number;
57
+ constructor(code: ProviderErrorCode, message: string, options?: ProviderErrorOptions);
58
+ }
59
+ declare class ProviderUnavailableError extends ProviderError {
60
+ constructor(message?: string, options?: ProviderErrorOptions);
61
+ }
62
+ declare class ProviderOperationPendingError extends ProviderError {
63
+ constructor(message?: string);
64
+ }
65
+ declare class VerificationAttemptLimitError extends ProviderError {
66
+ constructor(retryAfterSeconds: number);
67
+ }
68
+ declare class ProviderRequiredInformationError extends ProviderError {
69
+ constructor(message?: string);
70
+ }
71
+ interface SafeProviderFailure {
72
+ code: ProviderErrorCode;
73
+ safeCode: string;
74
+ retryable: boolean;
75
+ retryAfterSeconds?: number;
76
+ }
77
+ declare function toSafeProviderFailure(error: unknown): SafeProviderFailure;
78
+
79
+ interface ProviderCapabilities {
80
+ presentations: VerificationLaunchPresentation[];
81
+ canResume: boolean;
82
+ canRetry: boolean;
83
+ canCancel: boolean;
84
+ canRedact: boolean;
85
+ }
86
+ interface JsonSchema2020 {
87
+ $schema?: string;
88
+ $id?: string;
89
+ type?: string | string[];
90
+ title?: string;
91
+ description?: string;
92
+ const?: unknown;
93
+ enum?: unknown[];
94
+ required?: string[];
95
+ additionalProperties?: boolean | JsonSchema2020;
96
+ properties?: Record<string, JsonSchema2020>;
97
+ items?: JsonSchema2020 | JsonSchema2020[];
98
+ minLength?: number;
99
+ maxLength?: number;
100
+ minimum?: number;
101
+ maximum?: number;
102
+ minItems?: number;
103
+ uniqueItems?: boolean;
104
+ pattern?: string;
105
+ format?: string;
106
+ 'x-secret'?: boolean;
107
+ [key: string]: unknown;
108
+ }
109
+ interface ProviderConfigurationSchemaV1 extends JsonSchema2020 {
110
+ $schema: 'https://json-schema.org/draft/2020-12/schema';
111
+ type: 'object';
112
+ additionalProperties: false;
113
+ required: string[];
114
+ properties: Record<string, JsonSchema2020>;
115
+ }
116
+ interface ProviderManifestV1 {
117
+ contractVersion: typeof VERIFICATION_ADAPTER_CONTRACT_VERSION;
118
+ adapterVersion: string;
119
+ engineCompatibility: string;
120
+ provider: VerificationProviderCode;
121
+ displayName: string;
122
+ description?: string;
123
+ supportedPackages: VerificationPackageCode[];
124
+ supportedCountries: string[];
125
+ environments: VerificationProviderEnvironment[];
126
+ capabilities: ProviderCapabilities;
127
+ launcherKeys: string[];
128
+ launchPresentations: VerificationLaunchPresentation[];
129
+ configurationSchemaVersion: string;
130
+ configurationSchema: ProviderConfigurationSchemaV1;
131
+ webhook: {
132
+ protocol: WebhookProtocolId;
133
+ eventFamilies: string[];
134
+ toleranceSeconds?: number;
135
+ };
136
+ dataPolicy: {
137
+ classifications: string[];
138
+ prohibitedPersistence: string[];
139
+ rawPayloadPersistence: false;
140
+ browserSecretPersistence: false;
141
+ governmentIdentifierPersistence: false;
142
+ };
143
+ retry: {
144
+ sameResourceWhenResumable: boolean;
145
+ newAttemptAfterTerminal: boolean;
146
+ };
147
+ cancellation: {
148
+ supported: boolean;
149
+ terminal: boolean;
150
+ };
151
+ redaction: {
152
+ supported: boolean;
153
+ asynchronous: boolean;
154
+ notApplicable?: boolean;
155
+ };
156
+ apiHosts: string[];
157
+ testedApiVersions: string[];
158
+ }
159
+ interface ProviderSafeLogger {
160
+ info(event: string, metadata?: Record<string, string | number | boolean | null>): void;
161
+ warn(event: string, metadata?: Record<string, string | number | boolean | null>): void;
162
+ error(event: string, metadata?: Record<string, string | number | boolean | null>): void;
163
+ }
164
+ interface ProviderHealthObservation {
165
+ operation: ProviderOperation;
166
+ outcome: 'success' | 'retryable_failure' | 'terminal_failure' | 'unknown_status';
167
+ safeCode: string;
168
+ observedAt: string;
169
+ latencyMs?: number;
170
+ }
171
+ interface TraceSpan {
172
+ name: string;
173
+ attributes?: Record<string, string | number | boolean>;
174
+ }
175
+ interface OpenTelemetryHooks {
176
+ counter?(name: string, value: number, attributes?: Record<string, string>): void;
177
+ histogram?(name: string, value: number, attributes?: Record<string, string>): void;
178
+ startSpan?(span: TraceSpan): {
179
+ end(): void;
180
+ };
181
+ }
182
+ interface ProviderRateBudget {
183
+ acquire(operation: ProviderOperation): Promise<{
184
+ allowed: boolean;
185
+ retryAfterSeconds?: number;
186
+ }>;
187
+ }
188
+ interface ProviderHttpClient {
189
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
190
+ }
191
+ interface ProviderRuntimeContext<TConfiguration extends object = Record<string, unknown>> {
192
+ environment: VerificationProviderEnvironment;
193
+ configuration: Readonly<TConfiguration>;
194
+ http: ProviderHttpClient;
195
+ now: () => Date;
196
+ crypto: Crypto;
197
+ idempotency: {
198
+ keyFor(operation: ProviderOperation, attemptId: string, suppliedKey?: string): string;
199
+ };
200
+ logger: ProviderSafeLogger;
201
+ telemetry?: OpenTelemetryHooks;
202
+ recordHealth: (observation: ProviderHealthObservation) => Promise<void>;
203
+ rateBudget?: ProviderRateBudget;
204
+ }
205
+ interface ProviderAddressInput {
206
+ street1: string;
207
+ street2?: string | null;
208
+ city: string;
209
+ subdivision?: string | null;
210
+ postalCode: string;
211
+ countryCode: string;
212
+ }
213
+ interface ProviderAssociatedPersonInput {
214
+ subjectReference: string;
215
+ legalFirstName: string;
216
+ legalLastName: string;
217
+ email?: string | null;
218
+ relationshipKind: string;
219
+ claimedOwnershipPercentage?: number | null;
220
+ }
221
+ interface ProviderOrganizationInput {
222
+ legalName: string;
223
+ jurisdictionCountryCode: string;
224
+ entityType?: string | null;
225
+ registeredAddress?: ProviderAddressInput | null;
226
+ physicalAddress?: ProviderAddressInput | null;
227
+ associatedPeople?: ProviderAssociatedPersonInput[];
228
+ evidenceReferences?: string[];
229
+ }
230
+ interface ProviderRelationshipInput {
231
+ relationshipReference: string;
232
+ kind: string;
233
+ claimedOwnershipPercentage?: number | null;
234
+ subjectReference?: string | null;
235
+ }
236
+ interface ProviderAttemptCommand {
237
+ attemptId: string;
238
+ subjectReference: string;
239
+ organizationReference?: string | null;
240
+ packageCode: VerificationPackageCode;
241
+ countryCode: string;
242
+ idempotencyKey: string;
243
+ configurationRevision: string;
244
+ legalFirstName?: string | null;
245
+ legalLastName?: string | null;
246
+ email?: string | null;
247
+ organization?: ProviderOrganizationInput | null;
248
+ relationship?: ProviderRelationshipInput | null;
249
+ associatedPerson?: ProviderAssociatedPersonInput | null;
250
+ evidenceReferences?: string[];
251
+ requestOrigin?: string | null;
252
+ metadata?: Record<string, string | number | boolean | null>;
253
+ }
254
+ interface ProviderResumeCommand {
255
+ attemptId: string;
256
+ providerResourceId: string;
257
+ configurationRevision: string;
258
+ requestOrigin?: string | null;
259
+ }
260
+ interface ProviderRetryCommand extends ProviderAttemptCommand {
261
+ previousProviderResourceId?: string | null;
262
+ }
263
+ interface ProviderResourceCommand {
264
+ attemptId: string;
265
+ providerResourceId: string;
266
+ configurationRevision: string;
267
+ requestOrigin?: string | null;
268
+ }
269
+ interface ProviderRedactionCommand {
270
+ subjectReference: string;
271
+ providerResourceId?: string | null;
272
+ providerResourceType?: string;
273
+ requestReference: string;
274
+ }
275
+ interface ProviderLaunchEnvelope {
276
+ attemptId: string;
277
+ canonicalStatus: VerificationCanonicalStatus;
278
+ launcherKey: string;
279
+ presentation: VerificationLaunchPresentation;
280
+ providerDisclosure?: string;
281
+ transientSecret?: string;
282
+ transientSecretExpiresAt?: string;
283
+ hostedUrl?: string;
284
+ hostedFallbackExpiresAt?: string;
285
+ safeErrorCode?: string | null;
286
+ retryAfter?: string | null;
287
+ supportPath?: string | null;
288
+ continuationReference?: string;
289
+ }
290
+ interface ProviderAttemptResult {
291
+ attemptId: string;
292
+ providerResourceId: string;
293
+ providerStatus: string;
294
+ canonicalStatus: VerificationCanonicalStatus;
295
+ launch: ProviderLaunchEnvelope;
296
+ linkedResources?: Array<{
297
+ resourceType: string;
298
+ resourceId: string;
299
+ relationshipCode: string;
300
+ providerStatus: string;
301
+ occurredAt: string;
302
+ }>;
303
+ }
304
+ interface NormalizedProviderSnapshot {
305
+ providerResourceId: string;
306
+ providerStatus: string;
307
+ canonicalStatus: VerificationCanonicalStatus;
308
+ occurredAt: string;
309
+ providerCreatedAt?: string;
310
+ normalizedReasonCodes: string[];
311
+ safeMetadata: Record<string, string | boolean | number | null>;
312
+ }
313
+ interface ProviderOperationResult {
314
+ accepted: boolean;
315
+ providerStatus?: string;
316
+ canonicalStatus?: VerificationCanonicalStatus;
317
+ }
318
+ interface ProviderRedactionResult {
319
+ completed: boolean;
320
+ retryable: boolean;
321
+ disposition?: 'scheduled' | 'processing' | 'retryable' | 'redacted' | 'not_applicable' | 'dead_letter' | 'failed';
322
+ }
323
+ interface VerifiedWebhookEnvelope {
324
+ providerEventKey: string;
325
+ receivedAt: string;
326
+ bodySha256: string;
327
+ signatureIssuedAt?: string;
328
+ opaquePayload: Uint8Array;
329
+ }
330
+ interface NormalizedProviderEvent {
331
+ providerEventKey: string;
332
+ providerResourceId: string;
333
+ eventType: string;
334
+ providerEventType: string;
335
+ canonicalStatus?: VerificationCanonicalStatus;
336
+ occurredAt: string;
337
+ normalizedReasonCodes: string[];
338
+ safeMetadata: Record<string, string | boolean | number | null>;
339
+ }
340
+ /**
341
+ * Provider-neutral verification adapter. The engine owns reconciliation,
342
+ * queues, routing, attempts, decisions and protected-action enforcement.
343
+ */
344
+ interface VerificationAdapterV1<TConfig extends object = Record<string, unknown>> {
345
+ readonly contractVersion: typeof VERIFICATION_ADAPTER_CONTRACT_VERSION;
346
+ readonly manifest: ProviderManifestV1;
347
+ readonly provider: VerificationProviderCode;
348
+ readonly environment: VerificationProviderEnvironment;
349
+ readonly runtime: ProviderRuntimeContext<TConfig>;
350
+ validateConfiguration(): void;
351
+ createAttempt(command: ProviderAttemptCommand): Promise<ProviderAttemptResult>;
352
+ resumeAttempt(command: ProviderResumeCommand): Promise<ProviderLaunchEnvelope>;
353
+ retrieveAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;
354
+ retryAttempt(command: ProviderRetryCommand): Promise<ProviderAttemptResult>;
355
+ cancelAttempt(command: ProviderResourceCommand): Promise<ProviderOperationResult>;
356
+ redactSubject(command: ProviderRedactionCommand): Promise<ProviderRedactionResult>;
357
+ verifyWebhook(input: Request): Promise<VerifiedWebhookEnvelope>;
358
+ normalizeWebhook(input: VerifiedWebhookEnvelope): Promise<NormalizedProviderEvent>;
359
+ }
360
+ interface ActorContext {
361
+ tenantKey: string;
362
+ actorId: string;
363
+ actorType: 'user' | 'operator' | 'system';
364
+ roles: string[];
365
+ authorizedSubjectScope: string[];
366
+ }
367
+ interface ProtectedActionDenial {
368
+ code: 'VERIFICATION_REQUIRED';
369
+ action: string;
370
+ resourceHash: string;
371
+ requiredPackages: VerificationPackageCode[];
372
+ continuation: {
373
+ key: string;
374
+ token: string;
375
+ expiresAt: string;
376
+ };
377
+ retryAfter: string | null;
378
+ supportPath: string | null;
379
+ }
380
+ interface SafeProviderFailureEnvelope {
381
+ code: ProviderErrorCode;
382
+ safeCode: string;
383
+ retryable: boolean;
384
+ retryAfterSeconds?: number;
385
+ supportPath?: string | null;
386
+ }
387
+
388
+ export { VERIFICATION_ADAPTER_CONTRACT_VERSION as $, type ActorContext as A, ProviderRequiredInformationError as B, CANONICAL_STATUSES as C, type ProviderResourceCommand as D, ENGINE_CONTRACT_VERSION as E, type ProviderResourceType as F, type ProviderResumeCommand as G, type ProviderRetryCommand as H, type ProviderSafeLogger as I, type JsonSchema2020 as J, ProviderUnavailableError as K, LAUNCH_PRESENTATIONS as L, STANDARD_RELATIONSHIP_KINDS as M, type NormalizedProviderEvent as N, type OpenTelemetryHooks as O, type ProviderConfigurationSchemaV1 as P, STANDARD_WEBHOOK_PROTOCOLS as Q, type SafeProviderFailure as R, STANDARD_PACKAGE_CODES as S, type SafeProviderFailureEnvelope as T, type StandardPackageCode as U, type VerificationAdapterV1 as V, type StandardRelationshipKind as W, type StandardWebhookProtocol as X, TERMINAL_STATUSES as Y, type TerminalVerificationStatus as Z, type TraceSpan as _, type ProviderManifestV1 as a, VerificationAttemptLimitError as a0, type VerificationCanonicalStatus as a1, type VerificationLaunchPresentation as a2, type VerificationLauncherKey as a3, type VerificationPackageCode as a4, type VerificationProviderCode as a5, type VerificationProviderEnvironment as a6, type VerifiedWebhookEnvelope as a7, type WebhookProtocolId as a8, assertPackageCode as a9, compareSemver as aa, isCanonicalStatus as ab, isCountryCode as ac, isCustomPackageCode as ad, isLauncherKey as ae, isOpaqueSubjectReference as af, isPackageCode as ag, isProviderCode as ah, isResourceType as ai, isSemver as aj, isStandardPackageCode as ak, isTerminalStatus as al, isWebhookProtocol as am, majorsCompatible as an, metadataContainsForbiddenIdentifier as ao, toSafeProviderFailure as ap, type ProviderRuntimeContext as b, type NormalizedProviderSnapshot as c, PROVIDER_ENVIRONMENTS as d, PROVIDER_MANIFEST_SCHEMA_URN as e, PROVIDER_OPERATIONS as f, type ProtectedActionDenial as g, type ProviderAddressInput as h, type ProviderAssociatedPersonInput as i, type ProviderAttemptCommand as j, type ProviderAttemptResult as k, type ProviderCapabilities as l, ProviderError as m, type ProviderErrorCode as n, type ProviderErrorOptions as o, type ProviderHealthObservation as p, type ProviderHttpClient as q, type ProviderLaunchEnvelope as r, type ProviderOperation as s, ProviderOperationPendingError as t, type ProviderOperationResult as u, type ProviderOrganizationInput as v, type ProviderRateBudget as w, type ProviderRedactionCommand as x, type ProviderRedactionResult as y, type ProviderRelationshipInput as z };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts-5VqcOmjU.d.ts","sources":["contracts-5VqcOmjU.d.ts"],"names":[],"mappings":"AAAA"}