@agenticprimitives/connect-auth 0.1.0-alpha.2

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,106 @@
1
+ /**
2
+ * Passkey (WebAuthn) auth method.
3
+ *
4
+ * This module is the home of the WebAuthn ceremony for the agenticprimitives
5
+ * stack:
6
+ * - challenge encoding (32-byte hash → base64url challenge)
7
+ * - DER signature parsing → (r, s)
8
+ * - low-s normalisation (P-256 group order)
9
+ * - WebAuthn `Assertion` struct building from a raw browser response
10
+ * (the structured form that `AgentAccount._verifyWebAuthn` consumes)
11
+ * - COSE attestation parsing → P-256 (x, y) public key for on-chain
12
+ * credential registration via `AgentAccountFactory.createAccountWithPasskey`
13
+ *
14
+ * Doctrine: passkey ceremony belongs in connect-auth per the package's
15
+ * CLAUDE.md. Downstream packages (`agent-account`) consume the
16
+ * `WebAuthnAssertion` struct produced here and encode it into the
17
+ * smart-account signature wire format (`0x01 || abi.encode(...)`).
18
+ *
19
+ * Ported from smart-agent `packages/sdk/src/{passkey,cose-parse}.ts`
20
+ * (branch 003-intent-marketplace-proposal) — adapted to agenticprimitives
21
+ * package boundaries.
22
+ */
23
+ import type { Hex } from '../types';
24
+ /** secp256r1 (P-256) group order. */
25
+ export declare const P256_N = 115792089210356248762697446949407573529996955224135760342422259061068512044369n;
26
+ export declare function base64urlEncode(bytes: Uint8Array): string;
27
+ export declare function base64urlDecode(s: string): Uint8Array;
28
+ export declare function parseDerSignature(der: Uint8Array): {
29
+ r: bigint;
30
+ s: bigint;
31
+ };
32
+ /**
33
+ * Many WebAuthn authenticators emit high-s signatures (allowed by FIPS
34
+ * 186-4). The on-chain RIP-7212 precompile accepts both halves, but we
35
+ * normalise defensively so we stay compatible with stricter off-chain
36
+ * verifiers.
37
+ */
38
+ export declare function normaliseLowS(s: bigint): bigint;
39
+ /**
40
+ * Structured WebAuthn assertion in the shape `AgentAccount._verifyWebAuthn`
41
+ * consumes (the contract decodes this struct from the signature blob).
42
+ *
43
+ * Distinct from `PasskeyAssertion` (in `../types`), which is the
44
+ * protocol-level raw form returned by `PasskeySigner.assert()`.
45
+ */
46
+ export interface WebAuthnAssertion {
47
+ authenticatorData: Hex;
48
+ clientDataJSON: string;
49
+ challengeIndex: bigint;
50
+ typeIndex: bigint;
51
+ r: bigint;
52
+ s: bigint;
53
+ credentialIdDigest: Hex;
54
+ }
55
+ /**
56
+ * Build a `WebAuthnAssertion` from a raw browser
57
+ * `navigator.credentials.get()` response.
58
+ *
59
+ * @param credentialIdBytes raw credentialId bytes
60
+ * @param authenticatorData response.authenticatorData
61
+ * @param clientDataJSON response.clientDataJSON (UTF-8 bytes)
62
+ * @param derSignature response.signature (DER ECDSA)
63
+ */
64
+ export declare function buildWebAuthnAssertion(args: {
65
+ credentialIdBytes: Uint8Array;
66
+ authenticatorData: Uint8Array;
67
+ clientDataJSON: Uint8Array;
68
+ derSignature: Uint8Array;
69
+ }): WebAuthnAssertion;
70
+ /**
71
+ * Convert a 32-byte hash to the base64url-encoded challenge string
72
+ * `navigator.credentials.get({ publicKey: { challenge } })` accepts.
73
+ */
74
+ export declare function hashToWebAuthnChallenge(hash: Hex): string;
75
+ export interface ParsedAttestation {
76
+ credentialId: Uint8Array;
77
+ credentialIdBase64Url: string;
78
+ pubKeyX: bigint;
79
+ pubKeyY: bigint;
80
+ aaguid: Uint8Array;
81
+ signCount: number;
82
+ flagAttestedCredentialData: boolean;
83
+ flagUserPresent: boolean;
84
+ flagUserVerified: boolean;
85
+ }
86
+ /**
87
+ * Parse a WebAuthn `attestationObject` (CBOR-encoded) returned by
88
+ * `navigator.credentials.create()` → P-256 public key (x, y) plus
89
+ * credentialId, suitable for on-chain registration via
90
+ * `AgentAccountFactory.createAccountWithPasskey(credentialIdDigest, x, y, salt)`.
91
+ */
92
+ export declare function parseAttestationObject(attestationObject: Uint8Array): ParsedAttestation;
93
+ export declare function parseAuthData(authData: Uint8Array): ParsedAttestation;
94
+ export interface PasskeySignupInput {
95
+ label: string;
96
+ challenge: Hex;
97
+ }
98
+ export declare function beginSignup(_input: {
99
+ label: string;
100
+ }): Promise<never>;
101
+ export declare function completeSignup(_req: unknown): Promise<never>;
102
+ export declare function beginLogin(_input: {
103
+ credentialId: string;
104
+ }): Promise<never>;
105
+ export declare function completeLogin(_req: unknown): Promise<never>;
106
+ //# sourceMappingURL=passkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkey.d.ts","sourceRoot":"","sources":["../../src/methods/passkey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC,qCAAqC;AACrC,eAAO,MAAM,MAAM,kFACkD,CAAC;AAItE,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CASzD;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAYrD;AAID,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAiB3E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAID;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,GAAG,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,kBAAkB,EAAE,GAAG,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,iBAAiB,EAAE,UAAU,CAAC;IAC9B,iBAAiB,EAAE,UAAU,CAAC;IAC9B,cAAc,EAAE,UAAU,CAAC;IAC3B,YAAY,EAAE,UAAU,CAAC;CAC1B,GAAG,iBAAiB,CA2BpB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAEzD;AAID,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,UAAU,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B,EAAE,OAAO,CAAC;IACpC,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,UAAU,GAC5B,iBAAiB,CAQnB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,UAAU,GAAG,iBAAiB,CA2CrE;AAID,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAE3E;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAElE;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAEjF;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAEjE"}
@@ -0,0 +1,307 @@
1
+ /**
2
+ * Passkey (WebAuthn) auth method.
3
+ *
4
+ * This module is the home of the WebAuthn ceremony for the agenticprimitives
5
+ * stack:
6
+ * - challenge encoding (32-byte hash → base64url challenge)
7
+ * - DER signature parsing → (r, s)
8
+ * - low-s normalisation (P-256 group order)
9
+ * - WebAuthn `Assertion` struct building from a raw browser response
10
+ * (the structured form that `AgentAccount._verifyWebAuthn` consumes)
11
+ * - COSE attestation parsing → P-256 (x, y) public key for on-chain
12
+ * credential registration via `AgentAccountFactory.createAccountWithPasskey`
13
+ *
14
+ * Doctrine: passkey ceremony belongs in connect-auth per the package's
15
+ * CLAUDE.md. Downstream packages (`agent-account`) consume the
16
+ * `WebAuthnAssertion` struct produced here and encode it into the
17
+ * smart-account signature wire format (`0x01 || abi.encode(...)`).
18
+ *
19
+ * Ported from smart-agent `packages/sdk/src/{passkey,cose-parse}.ts`
20
+ * (branch 003-intent-marketplace-proposal) — adapted to agenticprimitives
21
+ * package boundaries.
22
+ */
23
+ import { keccak256, toHex, toBytes } from 'viem';
24
+ // ─── Constants ───────────────────────────────────────────────────────
25
+ /** secp256r1 (P-256) group order. */
26
+ export const P256_N = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n;
27
+ // ─── Base64url codec ─────────────────────────────────────────────────
28
+ export function base64urlEncode(bytes) {
29
+ let bin = '';
30
+ for (const b of bytes)
31
+ bin += String.fromCharCode(b);
32
+ const b64 = typeof btoa === 'function'
33
+ ? btoa(bin)
34
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
+ globalThis.Buffer.from(bytes).toString('base64');
36
+ return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
37
+ }
38
+ export function base64urlDecode(s) {
39
+ const padded = s.replace(/-/g, '+').replace(/_/g, '/') +
40
+ '=='.slice((2 - (s.length & 3)) & 3);
41
+ const bin = typeof atob === 'function'
42
+ ? atob(padded)
43
+ : // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ globalThis.Buffer.from(padded, 'base64').toString('binary');
45
+ const out = new Uint8Array(bin.length);
46
+ for (let i = 0; i < bin.length; i++)
47
+ out[i] = bin.charCodeAt(i);
48
+ return out;
49
+ }
50
+ // ─── DER signature parsing + low-s normalisation ─────────────────────
51
+ export function parseDerSignature(der) {
52
+ if (der.length < 8)
53
+ throw new Error('DER: too short');
54
+ if (der[0] !== 0x30)
55
+ throw new Error('DER: missing sequence tag');
56
+ let i = 2;
57
+ if (der[i] !== 0x02)
58
+ throw new Error('DER: missing r tag');
59
+ i++;
60
+ const rLen = der[i];
61
+ i++;
62
+ const rBytes = der.slice(i, i + rLen);
63
+ i += rLen;
64
+ if (der[i] !== 0x02)
65
+ throw new Error('DER: missing s tag');
66
+ i++;
67
+ const sLen = der[i];
68
+ i++;
69
+ const sBytes = der.slice(i, i + sLen);
70
+ i += sLen;
71
+ return { r: bytesToBigInt(rBytes), s: bytesToBigInt(sBytes) };
72
+ }
73
+ /**
74
+ * Many WebAuthn authenticators emit high-s signatures (allowed by FIPS
75
+ * 186-4). The on-chain RIP-7212 precompile accepts both halves, but we
76
+ * normalise defensively so we stay compatible with stricter off-chain
77
+ * verifiers.
78
+ */
79
+ export function normaliseLowS(s) {
80
+ return s > P256_N / 2n ? P256_N - s : s;
81
+ }
82
+ /**
83
+ * Build a `WebAuthnAssertion` from a raw browser
84
+ * `navigator.credentials.get()` response.
85
+ *
86
+ * @param credentialIdBytes raw credentialId bytes
87
+ * @param authenticatorData response.authenticatorData
88
+ * @param clientDataJSON response.clientDataJSON (UTF-8 bytes)
89
+ * @param derSignature response.signature (DER ECDSA)
90
+ */
91
+ export function buildWebAuthnAssertion(args) {
92
+ const cdjStr = new TextDecoder().decode(args.clientDataJSON);
93
+ const cdjBytes = args.clientDataJSON;
94
+ const typeMarker = new TextEncoder().encode('"type":"webauthn.get"');
95
+ const typeIndex = findIndex(cdjBytes, typeMarker);
96
+ if (typeIndex < 0) {
97
+ throw new Error('clientDataJSON: missing "type":"webauthn.get"');
98
+ }
99
+ const challengeMarker = new TextEncoder().encode('"challenge":"');
100
+ const challengeIndex = findIndex(cdjBytes, challengeMarker);
101
+ if (challengeIndex < 0) {
102
+ throw new Error('clientDataJSON: missing "challenge" key');
103
+ }
104
+ const { r, s } = parseDerSignature(args.derSignature);
105
+ return {
106
+ authenticatorData: toHex(args.authenticatorData),
107
+ clientDataJSON: cdjStr,
108
+ challengeIndex: BigInt(challengeIndex),
109
+ typeIndex: BigInt(typeIndex),
110
+ r,
111
+ s: normaliseLowS(s),
112
+ credentialIdDigest: keccak256(args.credentialIdBytes),
113
+ };
114
+ }
115
+ /**
116
+ * Convert a 32-byte hash to the base64url-encoded challenge string
117
+ * `navigator.credentials.get({ publicKey: { challenge } })` accepts.
118
+ */
119
+ export function hashToWebAuthnChallenge(hash) {
120
+ return base64urlEncode(toBytes(hash));
121
+ }
122
+ /**
123
+ * Parse a WebAuthn `attestationObject` (CBOR-encoded) returned by
124
+ * `navigator.credentials.create()` → P-256 public key (x, y) plus
125
+ * credentialId, suitable for on-chain registration via
126
+ * `AgentAccountFactory.createAccountWithPasskey(credentialIdDigest, x, y, salt)`.
127
+ */
128
+ export function parseAttestationObject(attestationObject) {
129
+ const top = cborDecode(attestationObject);
130
+ if (!isMap(top))
131
+ throw new Error('attestationObject: expected CBOR map');
132
+ const authData = mapGet(top, 'authData');
133
+ if (!(authData instanceof Uint8Array)) {
134
+ throw new Error('attestationObject: missing authData');
135
+ }
136
+ return parseAuthData(authData);
137
+ }
138
+ export function parseAuthData(authData) {
139
+ if (authData.length < 37)
140
+ throw new Error('authData too short');
141
+ const flags = authData[32];
142
+ const signCount = new DataView(authData.buffer, authData.byteOffset + 33, 4).getUint32(0, false);
143
+ const flagUP = (flags & 0x01) !== 0;
144
+ const flagUV = (flags & 0x04) !== 0;
145
+ const flagAT = (flags & 0x40) !== 0;
146
+ if (!flagAT) {
147
+ throw new Error('authData: attested credential data flag not set');
148
+ }
149
+ if (authData.length < 37 + 16 + 2) {
150
+ throw new Error('authData too short for attested credential data');
151
+ }
152
+ let i = 37;
153
+ const aaguid = authData.slice(i, i + 16);
154
+ i += 16;
155
+ const credIdLen = (authData[i] << 8) | authData[i + 1];
156
+ i += 2;
157
+ const credentialId = authData.slice(i, i + credIdLen);
158
+ i += credIdLen;
159
+ const cosePubKeyBytes = authData.slice(i);
160
+ const coseMap = cborDecode(cosePubKeyBytes);
161
+ if (!isMap(coseMap))
162
+ throw new Error('COSE_Key: expected map');
163
+ const x = mapGet(coseMap, -2);
164
+ const y = mapGet(coseMap, -3);
165
+ if (!(x instanceof Uint8Array) || !(y instanceof Uint8Array)) {
166
+ throw new Error('COSE_Key: missing x/y coordinates');
167
+ }
168
+ return {
169
+ credentialId,
170
+ credentialIdBase64Url: base64urlFromBytes(credentialId),
171
+ pubKeyX: bytesToBigInt(x),
172
+ pubKeyY: bytesToBigInt(y),
173
+ aaguid,
174
+ signCount,
175
+ flagAttestedCredentialData: flagAT,
176
+ flagUserPresent: flagUP,
177
+ flagUserVerified: flagUV,
178
+ };
179
+ }
180
+ export async function beginSignup(_input) {
181
+ throw new Error('connect-auth/passkey: beginSignup not implemented yet.');
182
+ }
183
+ export async function completeSignup(_req) {
184
+ throw new Error('connect-auth/passkey: completeSignup not implemented yet.');
185
+ }
186
+ export async function beginLogin(_input) {
187
+ throw new Error('connect-auth/passkey: beginLogin not implemented yet.');
188
+ }
189
+ export async function completeLogin(_req) {
190
+ throw new Error('connect-auth/passkey: completeLogin not implemented yet.');
191
+ }
192
+ // ─── Private helpers ─────────────────────────────────────────────────
193
+ function bytesToBigInt(b) {
194
+ let n = 0n;
195
+ for (const x of b)
196
+ n = (n << 8n) | BigInt(x);
197
+ return n;
198
+ }
199
+ function base64urlFromBytes(b) {
200
+ return base64urlEncode(b);
201
+ }
202
+ function findIndex(haystack, needle) {
203
+ outer: for (let i = 0; i + needle.length <= haystack.length; i++) {
204
+ for (let j = 0; j < needle.length; j++) {
205
+ if (haystack[i + j] !== needle[j])
206
+ continue outer;
207
+ }
208
+ return i;
209
+ }
210
+ return -1;
211
+ }
212
+ function isMap(v) {
213
+ return v instanceof Map;
214
+ }
215
+ function mapGet(m, key) {
216
+ if (m.has(key))
217
+ return m.get(key);
218
+ if (typeof key === 'number') {
219
+ const bk = BigInt(key);
220
+ if (m.has(bk))
221
+ return m.get(bk);
222
+ }
223
+ return undefined;
224
+ }
225
+ function cborDecode(bytes) {
226
+ const reader = {
227
+ view: new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength),
228
+ pos: 0,
229
+ };
230
+ return decodeOne(reader);
231
+ function decodeOne(r) {
232
+ const first = r.view.getUint8(r.pos++);
233
+ const major = first >> 5;
234
+ const minor = first & 0x1f;
235
+ const len = readLength(r, minor);
236
+ switch (major) {
237
+ case 0:
238
+ return len;
239
+ case 1:
240
+ return typeof len === 'bigint'
241
+ ? -(len + 1n)
242
+ : -len - 1;
243
+ case 2: {
244
+ const b = new Uint8Array(r.view.buffer, r.view.byteOffset + r.pos, Number(len));
245
+ r.pos += Number(len);
246
+ return b.slice();
247
+ }
248
+ case 3: {
249
+ const b = new Uint8Array(r.view.buffer, r.view.byteOffset + r.pos, Number(len));
250
+ r.pos += Number(len);
251
+ return new TextDecoder().decode(b);
252
+ }
253
+ case 4: {
254
+ const out = [];
255
+ for (let i = 0n; i < BigInt(len); i++)
256
+ out.push(decodeOne(r));
257
+ return out;
258
+ }
259
+ case 5: {
260
+ const m = new Map();
261
+ for (let i = 0n; i < BigInt(len); i++) {
262
+ const k = decodeOne(r);
263
+ const v = decodeOne(r);
264
+ m.set(k, v);
265
+ }
266
+ return m;
267
+ }
268
+ case 7:
269
+ if (minor === 20)
270
+ return false;
271
+ if (minor === 21)
272
+ return true;
273
+ if (minor === 22)
274
+ return null;
275
+ throw new Error('CBOR: unsupported simple/float value');
276
+ default:
277
+ throw new Error(`CBOR: unsupported major type ${major}`);
278
+ }
279
+ }
280
+ function readLength(r, minor) {
281
+ if (minor < 24)
282
+ return minor;
283
+ if (minor === 24) {
284
+ const v = r.view.getUint8(r.pos);
285
+ r.pos += 1;
286
+ return v;
287
+ }
288
+ if (minor === 25) {
289
+ const v = r.view.getUint16(r.pos, false);
290
+ r.pos += 2;
291
+ return v;
292
+ }
293
+ if (minor === 26) {
294
+ const v = r.view.getUint32(r.pos, false);
295
+ r.pos += 4;
296
+ return v;
297
+ }
298
+ if (minor === 27) {
299
+ const hi = r.view.getUint32(r.pos, false);
300
+ const lo = r.view.getUint32(r.pos + 4, false);
301
+ r.pos += 8;
302
+ return (BigInt(hi) << 32n) | BigInt(lo);
303
+ }
304
+ throw new Error('CBOR: indefinite-length / reserved length not supported');
305
+ }
306
+ }
307
+ //# sourceMappingURL=passkey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkey.js","sourceRoot":"","sources":["../../src/methods/passkey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGjD,wEAAwE;AAExE,qCAAqC;AACrC,MAAM,CAAC,MAAM,MAAM,GACjB,mEAAmE,CAAC;AAEtE,wEAAwE;AAExE,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACrD,MAAM,GAAG,GACP,OAAO,IAAI,KAAK,UAAU;QACxB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACX,CAAC,CAAC,8DAA8D;YAC7D,UAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChE,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,CAAS;IACvC,MAAM,MAAM,GACV,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,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';
2
+ export interface SiweMessageInput {
3
+ domain: string;
4
+ address: Address;
5
+ statement?: string;
6
+ uri: string;
7
+ chainId: number;
8
+ nonce: string;
9
+ issuedAt?: string;
10
+ expirationTime?: string;
11
+ }
12
+ export interface SiweParsed {
13
+ domain: string;
14
+ address: Address;
15
+ statement: string | null;
16
+ uri: string;
17
+ version: string;
18
+ chainId: number;
19
+ nonce: string;
20
+ issuedAt: string;
21
+ expirationTime: string | null;
22
+ }
23
+ /** Build an EIP-4361 message string from structured input. */
24
+ export declare function buildMessage(input: SiweMessageInput): string;
25
+ /**
26
+ * Parse a SIWE message into its fields. Strict: rejects messages that don't
27
+ * match the EIP-4361 shape we produce. We deliberately don't accept every
28
+ * valid SIWE message variant — only what we generate.
29
+ */
30
+ export declare function parseMessage(text: string): SiweParsed;
31
+ export interface SiweVerifyResult {
32
+ ok: true;
33
+ address: Address;
34
+ parsed: SiweParsed;
35
+ }
36
+ export interface SiweVerifyError {
37
+ ok: false;
38
+ reason: string;
39
+ }
40
+ /**
41
+ * Pure parse-and-validate — checks version, domain, nonce, expiration,
42
+ * and computes the EIP-191 digest. Does NOT verify the signature.
43
+ *
44
+ * Used by `verify` (ECDSA path) and `verifyOnchain` (ERC-1271/6492 path).
45
+ * Splitting this out lets callers verify signatures against a contract
46
+ * (e.g. `UniversalSignatureValidator`) without re-implementing the SIWE
47
+ * field validation.
48
+ */
49
+ export declare function parseAndValidate(message: string, opts?: {
50
+ now?: () => number;
51
+ allowedDomains?: string[];
52
+ expectedNonce?: string;
53
+ }): {
54
+ ok: true;
55
+ parsed: SiweParsed;
56
+ digest: Uint8Array;
57
+ } | SiweVerifyError;
58
+ /**
59
+ * Verify a SIWE message via a caller-supplied async signature verifier
60
+ * (typically `verifyUserSignature` from `./verify-signature`, which calls
61
+ * the on-chain `UniversalSignatureValidator`).
62
+ *
63
+ * Per spec 130 and the `demo-a2a is signer-agnostic` doctrine: when the
64
+ * SIWE `address` is a smart account, this is how we verify — the
65
+ * validator dispatches between ECDSA / ERC-1271 / ERC-6492 on-chain,
66
+ * supporting EOA-owned, passkey-owned, and counterfactual accounts
67
+ * without the caller branching on signer type.
68
+ */
69
+ export declare function verifyOnchain(message: string, signature: Hex, signatureVerifier: (args: {
70
+ signer: Address;
71
+ hash: Hex;
72
+ signature: Hex;
73
+ }) => Promise<boolean>, opts?: {
74
+ now?: () => number;
75
+ allowedDomains?: string[];
76
+ expectedNonce?: string;
77
+ }): Promise<SiweVerifyResult | SiweVerifyError>;
78
+ /**
79
+ * Legacy ECDSA-only SIWE verifier. Recovers the signer address from the
80
+ * 65-byte signature and compares against the message's `address` field.
81
+ *
82
+ * Prefer `verifyOnchain` for new code — it goes through the universal
83
+ * validator and works for both EOA-owned and smart-account-owned
84
+ * (passkey, multisig, etc.) signers. Kept here for backward compat with
85
+ * the existing `verify` tests and the EOA-only siwe verifier path.
86
+ */
87
+ export declare function verify(message: string, signature: Hex, opts?: {
88
+ now?: () => number;
89
+ allowedDomains?: string[];
90
+ expectedNonce?: string;
91
+ }): SiweVerifyResult | SiweVerifyError;
92
+ //# sourceMappingURL=siwe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siwe.d.ts","sourceRoot":"","sources":["../../src/methods/siwe.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,SA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