@splitin/verification-compat-splitin-v2 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SplitInTech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,32 @@
1
+ Verification Adapter SDK
2
+ Copyright (c) 2026 SplitInTech
3
+
4
+ This product is licensed under the MIT License. See LICENSE.
5
+
6
+ Third-party notices
7
+ ===================
8
+
9
+ This project redistributes no vendor identity SDKs in its core or server
10
+ packages. Optional peer dependencies used by browser plugins:
11
+
12
+ - `@stripe/stripe-js` — Stripe, Inc. (MIT). Used only by the Stripe Identity
13
+ browser plugin via dynamic import. Stripe is a trademark of Stripe, Inc.
14
+ - `persona` — Persona Identities, Inc. Used only by the Persona browser plugin
15
+ via dynamic import.
16
+ - `react-plaid-link` — Plaid Inc. (MIT). Used only by the Plaid Identity
17
+ Verification browser plugin via dynamic import. Plaid is a trademark of
18
+ Plaid Inc.
19
+
20
+ Server adapters speak HTTPS to provider APIs with an injected Fetch
21
+ implementation. They do not bundle Stripe, Persona, or Plaid Node SDKs.
22
+
23
+ Runtime and tooling (declared in package.json; not vendored):
24
+
25
+ - `ajv` — MIT
26
+ - `jose` — MIT (Plaid webhook JWT verification)
27
+ - `pg` — MIT (optional PostgreSQL executor)
28
+ - TypeScript, tsup, vitest, Changesets — Apache-2.0 / MIT as published by
29
+ their authors
30
+
31
+ This project provides engineering primitives. It is not a legal, KYC, KYB, or
32
+ regulatory compliance certification.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @splitin/verification-compat-splitin-v2
2
+
3
+ Temporary mapping between the **public Verification Adapter V1** contract and
4
+ SplitIn's **internal V2** adapter surface.
5
+
6
+ This package is a bridge. **Do not change SplitIn application or SDK code to
7
+ consume it today.** SplitIn will later pin public npm packages
8
+ (`@splitin/verification-adapter-sdk` and friends) and delete this compatibility
9
+ layer.
10
+
11
+ ## Why this exists
12
+
13
+ The open-source V1 contract renamed and removed SplitIn-specific fields:
14
+
15
+ | Internal SplitIn V2 | Public V1 |
16
+ | --- | --- |
17
+ | `requestRetry` | `retryAttempt` |
18
+ | `reconcileAttempt` | Engine-owned. V1 adapters expose `retrieveAttempt` only |
19
+ | `inquiryOrSessionId` | `continuationReference` |
20
+ | `environmentId` | Runtime `environment`, not a launch field |
21
+ | `opaqueLaunchSecret` | `transientSecret` |
22
+ | `metadata.splitin_attempt_id` | Opaque `attempt_id` |
23
+ | `splitin.verification.required.v2` | `VERIFICATION_REQUIRED` |
24
+ | `webhook.authentication` / `eventTypes` | `webhook.protocol` / `eventFamilies` |
25
+ | Canonical statuses without `redacted` | V1 adds `redacted`; maps to V2 `canceled` plus metadata |
26
+
27
+ ## Future upstream migration
28
+
29
+ 1. SplitIn keeps shipping its internal V2 adapters.
30
+ 2. This package documents the field map and hosts parity fixtures derived from
31
+ non-sensitive fake-provider behavior.
32
+ 3. After sandbox certification of public `1.0.0`, SplitIn will switch its
33
+ composition root to the pinned public packages.
34
+ 4. This package is then deprecated and removed. **No SplitIn import lands now.**
35
+
36
+ ## License
37
+
38
+ MIT. See [LICENSE](LICENSE).
package/dist/index.cjs ADDED
@@ -0,0 +1,186 @@
1
+ 'use strict';
2
+
3
+ // src/index.ts
4
+ var SPLITIN_V2_CONTRACT_VERSION = "2.0.0";
5
+ var V1_PROTECTED_ACTION_CODE = "VERIFICATION_REQUIRED";
6
+ var V2_PROTECTED_ACTION_CONTRACT = "splitin.verification.required.v2";
7
+ var METHOD_MAP = {
8
+ requestRetry: "retryAttempt",
9
+ retryAttempt: "requestRetry",
10
+ reconcileAttempt: "engineOwned",
11
+ retrieveAttempt: "retrieveAttempt"
12
+ };
13
+ var LAUNCH_ALIAS_MAP = {
14
+ inquiryOrSessionId: "continuationReference",
15
+ environmentId: "runtimeEnvironment",
16
+ opaqueLaunchSecret: "transientSecret",
17
+ transientSecret: "opaqueLaunchSecret",
18
+ continuationReference: "inquiryOrSessionId"
19
+ };
20
+ var WEBHOOK_PROTOCOL_MAP = {
21
+ stripe_v1_hmac: "stripe_v1_hmac",
22
+ persona_hmac_sha256: "persona_hmac_sha256",
23
+ plaid_es256_jwk: "plaid_es256_jwk",
24
+ none: "none"
25
+ };
26
+ var PACKAGE_CODE_MAP = {
27
+ human_idv: "human_idv",
28
+ business_kyb: "business_kyb",
29
+ associated_person_idv: "associated_person_idv",
30
+ ownership_review: "ownership_review"
31
+ };
32
+ function mapStatusV1ToV2(status) {
33
+ if (status === "redacted") return "canceled";
34
+ return status;
35
+ }
36
+ function mapStatusV2ToV1(status, redacted = false) {
37
+ return redacted ? "redacted" : status;
38
+ }
39
+ function mapWebhookProtocolV1ToV2(protocol) {
40
+ return WEBHOOK_PROTOCOL_MAP[protocol] ?? protocol;
41
+ }
42
+ function mapWebhookProtocolV2ToV1(authentication) {
43
+ return WEBHOOK_PROTOCOL_MAP[authentication] ?? authentication;
44
+ }
45
+ function toV2ProtectedActionContract(code) {
46
+ return code === V1_PROTECTED_ACTION_CODE ? V2_PROTECTED_ACTION_CONTRACT : code;
47
+ }
48
+ function toV1ProtectedActionCode(contract) {
49
+ return contract === V2_PROTECTED_ACTION_CONTRACT ? V1_PROTECTED_ACTION_CODE : contract;
50
+ }
51
+ var SPLITIN_META = /^splitin_/;
52
+ function metadataV2ToV1(metadata) {
53
+ const output = {};
54
+ for (const [key, value] of Object.entries(metadata ?? {})) {
55
+ if (key === "splitin_attempt_id") {
56
+ output.attempt_id = value;
57
+ continue;
58
+ }
59
+ if (SPLITIN_META.test(key)) {
60
+ output[key.replace(SPLITIN_META, "")] = value;
61
+ continue;
62
+ }
63
+ output[key] = value;
64
+ }
65
+ return output;
66
+ }
67
+ function metadataV1ToV2(metadata, attemptId) {
68
+ const output = { ...metadata ?? {} };
69
+ const opaqueAttempt = metadata?.attempt_id ?? attemptId ?? null;
70
+ if (opaqueAttempt != null) output.splitin_attempt_id = opaqueAttempt;
71
+ return output;
72
+ }
73
+ function launchV1ToV2(launch, environment) {
74
+ return {
75
+ presentation: launch.presentation,
76
+ launcherKey: launch.launcherKey,
77
+ adapter: launch.launcherKey,
78
+ inquiryOrSessionId: launch.continuationReference,
79
+ environmentId: environment,
80
+ transientSecret: launch.transientSecret,
81
+ transientSecretExpiresAt: launch.transientSecretExpiresAt,
82
+ opaqueLaunchSecret: launch.transientSecret,
83
+ hostedUrl: launch.hostedUrl,
84
+ hostedFallbackExpiresAt: launch.hostedFallbackExpiresAt,
85
+ expiresAt: launch.transientSecretExpiresAt ?? launch.hostedFallbackExpiresAt,
86
+ providerDisclosure: launch.providerDisclosure
87
+ };
88
+ }
89
+ function launchV2ToV1(launch, attemptId) {
90
+ return {
91
+ attemptId,
92
+ canonicalStatus: "pending_user_input",
93
+ launcherKey: launch.launcherKey,
94
+ presentation: launch.presentation,
95
+ providerDisclosure: launch.providerDisclosure,
96
+ transientSecret: launch.transientSecret ?? launch.opaqueLaunchSecret,
97
+ transientSecretExpiresAt: launch.transientSecretExpiresAt ?? launch.expiresAt,
98
+ hostedUrl: launch.hostedUrl,
99
+ hostedFallbackExpiresAt: launch.hostedFallbackExpiresAt,
100
+ continuationReference: launch.inquiryOrSessionId
101
+ };
102
+ }
103
+ function attemptCommandV2ToV1(command, countryCode = "US") {
104
+ return {
105
+ attemptId: command.attemptId,
106
+ subjectReference: command.subjectReference ?? command.humanSubjectReference,
107
+ packageCode: command.packageCode,
108
+ countryCode,
109
+ idempotencyKey: command.idempotencyKey,
110
+ configurationRevision: command.providerConfigReference,
111
+ legalFirstName: command.legalFirstName,
112
+ legalLastName: command.legalLastName,
113
+ email: command.email,
114
+ requestOrigin: command.requestOrigin,
115
+ metadata: metadataV2ToV1(command.metadata)
116
+ };
117
+ }
118
+ function attemptCommandV1ToV2(command) {
119
+ return {
120
+ attemptId: command.attemptId,
121
+ humanSubjectReference: command.subjectReference,
122
+ subjectReference: command.subjectReference,
123
+ packageCode: command.packageCode,
124
+ idempotencyKey: command.idempotencyKey,
125
+ providerConfigReference: command.configurationRevision,
126
+ legalFirstName: command.legalFirstName,
127
+ legalLastName: command.legalLastName,
128
+ email: command.email,
129
+ requestOrigin: command.requestOrigin,
130
+ metadata: metadataV1ToV2(command.metadata, command.attemptId)
131
+ };
132
+ }
133
+ function wrapV1AdapterForSplitInV2(adapter) {
134
+ return {
135
+ requestRetry: (command) => adapter.retryAttempt(command),
136
+ retrieveAttempt: (command) => adapter.retrieveAttempt(command),
137
+ reconcileAttempt: async (command) => {
138
+ const snapshot = await adapter.retrieveAttempt(command);
139
+ return {
140
+ ...snapshot,
141
+ canonicalStatus: mapStatusV1ToV2(snapshot.canonicalStatus),
142
+ safeMetadata: metadataV1ToV2(snapshot.safeMetadata, command.attemptId)
143
+ };
144
+ }
145
+ };
146
+ }
147
+ function mapManifestWebhookV1ToV2(manifest) {
148
+ return {
149
+ authentication: mapWebhookProtocolV1ToV2(manifest.webhook.protocol),
150
+ eventTypes: manifest.webhook.eventFamilies,
151
+ toleranceSeconds: manifest.webhook.toleranceSeconds
152
+ };
153
+ }
154
+ function mapRedactionCommandV2ToV1(command) {
155
+ return {
156
+ subjectReference: command.subjectReference,
157
+ providerResourceId: command.providerResourceId,
158
+ providerResourceType: command.providerResourceType,
159
+ requestReference: command.requestReference
160
+ };
161
+ }
162
+
163
+ exports.LAUNCH_ALIAS_MAP = LAUNCH_ALIAS_MAP;
164
+ exports.METHOD_MAP = METHOD_MAP;
165
+ exports.PACKAGE_CODE_MAP = PACKAGE_CODE_MAP;
166
+ exports.SPLITIN_V2_CONTRACT_VERSION = SPLITIN_V2_CONTRACT_VERSION;
167
+ exports.V1_PROTECTED_ACTION_CODE = V1_PROTECTED_ACTION_CODE;
168
+ exports.V2_PROTECTED_ACTION_CONTRACT = V2_PROTECTED_ACTION_CONTRACT;
169
+ exports.WEBHOOK_PROTOCOL_MAP = WEBHOOK_PROTOCOL_MAP;
170
+ exports.attemptCommandV1ToV2 = attemptCommandV1ToV2;
171
+ exports.attemptCommandV2ToV1 = attemptCommandV2ToV1;
172
+ exports.launchV1ToV2 = launchV1ToV2;
173
+ exports.launchV2ToV1 = launchV2ToV1;
174
+ exports.mapManifestWebhookV1ToV2 = mapManifestWebhookV1ToV2;
175
+ exports.mapRedactionCommandV2ToV1 = mapRedactionCommandV2ToV1;
176
+ exports.mapStatusV1ToV2 = mapStatusV1ToV2;
177
+ exports.mapStatusV2ToV1 = mapStatusV2ToV1;
178
+ exports.mapWebhookProtocolV1ToV2 = mapWebhookProtocolV1ToV2;
179
+ exports.mapWebhookProtocolV2ToV1 = mapWebhookProtocolV2ToV1;
180
+ exports.metadataV1ToV2 = metadataV1ToV2;
181
+ exports.metadataV2ToV1 = metadataV2ToV1;
182
+ exports.toV1ProtectedActionCode = toV1ProtectedActionCode;
183
+ exports.toV2ProtectedActionContract = toV2ProtectedActionContract;
184
+ exports.wrapV1AdapterForSplitInV2 = wrapV1AdapterForSplitInV2;
185
+ //# sourceMappingURL=index.cjs.map
186
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAeO,IAAM,2BAAA,GAA8B;AAEpC,IAAM,wBAAA,GAA2B;AACjC,IAAM,4BAAA,GAA+B;AAErC,IAAM,UAAA,GAAa;AAAA,EACxB,YAAA,EAAc,cAAA;AAAA,EACd,YAAA,EAAc,cAAA;AAAA,EACd,gBAAA,EAAkB,aAAA;AAAA,EAClB,eAAA,EAAiB;AACnB;AAEO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,kBAAA,EAAoB,uBAAA;AAAA,EACpB,aAAA,EAAe,oBAAA;AAAA,EACf,kBAAA,EAAoB,iBAAA;AAAA,EACpB,eAAA,EAAiB,oBAAA;AAAA,EACjB,qBAAA,EAAuB;AACzB;AAEO,IAAM,oBAAA,GAA+C;AAAA,EAC1D,cAAA,EAAgB,gBAAA;AAAA,EAChB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,eAAA,EAAiB,iBAAA;AAAA,EACjB,IAAA,EAAM;AACR;AAEO,IAAM,gBAAA,GAA2C;AAAA,EACtD,SAAA,EAAW,WAAA;AAAA,EACX,YAAA,EAAc,cAAA;AAAA,EACd,qBAAA,EAAuB,uBAAA;AAAA,EACvB,gBAAA,EAAkB;AACpB;AAIO,SAAS,gBAAgB,MAAA,EAA+D;AAC7F,EAAA,IAAI,MAAA,KAAW,YAAY,OAAO,UAAA;AAClC,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,eAAA,CAAgB,MAAA,EAAkC,QAAA,GAAW,KAAA,EAAoC;AAC/G,EAAA,OAAO,WAAW,UAAA,GAAa,MAAA;AACjC;AAEO,SAAS,yBAAyB,QAAA,EAAqC;AAC5E,EAAA,OAAO,oBAAA,CAAqB,QAAQ,CAAA,IAAK,QAAA;AAC3C;AAEO,SAAS,yBAAyB,cAAA,EAA2C;AAClF,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AAe,QAAA,CAAS,YAAA,EAAc,QAAQ,SAAS;AAAA,OACvE;AAAA,IACF;AAAA,GACF;AACF;AAEO,SAAS,yBAAyB,QAAA,EAIvC;AACA,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,wBAAA,CAAyB,QAAA,CAAS,OAAA,CAAQ,QAAQ,CAAA;AAAA,IAClE,UAAA,EAAY,SAAS,OAAA,CAAQ,aAAA;AAAA,IAC7B,gBAAA,EAAkB,SAAS,OAAA,CAAQ;AAAA,GACrC;AACF;AAEO,SAAS,0BAA0B,OAAA,EAKb;AAC3B,EAAA,OAAO;AAAA,IACL,kBAAkB,OAAA,CAAQ,gBAAA;AAAA,IAC1B,oBAAoB,OAAA,CAAQ,kBAAA;AAAA,IAC5B,sBAAsB,OAAA,CAAQ,oBAAA;AAAA,IAC9B,kBAAkB,OAAA,CAAQ;AAAA,GAC5B;AACF","file":"index.cjs","sourcesContent":["import type {\n NormalizedProviderSnapshot,\n ProviderAttemptCommand,\n ProviderAttemptResult,\n ProviderLaunchEnvelope,\n ProviderManifestV1,\n ProviderRedactionCommand,\n ProviderResourceCommand,\n ProviderRetryCommand,\n VerificationAdapterV1,\n VerificationCanonicalStatus,\n WebhookProtocolId,\n} from '@splitin/verification-adapter-sdk';\n\n/** Internal SplitIn V2 contract version. Public V1 remains 1.0.0. */\nexport const SPLITIN_V2_CONTRACT_VERSION = '2.0.0' as const;\n\nexport const V1_PROTECTED_ACTION_CODE = 'VERIFICATION_REQUIRED' as const;\nexport const V2_PROTECTED_ACTION_CONTRACT = 'splitin.verification.required.v2' as const;\n\nexport const METHOD_MAP = {\n requestRetry: 'retryAttempt',\n retryAttempt: 'requestRetry',\n reconcileAttempt: 'engineOwned',\n retrieveAttempt: 'retrieveAttempt',\n} as const;\n\nexport const LAUNCH_ALIAS_MAP = {\n inquiryOrSessionId: 'continuationReference',\n environmentId: 'runtimeEnvironment',\n opaqueLaunchSecret: 'transientSecret',\n transientSecret: 'opaqueLaunchSecret',\n continuationReference: 'inquiryOrSessionId',\n} as const;\n\nexport const WEBHOOK_PROTOCOL_MAP: Record<string, string> = {\n stripe_v1_hmac: 'stripe_v1_hmac',\n persona_hmac_sha256: 'persona_hmac_sha256',\n plaid_es256_jwk: 'plaid_es256_jwk',\n none: 'none',\n};\n\nexport const PACKAGE_CODE_MAP: Record<string, string> = {\n human_idv: 'human_idv',\n business_kyb: 'business_kyb',\n associated_person_idv: 'associated_person_idv',\n ownership_review: 'ownership_review',\n};\n\nexport type SplitInV2CanonicalStatus = Exclude<VerificationCanonicalStatus, 'redacted'>;\n\nexport function mapStatusV1ToV2(status: VerificationCanonicalStatus): SplitInV2CanonicalStatus {\n if (status === 'redacted') return 'canceled';\n return status;\n}\n\nexport function mapStatusV2ToV1(status: SplitInV2CanonicalStatus, redacted = false): VerificationCanonicalStatus {\n return redacted ? 'redacted' : status;\n}\n\nexport function mapWebhookProtocolV1ToV2(protocol: WebhookProtocolId): string {\n return WEBHOOK_PROTOCOL_MAP[protocol] ?? protocol;\n}\n\nexport function mapWebhookProtocolV2ToV1(authentication: string): WebhookProtocolId {\n return (WEBHOOK_PROTOCOL_MAP[authentication] ?? authentication) as WebhookProtocolId;\n}\n\nexport function toV2ProtectedActionContract(code: string): string {\n return code === V1_PROTECTED_ACTION_CODE ? V2_PROTECTED_ACTION_CONTRACT : code;\n}\n\nexport function toV1ProtectedActionCode(contract: string): string {\n return contract === V2_PROTECTED_ACTION_CONTRACT ? V1_PROTECTED_ACTION_CODE : contract;\n}\n\nconst SPLITIN_META = /^splitin_/;\n\nexport function metadataV2ToV1(metadata: Record<string, string | number | boolean | null> | undefined): Record<string, string | number | boolean | null> {\n const output: Record<string, string | number | boolean | null> = {};\n for (const [key, value] of Object.entries(metadata ?? {})) {\n if (key === 'splitin_attempt_id') {\n output.attempt_id = value;\n continue;\n }\n if (SPLITIN_META.test(key)) {\n output[key.replace(SPLITIN_META, '')] = value;\n continue;\n }\n output[key] = value;\n }\n return output;\n}\n\nexport function metadataV1ToV2(\n metadata: Record<string, string | number | boolean | null> | undefined,\n attemptId?: string,\n): Record<string, string | number | boolean | null> {\n const output: Record<string, string | number | boolean | null> = { ...(metadata ?? {}) };\n const opaqueAttempt = metadata?.attempt_id ?? attemptId ?? null;\n if (opaqueAttempt != null) output.splitin_attempt_id = opaqueAttempt;\n return output;\n}\n\nexport interface SplitInV2LaunchEnvelope {\n presentation: ProviderLaunchEnvelope['presentation'];\n launcherKey: string;\n adapter?: string;\n inquiryOrSessionId?: string;\n environmentId?: string;\n transientSecret?: string;\n transientSecretExpiresAt?: string;\n opaqueLaunchSecret?: string;\n hostedUrl?: string;\n hostedFallbackExpiresAt?: string;\n expiresAt?: string;\n providerDisclosure?: string;\n}\n\nexport function launchV1ToV2(launch: ProviderLaunchEnvelope, environment?: string): SplitInV2LaunchEnvelope {\n return {\n presentation: launch.presentation,\n launcherKey: launch.launcherKey,\n adapter: launch.launcherKey,\n inquiryOrSessionId: launch.continuationReference,\n environmentId: environment,\n transientSecret: launch.transientSecret,\n transientSecretExpiresAt: launch.transientSecretExpiresAt,\n opaqueLaunchSecret: launch.transientSecret,\n hostedUrl: launch.hostedUrl,\n hostedFallbackExpiresAt: launch.hostedFallbackExpiresAt,\n expiresAt: launch.transientSecretExpiresAt ?? launch.hostedFallbackExpiresAt,\n providerDisclosure: launch.providerDisclosure,\n };\n}\n\nexport function launchV2ToV1(launch: SplitInV2LaunchEnvelope, attemptId: string): ProviderLaunchEnvelope {\n return {\n attemptId,\n canonicalStatus: 'pending_user_input',\n launcherKey: launch.launcherKey,\n presentation: launch.presentation,\n providerDisclosure: launch.providerDisclosure,\n transientSecret: launch.transientSecret ?? launch.opaqueLaunchSecret,\n transientSecretExpiresAt: launch.transientSecretExpiresAt ?? launch.expiresAt,\n hostedUrl: launch.hostedUrl,\n hostedFallbackExpiresAt: launch.hostedFallbackExpiresAt,\n continuationReference: launch.inquiryOrSessionId,\n };\n}\n\nexport interface SplitInV2AttemptCommand {\n attemptId: string;\n humanSubjectReference: string;\n subjectReference?: string;\n packageCode: string;\n idempotencyKey: string;\n providerConfigReference: string;\n legalFirstName?: string | null;\n legalLastName?: string | null;\n email?: string | null;\n requestOrigin?: string | null;\n metadata?: Record<string, string | number | boolean | null>;\n}\n\nexport function attemptCommandV2ToV1(command: SplitInV2AttemptCommand, countryCode = 'US'): ProviderAttemptCommand {\n return {\n attemptId: command.attemptId,\n subjectReference: command.subjectReference ?? command.humanSubjectReference,\n packageCode: command.packageCode,\n countryCode,\n idempotencyKey: command.idempotencyKey,\n configurationRevision: command.providerConfigReference,\n legalFirstName: command.legalFirstName,\n legalLastName: command.legalLastName,\n email: command.email,\n requestOrigin: command.requestOrigin,\n metadata: metadataV2ToV1(command.metadata),\n };\n}\n\nexport function attemptCommandV1ToV2(command: ProviderAttemptCommand): SplitInV2AttemptCommand {\n return {\n attemptId: command.attemptId,\n humanSubjectReference: command.subjectReference,\n subjectReference: command.subjectReference,\n packageCode: command.packageCode,\n idempotencyKey: command.idempotencyKey,\n providerConfigReference: command.configurationRevision,\n legalFirstName: command.legalFirstName,\n legalLastName: command.legalLastName,\n email: command.email,\n requestOrigin: command.requestOrigin,\n metadata: metadataV1ToV2(command.metadata, command.attemptId),\n };\n}\n\nexport interface SplitInV2AdapterSurface {\n requestRetry(command: ProviderRetryCommand): Promise<ProviderAttemptResult>;\n reconcileAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;\n retrieveAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;\n}\n\n/**\n * Wrap a public V1 adapter so a V2-shaped engine can call requestRetry /\n * reconcileAttempt. Reconciliation remains engine-owned: this wrapper delegates\n * reconcileAttempt to retrieveAttempt and never asks the adapter to persist.\n */\nexport function wrapV1AdapterForSplitInV2(adapter: VerificationAdapterV1): SplitInV2AdapterSurface {\n return {\n requestRetry: (command) => adapter.retryAttempt(command),\n retrieveAttempt: (command) => adapter.retrieveAttempt(command),\n reconcileAttempt: async (command) => {\n const snapshot = await adapter.retrieveAttempt(command);\n return {\n ...snapshot,\n canonicalStatus: mapStatusV1ToV2(snapshot.canonicalStatus),\n safeMetadata: metadataV1ToV2(snapshot.safeMetadata, command.attemptId),\n };\n },\n };\n}\n\nexport function mapManifestWebhookV1ToV2(manifest: ProviderManifestV1): {\n authentication: string;\n eventTypes: string[];\n toleranceSeconds?: number;\n} {\n return {\n authentication: mapWebhookProtocolV1ToV2(manifest.webhook.protocol),\n eventTypes: manifest.webhook.eventFamilies,\n toleranceSeconds: manifest.webhook.toleranceSeconds,\n };\n}\n\nexport function mapRedactionCommandV2ToV1(command: {\n subjectReference: string;\n providerResourceId?: string | null;\n providerResourceType?: string;\n requestReference: string;\n}): ProviderRedactionCommand {\n return {\n subjectReference: command.subjectReference,\n providerResourceId: command.providerResourceId,\n providerResourceType: command.providerResourceType,\n requestReference: command.requestReference,\n };\n}\n"]}
@@ -0,0 +1,85 @@
1
+ import { ProviderRetryCommand, ProviderAttemptResult, ProviderResourceCommand, NormalizedProviderSnapshot, VerificationCanonicalStatus, ProviderLaunchEnvelope, ProviderAttemptCommand, ProviderManifestV1, ProviderRedactionCommand, WebhookProtocolId, VerificationAdapterV1 } from '@splitin/verification-adapter-sdk';
2
+
3
+ /** Internal SplitIn V2 contract version. Public V1 remains 1.0.0. */
4
+ declare const SPLITIN_V2_CONTRACT_VERSION: "2.0.0";
5
+ declare const V1_PROTECTED_ACTION_CODE: "VERIFICATION_REQUIRED";
6
+ declare const V2_PROTECTED_ACTION_CONTRACT: "splitin.verification.required.v2";
7
+ declare const METHOD_MAP: {
8
+ readonly requestRetry: "retryAttempt";
9
+ readonly retryAttempt: "requestRetry";
10
+ readonly reconcileAttempt: "engineOwned";
11
+ readonly retrieveAttempt: "retrieveAttempt";
12
+ };
13
+ declare const LAUNCH_ALIAS_MAP: {
14
+ readonly inquiryOrSessionId: "continuationReference";
15
+ readonly environmentId: "runtimeEnvironment";
16
+ readonly opaqueLaunchSecret: "transientSecret";
17
+ readonly transientSecret: "opaqueLaunchSecret";
18
+ readonly continuationReference: "inquiryOrSessionId";
19
+ };
20
+ declare const WEBHOOK_PROTOCOL_MAP: Record<string, string>;
21
+ declare const PACKAGE_CODE_MAP: Record<string, string>;
22
+ type SplitInV2CanonicalStatus = Exclude<VerificationCanonicalStatus, 'redacted'>;
23
+ declare function mapStatusV1ToV2(status: VerificationCanonicalStatus): SplitInV2CanonicalStatus;
24
+ declare function mapStatusV2ToV1(status: SplitInV2CanonicalStatus, redacted?: boolean): VerificationCanonicalStatus;
25
+ declare function mapWebhookProtocolV1ToV2(protocol: WebhookProtocolId): string;
26
+ declare function mapWebhookProtocolV2ToV1(authentication: string): WebhookProtocolId;
27
+ declare function toV2ProtectedActionContract(code: string): string;
28
+ declare function toV1ProtectedActionCode(contract: string): string;
29
+ declare function metadataV2ToV1(metadata: Record<string, string | number | boolean | null> | undefined): Record<string, string | number | boolean | null>;
30
+ declare function metadataV1ToV2(metadata: Record<string, string | number | boolean | null> | undefined, attemptId?: string): Record<string, string | number | boolean | null>;
31
+ interface SplitInV2LaunchEnvelope {
32
+ presentation: ProviderLaunchEnvelope['presentation'];
33
+ launcherKey: string;
34
+ adapter?: string;
35
+ inquiryOrSessionId?: string;
36
+ environmentId?: string;
37
+ transientSecret?: string;
38
+ transientSecretExpiresAt?: string;
39
+ opaqueLaunchSecret?: string;
40
+ hostedUrl?: string;
41
+ hostedFallbackExpiresAt?: string;
42
+ expiresAt?: string;
43
+ providerDisclosure?: string;
44
+ }
45
+ declare function launchV1ToV2(launch: ProviderLaunchEnvelope, environment?: string): SplitInV2LaunchEnvelope;
46
+ declare function launchV2ToV1(launch: SplitInV2LaunchEnvelope, attemptId: string): ProviderLaunchEnvelope;
47
+ interface SplitInV2AttemptCommand {
48
+ attemptId: string;
49
+ humanSubjectReference: string;
50
+ subjectReference?: string;
51
+ packageCode: string;
52
+ idempotencyKey: string;
53
+ providerConfigReference: string;
54
+ legalFirstName?: string | null;
55
+ legalLastName?: string | null;
56
+ email?: string | null;
57
+ requestOrigin?: string | null;
58
+ metadata?: Record<string, string | number | boolean | null>;
59
+ }
60
+ declare function attemptCommandV2ToV1(command: SplitInV2AttemptCommand, countryCode?: string): ProviderAttemptCommand;
61
+ declare function attemptCommandV1ToV2(command: ProviderAttemptCommand): SplitInV2AttemptCommand;
62
+ interface SplitInV2AdapterSurface {
63
+ requestRetry(command: ProviderRetryCommand): Promise<ProviderAttemptResult>;
64
+ reconcileAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;
65
+ retrieveAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;
66
+ }
67
+ /**
68
+ * Wrap a public V1 adapter so a V2-shaped engine can call requestRetry /
69
+ * reconcileAttempt. Reconciliation remains engine-owned: this wrapper delegates
70
+ * reconcileAttempt to retrieveAttempt and never asks the adapter to persist.
71
+ */
72
+ declare function wrapV1AdapterForSplitInV2(adapter: VerificationAdapterV1): SplitInV2AdapterSurface;
73
+ declare function mapManifestWebhookV1ToV2(manifest: ProviderManifestV1): {
74
+ authentication: string;
75
+ eventTypes: string[];
76
+ toleranceSeconds?: number;
77
+ };
78
+ declare function mapRedactionCommandV2ToV1(command: {
79
+ subjectReference: string;
80
+ providerResourceId?: string | null;
81
+ providerResourceType?: string;
82
+ requestReference: string;
83
+ }): ProviderRedactionCommand;
84
+
85
+ export { LAUNCH_ALIAS_MAP, METHOD_MAP, PACKAGE_CODE_MAP, SPLITIN_V2_CONTRACT_VERSION, type SplitInV2AdapterSurface, type SplitInV2AttemptCommand, type SplitInV2CanonicalStatus, type SplitInV2LaunchEnvelope, V1_PROTECTED_ACTION_CODE, V2_PROTECTED_ACTION_CONTRACT, WEBHOOK_PROTOCOL_MAP, attemptCommandV1ToV2, attemptCommandV2ToV1, launchV1ToV2, launchV2ToV1, mapManifestWebhookV1ToV2, mapRedactionCommandV2ToV1, mapStatusV1ToV2, mapStatusV2ToV1, mapWebhookProtocolV1ToV2, mapWebhookProtocolV2ToV1, metadataV1ToV2, metadataV2ToV1, toV1ProtectedActionCode, toV2ProtectedActionContract, wrapV1AdapterForSplitInV2 };
@@ -0,0 +1,85 @@
1
+ import { ProviderRetryCommand, ProviderAttemptResult, ProviderResourceCommand, NormalizedProviderSnapshot, VerificationCanonicalStatus, ProviderLaunchEnvelope, ProviderAttemptCommand, ProviderManifestV1, ProviderRedactionCommand, WebhookProtocolId, VerificationAdapterV1 } from '@splitin/verification-adapter-sdk';
2
+
3
+ /** Internal SplitIn V2 contract version. Public V1 remains 1.0.0. */
4
+ declare const SPLITIN_V2_CONTRACT_VERSION: "2.0.0";
5
+ declare const V1_PROTECTED_ACTION_CODE: "VERIFICATION_REQUIRED";
6
+ declare const V2_PROTECTED_ACTION_CONTRACT: "splitin.verification.required.v2";
7
+ declare const METHOD_MAP: {
8
+ readonly requestRetry: "retryAttempt";
9
+ readonly retryAttempt: "requestRetry";
10
+ readonly reconcileAttempt: "engineOwned";
11
+ readonly retrieveAttempt: "retrieveAttempt";
12
+ };
13
+ declare const LAUNCH_ALIAS_MAP: {
14
+ readonly inquiryOrSessionId: "continuationReference";
15
+ readonly environmentId: "runtimeEnvironment";
16
+ readonly opaqueLaunchSecret: "transientSecret";
17
+ readonly transientSecret: "opaqueLaunchSecret";
18
+ readonly continuationReference: "inquiryOrSessionId";
19
+ };
20
+ declare const WEBHOOK_PROTOCOL_MAP: Record<string, string>;
21
+ declare const PACKAGE_CODE_MAP: Record<string, string>;
22
+ type SplitInV2CanonicalStatus = Exclude<VerificationCanonicalStatus, 'redacted'>;
23
+ declare function mapStatusV1ToV2(status: VerificationCanonicalStatus): SplitInV2CanonicalStatus;
24
+ declare function mapStatusV2ToV1(status: SplitInV2CanonicalStatus, redacted?: boolean): VerificationCanonicalStatus;
25
+ declare function mapWebhookProtocolV1ToV2(protocol: WebhookProtocolId): string;
26
+ declare function mapWebhookProtocolV2ToV1(authentication: string): WebhookProtocolId;
27
+ declare function toV2ProtectedActionContract(code: string): string;
28
+ declare function toV1ProtectedActionCode(contract: string): string;
29
+ declare function metadataV2ToV1(metadata: Record<string, string | number | boolean | null> | undefined): Record<string, string | number | boolean | null>;
30
+ declare function metadataV1ToV2(metadata: Record<string, string | number | boolean | null> | undefined, attemptId?: string): Record<string, string | number | boolean | null>;
31
+ interface SplitInV2LaunchEnvelope {
32
+ presentation: ProviderLaunchEnvelope['presentation'];
33
+ launcherKey: string;
34
+ adapter?: string;
35
+ inquiryOrSessionId?: string;
36
+ environmentId?: string;
37
+ transientSecret?: string;
38
+ transientSecretExpiresAt?: string;
39
+ opaqueLaunchSecret?: string;
40
+ hostedUrl?: string;
41
+ hostedFallbackExpiresAt?: string;
42
+ expiresAt?: string;
43
+ providerDisclosure?: string;
44
+ }
45
+ declare function launchV1ToV2(launch: ProviderLaunchEnvelope, environment?: string): SplitInV2LaunchEnvelope;
46
+ declare function launchV2ToV1(launch: SplitInV2LaunchEnvelope, attemptId: string): ProviderLaunchEnvelope;
47
+ interface SplitInV2AttemptCommand {
48
+ attemptId: string;
49
+ humanSubjectReference: string;
50
+ subjectReference?: string;
51
+ packageCode: string;
52
+ idempotencyKey: string;
53
+ providerConfigReference: string;
54
+ legalFirstName?: string | null;
55
+ legalLastName?: string | null;
56
+ email?: string | null;
57
+ requestOrigin?: string | null;
58
+ metadata?: Record<string, string | number | boolean | null>;
59
+ }
60
+ declare function attemptCommandV2ToV1(command: SplitInV2AttemptCommand, countryCode?: string): ProviderAttemptCommand;
61
+ declare function attemptCommandV1ToV2(command: ProviderAttemptCommand): SplitInV2AttemptCommand;
62
+ interface SplitInV2AdapterSurface {
63
+ requestRetry(command: ProviderRetryCommand): Promise<ProviderAttemptResult>;
64
+ reconcileAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;
65
+ retrieveAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;
66
+ }
67
+ /**
68
+ * Wrap a public V1 adapter so a V2-shaped engine can call requestRetry /
69
+ * reconcileAttempt. Reconciliation remains engine-owned: this wrapper delegates
70
+ * reconcileAttempt to retrieveAttempt and never asks the adapter to persist.
71
+ */
72
+ declare function wrapV1AdapterForSplitInV2(adapter: VerificationAdapterV1): SplitInV2AdapterSurface;
73
+ declare function mapManifestWebhookV1ToV2(manifest: ProviderManifestV1): {
74
+ authentication: string;
75
+ eventTypes: string[];
76
+ toleranceSeconds?: number;
77
+ };
78
+ declare function mapRedactionCommandV2ToV1(command: {
79
+ subjectReference: string;
80
+ providerResourceId?: string | null;
81
+ providerResourceType?: string;
82
+ requestReference: string;
83
+ }): ProviderRedactionCommand;
84
+
85
+ export { LAUNCH_ALIAS_MAP, METHOD_MAP, PACKAGE_CODE_MAP, SPLITIN_V2_CONTRACT_VERSION, type SplitInV2AdapterSurface, type SplitInV2AttemptCommand, type SplitInV2CanonicalStatus, type SplitInV2LaunchEnvelope, V1_PROTECTED_ACTION_CODE, V2_PROTECTED_ACTION_CONTRACT, WEBHOOK_PROTOCOL_MAP, attemptCommandV1ToV2, attemptCommandV2ToV1, launchV1ToV2, launchV2ToV1, mapManifestWebhookV1ToV2, mapRedactionCommandV2ToV1, mapStatusV1ToV2, mapStatusV2ToV1, mapWebhookProtocolV1ToV2, mapWebhookProtocolV2ToV1, metadataV1ToV2, metadataV2ToV1, toV1ProtectedActionCode, toV2ProtectedActionContract, wrapV1AdapterForSplitInV2 };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["index.d.ts"],"names":[],"mappings":"AAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,163 @@
1
+ // src/index.ts
2
+ var SPLITIN_V2_CONTRACT_VERSION = "2.0.0";
3
+ var V1_PROTECTED_ACTION_CODE = "VERIFICATION_REQUIRED";
4
+ var V2_PROTECTED_ACTION_CONTRACT = "splitin.verification.required.v2";
5
+ var METHOD_MAP = {
6
+ requestRetry: "retryAttempt",
7
+ retryAttempt: "requestRetry",
8
+ reconcileAttempt: "engineOwned",
9
+ retrieveAttempt: "retrieveAttempt"
10
+ };
11
+ var LAUNCH_ALIAS_MAP = {
12
+ inquiryOrSessionId: "continuationReference",
13
+ environmentId: "runtimeEnvironment",
14
+ opaqueLaunchSecret: "transientSecret",
15
+ transientSecret: "opaqueLaunchSecret",
16
+ continuationReference: "inquiryOrSessionId"
17
+ };
18
+ var WEBHOOK_PROTOCOL_MAP = {
19
+ stripe_v1_hmac: "stripe_v1_hmac",
20
+ persona_hmac_sha256: "persona_hmac_sha256",
21
+ plaid_es256_jwk: "plaid_es256_jwk",
22
+ none: "none"
23
+ };
24
+ var PACKAGE_CODE_MAP = {
25
+ human_idv: "human_idv",
26
+ business_kyb: "business_kyb",
27
+ associated_person_idv: "associated_person_idv",
28
+ ownership_review: "ownership_review"
29
+ };
30
+ function mapStatusV1ToV2(status) {
31
+ if (status === "redacted") return "canceled";
32
+ return status;
33
+ }
34
+ function mapStatusV2ToV1(status, redacted = false) {
35
+ return redacted ? "redacted" : status;
36
+ }
37
+ function mapWebhookProtocolV1ToV2(protocol) {
38
+ return WEBHOOK_PROTOCOL_MAP[protocol] ?? protocol;
39
+ }
40
+ function mapWebhookProtocolV2ToV1(authentication) {
41
+ return WEBHOOK_PROTOCOL_MAP[authentication] ?? authentication;
42
+ }
43
+ function toV2ProtectedActionContract(code) {
44
+ return code === V1_PROTECTED_ACTION_CODE ? V2_PROTECTED_ACTION_CONTRACT : code;
45
+ }
46
+ function toV1ProtectedActionCode(contract) {
47
+ return contract === V2_PROTECTED_ACTION_CONTRACT ? V1_PROTECTED_ACTION_CODE : contract;
48
+ }
49
+ var SPLITIN_META = /^splitin_/;
50
+ function metadataV2ToV1(metadata) {
51
+ const output = {};
52
+ for (const [key, value] of Object.entries(metadata ?? {})) {
53
+ if (key === "splitin_attempt_id") {
54
+ output.attempt_id = value;
55
+ continue;
56
+ }
57
+ if (SPLITIN_META.test(key)) {
58
+ output[key.replace(SPLITIN_META, "")] = value;
59
+ continue;
60
+ }
61
+ output[key] = value;
62
+ }
63
+ return output;
64
+ }
65
+ function metadataV1ToV2(metadata, attemptId) {
66
+ const output = { ...metadata ?? {} };
67
+ const opaqueAttempt = metadata?.attempt_id ?? attemptId ?? null;
68
+ if (opaqueAttempt != null) output.splitin_attempt_id = opaqueAttempt;
69
+ return output;
70
+ }
71
+ function launchV1ToV2(launch, environment) {
72
+ return {
73
+ presentation: launch.presentation,
74
+ launcherKey: launch.launcherKey,
75
+ adapter: launch.launcherKey,
76
+ inquiryOrSessionId: launch.continuationReference,
77
+ environmentId: environment,
78
+ transientSecret: launch.transientSecret,
79
+ transientSecretExpiresAt: launch.transientSecretExpiresAt,
80
+ opaqueLaunchSecret: launch.transientSecret,
81
+ hostedUrl: launch.hostedUrl,
82
+ hostedFallbackExpiresAt: launch.hostedFallbackExpiresAt,
83
+ expiresAt: launch.transientSecretExpiresAt ?? launch.hostedFallbackExpiresAt,
84
+ providerDisclosure: launch.providerDisclosure
85
+ };
86
+ }
87
+ function launchV2ToV1(launch, attemptId) {
88
+ return {
89
+ attemptId,
90
+ canonicalStatus: "pending_user_input",
91
+ launcherKey: launch.launcherKey,
92
+ presentation: launch.presentation,
93
+ providerDisclosure: launch.providerDisclosure,
94
+ transientSecret: launch.transientSecret ?? launch.opaqueLaunchSecret,
95
+ transientSecretExpiresAt: launch.transientSecretExpiresAt ?? launch.expiresAt,
96
+ hostedUrl: launch.hostedUrl,
97
+ hostedFallbackExpiresAt: launch.hostedFallbackExpiresAt,
98
+ continuationReference: launch.inquiryOrSessionId
99
+ };
100
+ }
101
+ function attemptCommandV2ToV1(command, countryCode = "US") {
102
+ return {
103
+ attemptId: command.attemptId,
104
+ subjectReference: command.subjectReference ?? command.humanSubjectReference,
105
+ packageCode: command.packageCode,
106
+ countryCode,
107
+ idempotencyKey: command.idempotencyKey,
108
+ configurationRevision: command.providerConfigReference,
109
+ legalFirstName: command.legalFirstName,
110
+ legalLastName: command.legalLastName,
111
+ email: command.email,
112
+ requestOrigin: command.requestOrigin,
113
+ metadata: metadataV2ToV1(command.metadata)
114
+ };
115
+ }
116
+ function attemptCommandV1ToV2(command) {
117
+ return {
118
+ attemptId: command.attemptId,
119
+ humanSubjectReference: command.subjectReference,
120
+ subjectReference: command.subjectReference,
121
+ packageCode: command.packageCode,
122
+ idempotencyKey: command.idempotencyKey,
123
+ providerConfigReference: command.configurationRevision,
124
+ legalFirstName: command.legalFirstName,
125
+ legalLastName: command.legalLastName,
126
+ email: command.email,
127
+ requestOrigin: command.requestOrigin,
128
+ metadata: metadataV1ToV2(command.metadata, command.attemptId)
129
+ };
130
+ }
131
+ function wrapV1AdapterForSplitInV2(adapter) {
132
+ return {
133
+ requestRetry: (command) => adapter.retryAttempt(command),
134
+ retrieveAttempt: (command) => adapter.retrieveAttempt(command),
135
+ reconcileAttempt: async (command) => {
136
+ const snapshot = await adapter.retrieveAttempt(command);
137
+ return {
138
+ ...snapshot,
139
+ canonicalStatus: mapStatusV1ToV2(snapshot.canonicalStatus),
140
+ safeMetadata: metadataV1ToV2(snapshot.safeMetadata, command.attemptId)
141
+ };
142
+ }
143
+ };
144
+ }
145
+ function mapManifestWebhookV1ToV2(manifest) {
146
+ return {
147
+ authentication: mapWebhookProtocolV1ToV2(manifest.webhook.protocol),
148
+ eventTypes: manifest.webhook.eventFamilies,
149
+ toleranceSeconds: manifest.webhook.toleranceSeconds
150
+ };
151
+ }
152
+ function mapRedactionCommandV2ToV1(command) {
153
+ return {
154
+ subjectReference: command.subjectReference,
155
+ providerResourceId: command.providerResourceId,
156
+ providerResourceType: command.providerResourceType,
157
+ requestReference: command.requestReference
158
+ };
159
+ }
160
+
161
+ export { LAUNCH_ALIAS_MAP, METHOD_MAP, PACKAGE_CODE_MAP, SPLITIN_V2_CONTRACT_VERSION, V1_PROTECTED_ACTION_CODE, V2_PROTECTED_ACTION_CONTRACT, WEBHOOK_PROTOCOL_MAP, attemptCommandV1ToV2, attemptCommandV2ToV1, launchV1ToV2, launchV2ToV1, mapManifestWebhookV1ToV2, mapRedactionCommandV2ToV1, mapStatusV1ToV2, mapStatusV2ToV1, mapWebhookProtocolV1ToV2, mapWebhookProtocolV2ToV1, metadataV1ToV2, metadataV2ToV1, toV1ProtectedActionCode, toV2ProtectedActionContract, wrapV1AdapterForSplitInV2 };
162
+ //# sourceMappingURL=index.js.map
163
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAeO,IAAM,2BAAA,GAA8B;AAEpC,IAAM,wBAAA,GAA2B;AACjC,IAAM,4BAAA,GAA+B;AAErC,IAAM,UAAA,GAAa;AAAA,EACxB,YAAA,EAAc,cAAA;AAAA,EACd,YAAA,EAAc,cAAA;AAAA,EACd,gBAAA,EAAkB,aAAA;AAAA,EAClB,eAAA,EAAiB;AACnB;AAEO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,kBAAA,EAAoB,uBAAA;AAAA,EACpB,aAAA,EAAe,oBAAA;AAAA,EACf,kBAAA,EAAoB,iBAAA;AAAA,EACpB,eAAA,EAAiB,oBAAA;AAAA,EACjB,qBAAA,EAAuB;AACzB;AAEO,IAAM,oBAAA,GAA+C;AAAA,EAC1D,cAAA,EAAgB,gBAAA;AAAA,EAChB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,eAAA,EAAiB,iBAAA;AAAA,EACjB,IAAA,EAAM;AACR;AAEO,IAAM,gBAAA,GAA2C;AAAA,EACtD,SAAA,EAAW,WAAA;AAAA,EACX,YAAA,EAAc,cAAA;AAAA,EACd,qBAAA,EAAuB,uBAAA;AAAA,EACvB,gBAAA,EAAkB;AACpB;AAIO,SAAS,gBAAgB,MAAA,EAA+D;AAC7F,EAAA,IAAI,MAAA,KAAW,YAAY,OAAO,UAAA;AAClC,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,eAAA,CAAgB,MAAA,EAAkC,QAAA,GAAW,KAAA,EAAoC;AAC/G,EAAA,OAAO,WAAW,UAAA,GAAa,MAAA;AACjC;AAEO,SAAS,yBAAyB,QAAA,EAAqC;AAC5E,EAAA,OAAO,oBAAA,CAAqB,QAAQ,CA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CAAgB,QAAA,CAAS,eAAe,CAAA;AAAA,QACzD,YAAA,EAAc,cAAA,CAAe,QAAA,CAAS,YAAA,EAAc,QAAQ,SAAS;AAAA,OACvE;AAAA,IACF;AAAA,GACF;AACF;AAEO,SAAS,yBAAyB,QAAA,EAIvC;AACA,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,wBAAA,CAAyB,QAAA,CAAS,OAAA,CAAQ,QAAQ,CAAA;AAAA,IAClE,UAAA,EAAY,SAAS,OAAA,CAAQ,aAAA;AAAA,IAC7B,gBAAA,EAAkB,SAAS,OAAA,CAAQ;AAAA,GACrC;AACF;AAEO,SAAS,0BAA0B,OAAA,EAKb;AAC3B,EAAA,OAAO;AAAA,IACL,kBAAkB,OAAA,CAAQ,gBAAA;AAAA,IAC1B,oBAAoB,OAAA,CAAQ,kBAAA;AAAA,IAC5B,sBAAsB,OAAA,CAAQ,oBAAA;AAAA,IAC9B,kBAAkB,OAAA,CAAQ;AAAA,GAC5B;AACF","file":"index.js","sourcesContent":["import type {\n NormalizedProviderSnapshot,\n ProviderAttemptCommand,\n ProviderAttemptResult,\n ProviderLaunchEnvelope,\n ProviderManifestV1,\n ProviderRedactionCommand,\n ProviderResourceCommand,\n ProviderRetryCommand,\n VerificationAdapterV1,\n VerificationCanonicalStatus,\n WebhookProtocolId,\n} from '@splitin/verification-adapter-sdk';\n\n/** Internal SplitIn V2 contract version. Public V1 remains 1.0.0. */\nexport const SPLITIN_V2_CONTRACT_VERSION = '2.0.0' as const;\n\nexport const V1_PROTECTED_ACTION_CODE = 'VERIFICATION_REQUIRED' as const;\nexport const V2_PROTECTED_ACTION_CONTRACT = 'splitin.verification.required.v2' as const;\n\nexport const METHOD_MAP = {\n requestRetry: 'retryAttempt',\n retryAttempt: 'requestRetry',\n reconcileAttempt: 'engineOwned',\n retrieveAttempt: 'retrieveAttempt',\n} as const;\n\nexport const LAUNCH_ALIAS_MAP = {\n inquiryOrSessionId: 'continuationReference',\n environmentId: 'runtimeEnvironment',\n opaqueLaunchSecret: 'transientSecret',\n transientSecret: 'opaqueLaunchSecret',\n continuationReference: 'inquiryOrSessionId',\n} as const;\n\nexport const WEBHOOK_PROTOCOL_MAP: Record<string, string> = {\n stripe_v1_hmac: 'stripe_v1_hmac',\n persona_hmac_sha256: 'persona_hmac_sha256',\n plaid_es256_jwk: 'plaid_es256_jwk',\n none: 'none',\n};\n\nexport const PACKAGE_CODE_MAP: Record<string, string> = {\n human_idv: 'human_idv',\n business_kyb: 'business_kyb',\n associated_person_idv: 'associated_person_idv',\n ownership_review: 'ownership_review',\n};\n\nexport type SplitInV2CanonicalStatus = Exclude<VerificationCanonicalStatus, 'redacted'>;\n\nexport function mapStatusV1ToV2(status: VerificationCanonicalStatus): SplitInV2CanonicalStatus {\n if (status === 'redacted') return 'canceled';\n return status;\n}\n\nexport function mapStatusV2ToV1(status: SplitInV2CanonicalStatus, redacted = false): VerificationCanonicalStatus {\n return redacted ? 'redacted' : status;\n}\n\nexport function mapWebhookProtocolV1ToV2(protocol: WebhookProtocolId): string {\n return WEBHOOK_PROTOCOL_MAP[protocol] ?? protocol;\n}\n\nexport function mapWebhookProtocolV2ToV1(authentication: string): WebhookProtocolId {\n return (WEBHOOK_PROTOCOL_MAP[authentication] ?? authentication) as WebhookProtocolId;\n}\n\nexport function toV2ProtectedActionContract(code: string): string {\n return code === V1_PROTECTED_ACTION_CODE ? V2_PROTECTED_ACTION_CONTRACT : code;\n}\n\nexport function toV1ProtectedActionCode(contract: string): string {\n return contract === V2_PROTECTED_ACTION_CONTRACT ? V1_PROTECTED_ACTION_CODE : contract;\n}\n\nconst SPLITIN_META = /^splitin_/;\n\nexport function metadataV2ToV1(metadata: Record<string, string | number | boolean | null> | undefined): Record<string, string | number | boolean | null> {\n const output: Record<string, string | number | boolean | null> = {};\n for (const [key, value] of Object.entries(metadata ?? {})) {\n if (key === 'splitin_attempt_id') {\n output.attempt_id = value;\n continue;\n }\n if (SPLITIN_META.test(key)) {\n output[key.replace(SPLITIN_META, '')] = value;\n continue;\n }\n output[key] = value;\n }\n return output;\n}\n\nexport function metadataV1ToV2(\n metadata: Record<string, string | number | boolean | null> | undefined,\n attemptId?: string,\n): Record<string, string | number | boolean | null> {\n const output: Record<string, string | number | boolean | null> = { ...(metadata ?? {}) };\n const opaqueAttempt = metadata?.attempt_id ?? attemptId ?? null;\n if (opaqueAttempt != null) output.splitin_attempt_id = opaqueAttempt;\n return output;\n}\n\nexport interface SplitInV2LaunchEnvelope {\n presentation: ProviderLaunchEnvelope['presentation'];\n launcherKey: string;\n adapter?: string;\n inquiryOrSessionId?: string;\n environmentId?: string;\n transientSecret?: string;\n transientSecretExpiresAt?: string;\n opaqueLaunchSecret?: string;\n hostedUrl?: string;\n hostedFallbackExpiresAt?: string;\n expiresAt?: string;\n providerDisclosure?: string;\n}\n\nexport function launchV1ToV2(launch: ProviderLaunchEnvelope, environment?: string): SplitInV2LaunchEnvelope {\n return {\n presentation: launch.presentation,\n launcherKey: launch.launcherKey,\n adapter: launch.launcherKey,\n inquiryOrSessionId: launch.continuationReference,\n environmentId: environment,\n transientSecret: launch.transientSecret,\n transientSecretExpiresAt: launch.transientSecretExpiresAt,\n opaqueLaunchSecret: launch.transientSecret,\n hostedUrl: launch.hostedUrl,\n hostedFallbackExpiresAt: launch.hostedFallbackExpiresAt,\n expiresAt: launch.transientSecretExpiresAt ?? launch.hostedFallbackExpiresAt,\n providerDisclosure: launch.providerDisclosure,\n };\n}\n\nexport function launchV2ToV1(launch: SplitInV2LaunchEnvelope, attemptId: string): ProviderLaunchEnvelope {\n return {\n attemptId,\n canonicalStatus: 'pending_user_input',\n launcherKey: launch.launcherKey,\n presentation: launch.presentation,\n providerDisclosure: launch.providerDisclosure,\n transientSecret: launch.transientSecret ?? launch.opaqueLaunchSecret,\n transientSecretExpiresAt: launch.transientSecretExpiresAt ?? launch.expiresAt,\n hostedUrl: launch.hostedUrl,\n hostedFallbackExpiresAt: launch.hostedFallbackExpiresAt,\n continuationReference: launch.inquiryOrSessionId,\n };\n}\n\nexport interface SplitInV2AttemptCommand {\n attemptId: string;\n humanSubjectReference: string;\n subjectReference?: string;\n packageCode: string;\n idempotencyKey: string;\n providerConfigReference: string;\n legalFirstName?: string | null;\n legalLastName?: string | null;\n email?: string | null;\n requestOrigin?: string | null;\n metadata?: Record<string, string | number | boolean | null>;\n}\n\nexport function attemptCommandV2ToV1(command: SplitInV2AttemptCommand, countryCode = 'US'): ProviderAttemptCommand {\n return {\n attemptId: command.attemptId,\n subjectReference: command.subjectReference ?? command.humanSubjectReference,\n packageCode: command.packageCode,\n countryCode,\n idempotencyKey: command.idempotencyKey,\n configurationRevision: command.providerConfigReference,\n legalFirstName: command.legalFirstName,\n legalLastName: command.legalLastName,\n email: command.email,\n requestOrigin: command.requestOrigin,\n metadata: metadataV2ToV1(command.metadata),\n };\n}\n\nexport function attemptCommandV1ToV2(command: ProviderAttemptCommand): SplitInV2AttemptCommand {\n return {\n attemptId: command.attemptId,\n humanSubjectReference: command.subjectReference,\n subjectReference: command.subjectReference,\n packageCode: command.packageCode,\n idempotencyKey: command.idempotencyKey,\n providerConfigReference: command.configurationRevision,\n legalFirstName: command.legalFirstName,\n legalLastName: command.legalLastName,\n email: command.email,\n requestOrigin: command.requestOrigin,\n metadata: metadataV1ToV2(command.metadata, command.attemptId),\n };\n}\n\nexport interface SplitInV2AdapterSurface {\n requestRetry(command: ProviderRetryCommand): Promise<ProviderAttemptResult>;\n reconcileAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;\n retrieveAttempt(command: ProviderResourceCommand): Promise<NormalizedProviderSnapshot>;\n}\n\n/**\n * Wrap a public V1 adapter so a V2-shaped engine can call requestRetry /\n * reconcileAttempt. Reconciliation remains engine-owned: this wrapper delegates\n * reconcileAttempt to retrieveAttempt and never asks the adapter to persist.\n */\nexport function wrapV1AdapterForSplitInV2(adapter: VerificationAdapterV1): SplitInV2AdapterSurface {\n return {\n requestRetry: (command) => adapter.retryAttempt(command),\n retrieveAttempt: (command) => adapter.retrieveAttempt(command),\n reconcileAttempt: async (command) => {\n const snapshot = await adapter.retrieveAttempt(command);\n return {\n ...snapshot,\n canonicalStatus: mapStatusV1ToV2(snapshot.canonicalStatus),\n safeMetadata: metadataV1ToV2(snapshot.safeMetadata, command.attemptId),\n };\n },\n };\n}\n\nexport function mapManifestWebhookV1ToV2(manifest: ProviderManifestV1): {\n authentication: string;\n eventTypes: string[];\n toleranceSeconds?: number;\n} {\n return {\n authentication: mapWebhookProtocolV1ToV2(manifest.webhook.protocol),\n eventTypes: manifest.webhook.eventFamilies,\n toleranceSeconds: manifest.webhook.toleranceSeconds,\n };\n}\n\nexport function mapRedactionCommandV2ToV1(command: {\n subjectReference: string;\n providerResourceId?: string | null;\n providerResourceType?: string;\n requestReference: string;\n}): ProviderRedactionCommand {\n return {\n subjectReference: command.subjectReference,\n providerResourceId: command.providerResourceId,\n providerResourceType: command.providerResourceType,\n requestReference: command.requestReference,\n };\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@splitin/verification-compat-splitin-v2",
3
+ "version": "0.1.0-beta.0",
4
+ "description": "Temporary mapping between public Verification Adapter V1 and SplitIn internal V2. Do not consume from SplitIn yet.",
5
+ "license": "MIT",
6
+ "author": "SplitInTech, @ojchavan",
7
+ "homepage": "https://github.com/splitintech/open-internal-tools/tree/main/verification-adapter-sdk/packages/verification-compat-splitin-v2#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/splitintech/open-internal-tools.git",
11
+ "directory": "verification-adapter-sdk/packages/verification-compat-splitin-v2"
12
+ },
13
+ "type": "module",
14
+ "sideEffects": false,
15
+ "engines": { "node": ">=20" },
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.cjs"
24
+ }
25
+ },
26
+ "files": ["dist", "LICENSE", "NOTICE", "README.md", "package.json"],
27
+ "publishConfig": { "access": "public" },
28
+ "scripts": {
29
+ "build": "tsup",
30
+ "test": "vitest run",
31
+ "typecheck": "tsc --noEmit -p tsconfig.json"
32
+ },
33
+ "dependencies": {
34
+ "@splitin/verification-adapter-sdk": "0.1.0-beta.0"
35
+ },
36
+ "devDependencies": {
37
+ "tsup": "^8.5.0",
38
+ "typescript": "^5.8.3",
39
+ "vitest": "^3.2.4"
40
+ }
41
+ }