@icp-sdk/core 4.2.3 → 5.0.0-beta.0
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 +7 -0
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -0
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js +19 -0
- package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -0
- package/lib/cjs/agent/agent/http/index.d.ts +171 -0
- package/lib/cjs/agent/agent/http/index.d.ts.map +1 -0
- package/lib/cjs/agent/agent/http/index.js +1079 -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 +93 -0
- package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -0
- package/lib/cjs/agent/canisterStatus/index.js +301 -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 +228 -0
- package/lib/cjs/agent/certificate.d.ts.map +1 -0
- package/lib/cjs/agent/certificate.js +591 -0
- package/lib/cjs/agent/certificate.js.map +1 -0
- package/lib/cjs/agent/constants.d.ts +14 -0
- package/lib/cjs/agent/constants.d.ts.map +1 -0
- package/lib/cjs/agent/constants.js +18 -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 +380 -0
- package/lib/cjs/agent/errors.d.ts.map +1 -0
- package/lib/cjs/agent/errors.js +733 -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 +31 -1
- package/lib/cjs/agent/index.d.ts.map +1 -1
- package/lib/cjs/agent/index.js +59 -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/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/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 +11 -1
- package/lib/cjs/candid/index.d.ts.map +1 -1
- package/lib/cjs/candid/index.js +33 -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 +15 -1
- package/lib/cjs/identity/index.d.ts.map +1 -1
- package/lib/cjs/identity/index.js +24 -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 +4 -1
- package/lib/cjs/identity/secp256k1/index.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/index.js +4 -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 +3 -1
- package/lib/cjs/principal/index.d.ts.map +1 -1
- package/lib/cjs/principal/index.js +7 -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 +7 -0
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -0
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js +16 -0
- package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -0
- package/lib/esm/agent/agent/http/index.d.ts +171 -0
- package/lib/esm/agent/agent/http/index.d.ts.map +1 -0
- package/lib/esm/agent/agent/http/index.js +1037 -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 +110 -1
- package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
- package/lib/esm/agent/canister-env/index.js +110 -1
- package/lib/esm/agent/canister-env/index.js.map +1 -1
- package/lib/esm/agent/canisterStatus/index.d.ts +93 -0
- package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -0
- package/lib/esm/agent/canisterStatus/index.js +261 -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 +228 -0
- package/lib/esm/agent/certificate.d.ts.map +1 -0
- package/lib/esm/agent/certificate.js +545 -0
- package/lib/esm/agent/certificate.js.map +1 -0
- package/lib/esm/agent/constants.d.ts +14 -0
- package/lib/esm/agent/constants.d.ts.map +1 -0
- package/lib/esm/agent/constants.js +15 -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 +380 -0
- package/lib/esm/agent/errors.d.ts.map +1 -0
- package/lib/esm/agent/errors.js +678 -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 +31 -1
- package/lib/esm/agent/index.d.ts.map +1 -1
- package/lib/esm/agent/index.js +31 -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/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/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 +11 -1
- package/lib/esm/candid/index.d.ts.map +1 -1
- package/lib/esm/candid/index.js +10 -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 +15 -1
- package/lib/esm/identity/index.d.ts.map +1 -1
- package/lib/esm/identity/index.js +17 -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 +4 -1
- package/lib/esm/identity/secp256k1/index.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/index.js +4 -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 +3 -1
- package/lib/esm/principal/index.d.ts.map +1 -1
- package/lib/esm/principal/index.js +3 -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 +1405 -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 +191 -1
- package/src/agent/canisterStatus/index.ts +412 -0
- package/src/agent/cbor.ts +63 -0
- package/src/agent/certificate.ts +841 -0
- package/src/agent/constants.ts +19 -0
- package/src/agent/der.ts +170 -0
- package/src/agent/errors.ts +868 -0
- package/src/agent/fetch_candid.ts +37 -0
- package/src/agent/index.ts +37 -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/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/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 +16 -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 +19 -1
- package/src/identity/secp256k1/der.ts +156 -0
- package/src/identity/secp256k1/index.ts +5 -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 +3 -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,195 @@
|
|
|
1
|
+
import { SignIdentity, ED25519_OID, unwrapDER, wrapDER, } from '../../agent/index.js';
|
|
2
|
+
import { uint8Equals, uint8FromBufLike } from '../../candid/index.js';
|
|
3
|
+
import { ed25519 } from '@noble/curves/ed25519';
|
|
4
|
+
import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
|
|
5
|
+
function isObject(value) {
|
|
6
|
+
return value !== null && typeof value === 'object';
|
|
7
|
+
}
|
|
8
|
+
export class Ed25519PublicKey {
|
|
9
|
+
/**
|
|
10
|
+
* Construct Ed25519PublicKey from an existing PublicKey
|
|
11
|
+
* @param {unknown} maybeKey - existing PublicKey, ArrayBuffer, DerEncodedPublicKey, or hex string
|
|
12
|
+
* @returns {Ed25519PublicKey} Instance of Ed25519PublicKey
|
|
13
|
+
*/
|
|
14
|
+
static from(maybeKey) {
|
|
15
|
+
if (typeof maybeKey === 'string') {
|
|
16
|
+
const key = hexToBytes(maybeKey);
|
|
17
|
+
return this.fromRaw(key);
|
|
18
|
+
}
|
|
19
|
+
else if (isObject(maybeKey)) {
|
|
20
|
+
const key = maybeKey;
|
|
21
|
+
if (isObject(key) && Object.hasOwnProperty.call(key, '__derEncodedPublicKey__')) {
|
|
22
|
+
return this.fromDer(key);
|
|
23
|
+
}
|
|
24
|
+
else if (ArrayBuffer.isView(key)) {
|
|
25
|
+
const view = key;
|
|
26
|
+
return this.fromRaw(uint8FromBufLike(view.buffer));
|
|
27
|
+
}
|
|
28
|
+
else if (key instanceof ArrayBuffer) {
|
|
29
|
+
return this.fromRaw(uint8FromBufLike(key));
|
|
30
|
+
}
|
|
31
|
+
else if ('rawKey' in key && key.rawKey instanceof Uint8Array) {
|
|
32
|
+
return this.fromRaw(key.rawKey);
|
|
33
|
+
}
|
|
34
|
+
else if ('derKey' in key) {
|
|
35
|
+
return this.fromDer(key.derKey);
|
|
36
|
+
}
|
|
37
|
+
else if ('toDer' in key) {
|
|
38
|
+
return this.fromDer(key.toDer());
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
throw new Error('Cannot construct Ed25519PublicKey from the provided key.');
|
|
42
|
+
}
|
|
43
|
+
static fromRaw(rawKey) {
|
|
44
|
+
return new Ed25519PublicKey(rawKey);
|
|
45
|
+
}
|
|
46
|
+
static fromDer(derKey) {
|
|
47
|
+
return new Ed25519PublicKey(this.derDecode(derKey));
|
|
48
|
+
}
|
|
49
|
+
// The length of Ed25519 public keys is always 32 bytes.
|
|
50
|
+
static { this.RAW_KEY_LENGTH = 32; }
|
|
51
|
+
static derEncode(publicKey) {
|
|
52
|
+
const key = wrapDER(publicKey, ED25519_OID);
|
|
53
|
+
key.__derEncodedPublicKey__ = undefined;
|
|
54
|
+
return key;
|
|
55
|
+
}
|
|
56
|
+
static derDecode(key) {
|
|
57
|
+
const unwrapped = unwrapDER(key, ED25519_OID);
|
|
58
|
+
if (unwrapped.length !== this.RAW_KEY_LENGTH) {
|
|
59
|
+
throw new Error('An Ed25519 public key must be exactly 32bytes long');
|
|
60
|
+
}
|
|
61
|
+
return unwrapped;
|
|
62
|
+
}
|
|
63
|
+
#rawKey;
|
|
64
|
+
get rawKey() {
|
|
65
|
+
return this.#rawKey;
|
|
66
|
+
}
|
|
67
|
+
#derKey;
|
|
68
|
+
get derKey() {
|
|
69
|
+
return this.#derKey;
|
|
70
|
+
}
|
|
71
|
+
// `fromRaw` and `fromDer` should be used for instantiation, not this constructor.
|
|
72
|
+
constructor(key) {
|
|
73
|
+
if (key.byteLength !== Ed25519PublicKey.RAW_KEY_LENGTH) {
|
|
74
|
+
throw new Error('An Ed25519 public key must be exactly 32bytes long');
|
|
75
|
+
}
|
|
76
|
+
this.#rawKey = key;
|
|
77
|
+
this.#derKey = Ed25519PublicKey.derEncode(key);
|
|
78
|
+
}
|
|
79
|
+
toDer() {
|
|
80
|
+
return this.derKey;
|
|
81
|
+
}
|
|
82
|
+
toRaw() {
|
|
83
|
+
return this.rawKey;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Ed25519KeyIdentity is an implementation of SignIdentity that uses Ed25519 keys. This class is used to sign and verify messages for an agent.
|
|
88
|
+
*/
|
|
89
|
+
export class Ed25519KeyIdentity extends SignIdentity {
|
|
90
|
+
/**
|
|
91
|
+
* Generate a new Ed25519KeyIdentity.
|
|
92
|
+
* @param seed a 32-byte seed for the private key. If not provided, a random seed will be generated.
|
|
93
|
+
* @returns Ed25519KeyIdentity
|
|
94
|
+
*/
|
|
95
|
+
static generate(seed) {
|
|
96
|
+
if (seed && seed.length !== 32) {
|
|
97
|
+
throw new Error('Ed25519 Seed needs to be 32 bytes long.');
|
|
98
|
+
}
|
|
99
|
+
if (!seed)
|
|
100
|
+
seed = ed25519.utils.randomPrivateKey();
|
|
101
|
+
// Check if the seed is all zeros
|
|
102
|
+
if (uint8Equals(seed, new Uint8Array(new Array(32).fill(0)))) {
|
|
103
|
+
console.warn('Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.');
|
|
104
|
+
}
|
|
105
|
+
const sk = new Uint8Array(32);
|
|
106
|
+
for (let i = 0; i < 32; i++) {
|
|
107
|
+
sk[i] = seed[i];
|
|
108
|
+
}
|
|
109
|
+
const pk = ed25519.getPublicKey(sk);
|
|
110
|
+
return Ed25519KeyIdentity.fromKeyPair(pk, sk);
|
|
111
|
+
}
|
|
112
|
+
static fromParsedJson(obj) {
|
|
113
|
+
const [publicKeyDer, privateKeyRaw] = obj;
|
|
114
|
+
return new Ed25519KeyIdentity(Ed25519PublicKey.fromDer(hexToBytes(publicKeyDer)), hexToBytes(privateKeyRaw));
|
|
115
|
+
}
|
|
116
|
+
static fromJSON(json) {
|
|
117
|
+
const parsed = JSON.parse(json);
|
|
118
|
+
if (Array.isArray(parsed)) {
|
|
119
|
+
if (typeof parsed[0] === 'string' && typeof parsed[1] === 'string') {
|
|
120
|
+
return this.fromParsedJson([parsed[0], parsed[1]]);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
throw new Error('Deserialization error: JSON must have at least 2 items.');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(json)}`);
|
|
127
|
+
}
|
|
128
|
+
static fromKeyPair(publicKey, privateKey) {
|
|
129
|
+
return new Ed25519KeyIdentity(Ed25519PublicKey.fromRaw(publicKey), privateKey);
|
|
130
|
+
}
|
|
131
|
+
static fromSecretKey(secretKey) {
|
|
132
|
+
const publicKey = ed25519.getPublicKey(secretKey);
|
|
133
|
+
return Ed25519KeyIdentity.fromKeyPair(publicKey, secretKey);
|
|
134
|
+
}
|
|
135
|
+
#publicKey;
|
|
136
|
+
#privateKey;
|
|
137
|
+
// `fromRaw` and `fromDer` should be used for instantiation, not this constructor.
|
|
138
|
+
constructor(publicKey, privateKey) {
|
|
139
|
+
super();
|
|
140
|
+
this.#publicKey = Ed25519PublicKey.from(publicKey);
|
|
141
|
+
this.#privateKey = privateKey;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Serialize this key to JSON.
|
|
145
|
+
*/
|
|
146
|
+
toJSON() {
|
|
147
|
+
return [bytesToHex(this.#publicKey.toDer()), bytesToHex(this.#privateKey)];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Return a copy of the key pair.
|
|
151
|
+
*/
|
|
152
|
+
getKeyPair() {
|
|
153
|
+
return {
|
|
154
|
+
secretKey: this.#privateKey,
|
|
155
|
+
publicKey: this.#publicKey,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Return the public key.
|
|
160
|
+
*/
|
|
161
|
+
getPublicKey() {
|
|
162
|
+
return this.#publicKey;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Signs a blob of data, with this identity's private key.
|
|
166
|
+
* @param challenge - challenge to sign with this identity's secretKey, producing a signature
|
|
167
|
+
*/
|
|
168
|
+
async sign(challenge) {
|
|
169
|
+
// Some implementations of Ed25519 private keys append a public key to the end of the private key. We only want the private key.
|
|
170
|
+
const signature = ed25519.sign(challenge, this.#privateKey.slice(0, 32));
|
|
171
|
+
// add { __signature__: void; } to the signature to make it compatible with the agent
|
|
172
|
+
Object.defineProperty(signature, '__signature__', {
|
|
173
|
+
enumerable: false,
|
|
174
|
+
value: undefined,
|
|
175
|
+
});
|
|
176
|
+
return signature;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Verify
|
|
180
|
+
* @param sig - signature to verify
|
|
181
|
+
* @param msg - message to verify
|
|
182
|
+
* @param pk - public key
|
|
183
|
+
* @returns - true if the signature is valid, false otherwise
|
|
184
|
+
*/
|
|
185
|
+
static verify(sig, msg, pk) {
|
|
186
|
+
const [signature, message, publicKey] = [sig, msg, pk].map(x => {
|
|
187
|
+
if (typeof x === 'string') {
|
|
188
|
+
x = hexToBytes(x);
|
|
189
|
+
}
|
|
190
|
+
return uint8FromBufLike(x);
|
|
191
|
+
});
|
|
192
|
+
return ed25519.verify(signature, message, publicKey);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=ed25519.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../../../../src/identity/identity/ed25519.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAO,GACR,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;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AC,CAAC,EAAE;YAC7D,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;gBAC1B,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;YACD,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Identity, type PublicKey } from '../../agent/index.js';
|
|
2
|
+
import { Principal } from '../../principal/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* A partial delegated identity, representing a delegation chain and the public key that it targets
|
|
5
|
+
*/
|
|
6
|
+
export declare class PartialIdentity implements Identity {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* The raw public key of this identity.
|
|
10
|
+
*/
|
|
11
|
+
get rawKey(): Uint8Array | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The DER-encoded public key of this identity.
|
|
14
|
+
*/
|
|
15
|
+
get derKey(): Uint8Array | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The DER-encoded public key of this identity.
|
|
18
|
+
*/
|
|
19
|
+
toDer(): Uint8Array;
|
|
20
|
+
/**
|
|
21
|
+
* The inner {@link PublicKey} used by this identity.
|
|
22
|
+
*/
|
|
23
|
+
getPublicKey(): PublicKey;
|
|
24
|
+
/**
|
|
25
|
+
* The {@link Principal} of this identity.
|
|
26
|
+
*/
|
|
27
|
+
getPrincipal(): Principal;
|
|
28
|
+
/**
|
|
29
|
+
* Required for the Identity interface, but cannot implemented for just a public key.
|
|
30
|
+
*/
|
|
31
|
+
transformRequest(): Promise<never>;
|
|
32
|
+
constructor(inner: PublicKey);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=partial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partial.d.ts","sourceRoot":"","sources":["../../../../src/identity/identity/partial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;GAEG;AACH,qBAAa,eAAgB,YAAW,QAAQ;;IAG9C;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,GAAG,SAAS,CAEnC;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,GAAG,SAAS,CAEnC;IAED;;OAEG;IACI,KAAK,IAAI,UAAU;IAI1B;;OAEG;IACI,YAAY,IAAI,SAAS;IAIhC;;OAEG;IACI,YAAY,IAAI,SAAS;IAOhC;;OAEG;IACI,gBAAgB,IAAI,OAAO,CAAC,KAAK,CAAC;gBAM7B,KAAK,EAAE,SAAS;CAG7B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Principal } from '../../principal/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* A partial delegated identity, representing a delegation chain and the public key that it targets
|
|
4
|
+
*/
|
|
5
|
+
export class PartialIdentity {
|
|
6
|
+
#inner;
|
|
7
|
+
/**
|
|
8
|
+
* The raw public key of this identity.
|
|
9
|
+
*/
|
|
10
|
+
get rawKey() {
|
|
11
|
+
return this.#inner.rawKey;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The DER-encoded public key of this identity.
|
|
15
|
+
*/
|
|
16
|
+
get derKey() {
|
|
17
|
+
return this.#inner.derKey;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The DER-encoded public key of this identity.
|
|
21
|
+
*/
|
|
22
|
+
toDer() {
|
|
23
|
+
return this.#inner.toDer();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The inner {@link PublicKey} used by this identity.
|
|
27
|
+
*/
|
|
28
|
+
getPublicKey() {
|
|
29
|
+
return this.#inner;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The {@link Principal} of this identity.
|
|
33
|
+
*/
|
|
34
|
+
getPrincipal() {
|
|
35
|
+
if (!this.#inner.rawKey) {
|
|
36
|
+
throw new Error('Cannot get principal from a public key without a raw key.');
|
|
37
|
+
}
|
|
38
|
+
return Principal.fromUint8Array(new Uint8Array(this.#inner.rawKey));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Required for the Identity interface, but cannot implemented for just a public key.
|
|
42
|
+
*/
|
|
43
|
+
transformRequest() {
|
|
44
|
+
return Promise.reject('Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.');
|
|
45
|
+
}
|
|
46
|
+
constructor(inner) {
|
|
47
|
+
this.#inner = inner;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=partial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partial.js","sourceRoot":"","sources":["../../../../src/identity/identity/partial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B,MAAM,CAAY;IAElB;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACI,gBAAgB;QACrB,OAAO,OAAO,CAAC,MAAM,CACnB,mLAAmL,CACpL,CAAC;IACJ,CAAC;IAED,YAAY,KAAgB;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type DerEncodedPublicKey, type PublicKey, type Signature, SignIdentity } from '../../agent/index.js';
|
|
2
|
+
export declare class CosePublicKey implements PublicKey {
|
|
3
|
+
protected _cose: Uint8Array;
|
|
4
|
+
protected _encodedKey: DerEncodedPublicKey;
|
|
5
|
+
constructor(_cose: Uint8Array);
|
|
6
|
+
toDer(): DerEncodedPublicKey;
|
|
7
|
+
getCose(): Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A SignIdentity that uses `navigator.credentials`. See https://webauthn.guide/ for
|
|
11
|
+
* more information about WebAuthentication.
|
|
12
|
+
*/
|
|
13
|
+
export declare class WebAuthnIdentity extends SignIdentity {
|
|
14
|
+
readonly rawId: Uint8Array;
|
|
15
|
+
protected authenticatorAttachment: AuthenticatorAttachment | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Create an identity from a JSON serialization.
|
|
18
|
+
* @param json - json to parse
|
|
19
|
+
*/
|
|
20
|
+
static fromJSON(json: string): WebAuthnIdentity;
|
|
21
|
+
/**
|
|
22
|
+
* Create an identity.
|
|
23
|
+
* @param credentialCreationOptions an optional CredentialCreationOptions Challenge
|
|
24
|
+
*/
|
|
25
|
+
static create(credentialCreationOptions?: CredentialCreationOptions): Promise<WebAuthnIdentity>;
|
|
26
|
+
protected _publicKey: CosePublicKey;
|
|
27
|
+
constructor(rawId: Uint8Array, cose: Uint8Array, authenticatorAttachment: AuthenticatorAttachment | undefined);
|
|
28
|
+
getPublicKey(): PublicKey;
|
|
29
|
+
/**
|
|
30
|
+
* WebAuthn level 3 spec introduces a new attribute on successful WebAuthn interactions,
|
|
31
|
+
* see https://w3c.github.io/webauthn/#dom-publickeycredential-authenticatorattachment.
|
|
32
|
+
* This attribute is already implemented for Chrome, Safari and Edge.
|
|
33
|
+
*
|
|
34
|
+
* Given the attribute is only available after a successful interaction, the information is
|
|
35
|
+
* provided opportunistically and might also be `undefined`.
|
|
36
|
+
*/
|
|
37
|
+
getAuthenticatorAttachment(): AuthenticatorAttachment | undefined;
|
|
38
|
+
sign(blob: Uint8Array): Promise<Signature>;
|
|
39
|
+
/**
|
|
40
|
+
* Allow for JSON serialization of all information needed to reuse this identity.
|
|
41
|
+
*/
|
|
42
|
+
toJSON(): JsonnableWebAuthnIdentity;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* ReturnType<WebAuthnIdentity.toJSON>
|
|
46
|
+
*/
|
|
47
|
+
export interface JsonnableWebAuthnIdentity {
|
|
48
|
+
publicKey: string;
|
|
49
|
+
rawId: string;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=webauthn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../../../../src/identity/identity/webauthn.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,YAAY,EAIb,MAAM,QAAQ,CAAC;AAsChB,qBAAa,aAAc,YAAW,SAAS;IAG1B,SAAS,CAAC,KAAK,EAAE,UAAU;IAF9C,SAAS,CAAC,WAAW,EAAE,mBAAmB,CAAC;gBAEd,KAAK,EAAE,UAAU;IAIvC,KAAK,IAAI,mBAAmB;IAI5B,OAAO,IAAI,UAAU;CAG7B;AAwED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;aAgD9B,KAAK,EAAE,UAAU;IAEjC,SAAS,CAAC,uBAAuB,EAAE,uBAAuB,GAAG,SAAS;IAjDxE;;;OAGG;WACW,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB;IAUtD;;;OAGG;WACiB,MAAM,CACxB,yBAAyB,CAAC,EAAE,yBAAyB,GACpD,OAAO,CAAC,gBAAgB,CAAC;IAwB5B,SAAS,CAAC,UAAU,EAAE,aAAa,CAAC;gBAGlB,KAAK,EAAE,UAAU,EACjC,IAAI,EAAE,UAAU,EACN,uBAAuB,EAAE,uBAAuB,GAAG,SAAS;IAMjE,YAAY,IAAI,SAAS;IAIhC;;;;;;;OAOG;IACI,0BAA0B,IAAI,uBAAuB,GAAG,SAAS;IAI3D,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;IAqCvD;;OAEG;IACI,MAAM,IAAI,yBAAyB;CAM3C;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IAExC,SAAS,EAAE,MAAM,CAAC;IAElB,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { SignIdentity, wrapDER, DER_COSE_OID, Cbor, } from '../../agent/index.js';
|
|
2
|
+
import { bytesToHex, hexToBytes, randomBytes, bytesToUtf8 } from '@noble/hashes/utils';
|
|
3
|
+
import { uint8FromBufLike } from '../../candid/index.js';
|
|
4
|
+
function _coseToDerEncodedBlob(cose) {
|
|
5
|
+
return wrapDER(cose, DER_COSE_OID);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* From the documentation;
|
|
9
|
+
* The authData is a byte array described in the spec. Parsing it will involve slicing bytes from
|
|
10
|
+
* the array and converting them into usable objects.
|
|
11
|
+
*
|
|
12
|
+
* See https://webauthn.guide/#registration (subsection "Example: Parsing the authenticator data").
|
|
13
|
+
* @param authData The authData field of the attestation response.
|
|
14
|
+
* @returns The COSE key of the authData.
|
|
15
|
+
*/
|
|
16
|
+
function _authDataToCose(authData) {
|
|
17
|
+
const dataView = new DataView(new ArrayBuffer(2));
|
|
18
|
+
const idLenBytes = authData.slice(53, 55);
|
|
19
|
+
[...new Uint8Array(idLenBytes)].forEach((v, i) => dataView.setUint8(i, v));
|
|
20
|
+
const credentialIdLength = dataView.getUint16(0);
|
|
21
|
+
// Get the public key object.
|
|
22
|
+
return authData.slice(55 + credentialIdLength);
|
|
23
|
+
}
|
|
24
|
+
export class CosePublicKey {
|
|
25
|
+
constructor(_cose) {
|
|
26
|
+
this._cose = _cose;
|
|
27
|
+
this._encodedKey = _coseToDerEncodedBlob(_cose);
|
|
28
|
+
}
|
|
29
|
+
toDer() {
|
|
30
|
+
return this._encodedKey;
|
|
31
|
+
}
|
|
32
|
+
getCose() {
|
|
33
|
+
return this._cose;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a challenge from a string or array. The default challenge is always the same
|
|
38
|
+
* because we don't need to verify the authenticity of the key on the server (we don't
|
|
39
|
+
* register our keys with the IC). Any challenge would do, even one per key, randomly
|
|
40
|
+
* generated.
|
|
41
|
+
* @param challenge The challenge to transform into a byte array. By default a hard
|
|
42
|
+
* coded string.
|
|
43
|
+
*/
|
|
44
|
+
function _createChallengeBuffer(challenge = '<ic0.app>') {
|
|
45
|
+
if (typeof challenge === 'string') {
|
|
46
|
+
return Uint8Array.from(challenge, c => c.charCodeAt(0));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return challenge;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a credentials to authenticate with a server. This is necessary in order in
|
|
54
|
+
* WebAuthn to get credentials IDs (which give us the public key and allow us to
|
|
55
|
+
* sign), but in the case of the Internet Computer, we don't actually need to register
|
|
56
|
+
* it, so we don't.
|
|
57
|
+
* @param credentialCreationOptions an optional CredentialCreationOptions object
|
|
58
|
+
*/
|
|
59
|
+
async function _createCredential(credentialCreationOptions) {
|
|
60
|
+
const creds = (await navigator.credentials.create(credentialCreationOptions ?? {
|
|
61
|
+
publicKey: {
|
|
62
|
+
authenticatorSelection: {
|
|
63
|
+
userVerification: 'preferred',
|
|
64
|
+
},
|
|
65
|
+
attestation: 'direct',
|
|
66
|
+
challenge: _createChallengeBuffer(),
|
|
67
|
+
pubKeyCredParams: [{ type: 'public-key', alg: PubKeyCoseAlgo.ECDSA_WITH_SHA256 }],
|
|
68
|
+
rp: {
|
|
69
|
+
name: 'Internet Identity Service',
|
|
70
|
+
},
|
|
71
|
+
user: {
|
|
72
|
+
id: randomBytes(16),
|
|
73
|
+
name: 'Internet Identity',
|
|
74
|
+
displayName: 'Internet Identity',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}));
|
|
78
|
+
if (creds === null) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
// do _not_ use ...creds here, as creds is not enumerable in all cases
|
|
83
|
+
id: creds.id,
|
|
84
|
+
response: creds.response,
|
|
85
|
+
type: creds.type,
|
|
86
|
+
authenticatorAttachment: creds.authenticatorAttachment,
|
|
87
|
+
getClientExtensionResults: creds.getClientExtensionResults,
|
|
88
|
+
// Some password managers will return a Uint8Array, so we ensure we return an ArrayBuffer.
|
|
89
|
+
rawId: creds.rawId,
|
|
90
|
+
toJSON: creds.toJSON.bind(creds), // Ensure the toJSON method is included
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// See https://www.iana.org/assignments/cose/cose.xhtml#algorithms for a complete
|
|
94
|
+
// list of these algorithms. We only list the ones we support here.
|
|
95
|
+
var PubKeyCoseAlgo;
|
|
96
|
+
(function (PubKeyCoseAlgo) {
|
|
97
|
+
PubKeyCoseAlgo[PubKeyCoseAlgo["ECDSA_WITH_SHA256"] = -7] = "ECDSA_WITH_SHA256";
|
|
98
|
+
})(PubKeyCoseAlgo || (PubKeyCoseAlgo = {}));
|
|
99
|
+
/**
|
|
100
|
+
* A SignIdentity that uses `navigator.credentials`. See https://webauthn.guide/ for
|
|
101
|
+
* more information about WebAuthentication.
|
|
102
|
+
*/
|
|
103
|
+
export class WebAuthnIdentity extends SignIdentity {
|
|
104
|
+
/**
|
|
105
|
+
* Create an identity from a JSON serialization.
|
|
106
|
+
* @param json - json to parse
|
|
107
|
+
*/
|
|
108
|
+
static fromJSON(json) {
|
|
109
|
+
const { publicKey, rawId } = JSON.parse(json);
|
|
110
|
+
if (typeof publicKey !== 'string' || typeof rawId !== 'string') {
|
|
111
|
+
throw new Error('Invalid JSON string.');
|
|
112
|
+
}
|
|
113
|
+
return new this(hexToBytes(rawId), hexToBytes(publicKey), undefined);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Create an identity.
|
|
117
|
+
* @param credentialCreationOptions an optional CredentialCreationOptions Challenge
|
|
118
|
+
*/
|
|
119
|
+
static async create(credentialCreationOptions) {
|
|
120
|
+
const creds = await _createCredential(credentialCreationOptions);
|
|
121
|
+
if (!creds || creds.type !== 'public-key') {
|
|
122
|
+
throw new Error('Could not create credentials.');
|
|
123
|
+
}
|
|
124
|
+
const response = creds.response;
|
|
125
|
+
if (response.attestationObject === undefined) {
|
|
126
|
+
throw new Error('Was expecting an attestation response.');
|
|
127
|
+
}
|
|
128
|
+
// Parse the attestationObject as CBOR.
|
|
129
|
+
const attObject = Cbor.decode(new Uint8Array(response.attestationObject));
|
|
130
|
+
return new this(uint8FromBufLike(creds.rawId), _authDataToCose(attObject.authData), creds.authenticatorAttachment ?? undefined);
|
|
131
|
+
}
|
|
132
|
+
constructor(rawId, cose, authenticatorAttachment) {
|
|
133
|
+
super();
|
|
134
|
+
this.rawId = rawId;
|
|
135
|
+
this.authenticatorAttachment = authenticatorAttachment;
|
|
136
|
+
this._publicKey = new CosePublicKey(cose);
|
|
137
|
+
}
|
|
138
|
+
getPublicKey() {
|
|
139
|
+
return this._publicKey;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* WebAuthn level 3 spec introduces a new attribute on successful WebAuthn interactions,
|
|
143
|
+
* see https://w3c.github.io/webauthn/#dom-publickeycredential-authenticatorattachment.
|
|
144
|
+
* This attribute is already implemented for Chrome, Safari and Edge.
|
|
145
|
+
*
|
|
146
|
+
* Given the attribute is only available after a successful interaction, the information is
|
|
147
|
+
* provided opportunistically and might also be `undefined`.
|
|
148
|
+
*/
|
|
149
|
+
getAuthenticatorAttachment() {
|
|
150
|
+
return this.authenticatorAttachment;
|
|
151
|
+
}
|
|
152
|
+
async sign(blob) {
|
|
153
|
+
const result = (await navigator.credentials.get({
|
|
154
|
+
publicKey: {
|
|
155
|
+
allowCredentials: [
|
|
156
|
+
{
|
|
157
|
+
type: 'public-key',
|
|
158
|
+
id: this.rawId,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
challenge: blob,
|
|
162
|
+
userVerification: 'preferred',
|
|
163
|
+
},
|
|
164
|
+
}));
|
|
165
|
+
if (result.authenticatorAttachment !== null) {
|
|
166
|
+
this.authenticatorAttachment = result.authenticatorAttachment;
|
|
167
|
+
}
|
|
168
|
+
const response = result.response;
|
|
169
|
+
const encoded = Cbor.encode({
|
|
170
|
+
authenticator_data: response.authenticatorData,
|
|
171
|
+
client_data_json: bytesToUtf8(new Uint8Array(response.clientDataJSON)),
|
|
172
|
+
signature: response.signature,
|
|
173
|
+
});
|
|
174
|
+
if (!encoded) {
|
|
175
|
+
throw new Error('failed to encode cbor');
|
|
176
|
+
}
|
|
177
|
+
Object.assign(encoded, {
|
|
178
|
+
__signature__: undefined,
|
|
179
|
+
});
|
|
180
|
+
return encoded;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Allow for JSON serialization of all information needed to reuse this identity.
|
|
184
|
+
*/
|
|
185
|
+
toJSON() {
|
|
186
|
+
return {
|
|
187
|
+
publicKey: bytesToHex(this._publicKey.getCose()),
|
|
188
|
+
rawId: bytesToHex(this.rawId),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=webauthn.js.map
|
|
@@ -0,0 +1 @@
|
|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C;YACtE,SAAS,EAAE,QAAQ,CAAC,SAAS;SAC9B,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;YACrB,aAAa,EAAE,SAAS;SACzB,CAAC,CAAC;QAEH,OAAO,OAAoB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO;YACL,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAChD,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;SAC9B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module api
|
|
3
|
+
*/
|
|
4
|
+
export * from './identity/ed25519.ts';
|
|
5
|
+
export * from './identity/ecdsa.ts';
|
|
6
|
+
export * from './identity/delegation.ts';
|
|
7
|
+
export * from './identity/partial.ts';
|
|
8
|
+
export { WebAuthnIdentity } from './identity/webauthn.ts';
|
|
9
|
+
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
|
+
}
|
|
2
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEvE;;GAEG;AACH,qBAAa,oBAAoB;;CAIhC"}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module api
|
|
3
|
+
*/
|
|
4
|
+
export * from "./identity/ed25519.js";
|
|
5
|
+
export * from "./identity/ecdsa.js";
|
|
6
|
+
export * from "./identity/delegation.js";
|
|
7
|
+
export * from "./identity/partial.js";
|
|
8
|
+
export { WebAuthnIdentity } from "./identity/webauthn.js";
|
|
9
|
+
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
|
+
}
|
|
2
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEvE;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAC/B;QACE,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACtF,CAAC;CACF"}
|
|
@@ -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"}
|