@icp-sdk/core 5.0.0-beta.0 → 5.0.0-beta.2
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/README.md +0 -2
- 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 +23 -5
- package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
- package/lib/cjs/agent/agent/http/index.js +201 -86
- package/lib/cjs/agent/agent/http/index.js.map +1 -1
- package/lib/cjs/agent/agent/index.d.ts +2 -0
- package/lib/cjs/agent/agent/index.d.ts.map +1 -1
- package/lib/cjs/agent/agent/index.js +2 -0
- package/lib/cjs/agent/agent/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 -97
- 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 +9 -2
- 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 -5
- package/lib/cjs/agent/index.d.ts.map +1 -1
- package/lib/cjs/agent/index.js +92 -11
- 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 +219 -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/identity/secp256k1/pem.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/pem.js +1 -2
- package/lib/cjs/identity/secp256k1/pem.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 +23 -5
- package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
- package/lib/esm/agent/agent/http/index.js +203 -84
- package/lib/esm/agent/agent/http/index.js.map +1 -1
- package/lib/esm/agent/agent/index.d.ts +2 -0
- package/lib/esm/agent/agent/index.d.ts.map +1 -1
- package/lib/esm/agent/agent/index.js +2 -0
- package/lib/esm/agent/agent/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 -98
- 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 +9 -2
- 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 -5
- package/lib/esm/agent/index.d.ts.map +1 -1
- package/lib/esm/agent/index.js +97 -5
- 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 +178 -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/identity/secp256k1/pem.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/pem.js +1 -2
- package/lib/esm/identity/secp256k1/pem.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 +3 -1
- package/src/agent/actor.ts +3 -3
- package/src/agent/agent/api.ts +8 -8
- package/src/agent/agent/http/index.ts +259 -97
- package/src/agent/agent/index.ts +2 -0
- package/src/agent/canister-env/index.ts +2 -1
- package/src/agent/canisterStatus/index.ts +46 -196
- package/src/agent/certificate.ts +271 -52
- package/src/agent/constants.ts +5 -0
- package/src/agent/errors.ts +19 -5
- package/src/agent/index.ts +97 -5
- package/src/agent/polling/index.ts +1 -1
- package/src/agent/subnetStatus/index.ts +265 -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/identity/secp256k1/pem.ts +1 -2
- package/src/principal/index.ts +16 -0
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pem.d.ts","sourceRoot":"","sources":["../../../../src/identity/secp256k1/pem.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"pem.d.ts","sourceRoot":"","sources":["../../../../src/identity/secp256k1/pem.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA4BtD"}
|
|
@@ -32,8 +32,7 @@ export function pemToSecretKey(pem) {
|
|
|
32
32
|
return rawKey.slice(7, 39);
|
|
33
33
|
}
|
|
34
34
|
catch (error) {
|
|
35
|
-
|
|
36
|
-
throw new Error('Encountered error while parsing PEM key');
|
|
35
|
+
throw new Error(`Encountered error while parsing PEM key: ${error}`);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
//# sourceMappingURL=pem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pem.js","sourceRoot":"","sources":["../../../../src/identity/secp256k1/pem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,MAAM,GAAG,gCAAgC,CAAC;AAChD,MAAM,MAAM,GAAG,8BAA8B,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvE,gCAAgC;IAChC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpC,oBAAoB;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC,EAAE,CAAC;YACzE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QACD,gEAAgE;QAChE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,
|
|
1
|
+
{"version":3,"file":"pem.js","sourceRoot":"","sources":["../../../../src/identity/secp256k1/pem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,MAAM,GAAG,gCAAgC,CAAC;AAChD,MAAM,MAAM,GAAG,8BAA8B,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvE,gCAAgC;IAChC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpC,oBAAoB;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC,EAAE,CAAC;YACzE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QACD,gEAAgE;QAChE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,4CAA4C,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icp-sdk/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.2",
|
|
4
4
|
"author": "DFINITY Stiftung <sdk@dfinity.org>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "JavaScript and TypeScript library to interact with the Internet Computer",
|
|
@@ -96,8 +96,10 @@
|
|
|
96
96
|
"scripts": {
|
|
97
97
|
"build": "tsc -b && tsc -p tsconfig.cjs.json && tsc-alias && tsc-alias -p tsconfig.cjs.json && cp src/package.json lib/esm/package.json",
|
|
98
98
|
"build:watch": "tsc -b --watch",
|
|
99
|
+
"prebundle": "pnpm build",
|
|
99
100
|
"bundle": "esbuild src/index.ts src/agent/index.ts src/candid/index.ts src/identity/index.ts src/identity/secp256k1/index.ts src/principal/index.ts --bundle --outdir=dist --platform=browser",
|
|
100
101
|
"attw": "attw --pack . --profile node16",
|
|
102
|
+
"pretest": "pnpm build",
|
|
101
103
|
"test": "jest"
|
|
102
104
|
}
|
|
103
105
|
}
|
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;
|