@fairmint/canton-node-sdk 0.0.300 → 0.0.301

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 (98) hide show
  1. package/README.md +108 -22
  2. package/build/src/clients/ledger-json-api/operations/v2/parties/external/generate-topology.d.ts +8 -6
  3. package/build/src/clients/ledger-json-api/operations/v2/parties/external/generate-topology.d.ts.map +1 -1
  4. package/build/src/clients/ledger-json-api/operations/v2/parties/external/generate-topology.js +8 -6
  5. package/build/src/clients/ledger-json-api/operations/v2/parties/external/generate-topology.js.map +1 -1
  6. package/build/src/external-parties/directory.d.ts +22 -10
  7. package/build/src/external-parties/directory.d.ts.map +1 -1
  8. package/build/src/external-parties/directory.js +42 -27
  9. package/build/src/external-parties/directory.js.map +1 -1
  10. package/build/src/external-parties/index.d.ts +9 -16
  11. package/build/src/external-parties/index.d.ts.map +1 -1
  12. package/build/src/external-parties/index.js +9 -35
  13. package/build/src/external-parties/index.js.map +1 -1
  14. package/build/src/utils/amulet/external-party-cc-token-standard-transfer.d.ts +1 -1
  15. package/build/src/utils/amulet/external-party-cc-token-standard-transfer.d.ts.map +1 -1
  16. package/build/src/utils/amulet/external-party-cc-token-standard-transfer.js +16 -5
  17. package/build/src/utils/amulet/external-party-cc-token-standard-transfer.js.map +1 -1
  18. package/build/src/utils/amulet/external-party-transfer-offer.d.ts +5 -3
  19. package/build/src/utils/amulet/external-party-transfer-offer.d.ts.map +1 -1
  20. package/build/src/utils/amulet/external-party-transfer-offer.js +21 -7
  21. package/build/src/utils/amulet/external-party-transfer-offer.js.map +1 -1
  22. package/build/src/utils/amulet/external-party-transfer-preapproval.d.ts +8 -1
  23. package/build/src/utils/amulet/external-party-transfer-preapproval.d.ts.map +1 -1
  24. package/build/src/utils/amulet/external-party-transfer-preapproval.js +30 -7
  25. package/build/src/utils/amulet/external-party-transfer-preapproval.js.map +1 -1
  26. package/build/src/utils/amulet/index.d.ts +0 -1
  27. package/build/src/utils/amulet/index.d.ts.map +1 -1
  28. package/build/src/utils/amulet/index.js +0 -1
  29. package/build/src/utils/amulet/index.js.map +1 -1
  30. package/build/src/utils/external-signing/canton-ed25519-signer.d.ts +7 -1
  31. package/build/src/utils/external-signing/canton-ed25519-signer.d.ts.map +1 -1
  32. package/build/src/utils/external-signing/canton-ed25519-signer.js +15 -7
  33. package/build/src/utils/external-signing/canton-ed25519-signer.js.map +1 -1
  34. package/build/src/utils/external-signing/canton-protocol.d.ts +5 -37
  35. package/build/src/utils/external-signing/canton-protocol.d.ts.map +1 -1
  36. package/build/src/utils/external-signing/canton-protocol.js +10 -217
  37. package/build/src/utils/external-signing/canton-protocol.js.map +1 -1
  38. package/build/src/utils/external-signing/create-external-party.d.ts +27 -6
  39. package/build/src/utils/external-signing/create-external-party.d.ts.map +1 -1
  40. package/build/src/utils/external-signing/create-external-party.js +39 -11
  41. package/build/src/utils/external-signing/create-external-party.js.map +1 -1
  42. package/build/src/utils/external-signing/execute-external-party-signed-transaction.d.ts +7 -3
  43. package/build/src/utils/external-signing/execute-external-party-signed-transaction.d.ts.map +1 -1
  44. package/build/src/utils/external-signing/execute-external-party-signed-transaction.js +17 -7
  45. package/build/src/utils/external-signing/execute-external-party-signed-transaction.js.map +1 -1
  46. package/build/src/utils/external-signing/external-party-lifecycle.js +2 -2
  47. package/build/src/utils/external-signing/external-party-lifecycle.js.map +1 -1
  48. package/build/src/utils/external-signing/external-party-onboarding.d.ts +56 -14
  49. package/build/src/utils/external-signing/external-party-onboarding.d.ts.map +1 -1
  50. package/build/src/utils/external-signing/external-party-onboarding.js +71 -26
  51. package/build/src/utils/external-signing/external-party-onboarding.js.map +1 -1
  52. package/build/src/utils/external-signing/external-party-wallet.d.ts +23 -6
  53. package/build/src/utils/external-signing/external-party-wallet.d.ts.map +1 -1
  54. package/build/src/utils/external-signing/external-party-wallet.js +52 -18
  55. package/build/src/utils/external-signing/external-party-wallet.js.map +1 -1
  56. package/build/src/utils/external-signing/external-signing-client.d.ts.map +1 -1
  57. package/build/src/utils/external-signing/external-signing-client.js +17 -16
  58. package/build/src/utils/external-signing/external-signing-client.js.map +1 -1
  59. package/build/src/utils/external-signing/hash-signature.d.ts +20 -0
  60. package/build/src/utils/external-signing/hash-signature.d.ts.map +1 -0
  61. package/build/src/utils/external-signing/hash-signature.js +63 -0
  62. package/build/src/utils/external-signing/hash-signature.js.map +1 -0
  63. package/build/src/utils/external-signing/onboarding-topology.d.ts +82 -0
  64. package/build/src/utils/external-signing/onboarding-topology.d.ts.map +1 -0
  65. package/build/src/utils/external-signing/onboarding-topology.js +213 -0
  66. package/build/src/utils/external-signing/onboarding-topology.js.map +1 -0
  67. package/build/src/utils/external-signing/party-identity.d.ts +43 -0
  68. package/build/src/utils/external-signing/party-identity.d.ts.map +1 -0
  69. package/build/src/utils/external-signing/party-identity.js +120 -0
  70. package/build/src/utils/external-signing/party-identity.js.map +1 -0
  71. package/build/src/utils/external-signing/prepared-transaction.d.ts +58 -0
  72. package/build/src/utils/external-signing/prepared-transaction.d.ts.map +1 -0
  73. package/build/src/utils/external-signing/prepared-transaction.js +158 -0
  74. package/build/src/utils/external-signing/prepared-transaction.js.map +1 -0
  75. package/build/src/utils/external-signing/wallet-ownership-checks.d.ts.map +1 -1
  76. package/build/src/utils/external-signing/wallet-ownership-checks.js +8 -5
  77. package/build/src/utils/external-signing/wallet-ownership-checks.js.map +1 -1
  78. package/package.json +5 -3
  79. package/build/src/external-parties/discovery.d.ts +0 -72
  80. package/build/src/external-parties/discovery.d.ts.map +0 -1
  81. package/build/src/external-parties/discovery.js +0 -160
  82. package/build/src/external-parties/discovery.js.map +0 -1
  83. package/build/src/external-parties/errors.d.ts +0 -28
  84. package/build/src/external-parties/errors.d.ts.map +0 -1
  85. package/build/src/external-parties/errors.js +0 -33
  86. package/build/src/external-parties/errors.js.map +0 -1
  87. package/build/src/external-parties/hints.d.ts +0 -42
  88. package/build/src/external-parties/hints.d.ts.map +0 -1
  89. package/build/src/external-parties/hints.js +0 -83
  90. package/build/src/external-parties/hints.js.map +0 -1
  91. package/build/src/external-parties/keys.d.ts +0 -34
  92. package/build/src/external-parties/keys.d.ts.map +0 -1
  93. package/build/src/external-parties/keys.js +0 -209
  94. package/build/src/external-parties/keys.js.map +0 -1
  95. package/build/src/utils/amulet/external-party-cc-transfer.d.ts +0 -67
  96. package/build/src/utils/amulet/external-party-cc-transfer.d.ts.map +0 -1
  97. package/build/src/utils/amulet/external-party-cc-transfer.js +0 -148
  98. package/build/src/utils/amulet/external-party-cc-transfer.js.map +0 -1
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyParticipantPreparedTransaction = verifyParticipantPreparedTransaction;
4
+ exports.assertSubmittedPreparedTransaction = assertSubmittedPreparedTransaction;
5
+ /**
6
+ * Node-sdk's check of a prepared transaction before an external party's key signs its hash, and again before a signed
7
+ * one is submitted. Internal: not exported from the package.
8
+ *
9
+ * A participant (or a validator, on the participant's behalf) answers a prepare request with the prepared transaction
10
+ * and its hash. Node-sdk never hands a signer the participant's word for that hash: `@fairmint/canton-protocol/
11
+ * transaction` recomputes the hash from the transaction bytes under the hashing scheme node-sdk asked for, compares it
12
+ * with the participant's, and checks that the transaction's own metadata acts as the requested parties, under the
13
+ * requested command id, on the requested synchronizer. Only the recomputed hash is returned to be signed.
14
+ *
15
+ * Where node-sdk did not choose the command id or the synchronizer (a validator prepares the transfer-preapproval
16
+ * setup, and a caller submits a transaction it prepared elsewhere), they are read from the transaction itself, so the
17
+ * check still recomputes the hash and checks the acting parties exactly.
18
+ */
19
+ const core_ledger_proto_1 = require("@canton-network/core-ledger-proto");
20
+ const transaction_1 = require("@fairmint/canton-protocol/transaction");
21
+ const errors_1 = require("../../core/errors");
22
+ const party_identity_1 = require("./party-identity");
23
+ const PREPARED_HASH_HEX_PATTERN = /^[0-9a-fA-F]{64}$/;
24
+ /**
25
+ * Stands in for a command id or synchronizer the transaction does not state (or that cannot be read): it never equals a
26
+ * transaction's own value, so canton-protocol still recomputes the hash first and then refuses the metadata.
27
+ */
28
+ const UNSTATED = '(not stated by the prepared transaction)';
29
+ /**
30
+ * Verifies a participant's prepared transaction and resolves its recomputed hash. A refusal of the participant's answer
31
+ * (another scheme, no transaction, a hash that is not the transaction's, a transaction that cannot be hashed or that
32
+ * does not state what was asked) is an {@link OperationError} (`TRANSACTION_FAILED`) with canton-protocol's refusal as
33
+ * `cause` and its `code` and `field` in the context; an invalid expectation (caller input) is a {@link ValidationError}.
34
+ * Nothing may be signed when it rejects.
35
+ */
36
+ async function verifyParticipantPreparedTransaction(input) {
37
+ if ('answeredHashingScheme' in input && input.answeredHashingScheme !== input.hashingScheme) {
38
+ throw new errors_1.OperationError(`Canton ${input.operation} response is prepared under another hashing scheme than requested`, errors_1.OperationErrorCode.TRANSACTION_FAILED, { requestedHashingScheme: input.hashingScheme, answeredHashingScheme: String(input.answeredHashingScheme) });
39
+ }
40
+ if (typeof input.preparedTransaction !== 'string' || input.preparedTransaction.trim() === '') {
41
+ throw new errors_1.OperationError(`Canton ${input.operation} response did not include a prepared transaction`, errors_1.OperationErrorCode.TRANSACTION_FAILED);
42
+ }
43
+ if (typeof input.preparedTransactionHash !== 'string') {
44
+ throw new errors_1.OperationError(`Canton ${input.operation} response did not include a valid prepared hash`, errors_1.OperationErrorCode.TRANSACTION_FAILED);
45
+ }
46
+ const { preparedTransaction } = input;
47
+ try {
48
+ const verified = await (0, transaction_1.verifyPreparedTransaction)({
49
+ preparedTransaction,
50
+ hashingScheme: input.hashingScheme,
51
+ hash: input.preparedTransactionHash,
52
+ expected: expectedSubject(preparedTransaction, input.expected),
53
+ });
54
+ return {
55
+ preparedTransaction,
56
+ preparedTransactionHashHex: verified.hash,
57
+ hashingSchemeVersion: input.hashingScheme,
58
+ };
59
+ }
60
+ catch (error) {
61
+ if (!(0, transaction_1.isCantonProtocolError)(error) || error.code === 'UNSUPPORTED')
62
+ throw error;
63
+ if (error.code === 'INVALID_INPUT' && error.field?.startsWith('expected') === true) {
64
+ throw (0, party_identity_1.callerInputError)(error);
65
+ }
66
+ throw withCause(new errors_1.OperationError(participantRefusalMessage(input.operation, error), errors_1.OperationErrorCode.TRANSACTION_FAILED, {
67
+ ...refusalContext(error),
68
+ }), error);
69
+ }
70
+ }
71
+ /**
72
+ * Checks, before a signed prepared transaction is submitted, that the signed hash is the hash of the transaction bytes
73
+ * under the scheme it is executed with, and that the transaction states what is expected. Every refusal is a
74
+ * {@link ValidationError} (caller input) with canton-protocol's refusal as `cause` where it made it; nothing may be
75
+ * submitted when it rejects.
76
+ */
77
+ async function assertSubmittedPreparedTransaction(input) {
78
+ if (typeof input.preparedTransactionHashHex !== 'string' ||
79
+ !PREPARED_HASH_HEX_PATTERN.test(input.preparedTransactionHashHex.trim())) {
80
+ throw new errors_1.ValidationError('preparedTransactionHashHex must be a 32-byte prepared-transaction hash, hex', {
81
+ preparedTransactionHashHex: input.preparedTransactionHashHex,
82
+ });
83
+ }
84
+ if (typeof input.preparedTransaction !== 'string' || input.preparedTransaction.trim() === '') {
85
+ throw new errors_1.ValidationError('preparedTransaction is required');
86
+ }
87
+ try {
88
+ await (0, transaction_1.verifyPreparedTransaction)({
89
+ preparedTransaction: input.preparedTransaction,
90
+ hashingScheme: input.hashingScheme,
91
+ hash: input.preparedTransactionHashHex,
92
+ expected: expectedSubject(input.preparedTransaction, input.expected),
93
+ });
94
+ }
95
+ catch (error) {
96
+ if (!(0, transaction_1.isCantonProtocolError)(error) || error.code === 'UNSUPPORTED')
97
+ throw error;
98
+ if (error.code === 'INVALID_INPUT')
99
+ throw (0, party_identity_1.callerInputError)(error);
100
+ throw withCause(new errors_1.ValidationError(submittedRefusalMessage(error), refusalContext(error)), error);
101
+ }
102
+ }
103
+ /** The expectation with any omitted command id or synchronizer read from the transaction itself. */
104
+ function expectedSubject(preparedTransaction, expected) {
105
+ if (expected.commandId !== undefined && expected.synchronizerId !== undefined) {
106
+ return { actAs: expected.actAs, commandId: expected.commandId, synchronizerId: expected.synchronizerId };
107
+ }
108
+ const stated = readStatedMetadata(preparedTransaction);
109
+ return {
110
+ actAs: expected.actAs,
111
+ commandId: expected.commandId ?? (stated.commandId || UNSTATED),
112
+ synchronizerId: expected.synchronizerId ?? (stated.synchronizerId || UNSTATED),
113
+ };
114
+ }
115
+ /**
116
+ * The command id and synchronizer the transaction states, or empty strings when its bytes cannot be read (canton-
117
+ * protocol then refuses the transaction itself: it hashes the same bytes, strictly, before comparing any metadata).
118
+ */
119
+ function readStatedMetadata(preparedTransaction) {
120
+ try {
121
+ const { metadata } = core_ledger_proto_1.PreparedTransaction.fromBinary(Buffer.from(preparedTransaction, 'base64'));
122
+ return {
123
+ commandId: metadata?.submitterInfo?.commandId ?? '',
124
+ synchronizerId: metadata?.synchronizerId ?? '',
125
+ };
126
+ }
127
+ catch {
128
+ return { commandId: '', synchronizerId: '' };
129
+ }
130
+ }
131
+ function participantRefusalMessage(operation, error) {
132
+ if (error.code === 'HASH_MISMATCH') {
133
+ return `Canton ${operation} response hash is not the hash of its prepared transaction`;
134
+ }
135
+ if (error.code === 'UNEXPECTED') {
136
+ return `Canton ${operation} response prepared transaction does not state the requested ${error.field ?? 'details'}`;
137
+ }
138
+ if (error.code === 'UNDECODABLE')
139
+ return `Canton ${operation} response prepared transaction cannot be hashed`;
140
+ return error.field === 'hash'
141
+ ? `Canton ${operation} response did not include a valid prepared hash`
142
+ : `Canton ${operation} response did not include a valid prepared transaction`;
143
+ }
144
+ function submittedRefusalMessage(error) {
145
+ if (error.code === 'HASH_MISMATCH')
146
+ return 'preparedTransactionHashHex is not the hash of preparedTransaction';
147
+ if (error.code === 'UNEXPECTED')
148
+ return `preparedTransaction does not state the expected ${error.field ?? 'details'}`;
149
+ return 'preparedTransaction cannot be decoded and hashed';
150
+ }
151
+ function refusalContext(error) {
152
+ return { code: error.code, ...(error.field === undefined ? {} : { field: error.field }) };
153
+ }
154
+ function withCause(wrapper, cause) {
155
+ Object.defineProperty(wrapper, 'cause', { value: cause, enumerable: false, writable: true });
156
+ return wrapper;
157
+ }
158
+ //# sourceMappingURL=prepared-transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepared-transaction.js","sourceRoot":"","sources":["../../../../src/utils/external-signing/prepared-transaction.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;GAaG;AACH,yEAAwE;AACxE,uEAK+C;AAC/C,8CAAwF;AACxF,qDAAoD;AA+CpD,MAAM,yBAAyB,GAAG,mBAAmB,CAAC;AACtD;;;GAGG;AACH,MAAM,QAAQ,GAAG,0CAA0C,CAAC;AAE5D;;;;;;GAMG;AACI,KAAK,+CACV,KAAqC;IAErC,IAAI,uBAAuB,IAAI,KAAK,IAAI,KAAK,CAAC,qBAAqB,KAAK,KAAK,CAAC,aAAa,EAAE,CAAC;QAC5F,MAAM,IAAI,uBAAc,CACtB,UAAU,KAAK,CAAC,SAAS,mEAAmE,EAC5F,2BAAkB,CAAC,kBAAkB,EACrC,EAAE,sBAAsB,EAAE,KAAK,CAAC,aAAa,EAAE,qBAAqB,EAAE,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAC5G,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,KAAK,CAAC,mBAAmB,KAAK,QAAQ,IAAI,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7F,MAAM,IAAI,uBAAc,CACtB,UAAU,KAAK,CAAC,SAAS,kDAAkD,EAC3E,2BAAkB,CAAC,kBAAkB,CACtC,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,KAAK,CAAC,uBAAuB,KAAK,QAAQ,EAAE,CAAC;QACtD,MAAM,IAAI,uBAAc,CACtB,UAAU,KAAK,CAAC,SAAS,iDAAiD,EAC1E,2BAAkB,CAAC,kBAAkB,CACtC,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,mBAAmB,EAAE,GAAG,KAAK,CAAC;IACtC,IAAI,CAAC;QACH,MAAM,QAAQ,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,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAItG;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,2BAA2B,GAAG,IAAI,CAUpC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,oBAAoB,GAC1B;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,2BAA2B,CAqChE;AAED,6CAA6C;AAC7C,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD"}
1
+ {"version":3,"file":"wallet-ownership-checks.d.ts","sourceRoot":"","sources":["../../../../src/utils/external-signing/wallet-ownership-checks.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE5F,gEAAgE;AAChE,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,YAAY,WAAY,sBAAsB,WAAW,MAAM,KAAG,2BAI7E,CAAC;AAiBH,sHAAsH;AACtH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CAgBpF;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAItG;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,2BAA2B,GAAG,IAAI,CAUpC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,oBAAoB,GAC1B;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,2BAA2B,CAuChE;AAED,6CAA6C;AAC7C,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -10,8 +10,10 @@ exports.partyNamespace = partyNamespace;
10
10
  * Checks shared by `verifyWalletOwnership` (the text message) and `verifyWalletProof` (the wallet proof message): the
11
11
  * proof's shape, the validity window, and the key and signature. Internal: not exported from the package.
12
12
  */
13
+ const party_1 = require("@fairmint/canton-protocol/party");
13
14
  const canton_protocol_1 = require("./canton-protocol");
14
15
  const canton_ed25519_signer_1 = require("./canton-ed25519-signer");
16
+ const party_identity_1 = require("./party-identity");
15
17
  const checkFailure = (reason, message) => ({
16
18
  verified: false,
17
19
  reason,
@@ -80,16 +82,17 @@ function checkKeyAndSignature(proof) {
80
82
  let keyBase64;
81
83
  try {
82
84
  keyBase64 = publicKeyBase64(proof.publicKey);
83
- fingerprint = (0, canton_protocol_1.deriveCantonEd25519PublicKeyFingerprint)(keyBase64);
85
+ fingerprint = (0, party_1.fingerprintEd25519PublicKey)(keyBase64);
84
86
  }
85
87
  catch {
86
88
  return (0, exports.checkFailure)('unsupported-public-key', 'The public key is not an Ed25519 key in hex (raw 32 bytes) or base64 (raw 32 bytes or DER SubjectPublicKeyInfo)');
87
89
  }
88
- let partyFingerprint;
89
- try {
90
- partyFingerprint = (0, canton_protocol_1.extractPublicKeyFingerprint)(proof.partyId);
90
+ // A party id is never trimmed: a leading space would otherwise pass as part of the hint.
91
+ if ((0, party_identity_1.hasSurroundingWhitespace)(proof.partyId)) {
92
+ return (0, exports.checkFailure)('party-mismatch', 'The party id has whitespace around it');
91
93
  }
92
- catch {
94
+ const partyFingerprint = (0, party_1.readPartyNamespace)(proof.partyId);
95
+ if (partyFingerprint === null) {
93
96
  return (0, exports.checkFailure)('party-mismatch', 'The party id is not of the form hint::namespace');
94
97
  }
95
98
  if (partyFingerprint !== fingerprint) {
@@ -1 +1 @@
1
- {"version":3,"file":"wallet-ownership-checks.js","sourceRoot":"","sources":["../../../../src/utils/external-signing/wallet-ownership-checks.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;GAGG;AACH,uDAI2B;AAC3B,mEAA0E;AAUnE,MAAM,YAAY,GAAG,CAAC,MAA8B,EAAE,OAAe,EAA+B,EAAE,CAAC,CAAC;IAC7G,QAAQ,EAAE,KAAK;IACf,MAAM;IACN,OAAO;CACR,CAAC,CAAC;AAJU,QAAA,YAAY,GAAZ,YAAY,CAItB;AAEH;;;GAGG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAChG,CAAC;AAED,oGAAoG;AACpG,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;QACrC,CAAC,CAAC,IAAA,uDAA+B,EAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QAC1D,CAAC,CAAC,IAAA,uDAA+B,EAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CAAC;AAClE,CAAC;AAED,sHAAsH;AACtH,kCAAyC,KAAc;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC7D,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OA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EAAE,SAAS,EAAE,CAAC,CAAC;IAC7G,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAA,QAAA,YAAY,EAAC,eAAe,EAAE,sDAAsD,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC;AAED,6CAA6C;AAC7C,wBAA+B,OAAe;IAC5C,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC"}
1
+ {"version":3,"file":"wallet-ownership-checks.js","sourceRoot":"","sources":["../../../../src/utils/external-signing/wallet-ownership-checks.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;GAGG;AACH,2DAAkG;AAClG,uDAA2D;AAC3D,mEAA0E;AAC1E,qDAA4D;AAUrD,MAAM,YAAY,GAAG,CAAC,MAA8B,EAAE,OAAe,EAA+B,EAAE,CAAC,CAAC;IAC7G,QAAQ,EAAE,KAAK;IACf,MAAM;IACN,OAAO;CACR,CAAC,CAAC;AAJU,QAAA,YAAY,GAAZ,YAAY,CAItB;AAEH;;;GAGG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAChG,CAAC;AAED,oGAAoG;AACpG,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;QACrC,CAAC,CAAC,IAAA,uDAA+B,EAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;QAC1D,CAAC,CAAC,IAAA,uDAA+B,EAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CAAC;AAClE,CAAC;AAED,sHAAsH;AACtH,kCAAyC,KAAc;IACrD,IAA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AiB,CAAC;IACtB,IAAI,CAAC;QACH,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAA,QAAA,YAAY,EAAC,qBAAqB,EAAE,gDAAgD,CAAC,CAAC;IAC/F,CAAC;IACD,IAAI,CAAC;QACH,IAAA,wCAAsB,EAAC,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7G,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAA,QAAA,YAAY,EAAC,eAAe,EAAE,sDAAsD,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC;AAED,6CAA6C;AAC7C,wBAA+B,OAAe;IAC5C,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairmint/canton-node-sdk",
3
- "version": "0.0.300",
3
+ "version": "0.0.301",
4
4
  "description": "Canton Node SDK",
5
5
  "keywords": [
6
6
  "canton",
@@ -95,9 +95,10 @@
95
95
  "tsc7": "node node_modules/typescript-7/bin/tsc"
96
96
  },
97
97
  "dependencies": {
98
+ "@canton-network/core-ledger-proto": "1.17.0",
99
+ "@fairmint/canton-protocol": "0.1.0",
98
100
  "@hardlydifficult/rest-client": "1.0.65",
99
101
  "@hardlydifficult/websocket": "1.0.73",
100
- "@noble/hashes": "1.8.0",
101
102
  "@stellar/stellar-base": "15.0.0",
102
103
  "axios": "1.21.1",
103
104
  "dotenv": "18.0.10",
@@ -109,6 +110,7 @@
109
110
  "zod": "4.6.7"
110
111
  },
111
112
  "devDependencies": {
113
+ "@canton-network/core-tx-hashing": "1.2.0",
112
114
  "@fairmint/canton-dev-tools": "0.1.16",
113
115
  "@types/jest": "30.0.0",
114
116
  "@types/node": "26.6.6",
@@ -134,7 +136,7 @@
134
136
  "typescript-7": "npm:typescript@7.0.2"
135
137
  },
136
138
  "engines": {
137
- "node": ">=22.0.0"
139
+ "node": ">=22.12.0"
138
140
  },
139
141
  "publishConfig": {
140
142
  "access": "public"
@@ -1,72 +0,0 @@
1
- /** One of a key's parties. */
2
- export interface ExternalPartyEntry {
3
- readonly partyId: string;
4
- /** What precedes `::` in the party ID. */
5
- readonly partyHint: string;
6
- /** Whether this participant hosts the party (it can prepare and submit for it here). */
7
- readonly hostedHere: boolean;
8
- }
9
- /** A key's parties, sorted by hint, and whether the party list they came from was read to its end. */
10
- export interface ExternalPartyListing {
11
- readonly parties: readonly ExternalPartyEntry[];
12
- /**
13
- * False when the list was cut short (a page or time bound, or no list at all): a party the list and the exact lookups
14
- * did not show may still exist.
15
- */
16
- readonly complete: boolean;
17
- }
18
- /** {@link discoverExternalParties}' answer. */
19
- export interface ExternalPartyDiscovery extends ExternalPartyListing {
20
- /**
21
- * False when hints were asked for, the list was not complete and there was no `findParty` to look them up: a hint
22
- * outside `parties` may then be taken. True otherwise.
23
- */
24
- readonly hintsChecked: boolean;
25
- }
26
- /** What a party list answers: party IDs (any namespace; only the key's are kept) and whether it was read to its end. */
27
- export interface ExternalPartyListAnswer {
28
- readonly parties: ReadonlyArray<{
29
- readonly partyId: string;
30
- readonly hostedHere: boolean;
31
- }>;
32
- readonly complete: boolean;
33
- }
34
- /** What an exact party lookup answers. `hostedHere` omitted counts as hosted. */
35
- export interface ExternalPartyLookupAnswer {
36
- readonly exists: boolean;
37
- readonly hostedHere?: boolean;
38
- }
39
- /** The most hints {@link discoverExternalParties} looks up in one call. */
40
- export declare const MAX_EXTERNAL_PARTY_LOOKUP_HINTS = 16;
41
- /**
42
- * A key's parties: what `listParties` answers in the key's namespace, plus an exact `findParty` of each of `hints` the
43
- * list did not show. The lookups run even when the list says complete (a cached list can predate a party allocated
44
- * since); with a complete list a failed lookup is skipped, with an incomplete one it fails the call (`LOOKUP_FAILED`).
45
- * Either callback may be left out: without `listParties` the answer is never complete; without `findParty` the hints
46
- * are not checked (`hintsChecked: false` when the list is incomplete).
47
- *
48
- * `signal` goes to each callback and each call is raced against it, so a callback that ignores it does not hold the
49
- * call open (`ABORTED`). A callback's failure is `LIST_FAILED` or `LOOKUP_FAILED` with its error as `cause` (an
50
- * {@link ExternalPartyError} `ABORTED` or `INVALID_RESPONSE` it throws passes through as it is), and an unreadable
51
- * answer is `INVALID_RESPONSE`. Nothing is recorded or allocated.
52
- */
53
- export declare function discoverExternalParties(input: {
54
- readonly publicKeyFingerprint: string;
55
- /** Hints to look up exactly (each non-empty, trimmed, without `::`); duplicates are looked up once. */
56
- readonly hints?: readonly string[];
57
- readonly signal?: AbortSignal;
58
- readonly listParties?: (request: {
59
- readonly signal?: AbortSignal;
60
- }) => Promise<ExternalPartyListAnswer>;
61
- readonly findParty?: (request: {
62
- readonly partyId: string;
63
- readonly signal?: AbortSignal;
64
- }) => Promise<ExternalPartyLookupAnswer>;
65
- }): Promise<ExternalPartyDiscovery>;
66
- /** `parties` (party ID → hosted here) as frozen entries, sorted by hint (then party ID), in code-unit order. */
67
- export declare function sortedEntries(parties: ReadonlyMap<string, boolean>): readonly ExternalPartyEntry[];
68
- /** Awaits `start()`, unless `signal` aborts first (`ABORTED`); an already-aborted signal never starts it. */
69
- export declare function raceAbort<T>(start: () => Promise<T>, signal: AbortSignal | undefined, message: string, partyId?: string): Promise<T>;
70
- /** A string of 1 to 255 characters (a Daml-LF Party at most), trimmed, on one line: what a listing may answer. */
71
- export declare function isBoundedIdentifier(value: unknown): value is string;
72
- //# sourceMappingURL=discovery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/external-parties/discovery.ts"],"names":[],"mappings":"AAaA,8BAA8B;AAC9B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OA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B,CAAC,CAAC;IACxG,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE;QAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;KAC/B,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAC1C,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA4ElC;AAED,gHAAgH;AAChH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,kBAAkB,EAAE,CAMlG;AAED,6GAA6G;AAC7G,wBAAsB,SAAS,CAAC,CAAC,EAC/B,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACvB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,CAAC,CAAC,CAuBZ;AAED,kHAAkH;AAClH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAQnE"}
@@ -1,160 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_EXTERNAL_PARTY_LOOKUP_HINTS = void 0;
4
- exports.discoverExternalParties = discoverExternalParties;
5
- exports.sortedEntries = sortedEntries;
6
- exports.raceAbort = raceAbort;
7
- exports.isBoundedIdentifier = isBoundedIdentifier;
8
- /**
9
- * "Find every party this key controls": a key's parties from a party list, plus exact lookups of the hints the list may
10
- * not show. Pure orchestration over two callbacks, so it serves {@link createExternalPartyDirectory} and any other party
11
- * store (an app's own port, a test double) alike. Browser-safe.
12
- */
13
- const errors_1 = require("./errors");
14
- const keys_1 = require("./keys");
15
- /** The most hints {@link discoverExternalParties} looks up in one call. */
16
- exports.MAX_EXTERNAL_PARTY_LOOKUP_HINTS = 16;
17
- /**
18
- * A key's parties: what `listParties` answers in the key's namespace, plus an exact `findParty` of each of `hints` the
19
- * list did not show. The lookups run even when the list says complete (a cached list can predate a party allocated
20
- * since); with a complete list a failed lookup is skipped, with an incomplete one it fails the call (`LOOKUP_FAILED`).
21
- * Either callback may be left out: without `listParties` the answer is never complete; without `findParty` the hints
22
- * are not checked (`hintsChecked: false` when the list is incomplete).
23
- *
24
- * `signal` goes to each callback and each call is raced against it, so a callback that ignores it does not hold the
25
- * call open (`ABORTED`). A callback's failure is `LIST_FAILED` or `LOOKUP_FAILED` with its error as `cause` (an
26
- * {@link ExternalPartyError} `ABORTED` or `INVALID_RESPONSE` it throws passes through as it is), and an unreadable
27
- * answer is `INVALID_RESPONSE`. Nothing is recorded or allocated.
28
- */
29
- async function discoverExternalParties(input) {
30
- const { publicKeyFingerprint, signal, listParties, findParty } = input;
31
- if (!(0, keys_1.isCantonPublicKeyFingerprint)(publicKeyFingerprint)) {
32
- throw (0, errors_1.invalidInput)('publicKeyFingerprint must be a Canton SHA-256 multihash (1220 and 64 lowercase hex characters)');
33
- }
34
- const hints = input.hints ?? [];
35
- if (!Array.isArray(hints) ||
36
- hints.length > exports.MAX_EXTERNAL_PARTY_LOOKUP_HINTS ||
37
- !hints.every((hint) => isBoundedIdentifier(hint) && (0, keys_1.isExternalPartyHint)(hint))) {
38
- throw (0, errors_1.invalidInput)(`hints must be at most ${exports.MAX_EXTERNAL_PARTY_LOOKUP_HINTS} trimmed party hints of Daml-LF Party characters, without "::" or a trailing ":"`);
39
- }
40
- const found = new Map();
41
- let complete = false;
42
- if (listParties !== undefined) {
43
- let listed;
44
- try {
45
- listed = await raceAbort(async () => listParties(signal ? { signal } : {}), signal, 'The party listing was aborted.');
46
- }
47
- catch (error) {
48
- if ((0, errors_1.isExternalPartyError)(error, 'ABORTED', 'INVALID_RESPONSE'))
49
- throw error;
50
- throw new errors_1.ExternalPartyError('LIST_FAILED', 'The participant could not list the parties.', { cause: error });
51
- }
52
- if (!isListAnswer(listed)) {
53
- throw new errors_1.ExternalPartyError('INVALID_RESPONSE', 'The party list is invalid.');
54
- }
55
- for (const entry of listed.parties) {
56
- // Only the key's own parties, whatever the list answered.
57
- if ((0, keys_1.parseExternalPartyId)(entry.partyId)?.namespace === publicKeyFingerprint) {
58
- found.set(entry.partyId, entry.hostedHere);
59
- }
60
- }
61
- ({ complete } = listed);
62
- }
63
- const hintsChecked = !(!complete && findParty === undefined && hints.length > 0);
64
- if (findParty !== undefined) {
65
- for (const hint of new Set(hints)) {
66
- const partyId = `${hint}::${publicKeyFingerprint}`;
67
- if (found.has(partyId) || partyId.length > keys_1.MAX_EXTERNAL_PARTY_ID_LENGTH)
68
- continue;
69
- let lookup;
70
- try {
71
- lookup = await raceAbort(async () => findParty(signal ? { partyId, signal } : { partyId }), signal, 'The party lookup was aborted.', partyId);
72
- }
73
- catch (error) {
74
- // An unreadable answer fails the call however it arrives (thrown, or returned and checked below).
75
- if ((0, errors_1.isExternalPartyError)(error, 'ABORTED', 'INVALID_RESPONSE'))
76
- throw error;
77
- // With a complete list the lookups only add to it: a failed one is skipped, unless the call was aborted.
78
- if (complete && !signal?.aborted)
79
- continue;
80
- throw new errors_1.ExternalPartyError('LOOKUP_FAILED', 'The participant could not look up the party.', {
81
- cause: error,
82
- partyId,
83
- });
84
- }
85
- if (!isLookupAnswer(lookup)) {
86
- throw new errors_1.ExternalPartyError('INVALID_RESPONSE', 'The party lookup is invalid.', { partyId });
87
- }
88
- if (lookup.exists)
89
- found.set(partyId, lookup.hostedHere !== false);
90
- }
91
- }
92
- return Object.freeze({
93
- parties: sortedEntries(found),
94
- complete,
95
- hintsChecked,
96
- });
97
- }
98
- /** `parties` (party ID → hosted here) as frozen entries, sorted by hint (then party ID), in code-unit order. */
99
- function sortedEntries(parties) {
100
- const entries = [...parties].map(([partyId, hostedHere]) => Object.freeze({ partyId, partyHint: partyId.slice(0, partyId.indexOf('::')), hostedHere }));
101
- entries.sort((a, b) => compare(a.partyHint, b.partyHint) || compare(a.partyId, b.partyId));
102
- return Object.freeze(entries);
103
- }
104
- /** Awaits `start()`, unless `signal` aborts first (`ABORTED`); an already-aborted signal never starts it. */
105
- async function raceAbort(start, signal, message, partyId) {
106
- const aborted = () => new errors_1.ExternalPartyError('ABORTED', message, {
107
- cause: signal?.reason,
108
- ...(partyId === undefined ? {} : { partyId }),
109
- });
110
- if (!signal)
111
- return start();
112
- if (signal.aborted)
113
- throw aborted();
114
- const promise = start();
115
- let onAbort = () => undefined;
116
- const abortedWait = new Promise((_, reject) => {
117
- onAbort = () => reject(aborted());
118
- signal.addEventListener('abort', onAbort, { once: true });
119
- // `start()` may itself have aborted the signal, before the listener could hear it.
120
- if (signal.aborted)
121
- onAbort();
122
- });
123
- abortedWait.catch(() => undefined);
124
- promise.catch(() => undefined);
125
- try {
126
- return await Promise.race([promise, abortedWait]);
127
- }
128
- finally {
129
- signal.removeEventListener('abort', onAbort);
130
- }
131
- }
132
- /** A string of 1 to 255 characters (a Daml-LF Party at most), trimmed, on one line: what a listing may answer. */
133
- function isBoundedIdentifier(value) {
134
- return (typeof value === 'string' &&
135
- value.length > 0 &&
136
- value.length <= keys_1.MAX_EXTERNAL_PARTY_ID_LENGTH &&
137
- value.trim() === value &&
138
- !/[\r\n]/u.test(value));
139
- }
140
- function isListAnswer(value) {
141
- if (typeof value !== 'object' || value === null)
142
- return false;
143
- const { parties, complete } = value;
144
- return (typeof complete === 'boolean' &&
145
- Array.isArray(parties) &&
146
- parties.every((entry) => typeof entry === 'object' &&
147
- entry !== null &&
148
- isBoundedIdentifier(entry['partyId']) &&
149
- typeof entry['hostedHere'] === 'boolean'));
150
- }
151
- function isLookupAnswer(value) {
152
- if (typeof value !== 'object' || value === null)
153
- return false;
154
- const { exists, hostedHere } = value;
155
- return typeof exists === 'boolean' && (hostedHere === undefined || typeof hostedHere === 'boolean');
156
- }
157
- function compare(a, b) {
158
- return a < b ? -1 : a > b ? 1 : 0;
159
- }
160
- //# sourceMappingURL=discovery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.js","s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,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC;AACtG,CAAC;AAED,SAAS,OAAO,CAAC,CAAS,EAAE,CAAS;IACnC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC"}
@@ -1,28 +0,0 @@
1
- /**
2
- * The external-party module's one error type. Browser-safe: no Node or SDK dependency, and matched by a brand rather
3
- * than `instanceof`, so it is recognised across copies of this module.
4
- */
5
- /**
6
- * Why an external-party call failed:
7
- *
8
- * - `INVALID_INPUT`: a key, fingerprint, hint, option or argument the caller passed is not valid.
9
- * - `INVALID_RESPONSE`: the participant (or a `listParties` / `findParty` callback) answered something unreadable.
10
- * - `ABORTED`: the caller's `signal` aborted the call.
11
- * - `LIST_FAILED`: reading the participant's party list failed; `cause` is the ledger client's error.
12
- * - `LOOKUP_FAILED`: an exact party lookup failed; `cause` is the ledger client's error.
13
- */
14
- export type ExternalPartyErrorCode = 'INVALID_INPUT' | 'INVALID_RESPONSE' | 'ABORTED' | 'LIST_FAILED' | 'LOOKUP_FAILED';
15
- export declare class ExternalPartyError extends Error {
16
- readonly name = "ExternalPartyError";
17
- readonly code: ExternalPartyErrorCode;
18
- /** For `LOOKUP_FAILED`, and `ABORTED` or `INVALID_RESPONSE` of a lookup: the party ID that was looked up. */
19
- readonly partyId: string | undefined;
20
- constructor(code: ExternalPartyErrorCode, message: string, options?: {
21
- readonly cause?: unknown;
22
- readonly partyId?: string;
23
- });
24
- }
25
- /** Whether `error` is an {@link ExternalPartyError} (of any copy of this module), optionally with one of `codes`. */
26
- export declare function isExternalPartyError(error: unknown, ...codes: readonly ExternalPartyErrorCode[]): error is ExternalPartyError;
27
- export declare function invalidInput(message: string): ExternalPartyError;
28
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/external-parties/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAAG,kBAAkB,GAAG,SAAS,GAAG,aAAa,GAAG,eAAe,CAAC;AAIxH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAyB,IAAI,wBAAwB;IACrD,SAAgB,IAAI,EAAE,sBAAsB,CAAC;IAC7C,6GAA6G;IAC7G,SAAgB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5C,YACE,IAAI,EAAE,sBAAsB,EAC5B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,EAStE;CACF;AAED,qHAAqH;AACrH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,GAAG,KAAK,EAAE,SAAS,sBAAsB,EAAE,GAC1C,KAAK,IAAI,kBAAkB,CAG7B;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAEhE"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- /**
3
- * The external-party module's one error type. Browser-safe: no Node or SDK dependency, and matched by a brand rather
4
- * than `instanceof`, so it is recognised across copies of this module.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ExternalPartyError = void 0;
8
- exports.isExternalPartyError = isExternalPartyError;
9
- exports.invalidInput = invalidInput;
10
- const BRAND = Symbol.for('@fairmint/canton-node-sdk/ExternalPartyError');
11
- class ExternalPartyError extends Error {
12
- constructor(code, message, options = {}) {
13
- super(message);
14
- this.name = 'ExternalPartyError';
15
- this.code = code;
16
- this.partyId = options.partyId;
17
- if ('cause' in options) {
18
- Object.defineProperty(this, 'cause', { value: options.cause, enumerable: false, writable: true });
19
- }
20
- Object.defineProperty(this, BRAND, { value: true });
21
- }
22
- }
23
- exports.ExternalPartyError = ExternalPartyError;
24
- /** Whether `error` is an {@link ExternalPartyError} (of any copy of this module), optionally with one of `codes`. */
25
- function isExternalPartyError(error, ...codes) {
26
- if (typeof error !== 'object' || error === null || error[BRAND] !== true)
27
- return false;
28
- return codes.length === 0 || codes.includes(error.code);
29
- }
30
- function invalidInput(message) {
31
- return new ExternalPartyError('INVALID_INPUT', message);
32
- }
33
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/external-parties/errors.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAaH,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;AAEzE,wBAAgC,SAAQ,KAAK;IAM3C,YACE,IAA4B,EAC5B,OAAe,EACf,OAAO,GAA4D,EAAE;QAErE,KAAK,CAAC,OAAO,CAAC,CAAC;QAVQ,SAAI,GAAG,oBAAoB,CAAC;QAWnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACpG,CAAC;QACD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;CACF;;AAED,qHAAqH;AACrH,8BACE,KAAc,EACd,GAAG,KAAwC;IAE3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAAiC,CAAC,KAAK,CAAC,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACpH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAE,KAA4B,CAAC,IAAI,CAAC,CAAC;AAClF,CAAC;AAED,sBAA6B,OAAe;IAC1C,OAAO,IAAI,kBAAkB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Party hints for new external parties: a short, readable suggestion, and the check of a hint a user typed. Pure and
3
- * browser-safe. A party ID already carries its key's fingerprint, so a hint only has to be unique among that key's own
4
- * parties. The hint is public and permanent on the ledger (every counterparty, Scan and explorers see the party ID):
5
- * never a name, email or other personal data.
6
- */
7
- /** The hint {@link suggestExternalPartyHint} uses when given no base name. */
8
- export declare const DEFAULT_EXTERNAL_PARTY_HINT = "wallet";
9
- /** The longest base {@link suggestExternalPartyHint} keeps, before any `-2`, `-3`, ... suffix. */
10
- export declare const MAX_SUGGESTED_EXTERNAL_PARTY_HINT_BASE_LENGTH = 24;
11
- /** The longest new party hint {@link validateExternalPartyHint} accepts. */
12
- export declare const MAX_NEW_EXTERNAL_PARTY_HINT_LENGTH = 40;
13
- /**
14
- * Why a new party hint is refused:
15
- *
16
- * - `empty`: nothing but whitespace.
17
- * - `too-long`: more than {@link MAX_NEW_EXTERNAL_PARTY_HINT_LENGTH} characters.
18
- * - `charset`: not a letter or digit followed by letters, digits, `-` and `_`.
19
- * - `taken`: one of the key's parties already has it (use that party instead).
20
- */
21
- export type ExternalPartyHintError = 'empty' | 'too-long' | 'charset' | 'taken';
22
- /**
23
- * A short, readable party hint, unique among the key's parties: `base` reduced to lowercase letters, digits and dashes
24
- * (at most {@link MAX_SUGGESTED_EXTERNAL_PARTY_HINT_BASE_LENGTH} characters), else `fallback` reduced the same way
25
- * ({@link DEFAULT_EXTERNAL_PARTY_HINT} by default), then `-2`, `-3`, ... until it is not one of `taken` (the hints of
26
- * the key's parties). Pass an app label or a nickname the user picks as `base`.
27
- */
28
- export declare function suggestExternalPartyHint(options?: {
29
- readonly base?: string;
30
- readonly taken?: Iterable<string>;
31
- readonly fallback?: string;
32
- }): string;
33
- /**
34
- * Checks a hint the user typed for a **new** party, after trimming it: null when it is fine, else why not. `taken` is
35
- * the hints the key's parties already have.
36
- *
37
- * Only for new names: an existing party keeps its hint, which may be longer or use other characters, so check `taken`
38
- * first and use an existing party by its own hint without validating it. The rule is deliberately narrower than what
39
- * the participant accepts, so a hint is short, readable and safe in a URL.
40
- */
41
- export declare function validateExternalPartyHint(hint: string, taken?: readonly string[]): ExternalPartyHintError | null;
42
- //# sourceMappingURL=hints.d.ts.map