@oxy.so/contracts 2.1.0 → 3.0.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.
Files changed (57) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountEmail.js +79 -0
  3. package/dist/cjs/deviceBoot.js +2 -2
  4. package/dist/cjs/deviceSession.js +73 -16
  5. package/dist/cjs/identity.js +1 -3
  6. package/dist/cjs/identityLink.js +92 -0
  7. package/dist/cjs/identityProof.js +6 -29
  8. package/dist/cjs/index.js +82 -65
  9. package/dist/cjs/reputation.js +10 -55
  10. package/dist/cjs/signIn.js +304 -0
  11. package/dist/esm/.tsbuildinfo +1 -1
  12. package/dist/esm/accountEmail.js +76 -0
  13. package/dist/esm/deviceBoot.js +2 -2
  14. package/dist/esm/deviceSession.js +72 -15
  15. package/dist/esm/identity.js +1 -3
  16. package/dist/esm/identityLink.js +87 -0
  17. package/dist/esm/identityProof.js +6 -29
  18. package/dist/esm/index.js +13 -16
  19. package/dist/esm/reputation.js +9 -54
  20. package/dist/esm/signIn.js +299 -0
  21. package/dist/types/.tsbuildinfo +1 -1
  22. package/dist/types/accountEmail.d.ts +90 -0
  23. package/dist/types/agency.d.ts +2 -2
  24. package/dist/types/deviceBoot.d.ts +2 -2
  25. package/dist/types/deviceSession.d.ts +131 -19
  26. package/dist/types/externalIdentity.d.ts +4 -4
  27. package/dist/types/identity.d.ts +4 -8
  28. package/dist/types/identityLink.d.ts +146 -0
  29. package/dist/types/identityProof.d.ts +15 -42
  30. package/dist/types/index.d.ts +10 -12
  31. package/dist/types/inference/accountBilling.d.ts +2 -2
  32. package/dist/types/inference/embeddings.d.ts +16 -16
  33. package/dist/types/inference/entitlement.d.ts +2 -2
  34. package/dist/types/inference/errors.d.ts +8 -8
  35. package/dist/types/inference/inbox.d.ts +8 -8
  36. package/dist/types/inference/providerConnection.d.ts +20 -20
  37. package/dist/types/inference/request.d.ts +16 -16
  38. package/dist/types/inference/streamEvents.d.ts +20 -20
  39. package/dist/types/keyRecovery.d.ts +4 -4
  40. package/dist/types/oauth.d.ts +16 -16
  41. package/dist/types/reputation.d.ts +32 -127
  42. package/dist/types/sessionStatus.d.ts +2 -2
  43. package/dist/types/signIn.d.ts +717 -0
  44. package/dist/types/userResponse.d.ts +2 -2
  45. package/package.json +1 -1
  46. package/dist/cjs/identityMove.js +0 -156
  47. package/dist/cjs/identityRecovery.js +0 -51
  48. package/dist/cjs/webIdentityCarrier.js +0 -181
  49. package/dist/cjs/webauthn.js +0 -85
  50. package/dist/esm/identityMove.js +0 -148
  51. package/dist/esm/identityRecovery.js +0 -48
  52. package/dist/esm/webIdentityCarrier.js +0 -178
  53. package/dist/esm/webauthn.js +0 -82
  54. package/dist/types/identityMove.d.ts +0 -185
  55. package/dist/types/identityRecovery.d.ts +0 -246
  56. package/dist/types/webIdentityCarrier.d.ts +0 -1130
  57. package/dist/types/webauthn.d.ts +0 -285
@@ -1,48 +0,0 @@
1
- /**
2
- * Signed-out recovery contract (ADR 0024 D5) — get an EXISTING account back from
3
- * its root alone, with no passkey, session or email.
4
- *
5
- * 1. `POST /identity/recovery/challenge` → a one-use challenge. It says nothing
6
- * about any account.
7
- * 2. The holder derives the root locally from recovery material (12/24 words or a
8
- * raw key) and signs `recover_account_start` over that challenge:
9
- * `POST /identity/recovery/start { publicKey, proof }`. Only a valid proof
10
- * learns which account the root belongs to; the response carries passkey
11
- * registration options for THAT account and a short-lived ticket.
12
- * 3. The holder creates the passkey, seals the root under it (PRF), and signs
13
- * `recover_account_complete` over the registration challenge and the envelope
14
- * digest: `POST /identity/recovery/complete`. The passkey, the envelope and a
15
- * session are created in one transaction.
16
- *
17
- * The recovery material and the root never leave the holder. Platform-agnostic —
18
- * zod only, ESM-safe.
19
- */
20
- import { z } from 'zod';
21
- import { identityProofSchema } from './identityProof.js';
22
- import { webIdentityEnvelopeSchema, webIdentityPublicKeySchema } from './webIdentityCarrier.js';
23
- /** A recovery attempt lives this long between steps. */
24
- export const IDENTITY_RECOVERY_TTL_MS = 5 * 60 * 1000;
25
- export const identityRecoveryChallengeResponseSchema = z.object({
26
- challenge: z.string().regex(/^[0-9a-f]{64}$/),
27
- expiresAt: z.number().int().positive(),
28
- });
29
- export const identityRecoveryStartRequestSchema = z
30
- .object({
31
- publicKey: webIdentityPublicKeySchema,
32
- /** `recover_account_start`, subject `root:<publicKey>`, actor `anonymous`. */
33
- proof: identityProofSchema,
34
- })
35
- .strict();
36
- export const identityRecoveryCompleteRequestSchema = z
37
- .object({
38
- ticket: z.string().regex(/^[0-9a-f]{64}$/),
39
- /** The browser `RegistrationResponseJSON`, verified by the API's WebAuthn library. */
40
- response: z.record(z.string(), z.unknown()),
41
- /** The root sealed under the new passkey — exactly one wrap, for that credential. */
42
- envelope: webIdentityEnvelopeSchema,
43
- /** `recover_account_complete`, subject = account id, actor `credential:<id>`, challenge = registration challenge (hex). */
44
- proof: identityProofSchema,
45
- deviceName: z.string().trim().max(100).optional(),
46
- deviceFingerprint: z.string().trim().max(512).optional(),
47
- })
48
- .strict();
@@ -1,178 +0,0 @@
1
- /**
2
- * Web identity holder contract — the sealed envelope that lets a browser hold an
3
- * account's self-custody root without Oxy ever being able to use it (ADR 0024).
4
- *
5
- * A root is a BIP-39 phrase (12–24 words) whose seed's first 32 bytes are the
6
- * secp256k1 key — exactly the Commons derivation — or, for a few imported
7
- * identities, a raw private key that never had a phrase. On the web it travels as:
8
- *
9
- * secret ── XChaCha20-Poly1305 under a random DEK ──▶ sealedSecret
10
- * DEK ── XChaCha20-Poly1305 under KEK_i ──▶ wraps[i]
11
- * KEK_i = HKDF(PRF output of passkey i)
12
- *
13
- * The server stores the envelope and can open NONE of it: the PRF output never
14
- * leaves the user's authenticator, and the secret is never uploaded. The AEAD
15
- * associated data binds the secret to the root's public key and kind, and each
16
- * wrap to its credential and RP ID, so a re-labelled or transplanted envelope
17
- * fails to open instead of decrypting into the wrong identity.
18
- *
19
- * Platform-agnostic — zod only, ESM-safe (no `require()`).
20
- */
21
- import { z } from 'zod';
22
- import { identityProofSchema } from './identityProof.js';
23
- /** The envelope scheme. A scheme change is a new literal, never a mutation. */
24
- export const WEB_IDENTITY_ENVELOPE_VERSION = 2;
25
- /**
26
- * What an envelope seals. A raw-key identity stays a raw-key identity:
27
- * nothing ever derives or displays a phrase for it.
28
- */
29
- export const WEB_IDENTITY_SECRET_KINDS = ['mnemonic-entropy', 'raw-private-key'];
30
- const hex = (bytes, label) => z
31
- .string()
32
- .trim()
33
- .regex(new RegExp(`^[0-9a-fA-F]{${bytes * 2}}$`), `${label} must be ${bytes * 2} hex characters`);
34
- /**
35
- * The identity's secp256k1 public key in Oxy's canonical form: uncompressed SEC1
36
- * (`04` + 64 bytes), lowercase hex — what `KeyManager.derivePublicKey` produces
37
- * and `users.public_key` stores.
38
- */
39
- export const webIdentityPublicKeySchema = z
40
- .string()
41
- .trim()
42
- .regex(/^04[0-9a-f]{128}$/, 'publicKey must be an uncompressed, lowercase secp256k1 key (130 hex characters)');
43
- /** A WebAuthn credential id, base64url as the browser reports it. */
44
- export const webauthnCredentialIdSchema = z
45
- .string()
46
- .trim()
47
- .min(16)
48
- .max(1024)
49
- .regex(/^[A-Za-z0-9_-]+$/, 'credentialId must be base64url');
50
- /** A WebAuthn RP ID: a bare registrable host name, lowercase. */
51
- export const webauthnRpIdSchema = z
52
- .string()
53
- .trim()
54
- .min(1)
55
- .max(253)
56
- .regex(/^(localhost|[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+)$/, 'rpId must be a lowercase host name');
57
- /** One passkey's wrap of the envelope's data key. */
58
- export const webIdentityWrapSchema = z.object({
59
- credentialId: webauthnCredentialIdSchema,
60
- /** 24-byte XChaCha20-Poly1305 nonce. */
61
- nonce: hex(24, 'nonce'),
62
- /** The 32-byte DEK sealed under this passkey's KEK, with the 16-byte tag appended (48 bytes). */
63
- wrappedKey: hex(48, 'wrappedKey'),
64
- createdAt: z.string().datetime(),
65
- /** The RP ID the passkey was created under, asserted explicitly by every later ceremony (ADR 0024 D2). */
66
- rpId: webauthnRpIdSchema,
67
- /**
68
- * When this passkey's PRF output was shown to open the envelope. A wrap is a
69
- * root HOLDER only once this is set; a login passkey never is by default.
70
- */
71
- verifiedAt: z.string().datetime().optional(),
72
- });
73
- /**
74
- * The sealed identity as it is stored (server copy and local copy alike).
75
- *
76
- * `wraps` holds one entry per passkey able to open it; at least one, and a
77
- * bounded number so an envelope cannot grow without limit.
78
- */
79
- export const webIdentityEnvelopeSchema = z
80
- .object({
81
- version: z.literal(WEB_IDENTITY_ENVELOPE_VERSION),
82
- algorithm: z.literal('xchacha20poly1305'),
83
- publicKey: webIdentityPublicKeySchema,
84
- secretKind: z.enum(WEB_IDENTITY_SECRET_KINDS),
85
- /** 24-byte nonce of the secret seal. */
86
- secretNonce: hex(24, 'secretNonce'),
87
- /**
88
- * The sealed secret, tag appended: 16/20/24/28/32 bytes of BIP-39 entropy
89
- * (12–24 words) or a 32-byte private key, plus 16.
90
- */
91
- sealedSecret: z
92
- .string()
93
- .trim()
94
- .regex(/^(?:[0-9a-fA-F]{64}|[0-9a-fA-F]{72}|[0-9a-fA-F]{80}|[0-9a-fA-F]{88}|[0-9a-fA-F]{96})$/, 'sealedSecret has an unsupported length'),
95
- wraps: z.array(webIdentityWrapSchema).min(1).max(10),
96
- })
97
- .refine((envelope) => envelope.secretKind === 'mnemonic-entropy' || envelope.sealedSecret.length === 96, {
98
- message: 'a raw private key seals to 48 bytes',
99
- path: ['sealedSecret'],
100
- });
101
- /**
102
- * `PUT /identity/web-envelope` — store or replace the caller's envelope.
103
- *
104
- * Refused unless `envelope.publicKey` is the identity key already linked to the
105
- * account: an envelope can only ever carry the account's own identity.
106
- */
107
- export const webIdentityEnvelopeUploadSchema = z.object({
108
- envelope: webIdentityEnvelopeSchema,
109
- });
110
- /** A root holder as the status read reports it — metadata only, nothing that opens anything. */
111
- export const webIdentityHolderSchema = z.object({
112
- credentialId: webauthnCredentialIdSchema,
113
- rpId: webauthnRpIdSchema,
114
- verifiedAt: z.string().datetime().nullable(),
115
- createdAt: z.string().datetime(),
116
- });
117
- /**
118
- * `GET /identity/web-envelope` — the caller's envelope and the readiness facts
119
- * ADR 0024 D5 keeps separate. A client decides what to show from these fields
120
- * WITHOUT decrypting anything.
121
- */
122
- export const webIdentityEnvelopeResponseSchema = z.object({
123
- envelope: webIdentityEnvelopeSchema.nullable(),
124
- /** The revision a write must name as `expectedRevision`; `0` when there is no envelope. */
125
- revision: z.number().int().nonnegative(),
126
- /** Whether the account has a linked root at all (it may live only in Commons). */
127
- rootLinked: z.boolean(),
128
- /** The web wraps, as metadata. */
129
- holders: z.array(webIdentityHolderSchema),
130
- /** When the owner confirmed the recovery material is written down, or `null`. */
131
- phraseConfirmedAt: z.string().datetime().nullable(),
132
- /** When the recovery material was shown to re-derive this root, or `null`. */
133
- recoveryVerifiedAt: z.string().datetime().nullable(),
134
- updatedAt: z.string().datetime().nullable(),
135
- });
136
- /** A root proof, plus the envelope revision the write expects to replace. */
137
- export const webIdentityEnvelopeProofFieldsSchema = z.object({
138
- proof: identityProofSchema,
139
- expectedRevision: z.number().int().nonnegative(),
140
- });
141
- /**
142
- * `POST /identity/web-envelope/phrase-confirmed`, `/recovery-verified` and
143
- * `DELETE /identity/web-envelope` prove control of the root, not just a bearer.
144
- */
145
- export const webIdentityEnvelopeActionSchema = webIdentityEnvelopeProofFieldsSchema.strict();
146
- /** `PUT /identity/web-envelope` body. */
147
- export const webIdentityEnvelopePutSchema = webIdentityEnvelopeUploadSchema.extend(webIdentityEnvelopeProofFieldsSchema.shape).strict();
148
- /**
149
- * A WebAuthn assertion by one of the account's EXISTING passkeys whose
150
- * `clientDataJSON.challenge` is the proof challenge — the fresh use of the
151
- * existing factor a keyless account needs before its first root is linked.
152
- */
153
- export const webauthnAssertionResponseSchema = z
154
- .object({
155
- id: webauthnCredentialIdSchema,
156
- rawId: z.string().min(1).max(2048),
157
- type: z.literal('public-key'),
158
- response: z
159
- .object({
160
- clientDataJSON: z.string().min(1).max(8192),
161
- authenticatorData: z.string().min(1).max(8192),
162
- signature: z.string().min(1).max(2048),
163
- userHandle: z.string().max(2048).optional(),
164
- })
165
- .passthrough(),
166
- clientExtensionResults: z.record(z.string(), z.unknown()).optional(),
167
- authenticatorAttachment: z.string().optional(),
168
- })
169
- .passthrough();
170
- /**
171
- * `POST /identity/web-envelope/establish` body — an account's FIRST root, linked
172
- * and stored with its envelope in ONE transaction: one root proof
173
- * (`web_envelope_establish`, digest of the envelope) plus a fresh `assertion` by
174
- * an existing passkey over the same challenge.
175
- */
176
- export const webIdentityEnvelopeEstablishSchema = webIdentityEnvelopeUploadSchema
177
- .extend({ proof: identityProofSchema, assertion: webauthnAssertionResponseSchema })
178
- .strict();
@@ -1,82 +0,0 @@
1
- /**
2
- * WebAuthn / passkey ceremony contracts (Fase B/b1).
3
- *
4
- * These schemas describe ONLY the outer Oxy envelope that wraps a WebAuthn
5
- * ceremony request — the username the client is registering/authenticating as,
6
- * plus non-authoritative device metadata. The browser
7
- * `RegistrationResponseJSON` / `AuthenticationResponseJSON` payloads are NOT
8
- * mirrored here: they are validated by `@simplewebauthn/server` inside the route
9
- * (`verifyRegistrationResponse` / `verifyAuthenticationResponse`), which is the
10
- * single source of truth for their structure. Re-encoding them in Zod would just
11
- * create a second, drift-prone definition of a shape we do not own.
12
- */
13
- import { z } from 'zod';
14
- import { identityProofSchema } from './identityProof.js';
15
- import { webIdentityEnvelopeSchema } from './webIdentityCarrier.js';
16
- /**
17
- * Device-session options shared by every first-party sign-in body
18
- * (`deviceName`/`deviceFingerprint`). Mirrors what
19
- * `sessionCreateOptionsFromBody` reads in the API so a WebAuthn login/verify can
20
- * name its resulting session exactly like `/auth/login` or `/auth/verify`.
21
- *
22
- * There is deliberately no `deviceId` here. `createSession` treats an explicit
23
- * device id as authoritative — `deviceId > stableDeviceKey > UA/IP > random` —
24
- * and stamps it verbatim, so on an UNAUTHENTICATED sign-in body it is a caller
25
- * naming somebody else's device and having a session, and then a device secret,
26
- * minted against it. The legitimate callers that pin a device id are
27
- * server-side and already authorized (the account-switch route threading the
28
- * operator's own central device id); they pass it to `createSession` directly
29
- * and never through a request body.
30
- */
31
- const deviceSessionEnvelope = {
32
- deviceName: z.string().trim().min(1).max(120).optional(),
33
- deviceFingerprint: z.string().trim().min(1).max(256).optional(),
34
- };
35
- /**
36
- * `POST /webauthn/register/options` — request registration options. With a bearer
37
- * token the caller links a passkey to their signed-in account and `username` is
38
- * ignored; without one it is a prospective signup and `username` is the desired
39
- * (not-yet-created) handle.
40
- */
41
- export const webauthnRegisterOptionsRequestSchema = z.object({
42
- username: z.string().trim().min(1).max(60).optional(),
43
- });
44
- /**
45
- * `POST /webauthn/login/options` — request authentication options. When
46
- * `username` is present the server scopes `allowCredentials` to that user's
47
- * passkeys (username-first); when omitted it returns an empty allow-list for the
48
- * usernameless / discoverable-credential flow (the default).
49
- */
50
- export const webauthnLoginOptionsRequestSchema = z.object({
51
- username: z.string().trim().min(1).max(60).optional(),
52
- });
53
- /**
54
- * `POST /webauthn/register/verify` — the outer envelope. The browser
55
- * `RegistrationResponseJSON` travels alongside these fields under `response` and
56
- * is validated by `@simplewebauthn/server`, not here. `username` is required only
57
- * for the prospective-signup branch (no bearer); the linking branch ignores it.
58
- */
59
- export const webauthnRegisterVerifyRequestSchema = z.object({
60
- username: z.string().trim().min(1).max(60).optional(),
61
- /**
62
- * Sign-up only (ADR 0024 D4): the account's root, created on the holder BEFORE
63
- * this request — sealed under the passkey being registered — and a root proof
64
- * (`enroll_identity`) whose challenge is the registration challenge. The
65
- * account, passkey, root and envelope are then created in one transaction.
66
- */
67
- identity: z
68
- .object({
69
- envelope: webIdentityEnvelopeSchema,
70
- proof: identityProofSchema,
71
- })
72
- .optional(),
73
- ...deviceSessionEnvelope,
74
- });
75
- /**
76
- * `POST /webauthn/login/verify` — the outer envelope. The browser
77
- * `AuthenticationResponseJSON` travels alongside these fields under `response`
78
- * and is validated by `@simplewebauthn/server`, not here.
79
- */
80
- export const webauthnLoginVerifyRequestSchema = z.object({
81
- ...deviceSessionEnvelope,
82
- });
@@ -1,185 +0,0 @@
1
- /**
2
- * Identity move contract — give a web root to Commons (add it, or keep it only in
3
- * Commons; ADR 0024 D6).
4
- *
5
- * The web (holding the root) shows a QR carrying only a move id; Commons scans.
6
- * The relay in between must not be able to take the root, so:
7
- *
8
- * 1. `POST /identity/move { initiatorCommitment }` — the web publishes only
9
- * `H(initiatorKey, nonce)`, never the key.
10
- * 2. `POST /identity/move/:moveId/join { responderEphemeralPublicKey }` —
11
- * Commons, having read the commitment first, joins with its own key.
12
- * 3. `POST /identity/move/:moveId/reveal` — only then does the web reveal its
13
- * key and nonce; Commons checks them against the commitment it read.
14
- * 4. Both screens show a 6-digit code over `(moveId, both keys, commitment)`;
15
- * the person confirms on the web that they match.
16
- * 5. `POST /identity/move/:moveId/seal` — the web seals the phrase entropy under
17
- * `HKDF(ECDH(both keys), moveId)`, authorized by a one-use root proof over the
18
- * exact sealed bytes.
19
- * 6. `POST /identity/move/:moveId/receipt` — Commons stores the root, reads it
20
- * back from its keychain, and signs a receipt over the move, the root, both
21
- * keys and the digest of the ciphertext it opened. The server verifies it; the
22
- * web verifies it again from what IT sealed before removing anything.
23
- *
24
- * Why the commitment: without it the relay sees both keys before committing to
25
- * anything and can grind a substituted key until the two codes agree (~10⁶
26
- * tries, seconds). With it, the relay must fix the key it shows Commons before
27
- * learning Commons' key, and the key it shows the web before the web reveals.
28
- *
29
- * The server holds a commitment, two ephemeral public keys, an opaque ciphertext
30
- * and a receipt — nothing that decrypts the ciphertext.
31
- *
32
- * Platform-agnostic — zod only, ESM-safe (no `require()`).
33
- */
34
- import { z } from 'zod';
35
- /** A move lives this long: one interactive handoff. */
36
- export declare const IDENTITY_MOVE_TTL_MS: number;
37
- /** 128-bit move id, lowercase hex. */
38
- export declare const identityMoveIdSchema: z.ZodString;
39
- /** An ephemeral secp256k1 public key, uncompressed lowercase hex. */
40
- export declare const identityMoveEphemeralKeySchema: z.ZodString;
41
- export declare const IDENTITY_MOVE_STATUSES: readonly ["pending", "joined", "sealed", "completed", "cancelled", "expired"];
42
- export type IdentityMoveStatus = (typeof IDENTITY_MOVE_STATUSES)[number];
43
- /** The QR payload Commons scans. Carries the move id only. */
44
- export declare const IDENTITY_MOVE_QR_PREFIX = "oxycommons://move?id=";
45
- export declare const identityMoveCreateRequestSchema: z.ZodObject<{
46
- /** `H(initiator ephemeral key, nonce)` — the key itself is revealed only after Commons joins. */
47
- initiatorCommitment: z.ZodString;
48
- }, "strict", z.ZodTypeAny, {
49
- initiatorCommitment: string;
50
- }, {
51
- initiatorCommitment: string;
52
- }>;
53
- export interface IdentityMoveCreateResponse {
54
- moveId: string;
55
- expiresAt: string;
56
- }
57
- export declare const identityMoveCreateResponseSchema: z.ZodType<IdentityMoveCreateResponse>;
58
- export declare const identityMoveJoinRequestSchema: z.ZodObject<{
59
- responderEphemeralPublicKey: z.ZodString;
60
- }, "strip", z.ZodTypeAny, {
61
- responderEphemeralPublicKey: string;
62
- }, {
63
- responderEphemeralPublicKey: string;
64
- }>;
65
- /** After Commons joined: the committed key and its nonce. */
66
- export declare const identityMoveRevealRequestSchema: z.ZodObject<{
67
- initiatorEphemeralPublicKey: z.ZodString;
68
- commitmentNonce: z.ZodString;
69
- }, "strict", z.ZodTypeAny, {
70
- initiatorEphemeralPublicKey: string;
71
- commitmentNonce: string;
72
- }, {
73
- initiatorEphemeralPublicKey: string;
74
- commitmentNonce: string;
75
- }>;
76
- export declare const identityMoveSealRequestSchema: z.ZodObject<{
77
- /** 24-byte XChaCha20-Poly1305 nonce, hex. */
78
- nonce: z.ZodString;
79
- /** The 16–32-byte phrase entropy (12–24 words), tag appended, hex. */
80
- ciphertext: z.ZodString;
81
- /**
82
- * Root proof (`identity_move_seal`), payload `{ moveId, nonce, ciphertext }`,
83
- * over a one-use challenge from `POST /identity/proof-challenge`.
84
- */
85
- proof: z.ZodObject<{
86
- v: z.ZodLiteral<2>;
87
- challenge: z.ZodString;
88
- expiresAt: z.ZodNumber;
89
- signature: z.ZodString;
90
- }, "strip", z.ZodTypeAny, {
91
- expiresAt: number;
92
- signature: string;
93
- v: 2;
94
- challenge: string;
95
- }, {
96
- expiresAt: number;
97
- signature: string;
98
- v: 2;
99
- challenge: string;
100
- }>;
101
- }, "strict", z.ZodTypeAny, {
102
- proof: {
103
- expiresAt: number;
104
- signature: string;
105
- v: 2;
106
- challenge: string;
107
- };
108
- nonce: string;
109
- ciphertext: string;
110
- }, {
111
- proof: {
112
- expiresAt: number;
113
- signature: string;
114
- v: 2;
115
- challenge: string;
116
- };
117
- nonce: string;
118
- ciphertext: string;
119
- }>;
120
- export declare const identityMoveReceiptRequestSchema: z.ZodObject<{
121
- /** Root signature over `buildMoveReceiptMessage(...)`. */
122
- signature: z.ZodString;
123
- }, "strict", z.ZodTypeAny, {
124
- signature: string;
125
- }, {
126
- signature: string;
127
- }>;
128
- /** `GET /identity/move/:moveId` — everything either side needs, nothing that decrypts. */
129
- export interface IdentityMoveState {
130
- moveId: string;
131
- status: IdentityMoveStatus;
132
- /** The commitment Commons must read before joining. */
133
- initiatorCommitment: string;
134
- /** The commitment's nonce, published with the key at reveal. */
135
- initiatorCommitmentNonce: string | null;
136
- /** The identity being moved (so Commons can check the key it will import). */
137
- publicKey: string;
138
- /** `null` until the web reveals it, after Commons joined. */
139
- initiatorEphemeralPublicKey: string | null;
140
- responderEphemeralPublicKey: string | null;
141
- nonce: string | null;
142
- ciphertext: string | null;
143
- receiptSignature: string | null;
144
- expiresAt: string;
145
- }
146
- export declare const identityMoveStateSchema: z.ZodType<IdentityMoveState>;
147
- export type IdentityMoveCreateRequest = z.infer<typeof identityMoveCreateRequestSchema>;
148
- export type IdentityMoveJoinRequest = z.infer<typeof identityMoveJoinRequestSchema>;
149
- export type IdentityMoveRevealRequest = z.infer<typeof identityMoveRevealRequestSchema>;
150
- export type IdentityMoveSealRequest = z.infer<typeof identityMoveSealRequestSchema>;
151
- export type IdentityMoveReceiptRequest = z.infer<typeof identityMoveReceiptRequestSchema>;
152
- /**
153
- * The initiator's commitment input, `canonicalJson({ v, purpose, key, nonce })`,
154
- * which the caller hashes with SHA-256.
155
- */
156
- export declare function buildMoveCommitmentInput(initiatorEphemeralPublicKey: string, nonce: string): string;
157
- /** The bytes both sides hash for the 6-digit code. */
158
- export declare function buildMoveSasInput(input: {
159
- moveId: string;
160
- initiatorEphemeralPublicKey: string;
161
- responderEphemeralPublicKey: string;
162
- initiatorCommitment: string;
163
- }): string;
164
- /** The ciphertext digest input the receipt binds: `canonicalJson({ nonce, ciphertext })`. */
165
- export declare function buildMoveCiphertextDigestInput(sealed: {
166
- nonce: string;
167
- ciphertext: string;
168
- }): string;
169
- /** The payload a seal proof digests. */
170
- export declare function buildMoveSealPayload(moveId: string, sealed: {
171
- nonce: string;
172
- ciphertext: string;
173
- }): {
174
- moveId: string;
175
- nonce: string;
176
- ciphertext: string;
177
- };
178
- /** The exact bytes a receipt signs. */
179
- export declare function buildMoveReceiptMessage(input: {
180
- moveId: string;
181
- rootPublicKey: string;
182
- initiatorEphemeralPublicKey: string;
183
- responderEphemeralPublicKey: string;
184
- ciphertextDigest: string;
185
- }): string;