@reclaimprotocol/client 0.1.29 → 0.1.31
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/README.md +255 -234
- package/lib/api.d.ts +2 -0
- package/lib/api.js +2 -0
- package/lib/client.js +2 -0
- package/lib/enckeys.d.ts +1 -1
- package/lib/enckeys.js +2 -2
- package/lib/encoding.d.ts +4 -0
- package/lib/encoding.js +10 -0
- package/lib/feature-flags.d.ts +9 -0
- package/lib/feature-flags.js +19 -0
- package/lib/index.d.ts +4 -4
- package/lib/index.js +4 -4
- package/lib/jwks.d.ts +8 -8
- package/lib/jwks.js +38 -17
- package/lib/launch/destination.d.ts +14 -0
- package/lib/launch/destination.js +89 -0
- package/lib/launch/device.d.ts +30 -0
- package/lib/launch/device.js +168 -0
- package/lib/launch/environment.d.ts +224 -0
- package/lib/launch/environment.js +98 -0
- package/lib/launch/errors.d.ts +20 -0
- package/lib/launch/errors.js +25 -0
- package/lib/launch/extension.d.ts +42 -0
- package/lib/launch/extension.js +72 -0
- package/lib/launch/flow.d.ts +82 -0
- package/lib/launch/flow.js +222 -0
- package/lib/launch/index.d.ts +16 -0
- package/lib/launch/index.js +12 -0
- package/lib/launch/mobile.d.ts +77 -0
- package/lib/launch/mobile.js +124 -0
- package/lib/launch/modal.d.ts +50 -0
- package/lib/launch/modal.js +258 -0
- package/lib/launch/options.d.ts +74 -0
- package/lib/launch/options.js +20 -0
- package/lib/launch/portal.d.ts +28 -0
- package/lib/launch/portal.js +68 -0
- package/lib/launch/qr.d.ts +5 -0
- package/lib/launch/qr.js +28 -0
- package/lib/launch/target.d.ts +46 -0
- package/lib/launch/target.js +128 -0
- package/lib/launch/vendor/qrcodegen.d.ts +134 -0
- package/lib/launch/vendor/qrcodegen.js +822 -0
- package/lib/legacy-proof.d.ts +2 -0
- package/lib/legacy-proof.js +37 -7
- package/lib/proof-hash.d.ts +5 -5
- package/lib/proof-hash.js +1 -1
- package/lib/proof-recipe.d.ts +3 -3
- package/lib/proof-recipe.js +1 -1
- package/lib/proof-types.d.ts +35 -8
- package/lib/reclaim.d.ts +81 -70
- package/lib/reclaim.js +79 -130
- package/lib/request-proof.d.ts +60 -0
- package/lib/request-proof.js +241 -0
- package/lib/result.d.ts +46 -38
- package/lib/result.js +160 -100
- package/lib/routes.gen.d.ts +76 -28
- package/lib/routes.gen.js +24 -11
- package/lib/tee-binding.d.ts +1 -1
- package/lib/types/openapi.d.ts +1 -0
- package/lib/types/openapi.gen.d.ts +1594 -488
- package/lib/types/openapi.gen.js +5 -0
- package/lib/verification-clients.d.ts +28 -14
- package/lib/verification-clients.js +31 -11
- package/lib/verify-attestor-tee.d.ts +19 -2
- package/lib/verify-attestor-tee.js +40 -4
- package/lib/verify-tee.d.ts +10 -1
- package/lib/verify-tee.js +34 -10
- package/package.json +5 -1
- package/src/api.ts +9 -0
- package/src/client.ts +2 -0
- package/src/enckeys.ts +2 -2
- package/src/encoding.ts +12 -0
- package/src/feature-flags.ts +39 -0
- package/src/index.ts +13 -14
- package/src/jwks.ts +52 -30
- package/src/launch/destination.ts +111 -0
- package/src/launch/device.ts +242 -0
- package/src/launch/environment.ts +337 -0
- package/src/launch/errors.ts +49 -0
- package/src/launch/extension.ts +124 -0
- package/src/launch/flow.ts +369 -0
- package/src/launch/index.ts +42 -0
- package/src/launch/mobile.ts +184 -0
- package/src/launch/modal.ts +378 -0
- package/src/launch/options.ts +99 -0
- package/src/launch/portal.ts +104 -0
- package/src/launch/qr.ts +37 -0
- package/src/launch/target.ts +150 -0
- package/src/launch/vendor/qrcodegen.ts +1034 -0
- package/src/proof-hash.ts +6 -6
- package/src/proof-recipe.ts +3 -3
- package/src/proof-types.ts +36 -8
- package/src/reclaim.ts +185 -218
- package/src/{legacy-proof.ts → request-proof.ts} +81 -36
- package/src/result.ts +238 -172
- package/src/routes.gen.ts +24 -11
- package/src/tee-binding.ts +1 -1
- package/src/types/openapi.gen.ts +1599 -488
- package/src/types/openapi.ts +3 -1
- package/src/verification-clients.ts +33 -19
- package/src/verify-attestor-tee.ts +66 -8
- package/src/verify-tee.ts +44 -13
- package/lib/api-client.d.ts +0 -31
- package/lib/api-client.js +0 -112
- package/lib/api-consts.d.ts +0 -4
- package/lib/api-consts.js +0 -4
- package/lib/api-errors.d.ts +0 -13
- package/lib/api-errors.js +0 -30
- package/lib/eip712.d.ts +0 -20
- package/lib/eip712.js +0 -108
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which client a `verificationUrl` names, and what a caller-supplied
|
|
3
|
+
* `verificationClientId` escape hatch can override.
|
|
4
|
+
*
|
|
5
|
+
* `build_verification_url` (packages/app/sql/ddl.sql) appends
|
|
6
|
+
* `?api=2&sessionId=<uuid>` (plus optional `&diag=1`) to the registered
|
|
7
|
+
* client's base URL, so parsing the path is enough to name the client — the
|
|
8
|
+
* registered URI is an attribution label, never the URL to open (see
|
|
9
|
+
* ./destination.ts for what actually gets opened).
|
|
10
|
+
*
|
|
11
|
+
* As of migration `20260917130000000.share-routes-uris.sql`, every built-in
|
|
12
|
+
* client (`builder` included) registers at the uniform `{origin}/share/
|
|
13
|
+
* {name}` shape (see `packages/app/src/verification/builtin-clients.ts`'s
|
|
14
|
+
* `clientUrl()` and `packages/app/src/routes/SharePage.tsx`). Only four of
|
|
15
|
+
* the six names are launchable targets here — `inapp-sdk` and `zkfetch` have
|
|
16
|
+
* no claimant browser flow, so `/share/inapp-sdk` and `/share/zkfetch`
|
|
17
|
+
* degrade the same as the old bare `/zkfetch` label always did.
|
|
18
|
+
*
|
|
19
|
+
* The pre-migration shapes — `/portals`, `/s` / `/verifier-app`,
|
|
20
|
+
* `/reclaim-browser-extension`, and `builder`'s own `/v/{id}` — are kept
|
|
21
|
+
* recognised too, deliberately, not just for a transition window:
|
|
22
|
+
* - a deployment that has not yet run that migration still seeds and
|
|
23
|
+
* serves the old uris, so dropping them would break every consumer
|
|
24
|
+
* hitting an un-migrated Builder;
|
|
25
|
+
* - `register_verification_client`'s seed upsert COALESCEs `uri` and never
|
|
26
|
+
* clobbers a non-null value, so an admin who set a custom (old-shape)
|
|
27
|
+
* uri before the migration keeps it forever — there is no future point
|
|
28
|
+
* at which the old shapes stop appearing in the wild;
|
|
29
|
+
* - `builder`'s own `/share/builder` route 302s to `/v/{sessionId}`
|
|
30
|
+
* server-side (see SharePage.tsx) — `/v/{id}` is where a claimant
|
|
31
|
+
* *actually lands* regardless of which shape the session was created
|
|
32
|
+
* against, so it must stay recognised independent of the migration
|
|
33
|
+
* question entirely.
|
|
34
|
+
* There is no ambiguity cost to recognising both: the shapes are disjoint
|
|
35
|
+
* path segments, so a URL can only ever match one.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export type VerificationTarget =
|
|
39
|
+
| 'builder'
|
|
40
|
+
| 'portals'
|
|
41
|
+
| 'verifier-app'
|
|
42
|
+
| 'reclaim-browser-extension'
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Fixed, deployment-independent ids for the built-in clients — duplicated
|
|
46
|
+
* from `packages/app/src/verification/builtin-clients.ts`'
|
|
47
|
+
* `BUILTIN_CLIENT_IDS` (also duplicated in the in-app SDK and the browser
|
|
48
|
+
* extension SDK). Changing one copy alone breaks every other caller.
|
|
49
|
+
*
|
|
50
|
+
* Used only as the `options.verificationClientId` escape hatch: when a
|
|
51
|
+
* staff-registered custom client's URL doesn't match the path convention
|
|
52
|
+
* above (an admin-overridden `uri`, or a fresh custom registration that was
|
|
53
|
+
* nonetheless assigned one of these fixed ids), a caller who knows the id
|
|
54
|
+
* out of band can still get the right launch mechanism instead of degrading
|
|
55
|
+
* to a tab. This is unrelated to — and does not feed — the extension
|
|
56
|
+
* handoff payload, which never carries a client id at all (see
|
|
57
|
+
* ./extension.ts).
|
|
58
|
+
*/
|
|
59
|
+
const BUILTIN_CLIENT_IDS: Record<VerificationTarget, string> = {
|
|
60
|
+
builder: '00000000-0000-4000-8000-000000000001',
|
|
61
|
+
'verifier-app': '00000000-0000-4000-8000-000000000002',
|
|
62
|
+
portals: '00000000-0000-4000-8000-000000000004',
|
|
63
|
+
'reclaim-browser-extension': '00000000-0000-4000-8000-000000000005',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ParsedFlowUrl {
|
|
67
|
+
url: URL
|
|
68
|
+
target: VerificationTarget | undefined
|
|
69
|
+
sessionId: string | undefined
|
|
70
|
+
diag: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Parses a `verificationUrl` into its client and session id, without
|
|
74
|
+
* rebuilding anything — see `./destination.ts` for the openable URL. */
|
|
75
|
+
export function parseFlowUrl(
|
|
76
|
+
verificationUrl: string,
|
|
77
|
+
verificationClientId?: string,
|
|
78
|
+
): ParsedFlowUrl {
|
|
79
|
+
const url = new URL(verificationUrl)
|
|
80
|
+
const segments = url.pathname.split('/').filter(Boolean)
|
|
81
|
+
|
|
82
|
+
let target: VerificationTarget | undefined
|
|
83
|
+
if(segments[0] === 'v' && segments.length >= 2) {
|
|
84
|
+
// Both a pre-migration `builder` uri (registered directly at
|
|
85
|
+
// `/v/{sessionId}`) and where a claimant's browser actually lands after
|
|
86
|
+
// `/share/builder`'s server-side 302 — recognised unconditionally, not
|
|
87
|
+
// merely as one of the two shapes below.
|
|
88
|
+
target = 'builder'
|
|
89
|
+
} else if(segments[0] === 'share' && segments.length >= 2) {
|
|
90
|
+
target = targetForShareName(segments[1])
|
|
91
|
+
} else if(segments[0] === 'portals') {
|
|
92
|
+
target = 'portals'
|
|
93
|
+
} else if(segments[0] === 's' || segments[0] === 'verifier-app') {
|
|
94
|
+
// `/s` is Builder's own share page and the uri `verifier-app` is
|
|
95
|
+
// registered at today; `/verifier-app` is the attribution-only label it
|
|
96
|
+
// used to carry, still recognised for a deployment that has not run the
|
|
97
|
+
// re-pointing migration (or whose admin kept the old uri).
|
|
98
|
+
target = 'verifier-app'
|
|
99
|
+
} else if(segments[0] === 'reclaim-browser-extension') {
|
|
100
|
+
target = 'reclaim-browser-extension'
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Falls back for EITHER an unrecognised path (old shape or new) or a
|
|
104
|
+
// `/share/{name}` naming a non-launchable client (`inapp-sdk`/`zkfetch`) —
|
|
105
|
+
// `targetForShareName` returning `undefined` for those must still let this
|
|
106
|
+
// run, not short-circuit it.
|
|
107
|
+
if(!target && verificationClientId) {
|
|
108
|
+
target = targetForClientId(verificationClientId)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
url,
|
|
113
|
+
target,
|
|
114
|
+
sessionId: url.searchParams.get('sessionId')?.trim() || undefined,
|
|
115
|
+
diag: url.searchParams.get('diag') === '1',
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The four launchable targets' `/share/{name}` segment, post-migration —
|
|
120
|
+
* see `builtin-clients.ts`'s `clientUrl()`. `inapp-sdk` and `zkfetch` get a
|
|
121
|
+
* real `/share/{name}` page too (so a stray GET doesn't 404), but neither
|
|
122
|
+
* has a claimant browser flow, so they degrade like the old bare `/zkfetch`
|
|
123
|
+
* label always did. */
|
|
124
|
+
function targetForShareName(name: string): VerificationTarget | undefined {
|
|
125
|
+
switch (name) {
|
|
126
|
+
case 'builder':
|
|
127
|
+
case 'portals':
|
|
128
|
+
case 'verifier-app':
|
|
129
|
+
case 'reclaim-browser-extension':
|
|
130
|
+
return name
|
|
131
|
+
default:
|
|
132
|
+
return undefined
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function targetForClientId(
|
|
137
|
+
verificationClientId: string,
|
|
138
|
+
): VerificationTarget | undefined {
|
|
139
|
+
const normalized = verificationClientId.trim().toLowerCase()
|
|
140
|
+
for(const [target, id] of Object.entries(BUILTIN_CLIENT_IDS)) {
|
|
141
|
+
if(id === normalized) {
|
|
142
|
+
// The key side of `Object.entries` on
|
|
143
|
+
// `Record<VerificationTarget, string>` is exactly
|
|
144
|
+
// `VerificationTarget`; TS widens it to `string` on the way out.
|
|
145
|
+
return target as VerificationTarget
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return undefined
|
|
150
|
+
}
|