@fairmint/canton-node-sdk 0.0.277 → 0.0.279

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 (64) hide show
  1. package/README.md +197 -14
  2. package/build/src/utils/external-signing/index.d.ts +2 -0
  3. package/build/src/utils/external-signing/index.d.ts.map +1 -1
  4. package/build/src/utils/external-signing/index.js +2 -0
  5. package/build/src/utils/external-signing/index.js.map +1 -1
  6. package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts +93 -0
  7. package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts.map +1 -0
  8. package/build/src/utils/external-signing/wallet-ownership-challenger.js +253 -0
  9. package/build/src/utils/external-signing/wallet-ownership-challenger.js.map +1 -0
  10. package/build/src/utils/external-signing/wallet-ownership.d.ts +48 -0
  11. package/build/src/utils/external-signing/wallet-ownership.d.ts.map +1 -0
  12. package/build/src/utils/external-signing/wallet-ownership.js +179 -0
  13. package/build/src/utils/external-signing/wallet-ownership.js.map +1 -0
  14. package/build/src/wallets/cip103.d.ts +100 -6
  15. package/build/src/wallets/cip103.d.ts.map +1 -1
  16. package/build/src/wallets/cip103.js +237 -107
  17. package/build/src/wallets/cip103.js.map +1 -1
  18. package/build/src/wallets/da-utilities/client.d.ts.map +1 -1
  19. package/build/src/wallets/da-utilities/client.js +3 -0
  20. package/build/src/wallets/da-utilities/client.js.map +1 -1
  21. package/build/src/wallets/errors.d.ts +51 -0
  22. package/build/src/wallets/errors.d.ts.map +1 -1
  23. package/build/src/wallets/errors.js +68 -1
  24. package/build/src/wallets/errors.js.map +1 -1
  25. package/build/src/wallets/holdings.d.ts +25 -0
  26. package/build/src/wallets/holdings.d.ts.map +1 -1
  27. package/build/src/wallets/holdings.js +44 -0
  28. package/build/src/wallets/holdings.js.map +1 -1
  29. package/build/src/wallets/index.d.ts +14 -7
  30. package/build/src/wallets/index.d.ts.map +1 -1
  31. package/build/src/wallets/index.js +22 -3
  32. package/build/src/wallets/index.js.map +1 -1
  33. package/build/src/wallets/notify.d.ts +7 -0
  34. package/build/src/wallets/notify.d.ts.map +1 -0
  35. package/build/src/wallets/notify.js +21 -0
  36. package/build/src/wallets/notify.js.map +1 -0
  37. package/build/src/wallets/ownership.d.ts +156 -0
  38. package/build/src/wallets/ownership.d.ts.map +1 -0
  39. package/build/src/wallets/ownership.js +269 -0
  40. package/build/src/wallets/ownership.js.map +1 -0
  41. package/build/src/wallets/session.d.ts +107 -0
  42. package/build/src/wallets/session.d.ts.map +1 -0
  43. package/build/src/wallets/session.js +371 -0
  44. package/build/src/wallets/session.js.map +1 -0
  45. package/build/src/wallets/store.d.ts +138 -0
  46. package/build/src/wallets/store.d.ts.map +1 -0
  47. package/build/src/wallets/store.js +262 -0
  48. package/build/src/wallets/store.js.map +1 -0
  49. package/build/src/wallets/templates.d.ts +15 -0
  50. package/build/src/wallets/templates.d.ts.map +1 -1
  51. package/build/src/wallets/templates.js +33 -9
  52. package/build/src/wallets/templates.js.map +1 -1
  53. package/build/src/wallets/token-registry.d.ts +15 -2
  54. package/build/src/wallets/token-registry.d.ts.map +1 -1
  55. package/build/src/wallets/token-registry.js.map +1 -1
  56. package/build/src/wallets/token-standard-wallet.d.ts +94 -9
  57. package/build/src/wallets/token-standard-wallet.d.ts.map +1 -1
  58. package/build/src/wallets/token-standard-wallet.js +160 -19
  59. package/build/src/wallets/token-standard-wallet.js.map +1 -1
  60. package/build/src/wallets/token-wallet.d.ts +43 -7
  61. package/build/src/wallets/token-wallet.d.ts.map +1 -1
  62. package/build/src/wallets/token-wallet.js +113 -35
  63. package/build/src/wallets/token-wallet.js.map +1 -1
  64. package/package.json +1 -1
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  /** Errors the wallets module throws. Each carries enough to decide whether a retry is safe. */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TokenWalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.WalletReadError = exports.WalletSubmitError = void 0;
4
+ exports.TokenWalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.WalletSignError = exports.WalletReadError = exports.WalletSubmitError = void 0;
5
+ exports.describeWalletError = describeWalletError;
5
6
  const UNKNOWN_HINT = 'The outcome is unknown: do not resubmit blindly; check the wallet for the result first.';
6
7
  /** A submission did not commit, or its outcome is unknown. The SDK never retries. */
7
8
  class WalletSubmitError extends Error {
@@ -13,9 +14,13 @@ class WalletSubmitError extends Error {
13
14
  this.code = details.code;
14
15
  if (details.commandId !== undefined)
15
16
  this.commandId = details.commandId;
17
+ if (details.burnReference !== undefined)
18
+ this.burnReference = details.burnReference;
16
19
  }
17
20
  }
18
21
  exports.WalletSubmitError = WalletSubmitError;
22
+ /** CIP-0103 -32005 (Limit exceeded): the wallet rate-limited the request. */
23
+ const LIMIT_EXCEEDED = -32005;
19
24
  /** The wallet could not read the ledger or its account, or answered in a shape this module does not understand. */
20
25
  class WalletReadError extends Error {
21
26
  constructor(message, code) {
@@ -23,9 +28,21 @@ class WalletReadError extends Error {
23
28
  this.name = 'WalletReadError';
24
29
  if (code !== undefined)
25
30
  this.code = code;
31
+ this.rateLimited = code === LIMIT_EXCEEDED;
26
32
  }
27
33
  }
28
34
  exports.WalletReadError = WalletReadError;
35
+ /** The wallet did not sign the ownership message. */
36
+ class WalletSignError extends Error {
37
+ constructor(reason, message, code) {
38
+ super(message);
39
+ this.name = 'WalletSignError';
40
+ this.reason = reason;
41
+ if (code !== undefined)
42
+ this.code = code;
43
+ }
44
+ }
45
+ exports.WalletSignError = WalletSignError;
29
46
  /** A registry API answered with a non-2xx status. `body` is the raw response text. */
30
47
  class RegistryApiError extends Error {
31
48
  constructor(status, body, url) {
@@ -54,4 +71,54 @@ class TokenWalletError extends Error {
54
71
  }
55
72
  }
56
73
  exports.TokenWalletError = TokenWalletError;
74
+ /** How many characters of a registry error body {@link describeWalletError} shows. */
75
+ const REGISTRY_BODY_CHARS = 300;
76
+ function described(kind, message, code) {
77
+ return code === undefined ? { message, kind } : { message, kind, code };
78
+ }
79
+ /** Text for a thrown value that is not an `Error`; never throws (cycles, BigInt, `undefined`). */
80
+ function thrownText(error) {
81
+ try {
82
+ // Typed as a string, but `undefined` for `undefined`, a function or a symbol.
83
+ const json = JSON.stringify(error);
84
+ return json ?? String(error);
85
+ }
86
+ catch {
87
+ return String(error);
88
+ }
89
+ }
90
+ /** A user-facing sentence and a kind for any error the wallets module throws (or anything else thrown). */
91
+ function describeWalletError(error) {
92
+ if (error instanceof WalletSubmitError) {
93
+ switch (error.outcome) {
94
+ case 'rejected-by-user':
95
+ return described('declined', 'You declined in the wallet. Nothing was submitted.', error.code);
96
+ case 'failed':
97
+ return described('not-committed', `Not committed: ${error.message}`, error.code);
98
+ case 'unknown':
99
+ // The message already says not to resubmit blindly.
100
+ return described('outcome-unknown', error.message, error.code);
101
+ }
102
+ }
103
+ if (error instanceof WalletReadError) {
104
+ return error.rateLimited
105
+ ? described('rate-limited', `The wallet is limiting how often this page reads the ledger (CIP-0103 -32005), and it still refused after a few retries. Wait a moment, then retry. Details: ${error.message}`, error.code)
106
+ : described('read-failed', `The wallet did not answer a read: ${error.message}`, error.code);
107
+ }
108
+ if (error instanceof WalletSignError) {
109
+ return error.reason === 'rejected-by-user'
110
+ ? described('declined', 'You declined to sign in the wallet. Nothing was verified.', error.code)
111
+ : described('sign-failed', `The wallet did not sign: ${error.message}`, error.code);
112
+ }
113
+ if (error instanceof RegistryApiError) {
114
+ return described('registry', `DA's registry answered ${error.status}: ${error.body.slice(0, REGISTRY_BODY_CHARS)}`, error.status);
115
+ }
116
+ if (error instanceof RegistryResponseError)
117
+ return described('registry', error.message);
118
+ if (error instanceof TokenWalletError)
119
+ return described('refused', error.message, error.code);
120
+ if (error instanceof Error)
121
+ return described('other', error.message);
122
+ return described('other', thrownText(error));
123
+ }
57
124
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/wallets/errors.ts"],"names":[],"mappings":";AAAA,+FAA+F;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ding[], request: {
45
45
  readonly instrumentId: InstrumentId;
46
46
  readonly amount: string;
47
47
  }): HoldingSelection;
48
+ /** One instrument's holdings, summed exactly. */
49
+ export interface InstrumentBalance {
50
+ /** {@link instrumentKey} of the instrument. */
51
+ readonly key: string;
52
+ readonly instrumentId: InstrumentId;
53
+ /** The spendable (unlocked) total, with 10 decimal places. */
54
+ readonly unlocked: string;
55
+ /** The total locked to a burn request, an allocation or a transfer in flight, with 10 decimal places. */
56
+ readonly locked: string;
57
+ /** How many holdings (locked ones included) make up the totals. */
58
+ readonly holdingCount: number;
59
+ }
60
+ /**
61
+ * A stable, unambiguous key for an instrument: `<id>@<admin>`, with `%` and `@` in each component percent-escaped
62
+ * (`%25`, `%40`), so the one bare `@` always separates id from admin and distinct instruments never share a key
63
+ * (`USD@issuer` at `registrar::1220bb` is `USD%40issuer@registrar::1220bb`; `USD` at `issuer@registrar::1220bb` is
64
+ * `USD@issuer%40registrar::1220bb`). An id and admin without `%` or `@`, as usual, read unchanged. Treat the key as
65
+ * opaque: compare it, do not parse it.
66
+ */
67
+ export declare function instrumentKey({ admin, id }: InstrumentId): string;
68
+ /**
69
+ * The holdings summed per instrument, locked apart, sorted by instrument id then admin (by code unit, so the order does
70
+ * not depend on the locale). Holdings come from {@link parseHolding}, which refuses an unparseable amount.
71
+ */
72
+ export declare function instrumentBalances(holdings: readonly Holding[]): InstrumentBalance[];
48
73
  //# sourceMappingURL=holdings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"holdings.d.ts","sourceRoot":"","sources":["../../../src/wallets/holdings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5D,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,+CAA+C;IAC/C,Q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AgB,kBAAkB,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,iBAAiB,EAAE,CAwBpF"}
@@ -4,6 +4,8 @@ exports.MAX_SKIPPING_COVER_CANDIDATES = void 0;
4
4
  exports.parseHolding = parseHolding;
5
5
  exports.requirePositiveAmount = requirePositiveAmount;
6
6
  exports.selectHoldings = selectHoldings;
7
+ exports.instrumentKey = instrumentKey;
8
+ exports.instrumentBalances = instrumentBalances;
7
9
  /** Read holdings from the ACS and pick the inputs for a transfer or burn, with exact decimal arithmetic. */
8
10
  const decimal_1 = require("./decimal");
9
11
  const errors_1 = require("./errors");
@@ -195,4 +197,46 @@ function selectHoldings(holdings, request) {
195
197
  amount: (0, decimal_1.formatDecimalUnits)(needed),
196
198
  };
197
199
  }
200
+ /** Escapes `%` and `@` in one key component, so the component holds no bare `@` and the escape itself is unambiguous. */
201
+ const escapeKeyComponent = (text) => text.replace(/%/g, '%25').replace(/@/g, '%40');
202
+ /**
203
+ * A stable, unambiguous key for an instrument: `<id>@<admin>`, with `%` and `@` in each component percent-escaped
204
+ * (`%25`, `%40`), so the one bare `@` always separates id from admin and distinct instruments never share a key
205
+ * (`USD@issuer` at `registrar::1220bb` is `USD%40issuer@registrar::1220bb`; `USD` at `issuer@registrar::1220bb` is
206
+ * `USD@issuer%40registrar::1220bb`). An id and admin without `%` or `@`, as usual, read unchanged. Treat the key as
207
+ * opaque: compare it, do not parse it.
208
+ */
209
+ function instrumentKey({ admin, id }) {
210
+ return `${escapeKeyComponent(id)}@${escapeKeyComponent(admin)}`;
211
+ }
212
+ const compareText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
213
+ /**
214
+ * The holdings summed per instrument, locked apart, sorted by instrument id then admin (by code unit, so the order does
215
+ * not depend on the locale). Holdings come from {@link parseHolding}, which refuses an unparseable amount.
216
+ */
217
+ function instrumentBalances(holdings) {
218
+ const totals = new Map();
219
+ for (const entry of holdings) {
220
+ const units = (0, decimal_1.parseDecimalUnits)(entry.amount);
221
+ if (units === null)
222
+ continue;
223
+ const key = instrumentKey(entry.instrumentId);
224
+ const total = totals.get(key) ?? { instrumentId: entry.instrumentId, unlocked: 0n, locked: 0n, count: 0 };
225
+ if (entry.locked)
226
+ total.locked += units;
227
+ else
228
+ total.unlocked += units;
229
+ total.count += 1;
230
+ totals.set(key, total);
231
+ }
232
+ return [...totals.entries()]
233
+ .map(([key, total]) => ({
234
+ key,
235
+ instrumentId: total.instrumentId,
236
+ unlocked: (0, decimal_1.formatDecimalUnits)(total.unlocked),
237
+ locked: (0, decimal_1.formatDecimalUnits)(total.locked),
238
+ holdingCount: total.count,
239
+ }))
240
+ .sort((a, b) => compareText(a.instrumentId.id, b.instrumentId.id) || compareText(a.instrumentId.admin, b.instrumentId.admin));
241
+ }
198
242
  //# sourceMappingURL=holdings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"holdings.js","sourceRoot":"","sources":["../../../src/wallets/holdings.ts"],"names":[],"mappings":";;;;;;AAAA,4GAA4G;AAC5G,uCAAqF;AACrF,qCAA4C;AAC5C,6CAAgE;AAChE,iCAAkD;AAClD,wDAAiE;AACjE,oEAA8F;AAC9F,2CAAgD;AAehD;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,CAAC,IAAA,eAAQ,EAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,OAAO,CACd,QAAwB,EACxB,MAKC;IAED,MAAM,KAAK,GAAG,IAAA,qBAAc,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,IACE,KAAK,KAAK,SAAS;Q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E,SAAS;QAC7B,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAC1G,IAAI,KAAK,CAAC,MAAM;YAAE,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC;;YACnC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC;QAC7B,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;QACjB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;SACzB,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QACtB,GAAG;QACH,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,QAAQ,EAAE,IAAA,4BAAkB,EAAC,KAAK,CAAC,QAAQ,CAAC;QAC5C,MAAM,EAAE,IAAA,4BAAkB,EAAC,KAAK,CAAC,MAAM,CAAC;QACxC,YAAY,EAAE,KAAK,CAAC,KAAK;KAC1B,CAAC,CAAC;SACF,IAAI,CACH,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAC/G,CAAC;AACN,CAAC"}
@@ -3,17 +3,24 @@
3
3
  * wallet provider. In a browser bundle import `@fairmint/canton-node-sdk/build/src/wallets/index.js`, which loads none
4
4
  * of the SDK's Node dependencies; the package root also exports it as the `Wallets` namespace (for Node).
5
5
  *
6
- * The surface is small on purpose: plug in a CIP-0103 provider (`createTokenWallet`), the registry client, the errors
7
- * and the data types. Command builders, parsers and the CIP-0103 client stay internal.
6
+ * The surface is small on purpose: plug in a CIP-0103 provider (`createTokenWallet`), a page's wallet session and
7
+ * observable state (`createCip103Session`, `createTokenWalletStore`; framework-agnostic), the registry client, the
8
+ * ownership proof's client side (`requestWalletOwnershipVerdict`, `proveWalletOwnership` and the message it signs; the
9
+ * server side, `createWalletOwnershipChallenger` and `verifyWalletOwnership`, is Node-only and exported from the
10
+ * package root), the read back-off options, the errors and their user-facing descriptions (`describeWalletError`), and
11
+ * the data types. Command builders, parsers, error-code tables and the CIP-0103 client stay internal.
8
12
  */
9
- export { createTokenWallet, type BurnRequestOptions, type TokenWallet, type TokenWalletOptions } from './token-wallet';
10
- export { createTokenStandardWallet, type TokenStandardWallet, type TokenStandardWalletOptions, type TransferOffers, type TransferOptions, type TransferRequest, type TransferResult, } from './token-standard-wallet';
11
- export { primaryPartyId, type Cip103EventListener, type Cip103LedgerApiParams, type Cip103PrepareExecuteParams, type Cip103Provider, type Cip103Request, } from './cip103';
13
+ export { createTokenWallet, newBurnReference, type BurnRequestOptions, type BurnRequestResult, type TokenWallet, type TokenWalletOptions, type TokenWalletState, } from './token-wallet';
14
+ export { createTokenStandardWallet, type TokenStandardState, type TokenStandardWallet, type TokenStandardWalletOptions, type TransferOffers, type TransferOptions, type TransferPlan, type TransferRequest, type TransferResult, } from './token-standard-wallet';
15
+ export { cip103NetworkId, DEFAULT_READ_RETRY_DELAYS_MS, primaryPartyId, type Cip103Account, type Cip103EventListener, type Cip103LedgerApiParams, type Cip103PrepareExecuteParams, type Cip103Provider, type Cip103Request, type Cip103SignMessageParams, type WalletReadRetryOptions, } from './cip103';
16
+ export { createCip103Session, type ConnectedWallet, type Cip103ConnectContext, type Cip103Session, type Cip103SessionState, } from './session';
17
+ export { createTokenWalletStore, type ActionOutcome, type OpenTokenWalletContext, type TokenWalletStore, type TokenWalletStoreOptions, type TokenWalletView, type WalletActionContext, } from './store';
18
+ export { buildWalletOwnershipMessage, proveWalletOwnership, requestWalletOwnershipVerdict, type ProveWalletOwnershipOptions, type RequestWalletOwnershipVerdictOptions, type WalletOwnershipChallenge, type WalletOwnershipChallengeFailure, type WalletOwnershipChallengeResponse, type WalletOwnershipFailure, type WalletOwnershipMessageFields, type WalletOwnershipProof, type WalletOwnershipVerdict, } from './ownership';
12
19
  export { createDaUtilitiesClient, type BurnRequestContextArgs, type DaNetwork, type DaUtilitiesClient, type DaUtilitiesClientOptions, type DaUtilitiesTarget, type FetchLike, } from './da-utilities/client';
13
20
  export type { ChoiceContext, ChoiceContextData, FactoryWithChoiceContext, ReadContracts, TokenRegistry, TransferFactory, TransferFactoryArgs, TransferInstructionAction, TransferKind, TransferSpec, } from './token-registry';
14
- export { RegistryApiError, RegistryResponseError, TokenWalletError, WalletReadError, WalletSubmitError, type TokenWalletErrorCode, type WalletSubmitOutcome, } from './errors';
21
+ export { describeWalletError, RegistryApiError, RegistryResponseError, TokenWalletError, WalletReadError, WalletSignError, WalletSubmitError, type TokenWalletErrorCode, type WalletErrorDescription, type WalletSignErrorReason, type WalletSubmitOutcome, } from './errors';
15
22
  export type { BurnRequest, MintOffer, TransferOffer } from './contracts';
16
- export type { Holding } from './holdings';
23
+ export { instrumentKey, type Holding, type InstrumentBalance } from './holdings';
17
24
  export type { ActiveContract, ContractFilter, CreateCommand, DisclosedContract, ExerciseCommand, InstrumentId, InterfaceView, LedgerCommand, SubmitResult, WalletSubmission, } from './types';
18
25
  export type { JsonArray, JsonObject, JsonPrimitive, JsonValue } from './json';
19
26
  export { formatDecimalUnits, parseDecimalUnits } from './decimal';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,KAAK,WA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,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sBAAsB,EACtB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,KAAK,2BAA2B,EAChC,KAAK,oCAAoC,EACzC,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,EACrC,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,SAAS,GACf,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACjF,YAAY,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
@@ -1,28 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseDecimalUnits = exports.formatDecimalUnits = exports.WalletSubmitError = exports.WalletReadError = exports.TokenWalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.createDaUtilitiesClient = exports.primaryPartyId = exports.createTokenStandardWallet = exports.createTokenWallet = void 0;
3
+ exports.parseDecimalUnits = exports.formatDecimalUnits = exports.instrumentKey = exports.WalletSubmitError = exports.WalletSignError = exports.WalletReadError = exports.TokenWalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.describeWalletError = exports.createDaUtilitiesClient = exports.requestWalletOwnershipVerdict = exports.proveWalletOwnership = exports.buildWalletOwnershipMessage = exports.createTokenWalletStore = exports.createCip103Session = exports.primaryPartyId = exports.DEFAULT_READ_RETRY_DELAYS_MS = exports.cip103NetworkId = exports.createTokenStandardWallet = exports.newBurnReference = exports.createTokenWallet = void 0;
4
4
  /**
5
5
  * Browser-safe token standard (CIP-56) and DA Utility Registry holder actions through any CIP-0103 (Canton dApp API)
6
6
  * wallet provider. In a browser bundle import `@fairmint/canton-node-sdk/build/src/wallets/index.js`, which loads none
7
7
  * of the SDK's Node dependencies; the package root also exports it as the `Wallets` namespace (for Node).
8
8
  *
9
- * The surface is small on purpose: plug in a CIP-0103 provider (`createTokenWallet`), the registry client, the errors
10
- * and the data types. Command builders, parsers and the CIP-0103 client stay internal.
9
+ * The surface is small on purpose: plug in a CIP-0103 provider (`createTokenWallet`), a page's wallet session and
10
+ * observable state (`createCip103Session`, `createTokenWalletStore`; framework-agnostic), the registry client, the
11
+ * ownership proof's client side (`requestWalletOwnershipVerdict`, `proveWalletOwnership` and the message it signs; the
12
+ * server side, `createWalletOwnershipChallenger` and `verifyWalletOwnership`, is Node-only and exported from the
13
+ * package root), the read back-off options, the errors and their user-facing descriptions (`describeWalletError`), and
14
+ * the data types. Command builders, parsers, error-code tables and the CIP-0103 client stay internal.
11
15
  */
12
16
  var token_wallet_1 = require("./token-wallet");
13
17
  Object.defineProperty(exports, "createTokenWallet", { enumerable: true, get: function () { return token_wallet_1.createTokenWallet; } });
18
+ Object.defineProperty(exports, "newBurnReference", { enumerable: true, get: function () { return token_wallet_1.newBurnReference; } });
14
19
  var token_standard_wallet_1 = require("./token-standard-wallet");
15
20
  Object.defineProperty(exports, "createTokenStandardWallet", { enumerable: true, get: function () { return token_standard_wallet_1.createTokenStandardWallet; } });
16
21
  var cip103_1 = require("./cip103");
22
+ Object.defineProperty(exports, "cip103NetworkId", { enumerable: true, get: function () { return cip103_1.cip103NetworkId; } });
23
+ Object.defineProperty(exports, "DEFAULT_READ_RETRY_DELAYS_MS", { enumerable: true, get: function () { return cip103_1.DEFAULT_READ_RETRY_DELAYS_MS; } });
17
24
  Object.defineProperty(exports, "primaryPartyId", { enumerable: true, get: function () { return cip103_1.primaryPartyId; } });
25
+ var session_1 = require("./session");
26
+ Object.defineProperty(exports, "createCip103Session", { enumerable: true, get: function () { return session_1.createCip103Session; } });
27
+ var store_1 = require("./store");
28
+ Object.defineProperty(exports, "createTokenWalletStore", { enumerable: true, get: function () { return store_1.createTokenWalletStore; } });
29
+ var ownership_1 = require("./ownership");
30
+ Object.defineProperty(exports, "buildWalletOwnershipMessage", { enumerable: true, get: function () { return ownership_1.buildWalletOwnershipMessage; } });
31
+ Object.defineProperty(exports, "proveWalletOwnership", { enumerable: true, get: function () { return ownership_1.proveWalletOwnership; } });
32
+ Object.defineProperty(exports, "requestWalletOwnershipVerdict", { enumerable: true, get: function () { return ownership_1.requestWalletOwnershipVerdict; } });
18
33
  var client_1 = require("./da-utilities/client");
19
34
  Object.defineProperty(exports, "createDaUtilitiesClient", { enumerable: true, get: function () { return client_1.createDaUtilitiesClient; } });
20
35
  var errors_1 = require("./errors");
36
+ Object.defineProperty(exports, "describeWalletError", { enumerable: true, get: function () { return errors_1.describeWalletError; } });
21
37
  Object.defineProperty(exports, "RegistryApiError", { enumerable: true, get: function () { return errors_1.RegistryApiError; } });
22
38
  Object.defineProperty(exports, "RegistryResponseError", { enumerable: true, get: function () { return errors_1.RegistryResponseError; } });
23
39
  Object.defineProperty(exports, "TokenWalletError", { enumerable: true, get: function () { return errors_1.TokenWalletError; } });
24
40
  Object.defineProperty(exports, "WalletReadError", { enumerable: true, get: function () { return errors_1.WalletReadError; } });
41
+ Object.defineProperty(exports, "WalletSignError", { enumerable: true, get: function () { return errors_1.WalletSignError; } });
25
42
  Object.defineProperty(exports, "WalletSubmitError", { enumerable: true, get: function () { return errors_1.WalletSubmitError; } });
43
+ var holdings_1 = require("./holdings");
44
+ Object.defineProperty(exports, "instrumentKey", { enumerable: true, get: function () { return holdings_1.instrumentKey; } });
26
45
  var decimal_1 = require("./decimal");
27
46
  Object.defineProperty(exports, "formatDecimalUnits", { enumerable: true, get: function () { return decimal_1.formatDecimalUnits; } });
28
47
  Object.defineProperty(exports, "parseDecimalUnits", { enumerable: true, get: function () { return decimal_1.parseDecimalUnits; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,+CAAuH;AAA9G,iHAAA,iBAAiB,OAAA;AAC1B,iEAQiC;AAP/B,kIAAA,yBAAyB,OAAA;AAQ3B,mCAOkB;AANhB,wGAAA,cAAc,OAAA;AAOhB,gDAQ+B;AAP7B,iHAAA,uBAAuB,OAAA;AAoBzB,mCAQkB;AAPhB,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,0GAAA,gBAAgB,OAAA;AAChB,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AAmBnB,qCAAkE;AAAzD,6GAAA,kBAAkB,OAAA;AAAE,4GAAA,iBAAiB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,+CAQwB;AAPtB,iHAAA,iBAAiB,OAAA;AACjB,gHAAA,gBAAgB,OAAA;AAOlB,iEAUiC;AAT/B,kIAAA,yBAAyB,OAAA;AAU3B,mCAYkB;AAXhB,yGAAA,eAAe,OAAA;AACf,sHAAA,4BAA4B,OAAA;AAC5B,wGAAA,cAAc,OAAA;AAUhB,qCAMmB;AALjB,8GAAA,mBAAmB,OAAA;AAMrB,iCAQiB;AAPf,+GAAA,sBAAsB,OAAA;AAQxB,yCAaqB;AAZnB,wHAAA,2BAA2B,OAAA;AAC3B,iHAAA,oBAAoB,OAAA;AACpB,0HAAA,6BAA6B,OAAA;AAW/B,gDAQ+B;AAP7B,iHAAA,uBAAuB,OAAA;AAoBzB,mCAYkB;AAXhB,6GAAA,mBAAmB,OAAA;AACnB,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,0GAAA,gBAAgB,OAAA;AAChB,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AAOnB,uCAAiF;AAAxE,yGAAA,aAAa,OAAA;AActB,qCAAkE;AAAzD,6GAAA,kBAAkB,OAAA;AAAE,4GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Call every listener, even when one throws: a listener's error must not skip the others or leave the caller's
3
+ * bookkeeping half done (a latch held, a state half published). Each error is rethrown on a fresh task, where the host
4
+ * reports it as uncaught, so it is not swallowed.
5
+ */
6
+ export declare function notifyListeners(listeners: Iterable<() => void>): void;
7
+ //# sourceMappingURL=notify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify.d.ts","sourceRoot":"","sources":["../../../src/wallets/notify.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAUrE"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.notifyListeners = notifyListeners;
4
+ /**
5
+ * Call every listener, even when one throws: a listener's error must not skip the others or leave the caller's
6
+ * bookkeeping half done (a latch held, a state half published). Each error is rethrown on a fresh task, where the host
7
+ * reports it as uncaught, so it is not swallowed.
8
+ */
9
+ function notifyListeners(listeners) {
10
+ for (const listener of [...listeners]) {
11
+ try {
12
+ listener();
13
+ }
14
+ catch (error) {
15
+ setTimeout(() => {
16
+ throw error;
17
+ }, 0);
18
+ }
19
+ }
20
+ }
21
+ //# sourceMappingURL=notify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify.js","sourceRoot":"","sources":["../../../src/wallets/notify.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,yBAAgC,SAA+B;IAC7D,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,QAAQ,EAAE,CAAC;QACb,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,UAAU,CAAC,GAAG,EAAE;gBACd,MAAM,KAAK,CAAC;YACd,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Proof that the user controls a wallet's party, not just its party id: the wallet signs a canonical, human-readable
3
+ * message (CIP-0103 `signMessage`) built from a challenge the dApp's server issued, and the server verifies it with
4
+ * `verifyWalletOwnership` (Node only, exported from the package root). A check in the browser proves nothing: anyone
5
+ * can call this code with a made-up provider, so only the server's verification counts.
6
+ *
7
+ * The message is plain text with a fixed first line and a statement that it is not a transaction, so a dApp cannot use
8
+ * it to get a transaction hash (34 binary bytes) signed. Wallets sign the raw message bytes with the party's key (Loop:
9
+ * Ed25519 over the UTF-8 bytes; the CIP-0103 reference wallet: the same), so the text form is the only protection. The
10
+ * nonce must come from the server, be random, and be accepted once.
11
+ *
12
+ * The `Network:` line is a label, not proof: a party id is derived from its key and is the same on every network, so a
13
+ * verified proof says nothing about the party existing or being hosted on that network. `proveWalletOwnership` refuses
14
+ * a wallet that reports another network as a guard against mistakes; a server that needs the network proven must look
15
+ * the party up on that network (its Scan or ledger party and topology APIs).
16
+ */
17
+ import { type Cip103Provider } from './cip103';
18
+ import type { DaNetwork, FetchLike } from './da-utilities/client';
19
+ /** The first line of every ownership message. */
20
+ export declare const WALLET_OWNERSHIP_TITLE = "Canton wallet ownership proof";
21
+ /** The message format version, its `Version:` line. */
22
+ export declare const WALLET_OWNERSHIP_VERSION = "1";
23
+ /** What the dApp's server issues for one proof. Times are ISO-8601 in UTC with milliseconds (`toISOString()`). */
24
+ export interface WalletOwnershipChallenge {
25
+ /** The dApp's host (`app.example.com`, `localhost:3000`): the site the user proves ownership to. */
26
+ readonly domain: string;
27
+ /** Single-use, server-generated, unguessable: 16-512 of `A-Z a-z 0-9 . _ ~ -`. */
28
+ readonly nonce: string;
29
+ readonly issuedAt: string;
30
+ readonly expiresAt: string;
31
+ /**
32
+ * The Canton network the dApp expects the wallet on (for example the wallet's CIP-0103 `networkId`, `canton:devnet`).
33
+ * A label in the message: signing it does not prove the party is on that network (see the module comment).
34
+ */
35
+ readonly network?: string;
36
+ }
37
+ /** Every field of an ownership message. */
38
+ export interface WalletOwnershipMessageFields extends WalletOwnershipChallenge {
39
+ readonly partyId: string;
40
+ }
41
+ /** What the browser sends to the server to verify. */
42
+ export interface WalletOwnershipProof {
43
+ readonly partyId: string;
44
+ /** The account's `publicKey`, as the wallet reported it. */
45
+ readonly publicKey: string;
46
+ /** The account's `namespace`, when the wallet reported it. */
47
+ readonly namespace?: string;
48
+ /** The exact text the wallet signed. */
49
+ readonly message: string;
50
+ /** The signature as the wallet returned it (Loop: hex; the CIP-0103 reference wallet: base64). */
51
+ readonly signature: string;
52
+ }
53
+ /** Whether `value` may be a message's domain: a host name, optionally with a port. */
54
+ export declare function isWalletOwnershipDomain(value: unknown): value is string;
55
+ /** Whether `value` may be a message's party: a Canton party id (`hint::namespace`) of printable ASCII. */
56
+ export declare function isWalletOwnershipPartyId(value: unknown): value is string;
57
+ /**
58
+ * The canonical message for these fields. Throws `TypeError` on a field that is not valid. The same fields always give
59
+ * the same text, so the server rebuilds it from the fields it parses and refuses anything else.
60
+ */
61
+ export declare function buildWalletOwnershipMessage(fields: WalletOwnershipMessageFields): string;
62
+ /**
63
+ * The fields of a canonical ownership message, or null for any text that is not exactly what
64
+ * {@link buildWalletOwnershipMessage} gives for its fields (another version, an extra line or space, a reordered
65
+ * field).
66
+ */
67
+ export declare function parseWalletOwnershipMessage(message: string): WalletOwnershipMessageFields | null;
68
+ export interface ProveWalletOwnershipOptions {
69
+ /** The challenge the dApp's server issued. */
70
+ readonly challenge: WalletOwnershipChallenge;
71
+ /**
72
+ * The party the dApp expects. CIP-0103 wallets sign with the primary account, so a different primary account is
73
+ * refused before anything is signed.
74
+ */
75
+ readonly partyId?: string;
76
+ /** Defaults to the system clock; an expired challenge is refused before anything is signed. */
77
+ readonly now?: () => Date;
78
+ }
79
+ /**
80
+ * Ask the wallet to sign the ownership message for the challenge, as its primary account. Returns what the server needs
81
+ * to verify; it is not itself proof of anything until the server verified it (`verifyWalletOwnership`).
82
+ */
83
+ export declare function proveWalletOwnership(provider: Cip103Provider, options: ProveWalletOwnershipOptions): Promise<WalletOwnershipProof>;
84
+ /** Why a proof did not verify (`verifyWalletOwnership`, Node only). */
85
+ export type WalletOwnershipFailure =
86
+ /** The proof is not an object of string fields. */
87
+ 'malformed-proof'
88
+ /** The message is not exactly a canonical ownership message. */
89
+ | 'malformed-message' | 'domain-mismatch' | 'nonce-mismatch'
90
+ /** The message, the proof and the expected party do not all name the same party, or the namespace differs. */
91
+ | 'party-mismatch' | 'network-mismatch'
92
+ /** The message's `Issued At` or `Expiration Time` is not the one the server issued. */
93
+ | 'window-mismatch'
94
+ /** Issued in the future (beyond the allowed clock skew). */
95
+ | 'not-yet-valid'
96
+ /** Past its expiration time. */
97
+ | 'expired'
98
+ /** The message allows a longer validity window than `maxAgeMs`. */
99
+ | 'lifetime-too-long'
100
+ /** The public key is not an Ed25519 key in an encoding this verifier accepts. */
101
+ | 'unsupported-public-key'
102
+ /** The key's fingerprint is not the party's namespace (see `verifyWalletOwnership`). */
103
+ | 'key-not-bound-to-party'
104
+ /** The signature is not 64 bytes of hex or base64. */
105
+ | 'malformed-signature'
106
+ /** The signature does not verify. */
107
+ | 'bad-signature';
108
+ /** Why a challenger refused a challenge token before looking at the signature (`createWalletOwnershipChallenger`). */
109
+ export type WalletOwnershipChallengeFailure =
110
+ /** The token was not issued by this server (another key or purpose, or altered). */
111
+ 'challenge-invalid' | 'challenge-expired'
112
+ /** Each challenge gets one verdict. */
113
+ | 'challenge-used'
114
+ /** Issued to another subject (signed-in user) or for another host. */
115
+ | 'challenge-not-yours';
116
+ /** A challenger's answer to a challenge request: what the wallet signs, and the token to send back with the proof. */
117
+ export interface WalletOwnershipChallengeResponse {
118
+ readonly challenge: WalletOwnershipChallenge;
119
+ /** Opaque to the browser: the server's MACed record of the challenge. */
120
+ readonly token: string;
121
+ }
122
+ /** The server's verdict on a proof. */
123
+ export type WalletOwnershipVerdict = {
124
+ readonly verified: true;
125
+ readonly partyId: string;
126
+ /** The party's namespace, which is the key's Canton fingerprint. */
127
+ readonly publicKeyFingerprint: string;
128
+ /** The message's network label as signed; not proof that the party exists on that network. */
129
+ readonly claimedNetwork: string | null;
130
+ readonly verifiedAt: string;
131
+ } | {
132
+ readonly verified: false;
133
+ readonly reason: WalletOwnershipChallengeFailure | WalletOwnershipFailure;
134
+ /** A sentence for logs or the user. */
135
+ readonly message: string;
136
+ };
137
+ export interface RequestWalletOwnershipVerdictOptions {
138
+ /** The party to prove; the wallet's primary account must be this party. */
139
+ readonly partyId: string;
140
+ readonly network: DaNetwork;
141
+ /** Sends the requests (for example a `fetch` that carries the user's session cookie). */
142
+ readonly fetch: FetchLike;
143
+ /** Answers `POST { network, partyId }` with `{ data: WalletOwnershipChallengeResponse }`. */
144
+ readonly challengeUrl: string;
145
+ /** Answers `POST { token, proof }` with `{ data: WalletOwnershipVerdict }`. */
146
+ readonly verifyUrl: string;
147
+ }
148
+ /**
149
+ * The browser half of an ownership check, against a server that uses the SDK's challenger (or the same wire format: a
150
+ * 2xx answer is `{ data }`, any other `{ error: string }`): POST `challengeUrl` with `{ network, partyId }`, have the
151
+ * wallet sign the challenge (`proveWalletOwnership`), POST `verifyUrl` with `{ token, proof }`, and return the server's
152
+ * verdict. Throws when no verdict was reached: the server refused (a non-2xx answer, or one without `data`), or the
153
+ * wallet did not sign (`WalletSignError`).
154
+ */
155
+ export declare function requestWalletOwnershipVerdict(provider: Cip103Provider, options: RequestWalletOwnershipVerdictOptions): Promise<WalletOwnershipVerdict>;
156
+ //# sourceMappingURL=ownership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../../../src/wallets/ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlE,iDAAiD;AACjD,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AACtE,uDAAuD;AACvD,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,kHAAkH;AAClH,MAAM,WAAW,wBAAwB;IACvC,oGAAoG;IACpG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,2CAA2C;AAC3C,MAAM,WAAW,4BAA6B,SAAQ,wBAAwB;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8DA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