@icp-sdk/core 4.2.3 → 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.d.ts +203 -0
- package/lib/cjs/agent/actor.d.ts.map +1 -0
- package/lib/cjs/agent/actor.js +341 -0
- package/lib/cjs/agent/actor.js.map +1 -0
- package/lib/cjs/agent/agent/api.d.ts +216 -0
- package/lib/cjs/agent/agent/api.d.ts.map +1 -0
- package/lib/cjs/agent/agent/api.js +39 -0
- package/lib/cjs/agent/agent/api.js.map +1 -0
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts +37 -0
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -0
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js +51 -0
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -0
- package/lib/cjs/agent/agent/http/index.d.ts +190 -0
- package/lib/cjs/agent/agent/http/index.d.ts.map +1 -0
- package/lib/cjs/agent/agent/http/index.js +1159 -0
- package/lib/cjs/agent/agent/http/index.js.map +1 -0
- package/lib/cjs/agent/agent/http/transforms.d.ts +54 -0
- package/lib/cjs/agent/agent/http/transforms.d.ts.map +1 -0
- package/lib/cjs/agent/agent/http/transforms.js +135 -0
- package/lib/cjs/agent/agent/http/transforms.js.map +1 -0
- package/lib/cjs/agent/agent/http/types.d.ts +81 -0
- package/lib/cjs/agent/agent/http/types.d.ts.map +1 -0
- package/lib/cjs/agent/agent/http/types.js +43 -0
- package/lib/cjs/agent/agent/http/types.js.map +1 -0
- package/lib/cjs/agent/agent/index.d.ts +3 -0
- package/lib/cjs/agent/agent/index.d.ts.map +1 -0
- package/lib/cjs/agent/agent/index.js +19 -0
- package/lib/cjs/agent/agent/index.js.map +1 -0
- package/lib/cjs/agent/auth.d.ts +91 -0
- package/lib/cjs/agent/auth.d.ts.map +1 -0
- package/lib/cjs/agent/auth.js +65 -0
- package/lib/cjs/agent/auth.js.map +1 -0
- package/lib/cjs/agent/canisterStatus/index.d.ts +61 -0
- package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -0
- package/lib/cjs/agent/canisterStatus/index.js +239 -0
- package/lib/cjs/agent/canisterStatus/index.js.map +1 -0
- package/lib/cjs/agent/cbor.d.ts +26 -0
- package/lib/cjs/agent/cbor.d.ts.map +1 -0
- package/lib/cjs/agent/cbor.js +93 -0
- package/lib/cjs/agent/cbor.js.map +1 -0
- package/lib/cjs/agent/certificate.d.ts +286 -0
- package/lib/cjs/agent/certificate.d.ts.map +1 -0
- package/lib/cjs/agent/certificate.js +762 -0
- package/lib/cjs/agent/certificate.js.map +1 -0
- package/lib/cjs/agent/constants.d.ts +18 -0
- package/lib/cjs/agent/constants.d.ts.map +1 -0
- package/lib/cjs/agent/constants.js +22 -0
- package/lib/cjs/agent/constants.js.map +1 -0
- package/lib/cjs/agent/der.d.ts +34 -0
- package/lib/cjs/agent/der.d.ts.map +1 -0
- package/lib/cjs/agent/der.js +175 -0
- package/lib/cjs/agent/der.js.map +1 -0
- package/lib/cjs/agent/errors.d.ts +386 -0
- package/lib/cjs/agent/errors.d.ts.map +1 -0
- package/lib/cjs/agent/errors.js +745 -0
- package/lib/cjs/agent/errors.js.map +1 -0
- package/lib/cjs/agent/fetch_candid.d.ts +9 -0
- package/lib/cjs/agent/fetch_candid.d.ts.map +1 -0
- package/lib/cjs/agent/fetch_candid.js +69 -0
- package/lib/cjs/agent/fetch_candid.js.map +1 -0
- package/lib/cjs/agent/index.d.ts +125 -1
- package/lib/cjs/agent/index.d.ts.map +1 -1
- package/lib/cjs/agent/index.js +142 -1
- package/lib/cjs/agent/index.js.map +1 -1
- package/lib/cjs/agent/observable.d.ts +24 -0
- package/lib/cjs/agent/observable.d.ts.map +1 -0
- package/lib/cjs/agent/observable.js +34 -0
- package/lib/cjs/agent/observable.js.map +1 -0
- package/lib/cjs/agent/polling/backoff.d.ts +50 -0
- package/lib/cjs/agent/polling/backoff.d.ts.map +1 -0
- package/lib/cjs/agent/polling/backoff.js +90 -0
- package/lib/cjs/agent/polling/backoff.js.map +1 -0
- package/lib/cjs/agent/polling/index.d.ts +63 -0
- package/lib/cjs/agent/polling/index.d.ts.map +1 -0
- package/lib/cjs/agent/polling/index.js +183 -0
- package/lib/cjs/agent/polling/index.js.map +1 -0
- package/lib/cjs/agent/polling/strategy.d.ts +52 -0
- package/lib/cjs/agent/polling/strategy.d.ts.map +1 -0
- package/lib/cjs/agent/polling/strategy.js +104 -0
- package/lib/cjs/agent/polling/strategy.js.map +1 -0
- package/lib/cjs/agent/public_key.d.ts +16 -0
- package/lib/cjs/agent/public_key.d.ts.map +1 -0
- package/lib/cjs/agent/public_key.js +52 -0
- package/lib/cjs/agent/public_key.js.map +1 -0
- package/lib/cjs/agent/request_id.d.ts +24 -0
- package/lib/cjs/agent/request_id.d.ts.map +1 -0
- package/lib/cjs/agent/request_id.js +88 -0
- package/lib/cjs/agent/request_id.js.map +1 -0
- 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/bls.d.ts +10 -0
- package/lib/cjs/agent/utils/bls.d.ts.map +1 -0
- package/lib/cjs/agent/utils/bls.js +20 -0
- package/lib/cjs/agent/utils/bls.js.map +1 -0
- package/lib/cjs/agent/utils/buffer.d.ts +22 -0
- package/lib/cjs/agent/utils/buffer.d.ts.map +1 -0
- package/lib/cjs/agent/utils/buffer.js +55 -0
- package/lib/cjs/agent/utils/buffer.js.map +1 -0
- package/lib/cjs/agent/utils/expirableMap.d.ts +80 -0
- package/lib/cjs/agent/utils/expirableMap.d.ts.map +1 -0
- package/lib/cjs/agent/utils/expirableMap.js +148 -0
- package/lib/cjs/agent/utils/expirableMap.js.map +1 -0
- package/lib/cjs/agent/utils/leb.d.ts +3 -0
- package/lib/cjs/agent/utils/leb.d.ts.map +1 -0
- package/lib/cjs/agent/utils/leb.js +17 -0
- package/lib/cjs/agent/utils/leb.js.map +1 -0
- package/lib/cjs/agent/utils/random.d.ts +6 -0
- package/lib/cjs/agent/utils/random.d.ts.map +1 -0
- package/lib/cjs/agent/utils/random.js +29 -0
- package/lib/cjs/agent/utils/random.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/candid-core.d.ts +72 -0
- package/lib/cjs/candid/candid-core.d.ts.map +1 -0
- package/lib/cjs/candid/candid-core.js +251 -0
- package/lib/cjs/candid/candid-core.js.map +1 -0
- package/lib/cjs/candid/candid-ui.d.ts +35 -0
- package/lib/cjs/candid/candid-ui.d.ts.map +1 -0
- package/lib/cjs/candid/candid-ui.js +317 -0
- package/lib/cjs/candid/candid-ui.js.map +1 -0
- package/lib/cjs/candid/idl.d.ts +579 -0
- package/lib/cjs/candid/idl.d.ts.map +1 -0
- package/lib/cjs/candid/idl.js +2228 -0
- package/lib/cjs/candid/idl.js.map +1 -0
- package/lib/cjs/candid/index.d.ts +30 -1
- package/lib/cjs/candid/index.d.ts.map +1 -1
- package/lib/cjs/candid/index.js +52 -1
- package/lib/cjs/candid/index.js.map +1 -1
- package/lib/cjs/candid/types.d.ts +6 -0
- package/lib/cjs/candid/types.d.ts.map +1 -0
- package/lib/cjs/candid/types.js +4 -0
- package/lib/cjs/candid/types.js.map +1 -0
- package/lib/cjs/candid/utils/bigint-math.d.ts +14 -0
- package/lib/cjs/candid/utils/bigint-math.d.ts.map +1 -0
- package/lib/cjs/candid/utils/bigint-math.js +30 -0
- package/lib/cjs/candid/utils/bigint-math.js.map +1 -0
- package/lib/cjs/candid/utils/buffer.d.ts +86 -0
- package/lib/cjs/candid/utils/buffer.d.ts.map +1 -0
- package/lib/cjs/candid/utils/buffer.js +191 -0
- package/lib/cjs/candid/utils/buffer.js.map +1 -0
- package/lib/cjs/candid/utils/hash.d.ts +7 -0
- package/lib/cjs/candid/utils/hash.d.ts.map +1 -0
- package/lib/cjs/candid/utils/hash.js +33 -0
- package/lib/cjs/candid/utils/hash.js.map +1 -0
- package/lib/cjs/candid/utils/leb128.d.ts +65 -0
- package/lib/cjs/candid/utils/leb128.d.ts.map +1 -0
- package/lib/cjs/candid/utils/leb128.js +228 -0
- package/lib/cjs/candid/utils/leb128.js.map +1 -0
- package/lib/cjs/identity/identity/delegation.d.ts +164 -0
- package/lib/cjs/identity/identity/delegation.d.ts.map +1 -0
- package/lib/cjs/identity/identity/delegation.js +302 -0
- package/lib/cjs/identity/identity/delegation.js.map +1 -0
- package/lib/cjs/identity/identity/ecdsa.d.ts +62 -0
- package/lib/cjs/identity/identity/ecdsa.d.ts.map +1 -0
- package/lib/cjs/identity/identity/ecdsa.js +117 -0
- package/lib/cjs/identity/identity/ecdsa.js.map +1 -0
- package/lib/cjs/identity/identity/ed25519.d.ts +67 -0
- package/lib/cjs/identity/identity/ed25519.d.ts.map +1 -0
- package/lib/cjs/identity/identity/ed25519.js +200 -0
- package/lib/cjs/identity/identity/ed25519.js.map +1 -0
- package/lib/cjs/identity/identity/partial.d.ts +34 -0
- package/lib/cjs/identity/identity/partial.d.ts.map +1 -0
- package/lib/cjs/identity/identity/partial.js +54 -0
- package/lib/cjs/identity/identity/partial.js.map +1 -0
- package/lib/cjs/identity/identity/webauthn.d.ts +51 -0
- package/lib/cjs/identity/identity/webauthn.d.ts.map +1 -0
- package/lib/cjs/identity/identity/webauthn.js +197 -0
- package/lib/cjs/identity/identity/webauthn.js.map +1 -0
- package/lib/cjs/identity/index.d.ts +38 -1
- package/lib/cjs/identity/index.d.ts.map +1 -1
- package/lib/cjs/identity/index.js +44 -1
- package/lib/cjs/identity/index.js.map +1 -1
- package/lib/cjs/identity/secp256k1/der.d.ts +33 -0
- package/lib/cjs/identity/secp256k1/der.d.ts.map +1 -0
- package/lib/cjs/identity/secp256k1/der.js +165 -0
- package/lib/cjs/identity/secp256k1/der.js.map +1 -0
- package/lib/cjs/identity/secp256k1/index.d.ts +51 -1
- package/lib/cjs/identity/secp256k1/index.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/index.js +51 -1
- package/lib/cjs/identity/secp256k1/index.js.map +1 -1
- package/lib/cjs/identity/secp256k1/pem.d.ts +7 -0
- package/lib/cjs/identity/secp256k1/pem.d.ts.map +1 -0
- package/lib/cjs/identity/secp256k1/pem.js +75 -0
- package/lib/cjs/identity/secp256k1/pem.js.map +1 -0
- package/lib/cjs/identity/secp256k1/secp256k1.d.ts +87 -0
- package/lib/cjs/identity/secp256k1/secp256k1.d.ts.map +1 -0
- package/lib/cjs/identity/secp256k1/secp256k1.js +260 -0
- package/lib/cjs/identity/secp256k1/secp256k1.js.map +1 -0
- package/lib/cjs/principal/index.d.ts +18 -1
- package/lib/cjs/principal/index.d.ts.map +1 -1
- package/lib/cjs/principal/index.js +22 -1
- package/lib/cjs/principal/index.js.map +1 -1
- package/lib/cjs/principal/principal.d.ts +50 -0
- package/lib/cjs/principal/principal.d.ts.map +1 -0
- package/lib/cjs/principal/principal.js +148 -0
- package/lib/cjs/principal/principal.js.map +1 -0
- package/lib/cjs/principal/utils/base32.d.ts +10 -0
- package/lib/cjs/principal/utils/base32.d.ts.map +1 -0
- package/lib/cjs/principal/utils/base32.js +90 -0
- package/lib/cjs/principal/utils/base32.js.map +1 -0
- package/lib/cjs/principal/utils/getCrc.d.ts +6 -0
- package/lib/cjs/principal/utils/getCrc.d.ts.map +1 -0
- package/lib/cjs/principal/utils/getCrc.js +53 -0
- package/lib/cjs/principal/utils/getCrc.js.map +1 -0
- package/lib/esm/agent/actor.d.ts +203 -0
- package/lib/esm/agent/actor.d.ts.map +1 -0
- package/lib/esm/agent/actor.js +337 -0
- package/lib/esm/agent/actor.js.map +1 -0
- package/lib/esm/agent/agent/api.d.ts +216 -0
- package/lib/esm/agent/agent/api.d.ts.map +1 -0
- package/lib/esm/agent/agent/api.js +34 -0
- package/lib/esm/agent/agent/api.js.map +1 -0
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts +37 -0
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -0
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js +48 -0
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -0
- package/lib/esm/agent/agent/http/index.d.ts +190 -0
- package/lib/esm/agent/agent/http/index.d.ts.map +1 -0
- package/lib/esm/agent/agent/http/index.js +1117 -0
- package/lib/esm/agent/agent/http/index.js.map +1 -0
- package/lib/esm/agent/agent/http/transforms.d.ts +54 -0
- package/lib/esm/agent/agent/http/transforms.d.ts.map +1 -0
- package/lib/esm/agent/agent/http/transforms.js +128 -0
- package/lib/esm/agent/agent/http/transforms.js.map +1 -0
- package/lib/esm/agent/agent/http/types.d.ts +81 -0
- package/lib/esm/agent/agent/http/types.d.ts.map +1 -0
- package/lib/esm/agent/agent/http/types.js +39 -0
- package/lib/esm/agent/agent/http/types.js.map +1 -0
- package/lib/esm/agent/agent/index.d.ts +3 -0
- package/lib/esm/agent/agent/index.d.ts.map +1 -0
- package/lib/esm/agent/agent/index.js +3 -0
- package/lib/esm/agent/agent/index.js.map +1 -0
- package/lib/esm/agent/auth.d.ts +91 -0
- package/lib/esm/agent/auth.d.ts.map +1 -0
- package/lib/esm/agent/auth.js +59 -0
- package/lib/esm/agent/auth.js.map +1 -0
- package/lib/esm/agent/canister-env/index.d.ts +111 -1
- package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
- package/lib/esm/agent/canister-env/index.js +111 -1
- package/lib/esm/agent/canister-env/index.js.map +1 -1
- package/lib/esm/agent/canisterStatus/index.d.ts +61 -0
- package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -0
- package/lib/esm/agent/canisterStatus/index.js +199 -0
- package/lib/esm/agent/canisterStatus/index.js.map +1 -0
- package/lib/esm/agent/cbor.d.ts +26 -0
- package/lib/esm/agent/cbor.d.ts.map +1 -0
- package/lib/esm/agent/cbor.js +54 -0
- package/lib/esm/agent/cbor.js.map +1 -0
- package/lib/esm/agent/certificate.d.ts +286 -0
- package/lib/esm/agent/certificate.d.ts.map +1 -0
- package/lib/esm/agent/certificate.js +712 -0
- package/lib/esm/agent/certificate.js.map +1 -0
- package/lib/esm/agent/constants.d.ts +18 -0
- package/lib/esm/agent/constants.d.ts.map +1 -0
- package/lib/esm/agent/constants.js +19 -0
- package/lib/esm/agent/constants.js.map +1 -0
- package/lib/esm/agent/der.d.ts +34 -0
- package/lib/esm/agent/der.d.ts.map +1 -0
- package/lib/esm/agent/der.js +166 -0
- package/lib/esm/agent/der.js.map +1 -0
- package/lib/esm/agent/errors.d.ts +386 -0
- package/lib/esm/agent/errors.d.ts.map +1 -0
- package/lib/esm/agent/errors.js +689 -0
- package/lib/esm/agent/errors.js.map +1 -0
- package/lib/esm/agent/fetch_candid.d.ts +9 -0
- package/lib/esm/agent/fetch_candid.d.ts.map +1 -0
- package/lib/esm/agent/fetch_candid.js +33 -0
- package/lib/esm/agent/fetch_candid.js.map +1 -0
- package/lib/esm/agent/index.d.ts +125 -1
- package/lib/esm/agent/index.d.ts.map +1 -1
- package/lib/esm/agent/index.js +125 -1
- package/lib/esm/agent/index.js.map +1 -1
- package/lib/esm/agent/observable.d.ts +24 -0
- package/lib/esm/agent/observable.d.ts.map +1 -0
- package/lib/esm/agent/observable.js +29 -0
- package/lib/esm/agent/observable.js.map +1 -0
- package/lib/esm/agent/polling/backoff.d.ts +50 -0
- package/lib/esm/agent/polling/backoff.d.ts.map +1 -0
- package/lib/esm/agent/polling/backoff.js +85 -0
- package/lib/esm/agent/polling/backoff.js.map +1 -0
- package/lib/esm/agent/polling/index.d.ts +63 -0
- package/lib/esm/agent/polling/index.d.ts.map +1 -0
- package/lib/esm/agent/polling/index.js +144 -0
- package/lib/esm/agent/polling/index.js.map +1 -0
- package/lib/esm/agent/polling/strategy.d.ts +52 -0
- package/lib/esm/agent/polling/strategy.d.ts.map +1 -0
- package/lib/esm/agent/polling/strategy.js +94 -0
- package/lib/esm/agent/polling/strategy.js.map +1 -0
- package/lib/esm/agent/public_key.d.ts +16 -0
- package/lib/esm/agent/public_key.d.ts.map +1 -0
- package/lib/esm/agent/public_key.js +48 -0
- package/lib/esm/agent/public_key.js.map +1 -0
- package/lib/esm/agent/request_id.d.ts +24 -0
- package/lib/esm/agent/request_id.d.ts.map +1 -0
- package/lib/esm/agent/request_id.js +83 -0
- package/lib/esm/agent/request_id.js.map +1 -0
- 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/bls.d.ts +10 -0
- package/lib/esm/agent/utils/bls.d.ts.map +1 -0
- package/lib/esm/agent/utils/bls.js +17 -0
- package/lib/esm/agent/utils/bls.js.map +1 -0
- package/lib/esm/agent/utils/buffer.d.ts +22 -0
- package/lib/esm/agent/utils/buffer.d.ts.map +1 -0
- package/lib/esm/agent/utils/buffer.js +50 -0
- package/lib/esm/agent/utils/buffer.js.map +1 -0
- package/lib/esm/agent/utils/expirableMap.d.ts +80 -0
- package/lib/esm/agent/utils/expirableMap.d.ts.map +1 -0
- package/lib/esm/agent/utils/expirableMap.js +144 -0
- package/lib/esm/agent/utils/expirableMap.js.map +1 -0
- package/lib/esm/agent/utils/leb.d.ts +3 -0
- package/lib/esm/agent/utils/leb.d.ts.map +1 -0
- package/lib/esm/agent/utils/leb.js +12 -0
- package/lib/esm/agent/utils/leb.js.map +1 -0
- package/lib/esm/agent/utils/random.d.ts +6 -0
- package/lib/esm/agent/utils/random.d.ts.map +1 -0
- package/lib/esm/agent/utils/random.js +25 -0
- package/lib/esm/agent/utils/random.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/candid-core.d.ts +72 -0
- package/lib/esm/candid/candid-core.d.ts.map +1 -0
- package/lib/esm/candid/candid-core.js +241 -0
- package/lib/esm/candid/candid-core.js.map +1 -0
- package/lib/esm/candid/candid-ui.d.ts +35 -0
- package/lib/esm/candid/candid-ui.d.ts.map +1 -0
- package/lib/esm/candid/candid-ui.js +272 -0
- package/lib/esm/candid/candid-ui.js.map +1 -0
- package/lib/esm/candid/idl.d.ts +579 -0
- package/lib/esm/candid/idl.d.ts.map +1 -0
- package/lib/esm/candid/idl.js +2189 -0
- package/lib/esm/candid/idl.js.map +1 -0
- package/lib/esm/candid/index.d.ts +30 -1
- package/lib/esm/candid/index.d.ts.map +1 -1
- package/lib/esm/candid/index.js +29 -1
- package/lib/esm/candid/index.js.map +1 -1
- package/lib/esm/candid/types.d.ts +6 -0
- package/lib/esm/candid/types.d.ts.map +1 -0
- package/lib/esm/candid/types.js +3 -0
- package/lib/esm/candid/types.js.map +1 -0
- package/lib/esm/candid/utils/bigint-math.d.ts +14 -0
- package/lib/esm/candid/utils/bigint-math.d.ts.map +1 -0
- package/lib/esm/candid/utils/bigint-math.js +26 -0
- package/lib/esm/candid/utils/bigint-math.js.map +1 -0
- package/lib/esm/candid/utils/buffer.d.ts +86 -0
- package/lib/esm/candid/utils/buffer.d.ts.map +1 -0
- package/lib/esm/candid/utils/buffer.js +182 -0
- package/lib/esm/candid/utils/buffer.js.map +1 -0
- package/lib/esm/candid/utils/hash.d.ts +7 -0
- package/lib/esm/candid/utils/hash.d.ts.map +1 -0
- package/lib/esm/candid/utils/hash.js +30 -0
- package/lib/esm/candid/utils/hash.js.map +1 -0
- package/lib/esm/candid/utils/leb128.d.ts +65 -0
- package/lib/esm/candid/utils/leb128.d.ts.map +1 -0
- package/lib/esm/candid/utils/leb128.js +216 -0
- package/lib/esm/candid/utils/leb128.js.map +1 -0
- package/lib/esm/identity/identity/delegation.d.ts +164 -0
- package/lib/esm/identity/identity/delegation.d.ts.map +1 -0
- package/lib/esm/identity/identity/delegation.js +294 -0
- package/lib/esm/identity/identity/delegation.js.map +1 -0
- package/lib/esm/identity/identity/ecdsa.d.ts +62 -0
- package/lib/esm/identity/identity/ecdsa.d.ts.map +1 -0
- package/lib/esm/identity/identity/ecdsa.js +112 -0
- package/lib/esm/identity/identity/ecdsa.js.map +1 -0
- package/lib/esm/identity/identity/ed25519.d.ts +67 -0
- package/lib/esm/identity/identity/ed25519.d.ts.map +1 -0
- package/lib/esm/identity/identity/ed25519.js +195 -0
- package/lib/esm/identity/identity/ed25519.js.map +1 -0
- package/lib/esm/identity/identity/partial.d.ts +34 -0
- package/lib/esm/identity/identity/partial.d.ts.map +1 -0
- package/lib/esm/identity/identity/partial.js +50 -0
- package/lib/esm/identity/identity/partial.js.map +1 -0
- package/lib/esm/identity/identity/webauthn.d.ts +51 -0
- package/lib/esm/identity/identity/webauthn.d.ts.map +1 -0
- package/lib/esm/identity/identity/webauthn.js +192 -0
- package/lib/esm/identity/identity/webauthn.js.map +1 -0
- package/lib/esm/identity/index.d.ts +38 -1
- package/lib/esm/identity/index.d.ts.map +1 -1
- package/lib/esm/identity/index.js +38 -1
- package/lib/esm/identity/index.js.map +1 -1
- package/lib/esm/identity/secp256k1/der.d.ts +33 -0
- package/lib/esm/identity/secp256k1/der.d.ts.map +1 -0
- package/lib/esm/identity/secp256k1/der.js +156 -0
- package/lib/esm/identity/secp256k1/der.js.map +1 -0
- package/lib/esm/identity/secp256k1/index.d.ts +51 -1
- package/lib/esm/identity/secp256k1/index.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/index.js +51 -1
- package/lib/esm/identity/secp256k1/index.js.map +1 -1
- package/lib/esm/identity/secp256k1/pem.d.ts +7 -0
- package/lib/esm/identity/secp256k1/pem.d.ts.map +1 -0
- package/lib/esm/identity/secp256k1/pem.js +39 -0
- package/lib/esm/identity/secp256k1/pem.js.map +1 -0
- package/lib/esm/identity/secp256k1/secp256k1.d.ts +87 -0
- package/lib/esm/identity/secp256k1/secp256k1.d.ts.map +1 -0
- package/lib/esm/identity/secp256k1/secp256k1.js +222 -0
- package/lib/esm/identity/secp256k1/secp256k1.js.map +1 -0
- package/lib/esm/principal/index.d.ts +18 -1
- package/lib/esm/principal/index.d.ts.map +1 -1
- package/lib/esm/principal/index.js +18 -1
- package/lib/esm/principal/index.js.map +1 -1
- package/lib/esm/principal/principal.d.ts +50 -0
- package/lib/esm/principal/principal.d.ts.map +1 -0
- package/lib/esm/principal/principal.js +144 -0
- package/lib/esm/principal/principal.js.map +1 -0
- package/lib/esm/principal/utils/base32.d.ts +10 -0
- package/lib/esm/principal/utils/base32.d.ts.map +1 -0
- package/lib/esm/principal/utils/base32.js +86 -0
- package/lib/esm/principal/utils/base32.js.map +1 -0
- package/lib/esm/principal/utils/getCrc.d.ts +6 -0
- package/lib/esm/principal/utils/getCrc.d.ts.map +1 -0
- package/lib/esm/principal/utils/getCrc.js +50 -0
- package/lib/esm/principal/utils/getCrc.js.map +1 -0
- package/package.json +17 -11
- package/src/agent/actor.ts +576 -0
- package/src/agent/agent/api.ts +262 -0
- package/src/agent/agent/http/index.ts +1518 -0
- package/src/agent/agent/http/transforms.ts +158 -0
- package/src/agent/agent/http/types.ts +126 -0
- package/src/agent/agent/index.ts +2 -0
- package/src/agent/auth.ts +147 -0
- package/src/agent/canister-env/index.ts +192 -1
- package/src/agent/canisterStatus/index.ts +267 -0
- package/src/agent/cbor.ts +63 -0
- package/src/agent/certificate.ts +1060 -0
- package/src/agent/constants.ts +24 -0
- package/src/agent/der.ts +170 -0
- package/src/agent/errors.ts +881 -0
- package/src/agent/fetch_candid.ts +37 -0
- package/src/agent/index.ts +131 -1
- package/src/agent/observable.ts +49 -0
- package/src/agent/polling/backoff.ts +130 -0
- package/src/agent/polling/index.ts +250 -0
- package/src/agent/polling/strategy.ts +144 -0
- package/src/agent/public_key.ts +65 -0
- package/src/agent/request_id.ts +92 -0
- package/src/agent/subnetStatus/index.ts +270 -0
- package/src/agent/utils/bls.ts +18 -0
- package/src/agent/utils/buffer.ts +60 -0
- package/src/agent/utils/expirableMap.ts +163 -0
- package/src/agent/utils/leb.ts +14 -0
- package/src/agent/utils/random.ts +30 -0
- package/src/agent/utils/readState.ts +180 -0
- package/src/candid/candid-core.ts +276 -0
- package/src/candid/candid-ui.ts +289 -0
- package/src/candid/idl.ts +2556 -0
- package/src/candid/index.ts +35 -1
- package/src/candid/types.ts +7 -0
- package/src/candid/utils/bigint-math.ts +26 -0
- package/src/candid/utils/buffer.ts +221 -0
- package/src/candid/utils/hash.ts +31 -0
- package/src/candid/utils/leb128.ts +234 -0
- package/src/identity/identity/delegation.ts +411 -0
- package/src/identity/identity/ecdsa.ts +158 -0
- package/src/identity/identity/ed25519.ts +239 -0
- package/src/identity/identity/partial.ts +60 -0
- package/src/identity/identity/webauthn.ts +265 -0
- package/src/identity/index.ts +39 -1
- package/src/identity/secp256k1/der.ts +156 -0
- package/src/identity/secp256k1/index.ts +52 -1
- package/src/identity/secp256k1/pem.ts +40 -0
- package/src/identity/secp256k1/secp256k1.ts +270 -0
- package/src/package.json +4 -0
- package/src/principal/index.ts +19 -1
- package/src/principal/principal.ts +171 -0
- package/src/principal/utils/base32.ts +101 -0
- package/src/principal/utils/getCrc.ts +52 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const encodeLenBytes: (len: number) => number;
|
|
2
|
+
export declare const encodeLen: (buf: Uint8Array, offset: number, len: number) => number;
|
|
3
|
+
export declare const decodeLenBytes: (buf: Uint8Array, offset: number) => number;
|
|
4
|
+
export declare const decodeLen: (buf: Uint8Array, offset: number) => number;
|
|
5
|
+
/**
|
|
6
|
+
* A DER encoded `SEQUENCE(OID)` for DER-encoded-COSE
|
|
7
|
+
*/
|
|
8
|
+
export declare const DER_COSE_OID: Uint8Array<ArrayBuffer>;
|
|
9
|
+
/**
|
|
10
|
+
* A DER encoded `SEQUENCE(OID)` for the Ed25519 algorithm
|
|
11
|
+
*/
|
|
12
|
+
export declare const ED25519_OID: Uint8Array<ArrayBuffer>;
|
|
13
|
+
/**
|
|
14
|
+
* A DER encoded `SEQUENCE(OID)` for secp256k1 with the ECDSA algorithm
|
|
15
|
+
*/
|
|
16
|
+
export declare const SECP256K1_OID: Uint8Array<ArrayBuffer>;
|
|
17
|
+
/**
|
|
18
|
+
* Wraps the given `payload` in a DER encoding tagged with the given encoded `oid` like so:
|
|
19
|
+
* `SEQUENCE(oid, BITSTRING(payload))`
|
|
20
|
+
* @param payload The payload to encode as the bit string
|
|
21
|
+
* @param oid The DER encoded (and SEQUENCE wrapped!) OID to tag the payload with
|
|
22
|
+
*/
|
|
23
|
+
export declare function wrapDER(payload: Uint8Array, oid: Uint8Array): Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Extracts a payload from the given `derEncoded` data, and checks that it was tagged with the given `oid`.
|
|
26
|
+
*
|
|
27
|
+
* `derEncoded = SEQUENCE(oid, BITSTRING(payload))`
|
|
28
|
+
* @param derEncoded The DER encoded and tagged data
|
|
29
|
+
* @param oid The DER encoded (and SEQUENCE wrapped!) expected OID
|
|
30
|
+
* @returns The unwrapped payload
|
|
31
|
+
*/
|
|
32
|
+
export declare const unwrapDER: (derEncoded: Uint8Array, oid: Uint8Array) => Uint8Array;
|
|
33
|
+
//# sourceMappingURL=der.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"der.d.ts","sourceRoot":"","sources":["../../../../src/identity/secp256k1/der.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAY5C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,KAAK,UAAU,EAAE,QAAQ,MAAM,EAAE,KAAK,MAAM,KAAG,MAsBxE,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,UAAU,EAAE,QAAQ,MAAM,KAAG,MAOhE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,KAAK,UAAU,EAAE,QAAQ,MAAM,KAAG,MAQ3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,yBAIvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW,yBAItB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,yBAMxB,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAuBxE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,YAAY,UAAU,EAAE,KAAK,UAAU,KAAG,UA4BnE,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { uint8Equals } from '../../candid/index.js';
|
|
2
|
+
export const encodeLenBytes = (len) => {
|
|
3
|
+
if (len <= 0x7f) {
|
|
4
|
+
return 1;
|
|
5
|
+
}
|
|
6
|
+
else if (len <= 0xff) {
|
|
7
|
+
return 2;
|
|
8
|
+
}
|
|
9
|
+
else if (len <= 0xffff) {
|
|
10
|
+
return 3;
|
|
11
|
+
}
|
|
12
|
+
else if (len <= 0xffffff) {
|
|
13
|
+
return 4;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
throw new Error('Length too long (> 4 bytes)');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const encodeLen = (buf, offset, len) => {
|
|
20
|
+
if (len <= 0x7f) {
|
|
21
|
+
buf[offset] = len;
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
24
|
+
else if (len <= 0xff) {
|
|
25
|
+
buf[offset] = 0x81;
|
|
26
|
+
buf[offset + 1] = len;
|
|
27
|
+
return 2;
|
|
28
|
+
}
|
|
29
|
+
else if (len <= 0xffff) {
|
|
30
|
+
buf[offset] = 0x82;
|
|
31
|
+
buf[offset + 1] = len >> 8;
|
|
32
|
+
buf[offset + 2] = len;
|
|
33
|
+
return 3;
|
|
34
|
+
}
|
|
35
|
+
else if (len <= 0xffffff) {
|
|
36
|
+
buf[offset] = 0x83;
|
|
37
|
+
buf[offset + 1] = len >> 16;
|
|
38
|
+
buf[offset + 2] = len >> 8;
|
|
39
|
+
buf[offset + 3] = len;
|
|
40
|
+
return 4;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new Error('Length too long (> 4 bytes)');
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export const decodeLenBytes = (buf, offset) => {
|
|
47
|
+
if (buf[offset] < 0x80)
|
|
48
|
+
return 1;
|
|
49
|
+
if (buf[offset] === 0x80)
|
|
50
|
+
throw new Error('Invalid length 0');
|
|
51
|
+
if (buf[offset] === 0x81)
|
|
52
|
+
return 2;
|
|
53
|
+
if (buf[offset] === 0x82)
|
|
54
|
+
return 3;
|
|
55
|
+
if (buf[offset] === 0x83)
|
|
56
|
+
return 4;
|
|
57
|
+
throw new Error('Length too long (> 4 bytes)');
|
|
58
|
+
};
|
|
59
|
+
export const decodeLen = (buf, offset) => {
|
|
60
|
+
const lenBytes = decodeLenBytes(buf, offset);
|
|
61
|
+
if (lenBytes === 1)
|
|
62
|
+
return buf[offset];
|
|
63
|
+
else if (lenBytes === 2)
|
|
64
|
+
return buf[offset + 1];
|
|
65
|
+
else if (lenBytes === 3)
|
|
66
|
+
return (buf[offset + 1] << 8) + buf[offset + 2];
|
|
67
|
+
else if (lenBytes === 4)
|
|
68
|
+
return (buf[offset + 1] << 16) + (buf[offset + 2] << 8) + buf[offset + 3];
|
|
69
|
+
throw new Error('Length too long (> 4 bytes)');
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* A DER encoded `SEQUENCE(OID)` for DER-encoded-COSE
|
|
73
|
+
*/
|
|
74
|
+
export const DER_COSE_OID = Uint8Array.from([
|
|
75
|
+
...[0x30, 0x0c], // SEQUENCE
|
|
76
|
+
...[0x06, 0x0a], // OID with 10 bytes
|
|
77
|
+
...[0x2b, 0x06, 0x01, 0x04, 0x01, 0x83, 0xb8, 0x43, 0x01, 0x01], // DER encoded COSE
|
|
78
|
+
]);
|
|
79
|
+
/**
|
|
80
|
+
* A DER encoded `SEQUENCE(OID)` for the Ed25519 algorithm
|
|
81
|
+
*/
|
|
82
|
+
export const ED25519_OID = Uint8Array.from([
|
|
83
|
+
...[0x30, 0x05], // SEQUENCE
|
|
84
|
+
...[0x06, 0x03], // OID with 3 bytes
|
|
85
|
+
...[0x2b, 0x65, 0x70], // id-Ed25519 OID
|
|
86
|
+
]);
|
|
87
|
+
/**
|
|
88
|
+
* A DER encoded `SEQUENCE(OID)` for secp256k1 with the ECDSA algorithm
|
|
89
|
+
*/
|
|
90
|
+
export const SECP256K1_OID = Uint8Array.from([
|
|
91
|
+
...[0x30, 0x10], // SEQUENCE
|
|
92
|
+
...[0x06, 0x07], // OID with 7 bytes
|
|
93
|
+
...[0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01], // OID ECDSA
|
|
94
|
+
...[0x06, 0x05], // OID with 5 bytes
|
|
95
|
+
...[0x2b, 0x81, 0x04, 0x00, 0x0a], // OID secp256k1
|
|
96
|
+
]);
|
|
97
|
+
/**
|
|
98
|
+
* Wraps the given `payload` in a DER encoding tagged with the given encoded `oid` like so:
|
|
99
|
+
* `SEQUENCE(oid, BITSTRING(payload))`
|
|
100
|
+
* @param payload The payload to encode as the bit string
|
|
101
|
+
* @param oid The DER encoded (and SEQUENCE wrapped!) OID to tag the payload with
|
|
102
|
+
*/
|
|
103
|
+
export function wrapDER(payload, oid) {
|
|
104
|
+
// The Bit String header needs to include the unused bit count byte in its length
|
|
105
|
+
const bitStringHeaderLength = 2 + encodeLenBytes(payload.byteLength + 1);
|
|
106
|
+
const len = oid.byteLength + bitStringHeaderLength + payload.byteLength;
|
|
107
|
+
let offset = 0;
|
|
108
|
+
const buf = new Uint8Array(1 + encodeLenBytes(len) + len);
|
|
109
|
+
// Sequence
|
|
110
|
+
buf[offset++] = 0x30;
|
|
111
|
+
// Sequence Length
|
|
112
|
+
offset += encodeLen(buf, offset, len);
|
|
113
|
+
// OID
|
|
114
|
+
buf.set(oid, offset);
|
|
115
|
+
offset += oid.byteLength;
|
|
116
|
+
// Bit String Header
|
|
117
|
+
buf[offset++] = 0x03;
|
|
118
|
+
offset += encodeLen(buf, offset, payload.byteLength + 1);
|
|
119
|
+
// 0 padding
|
|
120
|
+
buf[offset++] = 0x00;
|
|
121
|
+
buf.set(new Uint8Array(payload), offset);
|
|
122
|
+
return buf;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Extracts a payload from the given `derEncoded` data, and checks that it was tagged with the given `oid`.
|
|
126
|
+
*
|
|
127
|
+
* `derEncoded = SEQUENCE(oid, BITSTRING(payload))`
|
|
128
|
+
* @param derEncoded The DER encoded and tagged data
|
|
129
|
+
* @param oid The DER encoded (and SEQUENCE wrapped!) expected OID
|
|
130
|
+
* @returns The unwrapped payload
|
|
131
|
+
*/
|
|
132
|
+
export const unwrapDER = (derEncoded, oid) => {
|
|
133
|
+
let offset = 0;
|
|
134
|
+
const expect = (n, msg) => {
|
|
135
|
+
if (buf[offset++] !== n) {
|
|
136
|
+
throw new Error('Expected: ' + msg);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const buf = new Uint8Array(derEncoded);
|
|
140
|
+
expect(0x30, 'sequence');
|
|
141
|
+
offset += decodeLenBytes(buf, offset);
|
|
142
|
+
if (!uint8Equals(buf.slice(offset, offset + oid.byteLength), oid)) {
|
|
143
|
+
throw new Error('Not the expected OID.');
|
|
144
|
+
}
|
|
145
|
+
offset += oid.byteLength;
|
|
146
|
+
expect(0x03, 'bit string');
|
|
147
|
+
const payloadLen = decodeLen(buf, offset) - 1; // Subtracting 1 to account for the 0 padding
|
|
148
|
+
offset += decodeLenBytes(buf, offset);
|
|
149
|
+
expect(0x00, '0 padding');
|
|
150
|
+
const result = buf.slice(offset);
|
|
151
|
+
if (payloadLen !== result.length) {
|
|
152
|
+
throw new Error(`DER payload mismatch: Expected length ${payloadLen} actual length ${result.length}`);
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=der.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"der.js","sourceRoot":"","sources":["../../../../src/identity/secp256k1/der.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IACpD,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAe,EAAE,MAAc,EAAE,GAAW,EAAU,EAAE;IAChF,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC;QAClB,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QACnB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;QACtB,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,GAAG,C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AC,GAAG,EAAE,MAAM,CAAC,CAAC;IACtC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC1B,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,UAAU,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,yCAAyC,UAAU,kBAAkB,MAAM,CAAC,MAAM,EAAE,CACrF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,2 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
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
|
|
50
|
+
*/
|
|
51
|
+
export * from './secp256k1.ts';
|
|
2
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,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/identity/secp256k1/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,2 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
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
|
|
50
|
+
*/
|
|
51
|
+
export * from "./secp256k1.js";
|
|
2
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/identity/secp256k1/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/identity/secp256k1/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +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,CA6BtD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as asn1js from 'asn1js';
|
|
2
|
+
const HEADER = `-----BEGIN EC PRIVATE KEY-----`;
|
|
3
|
+
const FOOTER = `-----END EC PRIVATE KEY-----`;
|
|
4
|
+
/**
|
|
5
|
+
* Parse a PEM-encoded key into a Uint8Array
|
|
6
|
+
* @param pem - the PEM-encoded key
|
|
7
|
+
* @returns secret key as a Uint8Array
|
|
8
|
+
*/
|
|
9
|
+
export function pemToSecretKey(pem) {
|
|
10
|
+
const lines = pem.trim().split('\n');
|
|
11
|
+
const header = lines[0].trim();
|
|
12
|
+
const footer = lines[lines.length - 1].trim();
|
|
13
|
+
if (lines.length < 3) {
|
|
14
|
+
throw new Error('Invalid PEM format');
|
|
15
|
+
}
|
|
16
|
+
if (!header.startsWith(HEADER)) {
|
|
17
|
+
throw new Error('Invalid PEM header');
|
|
18
|
+
}
|
|
19
|
+
if (!footer.startsWith(FOOTER)) {
|
|
20
|
+
throw new Error('Invalid PEM footer');
|
|
21
|
+
}
|
|
22
|
+
const base64Data = lines.slice(1, -1).join('').replace(/\r?\n/g, '');
|
|
23
|
+
const rawKey = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0));
|
|
24
|
+
// Parse the key as ASN.1 object
|
|
25
|
+
try {
|
|
26
|
+
const asn1 = asn1js.fromBER(rawKey);
|
|
27
|
+
// OID for secp256k1
|
|
28
|
+
if (!asn1.result.toString().includes(`OBJECT IDENTIFIER : 1.3.132.0.10`)) {
|
|
29
|
+
throw new Error('Invalid curve, must be secp256k1');
|
|
30
|
+
}
|
|
31
|
+
// Returns the 32-byte raw private key at the appropriate offset
|
|
32
|
+
return rawKey.slice(7, 39);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error(error);
|
|
36
|
+
throw new Error('Encountered error while parsing PEM key');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=pem.js.map
|
|
@@ -0,0 +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,KAA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
|
2
|
+
declare type PublicKeyHex = string;
|
|
3
|
+
declare type SecretKeyHex = string;
|
|
4
|
+
export declare type JsonableSecp256k1Identity = [PublicKeyHex, SecretKeyHex];
|
|
5
|
+
export declare class Secp256k1PublicKey implements PublicKey {
|
|
6
|
+
#private;
|
|
7
|
+
static fromRaw(rawKey: Uint8Array): Secp256k1PublicKey;
|
|
8
|
+
static fromDer(derKey: DerEncodedPublicKey): Secp256k1PublicKey;
|
|
9
|
+
/**
|
|
10
|
+
* Construct Secp256k1PublicKey from an existing PublicKey
|
|
11
|
+
* @param {unknown} maybeKey - existing PublicKey, ArrayBuffer, DerEncodedPublicKey, or hex string
|
|
12
|
+
* @returns {Secp256k1PublicKey} Instance of Secp256k1PublicKey
|
|
13
|
+
*/
|
|
14
|
+
static from(maybeKey: unknown): Secp256k1PublicKey;
|
|
15
|
+
private static derEncode;
|
|
16
|
+
private static derDecode;
|
|
17
|
+
get rawKey(): Uint8Array;
|
|
18
|
+
get derKey(): DerEncodedPublicKey;
|
|
19
|
+
private constructor();
|
|
20
|
+
toDer(): DerEncodedPublicKey;
|
|
21
|
+
toRaw(): Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
export declare class Secp256k1KeyIdentity extends SignIdentity {
|
|
24
|
+
protected _privateKey: Uint8Array;
|
|
25
|
+
/**
|
|
26
|
+
* Generates an identity. If a seed is provided, the keys are generated from the
|
|
27
|
+
* seed according to BIP 0032. Otherwise, the key pair is randomly generated.
|
|
28
|
+
* This method throws an error in case the seed is not 32 bytes long or invalid
|
|
29
|
+
* for use as a private key.
|
|
30
|
+
* @param {Uint8Array} seed the optional seed
|
|
31
|
+
* @returns {Secp256k1KeyIdentity} Secp256k1KeyIdentity
|
|
32
|
+
*/
|
|
33
|
+
static generate(seed?: Uint8Array): Secp256k1KeyIdentity;
|
|
34
|
+
static fromParsedJson(obj: JsonableSecp256k1Identity): Secp256k1KeyIdentity;
|
|
35
|
+
static fromJSON(json: string): Secp256k1KeyIdentity;
|
|
36
|
+
/**
|
|
37
|
+
* generates an identity from a public and private key. Please ensure that you are generating these keys securely and protect the user's private key
|
|
38
|
+
* @param {Uint8Array} publicKey - Uint8Array
|
|
39
|
+
* @param {Uint8Array} privateKey - Uint8Array
|
|
40
|
+
* @returns {Secp256k1KeyIdentity} Secp256k1KeyIdentity
|
|
41
|
+
*/
|
|
42
|
+
static fromKeyPair(publicKey: Uint8Array, privateKey: Uint8Array): Secp256k1KeyIdentity;
|
|
43
|
+
/**
|
|
44
|
+
* generates an identity from an existing secret key, and is the correct method to generate an identity from a seed phrase. Please ensure you protect the user's private key.
|
|
45
|
+
* @param {Uint8Array} secretKey - Uint8Array
|
|
46
|
+
* @returns {Secp256k1KeyIdentity} - Secp256k1KeyIdentity
|
|
47
|
+
*/
|
|
48
|
+
static fromSecretKey(secretKey: Uint8Array): Secp256k1KeyIdentity;
|
|
49
|
+
/**
|
|
50
|
+
* Generates an identity from a seed phrase. Use carefully - seed phrases should only be used in secure contexts, and you should avoid having users copying and pasting seed phrases as much as possible.
|
|
51
|
+
* @param {string | string[]} seedPhrase - either an array of words or a string of words separated by spaces.
|
|
52
|
+
* @param password - optional password to be used by bip39
|
|
53
|
+
* @returns Secp256k1KeyIdentity
|
|
54
|
+
*/
|
|
55
|
+
static fromSeedPhrase(seedPhrase: string | string[], password?: string | undefined): Secp256k1KeyIdentity;
|
|
56
|
+
/**
|
|
57
|
+
* Utility method to create a Secp256k1KeyIdentity from a PEM-encoded key.
|
|
58
|
+
* @param pemKey - PEM-encoded key as a string
|
|
59
|
+
* @returns - Secp256k1KeyIdentity
|
|
60
|
+
*/
|
|
61
|
+
static fromPem(pemKey: string): Secp256k1KeyIdentity;
|
|
62
|
+
_publicKey: Secp256k1PublicKey;
|
|
63
|
+
protected constructor(publicKey: Secp256k1PublicKey, _privateKey: Uint8Array);
|
|
64
|
+
/**
|
|
65
|
+
* Serialize this key to JSON-serializable object.
|
|
66
|
+
* @returns {JsonableSecp256k1Identity} JsonableSecp256k1Identity
|
|
67
|
+
*/
|
|
68
|
+
toJSON(): JsonableSecp256k1Identity;
|
|
69
|
+
/**
|
|
70
|
+
* Return a copy of the key pair.
|
|
71
|
+
* @returns {KeyPair} KeyPair
|
|
72
|
+
*/
|
|
73
|
+
getKeyPair(): KeyPair;
|
|
74
|
+
/**
|
|
75
|
+
* Return the public key.
|
|
76
|
+
* @returns {Required<PublicKey>} Required<PublicKey>
|
|
77
|
+
*/
|
|
78
|
+
getPublicKey(): Required<PublicKey>;
|
|
79
|
+
/**
|
|
80
|
+
* Signs a blob of data, with this identity's private key.
|
|
81
|
+
* @param {Uint8Array} data - bytes to hash and sign with this identity's secretKey, producing a signature
|
|
82
|
+
* @returns {Promise<Signature>} signature
|
|
83
|
+
*/
|
|
84
|
+
sign(data: Uint8Array): Promise<Signature>;
|
|
85
|
+
}
|
|
86
|
+
export default Secp256k1KeyIdentity;
|
|
87
|
+
//# sourceMappingURL=secp256k1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secp256k1.d.ts","sourceRoot":"","sources":["../../../../src/identity/secp256k1/secp256k1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,SAAS,EACd,YAAY,EACb,MAAM,QAAQ,CAAC;AAUhB,OAAO,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,OAAO,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,MAAM,CAAC,OAAO,MAAM,yBAAyB,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AAQ7E,qBAAa,kBAAmB,YAAW,SAAS;;WACpC,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,kBAAkB;WAI/C,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,kBAAkB;IAItE;;;;OAIG;WACW,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB;IAwBzD,OAAO,CAAC,MAAM,CAAC,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