@fairmint/canton-node-sdk 0.0.300 → 0.0.302

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 (102) hide show
  1. package/README.md +116 -26
  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/clients/ledger-json-api/schemas/api/interactive-submission.d.ts +4 -1
  7. package/build/src/clients/ledger-json-api/schemas/api/interactive-submission.d.ts.map +1 -1
  8. package/build/src/clients/ledger-json-api/schemas/api/interactive-submission.js +1 -0
  9. package/build/src/clients/ledger-json-api/schemas/api/interactive-submission.js.map +1 -1
  10. package/build/src/external-parties/directory.d.ts +22 -10
  11. package/build/src/external-parties/directory.d.ts.map +1 -1
  12. package/build/src/external-parties/directory.js +42 -27
  13. package/build/src/external-parties/directory.js.map +1 -1
  14. package/build/src/external-parties/index.d.ts +9 -16
  15. package/build/src/external-parties/index.d.ts.map +1 -1
  16. package/build/src/external-parties/index.js +9 -35
  17. package/build/src/external-parties/index.js.map +1 -1
  18. package/build/src/utils/amulet/external-party-cc-token-standard-transfer.d.ts +1 -1
  19. package/build/src/utils/amulet/external-party-cc-token-standard-transfer.d.ts.map +1 -1
  20. package/build/src/utils/amulet/external-party-cc-token-standard-transfer.js +16 -5
  21. package/build/src/utils/amulet/external-party-cc-token-standard-transfer.js.map +1 -1
  22. package/build/src/utils/amulet/external-party-transfer-offer.d.ts +5 -3
  23. package/build/src/utils/amulet/external-party-transfer-offer.d.ts.map +1 -1
  24. package/build/src/utils/amulet/external-party-transfer-offer.js +21 -7
  25. package/build/src/utils/amulet/external-party-transfer-offer.js.map +1 -1
  26. package/build/src/utils/amulet/external-party-transfer-preapproval.d.ts +8 -1
  27. package/build/src/utils/amulet/external-party-transfer-preapproval.d.ts.map +1 -1
  28. package/build/src/utils/amulet/external-party-transfer-preapproval.js +30 -7
  29. package/build/src/utils/amulet/external-party-transfer-preapproval.js.map +1 -1
  30. package/build/src/utils/amulet/index.d.ts +0 -1
  31. package/build/src/utils/amulet/index.d.ts.map +1 -1
  32. package/build/src/utils/amulet/index.js +0 -1
  33. package/build/src/utils/amulet/index.js.map +1 -1
  34. package/build/src/utils/external-signing/canton-ed25519-signer.d.ts +7 -1
  35. package/build/src/utils/external-signing/canton-ed25519-signer.d.ts.map +1 -1
  36. package/build/src/utils/external-signing/canton-ed25519-signer.js +15 -7
  37. package/build/src/utils/external-signing/canton-ed25519-signer.js.map +1 -1
  38. package/build/src/utils/external-signing/canton-protocol.d.ts +5 -37
  39. package/build/src/utils/external-signing/canton-protocol.d.ts.map +1 -1
  40. package/build/src/utils/external-signing/canton-protocol.js +10 -217
  41. package/build/src/utils/external-signing/canton-protocol.js.map +1 -1
  42. package/build/src/utils/external-signing/create-external-party.d.ts +27 -6
  43. package/build/src/utils/external-signing/create-external-party.d.ts.map +1 -1
  44. package/build/src/utils/external-signing/create-external-party.js +39 -11
  45. package/build/src/utils/external-signing/create-external-party.js.map +1 -1
  46. package/build/src/utils/external-signing/execute-external-party-signed-transaction.d.ts +7 -3
  47. package/build/src/utils/external-signing/execute-external-party-signed-transaction.d.ts.map +1 -1
  48. package/build/src/utils/external-signing/execute-external-party-signed-transaction.js +17 -7
  49. package/build/src/utils/external-signing/execute-external-party-signed-transaction.js.map +1 -1
  50. package/build/src/utils/external-signing/external-party-lifecycle.js +2 -2
  51. package/build/src/utils/external-signing/external-party-lifecycle.js.map +1 -1
  52. package/build/src/utils/external-signing/external-party-onboarding.d.ts +56 -14
  53. package/build/src/utils/external-signing/external-party-onboarding.d.ts.map +1 -1
  54. package/build/src/utils/external-signing/external-party-onboarding.js +71 -26
  55. package/build/src/utils/external-signing/external-party-onboarding.js.map +1 -1
  56. package/build/src/utils/external-signing/external-party-wallet.d.ts +23 -6
  57. package/build/src/utils/external-signing/external-party-wallet.d.ts.map +1 -1
  58. package/build/src/utils/external-signing/external-party-wallet.js +52 -18
  59. package/build/src/utils/external-signing/external-party-wallet.js.map +1 -1
  60. package/build/src/utils/external-signing/external-signing-client.d.ts.map +1 -1
  61. package/build/src/utils/external-signing/external-signing-client.js +17 -16
  62. package/build/src/utils/external-signing/external-signing-client.js.map +1 -1
  63. package/build/src/utils/external-signing/hash-signature.d.ts +20 -0
  64. package/build/src/utils/external-signing/hash-signature.d.ts.map +1 -0
  65. package/build/src/utils/external-signing/hash-signature.js +63 -0
  66. package/build/src/utils/external-signing/hash-signature.js.map +1 -0
  67. package/build/src/utils/external-signing/onboarding-topology.d.ts +82 -0
  68. package/build/src/utils/external-signing/onboarding-topology.d.ts.map +1 -0
  69. package/build/src/utils/external-signing/onboarding-topology.js +213 -0
  70. package/build/src/utils/external-signing/onboarding-topology.js.map +1 -0
  71. package/build/src/utils/external-signing/party-identity.d.ts +43 -0
  72. package/build/src/utils/external-signing/party-identity.d.ts.map +1 -0
  73. package/build/src/utils/external-signing/party-identity.js +120 -0
  74. package/build/src/utils/external-signing/party-identity.js.map +1 -0
  75. package/build/src/utils/external-signing/prepared-transaction.d.ts +58 -0
  76. package/build/src/utils/external-signing/prepared-transaction.d.ts.map +1 -0
  77. package/build/src/utils/external-signing/prepared-transaction.js +158 -0
  78. package/build/src/utils/external-signing/prepared-transaction.js.map +1 -0
  79. package/build/src/utils/external-signing/wallet-ownership-checks.d.ts.map +1 -1
  80. package/build/src/utils/external-signing/wallet-ownership-checks.js +8 -5
  81. package/build/src/utils/external-signing/wallet-ownership-checks.js.map +1 -1
  82. package/package.json +6 -4
  83. package/build/src/external-parties/discovery.d.ts +0 -72
  84. package/build/src/external-parties/discovery.d.ts.map +0 -1
  85. package/build/src/external-parties/discovery.js +0 -160
  86. package/build/src/external-parties/discovery.js.map +0 -1
  87. package/build/src/external-parties/errors.d.ts +0 -28
  88. package/build/src/external-parties/errors.d.ts.map +0 -1
  89. package/build/src/external-parties/errors.js +0 -33
  90. package/build/src/external-parties/errors.js.map +0 -1
  91. package/build/src/external-parties/hints.d.ts +0 -42
  92. package/build/src/external-parties/hints.d.ts.map +0 -1
  93. package/build/src/external-parties/hints.js +0 -83
  94. package/build/src/external-parties/hints.js.map +0 -1
  95. package/build/src/external-parties/keys.d.ts +0 -34
  96. package/build/src/external-parties/keys.d.ts.map +0 -1
  97. package/build/src/external-parties/keys.js +0 -209
  98. package/build/src/external-parties/keys.js.map +0 -1
  99. package/build/src/utils/amulet/external-party-cc-transfer.d.ts +0 -67
  100. package/build/src/utils/amulet/external-party-cc-transfer.d.ts.map +0 -1
  101. package/build/src/utils/amulet/external-party-cc-transfer.js +0 -148
  102. package/build/src/utils/amulet/external-party-cc-transfer.js.map +0 -1
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onCallerInput = onCallerInput;
4
+ exports.callerInputError = callerInputError;
5
+ exports.cantonPublicKeyBase64 = cantonPublicKeyBase64;
6
+ exports.rawEd25519PublicKey = rawEd25519PublicKey;
7
+ exports.publicKeyFingerprintOf = publicKeyFingerprintOf;
8
+ exports.externalPartyIdOf = externalPartyIdOf;
9
+ exports.requestedExternalPartyId = requestedExternalPartyId;
10
+ exports.hasSurroundingWhitespace = hasSurroundingWhitespace;
11
+ exports.assertPartyKey = assertPartyKey;
12
+ exports.cantonHashHexOf = cantonHashHexOf;
13
+ /**
14
+ * Node-sdk's use of `@fairmint/canton-protocol/party` on caller input. Internal: not exported from the package.
15
+ *
16
+ * The key, fingerprint, party-ID and hash rules are canton-protocol's. These wrappers keep node-sdk's error contract
17
+ * for its own functions: input canton-protocol refuses (`INVALID_INPUT`) becomes a {@link ValidationError} carrying the
18
+ * refusal as `cause`, and a party/key mismatch keeps the SDK's messages.
19
+ */
20
+ const party_1 = require("@fairmint/canton-protocol/party");
21
+ const errors_1 = require("../../core/errors");
22
+ /** Runs a canton-protocol call on caller input: its `INVALID_INPUT` refusal becomes a {@link ValidationError}. */
23
+ function onCallerInput(call) {
24
+ try {
25
+ return call();
26
+ }
27
+ catch (error) {
28
+ throw callerInputError(error);
29
+ }
30
+ }
31
+ /**
32
+ * The error to throw for `error`, raised by canton-protocol on caller input: its `INVALID_INPUT` refusal becomes a
33
+ * {@link ValidationError} carrying it as `cause`; anything else is returned as it is.
34
+ */
35
+ function callerInputError(error) {
36
+ if ((0, party_1.isCantonProtocolError)(error, 'INVALID_INPUT')) {
37
+ const validation = new errors_1.ValidationError(error.message, error.field === undefined ? {} : { field: error.field });
38
+ Object.defineProperty(validation, 'cause', { value: error, enumerable: false, writable: true });
39
+ return validation;
40
+ }
41
+ return error;
42
+ }
43
+ /** Canton's encoding (DER X.509 SubjectPublicKeyInfo, base64) of a raw or DER Ed25519 public key. */
44
+ function cantonPublicKeyBase64(publicKeyBase64) {
45
+ return onCallerInput(() => (0, party_1.normalizeEd25519PublicKeyForCanton)(publicKeyBase64));
46
+ }
47
+ /** The raw 32 bytes of a raw or DER Ed25519 public key. */
48
+ function rawEd25519PublicKey(publicKeyBase64) {
49
+ return onCallerInput(() => (0, party_1.decodeEd25519PublicKey)(publicKeyBase64));
50
+ }
51
+ /** The Canton fingerprint of a raw or DER Ed25519 public key. */
52
+ function publicKeyFingerprintOf(publicKeyBase64) {
53
+ return onCallerInput(() => (0, party_1.fingerprintEd25519PublicKey)(publicKeyBase64));
54
+ }
55
+ /** The external party ID `hint::fingerprint`. */
56
+ function externalPartyIdOf(partyHint, publicKeyFingerprint) {
57
+ return onCallerInput(() => (0, party_1.buildExternalPartyId)(partyHint, publicKeyFingerprint));
58
+ }
59
+ /**
60
+ * The party ID Canton allocates for `partyHint` on `publicKeyBase64` (`hint::fingerprint`), built from the request so a
61
+ * participant's answer can be compared with it. Canton uses the hint exactly as sent, so a hint with leading or
62
+ * trailing whitespace is refused rather than trimmed, as is any hint canton-protocol's `buildExternalPartyId` refuses.
63
+ */
64
+ function requestedExternalPartyId(partyHint, publicKeyBase64) {
65
+ if (typeof partyHint === 'string' && partyHint !== partyHint.trim()) {
66
+ throw new errors_1.ValidationError('partyHint must not start or end with whitespace', { partyHint });
67
+ }
68
+ return externalPartyIdOf(partyHint, publicKeyFingerprintOf(publicKeyBase64));
69
+ }
70
+ /**
71
+ * Whether `partyId` has whitespace around it. A party ID is never trimmed: a space is a Daml-LF Party character, so `
72
+ * alice::…` would otherwise parse with ` alice` as its hint. Whitespace next to `::` is left to the ID's rules, as
73
+ * Canton reads it: a space before `::` is part of the hint (Canton allocates such a hint), and one after `::` is part
74
+ * of the namespace, which then is no key's fingerprint.
75
+ */
76
+ function hasSurroundingWhitespace(partyId) {
77
+ return partyId !== partyId.trim();
78
+ }
79
+ /**
80
+ * Checks that `partyId` is an external party of `publicKeyBase64` (its namespace is the key's fingerprint) and that a
81
+ * caller-supplied fingerprint, if any, is the key's; returns the key's fingerprint. An ID with whitespace around it is
82
+ * refused, never trimmed ({@link hasSurroundingWhitespace}).
83
+ */
84
+ function assertPartyKey(input) {
85
+ if (typeof input.partyId === 'string' && hasSurroundingWhitespace(input.partyId)) {
86
+ throw new errors_1.ValidationError('Canton party ID must not have whitespace around it', {
87
+ partyId: input.partyId,
88
+ });
89
+ }
90
+ const parsed = (0, party_1.parsePartyId)(input.partyId);
91
+ if (parsed === null) {
92
+ throw new errors_1.ValidationError('Expected a Canton party ID with one public key fingerprint suffix', {
93
+ partyId: input.partyId,
94
+ });
95
+ }
96
+ const keyFingerprint = publicKeyFingerprintOf(input.publicKeyBase64);
97
+ const suppliedFingerprint = input.publicKeyFingerprint?.trim();
98
+ if (suppliedFingerprint && suppliedFingerprint !== keyFingerprint) {
99
+ throw new errors_1.ValidationError('Submitted public key fingerprint does not match the public key', {
100
+ suppliedFingerprint,
101
+ keyFingerprint,
102
+ });
103
+ }
104
+ if (parsed.namespace !== keyFingerprint) {
105
+ throw new errors_1.ValidationError('Canton party ID does not match the submitted public key', {
106
+ partyFingerprint: parsed.namespace,
107
+ keyFingerprint,
108
+ });
109
+ }
110
+ return keyFingerprint;
111
+ }
112
+ /** A Canton hash (`1220` and 64 hex characters, either case) the caller passed as hex, in canonical lowercase form. */
113
+ function cantonHashHexOf(value) {
114
+ const normalized = value.trim().toLowerCase();
115
+ if (!(0, party_1.isCantonHash)(normalized)) {
116
+ throw new errors_1.ValidationError('Expected a Canton SHA-256 multihash hex string', { value });
117
+ }
118
+ return normalized;
119
+ }
120
+ //# sourceMappingURL=party-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"party-identity.js","sourceRoot":"","sources":["../../../../src/utils/external-signing/party-identity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,2DAQyC;AACzC,8CAAoD;AASpD,kHAAkH;AAClH,uBAAiC,IAAa;IAC5C,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,0BAAiC,KAAc;IAC7C,IAAI,IAAA,6BAAqB,EAAC,KAAK,EAAE,eAAe,CAAC,EAAE,CAAC;QAClD,MAAM,UAAU,GAAG,IAAI,wBAAe,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/G,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAChG,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,qGAAqG;AACrG,+B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AM,GAAG,IAAA,oBAAY,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,wBAAe,CAAC,mEAAmE,EAAE;YAC7F,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,MAAM,cAAc,GAAG,sBAAsB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACrE,MAAM,mBAAmB,GAAG,KAAK,CAAC,oBAAoB,EAAE,IAAI,EAAE,CAAC;IAC/D,IAAI,mBAAmB,IAAI,mBAAmB,KAAK,cAAc,EAAE,CAAC;QAClE,MAAM,IAAI,wBAAe,CAAC,gEAAgE,EAAE;YAC1F,mBAAmB;YACnB,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,KAAK,cAAc,EAAE,CAAC;QACxC,MAAM,IAAI,wBAAe,CAAC,yDAAyD,EAAE;YACnF,gBAAgB,EAAE,MAAM,CAAC,SAAS;YAClC,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,uHAAuH;AACvH,yBAAgC,KAAa;IAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,CAAC,IAAA,oBAAY,EAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,wBAAe,CAAC,gDAAgD,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { type HashingScheme } from '@fairmint/canton-protocol/transaction';
2
+ /** What the prepared transaction must state. */
3
+ export interface PreparedTransactionExpectation {
4
+ /** The parties it must act as: the exact set. */
5
+ readonly actAs: readonly string[];
6
+ /** The command id requested. Omitted: the one the transaction states (when another party chose it). */
7
+ readonly commandId?: string | undefined;
8
+ /** The synchronizer requested. Omitted: the one the transaction states (when another party chose it). */
9
+ readonly synchronizerId?: string | undefined;
10
+ }
11
+ /** A participant's answer to a prepare request, with what node-sdk asked for. */
12
+ export interface ParticipantPreparedTransaction {
13
+ /** Names the request in error messages, e.g. `interactive submission prepare`. */
14
+ readonly operation: string;
15
+ readonly preparedTransaction: unknown;
16
+ /** The participant's hash of it: hex or base64, 32 bytes. */
17
+ readonly preparedTransactionHash: unknown;
18
+ /** The scheme node-sdk asked the transaction to be prepared under. */
19
+ readonly hashingScheme: HashingScheme;
20
+ /**
21
+ * The scheme the answer names. Omit only for an answer that names none (a validator's): an answer naming another
22
+ * scheme than the one requested is refused, so a participant cannot downgrade V3 to V2.
23
+ */
24
+ readonly answeredHashingScheme?: unknown;
25
+ readonly expected: PreparedTransactionExpectation;
26
+ }
27
+ /** A prepared transaction whose hash node-sdk recomputed. */
28
+ export interface VerifiedPreparedTransaction {
29
+ readonly preparedTransaction: string;
30
+ /** The recomputed hash, 64 lowercase hex characters: what the party signs. */
31
+ readonly preparedTransactionHashHex: string;
32
+ readonly hashingSchemeVersion: HashingScheme;
33
+ }
34
+ /** A signed prepared transaction a caller submits. */
35
+ export interface SubmittedPreparedTransaction {
36
+ readonly preparedTransaction: string;
37
+ /** The hash the party signed: 32 bytes, hex. */
38
+ readonly preparedTransactionHashHex: string;
39
+ /** The scheme it is executed under. */
40
+ readonly hashingScheme: HashingScheme;
41
+ readonly expected: PreparedTransactionExpectation;
42
+ }
43
+ /**
44
+ * Verifies a participant's prepared transaction and resolves its recomputed hash. A refusal of the participant's answer
45
+ * (another scheme, no transaction, a hash that is not the transaction's, a transaction that cannot be hashed or that
46
+ * does not state what was asked) is an {@link OperationError} (`TRANSACTION_FAILED`) with canton-protocol's refusal as
47
+ * `cause` and its `code` and `field` in the context; an invalid expectation (caller input) is a {@link ValidationError}.
48
+ * Nothing may be signed when it rejects.
49
+ */
50
+ export declare function verifyParticipantPreparedTransaction(input: ParticipantPreparedTransaction): Promise<VerifiedPreparedTransaction>;
51
+ /**
52
+ * Checks, before a signed prepared transaction is submitted, that the signed hash is the hash of the transaction bytes
53
+ * under the scheme it is executed with, and that the transaction states what is expected. Every refusal is a
54
+ * {@link ValidationError} (caller input) with canton-protocol's refusal as `cause` where it made it; nothing may be
55
+ * submitted when it rejects.
56
+ */
57
+ export declare function assertSubmittedPreparedTransaction(input: SubmittedPreparedTransaction): Promise<void>;
58
+ //# sourceMappingURL=prepared-transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepared-transaction.d.ts","sourceRoot":"","sources":["../../../../src/utils/external-signing/prepared-transaction.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,uCAAuC,CAAC;AAI/C,gDAAgD;AAChD,MAAM,WAAW,8BAA8B;IAC7C,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,uGAAuG;IACvG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,yGAAyG;IACzG,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9C;AAED,iFAAiF;AACjF,MAAM,WAAW,8BAA8B;IAC7C,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,6DAA6D;IAC7D,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAC;IAC1C,sEAAsE;IACtE,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,8BAA8B,CAAC;CACnD;AAED,6DAA6D;AAC7D,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,8EAA8E;IAC9E,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,oBAAoB,EAAE,aAAa,CAAC;CAC9C;AAED,sDAAsD;AACtD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,gDAAgD;IAChD,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC;IAC5C,uCAAuC;IACvC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,8BAA8B,CAAC;CACnD;AASD;;;;;;GAMG;AACH,wBAAsB,oCAAoC,CACxD,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CA6CtC;AAED;;;;;GAKG;AACH,wBAAsB,kCAAkC,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB3G"}
@@ -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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AC1B;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,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,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AC,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"}
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,CAA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,EAAE,CAAC;QAC9B,OAAO,IAAA,QAAA,YAAY,EAAC,gBAAgB,EAAE,iDAAiD,CAAC,CAAC;IAC3F,CAAC;IACD,IAAI,gBAAgB,KAAK,WAAW,EAAE,CAAC;QACrC,OAAO,IAAA,QAAA,YAAY,EACjB,wBAAwB,EACxB,uMAAuM,CACxM,CAAC;IACJ,CAAC;IAED,IAAI,SAAiB,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.302",
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,7 +110,8 @@
109
110
  "zod": "4.6.7"
110
111
  },
111
112
  "devDependencies": {
112
- "@fairmint/canton-dev-tools": "0.1.16",
113
+ "@canton-network/core-tx-hashing": "1.2.0",
114
+ "@fairmint/canton-dev-tools": "0.2.0",
113
115
  "@types/jest": "30.0.0",
114
116
  "@types/node": "26.6.6",
115
117
  "@types/ws": "8.18.2",
@@ -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,OAAO,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED,sGAAsG;AACtG,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,+CAA+C;AAC/C,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,wHAAwH;AACxH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC5F,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,iFAAiF;AACjF,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,2EAA2E;AAC3E,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE;IACnD,QAAQ,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