@splitin/verification-postgres 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/QUERY_PLANS.md ADDED
@@ -0,0 +1,90 @@
1
+ # Query plan notes for schema `verification`
2
+
3
+ Live `EXPLAIN (FORMAT JSON)` coverage runs in `tests/live.test.ts` when
4
+ `VERIFICATION_DATABASE_URL` is set (CI PostgreSQL 15 and 16). Hosts should
5
+ still capture `EXPLAIN (ANALYZE, BUFFERS)` against production-like data after
6
+ applying `001_init.sql` and `003_retention.sql`.
7
+
8
+ ## Route selection
9
+
10
+ ```sql
11
+ SELECT *
12
+ FROM verification.routes
13
+ WHERE tenant_key = $1
14
+ AND environment = $2
15
+ AND package_code = $3
16
+ AND lifecycle = 'active'
17
+ AND (country_code IS NULL OR country_code = $4)
18
+ ORDER BY priority, id;
19
+ ```
20
+
21
+ Intended index: `routes_active_selection_idx` (partial on `lifecycle = 'active'`).
22
+ The planner should perform an index range scan on `(tenant_key, environment, package_code)`
23
+ and filter country/cohort/window in memory. Do not sequential-scan `routes`.
24
+
25
+ ## Active attempts
26
+
27
+ ```sql
28
+ SELECT *
29
+ FROM verification.attempts
30
+ WHERE tenant_key = $1
31
+ AND subject_hash = $2
32
+ AND package_code = $3
33
+ AND canonical_status IN (
34
+ 'created', 'pending_user_input', 'paused', 'processing', 'manual_review_required'
35
+ )
36
+ ORDER BY updated_at DESC;
37
+ ```
38
+
39
+ Intended index: `attempts_active_idx`. Partial index keeps live rows only.
40
+
41
+ ## Valid decisions
42
+
43
+ ```sql
44
+ SELECT *
45
+ FROM verification.decisions
46
+ WHERE tenant_key = $1
47
+ AND subject_hash = $2
48
+ AND package_code = $3
49
+ AND status = 'verified'
50
+ AND revoked_at IS NULL
51
+ AND (expires_at IS NULL OR expires_at > now())
52
+ ORDER BY effective_at DESC
53
+ LIMIT 1;
54
+ ```
55
+
56
+ Intended index: `decisions_valid_idx`. Provider health and circuit state must not
57
+ appear in this plan; unexpired verified decisions are reused independently.
58
+
59
+ ## Pending webhook / reconcile / redaction jobs
60
+
61
+ Workers claim with:
62
+
63
+ ```sql
64
+ SELECT *
65
+ FROM verification.reconciliation_jobs
66
+ WHERE tenant_key = $1
67
+ AND state IN ('scheduled', 'retryable')
68
+ AND next_attempt_at <= now()
69
+ ORDER BY next_attempt_at, id
70
+ FOR UPDATE SKIP LOCKED
71
+ LIMIT $2;
72
+ ```
73
+
74
+ Intended indexes: `reconciliation_pending_idx`, `redaction_pending_idx`,
75
+ `webhook_leases_work_idx`. `FOR UPDATE SKIP LOCKED` avoids lock waits under
76
+ bounded concurrency. Never `SELECT FOR UPDATE` without `SKIP LOCKED` on the
77
+ worker path.
78
+
79
+ ## Idempotency before provider I/O
80
+
81
+ ```sql
82
+ INSERT INTO verification.idempotency_claims (tenant_key, claim_key, operation, attempt_id, state)
83
+ VALUES ($1, $2, $3, $4, 'claimed')
84
+ ON CONFLICT (tenant_key, claim_key) DO NOTHING
85
+ RETURNING *;
86
+ ```
87
+
88
+ Primary key `(tenant_key, claim_key)` makes this an index unique insert.
89
+ Commit this transaction **before** the provider HTTP call. Bind the provider
90
+ resource in a second short transaction.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ PostgreSQL persistence for `@splitin/verification-engine`. Schema name is
2
+ fixed to `verification`. Hosts inject a `query(sql, params)` executor
3
+ compatible with `pg` and serverless clients. `pg` is an optional peer
4
+ dependency.
5
+
6
+ ```ts
7
+ import { createPostgresStore, createPostgresQueue } from '@splitin/verification-postgres';
8
+ ```
9
+
10
+ Subject and resource references are HMAC-hashed with an injected secret
11
+ before they cross the database boundary. Raw webhooks, launch credentials,
12
+ hosted URLs, documents, selfies, and expanded identity outputs are never
13
+ persisted.