@icp-sdk/core 5.0.0-beta.0 → 5.0.0-beta.1

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 (137) hide show
  1. package/lib/cjs/agent/actor.js +2 -2
  2. package/lib/cjs/agent/actor.js.map +1 -1
  3. package/lib/cjs/agent/agent/api.d.ts +6 -6
  4. package/lib/cjs/agent/agent/api.js +4 -4
  5. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts +30 -0
  6. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -1
  7. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js +33 -1
  8. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -1
  9. package/lib/cjs/agent/agent/http/index.d.ts +22 -3
  10. package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
  11. package/lib/cjs/agent/agent/http/index.js +131 -51
  12. package/lib/cjs/agent/agent/http/index.js.map +1 -1
  13. package/lib/cjs/agent/canisterStatus/index.d.ts +18 -50
  14. package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -1
  15. package/lib/cjs/agent/canisterStatus/index.js +30 -92
  16. package/lib/cjs/agent/canisterStatus/index.js.map +1 -1
  17. package/lib/cjs/agent/certificate.d.ts +68 -10
  18. package/lib/cjs/agent/certificate.d.ts.map +1 -1
  19. package/lib/cjs/agent/certificate.js +198 -27
  20. package/lib/cjs/agent/certificate.js.map +1 -1
  21. package/lib/cjs/agent/constants.d.ts +4 -0
  22. package/lib/cjs/agent/constants.d.ts.map +1 -1
  23. package/lib/cjs/agent/constants.js +5 -1
  24. package/lib/cjs/agent/constants.js.map +1 -1
  25. package/lib/cjs/agent/errors.d.ts +7 -1
  26. package/lib/cjs/agent/errors.d.ts.map +1 -1
  27. package/lib/cjs/agent/errors.js +19 -7
  28. package/lib/cjs/agent/errors.js.map +1 -1
  29. package/lib/cjs/agent/index.d.ts +97 -3
  30. package/lib/cjs/agent/index.d.ts.map +1 -1
  31. package/lib/cjs/agent/index.js +92 -9
  32. package/lib/cjs/agent/index.js.map +1 -1
  33. package/lib/cjs/agent/polling/index.js +1 -1
  34. package/lib/cjs/agent/polling/index.js.map +1 -1
  35. package/lib/cjs/agent/subnetStatus/index.d.ts +70 -0
  36. package/lib/cjs/agent/subnetStatus/index.d.ts.map +1 -0
  37. package/lib/cjs/agent/subnetStatus/index.js +224 -0
  38. package/lib/cjs/agent/subnetStatus/index.js.map +1 -0
  39. package/lib/cjs/agent/utils/readState.d.ts +84 -0
  40. package/lib/cjs/agent/utils/readState.d.ts.map +1 -0
  41. package/lib/cjs/agent/utils/readState.js +149 -0
  42. package/lib/cjs/agent/utils/readState.js.map +1 -0
  43. package/lib/cjs/candid/index.d.ts +20 -1
  44. package/lib/cjs/candid/index.d.ts.map +1 -1
  45. package/lib/cjs/candid/index.js +20 -1
  46. package/lib/cjs/candid/index.js.map +1 -1
  47. package/lib/cjs/identity/index.d.ts +30 -7
  48. package/lib/cjs/identity/index.d.ts.map +1 -1
  49. package/lib/cjs/identity/index.js +31 -11
  50. package/lib/cjs/identity/index.js.map +1 -1
  51. package/lib/cjs/identity/secp256k1/index.d.ts +48 -1
  52. package/lib/cjs/identity/secp256k1/index.d.ts.map +1 -1
  53. package/lib/cjs/identity/secp256k1/index.js +48 -1
  54. package/lib/cjs/identity/secp256k1/index.js.map +1 -1
  55. package/lib/cjs/principal/index.d.ts +15 -0
  56. package/lib/cjs/principal/index.d.ts.map +1 -1
  57. package/lib/cjs/principal/index.js +15 -0
  58. package/lib/cjs/principal/index.js.map +1 -1
  59. package/lib/esm/agent/actor.js +3 -3
  60. package/lib/esm/agent/actor.js.map +1 -1
  61. package/lib/esm/agent/agent/api.d.ts +6 -6
  62. package/lib/esm/agent/agent/api.js +3 -3
  63. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts +30 -0
  64. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -1
  65. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js +33 -1
  66. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -1
  67. package/lib/esm/agent/agent/http/index.d.ts +22 -3
  68. package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
  69. package/lib/esm/agent/agent/http/index.js +134 -54
  70. package/lib/esm/agent/agent/http/index.js.map +1 -1
  71. package/lib/esm/agent/canister-env/index.d.ts +2 -1
  72. package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
  73. package/lib/esm/agent/canister-env/index.js +2 -1
  74. package/lib/esm/agent/canister-env/index.js.map +1 -1
  75. package/lib/esm/agent/canisterStatus/index.d.ts +18 -50
  76. package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -1
  77. package/lib/esm/agent/canisterStatus/index.js +31 -93
  78. package/lib/esm/agent/canisterStatus/index.js.map +1 -1
  79. package/lib/esm/agent/certificate.d.ts +68 -10
  80. package/lib/esm/agent/certificate.d.ts.map +1 -1
  81. package/lib/esm/agent/certificate.js +196 -29
  82. package/lib/esm/agent/certificate.js.map +1 -1
  83. package/lib/esm/agent/constants.d.ts +4 -0
  84. package/lib/esm/agent/constants.d.ts.map +1 -1
  85. package/lib/esm/agent/constants.js +4 -0
  86. package/lib/esm/agent/constants.js.map +1 -1
  87. package/lib/esm/agent/errors.d.ts +7 -1
  88. package/lib/esm/agent/errors.d.ts.map +1 -1
  89. package/lib/esm/agent/errors.js +15 -4
  90. package/lib/esm/agent/errors.js.map +1 -1
  91. package/lib/esm/agent/index.d.ts +97 -3
  92. package/lib/esm/agent/index.d.ts.map +1 -1
  93. package/lib/esm/agent/index.js +97 -3
  94. package/lib/esm/agent/index.js.map +1 -1
  95. package/lib/esm/agent/polling/index.js +1 -1
  96. package/lib/esm/agent/polling/index.js.map +1 -1
  97. package/lib/esm/agent/subnetStatus/index.d.ts +70 -0
  98. package/lib/esm/agent/subnetStatus/index.d.ts.map +1 -0
  99. package/lib/esm/agent/subnetStatus/index.js +183 -0
  100. package/lib/esm/agent/subnetStatus/index.js.map +1 -0
  101. package/lib/esm/agent/utils/readState.d.ts +84 -0
  102. package/lib/esm/agent/utils/readState.d.ts.map +1 -0
  103. package/lib/esm/agent/utils/readState.js +107 -0
  104. package/lib/esm/agent/utils/readState.js.map +1 -0
  105. package/lib/esm/candid/index.d.ts +20 -1
  106. package/lib/esm/candid/index.d.ts.map +1 -1
  107. package/lib/esm/candid/index.js +20 -1
  108. package/lib/esm/candid/index.js.map +1 -1
  109. package/lib/esm/identity/index.d.ts +30 -7
  110. package/lib/esm/identity/index.d.ts.map +1 -1
  111. package/lib/esm/identity/index.js +30 -9
  112. package/lib/esm/identity/index.js.map +1 -1
  113. package/lib/esm/identity/secp256k1/index.d.ts +48 -1
  114. package/lib/esm/identity/secp256k1/index.d.ts.map +1 -1
  115. package/lib/esm/identity/secp256k1/index.js +48 -1
  116. package/lib/esm/identity/secp256k1/index.js.map +1 -1
  117. package/lib/esm/principal/index.d.ts +15 -0
  118. package/lib/esm/principal/index.d.ts.map +1 -1
  119. package/lib/esm/principal/index.js +15 -0
  120. package/lib/esm/principal/index.js.map +1 -1
  121. package/package.json +1 -1
  122. package/src/agent/actor.ts +3 -3
  123. package/src/agent/agent/api.ts +8 -8
  124. package/src/agent/agent/http/index.ts +171 -58
  125. package/src/agent/canister-env/index.ts +2 -1
  126. package/src/agent/canisterStatus/index.ts +46 -191
  127. package/src/agent/certificate.ts +271 -52
  128. package/src/agent/constants.ts +5 -0
  129. package/src/agent/errors.ts +17 -4
  130. package/src/agent/index.ts +97 -3
  131. package/src/agent/polling/index.ts +1 -1
  132. package/src/agent/subnetStatus/index.ts +270 -0
  133. package/src/agent/utils/readState.ts +180 -0
  134. package/src/candid/index.ts +20 -1
  135. package/src/identity/index.ts +30 -10
  136. package/src/identity/secp256k1/index.ts +48 -1
  137. package/src/principal/index.ts +16 -0
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.IC_ROOT_SUBNET_ID = exports.CustomPath = void 0;
37
+ exports.request = request;
38
+ exports.lookupSubnetInfo = lookupSubnetInfo;
39
+ exports.encodePath = encodePath;
40
+ const _principal_1 = require("../../principal/index.js");
41
+ const errors_ts_1 = require("../errors.js");
42
+ const certificate_ts_1 = require("../certificate.js");
43
+ const cbor = __importStar(require("../cbor.js"));
44
+ const leb_ts_1 = require("../utils/leb.js");
45
+ const utils_1 = require("@noble/hashes/utils");
46
+ const readState_ts_1 = require("../utils/readState.js");
47
+ // Re-export shared types and functions
48
+ var readState_ts_2 = require("../utils/readState.js");
49
+ Object.defineProperty(exports, "CustomPath", { enumerable: true, get: function () { return readState_ts_2.CustomPath; } });
50
+ Object.defineProperty(exports, "IC_ROOT_SUBNET_ID", { enumerable: true, get: function () { return readState_ts_2.IC_ROOT_SUBNET_ID; } });
51
+ /**
52
+ * Requests information from a subnet's `read_state` endpoint.
53
+ * Can be used to request information about the subnet's time, canister ranges, public key, node keys, and metrics.
54
+ * @param {SubnetStatusOptions} options The configuration for the subnet status request.
55
+ * @see {@link SubnetStatusOptions} for detailed options.
56
+ * @returns {Promise<StatusMap>} A map populated with data from the requested paths. Each path is a key in the map, and the value is the data obtained from the certificate for that path.
57
+ * @example
58
+ * const status = await subnetStatus.request({
59
+ * subnetId: IC_ROOT_SUBNET_ID,
60
+ * paths: ['time', 'nodeKeys'],
61
+ * agent,
62
+ * });
63
+ *
64
+ * const time = status.get('time');
65
+ * const nodeKeys = status.get('nodeKeys');
66
+ */
67
+ async function request(options) {
68
+ const { agent, paths, disableCertificateTimeVerification = false } = options;
69
+ const subnetId = _principal_1.Principal.from(options.subnetId);
70
+ const uniquePaths = [...new Set(paths)];
71
+ const status = new Map();
72
+ const promises = uniquePaths.map((path, index) => {
73
+ const encodedPath = encodePath(path, subnetId);
74
+ return (async () => {
75
+ try {
76
+ if (agent.rootKey === null) {
77
+ throw errors_ts_1.ExternalError.fromCode(new errors_ts_1.MissingRootKeyErrorCode());
78
+ }
79
+ const rootKey = agent.rootKey;
80
+ const response = await agent.readSubnetState(subnetId, {
81
+ paths: [encodedPath],
82
+ });
83
+ const certificate = await certificate_ts_1.Certificate.create({
84
+ certificate: response.certificate,
85
+ rootKey,
86
+ principal: { subnetId },
87
+ disableTimeVerification: disableCertificateTimeVerification,
88
+ agent,
89
+ });
90
+ const lookup = (cert, lookupPath) => {
91
+ if (lookupPath === 'nodeKeys') {
92
+ // For node keys, we need to parse the certificate directly
93
+ const data = (0, readState_ts_1.lookupNodeKeysFromCertificate)(cert.cert, subnetId);
94
+ return {
95
+ path: lookupPath,
96
+ data,
97
+ };
98
+ }
99
+ else {
100
+ return {
101
+ path: lookupPath,
102
+ data: (0, certificate_ts_1.lookupResultToBuffer)(cert.lookup_path(encodedPath)),
103
+ };
104
+ }
105
+ };
106
+ const { path, data } = lookup(certificate, uniquePaths[index]);
107
+ if (!data) {
108
+ console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
109
+ if (typeof path === 'string') {
110
+ status.set(path, null);
111
+ }
112
+ else {
113
+ status.set(path.key, null);
114
+ }
115
+ }
116
+ else {
117
+ switch (path) {
118
+ case 'time': {
119
+ status.set(path, (0, leb_ts_1.decodeTime)(data));
120
+ break;
121
+ }
122
+ case 'canisterRanges': {
123
+ status.set(path, (0, certificate_ts_1.decodeCanisterRanges)(data));
124
+ break;
125
+ }
126
+ case 'publicKey': {
127
+ status.set(path, data);
128
+ break;
129
+ }
130
+ case 'nodeKeys': {
131
+ status.set(path, data);
132
+ break;
133
+ }
134
+ default: {
135
+ // Check for CustomPath signature
136
+ if ((0, readState_ts_1.isCustomPath)(path)) {
137
+ status.set(path.key, (0, readState_ts_1.decodeValue)(data, path.decodeStrategy));
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
143
+ catch (error) {
144
+ // Throw on certificate errors
145
+ if (error instanceof errors_ts_1.AgentError &&
146
+ (error.hasCode(errors_ts_1.CertificateVerificationErrorCode) ||
147
+ error.hasCode(errors_ts_1.CertificateTimeErrorCode))) {
148
+ throw error;
149
+ }
150
+ if ((0, readState_ts_1.isCustomPath)(path)) {
151
+ status.set(path.key, null);
152
+ }
153
+ else {
154
+ status.set(path, null);
155
+ }
156
+ console.group();
157
+ console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
158
+ console.warn(error);
159
+ console.groupEnd();
160
+ }
161
+ })();
162
+ });
163
+ // Fetch all values separately, as each option can fail
164
+ await Promise.all(promises);
165
+ return status;
166
+ }
167
+ /**
168
+ * Fetch subnet info including node keys from a certificate
169
+ * @param certificate the certificate bytes
170
+ * @param subnetId the subnet ID
171
+ * @returns SubnetStatus with subnet ID and node keys
172
+ */
173
+ function lookupSubnetInfo(certificate, subnetId) {
174
+ const cert = cbor.decode(certificate);
175
+ const nodeKeys = (0, readState_ts_1.lookupNodeKeysFromCertificate)(cert, subnetId);
176
+ const publicKey = lookupSubnetPublicKey(cert, subnetId);
177
+ return {
178
+ subnetId: subnetId.toText(),
179
+ nodeKeys,
180
+ publicKey,
181
+ };
182
+ }
183
+ function lookupSubnetPublicKey(certificate, subnetId) {
184
+ const subnetLookupResult = (0, certificate_ts_1.lookup_path)(['subnet', subnetId.toUint8Array(), 'public_key'], certificate.tree);
185
+ if (subnetLookupResult.status !== certificate_ts_1.LookupPathStatus.Found) {
186
+ throw errors_ts_1.ProtocolError.fromCode(new errors_ts_1.LookupErrorCode('Public key not found', subnetLookupResult.status));
187
+ }
188
+ return subnetLookupResult.value;
189
+ }
190
+ /**
191
+ * Encode a path for subnet state queries
192
+ * @param path the path to encode
193
+ * @param subnetId the subnet ID
194
+ * @returns the encoded path as an array of Uint8Arrays
195
+ */
196
+ function encodePath(path, subnetId) {
197
+ const subnetUint8Array = subnetId.toUint8Array();
198
+ switch (path) {
199
+ case 'time':
200
+ return [(0, utils_1.utf8ToBytes)('time')];
201
+ case 'canisterRanges':
202
+ return [(0, utils_1.utf8ToBytes)('canister_ranges'), subnetUint8Array];
203
+ case 'publicKey':
204
+ return [(0, utils_1.utf8ToBytes)('subnet'), subnetUint8Array, (0, utils_1.utf8ToBytes)('public_key')];
205
+ case 'nodeKeys':
206
+ return [(0, utils_1.utf8ToBytes)('subnet'), subnetUint8Array, (0, utils_1.utf8ToBytes)('node')];
207
+ default: {
208
+ // Check for CustomPath signature
209
+ if ((0, readState_ts_1.isCustomPath)(path)) {
210
+ if (typeof path['path'] === 'string' || path['path'] instanceof Uint8Array) {
211
+ // For string paths, treat as a subnet path segment
212
+ const encoded = typeof path['path'] === 'string' ? (0, utils_1.utf8ToBytes)(path['path']) : path['path'];
213
+ return [(0, utils_1.utf8ToBytes)('subnet'), subnetUint8Array, encoded];
214
+ }
215
+ else {
216
+ // For non-simple paths, return the provided custom path
217
+ return path['path'];
218
+ }
219
+ }
220
+ }
221
+ }
222
+ throw errors_ts_1.UnknownError.fromCode(new errors_ts_1.UnexpectedErrorCode(`Error while encoding your path for subnet status. Please ensure that your path ${path} was formatted correctly.`));
223
+ }
224
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/subnetStatus/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,0BA0GC;AAQD,4CAUC;AAqBD,gCA+BC;AA7QD,2CAAuC;AACvC,4CAUsB;AAEtB,sDAQ2B;AAC3B,iDAAmC;AACnC,4CAA6C;AAC7C,+CAAkD;AAClD,wDAS+B;AAE/B,uCAAuC;AACvC,sDAA2F;AAA7D,0GAAA,UAAU,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AAwC3D;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,OAAO,CAAC,OAA4B;IACxD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,kCAAkC,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAC7E,MAAM,QAAQ,GAAG,sBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAElD,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEhD,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/C,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE/C,OAAO,CAAC,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC;gBACH,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;oBAC3B,MAAM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C,QAAQ,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;gBAC5D,CAAC;qBAAM,CAAC;oBACN,wDAAwD;oBACxD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,wBAAY,CAAC,QAAQ,CACzB,IAAI,+BAAmB,CACrB,kFAAkF,IAAI,2BAA2B,CAClH,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { Principal } from '../../principal/index.js';
2
+ import { type DerEncodedPublicKey } from '../auth.ts';
3
+ import { type Cert } from '../certificate.ts';
4
+ /**
5
+ * The root subnet ID for IC mainnet
6
+ */
7
+ export declare const IC_ROOT_SUBNET_ID: Principal;
8
+ export type SubnetNodeKeys = Map<string, DerEncodedPublicKey>;
9
+ /**
10
+ * Represents the useful information about a subnet
11
+ */
12
+ export type BaseSubnetStatus = {
13
+ /**
14
+ * The subnet ID
15
+ */
16
+ subnetId: string;
17
+ /**
18
+ * The node keys of the subnet
19
+ */
20
+ nodeKeys: SubnetNodeKeys;
21
+ /**
22
+ * Not supported
23
+ */
24
+ metrics?: never;
25
+ };
26
+ /**
27
+ * Base types of an entry on the status map.
28
+ * An entry of null indicates that the request failed, due to lack of permissions or the result being missing.
29
+ */
30
+ export type BaseStatus = string | Uint8Array | Date | Uint8Array[] | Principal[] | bigint | null;
31
+ /**
32
+ * Decode strategy for custom paths
33
+ */
34
+ export type DecodeStrategy = 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw';
35
+ /**
36
+ * Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.
37
+ * @param {string} key the key to use to access the returned value in the status map
38
+ * @param {Uint8Array[]} path the path to the desired value, represented as an array of buffers
39
+ * @param {string} decodeStrategy the strategy to use to decode the returned value
40
+ */
41
+ export declare class CustomPath implements CustomPath {
42
+ key: string;
43
+ path: Uint8Array[] | string;
44
+ decodeStrategy: DecodeStrategy;
45
+ constructor(key: string, path: Uint8Array[] | string, decodeStrategy: DecodeStrategy);
46
+ }
47
+ /**
48
+ * Decode a value based on the specified strategy
49
+ * @param data the raw data to decode
50
+ * @param strategy the decode strategy to use
51
+ * @returns the decoded value
52
+ */
53
+ export declare function decodeValue(data: Uint8Array, strategy: DecodeStrategy): BaseStatus;
54
+ /**
55
+ * Decode controllers from CBOR-encoded buffer
56
+ * @param buf the CBOR-encoded buffer to decode
57
+ * @returns an array of principal IDs
58
+ */
59
+ export declare function decodeControllers(buf: Uint8Array): Principal[];
60
+ /**
61
+ * Encode a metadata path for canister metadata queries
62
+ * @param metaPath the metadata path (string or Uint8Array)
63
+ * @param canisterUint8Array the canister ID as Uint8Array
64
+ * @returns the encoded path
65
+ */
66
+ export declare function encodeMetadataPath(metaPath: string | Uint8Array, canisterUint8Array: Uint8Array): Uint8Array[];
67
+ /**
68
+ * Check if a path object has custom path signature (has 'key' and 'path' properties)
69
+ * @param path the path to check
70
+ * @returns true if the path has custom path signature, false otherwise
71
+ */
72
+ export declare function isCustomPath<T>(path: T): path is T & {
73
+ key: string;
74
+ path: unknown;
75
+ };
76
+ /**
77
+ * Lookup node keys from a certificate for a given subnet
78
+ * This can be used for both canister and subnet status queries
79
+ * @param certificate the certificate to fetch node keys from
80
+ * @param subnetId the subnet ID to fetch node keys for
81
+ * @returns a map of node IDs to public keys
82
+ */
83
+ export declare function lookupNodeKeysFromCertificate(certificate: Cert, subnetId: Principal): SubnetNodeKeys;
84
+ //# sourceMappingURL=readState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readState.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/readState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACL,KAAK,IAAI,EAOV,MAAM,mBAAmB,CAAC;AAS3B;;GAEG;AACH,eAA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,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,IAAI,EACjB,QAAQ,EAAE,SAAS,GAClB,cAAc,CAoChB"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CustomPath = exports.IC_ROOT_SUBNET_ID = void 0;
37
+ exports.decodeValue = decodeValue;
38
+ exports.decodeControllers = decodeControllers;
39
+ exports.encodeMetadataPath = encodeMetadataPath;
40
+ exports.isCustomPath = isCustomPath;
41
+ exports.lookupNodeKeysFromCertificate = lookupNodeKeysFromCertificate;
42
+ const _principal_1 = require("../../principal/index.js");
43
+ const cbor = __importStar(require("../cbor.js"));
44
+ const leb_ts_1 = require("../utils/leb.js");
45
+ const utils_1 = require("@noble/hashes/utils");
46
+ const certificate_ts_1 = require("../certificate.js");
47
+ const errors_ts_1 = require("../errors.js");
48
+ /**
49
+ * The root subnet ID for IC mainnet
50
+ */
51
+ exports.IC_ROOT_SUBNET_ID = _principal_1.Principal.fromText('tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe');
52
+ /**
53
+ * Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.
54
+ * @param {string} key the key to use to access the returned value in the status map
55
+ * @param {Uint8Array[]} path the path to the desired value, represented as an array of buffers
56
+ * @param {string} decodeStrategy the strategy to use to decode the returned value
57
+ */
58
+ class CustomPath {
59
+ constructor(key, path, decodeStrategy) {
60
+ this.key = key;
61
+ this.path = path;
62
+ this.decodeStrategy = decodeStrategy;
63
+ }
64
+ }
65
+ exports.CustomPath = CustomPath;
66
+ /**
67
+ * Decode a value based on the specified strategy
68
+ * @param data the raw data to decode
69
+ * @param strategy the decode strategy to use
70
+ * @returns the decoded value
71
+ */
72
+ function decodeValue(data, strategy) {
73
+ switch (strategy) {
74
+ case 'raw':
75
+ return data;
76
+ case 'leb128':
77
+ return (0, leb_ts_1.decodeLeb128)(data);
78
+ case 'cbor':
79
+ return cbor.decode(data);
80
+ case 'hex':
81
+ return (0, utils_1.bytesToHex)(data);
82
+ case 'utf-8':
83
+ return new TextDecoder().decode(data);
84
+ }
85
+ }
86
+ /**
87
+ * Decode controllers from CBOR-encoded buffer
88
+ * @param buf the CBOR-encoded buffer to decode
89
+ * @returns an array of principal IDs
90
+ */
91
+ function decodeControllers(buf) {
92
+ const controllersRaw = cbor.decode(buf);
93
+ return controllersRaw.map(buf => {
94
+ return _principal_1.Principal.fromUint8Array(buf);
95
+ });
96
+ }
97
+ /**
98
+ * Encode a metadata path for canister metadata queries
99
+ * @param metaPath the metadata path (string or Uint8Array)
100
+ * @param canisterUint8Array the canister ID as Uint8Array
101
+ * @returns the encoded path
102
+ */
103
+ function encodeMetadataPath(metaPath, canisterUint8Array) {
104
+ const encoded = typeof metaPath === 'string' ? (0, utils_1.utf8ToBytes)(metaPath) : metaPath;
105
+ return [(0, utils_1.utf8ToBytes)('canister'), canisterUint8Array, (0, utils_1.utf8ToBytes)('metadata'), encoded];
106
+ }
107
+ /**
108
+ * Check if a path object has custom path signature (has 'key' and 'path' properties)
109
+ * @param path the path to check
110
+ * @returns true if the path has custom path signature, false otherwise
111
+ */
112
+ function isCustomPath(path) {
113
+ return typeof path === 'object' && path !== null && 'key' in path && 'path' in path;
114
+ }
115
+ /**
116
+ * Lookup node keys from a certificate for a given subnet
117
+ * This can be used for both canister and subnet status queries
118
+ * @param certificate the certificate to fetch node keys from
119
+ * @param subnetId the subnet ID to fetch node keys for
120
+ * @returns a map of node IDs to public keys
121
+ */
122
+ function lookupNodeKeysFromCertificate(certificate, subnetId) {
123
+ const subnetLookupResult = (0, certificate_ts_1.lookup_subtree)(['subnet', subnetId.toUint8Array(), 'node'], certificate.tree);
124
+ if (subnetLookupResult.status !== certificate_ts_1.LookupSubtreeStatus.Found) {
125
+ throw errors_ts_1.ProtocolError.fromCode(new errors_ts_1.LookupErrorCode('Node not found', subnetLookupResult.status));
126
+ }
127
+ if (subnetLookupResult.value instanceof Uint8Array) {
128
+ throw errors_ts_1.UnknownError.fromCode(new errors_ts_1.HashTreeDecodeErrorCode('Invalid node tree'));
129
+ }
130
+ // The forks are all labeled trees with the <node_id> label
131
+ const nodeForks = (0, certificate_ts_1.flatten_forks)(subnetLookupResult.value);
132
+ const nodeKeys = new Map();
133
+ nodeForks.forEach(fork => {
134
+ const node_id = _principal_1.Principal.from(fork[1]).toText();
135
+ const publicKeyLookupResult = (0, certificate_ts_1.lookup_path)(['public_key'], fork[2]);
136
+ if (publicKeyLookupResult.status !== certificate_ts_1.LookupPathStatus.Found) {
137
+ throw errors_ts_1.ProtocolError.fromCode(new errors_ts_1.LookupErrorCode('Public key not found', publicKeyLookupResult.status));
138
+ }
139
+ const derEncodedPublicKey = publicKeyLookupResult.value;
140
+ if (derEncodedPublicKey.byteLength !== 44) {
141
+ throw errors_ts_1.ProtocolError.fromCode(new errors_ts_1.DerKeyLengthMismatchErrorCode(44, derEncodedPublicKey.byteLength));
142
+ }
143
+ else {
144
+ nodeKeys.set(node_id, derEncodedPublicKey);
145
+ }
146
+ });
147
+ return nodeKeys;
148
+ }
149
+ //# sourceMappingURL=readState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readState.js","sourceRoot":"","sources":["../../../../src/agent/utils/readState.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,kCAaC;AAOD,8CAKC;AAQD,gDAMC;AAOD,oCAEC;AASD,sEAuCC;AAnLD,2CAAuC;AACvC,iDAAmC;AACnC,4CAA+C;AAC/C,+CAA8D;AAE9D,sDAQ2B;AAC3B,4CAMsB;AAEtB;;GAEG;AACU,QAAA,iBAAiB,GAAG,sBAAS,CAAC,QAAQ,CACjD,iEAAiE,CAClE,CAAC;AAiCF;;;;;GAKG;AACH,MAAa,UAAU;IAIrB,YAAY,GAAW,EAAE,IAA2B,EAAE,cAA8B;QAClF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AATD,gCASC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,IAAgB,EAAE,QAAwB;IACpE,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,KAAK;YACR,OAAO,IAAI,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;QAC5B,KAAK,MAAM;YACT,OAAO,I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AAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,5 +1,24 @@
1
1
  /**
2
- * @module api
2
+ * JavaScript and TypeScript module to work with Candid interfaces
3
+ *
4
+ * ## Usage
5
+ *
6
+ * ```ts
7
+ * import { IDL } from '@icp-sdk/core/candid';
8
+ *
9
+ * const MyType = IDL.Record({
10
+ * name: IDL.Text,
11
+ * age: IDL.Nat8,
12
+ * });
13
+ *
14
+ * const encoded = IDL.encode([MyType], [{ name: 'John', age: 30 }]);
15
+ * const decoded = IDL.decode([MyType], encoded);
16
+ *
17
+ * console.log(decoded); // [{ name: 'John', age: 30 }]
18
+ * ```
19
+ *
20
+ * <!-- split here -->
21
+ * @module libs/candid/api
3
22
  */
4
23
  export * from './candid-ui.ts';
5
24
  export * from './candid-core.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/candid/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,UAAU,CAAC;AAClB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/candid/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,UAAU,CAAC;AAClB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -1,6 +1,25 @@
1
1
  "use strict";
2
2
  /**
3
- * @module api
3
+ * JavaScript and TypeScript module to work with Candid interfaces
4
+ *
5
+ * ## Usage
6
+ *
7
+ * ```ts
8
+ * import { IDL } from '@icp-sdk/core/candid';
9
+ *
10
+ * const MyType = IDL.Record({
11
+ * name: IDL.Text,
12
+ * age: IDL.Nat8,
13
+ * });
14
+ *
15
+ * const encoded = IDL.encode([MyType], [{ name: 'John', age: 30 }]);
16
+ * const decoded = IDL.decode([MyType], encoded);
17
+ *
18
+ * console.log(decoded); // [{ name: 'John', age: 30 }]
19
+ * ```
20
+ *
21
+ * <!-- split here -->
22
+ * @module libs/candid/api
4
23
  */
5
24
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
25
  if (k2 === undefined) k2 = k;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/candid/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,mDAAiC;AACjC,gDAAgC;AAMhC,kDAAgC;AAChC,oDAAkC;AAClC,oDAAkC;AAClC,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/candid/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,mDAAiC;AACjC,gDAAgC;AAMhC,kDAAgC;AAChC,oDAAkC;AAClC,oDAAkC;AAClC,6CAA2B"}
@@ -1,5 +1,34 @@
1
1
  /**
2
- * @module api
2
+ * JavaScript and TypeScript module to manage Identities and enable simple Web Authentication flows for applications on the [Internet Computer](https://internetcomputer.org/)
3
+ *
4
+ * ## Usage
5
+ *
6
+ * ```ts
7
+ * import { ECDSAKeyIdentity, Ed25519KeyIdentity, WebAuthnIdentity } from '@icp-sdk/core/identity';
8
+ *
9
+ * const ecdsaIdentity = await ECDSAKeyIdentity.generate();
10
+ * const ed25519Identity = Ed25519KeyIdentity.generate();
11
+ * const webAuthnIdentity = await WebAuthnIdentity.create();
12
+ * ```
13
+ *
14
+ * ### DelegationIdentity
15
+ *
16
+ * The `DelegationIdentity` is typically generated using the [`@icp-sdk/auth`](https://js.icp.build/auth/latest/) package.
17
+ *
18
+ * ### PartialIdentity
19
+ *
20
+ * The `PartialIdentity` is not typically used directly, but is used by the `DelegationIdentity` and `WebAuthnIdentity` classes.
21
+ *
22
+ * ### Secp256k1KeyIdentity
23
+ *
24
+ * See [@icp-sdk/core/identity/secp256k1](https://js.icp.build/core/latest/libs/identity-secp256k1/api/) for more information.
25
+ *
26
+ * ## In Node.js
27
+ *
28
+ * Depending on your version, you may need to use a polyfill and set `global.crypto` in a setup file. If you prefer, you can also pass in a `subtleCrypto` implementation in methods that call for it, either as a direct argument, or in a `cryptoOptions` object.
29
+ *
30
+ * <!-- split here -->
31
+ * @module libs/identity/api
3
32
  */
4
33
  export * from './identity/ed25519.ts';
5
34
  export * from './identity/ecdsa.ts';
@@ -7,10 +36,4 @@ export * from './identity/delegation.ts';
7
36
  export * from './identity/partial.ts';
8
37
  export { WebAuthnIdentity } from './identity/webauthn.ts';
9
38
  export { wrapDER, unwrapDER, DER_COSE_OID, ED25519_OID } from '../agent/index.js';
10
- /**
11
- * @deprecated due to size of dependencies. Use `@icp-sdk/identity/secp256k1` instead.
12
- */
13
- export declare class Secp256k1KeyIdentity {
14
- constructor();
15
- }
16
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEvE;;GAEG;AACH,qBAAa,oBAAoB;;CAIhC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,6 +1,35 @@
1
1
  "use strict";
2
2
  /**
3
- * @module api
3
+ * JavaScript and TypeScript module to manage Identities and enable simple Web Authentication flows for applications on the [Internet Computer](https://internetcomputer.org/)
4
+ *
5
+ * ## Usage
6
+ *
7
+ * ```ts
8
+ * import { ECDSAKeyIdentity, Ed25519KeyIdentity, WebAuthnIdentity } from '@icp-sdk/core/identity';
9
+ *
10
+ * const ecdsaIdentity = await ECDSAKeyIdentity.generate();
11
+ * const ed25519Identity = Ed25519KeyIdentity.generate();
12
+ * const webAuthnIdentity = await WebAuthnIdentity.create();
13
+ * ```
14
+ *
15
+ * ### DelegationIdentity
16
+ *
17
+ * The `DelegationIdentity` is typically generated using the [`@icp-sdk/auth`](https://js.icp.build/auth/latest/) package.
18
+ *
19
+ * ### PartialIdentity
20
+ *
21
+ * The `PartialIdentity` is not typically used directly, but is used by the `DelegationIdentity` and `WebAuthnIdentity` classes.
22
+ *
23
+ * ### Secp256k1KeyIdentity
24
+ *
25
+ * See [@icp-sdk/core/identity/secp256k1](https://js.icp.build/core/latest/libs/identity-secp256k1/api/) for more information.
26
+ *
27
+ * ## In Node.js
28
+ *
29
+ * Depending on your version, you may need to use a polyfill and set `global.crypto` in a setup file. If you prefer, you can also pass in a `subtleCrypto` implementation in methods that call for it, either as a direct argument, or in a `cryptoOptions` object.
30
+ *
31
+ * <!-- split here -->
32
+ * @module libs/identity/api
4
33
  */
5
34
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
35
  if (k2 === undefined) k2 = k;
@@ -17,7 +46,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
46
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
47
  };
19
48
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.Secp256k1KeyIdentity = exports.ED25519_OID = exports.DER_COSE_OID = exports.unwrapDER = exports.wrapDER = exports.WebAuthnIdentity = void 0;
49
+ exports.ED25519_OID = exports.DER_COSE_OID = exports.unwrapDER = exports.wrapDER = exports.WebAuthnIdentity = void 0;
21
50
  __exportStar(require("./identity/ed25519.js"), exports);
22
51
  __exportStar(require("./identity/ecdsa.js"), exports);
23
52
  __exportStar(require("./identity/delegation.js"), exports);
@@ -29,13 +58,4 @@ Object.defineProperty(exports, "wrapDER", { enumerable: true, get: function () {
29
58
  Object.defineProperty(exports, "unwrapDER", { enumerable: true, get: function () { return _agent_1.unwrapDER; } });
30
59
  Object.defineProperty(exports, "DER_COSE_OID", { enumerable: true, get: function () { return _agent_1.DER_COSE_OID; } });
31
60
  Object.defineProperty(exports, "ED25519_OID", { enumerable: true, get: function () { return _agent_1.ED25519_OID; } });
32
- /**
33
- * @deprecated due to size of dependencies. Use `@icp-sdk/identity/secp256k1` instead.
34
- */
35
- class Secp256k1KeyIdentity {
36
- constructor() {
37
- throw new Error('Secp256k1KeyIdentity is available in @icp-sdk/identity/secp256k1');
38
- }
39
- }
40
- exports.Secp256k1KeyIdentity = Secp256k1KeyIdentity;
41
61
  //# sourceMappingURL=index.js.map