@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.
- package/lib/cjs/agent/actor.js +2 -2
- package/lib/cjs/agent/actor.js.map +1 -1
- package/lib/cjs/agent/agent/api.d.ts +6 -6
- package/lib/cjs/agent/agent/api.js +4 -4
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts +30 -0
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -1
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js +33 -1
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -1
- package/lib/cjs/agent/agent/http/index.d.ts +22 -3
- package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
- package/lib/cjs/agent/agent/http/index.js +131 -51
- package/lib/cjs/agent/agent/http/index.js.map +1 -1
- package/lib/cjs/agent/canisterStatus/index.d.ts +18 -50
- package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -1
- package/lib/cjs/agent/canisterStatus/index.js +30 -92
- package/lib/cjs/agent/canisterStatus/index.js.map +1 -1
- package/lib/cjs/agent/certificate.d.ts +68 -10
- package/lib/cjs/agent/certificate.d.ts.map +1 -1
- package/lib/cjs/agent/certificate.js +198 -27
- package/lib/cjs/agent/certificate.js.map +1 -1
- package/lib/cjs/agent/constants.d.ts +4 -0
- package/lib/cjs/agent/constants.d.ts.map +1 -1
- package/lib/cjs/agent/constants.js +5 -1
- package/lib/cjs/agent/constants.js.map +1 -1
- package/lib/cjs/agent/errors.d.ts +7 -1
- package/lib/cjs/agent/errors.d.ts.map +1 -1
- package/lib/cjs/agent/errors.js +19 -7
- package/lib/cjs/agent/errors.js.map +1 -1
- package/lib/cjs/agent/index.d.ts +97 -3
- package/lib/cjs/agent/index.d.ts.map +1 -1
- package/lib/cjs/agent/index.js +92 -9
- package/lib/cjs/agent/index.js.map +1 -1
- package/lib/cjs/agent/polling/index.js +1 -1
- package/lib/cjs/agent/polling/index.js.map +1 -1
- package/lib/cjs/agent/subnetStatus/index.d.ts +70 -0
- package/lib/cjs/agent/subnetStatus/index.d.ts.map +1 -0
- package/lib/cjs/agent/subnetStatus/index.js +224 -0
- package/lib/cjs/agent/subnetStatus/index.js.map +1 -0
- package/lib/cjs/agent/utils/readState.d.ts +84 -0
- package/lib/cjs/agent/utils/readState.d.ts.map +1 -0
- package/lib/cjs/agent/utils/readState.js +149 -0
- package/lib/cjs/agent/utils/readState.js.map +1 -0
- package/lib/cjs/candid/index.d.ts +20 -1
- package/lib/cjs/candid/index.d.ts.map +1 -1
- package/lib/cjs/candid/index.js +20 -1
- package/lib/cjs/candid/index.js.map +1 -1
- package/lib/cjs/identity/index.d.ts +30 -7
- package/lib/cjs/identity/index.d.ts.map +1 -1
- package/lib/cjs/identity/index.js +31 -11
- package/lib/cjs/identity/index.js.map +1 -1
- package/lib/cjs/identity/secp256k1/index.d.ts +48 -1
- package/lib/cjs/identity/secp256k1/index.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/index.js +48 -1
- package/lib/cjs/identity/secp256k1/index.js.map +1 -1
- package/lib/cjs/principal/index.d.ts +15 -0
- package/lib/cjs/principal/index.d.ts.map +1 -1
- package/lib/cjs/principal/index.js +15 -0
- package/lib/cjs/principal/index.js.map +1 -1
- package/lib/esm/agent/actor.js +3 -3
- package/lib/esm/agent/actor.js.map +1 -1
- package/lib/esm/agent/agent/api.d.ts +6 -6
- package/lib/esm/agent/agent/api.js +3 -3
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts +30 -0
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -1
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js +33 -1
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -1
- package/lib/esm/agent/agent/http/index.d.ts +22 -3
- package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
- package/lib/esm/agent/agent/http/index.js +134 -54
- package/lib/esm/agent/agent/http/index.js.map +1 -1
- package/lib/esm/agent/canister-env/index.d.ts +2 -1
- package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
- package/lib/esm/agent/canister-env/index.js +2 -1
- package/lib/esm/agent/canister-env/index.js.map +1 -1
- package/lib/esm/agent/canisterStatus/index.d.ts +18 -50
- package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -1
- package/lib/esm/agent/canisterStatus/index.js +31 -93
- package/lib/esm/agent/canisterStatus/index.js.map +1 -1
- package/lib/esm/agent/certificate.d.ts +68 -10
- package/lib/esm/agent/certificate.d.ts.map +1 -1
- package/lib/esm/agent/certificate.js +196 -29
- package/lib/esm/agent/certificate.js.map +1 -1
- package/lib/esm/agent/constants.d.ts +4 -0
- package/lib/esm/agent/constants.d.ts.map +1 -1
- package/lib/esm/agent/constants.js +4 -0
- package/lib/esm/agent/constants.js.map +1 -1
- package/lib/esm/agent/errors.d.ts +7 -1
- package/lib/esm/agent/errors.d.ts.map +1 -1
- package/lib/esm/agent/errors.js +15 -4
- package/lib/esm/agent/errors.js.map +1 -1
- package/lib/esm/agent/index.d.ts +97 -3
- package/lib/esm/agent/index.d.ts.map +1 -1
- package/lib/esm/agent/index.js +97 -3
- package/lib/esm/agent/index.js.map +1 -1
- package/lib/esm/agent/polling/index.js +1 -1
- package/lib/esm/agent/polling/index.js.map +1 -1
- package/lib/esm/agent/subnetStatus/index.d.ts +70 -0
- package/lib/esm/agent/subnetStatus/index.d.ts.map +1 -0
- package/lib/esm/agent/subnetStatus/index.js +183 -0
- package/lib/esm/agent/subnetStatus/index.js.map +1 -0
- package/lib/esm/agent/utils/readState.d.ts +84 -0
- package/lib/esm/agent/utils/readState.d.ts.map +1 -0
- package/lib/esm/agent/utils/readState.js +107 -0
- package/lib/esm/agent/utils/readState.js.map +1 -0
- package/lib/esm/candid/index.d.ts +20 -1
- package/lib/esm/candid/index.d.ts.map +1 -1
- package/lib/esm/candid/index.js +20 -1
- package/lib/esm/candid/index.js.map +1 -1
- package/lib/esm/identity/index.d.ts +30 -7
- package/lib/esm/identity/index.d.ts.map +1 -1
- package/lib/esm/identity/index.js +30 -9
- package/lib/esm/identity/index.js.map +1 -1
- package/lib/esm/identity/secp256k1/index.d.ts +48 -1
- package/lib/esm/identity/secp256k1/index.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/index.js +48 -1
- package/lib/esm/identity/secp256k1/index.js.map +1 -1
- package/lib/esm/principal/index.d.ts +15 -0
- package/lib/esm/principal/index.d.ts.map +1 -1
- package/lib/esm/principal/index.js +15 -0
- package/lib/esm/principal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agent/actor.ts +3 -3
- package/src/agent/agent/api.ts +8 -8
- package/src/agent/agent/http/index.ts +171 -58
- package/src/agent/canister-env/index.ts +2 -1
- package/src/agent/canisterStatus/index.ts +46 -191
- package/src/agent/certificate.ts +271 -52
- package/src/agent/constants.ts +5 -0
- package/src/agent/errors.ts +17 -4
- package/src/agent/index.ts +97 -3
- package/src/agent/polling/index.ts +1 -1
- package/src/agent/subnetStatus/index.ts +270 -0
- package/src/agent/utils/readState.ts +180 -0
- package/src/candid/index.ts +20 -1
- package/src/identity/index.ts +30 -10
- package/src/identity/secp256k1/index.ts +48 -1
- package/src/principal/index.ts +16 -0
|
@@ -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,eAAO,MAAM,iBAAiB,WAE7B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAE9D;;GA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AAI,EACjB,QAAQ,EAAE,SAAS,GAClB,cAAc,CAoChB"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Principal } from '../../principal/index.js';
|
|
2
|
+
import * as cbor from "../cbor.js";
|
|
3
|
+
import { decodeLeb128 } from "../utils/leb.js";
|
|
4
|
+
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
|
|
5
|
+
import { flatten_forks, LookupPathStatus, lookup_path, lookup_subtree, LookupSubtreeStatus, } from "../certificate.js";
|
|
6
|
+
import { LookupErrorCode, DerKeyLengthMismatchErrorCode, ProtocolError, UnknownError, HashTreeDecodeErrorCode, } from "../errors.js";
|
|
7
|
+
/**
|
|
8
|
+
* The root subnet ID for IC mainnet
|
|
9
|
+
*/
|
|
10
|
+
export const IC_ROOT_SUBNET_ID = Principal.fromText('tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe');
|
|
11
|
+
/**
|
|
12
|
+
* Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.
|
|
13
|
+
* @param {string} key the key to use to access the returned value in the status map
|
|
14
|
+
* @param {Uint8Array[]} path the path to the desired value, represented as an array of buffers
|
|
15
|
+
* @param {string} decodeStrategy the strategy to use to decode the returned value
|
|
16
|
+
*/
|
|
17
|
+
export class CustomPath {
|
|
18
|
+
constructor(key, path, decodeStrategy) {
|
|
19
|
+
this.key = key;
|
|
20
|
+
this.path = path;
|
|
21
|
+
this.decodeStrategy = decodeStrategy;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Decode a value based on the specified strategy
|
|
26
|
+
* @param data the raw data to decode
|
|
27
|
+
* @param strategy the decode strategy to use
|
|
28
|
+
* @returns the decoded value
|
|
29
|
+
*/
|
|
30
|
+
export function decodeValue(data, strategy) {
|
|
31
|
+
switch (strategy) {
|
|
32
|
+
case 'raw':
|
|
33
|
+
return data;
|
|
34
|
+
case 'leb128':
|
|
35
|
+
return decodeLeb128(data);
|
|
36
|
+
case 'cbor':
|
|
37
|
+
return cbor.decode(data);
|
|
38
|
+
case 'hex':
|
|
39
|
+
return bytesToHex(data);
|
|
40
|
+
case 'utf-8':
|
|
41
|
+
return new TextDecoder().decode(data);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Decode controllers from CBOR-encoded buffer
|
|
46
|
+
* @param buf the CBOR-encoded buffer to decode
|
|
47
|
+
* @returns an array of principal IDs
|
|
48
|
+
*/
|
|
49
|
+
export function decodeControllers(buf) {
|
|
50
|
+
const controllersRaw = cbor.decode(buf);
|
|
51
|
+
return controllersRaw.map(buf => {
|
|
52
|
+
return Principal.fromUint8Array(buf);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Encode a metadata path for canister metadata queries
|
|
57
|
+
* @param metaPath the metadata path (string or Uint8Array)
|
|
58
|
+
* @param canisterUint8Array the canister ID as Uint8Array
|
|
59
|
+
* @returns the encoded path
|
|
60
|
+
*/
|
|
61
|
+
export function encodeMetadataPath(metaPath, canisterUint8Array) {
|
|
62
|
+
const encoded = typeof metaPath === 'string' ? utf8ToBytes(metaPath) : metaPath;
|
|
63
|
+
return [utf8ToBytes('canister'), canisterUint8Array, utf8ToBytes('metadata'), encoded];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if a path object has custom path signature (has 'key' and 'path' properties)
|
|
67
|
+
* @param path the path to check
|
|
68
|
+
* @returns true if the path has custom path signature, false otherwise
|
|
69
|
+
*/
|
|
70
|
+
export function isCustomPath(path) {
|
|
71
|
+
return typeof path === 'object' && path !== null && 'key' in path && 'path' in path;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Lookup node keys from a certificate for a given subnet
|
|
75
|
+
* This can be used for both canister and subnet status queries
|
|
76
|
+
* @param certificate the certificate to fetch node keys from
|
|
77
|
+
* @param subnetId the subnet ID to fetch node keys for
|
|
78
|
+
* @returns a map of node IDs to public keys
|
|
79
|
+
*/
|
|
80
|
+
export function lookupNodeKeysFromCertificate(certificate, subnetId) {
|
|
81
|
+
const subnetLookupResult = lookup_subtree(['subnet', subnetId.toUint8Array(), 'node'], certificate.tree);
|
|
82
|
+
if (subnetLookupResult.status !== LookupSubtreeStatus.Found) {
|
|
83
|
+
throw ProtocolError.fromCode(new LookupErrorCode('Node not found', subnetLookupResult.status));
|
|
84
|
+
}
|
|
85
|
+
if (subnetLookupResult.value instanceof Uint8Array) {
|
|
86
|
+
throw UnknownError.fromCode(new HashTreeDecodeErrorCode('Invalid node tree'));
|
|
87
|
+
}
|
|
88
|
+
// The forks are all labeled trees with the <node_id> label
|
|
89
|
+
const nodeForks = flatten_forks(subnetLookupResult.value);
|
|
90
|
+
const nodeKeys = new Map();
|
|
91
|
+
nodeForks.forEach(fork => {
|
|
92
|
+
const node_id = Principal.from(fork[1]).toText();
|
|
93
|
+
const publicKeyLookupResult = lookup_path(['public_key'], fork[2]);
|
|
94
|
+
if (publicKeyLookupResult.status !== LookupPathStatus.Found) {
|
|
95
|
+
throw ProtocolError.fromCode(new LookupErrorCode('Public key not found', publicKeyLookupResult.status));
|
|
96
|
+
}
|
|
97
|
+
const derEncodedPublicKey = publicKeyLookupResult.value;
|
|
98
|
+
if (derEncodedPublicKey.byteLength !== 44) {
|
|
99
|
+
throw ProtocolError.fromCode(new DerKeyLengthMismatchErrorCode(44, derEncodedPublicKey.byteLength));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
nodeKeys.set(node_id, derEncodedPublicKey);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return nodeKeys;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=readState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readState.js","sourceRoot":"","sources":["../../../../src/agent/utils/readState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;A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,GAAG,aAAa,CAAC,kBAAkB,CAAC,KAAK,CAA2B,CAAC;IACpF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAC;IAExD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACjD,MAAM,qBAAqB,GAAG,WAAW,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,IAAI,qBAAqB,CAAC,MAAM,KAAK,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC5D,MAAM,aAAa,CAAC,QAAQ,CAC1B,IAAI,eAAe,CAAC,sBAAsB,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAC1E,CAAC;QACJ,CAAC;QAED,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,KAAK,CAAC;QACxD,IAAI,mBAAmB,CAAC,UAAU,KAAK,EAAE,EAAE,CAAC;YAC1C,MAAM,aAAa,CAAC,QAAQ,CAC1B,IAAI,6BAA6B,CAAC,EAAE,EAAE,mBAAmB,CAAC,UAAU,CAAC,CACtE,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,mBAA0C,CAAC,CAAC;QACpE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
|
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"}
|
package/lib/esm/candid/index.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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.js";
|
|
5
24
|
export * from "./candid-core.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/candid/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","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;AAMhC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
|
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
|
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,5 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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.js";
|
|
5
34
|
export * from "./identity/ecdsa.js";
|
|
@@ -7,12 +36,4 @@ export * from "./identity/delegation.js";
|
|
|
7
36
|
export * from "./identity/partial.js";
|
|
8
37
|
export { WebAuthnIdentity } from "./identity/webauthn.js";
|
|
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 class Secp256k1KeyIdentity {
|
|
14
|
-
constructor() {
|
|
15
|
-
throw new Error('Secp256k1KeyIdentity is available in @icp-sdk/identity/secp256k1');
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","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,5 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The `@icp-sdk/core/identity/secp256k1` module provides an implementation of the [`SignIdentity`](https://js.icp.build/core/latest/libs/agent/api/classes/signidentity/) interface for the secp256k1 elliptic curve. It allows you to create and manage key pairs for signing and verification of messages.
|
|
3
|
+
*
|
|
4
|
+
* ## Usage
|
|
5
|
+
*
|
|
6
|
+
* Here's an example of how to use the `Secp256k1KeyIdentity` class to generate a new key pair and sign and verify a message:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Secp256k1KeyIdentity } from '@icp-sdk/core/identity/secp256k1';
|
|
10
|
+
*
|
|
11
|
+
* // Generate a new key pair
|
|
12
|
+
* const identity = Secp256k1KeyIdentity.generate();
|
|
13
|
+
*
|
|
14
|
+
* // Sign a message
|
|
15
|
+
* const message = 'Hello, world!';
|
|
16
|
+
* const signature = identity.sign(message);
|
|
17
|
+
*
|
|
18
|
+
* // Verify the signature
|
|
19
|
+
* const isValid = identity.verify(message, signature);
|
|
20
|
+
*
|
|
21
|
+
* console.log(`Signature is ${isValid ? 'valid' : 'invalid'}`);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* You can also use a seed to generate deterministic key pairs:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { Secp256k1KeyIdentity } from '@icp-sdk/core/identity/secp256k1';
|
|
28
|
+
*
|
|
29
|
+
* const seed = Buffer.from('my-secret-seed', 'utf8');
|
|
30
|
+
* const identity = Secp256k1KeyIdentity.generate(seed);
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* The Secp256k1KeyIdentity class also provides methods for converting the key pair to and from JSON-serializable objects:
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { Secp256k1KeyIdentity } from '@icp-sdk/core/identity/secp256k1';
|
|
37
|
+
*
|
|
38
|
+
* // Generate a new key pair
|
|
39
|
+
* const identity = Secp256k1KeyIdentity.generate();
|
|
40
|
+
*
|
|
41
|
+
* // Convert the key pair to a JSON-serializable object
|
|
42
|
+
* const json = identity.toJson();
|
|
43
|
+
*
|
|
44
|
+
* // Convert the JSON-serializable object back to a key pair
|
|
45
|
+
* const restoredIdentity = Secp256k1KeyIdentity.fromJson(json);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* <!-- split here -->
|
|
49
|
+
* @module libs/identity/secp256k1/api
|
|
3
50
|
*/
|
|
4
51
|
export * from './secp256k1.ts';
|
|
5
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/identity/secp256k1/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/identity/secp256k1/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The `@icp-sdk/core/identity/secp256k1` module provides an implementation of the [`SignIdentity`](https://js.icp.build/core/latest/libs/agent/api/classes/signidentity/) interface for the secp256k1 elliptic curve. It allows you to create and manage key pairs for signing and verification of messages.
|
|
3
|
+
*
|
|
4
|
+
* ## Usage
|
|
5
|
+
*
|
|
6
|
+
* Here's an example of how to use the `Secp256k1KeyIdentity` class to generate a new key pair and sign and verify a message:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Secp256k1KeyIdentity } from '@icp-sdk/core/identity/secp256k1';
|
|
10
|
+
*
|
|
11
|
+
* // Generate a new key pair
|
|
12
|
+
* const identity = Secp256k1KeyIdentity.generate();
|
|
13
|
+
*
|
|
14
|
+
* // Sign a message
|
|
15
|
+
* const message = 'Hello, world!';
|
|
16
|
+
* const signature = identity.sign(message);
|
|
17
|
+
*
|
|
18
|
+
* // Verify the signature
|
|
19
|
+
* const isValid = identity.verify(message, signature);
|
|
20
|
+
*
|
|
21
|
+
* console.log(`Signature is ${isValid ? 'valid' : 'invalid'}`);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* You can also use a seed to generate deterministic key pairs:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { Secp256k1KeyIdentity } from '@icp-sdk/core/identity/secp256k1';
|
|
28
|
+
*
|
|
29
|
+
* const seed = Buffer.from('my-secret-seed', 'utf8');
|
|
30
|
+
* const identity = Secp256k1KeyIdentity.generate(seed);
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* The Secp256k1KeyIdentity class also provides methods for converting the key pair to and from JSON-serializable objects:
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { Secp256k1KeyIdentity } from '@icp-sdk/core/identity/secp256k1';
|
|
37
|
+
*
|
|
38
|
+
* // Generate a new key pair
|
|
39
|
+
* const identity = Secp256k1KeyIdentity.generate();
|
|
40
|
+
*
|
|
41
|
+
* // Convert the key pair to a JSON-serializable object
|
|
42
|
+
* const json = identity.toJson();
|
|
43
|
+
*
|
|
44
|
+
* // Convert the JSON-serializable object back to a key pair
|
|
45
|
+
* const restoredIdentity = Secp256k1KeyIdentity.fromJson(json);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* <!-- split here -->
|
|
49
|
+
* @module libs/identity/secp256k1/api
|
|
3
50
|
*/
|
|
4
51
|
export * from "./secp256k1.js";
|
|
5
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/identity/secp256k1/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/identity/secp256k1/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JavaScript and TypeScript module to work with Internet Computer Principals.
|
|
3
|
+
*
|
|
4
|
+
* ## Usage
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { Principal } from '@icp-sdk/core/principal';
|
|
8
|
+
*
|
|
9
|
+
* const canisterId = Principal.fromText('uqqxf-5h777-77774-qaaaa-cai');
|
|
10
|
+
* const anonymousPrincipal = Principal.anonymous();
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* <!-- split here -->
|
|
14
|
+
* @module libs/principal/api
|
|
15
|
+
*/
|
|
1
16
|
export * from './principal.ts';
|
|
2
17
|
export { getCrc32 } from './utils/getCrc.ts';
|
|
3
18
|
export { base32Encode, base32Decode } from './utils/base32.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/principal/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/principal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JavaScript and TypeScript module to work with Internet Computer Principals.
|
|
3
|
+
*
|
|
4
|
+
* ## Usage
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { Principal } from '@icp-sdk/core/principal';
|
|
8
|
+
*
|
|
9
|
+
* const canisterId = Principal.fromText('uqqxf-5h777-77774-qaaaa-cai');
|
|
10
|
+
* const anonymousPrincipal = Principal.anonymous();
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* <!-- split here -->
|
|
14
|
+
* @module libs/principal/api
|
|
15
|
+
*/
|
|
1
16
|
export * from "./principal.js";
|
|
2
17
|
export { getCrc32 } from "./utils/getCrc.js";
|
|
3
18
|
export { base32Encode, base32Decode } from "./utils/base32.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/principal/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/principal/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
package/src/agent/actor.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
type Agent,
|
|
3
3
|
type HttpDetailsResponse,
|
|
4
4
|
isV2ResponseBody,
|
|
5
|
-
|
|
5
|
+
isV4ResponseBody,
|
|
6
6
|
QueryResponseStatus,
|
|
7
7
|
} from './agent/index.ts';
|
|
8
8
|
import {
|
|
@@ -452,7 +452,7 @@ function _createActorMethod(
|
|
|
452
452
|
});
|
|
453
453
|
let reply: Uint8Array | undefined;
|
|
454
454
|
let certificate: Certificate | undefined;
|
|
455
|
-
if (
|
|
455
|
+
if (isV4ResponseBody(response.body)) {
|
|
456
456
|
if (agent.rootKey == null) {
|
|
457
457
|
throw ExternalError.fromCode(new MissingRootKeyErrorCode());
|
|
458
458
|
}
|
|
@@ -460,7 +460,7 @@ function _createActorMethod(
|
|
|
460
460
|
certificate = await Certificate.create({
|
|
461
461
|
certificate: cert,
|
|
462
462
|
rootKey: agent.rootKey,
|
|
463
|
-
canisterId: ecid,
|
|
463
|
+
principal: { canisterId: ecid },
|
|
464
464
|
blsVerify,
|
|
465
465
|
agent,
|
|
466
466
|
});
|
package/src/agent/agent/api.ts
CHANGED
|
@@ -133,23 +133,23 @@ export interface v2ResponseBody {
|
|
|
133
133
|
* @returns boolean indicating if the body is a v2ResponseBody
|
|
134
134
|
*/
|
|
135
135
|
export function isV2ResponseBody(
|
|
136
|
-
body: v2ResponseBody |
|
|
136
|
+
body: v2ResponseBody | v4ResponseBody | null,
|
|
137
137
|
): body is v2ResponseBody {
|
|
138
138
|
return body !== null && body !== undefined && 'reject_code' in body;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
export interface
|
|
141
|
+
export interface v4ResponseBody {
|
|
142
142
|
certificate: Uint8Array;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
|
-
* Utility function to check if a body is a
|
|
146
|
+
* Utility function to check if a body is a v4ResponseBody for type safety.
|
|
147
147
|
* @param body The body to check
|
|
148
|
-
* @returns boolean indicating if the body is a
|
|
148
|
+
* @returns boolean indicating if the body is a v4ResponseBody
|
|
149
149
|
*/
|
|
150
|
-
export function
|
|
151
|
-
body: v2ResponseBody |
|
|
152
|
-
): body is
|
|
150
|
+
export function isV4ResponseBody(
|
|
151
|
+
body: v2ResponseBody | v4ResponseBody | null,
|
|
152
|
+
): body is v4ResponseBody {
|
|
153
153
|
return body !== null && body !== undefined && 'certificate' in body;
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -159,7 +159,7 @@ export interface SubmitResponse {
|
|
|
159
159
|
ok: boolean;
|
|
160
160
|
status: number;
|
|
161
161
|
statusText: string;
|
|
162
|
-
body: v2ResponseBody |
|
|
162
|
+
body: v2ResponseBody | v4ResponseBody | null;
|
|
163
163
|
headers: HttpHeaderField[];
|
|
164
164
|
};
|
|
165
165
|
requestDetails?: CallRequest;
|