@fairmint/canton-node-sdk 0.0.282 → 0.0.283

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 (72) hide show
  1. package/README.md +128 -154
  2. package/build/src/utils/external-signing/wallet-ownership-challenger.d.ts.map +1 -1
  3. package/build/src/utils/external-signing/wallet-ownership-challenger.js +2 -3
  4. package/build/src/utils/external-signing/wallet-ownership-challenger.js.map +1 -1
  5. package/build/src/utils/external-signing/wallet-ownership.d.ts.map +1 -1
  6. package/build/src/utils/external-signing/wallet-ownership.js +8 -18
  7. package/build/src/utils/external-signing/wallet-ownership.js.map +1 -1
  8. package/build/src/wallets/acs.d.ts +2 -1
  9. package/build/src/wallets/acs.d.ts.map +1 -1
  10. package/build/src/wallets/acs.js +6 -31
  11. package/build/src/wallets/acs.js.map +1 -1
  12. package/build/src/wallets/cip103.d.ts +32 -68
  13. package/build/src/wallets/cip103.d.ts.map +1 -1
  14. package/build/src/wallets/cip103.js +112 -230
  15. package/build/src/wallets/cip103.js.map +1 -1
  16. package/build/src/wallets/commands.d.ts +39 -6
  17. package/build/src/wallets/commands.d.ts.map +1 -1
  18. package/build/src/wallets/commands.js +50 -5
  19. package/build/src/wallets/commands.js.map +1 -1
  20. package/build/src/wallets/contracts.d.ts +12 -0
  21. package/build/src/wallets/contracts.d.ts.map +1 -1
  22. package/build/src/wallets/contracts.js +21 -5
  23. package/build/src/wallets/contracts.js.map +1 -1
  24. package/build/src/wallets/da-utilities/client.d.ts +61 -29
  25. package/build/src/wallets/da-utilities/client.d.ts.map +1 -1
  26. package/build/src/wallets/da-utilities/client.js +78 -75
  27. package/build/src/wallets/da-utilities/client.js.map +1 -1
  28. package/build/src/wallets/errors.d.ts +11 -8
  29. package/build/src/wallets/errors.d.ts.map +1 -1
  30. package/build/src/wallets/errors.js +13 -3
  31. package/build/src/wallets/errors.js.map +1 -1
  32. package/build/src/wallets/holdings.d.ts +14 -4
  33. package/build/src/wallets/holdings.d.ts.map +1 -1
  34. package/build/src/wallets/holdings.js +27 -47
  35. package/build/src/wallets/holdings.js.map +1 -1
  36. package/build/src/wallets/index.d.ts +17 -21
  37. package/build/src/wallets/index.d.ts.map +1 -1
  38. package/build/src/wallets/index.js +14 -23
  39. package/build/src/wallets/index.js.map +1 -1
  40. package/build/src/wallets/instrument.js +1 -1
  41. package/build/src/wallets/instrument.js.map +1 -1
  42. package/build/src/wallets/ownership.d.ts +20 -26
  43. package/build/src/wallets/ownership.d.ts.map +1 -1
  44. package/build/src/wallets/ownership.js +33 -27
  45. package/build/src/wallets/ownership.js.map +1 -1
  46. package/build/src/wallets/session.d.ts +30 -68
  47. package/build/src/wallets/session.d.ts.map +1 -1
  48. package/build/src/wallets/session.js +119 -167
  49. package/build/src/wallets/session.js.map +1 -1
  50. package/build/src/wallets/store.d.ts +148 -86
  51. package/build/src/wallets/store.d.ts.map +1 -1
  52. package/build/src/wallets/store.js +267 -99
  53. package/build/src/wallets/store.js.map +1 -1
  54. package/build/src/wallets/templates.d.ts +10 -23
  55. package/build/src/wallets/templates.d.ts.map +1 -1
  56. package/build/src/wallets/templates.js +9 -33
  57. package/build/src/wallets/templates.js.map +1 -1
  58. package/build/src/wallets/types.d.ts +6 -20
  59. package/build/src/wallets/types.d.ts.map +1 -1
  60. package/build/src/wallets/wallet.d.ts +130 -74
  61. package/build/src/wallets/wallet.d.ts.map +1 -1
  62. package/build/src/wallets/wallet.js +347 -185
  63. package/build/src/wallets/wallet.js.map +1 -1
  64. package/package.json +1 -1
  65. package/build/src/wallets/cip56-core.d.ts +0 -175
  66. package/build/src/wallets/cip56-core.d.ts.map +0 -1
  67. package/build/src/wallets/cip56-core.js +0 -325
  68. package/build/src/wallets/cip56-core.js.map +0 -1
  69. package/build/src/wallets/token-registry.d.ts +0 -97
  70. package/build/src/wallets/token-registry.d.ts.map +0 -1
  71. package/build/src/wallets/token-registry.js +0 -19
  72. package/build/src/wallets/token-registry.js.map +0 -1
@@ -5,17 +5,17 @@
5
5
  * can call this code with a made-up provider, so only the server's verification counts.
6
6
  *
7
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.
8
+ * it to get a transaction hash (34 binary bytes) signed. Wallets sign the raw message bytes with the party's key
9
+ * (Ed25519 over the UTF-8 bytes), so the text form is the only protection. The nonce must come from the server, be
10
+ * random, and be accepted once.
11
11
  *
12
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
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).
14
+ * a wallet that reports the other DA network (the session's rule) as a guard against mistakes; a server that needs the
15
+ * network proven must look the party up on that network (its Scan or ledger party and topology APIs).
16
16
  */
17
- import { type Cip103Provider } from './cip103';
18
- import type { DaNetwork, FetchLike } from './da-utilities/client';
17
+ import { type Cip103Connection } from './cip103';
18
+ import { type FetchLike } from './da-utilities/client';
19
19
  /** The first line of every ownership message. */
20
20
  export declare const WALLET_OWNERSHIP_TITLE = "Canton wallet ownership proof";
21
21
  /** The message format version, its `Version:` line. */
@@ -47,7 +47,7 @@ export interface WalletOwnershipProof {
47
47
  readonly namespace?: string;
48
48
  /** The exact text the wallet signed. */
49
49
  readonly message: string;
50
- /** The signature as the wallet returned it (Loop: hex; the CIP-0103 reference wallet: base64). */
50
+ /** The signature as the wallet returned it (hex or base64). */
51
51
  readonly signature: string;
52
52
  }
53
53
  /** Whether `value` may be a message's domain: a host name, optionally with a port. */
@@ -68,19 +68,16 @@ export declare function parseWalletOwnershipMessage(message: string): WalletOwne
68
68
  export interface ProveWalletOwnershipOptions {
69
69
  /** The challenge the dApp's server issued. */
70
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
71
  /** Defaults to the system clock; an expired challenge is refused before anything is signed. */
77
72
  readonly now?: () => Date;
78
73
  }
79
74
  /**
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`).
75
+ * Ask the wallet to sign the ownership message for the challenge, as the connection's party. CIP-0103 wallets sign with
76
+ * the primary account, so another primary account, or a wallet or challenge on the other DA network, is refused before
77
+ * anything is signed. Returns what the server needs to verify; it is not itself proof of anything until the server
78
+ * verified it (`verifyWalletOwnership`).
82
79
  */
83
- export declare function proveWalletOwnership(provider: Cip103Provider, options: ProveWalletOwnershipOptions): Promise<WalletOwnershipProof>;
80
+ export declare function proveWalletOwnership(connection: Cip103Connection, options: ProveWalletOwnershipOptions): Promise<WalletOwnershipProof>;
84
81
  /** Why a proof did not verify (`verifyWalletOwnership`, Node only). */
85
82
  export type WalletOwnershipFailure =
86
83
  /** The proof is not an object of string fields. */
@@ -135,11 +132,8 @@ export type WalletOwnershipVerdict = {
135
132
  readonly message: string;
136
133
  };
137
134
  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;
135
+ /** Sends the requests; defaults to the global `fetch` (same-origin requests carry the user's session cookie). */
136
+ readonly fetch?: FetchLike;
143
137
  /** Answers `POST { network, partyId }` with `{ data: WalletOwnershipChallengeResponse }`. */
144
138
  readonly challengeUrl: string;
145
139
  /** Answers `POST { token, proof }` with `{ data: WalletOwnershipVerdict }`. */
@@ -147,10 +141,10 @@ export interface RequestWalletOwnershipVerdictOptions {
147
141
  }
148
142
  /**
149
143
  * 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`).
144
+ * 2xx answer is `{ data }`, any other `{ error: string }`): POST `challengeUrl` with the connection's `{ network,
145
+ * partyId }`, have the wallet sign the challenge (`proveWalletOwnership`), POST `verifyUrl` with `{ token, proof }`,
146
+ * and return the server's verdict. Throws when no verdict was reached: the server refused (a non-2xx answer, or one
147
+ * without `data`), or the wallet did not sign (`WalletSignError`).
154
148
  */
155
- export declare function requestWalletOwnershipVerdict(provider: Cip103Provider, options: RequestWalletOwnershipVerdictOptions): Promise<WalletOwnershipVerdict>;
149
+ export declare function requestWalletOwnershipVerdict(connection: Cip103Connection, options: RequestWalletOwnershipVerdictOptions): Promise<WalletOwnershipVerdict>;
156
150
  //# sourceMappingURL=ownership.d.ts.map
@@ -1 +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;IAC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AE,gBAAgB,EAC5B,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,sBAAsB,CAAC,CAqBjC"}
@@ -14,16 +14,17 @@ exports.requestWalletOwnershipVerdict = requestWalletOwnershipVerdict;
14
14
  * can call this code with a made-up provider, so only the server's verification counts.
15
15
  *
16
16
  * The message is plain text with a fixed first line and a statement that it is not a transaction, so a dApp cannot use
17
- * it to get a transaction hash (34 binary bytes) signed. Wallets sign the raw message bytes with the party's key (Loop:
18
- * Ed25519 over the UTF-8 bytes; the CIP-0103 reference wallet: the same), so the text form is the only protection. The
19
- * nonce must come from the server, be random, and be accepted once.
17
+ * it to get a transaction hash (34 binary bytes) signed. Wallets sign the raw message bytes with the party's key
18
+ * (Ed25519 over the UTF-8 bytes), so the text form is the only protection. The nonce must come from the server, be
19
+ * random, and be accepted once.
20
20
  *
21
21
  * 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
22
22
  * verified proof says nothing about the party existing or being hosted on that network. `proveWalletOwnership` refuses
23
- * a wallet that reports another network as a guard against mistakes; a server that needs the network proven must look
24
- * the party up on that network (its Scan or ledger party and topology APIs).
23
+ * a wallet that reports the other DA network (the session's rule) as a guard against mistakes; a server that needs the
24
+ * network proven must look the party up on that network (its Scan or ledger party and topology APIs).
25
25
  */
26
26
  const cip103_1 = require("./cip103");
27
+ const client_1 = require("./da-utilities/client");
27
28
  const errors_1 = require("./errors");
28
29
  const json_1 = require("./json");
29
30
  /** The first line of every ownership message. */
@@ -143,29 +144,33 @@ function parseWalletOwnershipMessage(message) {
143
144
  return null;
144
145
  return buildWalletOwnershipMessage(fields) === message ? fields : null;
145
146
  }
146
- /** The signature from a `signMessage` result: `{signature}` (CIP-0103) or a bare string (some wallets). */
147
+ /** The signature from a `signMessage` result (CIP-0103's `{ signature }`). */
147
148
  function readSignature(raw) {
148
- if (typeof raw === 'string')
149
- return (0, json_1.nonEmptyString)(raw);
150
149
  return (0, json_1.isRecord)(raw) ? (0, json_1.nonEmptyString)(raw['signature']) : undefined;
151
150
  }
152
151
  /**
153
- * Ask the wallet to sign the ownership message for the challenge, as its primary account. Returns what the server needs
154
- * to verify; it is not itself proof of anything until the server verified it (`verifyWalletOwnership`).
152
+ * Ask the wallet to sign the ownership message for the challenge, as the connection's party. CIP-0103 wallets sign with
153
+ * the primary account, so another primary account, or a wallet or challenge on the other DA network, is refused before
154
+ * anything is signed. Returns what the server needs to verify; it is not itself proof of anything until the server
155
+ * verified it (`verifyWalletOwnership`).
155
156
  */
156
- async function proveWalletOwnership(provider, options) {
157
+ async function proveWalletOwnership(connection, options) {
158
+ const { provider, partyId, network } = connection;
159
+ const { challenge } = options;
157
160
  const account = await (0, cip103_1.primaryAccount)(provider);
158
- if (options.partyId !== undefined && options.partyId !== account.partyId) {
159
- throw new errors_1.WalletSignError('invalid-challenge', `The wallet's primary account is ${account.partyId}, not ${options.partyId}; switch accounts in the wallet first`);
161
+ if (account.partyId !== partyId) {
162
+ throw new errors_1.WalletSignError('invalid-challenge', `The wallet's primary account is ${account.partyId}, not ${partyId}; switch accounts in the wallet first`);
163
+ }
164
+ // A guard against signing for the wrong network, not proof: the wallet reports its network itself.
165
+ if (account.networkId !== undefined && (0, cip103_1.reportsOtherNetwork)(account.networkId, network)) {
166
+ throw new errors_1.WalletSignError('invalid-challenge', `The wallet is on ${account.networkId}, not ${(0, cip103_1.cip103NetworkId)(network)}; switch networks in the wallet first`);
167
+ }
168
+ if (challenge.network !== undefined && (0, cip103_1.reportsOtherNetwork)(challenge.network, network)) {
169
+ throw new errors_1.WalletSignError('invalid-challenge', `The challenge is for ${challenge.network}, not ${(0, cip103_1.cip103NetworkId)(network)}`);
160
170
  }
161
171
  if (account.publicKey === undefined) {
162
172
  throw new errors_1.WalletReadError('The wallet returned a primary account without publicKey, so ownership cannot be proven');
163
173
  }
164
- const { challenge } = options;
165
- // A guard against signing for the wrong network, not proof: the wallet reports its network itself.
166
- if (challenge.network !== undefined && account.networkId !== undefined && account.networkId !== challenge.network) {
167
- throw new errors_1.WalletSignError('invalid-challenge', `The wallet is on ${account.networkId}, not ${challenge.network}; switch networks in the wallet first`);
168
- }
169
174
  let message;
170
175
  try {
171
176
  message = buildWalletOwnershipMessage({
@@ -243,14 +248,15 @@ async function postForData(fetch, url, body) {
243
248
  }
244
249
  /**
245
250
  * The browser half of an ownership check, against a server that uses the SDK's challenger (or the same wire format: a
246
- * 2xx answer is `{ data }`, any other `{ error: string }`): POST `challengeUrl` with `{ network, partyId }`, have the
247
- * wallet sign the challenge (`proveWalletOwnership`), POST `verifyUrl` with `{ token, proof }`, and return the server's
248
- * verdict. Throws when no verdict was reached: the server refused (a non-2xx answer, or one without `data`), or the
249
- * wallet did not sign (`WalletSignError`).
251
+ * 2xx answer is `{ data }`, any other `{ error: string }`): POST `challengeUrl` with the connection's `{ network,
252
+ * partyId }`, have the wallet sign the challenge (`proveWalletOwnership`), POST `verifyUrl` with `{ token, proof }`,
253
+ * and return the server's verdict. Throws when no verdict was reached: the server refused (a non-2xx answer, or one
254
+ * without `data`), or the wallet did not sign (`WalletSignError`).
250
255
  */
251
- async function requestWalletOwnershipVerdict(provider, options) {
252
- const { partyId, network } = options;
253
- const issued = await postForData(options.fetch, options.challengeUrl, { network, partyId });
256
+ async function requestWalletOwnershipVerdict(connection, options) {
257
+ const { partyId, network } = connection;
258
+ const send = options.fetch ?? (0, client_1.globalFetch)('{ fetch } to requestWalletOwnershipVerdict');
259
+ const issued = await postForData(send, options.challengeUrl, { network, partyId });
254
260
  if (!(0, json_1.isRecord)(issued) || !(0, json_1.isRecord)(issued['challenge']) || typeof issued['token'] !== 'string') {
255
261
  throw new Error('The server answered the ownership challenge request without { challenge, token }');
256
262
  }
@@ -259,8 +265,8 @@ async function requestWalletOwnershipVerdict(provider, options) {
259
265
  if (challenge.network !== (0, cip103_1.cip103NetworkId)(network)) {
260
266
  throw new errors_1.WalletSignError('invalid-challenge', `The server issued a challenge for ${String(challenge.network)}, not ${(0, cip103_1.cip103NetworkId)(network)}`);
261
267
  }
262
- const proof = await proveWalletOwnership(provider, { challenge, partyId });
263
- const verdict = await postForData(options.fetch, options.verifyUrl, { token: issued['token'], proof });
268
+ const proof = await proveWalletOwnership(connection, { challenge });
269
+ const verdict = await postForData(send, options.verifyUrl, { token: issued['token'], proof });
264
270
  if (!isWalletOwnershipVerdict(verdict, partyId)) {
265
271
  throw new Error('The server answered the ownership proof without a well-formed verdict for the party');
266
272
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ownership.js","sourceRoot":"","sources":["../../../src/wallets/ownership.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,qCAOkB;AAElB,qCAA4D;AAC5D,iCAAkD;AAElD,iDAAiD;AACpC,QAAA,sBAAsB,GAAG,+BAA+B,CAAC;AACtE,uDAAuD;AAC1C,QAAA,wBAAwB,GAAG,GAAG,CAAC;AAmC5C,MAAM,cAAc,GAAG,mEAAmE,CAAC;AAC3F,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,sCAAsC;AACtC,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,WAAW,GAAG,+CAA+C,CAAC;AAEpE,sFAAsF;AACtF,iCAAwC,KAAc;IACpD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED,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;AAED,6DAA6D;AAC7D,SAAS,YAAY,CAAC,MAAoC;IACxD,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,OAAO,oDAAoD,CAAC;IA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GAAG,MAAM,oBAAoB,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACpE,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9F,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,qFAAqF,CAAC,CAAC;IACzG,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,26 +1,17 @@
1
- import { type Cip103Provider } from './cip103';
1
+ import { type Cip103Connection, type Cip103Provider } from './cip103';
2
2
  import type { DaNetwork } from './da-utilities/client';
3
3
  import { type WalletErrorDescription } from './errors';
4
4
  /** A connected wallet. Each session is one object: compare by identity to tell a live session from an ended one. */
5
- export interface ConnectedWallet {
6
- readonly provider: Cip103Provider;
7
- readonly partyId: string;
5
+ export interface ConnectedWallet extends Cip103Connection {
8
6
  /**
9
7
  * Unique per `ConnectedWallet` object within its session: use it as a UI key (React `key`), so a new session of the
10
- * same party (another provider or network) remounts what the previous one rendered.
8
+ * same party (another provider or account) remounts what the previous one rendered.
11
9
  */
12
10
  readonly key: string;
13
- /** What the dApp connected for; lets `createWalletStore` build DA's registry client itself. */
14
- readonly network?: DaNetwork;
15
11
  }
16
12
  export type Cip103SessionState = {
17
13
  readonly status: 'disconnected';
18
- /**
19
- * `user`: the dApp disconnected. `wallet`: the wallet rejected or ended the session. `null`: never connected, or
20
- * a failure (`error`).
21
- */
22
- readonly endedBy: 'user' | 'wallet' | null;
23
- /** Why the last connect, party lookup or wallet setup failed. */
14
+ /** Why the last connect, account read or wallet setup failed; null after a disconnect or before any connect. */
24
15
  readonly error: WalletErrorDescription | null;
25
16
  } | {
26
17
  readonly status: 'connecting';
@@ -28,70 +19,41 @@ export type Cip103SessionState = {
28
19
  readonly status: 'connected';
29
20
  readonly wallet: ConnectedWallet;
30
21
  };
31
- export interface Cip103ConnectContext {
22
+ export interface Cip103SessionOptions {
32
23
  /**
33
- * The network the dApp connects for, carried on the `ConnectedWallet`. A wallet whose primary account reports the
34
- * CIP-0103 `networkId` of another DA network (`canton:mainnet` when connecting for `devnet`, and the reverse) is
35
- * refused: the session stays disconnected with an error. CIP-0103 does not fix how a wallet spells its network id, so
36
- * an id the session does not recognise, or none, is accepted rather than locking every user out.
24
+ * The DA network the dApp works on, carried on every `ConnectedWallet`. A wallet whose primary account reports the
25
+ * CIP-0103 `networkId` of the other DA network is refused. CIP-0103 does not fix how a wallet spells its network id,
26
+ * so an id the session does not recognise, or none, is accepted.
37
27
  */
38
- readonly network?: DaNetwork;
28
+ readonly network: DaNetwork;
39
29
  }
40
30
  export interface Cip103Session {
31
+ readonly network: DaNetwork;
41
32
  subscribe(listener: () => void): () => void;
42
33
  /** The current state; the same object until it changes (for `useSyncExternalStore`). */
43
34
  getSnapshot(): Cip103SessionState;
44
35
  /**
45
- * The wallet reports a live session (its accept callback, or a session it restored): reads the primary account
46
- * (`getPrimaryAccount`) and connects as its party.
47
- *
48
- * - A reply that a newer call, `end()`, `fail()` or `dispose()` superseded is dropped. Of overlapping party lookups the
49
- * most recently started one decides. A `connected()` lookup supersedes older ones only once it has an answer it
50
- * acts on, so one whose failure is ignored (below) leaves a pending `connect()` or `accountsChanged` lookup to
51
- * decide.
52
- * - The same provider, party and network keep the same `ConnectedWallet` object, so a repeated callback changes
53
- * nothing.
54
- * - Ignored after `end()` until `connect()` runs again (wallets can repeat a connect callback after a disconnect).
55
- * - With `ifConnected: true` it first asks CIP-0103 `isConnected` and does nothing unless the wallet answers `{
56
- * isConnected: true }` (4200, any other failure or another answer count as not connected). Of overlapping restores,
57
- * the most recently started one decides, whichever answers first: an older one is dropped, also once its party
58
- * lookup has started (a newer restore that finds no session drops it, so it cannot connect after it). A restore is
59
- * also dropped when anything else started a party lookup or changed the session while it waited. While it waits it
60
- * supersedes nothing: only an `isConnected: true` answer starts its lookup, which then supersedes older ones, so a
61
- * restore that finds no session never cancels a pending `connect()` or `accountsChanged` lookup.
62
- * - A failed account read, or an account on the other DA network, leaves the session disconnected with `error`;
63
- * `connect()` recovers from it. While a wallet is connected, such a failure is ignored instead: a stale callback,
64
- * or another wallet that cannot be read, never drops a healthy session. The exception is the connected wallet's own
65
- * provider answering with an account on the other DA network: the wallet switched networks, so the session ends
66
- * with `error`. While a `connect()` is pending (`connecting`), every such failure is ignored: that `connect()`
67
- * reads the account itself and reports the outcome.
36
+ * The user asked to connect: signs out any other wallet the session is on (CIP-0103 `disconnect`, best-effort), sets
37
+ * `connecting`, waits for a disconnect of this wallet still in flight, sends CIP-0103 `connect` (the wallet's own
38
+ * sign-in), then reads the primary account (`getPrimaryAccount`). A failure becomes `error` (4001: declined).
39
+ * Resolves when it settled; superseded by a newer `connect()`, `disconnect()`, `fail()` or `dispose()`.
68
40
  */
69
- connected(provider: Cip103Provider, context?: Cip103ConnectContext & {
70
- readonly ifConnected?: boolean;
71
- }): Promise<void>;
41
+ connect(provider: Cip103Provider): Promise<void>;
72
42
  /**
73
- * The user asked to connect: sends CIP-0103 `disconnect` (best-effort) to any other wallet the session is on (a
74
- * wallet switch), sets `connecting`, waits for a disconnect of this wallet still in flight, then re-arms
75
- * `connected()` and sends CIP-0103 `connect` (the wallet's own sign-in); wallet callbacks before that are ignored. It
76
- * then always reads the primary account again, also when the wallet answers that it was already connected, so a
77
- * failed or lost party lookup recovers without a reload. A failure becomes `error` (4001: declined). Resolves when it
78
- * settled; superseded by a newer `connect()`, `end()`, `fail()` or `dispose()`.
43
+ * On page load: when the session is disconnected and the wallet answers CIP-0103 `isConnected` with `{ isConnected:
44
+ * true }`, reads the primary account and connects silently. It never publishes an error: any failure (4200 included)
45
+ * leaves the session as it was. Ignored while connecting or connected, and for a wallet the user signed out of
46
+ * (`disconnect()`, or a switch to another wallet) until `connect()` signs in to it again, also when the wallet still
47
+ * reports a session; dropped when anything else changed the session meanwhile, or a newer `restore()` started.
79
48
  */
80
- connect(provider: Cip103Provider, context?: Cip103ConnectContext): Promise<void>;
49
+ restore(provider: Cip103Provider): Promise<void>;
81
50
  /**
82
- * The session ended. `user`: the dApp disconnected, and CIP-0103 `disconnect` is sent best-effort to the providers
83
- * the session is on (the connected wallet's, and the one a pending `connect()` signs in to; failures are ignored),
84
- * before the new state is published. A `connect()` to such a provider waits for its disconnects to settle before it
85
- * sends `connect`, so a disconnect cannot land after the new sign-in, also a `connect()` that sending the disconnect
86
- * sets off (then that `connect()` owns the state, and `end()` publishes nothing). It waits for each disconnect at
87
- * most until three seconds after that disconnect was sent, also when a later disconnect of the same wallet is chained
88
- * to it, so a disconnect that never answers delays no `connect()` past three seconds after it was sent, however many
89
- * `connect()` and `end('user')` calls follow it. A nested `end()` or `fail()` that sending the disconnect sets off
90
- * does not take the state over: `end('user')` still publishes `endedBy: 'user'`. `wallet`: the wallet rejected or
91
- * ended the session; nothing is sent. Either way `connected()` is ignored until `connect()` runs again.
51
+ * The user disconnected: sends CIP-0103 `disconnect` (best-effort) to the wallets the session is on (the connected
52
+ * one, and the one a pending `connect()` signs in to), then publishes `disconnected`. A later `connect()` to such a
53
+ * wallet waits for its disconnect, at most three seconds after it was sent, so it cannot land after the new sign-in.
92
54
  */
93
- end(by: 'user' | 'wallet'): void;
94
- /** The wallet's own setup failed (e.g. Loop's `init`): disconnected with `error`. */
55
+ disconnect(): void;
56
+ /** The wallet's own setup failed: disconnected with `error`. */
95
57
  fail(error: unknown): void;
96
58
  /** Whether `wallet` is still this session's connected wallet. */
97
59
  isCurrent(wallet: ConnectedWallet): boolean;
@@ -99,9 +61,9 @@ export interface Cip103Session {
99
61
  dispose(): void;
100
62
  }
101
63
  /**
102
- * A CIP-0103 wallet session. While connected it listens on the provider: `accountsChanged` reads the primary account
103
- * again (another party becomes a new `ConnectedWallet`), and a `statusChanged` whose `connection.isConnected` is false
104
- * ends the session (`wallet`). A wallet that never emits these events loses nothing.
64
+ * A CIP-0103 wallet session on `options.network`. While connected it listens on the provider: `accountsChanged` reads
65
+ * the primary account again (another party becomes a new `ConnectedWallet`), and a `statusChanged` whose
66
+ * `connection.isConnected` is false (the wallet ended the session) leaves it disconnected without an error.
105
67
  */
106
- export declare function createCip103Session(): Cip103Session;
68
+ export declare function createCip103Session(options: Cip103SessionOptions): Cip103Session;
107
69
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/wallets/session.ts"],"names":[],"mappings":"AAQA,OAAO,EAOL,KAAK,cAAc,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAwC,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAG7F,oHAAoH;AACpH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;CAC9B;AAED,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IAC3C,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC/C,GACD;IAAE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;CAAE,GACjC;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC;AAEvE,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,QAAQ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