@fairmint/canton-node-sdk 0.0.295 → 0.0.296
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 +43 -0
- package/build/src/utils/external-signing/index.d.ts +1 -0
- package/build/src/utils/external-signing/index.d.ts.map +1 -1
- package/build/src/utils/external-signing/index.js +1 -0
- package/build/src/utils/external-signing/index.js.map +1 -1
- package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts +51 -10
- package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts.map +1 -1
- package/build/src/utils/external-signing/wallet-ownership-challenger.js +85 -18
- package/build/src/utils/external-signing/wallet-ownership-challenger.js.map +1 -1
- package/build/src/utils/external-signing/wallet-ownership-checks.d.ts +27 -0
- package/build/src/utils/external-signing/wallet-ownership-checks.d.ts.map +1 -0
- package/build/src/utils/external-signing/wallet-ownership-checks.js +117 -0
- package/build/src/utils/external-signing/wallet-ownership-checks.js.map +1 -0
- package/build/src/utils/external-signing/wallet-ownership.d.ts.map +1 -1
- package/build/src/utils/external-signing/wallet-ownership.js +21 -95
- package/build/src/utils/external-signing/wallet-ownership.js.map +1 -1
- package/build/src/utils/external-signing/wallet-proof.d.ts +44 -0
- package/build/src/utils/external-signing/wallet-proof.d.ts.map +1 -0
- package/build/src/utils/external-signing/wallet-proof.js +74 -0
- package/build/src/utils/external-signing/wallet-proof.js.map +1 -0
- package/build/src/wallets/index.d.ts +5 -2
- package/build/src/wallets/index.d.ts.map +1 -1
- package/build/src/wallets/index.js +12 -3
- package/build/src/wallets/index.js.map +1 -1
- package/build/src/wallets/ownership-fields.d.ts +4 -0
- package/build/src/wallets/ownership-fields.d.ts.map +1 -0
- package/build/src/wallets/ownership-fields.js +11 -0
- package/build/src/wallets/ownership-fields.js.map +1 -0
- package/build/src/wallets/ownership.d.ts +44 -7
- package/build/src/wallets/ownership.d.ts.map +1 -1
- package/build/src/wallets/ownership.js +137 -47
- package/build/src/wallets/ownership.js.map +1 -1
- package/build/src/wallets/proof-encoding.d.ts +17 -0
- package/build/src/wallets/proof-encoding.d.ts.map +1 -0
- package/build/src/wallets/proof-encoding.js +63 -0
- package/build/src/wallets/proof-encoding.js.map +1 -0
- package/build/src/wallets/store.d.ts +12 -4
- package/build/src/wallets/store.d.ts.map +1 -1
- package/build/src/wallets/store.js +8 -1
- package/build/src/wallets/store.js.map +1 -1
- package/build/src/wallets/wallet-proof.d.ts +50 -0
- package/build/src/wallets/wallet-proof.d.ts.map +1 -0
- package/build/src/wallets/wallet-proof.js +141 -0
- package/build/src/wallets/wallet-proof.js.map +1 -0
- package/package.json +1 -1
|
@@ -28,45 +28,10 @@ exports.verifyWalletOwnership = verifyWalletOwnership;
|
|
|
28
28
|
* hosted on that network; a caller that needs that must look the party up on the network (Scan, or the ledger's party
|
|
29
29
|
* and topology APIs).
|
|
30
30
|
*/
|
|
31
|
-
const canton_protocol_1 = require("./canton-protocol");
|
|
32
|
-
const canton_ed25519_signer_1 = require("./canton-ed25519-signer");
|
|
33
31
|
const ownership_1 = require("../../wallets/ownership");
|
|
32
|
+
const wallet_ownership_checks_1 = require("./wallet-ownership-checks");
|
|
34
33
|
exports.DEFAULT_WALLET_OWNERSHIP_MAX_AGE_MS = 10 * 60 * 1000;
|
|
35
34
|
exports.DEFAULT_WALLET_OWNERSHIP_CLOCK_SKEW_MS = 60 * 1000;
|
|
36
|
-
/**
|
|
37
|
-
* The key as base64 for the Canton helpers: 64 hex characters (the raw key, as Loop reports it), else base64 of the raw
|
|
38
|
-
* or DER SubjectPublicKeyInfo key (as Privy's provider reports it), which the helpers accept as is.
|
|
39
|
-
*/
|
|
40
|
-
function publicKeyBase64(value) {
|
|
41
|
-
return /^[0-9a-fA-F]{64}$/.test(value) ? Buffer.from(value, 'hex').toString('base64') : value;
|
|
42
|
-
}
|
|
43
|
-
/** The signature as base64: 128 hex characters (Loop), else base64 (Privy); 64 bytes either way. */
|
|
44
|
-
function signatureBase64(value) {
|
|
45
|
-
return /^[0-9a-fA-F]{128}$/.test(value)
|
|
46
|
-
? (0, canton_ed25519_signer_1.normalizeCantonEd25519Signature)({ signatureHex: value })
|
|
47
|
-
: (0, canton_ed25519_signer_1.normalizeCantonEd25519Signature)({ signatureBase64: value });
|
|
48
|
-
}
|
|
49
|
-
function readProof(proof) {
|
|
50
|
-
if (typeof proof !== 'object' || proof === null)
|
|
51
|
-
return null;
|
|
52
|
-
const record = proof;
|
|
53
|
-
const { partyId, publicKey, namespace, message, signature } = record;
|
|
54
|
-
if (typeof partyId !== 'string' ||
|
|
55
|
-
typeof publicKey !== 'string' ||
|
|
56
|
-
typeof message !== 'string' ||
|
|
57
|
-
typeof signature !== 'string' ||
|
|
58
|
-
(namespace !== undefined && typeof namespace !== 'string') ||
|
|
59
|
-
publicKey.length > 1024 ||
|
|
60
|
-
signature.length > 1024) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
return { partyId, publicKey, message, signature, ...(namespace !== undefined && { namespace }) };
|
|
64
|
-
}
|
|
65
|
-
const fail = (reason, message) => ({
|
|
66
|
-
verified: false,
|
|
67
|
-
reason,
|
|
68
|
-
message,
|
|
69
|
-
});
|
|
70
35
|
/**
|
|
71
36
|
* Verify a wallet ownership proof (see the module comment for what this does and does not establish). Never throws for
|
|
72
37
|
* a bad proof: the result says why it failed. Throws `TypeError` for invalid options.
|
|
@@ -81,84 +46,45 @@ function verifyWalletOwnership(proof, options) {
|
|
|
81
46
|
if (typeof options.expectedDomain !== 'string' || options.expectedDomain.length === 0) {
|
|
82
47
|
throw new TypeError('expectedDomain is required');
|
|
83
48
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
const read = readProof(proof);
|
|
49
|
+
(0, wallet_ownership_checks_1.assertWindowOptions)(now, maxAgeMs, skewMs, 'now, maxAgeMs and clockSkewMs');
|
|
50
|
+
const read = (0, wallet_ownership_checks_1.readWalletOwnershipProof)(proof);
|
|
88
51
|
if (read === null)
|
|
89
|
-
return
|
|
52
|
+
return (0, wallet_ownership_checks_1.checkFailure)('malformed-proof', 'The proof is not { partyId, publicKey, message, signature }');
|
|
90
53
|
const fields = (0, ownership_1.parseWalletOwnershipMessage)(read.message);
|
|
91
54
|
if (fields === null)
|
|
92
|
-
return
|
|
55
|
+
return (0, wallet_ownership_checks_1.checkFailure)('malformed-message', 'The signed text is not a canonical wallet ownership message');
|
|
93
56
|
if (fields.partyId !== read.partyId) {
|
|
94
|
-
return
|
|
57
|
+
return (0, wallet_ownership_checks_1.checkFailure)('party-mismatch', 'The signed message names another party than the proof');
|
|
95
58
|
}
|
|
96
59
|
if (options.expectedPartyId !== undefined && read.partyId !== options.expectedPartyId) {
|
|
97
|
-
return
|
|
60
|
+
return (0, wallet_ownership_checks_1.checkFailure)('party-mismatch', 'The proof is for another party than expected');
|
|
98
61
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return fail('party-mismatch', "The wallet's namespace is not the party id's namespace");
|
|
62
|
+
if (read.namespace !== undefined && read.namespace !== (0, wallet_ownership_checks_1.partyNamespace)(read.partyId)) {
|
|
63
|
+
return (0, wallet_ownership_checks_1.checkFailure)('party-mismatch', "The wallet's namespace is not the party id's namespace");
|
|
102
64
|
}
|
|
103
65
|
if (fields.domain !== options.expectedDomain) {
|
|
104
|
-
return
|
|
66
|
+
return (0, wallet_ownership_checks_1.checkFailure)('domain-mismatch', `The message was signed for ${fields.domain}, not ${options.expectedDomain}`);
|
|
105
67
|
}
|
|
106
68
|
if (fields.nonce !== options.expectedNonce) {
|
|
107
|
-
return
|
|
69
|
+
return (0, wallet_ownership_checks_1.checkFailure)('nonce-mismatch', 'The message was signed for another challenge');
|
|
108
70
|
}
|
|
109
71
|
if (options.expectedNetwork !== undefined && fields.network !== options.expectedNetwork) {
|
|
110
|
-
return
|
|
72
|
+
return (0, wallet_ownership_checks_1.checkFailure)('network-mismatch', `The message names network ${fields.network ?? '(none)'}, not ${options.expectedNetwork}`);
|
|
111
73
|
}
|
|
112
74
|
if ((options.expectedIssuedAt !== undefined && fields.issuedAt !== options.expectedIssuedAt) ||
|
|
113
75
|
(options.expectedExpiresAt !== undefined && fields.expiresAt !== options.expectedExpiresAt)) {
|
|
114
|
-
return
|
|
115
|
-
}
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
// With the lifetime bounded above, this also bounds the message's age by maxAgeMs.
|
|
124
|
-
if (now >= expiresAt)
|
|
125
|
-
return fail('expired', 'The message has expired');
|
|
126
|
-
let fingerprint;
|
|
127
|
-
let keyBase64;
|
|
128
|
-
try {
|
|
129
|
-
keyBase64 = publicKeyBase64(read.publicKey);
|
|
130
|
-
fingerprint = (0, canton_protocol_1.deriveCantonEd25519PublicKeyFingerprint)(keyBase64);
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
return fail('unsupported-public-key', 'The public key is not an Ed25519 key in hex (raw 32 bytes) or base64 (raw 32 bytes or DER SubjectPublicKeyInfo)');
|
|
134
|
-
}
|
|
135
|
-
let partyFingerprint;
|
|
136
|
-
try {
|
|
137
|
-
partyFingerprint = (0, canton_protocol_1.extractPublicKeyFingerprint)(read.partyId);
|
|
138
|
-
}
|
|
139
|
-
catch {
|
|
140
|
-
return fail('party-mismatch', 'The party id is not of the form hint::namespace');
|
|
141
|
-
}
|
|
142
|
-
if (partyFingerprint !== fingerprint) {
|
|
143
|
-
return fail('key-not-bound-to-party', "The public key's Canton fingerprint is not the party's namespace, so the key does not prove control of the party (a participant-hosted party, or a rotated or delegated key, needs a topology lookup)");
|
|
144
|
-
}
|
|
145
|
-
let signature;
|
|
146
|
-
try {
|
|
147
|
-
signature = signatureBase64(read.signature);
|
|
148
|
-
}
|
|
149
|
-
catch {
|
|
150
|
-
return fail('malformed-signature', 'The signature is not 64 bytes of hex or base64');
|
|
151
|
-
}
|
|
152
|
-
try {
|
|
153
|
-
(0, canton_protocol_1.assertEd25519Signature)({ publicKeyBase64: keyBase64, payload: read.message, signatureBase64: signature });
|
|
154
|
-
}
|
|
155
|
-
catch {
|
|
156
|
-
return fail('bad-signature', 'The signature does not verify against the public key');
|
|
157
|
-
}
|
|
76
|
+
return (0, wallet_ownership_checks_1.checkFailure)('window-mismatch', 'The message names another validity window than the server issued');
|
|
77
|
+
}
|
|
78
|
+
const windowFailure = (0, wallet_ownership_checks_1.checkWindow)(fields.issuedAt, fields.expiresAt, now, maxAgeMs, skewMs);
|
|
79
|
+
if (windowFailure !== null)
|
|
80
|
+
return windowFailure;
|
|
81
|
+
const bound = (0, wallet_ownership_checks_1.checkKeyAndSignature)(read);
|
|
82
|
+
if ('verified' in bound)
|
|
83
|
+
return bound;
|
|
158
84
|
return {
|
|
159
85
|
verified: true,
|
|
160
86
|
partyId: read.partyId,
|
|
161
|
-
publicKeyFingerprint: fingerprint,
|
|
87
|
+
publicKeyFingerprint: bound.fingerprint,
|
|
162
88
|
domain: fields.domain,
|
|
163
89
|
nonce: fields.nonce,
|
|
164
90
|
...(fields.network !== undefined && { network: fields.network }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-ownership.js","sourceRoot":"","sources":["../../../../src/utils/external-signing/wallet-ownership.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,
|
|
1
|
+
{"version":3,"file":"wallet-ownership.js","sourceRoot":"","sources":["../../../../src/utils/external-signing/wallet-ownership.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,uDAAsE;AAEtE,uEAOmC;AA8CtB,QAAA,mCAAmC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACrD,QAAA,sCAAsC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhE;;;GAGG;AACH,+BACE,KAAc,EACd,OAAqC;IAErC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAA,mCAAmC,C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AAC,CAAC;IAC5F,IAAI,aAAa,KAAK,IAAI;QAAE,OAAO,aAAa,CAAC;IACjD,MAAM,KAAK,GAAG,IAAA,8CAAoB,EAAC,IAAI,CAAC,CAAC;IACzC,IAAI,UAAU,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IAEtC,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,oBAAoB,EAAE,KAAK,CAAC,WAAW;QACvC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QAChE,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DaNetwork } from '../../wallets/da-utilities/client';
|
|
2
|
+
import type { WalletOwnershipFailure } from '../../wallets/ownership';
|
|
3
|
+
import { type WalletProofFields } from '../../wallets/wallet-proof';
|
|
4
|
+
/** What the server expects the message to name. Optional fields are not checked when omitted. */
|
|
5
|
+
export interface WalletProofExpectation {
|
|
6
|
+
/** The purpose tag (`fairmint:tokenization-wallet-proof:v1`). */
|
|
7
|
+
readonly domain: string;
|
|
8
|
+
readonly network: DaNetwork;
|
|
9
|
+
/** The party the user claims; the proof and its message must both name it. */
|
|
10
|
+
readonly partyId: string;
|
|
11
|
+
readonly investorContext?: string;
|
|
12
|
+
readonly idempotencyKey?: string;
|
|
13
|
+
/** The `issuedAt` the server issued, when it built the message; the message must repeat it exactly. */
|
|
14
|
+
readonly issuedAt?: string;
|
|
15
|
+
/** The `expiresAt` the server issued, when it built the message; the message must repeat it exactly. */
|
|
16
|
+
readonly expiresAt?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface VerifyWalletProofArgs {
|
|
19
|
+
/** `{ partyId, publicKey, message, signature }` (and optional `namespace`), as the browser sent it. */
|
|
20
|
+
readonly proof: unknown;
|
|
21
|
+
readonly expected: WalletProofExpectation;
|
|
22
|
+
/** Defaults to the system clock. */
|
|
23
|
+
readonly now?: Date;
|
|
24
|
+
/** The longest validity window accepted (`expiresAt - issuedAt`). Defaults to 10 minutes. */
|
|
25
|
+
readonly maxLifetimeMs?: number;
|
|
26
|
+
/** How far in the future `issuedAt` may be. Defaults to 60 seconds. */
|
|
27
|
+
readonly maxSkewMs?: number;
|
|
28
|
+
}
|
|
29
|
+
export type WalletProofVerification = ({
|
|
30
|
+
readonly verified: true;
|
|
31
|
+
/** The party's namespace, which is the key's Canton fingerprint. */
|
|
32
|
+
readonly publicKeyFingerprint: string;
|
|
33
|
+
} & WalletProofFields) | {
|
|
34
|
+
readonly verified: false;
|
|
35
|
+
readonly reason: WalletOwnershipFailure;
|
|
36
|
+
/** A sentence for logs or the user; it never echoes the submitted values. */
|
|
37
|
+
readonly message: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Verify a wallet proof (see the module comment). Never throws for a bad proof: the result says why it failed. Throws
|
|
41
|
+
* `TypeError` for invalid arguments (an expectation without domain, network or party, or a bad clock or bound).
|
|
42
|
+
*/
|
|
43
|
+
export declare function verifyWalletProof(args: VerifyWalletProofArgs): WalletProofVerification;
|
|
44
|
+
//# sourceMappingURL=wallet-proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-proof.d.ts","sourceRoot":"","sources":["../../../../src/utils/external-signing/wallet-proof.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAW7F,iGAAiG;AACjG,MAAM,WAAW,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"__esModule", { value: true });
|
|
3
|
+
exports.verifyWalletProof = verifyWalletProof;
|
|
4
|
+
/**
|
|
5
|
+
* Server-side verification of a wallet proof message (`wallet-proof-v1`, `buildWalletProofMessage` in the browser-safe
|
|
6
|
+
* wallets module): the compact JSON form apiv2's CNTN tokenization flow uses. Node only, like `verifyWalletOwnership`,
|
|
7
|
+
* whose key and signature checks it shares.
|
|
8
|
+
*
|
|
9
|
+
* A `verified` result means the party's own key signed exactly the canonical message naming the expected domain,
|
|
10
|
+
* network, party (and, when given, account and request) within its validity window: the message parses strictly
|
|
11
|
+
* (`parseWalletProofMessage`), each field equals the server's value, `issuedAt <= now + maxSkewMs`, `expiresAt > now`,
|
|
12
|
+
* `expiresAt - issuedAt <= maxLifetimeMs`, the key's Canton fingerprint is the party's namespace, and the Ed25519
|
|
13
|
+
* signature over the message's UTF-8 bytes verifies. The same limits as `verifyWalletOwnership` apply: the network is a
|
|
14
|
+
* label, a party not namespaced by its key fails `key-not-bound-to-party`, and the caller must accept each
|
|
15
|
+
* `idempotencyKey` once (this function cannot tell a replay from a fresh proof).
|
|
16
|
+
*/
|
|
17
|
+
const cip103_1 = require("../../wallets/cip103");
|
|
18
|
+
const wallet_proof_1 = require("../../wallets/wallet-proof");
|
|
19
|
+
const wallet_ownership_1 = require("./wallet-ownership");
|
|
20
|
+
const wallet_ownership_checks_1 = require("./wallet-ownership-checks");
|
|
21
|
+
/**
|
|
22
|
+
* Verify a wallet proof (see the module comment). Never throws for a bad proof: the result says why it failed. Throws
|
|
23
|
+
* `TypeError` for invalid arguments (an expectation without domain, network or party, or a bad clock or bound).
|
|
24
|
+
*/
|
|
25
|
+
function verifyWalletProof(args) {
|
|
26
|
+
const { expected } = args;
|
|
27
|
+
const maxLifetimeMs = args.maxLifetimeMs ?? wallet_ownership_1.DEFAULT_WALLET_OWNERSHIP_MAX_AGE_MS;
|
|
28
|
+
const maxSkewMs = args.maxSkewMs ?? wallet_ownership_1.DEFAULT_WALLET_OWNERSHIP_CLOCK_SKEW_MS;
|
|
29
|
+
const now = (args.now ?? new Date()).getTime();
|
|
30
|
+
for (const key of ['domain', 'network', 'partyId']) {
|
|
31
|
+
if (typeof expected[key] !== 'string' || expected[key].length === 0) {
|
|
32
|
+
throw new TypeError(`expected.${key} is required`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!(0, cip103_1.isDaNetwork)(expected.network))
|
|
36
|
+
throw new TypeError('expected.network must be devnet or mainnet');
|
|
37
|
+
(0, wallet_ownership_checks_1.assertWindowOptions)(now, maxLifetimeMs, maxSkewMs, 'now, maxLifetimeMs and maxSkewMs');
|
|
38
|
+
const read = (0, wallet_ownership_checks_1.readWalletOwnershipProof)(args.proof);
|
|
39
|
+
if (read === null)
|
|
40
|
+
return (0, wallet_ownership_checks_1.checkFailure)('malformed-proof', 'The proof is not { partyId, publicKey, message, signature }');
|
|
41
|
+
const fields = (0, wallet_proof_1.parseWalletProofMessage)(read.message);
|
|
42
|
+
if (fields === null)
|
|
43
|
+
return (0, wallet_ownership_checks_1.checkFailure)('malformed-message', 'The signed text is not a canonical wallet proof message');
|
|
44
|
+
if (fields.partyId !== read.partyId) {
|
|
45
|
+
return (0, wallet_ownership_checks_1.checkFailure)('party-mismatch', 'The signed message names another party than the proof');
|
|
46
|
+
}
|
|
47
|
+
if (read.partyId !== expected.partyId)
|
|
48
|
+
return (0, wallet_ownership_checks_1.checkFailure)('party-mismatch', 'The proof is for another party than expected');
|
|
49
|
+
if (read.namespace !== undefined && read.namespace !== (0, wallet_ownership_checks_1.partyNamespace)(read.partyId)) {
|
|
50
|
+
return (0, wallet_ownership_checks_1.checkFailure)('party-mismatch', "The wallet's namespace is not the party id's namespace");
|
|
51
|
+
}
|
|
52
|
+
if (fields.domain !== expected.domain)
|
|
53
|
+
return (0, wallet_ownership_checks_1.checkFailure)('domain-mismatch', 'The message was signed for another purpose');
|
|
54
|
+
if (fields.network !== expected.network)
|
|
55
|
+
return (0, wallet_ownership_checks_1.checkFailure)('network-mismatch', 'The message names another network');
|
|
56
|
+
if (expected.investorContext !== undefined && fields.investorContext !== expected.investorContext) {
|
|
57
|
+
return (0, wallet_ownership_checks_1.checkFailure)('investor-context-mismatch', 'The message names another account');
|
|
58
|
+
}
|
|
59
|
+
if (expected.idempotencyKey !== undefined && fields.idempotencyKey !== expected.idempotencyKey) {
|
|
60
|
+
return (0, wallet_ownership_checks_1.checkFailure)('idempotency-key-mismatch', 'The message was signed for another request');
|
|
61
|
+
}
|
|
62
|
+
if ((expected.issuedAt !== undefined && fields.issuedAt !== expected.issuedAt) ||
|
|
63
|
+
(expected.expiresAt !== undefined && fields.expiresAt !== expected.expiresAt)) {
|
|
64
|
+
return (0, wallet_ownership_checks_1.checkFailure)('window-mismatch', 'The message names another validity window than the server issued');
|
|
65
|
+
}
|
|
66
|
+
const windowFailure = (0, wallet_ownership_checks_1.checkWindow)(fields.issuedAt, fields.expiresAt, now, maxLifetimeMs, maxSkewMs);
|
|
67
|
+
if (windowFailure !== null)
|
|
68
|
+
return windowFailure;
|
|
69
|
+
const bound = (0, wallet_ownership_checks_1.checkKeyAndSignature)(read);
|
|
70
|
+
if ('verified' in bound)
|
|
71
|
+
return bound;
|
|
72
|
+
return { verified: true, ...fields, publicKeyFingerprint: bound.fingerprint };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=wallet-proof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-proof.js","sourceRoot":"","sources":["../../../../src/utils/external-signing/wallet-proof.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,iDAAmD;AAGnD,6DAA6F;AAC7F,yDAAiH;AACjH,uEAOmC;AA0CnC;;;GAGG;AACH,2BAAkC,IAA2B;IAC3D,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC1B,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,sDAAmC,CAAC;IAChF,MAAM,SAAS,GAAG,IAAI,CA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,CAAC,CAAC;IACpG,IAAI,aAAa,KAAK,IAAI;QAAE,OAAO,aAAa,CAAC;IACjD,MAAM,KAAK,GAAG,IAAA,8CAAoB,EAAC,IAAI,CAAC,CAAC;IACzC,IAAI,UAAU,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IAEtC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,oBAAoB,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
* (`InstrumentBalance.lockedInExpiredLocks`), and the `reclaimLockedTokens` action that unlocks both
|
|
24
24
|
* (`WalletToken.canReclaim` says when it applies).
|
|
25
25
|
* - The ownership proof's browser half (`requestWalletOwnershipVerdict`); the server half
|
|
26
|
-
* (`createWalletOwnershipChallenger`, `verifyWalletOwnership`) is Node-only and exported from the package root.
|
|
26
|
+
* (`createWalletOwnershipChallenger`, `verifyWalletOwnership`) is Node-only and exported from the package root. The
|
|
27
|
+
* compact wallet proof message (`buildWalletProofMessage`, `parseWalletProofMessage`, `proveWalletProof`; verified by
|
|
28
|
+
* `verifyWalletProof` at the package root) is apiv2's CNTN tokenization wallet proof format.
|
|
27
29
|
* - The errors, their guards (`isWalletError`, `isWalletSubmitError`, …: they match errors of any copy of this module,
|
|
28
30
|
* where `instanceof` does not), their user-facing descriptions (`describeWalletError`), and the data types.
|
|
29
31
|
* - Display helpers that return codes, not sentences: `selectWalletToken`, `formatTokenAmount`, `formatOfferExpiry`,
|
|
@@ -43,7 +45,8 @@ export { actionState, canAct, createWalletStore, walletActionKey, type ActionOut
|
|
|
43
45
|
export { createWallet, type BurnRequestOptions, type BurnRequestResult, type TransferOffers, type TransferPlan, type TransferPreapprovalOptions, type TransferRequest, type TransferResult, type Wallet, type WalletCallOptions, type WalletOptions, type WalletState, type WithdrawExpiredResult, type WithdrawnOffer, type ReleasedLock, type ReclaimLockedTokensResult, } from './wallet';
|
|
44
46
|
export type { Cip103Connection, Cip103EventListener, Cip103Provider, Cip103Request } from './cip103';
|
|
45
47
|
export { discoverCip103Wallets, INJECTED_WALLET_ID, type Cip103DiscoveryHost, type DiscoverCip103WalletsOptions, type DiscoveredWallet, } from './discovery';
|
|
46
|
-
export { buildWalletOwnershipMessage, proveWalletOwnership, requestWalletOwnershipVerdict, type ProveWalletOwnershipOptions, type RequestWalletOwnershipVerdictOptions, type WalletOwnershipChallenge, type WalletOwnershipChallengeFailure, type WalletOwnershipChallengeResponse, type WalletOwnershipFailure, type WalletOwnershipMessageFields, type WalletOwnershipProof, type WalletOwnershipVerdict, } from './ownership';
|
|
48
|
+
export { buildWalletOwnershipMessage, proveWalletOwnership, proveWalletProof, requestWalletOwnershipVerdict, type ProveWalletOwnershipOptions, type ProveWalletProofOptions, type RequestWalletOwnershipVerdictOptions, type WalletOwnershipChallenge, type WalletOwnershipChallengeFailure, type WalletOwnershipChallengeResponse, type WalletOwnershipFailure, type WalletOwnershipMessageFields, type WalletOwnershipProof, type WalletOwnershipVerdict, } from './ownership';
|
|
49
|
+
export { buildWalletProofMessage, parseWalletProofMessage, WALLET_PROOF_FORMAT, WALLET_PROOF_MAX_MESSAGE_BYTES, WALLET_PROOF_MAX_MESSAGE_LENGTH, type WalletProofChallengeResponse, type WalletProofFields, type WalletProofFormat, } from './wallet-proof';
|
|
47
50
|
export { DA_REGISTRY_REQUEST_TIMEOUT_MS, type DaNetwork, type DaRegistryOptions, type FetchLike, type TransferKind, } from './da-utilities/client';
|
|
48
51
|
export { describeWalletError, isRegistryApiError, isRegistryResponseError, isWalletCancellation, isWalletError, isWalletOptionError, isWalletReadError, isWalletSignError, isWalletSubmitError, RegistryApiError, RegistryResponseError, WalletError, WalletOptionError, WalletReadError, WalletSignError, WalletSubmitError, type WalletErrorCode, type WalletErrorDescription, type WalletOptionErrorCode, type WalletSignErrorReason, type WalletSubmitCategory, type WalletSubmitErrorDetails, type WalletSubmitOutcome, } from './errors';
|
|
49
52
|
export { coveringPreapproval, type BurnRequest, type MintOffer, type PreapprovalScope, type TransferOffer, type TransferOfferRegistry, type TransferPreapproval, } from './contracts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAC/G,OAAO,EACL,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK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AAY,EACZ,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.parseDecimalUnits = exports.formatDecimalUnits = exports.readHoldingView = exports.HOLDING_V1_INTERFACE_ID = exports.CANTON_COIN_METADATA = exports.AMULET_TEMPLATES = exports.AMULET_REGISTRY_BASE_URLS = exports.AMULET_INSTRUMENT_ID = void 0;
|
|
3
|
+
exports.readSignature = exports.shortCantonId = exports.OFFER_EXPIRY_SOON_MS = exports.formatTokenAmount = exports.formatOfferExpiry = exports.describePreapprovalScope = exports.walletTokens = exports.selectWalletToken = exports.expiredUnclaimedLocks = exports.isTransferOfferExpired = exports.coveringPreapproval = exports.WalletSubmitError = exports.WalletSignError = exports.WalletReadError = exports.WalletOptionError = exports.WalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.isWalletSubmitError = exports.isWalletSignError = exports.isWalletReadError = exports.isWalletOptionError = exports.isWalletError = exports.isWalletCancellation = exports.isRegistryResponseError = exports.isRegistryApiError = exports.describeWalletError = exports.DA_REGISTRY_REQUEST_TIMEOUT_MS = exports.WALLET_PROOF_MAX_MESSAGE_LENGTH = exports.WALLET_PROOF_MAX_MESSAGE_BYTES = exports.WALLET_PROOF_FORMAT = exports.parseWalletProofMessage = exports.buildWalletProofMessage = exports.requestWalletOwnershipVerdict = exports.proveWalletProof = exports.proveWalletOwnership = exports.buildWalletOwnershipMessage = exports.INJECTED_WALLET_ID = exports.discoverCip103Wallets = exports.createWallet = exports.walletActionKey = exports.createWalletStore = exports.canAct = exports.actionState = exports.extensionWalletOptions = exports.loopWalletOption = exports.createWriteLatch = exports.DEFAULT_RESTORE_TIMEOUT_MS = exports.createWalletConnector = exports.createCip103Session = void 0;
|
|
4
|
+
exports.parseDecimalUnits = exports.formatDecimalUnits = exports.readHoldingView = exports.HOLDING_V1_INTERFACE_ID = exports.CANTON_COIN_METADATA = exports.AMULET_TEMPLATES = exports.AMULET_REGISTRY_BASE_URLS = exports.AMULET_INSTRUMENT_ID = exports.isCantonCoin = exports.withTimeout = exports.MAX_TIMER_MS = exports.validateSignMessage = exports.SIGN_MESSAGE_MIN_BYTES = exports.SIGN_MESSAGE_MAX_BYTES = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* Browser-safe DA Utility Registry holder actions through any CIP-0103 (Canton dApp API) wallet provider. In a browser
|
|
7
7
|
* bundle import `@fairmint/canton-node-sdk/wallets`, which loads none of the SDK's Node dependencies (the deep path
|
|
@@ -27,7 +27,9 @@ exports.parseDecimalUnits = exports.formatDecimalUnits = exports.readHoldingView
|
|
|
27
27
|
* (`InstrumentBalance.lockedInExpiredLocks`), and the `reclaimLockedTokens` action that unlocks both
|
|
28
28
|
* (`WalletToken.canReclaim` says when it applies).
|
|
29
29
|
* - The ownership proof's browser half (`requestWalletOwnershipVerdict`); the server half
|
|
30
|
-
* (`createWalletOwnershipChallenger`, `verifyWalletOwnership`) is Node-only and exported from the package root.
|
|
30
|
+
* (`createWalletOwnershipChallenger`, `verifyWalletOwnership`) is Node-only and exported from the package root. The
|
|
31
|
+
* compact wallet proof message (`buildWalletProofMessage`, `parseWalletProofMessage`, `proveWalletProof`; verified by
|
|
32
|
+
* `verifyWalletProof` at the package root) is apiv2's CNTN tokenization wallet proof format.
|
|
31
33
|
* - The errors, their guards (`isWalletError`, `isWalletSubmitError`, …: they match errors of any copy of this module,
|
|
32
34
|
* where `instanceof` does not), their user-facing descriptions (`describeWalletError`), and the data types.
|
|
33
35
|
* - Display helpers that return codes, not sentences: `selectWalletToken`, `formatTokenAmount`, `formatOfferExpiry`,
|
|
@@ -61,7 +63,14 @@ Object.defineProperty(exports, "INJECTED_WALLET_ID", { enumerable: true, get: fu
|
|
|
61
63
|
var ownership_1 = require("./ownership");
|
|
62
64
|
Object.defineProperty(exports, "buildWalletOwnershipMessage", { enumerable: true, get: function () { return ownership_1.buildWalletOwnershipMessage; } });
|
|
63
65
|
Object.defineProperty(exports, "proveWalletOwnership", { enumerable: true, get: function () { return ownership_1.proveWalletOwnership; } });
|
|
66
|
+
Object.defineProperty(exports, "proveWalletProof", { enumerable: true, get: function () { return ownership_1.proveWalletProof; } });
|
|
64
67
|
Object.defineProperty(exports, "requestWalletOwnershipVerdict", { enumerable: true, get: function () { return ownership_1.requestWalletOwnershipVerdict; } });
|
|
68
|
+
var wallet_proof_1 = require("./wallet-proof");
|
|
69
|
+
Object.defineProperty(exports, "buildWalletProofMessage", { enumerable: true, get: function () { return wallet_proof_1.buildWalletProofMessage; } });
|
|
70
|
+
Object.defineProperty(exports, "parseWalletProofMessage", { enumerable: true, get: function () { return wallet_proof_1.parseWalletProofMessage; } });
|
|
71
|
+
Object.defineProperty(exports, "WALLET_PROOF_FORMAT", { enumerable: true, get: function () { return wallet_proof_1.WALLET_PROOF_FORMAT; } });
|
|
72
|
+
Object.defineProperty(exports, "WALLET_PROOF_MAX_MESSAGE_BYTES", { enumerable: true, get: function () { return wallet_proof_1.WALLET_PROOF_MAX_MESSAGE_BYTES; } });
|
|
73
|
+
Object.defineProperty(exports, "WALLET_PROOF_MAX_MESSAGE_LENGTH", { enumerable: true, get: function () { return wallet_proof_1.WALLET_PROOF_MAX_MESSAGE_LENGTH; } });
|
|
65
74
|
var client_1 = require("./da-utilities/client");
|
|
66
75
|
Object.defineProperty(exports, "DA_REGISTRY_REQUEST_TIMEOUT_MS", { enumerable: true, get: function () { return client_1.DA_REGISTRY_REQUEST_TIMEOUT_MS; } });
|
|
67
76
|
var errors_1 = require("./errors");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":";;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qCAMmB;AALjB,8GAAA,mBAAmB,OAAA;AAMrB,yCAWqB;AAVnB,kHAAA,qBAAqB,OAAA;AACrB,uHAAA,0BAA0B,OAAA;AAU5B,iCAOiB;AANf,yGAAA,gBAAgB,OAAA;AAOlB,+BAA+G;AAAtG,wGAAA,gBAAgB,OAAA;AACzB,qCAOmB;AANjB,iHAAA,sBAAsB,OAAA;AAQxB,iCAiBiB;AAhBf,oGAAA,WAAW,OAAA;AACX,+FAAA,MAAM,OAAA;AACN,0GAAA,iBAAiB,OAAA;AACjB,wGAAA,eAAe,OAAA;AAcjB,mCAiBkB;AAhBhB,sGAAA,YAAY,OAAA;AAkBd,yCAMqB;AALnB,kHAAA,qBAAqB,OAAA;AACrB,+GAAA,kBAAkB,OAAA;AAKpB,yCAeqB;AAdnB,wHAAA,2BAA2B,OAAA;AAC3B,iHAAA,oBAAoB,OAAA;AACpB,6GAAA,gBAAgB,OAAA;AAChB,0HAAA,6BAA6B,OAAA;AAY/B,+CASwB;AARtB,uHAAA,uBAAuB,OAAA;AACvB,uHAAA,uBAAuB,OAAA;AACvB,mHAAA,mBAAmB,OAAA;AACnB,8HAAA,8BAA8B,OAAA;AAC9B,+HAAA,+BAA+B,OAAA;AAKjC,gD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,qCAAkE;AAAzD,6GAAA,kBAAkB,OAAA;AAAE,4GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Field rules shared by the text ownership message (`./ownership`) and the wallet proof message (`./wallet-proof`). */
|
|
2
|
+
/** Whether `value` may be a message's party: a Canton party id (`hint::namespace`) of printable ASCII. */
|
|
3
|
+
export declare function isWalletOwnershipPartyId(value: unknown): value is string;
|
|
4
|
+
//# sourceMappingURL=ownership-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownership-fields.d.ts","sourceRoot":"","sources":["../../../src/wallets/ownership-fields.ts"],"names":[],"mappings":"AAAA,wHAAwH;AAKxH,0GAA0G;AAC1G,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAIxE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Field rules shared by the text ownership message (`./ownership`) and the wallet proof message (`./wallet-proof`). */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isWalletOwnershipPartyId = isWalletOwnershipPartyId;
|
|
5
|
+
/** Printable ASCII without spaces. */
|
|
6
|
+
const TOKEN_PATTERN = /^[!-~]+$/;
|
|
7
|
+
/** Whether `value` may be a message's party: a Canton party id (`hint::namespace`) of printable ASCII. */
|
|
8
|
+
function isWalletOwnershipPartyId(value) {
|
|
9
|
+
return (typeof value === 'string' && value.length <= 512 && TOKEN_PATTERN.test(value) && value.split('::').length === 2);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ownership-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownership-fields.js","sourceRoot":"","sources":["../../../src/wallets/ownership-fields.ts"],"names":[],"mappings":";AAAA,wHAAwH;;;AAExH,sCAAsC;AACtC,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC,0GAA0G;AAC1G,kCAAyC,KAAc;IACrD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAChH,CAAC;AACJ,CAAC"}
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { type Cip103Connection } from './cip103';
|
|
18
18
|
import { type FetchLike } from './da-utilities/client';
|
|
19
|
+
import { isWalletOwnershipPartyId } from './ownership-fields';
|
|
20
|
+
import { type WalletProofFields } from './wallet-proof';
|
|
19
21
|
/** The first line of every ownership message. */
|
|
20
22
|
export declare const WALLET_OWNERSHIP_TITLE = "Canton wallet ownership proof";
|
|
21
23
|
/** The message format version, its `Version:` line. */
|
|
@@ -52,8 +54,7 @@ export interface WalletOwnershipProof {
|
|
|
52
54
|
}
|
|
53
55
|
/** Whether `value` may be a message's domain: a host name, optionally with a port. */
|
|
54
56
|
export declare function isWalletOwnershipDomain(value: unknown): value is string;
|
|
55
|
-
|
|
56
|
-
export declare function isWalletOwnershipPartyId(value: unknown): value is string;
|
|
57
|
+
export { isWalletOwnershipPartyId };
|
|
57
58
|
/**
|
|
58
59
|
* The canonical message for these fields. Throws `TypeError` on a field that is not valid. The same fields always give
|
|
59
60
|
* the same text, so the server rebuilds it from the fields it parses and refuses anything else.
|
|
@@ -84,15 +85,39 @@ export interface ProveWalletOwnershipOptions {
|
|
|
84
85
|
* verified it (`verifyWalletOwnership`).
|
|
85
86
|
*/
|
|
86
87
|
export declare function proveWalletOwnership(connection: Cip103Connection, options: ProveWalletOwnershipOptions): Promise<WalletOwnershipProof>;
|
|
88
|
+
export interface ProveWalletProofOptions {
|
|
89
|
+
/** The exact wallet proof message to sign (`buildWalletProofMessage`), as the server built it. */
|
|
90
|
+
readonly message: string;
|
|
91
|
+
/** The fields the server sent with the message, when it did: they must be exactly the message's. */
|
|
92
|
+
readonly fields?: WalletProofFields;
|
|
93
|
+
/** Defaults to the system clock; an expired message is refused before anything is signed. */
|
|
94
|
+
readonly now?: () => Date;
|
|
95
|
+
/** As in {@link ProveWalletOwnershipOptions.signal}. */
|
|
96
|
+
readonly signal?: AbortSignal;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Ask the wallet to sign a server-built wallet proof message (`wallet-proof-v1`, see `buildWalletProofMessage`) as the
|
|
100
|
+
* connection's party. Before anything is signed, the message must parse as a wallet proof (`parseWalletProofMessage`)
|
|
101
|
+
* naming the connection's party and network, match `fields` when given, and not have expired; the wallet's primary
|
|
102
|
+
* account must be the connection's party, on its network. The wallet signs exactly `message`. Returns `{ partyId,
|
|
103
|
+
* publicKey, message, signature }` (and `namespace` when the wallet reported it), which a page may show for copying; it
|
|
104
|
+
* proves nothing until the server verified it (`verifyWalletProof`). The key and signature are standard base64 whatever
|
|
105
|
+
* the wallet returned (hex or base64), so the proof verifies with servers that decode base64 only.
|
|
106
|
+
*/
|
|
107
|
+
export declare function proveWalletProof(connection: Cip103Connection, options: ProveWalletProofOptions): Promise<WalletOwnershipProof>;
|
|
87
108
|
/** Why a proof did not verify (`verifyWalletOwnership`, Node only). */
|
|
88
109
|
export type WalletOwnershipFailure =
|
|
89
110
|
/** The proof is not an object of string fields. */
|
|
90
111
|
'malformed-proof'
|
|
91
|
-
/** The message is not exactly a canonical ownership message. */
|
|
112
|
+
/** The message is not exactly a canonical ownership message (or wallet proof message, for `verifyWalletProof`). */
|
|
92
113
|
| 'malformed-message' | 'domain-mismatch' | 'nonce-mismatch'
|
|
93
114
|
/** The message, the proof and the expected party do not all name the same party, or the namespace differs. */
|
|
94
115
|
| 'party-mismatch' | 'network-mismatch'
|
|
95
|
-
/**
|
|
116
|
+
/** A wallet proof message (`verifyWalletProof`) names another `investorContext` than expected. */
|
|
117
|
+
| 'investor-context-mismatch'
|
|
118
|
+
/** A wallet proof message (`verifyWalletProof`) names another `idempotencyKey` than expected. */
|
|
119
|
+
| 'idempotency-key-mismatch'
|
|
120
|
+
/** The message's issue or expiry time is not the one the server issued. */
|
|
96
121
|
| 'window-mismatch'
|
|
97
122
|
/** Issued in the future (beyond the allowed clock skew). */
|
|
98
123
|
| 'not-yet-valid'
|
|
@@ -116,7 +141,10 @@ export type WalletOwnershipChallengeFailure =
|
|
|
116
141
|
| 'challenge-used'
|
|
117
142
|
/** Issued to another subject (signed-in user) or for another host. */
|
|
118
143
|
| 'challenge-not-yours';
|
|
119
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* A challenger's answer to a challenge request in the default text format: what the wallet signs, and the token to send
|
|
146
|
+
* back with the proof. The `wallet-proof-v1` format answers `WalletProofChallengeResponse` instead.
|
|
147
|
+
*/
|
|
120
148
|
export interface WalletOwnershipChallengeResponse {
|
|
121
149
|
readonly challenge: WalletOwnershipChallenge;
|
|
122
150
|
/** Opaque to the browser: the server's MACed record of the challenge. */
|
|
@@ -140,10 +168,18 @@ export type WalletOwnershipVerdict = {
|
|
|
140
168
|
export interface RequestWalletOwnershipVerdictOptions {
|
|
141
169
|
/** Sends the requests; defaults to the global `fetch` (same-origin requests carry the user's session cookie). */
|
|
142
170
|
readonly fetch?: FetchLike;
|
|
143
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* Answers `POST { network, partyId }` with `{ data: WalletOwnershipChallengeResponse }` (the text message) or `{
|
|
173
|
+
* data: WalletProofChallengeResponse }` (`format: 'wallet-proof-v1'`, a server-built message); the server picks.
|
|
174
|
+
*/
|
|
144
175
|
readonly challengeUrl: string;
|
|
145
176
|
/** Answers `POST { token, proof }` with `{ data: WalletOwnershipVerdict }`. */
|
|
146
177
|
readonly verifyUrl: string;
|
|
178
|
+
/**
|
|
179
|
+
* Called with the signed proof (`{ partyId, publicKey, message, signature }`) before it is sent to `verifyUrl`, for a
|
|
180
|
+
* page that shows it. Not called when the wallet did not sign.
|
|
181
|
+
*/
|
|
182
|
+
readonly onProof?: (proof: WalletOwnershipProof) => void;
|
|
147
183
|
/**
|
|
148
184
|
* Cancels the check (for example when the user leaves the page): once aborted, the call rejects with an `AbortError`,
|
|
149
185
|
* the requests in flight get the signal, and nothing more is sent. A signature request already shown to the user is
|
|
@@ -154,7 +190,8 @@ export interface RequestWalletOwnershipVerdictOptions {
|
|
|
154
190
|
/**
|
|
155
191
|
* The browser half of an ownership check, against a server that uses the SDK's challenger (or the same wire format: a
|
|
156
192
|
* 2xx answer is `{ data }`, any other `{ error: string }`): POST `challengeUrl` with the connection's `{ network,
|
|
157
|
-
* partyId }`, have the wallet sign the challenge (`proveWalletOwnership`
|
|
193
|
+
* partyId }`, have the wallet sign the challenge (`proveWalletOwnership` for the text message, `proveWalletProof` for a
|
|
194
|
+
* `wallet-proof-v1` challenge, whose server-built message it signs exactly), POST `verifyUrl` with `{ token, proof }`,
|
|
158
195
|
* and return the server's verdict. Throws when no verdict was reached: the server refused (a non-2xx answer, or one
|
|
159
196
|
* without `data`), or the wallet did not sign (`WalletSignError`).
|
|
160
197
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../../../src/wallets/ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../../../src/wallets/ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAQL,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAExB,iDAAiD;AACjD,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AACtE,uDAAuD;AACvD,eAAO,MAAM,wBAAw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