@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,70 @@
|
|
|
1
|
+
import { Principal } from '../../principal/index.js';
|
|
2
|
+
import { HttpAgent } from '../agent/http/index.ts';
|
|
3
|
+
import { type CanisterRanges } from '../certificate.ts';
|
|
4
|
+
import { type BaseStatus, type BaseSubnetStatus, type SubnetNodeKeys, CustomPath } from '../utils/readState.ts';
|
|
5
|
+
export { type DecodeStrategy, CustomPath, IC_ROOT_SUBNET_ID } from '../utils/readState.ts';
|
|
6
|
+
export type SubnetStatus = BaseSubnetStatus & {
|
|
7
|
+
/**
|
|
8
|
+
* The public key of the subnet
|
|
9
|
+
*/
|
|
10
|
+
publicKey: Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
export type Status = BaseStatus | SubnetNodeKeys | CanisterRanges;
|
|
13
|
+
/**
|
|
14
|
+
* Pre-configured fields for subnet status paths
|
|
15
|
+
*/
|
|
16
|
+
export type Path = 'time' | 'canisterRanges' | 'publicKey' | 'nodeKeys' | CustomPath;
|
|
17
|
+
export type StatusMap = Map<Path | string, Status>;
|
|
18
|
+
export type SubnetStatusOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* The subnet ID to query. Use {@link IC_ROOT_SUBNET_ID} for the IC mainnet root subnet.
|
|
21
|
+
* You can use {@link HttpAgent.getSubnetIdFromCanister} to get a subnet ID from a canister.
|
|
22
|
+
*/
|
|
23
|
+
subnetId: Principal;
|
|
24
|
+
/**
|
|
25
|
+
* The agent to use to make the subnet request.
|
|
26
|
+
*/
|
|
27
|
+
agent: HttpAgent;
|
|
28
|
+
/**
|
|
29
|
+
* The paths to request.
|
|
30
|
+
* @default []
|
|
31
|
+
*/
|
|
32
|
+
paths?: Path[] | Set<Path>;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to disable the certificate freshness checks.
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
disableCertificateTimeVerification?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Requests information from a subnet's `read_state` endpoint.
|
|
41
|
+
* Can be used to request information about the subnet's time, canister ranges, public key, node keys, and metrics.
|
|
42
|
+
* @param {SubnetStatusOptions} options The configuration for the subnet status request.
|
|
43
|
+
* @see {@link SubnetStatusOptions} for detailed options.
|
|
44
|
+
* @returns {Promise<StatusMap>} A map populated with data from the requested paths. Each path is a key in the map, and the value is the data obtained from the certificate for that path.
|
|
45
|
+
* @example
|
|
46
|
+
* const status = await subnetStatus.request({
|
|
47
|
+
* subnetId: IC_ROOT_SUBNET_ID,
|
|
48
|
+
* paths: ['time', 'nodeKeys'],
|
|
49
|
+
* agent,
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* const time = status.get('time');
|
|
53
|
+
* const nodeKeys = status.get('nodeKeys');
|
|
54
|
+
*/
|
|
55
|
+
export declare function request(options: SubnetStatusOptions): Promise<StatusMap>;
|
|
56
|
+
/**
|
|
57
|
+
* Fetch subnet info including node keys from a certificate
|
|
58
|
+
* @param certificate the certificate bytes
|
|
59
|
+
* @param subnetId the subnet ID
|
|
60
|
+
* @returns SubnetStatus with subnet ID and node keys
|
|
61
|
+
*/
|
|
62
|
+
export declare function lookupSubnetInfo(certificate: Uint8Array, subnetId: Principal): SubnetStatus;
|
|
63
|
+
/**
|
|
64
|
+
* Encode a path for subnet state queries
|
|
65
|
+
* @param path the path to encode
|
|
66
|
+
* @param subnetId the subnet ID
|
|
67
|
+
* @returns the encoded path as an array of Uint8Arrays
|
|
68
|
+
*/
|
|
69
|
+
export declare function encodePath(path: Path, subnetId: Principal): Uint8Array[];
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/subnetStatus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYvC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAEL,KAAK,cAAc,EAMpB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,UAAU,EAKX,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,KAAK,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,cAAc,GAAG,cAAc,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,gBAAgB,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;AAErF,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B;;;OAGG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,CA0G9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,GAAG,YAAY,CAU3F;AAeD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,GAAG,UAAU,EAAE,CA+BxE"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.IC_ROOT_SUBNET_ID = exports.CustomPath = void 0;
|
|
37
|
+
exports.request = request;
|
|
38
|
+
exports.lookupSubnetInfo = lookupSubnetInfo;
|
|
39
|
+
exports.encodePath = encodePath;
|
|
40
|
+
const _principal_1 = require("../../principal/index.js");
|
|
41
|
+
const errors_ts_1 = require("../errors.js");
|
|
42
|
+
const certificate_ts_1 = require("../certificate.js");
|
|
43
|
+
const cbor = __importStar(require("../cbor.js"));
|
|
44
|
+
const leb_ts_1 = require("../utils/leb.js");
|
|
45
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
46
|
+
const readState_ts_1 = require("../utils/readState.js");
|
|
47
|
+
// Re-export shared types and functions
|
|
48
|
+
var readState_ts_2 = require("../utils/readState.js");
|
|
49
|
+
Object.defineProperty(exports, "CustomPath", { enumerable: true, get: function () { return readState_ts_2.CustomPath; } });
|
|
50
|
+
Object.defineProperty(exports, "IC_ROOT_SUBNET_ID", { enumerable: true, get: function () { return readState_ts_2.IC_ROOT_SUBNET_ID; } });
|
|
51
|
+
/**
|
|
52
|
+
* Requests information from a subnet's `read_state` endpoint.
|
|
53
|
+
* Can be used to request information about the subnet's time, canister ranges, public key, node keys, and metrics.
|
|
54
|
+
* @param {SubnetStatusOptions} options The configuration for the subnet status request.
|
|
55
|
+
* @see {@link SubnetStatusOptions} for detailed options.
|
|
56
|
+
* @returns {Promise<StatusMap>} A map populated with data from the requested paths. Each path is a key in the map, and the value is the data obtained from the certificate for that path.
|
|
57
|
+
* @example
|
|
58
|
+
* const status = await subnetStatus.request({
|
|
59
|
+
* subnetId: IC_ROOT_SUBNET_ID,
|
|
60
|
+
* paths: ['time', 'nodeKeys'],
|
|
61
|
+
* agent,
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* const time = status.get('time');
|
|
65
|
+
* const nodeKeys = status.get('nodeKeys');
|
|
66
|
+
*/
|
|
67
|
+
async function request(options) {
|
|
68
|
+
const { agent, paths, disableCertificateTimeVerification = false } = options;
|
|
69
|
+
const subnetId = _principal_1.Principal.from(options.subnetId);
|
|
70
|
+
const uniquePaths = [...new Set(paths)];
|
|
71
|
+
const status = new Map();
|
|
72
|
+
const promises = uniquePaths.map((path, index) => {
|
|
73
|
+
const encodedPath = encodePath(path, subnetId);
|
|
74
|
+
return (async () => {
|
|
75
|
+
try {
|
|
76
|
+
if (agent.rootKey === null) {
|
|
77
|
+
throw errors_ts_1.ExternalError.fromCode(new errors_ts_1.MissingRootKeyErrorCode());
|
|
78
|
+
}
|
|
79
|
+
const rootKey = agent.rootKey;
|
|
80
|
+
const response = await agent.readSubnetState(subnetId, {
|
|
81
|
+
paths: [encodedPath],
|
|
82
|
+
});
|
|
83
|
+
const certificate = await certificate_ts_1.Certificate.create({
|
|
84
|
+
certificate: response.certificate,
|
|
85
|
+
rootKey,
|
|
86
|
+
principal: { subnetId },
|
|
87
|
+
disableTimeVerification: disableCertificateTimeVerification,
|
|
88
|
+
agent,
|
|
89
|
+
});
|
|
90
|
+
const lookup = (cert, lookupPath) => {
|
|
91
|
+
if (lookupPath === 'nodeKeys') {
|
|
92
|
+
// For node keys, we need to parse the certificate directly
|
|
93
|
+
const data = (0, readState_ts_1.lookupNodeKeysFromCertificate)(cert.cert, subnetId);
|
|
94
|
+
return {
|
|
95
|
+
path: lookupPath,
|
|
96
|
+
data,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return {
|
|
101
|
+
path: lookupPath,
|
|
102
|
+
data: (0, certificate_ts_1.lookupResultToBuffer)(cert.lookup_path(encodedPath)),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const { path, data } = lookup(certificate, uniquePaths[index]);
|
|
107
|
+
if (!data) {
|
|
108
|
+
console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
|
|
109
|
+
if (typeof path === 'string') {
|
|
110
|
+
status.set(path, null);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
status.set(path.key, null);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
switch (path) {
|
|
118
|
+
case 'time': {
|
|
119
|
+
status.set(path, (0, leb_ts_1.decodeTime)(data));
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case 'canisterRanges': {
|
|
123
|
+
status.set(path, (0, certificate_ts_1.decodeCanisterRanges)(data));
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 'publicKey': {
|
|
127
|
+
status.set(path, data);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case 'nodeKeys': {
|
|
131
|
+
status.set(path, data);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
default: {
|
|
135
|
+
// Check for CustomPath signature
|
|
136
|
+
if ((0, readState_ts_1.isCustomPath)(path)) {
|
|
137
|
+
status.set(path.key, (0, readState_ts_1.decodeValue)(data, path.decodeStrategy));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
// Throw on certificate errors
|
|
145
|
+
if (error instanceof errors_ts_1.AgentError &&
|
|
146
|
+
(error.hasCode(errors_ts_1.CertificateVerificationErrorCode) ||
|
|
147
|
+
error.hasCode(errors_ts_1.CertificateTimeErrorCode))) {
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
if ((0, readState_ts_1.isCustomPath)(path)) {
|
|
151
|
+
status.set(path.key, null);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
status.set(path, null);
|
|
155
|
+
}
|
|
156
|
+
console.group();
|
|
157
|
+
console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
|
|
158
|
+
console.warn(error);
|
|
159
|
+
console.groupEnd();
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
});
|
|
163
|
+
// Fetch all values separately, as each option can fail
|
|
164
|
+
await Promise.all(promises);
|
|
165
|
+
return status;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Fetch subnet info including node keys from a certificate
|
|
169
|
+
* @param certificate the certificate bytes
|
|
170
|
+
* @param subnetId the subnet ID
|
|
171
|
+
* @returns SubnetStatus with subnet ID and node keys
|
|
172
|
+
*/
|
|
173
|
+
function lookupSubnetInfo(certificate, subnetId) {
|
|
174
|
+
const cert = cbor.decode(certificate);
|
|
175
|
+
const nodeKeys = (0, readState_ts_1.lookupNodeKeysFromCertificate)(cert, subnetId);
|
|
176
|
+
const publicKey = lookupSubnetPublicKey(cert, subnetId);
|
|
177
|
+
return {
|
|
178
|
+
subnetId: subnetId.toText(),
|
|
179
|
+
nodeKeys,
|
|
180
|
+
publicKey,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function lookupSubnetPublicKey(certificate, subnetId) {
|
|
184
|
+
const subnetLookupResult = (0, certificate_ts_1.lookup_path)(['subnet', subnetId.toUint8Array(), 'public_key'], certificate.tree);
|
|
185
|
+
if (subnetLookupResult.status !== certificate_ts_1.LookupPathStatus.Found) {
|
|
186
|
+
throw errors_ts_1.ProtocolError.fromCode(new errors_ts_1.LookupErrorCode('Public key not found', subnetLookupResult.status));
|
|
187
|
+
}
|
|
188
|
+
return subnetLookupResult.value;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Encode a path for subnet state queries
|
|
192
|
+
* @param path the path to encode
|
|
193
|
+
* @param subnetId the subnet ID
|
|
194
|
+
* @returns the encoded path as an array of Uint8Arrays
|
|
195
|
+
*/
|
|
196
|
+
function encodePath(path, subnetId) {
|
|
197
|
+
const subnetUint8Array = subnetId.toUint8Array();
|
|
198
|
+
switch (path) {
|
|
199
|
+
case 'time':
|
|
200
|
+
return [(0, utils_1.utf8ToBytes)('time')];
|
|
201
|
+
case 'canisterRanges':
|
|
202
|
+
return [(0, utils_1.utf8ToBytes)('canister_ranges'), subnetUint8Array];
|
|
203
|
+
case 'publicKey':
|
|
204
|
+
return [(0, utils_1.utf8ToBytes)('subnet'), subnetUint8Array, (0, utils_1.utf8ToBytes)('public_key')];
|
|
205
|
+
case 'nodeKeys':
|
|
206
|
+
return [(0, utils_1.utf8ToBytes)('subnet'), subnetUint8Array, (0, utils_1.utf8ToBytes)('node')];
|
|
207
|
+
default: {
|
|
208
|
+
// Check for CustomPath signature
|
|
209
|
+
if ((0, readState_ts_1.isCustomPath)(path)) {
|
|
210
|
+
if (typeof path['path'] === 'string' || path['path'] instanceof Uint8Array) {
|
|
211
|
+
// For string paths, treat as a subnet path segment
|
|
212
|
+
const encoded = typeof path['path'] === 'string' ? (0, utils_1.utf8ToBytes)(path['path']) : path['path'];
|
|
213
|
+
return [(0, utils_1.utf8ToBytes)('subnet'), subnetUint8Array, encoded];
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
// For non-simple paths, return the provided custom path
|
|
217
|
+
return path['path'];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
throw errors_ts_1.UnknownError.fromCode(new errors_ts_1.UnexpectedErrorCode(`Error while encoding your path for subnet status. Please ensure that your path ${path} was formatted correctly.`));
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/subnetStatus/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,0BA0GC;AAQD,4CAUC;AAqBD,gCA+BC;AA7QD,2CAAuC;AACvC,4CAUsB;AAEtB,sDAQ2B;AAC3B,iDAAmC;AACnC,4CAA6C;AAC7C,+CAAkD;AAClD,wDAS+B;AAE/B,uCAAuC;AACvC,sDAA2F;AAA7D,0GAAA,UAAU,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AAwC3D;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,OAAO,CAAC,OAA4B;IACxD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,kCAAkC,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAC7E,MAAM,QAAQ,GAAG,sBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAElD,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEhD,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/C,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE/C,OAAO,CAAC,KAAK,IAAI,EAAE;YACjB,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CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC9E,OAAO,CAAC,IAAA,mBAAW,EAAC,QAAQ,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;gBAC5D,CAAC;qBAAM,CAAC;oBACN,wDAAwD;oBACxD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,wBAAY,CAAC,QAAQ,CACzB,IAAI,+BAAmB,CACrB,kFAAkF,IAAI,2BAA2B,CAClH,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare let verify: (pk: Uint8Array, sig: Uint8Array, msg: Uint8Array) => boolean;
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param pk primary key: Uint8Array
|
|
5
|
+
* @param sig signature: Uint8Array
|
|
6
|
+
* @param msg message: Uint8Array
|
|
7
|
+
* @returns boolean
|
|
8
|
+
*/
|
|
9
|
+
export declare function blsVerify(pk: Uint8Array, sig: Uint8Array, msg: Uint8Array): boolean;
|
|
10
|
+
//# sourceMappingURL=bls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bls.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/bls.ts"],"names":[],"mappings":"AAGA,eAAO,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC;AAEjF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAKnF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verify = void 0;
|
|
4
|
+
exports.blsVerify = blsVerify;
|
|
5
|
+
const bls12_381_1 = require("@noble/curves/bls12-381");
|
|
6
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param pk primary key: Uint8Array
|
|
10
|
+
* @param sig signature: Uint8Array
|
|
11
|
+
* @param msg message: Uint8Array
|
|
12
|
+
* @returns boolean
|
|
13
|
+
*/
|
|
14
|
+
function blsVerify(pk, sig, msg) {
|
|
15
|
+
const primaryKey = typeof pk === 'string' ? pk : (0, utils_1.bytesToHex)(pk);
|
|
16
|
+
const signature = typeof sig === 'string' ? sig : (0, utils_1.bytesToHex)(sig);
|
|
17
|
+
const message = typeof msg === 'string' ? msg : (0, utils_1.bytesToHex)(msg);
|
|
18
|
+
return bls12_381_1.bls12_381.verifyShortSignature(signature, message, primaryKey);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=bls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bls.js","sourceRoot":"","sources":["../../../../src/agent/utils/bls.ts"],"names":[],"mappings":";;;AAYA,8BAKC;AAjBD,uDAAoD;AACpD,+CAAiD;AAIjD;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,EAAc,EAAE,GAAe,EAAE,GAAe;IACxE,MAAM,UAAU,GAAG,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAA,kBAAU,EAAC,EAAE,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,kBAAU,EAAC,GAAG,CAAC,CAAC;IAClE,MAAM,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,kBAAU,EAAC,GAAG,CAAC,CAAC;IAChE,OAAO,qBAAS,CAAC,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a true Uint8Array from an ArrayBufferLike object.
|
|
3
|
+
* @param bufLike a buffer-like object
|
|
4
|
+
* @returns Uint8Array
|
|
5
|
+
*/
|
|
6
|
+
export declare function uint8FromBufLike(bufLike: ArrayBuffer | Uint8Array | DataView | ArrayBufferView | ArrayBufferLike | [number] | number[] | {
|
|
7
|
+
buffer: ArrayBuffer;
|
|
8
|
+
}): Uint8Array;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a true ArrayBuffer from a Uint8Array, as Uint8Array.buffer is unsafe.
|
|
11
|
+
* @param {Uint8Array} arr Uint8Array to convert
|
|
12
|
+
* @returns ArrayBuffer
|
|
13
|
+
*/
|
|
14
|
+
export declare function uint8ToBuf(arr: Uint8Array): ArrayBuffer;
|
|
15
|
+
/**
|
|
16
|
+
* Compares two Uint8Arrays for equality.
|
|
17
|
+
* @param a The first Uint8Array.
|
|
18
|
+
* @param b The second Uint8Array.
|
|
19
|
+
* @returns True if the Uint8Arrays are equal, false otherwise.
|
|
20
|
+
*/
|
|
21
|
+
export declare function uint8Equals(a: Uint8Array, b: Uint8Array): boolean;
|
|
22
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/buffer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EACH,WAAW,GACX,UAAU,GACV,QAAQ,GACR,eAAe,GACf,eAAe,GACf,CAAC,MAAM,CAAC,GACR,MAAM,EAAE,GACR;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GAC1B,UAAU,CAkBZ;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAKvD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAMjE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uint8FromBufLike = uint8FromBufLike;
|
|
4
|
+
exports.uint8ToBuf = uint8ToBuf;
|
|
5
|
+
exports.uint8Equals = uint8Equals;
|
|
6
|
+
/**
|
|
7
|
+
* Returns a true Uint8Array from an ArrayBufferLike object.
|
|
8
|
+
* @param bufLike a buffer-like object
|
|
9
|
+
* @returns Uint8Array
|
|
10
|
+
*/
|
|
11
|
+
function uint8FromBufLike(bufLike) {
|
|
12
|
+
if (!bufLike) {
|
|
13
|
+
throw new Error('Input cannot be null or undefined');
|
|
14
|
+
}
|
|
15
|
+
if (bufLike instanceof Uint8Array) {
|
|
16
|
+
return bufLike;
|
|
17
|
+
}
|
|
18
|
+
if (bufLike instanceof ArrayBuffer) {
|
|
19
|
+
return new Uint8Array(bufLike);
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(bufLike)) {
|
|
22
|
+
return new Uint8Array(bufLike);
|
|
23
|
+
}
|
|
24
|
+
if ('buffer' in bufLike) {
|
|
25
|
+
return uint8FromBufLike(bufLike.buffer);
|
|
26
|
+
}
|
|
27
|
+
return new Uint8Array(bufLike);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns a true ArrayBuffer from a Uint8Array, as Uint8Array.buffer is unsafe.
|
|
31
|
+
* @param {Uint8Array} arr Uint8Array to convert
|
|
32
|
+
* @returns ArrayBuffer
|
|
33
|
+
*/
|
|
34
|
+
function uint8ToBuf(arr) {
|
|
35
|
+
const buf = new ArrayBuffer(arr.byteLength);
|
|
36
|
+
const view = new Uint8Array(buf);
|
|
37
|
+
view.set(arr);
|
|
38
|
+
return buf;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Compares two Uint8Arrays for equality.
|
|
42
|
+
* @param a The first Uint8Array.
|
|
43
|
+
* @param b The second Uint8Array.
|
|
44
|
+
* @returns True if the Uint8Arrays are equal, false otherwise.
|
|
45
|
+
*/
|
|
46
|
+
function uint8Equals(a, b) {
|
|
47
|
+
if (a.length !== b.length)
|
|
48
|
+
return false;
|
|
49
|
+
for (let i = 0; i < a.length; i++) {
|
|
50
|
+
if (a[i] !== b[i])
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../src/agent/utils/buffer.ts"],"names":[],"mappings":";;AAKA,4CA4BC;AAOD,gCAKC;AAQD,kCAMC;AA3DD;;;;GAIG;AACH,SAAgB,gBAAgB,CAC9B,OAQ2B;IAE3B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,OAAO,YAAY,UAAU,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,OAAO,YAAY,WAAW,EAAE,CAAC;QACnC,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;QACxB,OAAO,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAe;IACxC,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,CAAa,EAAE,CAAa;IACtD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type ExpirableMapOptions<K, V> = {
|
|
2
|
+
source?: Iterable<[K, V]>;
|
|
3
|
+
expirationTime?: number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* A map that expires entries after a given time.
|
|
7
|
+
* Defaults to 10 minutes.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ExpirableMap<K, V> implements Map<K, V> {
|
|
10
|
+
#private;
|
|
11
|
+
[Symbol.iterator]: () => MapIterator<[K, V]>;
|
|
12
|
+
[Symbol.toStringTag]: string;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new ExpirableMap.
|
|
15
|
+
* @param {ExpirableMapOptions<any, any>} options - options for the map.
|
|
16
|
+
* @param {Iterable<[any, any]>} options.source - an optional source of entries to initialize the map with.
|
|
17
|
+
* @param {number} options.expirationTime - the time in milliseconds after which entries will expire.
|
|
18
|
+
*/
|
|
19
|
+
constructor(options?: ExpirableMapOptions<K, V>);
|
|
20
|
+
/**
|
|
21
|
+
* Prune removes all expired entries.
|
|
22
|
+
*/
|
|
23
|
+
prune(): this;
|
|
24
|
+
/**
|
|
25
|
+
* Set the value for the given key. Prunes expired entries.
|
|
26
|
+
* @param key for the entry
|
|
27
|
+
* @param value of the entry
|
|
28
|
+
* @returns this
|
|
29
|
+
*/
|
|
30
|
+
set(key: K, value: V): this;
|
|
31
|
+
/**
|
|
32
|
+
* Get the value associated with the key, if it exists and has not expired.
|
|
33
|
+
* @param key K
|
|
34
|
+
* @returns the value associated with the key, or undefined if the key is not present or has expired.
|
|
35
|
+
*/
|
|
36
|
+
get(key: K): V | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Clear all entries.
|
|
39
|
+
*/
|
|
40
|
+
clear(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Entries returns the entries of the map, without the expiration time.
|
|
43
|
+
* @returns an iterator over the entries of the map.
|
|
44
|
+
*/
|
|
45
|
+
entries(): MapIterator<[K, V]>;
|
|
46
|
+
/**
|
|
47
|
+
* Values returns the values of the map, without the expiration time.
|
|
48
|
+
* @returns an iterator over the values of the map.
|
|
49
|
+
*/
|
|
50
|
+
values(): MapIterator<V>;
|
|
51
|
+
/**
|
|
52
|
+
* Keys returns the keys of the map
|
|
53
|
+
* @returns an iterator over the keys of the map.
|
|
54
|
+
*/
|
|
55
|
+
keys(): MapIterator<K>;
|
|
56
|
+
/**
|
|
57
|
+
* forEach calls the callbackfn on each entry of the map.
|
|
58
|
+
* @param callbackfn to call on each entry
|
|
59
|
+
* @param thisArg to use as this when calling the callbackfn
|
|
60
|
+
*/
|
|
61
|
+
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: ExpirableMap<K, V>): void;
|
|
62
|
+
/**
|
|
63
|
+
* has returns true if the key exists and has not expired.
|
|
64
|
+
* @param key K
|
|
65
|
+
* @returns true if the key exists and has not expired.
|
|
66
|
+
*/
|
|
67
|
+
has(key: K): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* delete the entry for the given key.
|
|
70
|
+
* @param key K
|
|
71
|
+
* @returns true if the key existed and has been deleted.
|
|
72
|
+
*/
|
|
73
|
+
delete(key: K): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* get size of the map.
|
|
76
|
+
* @returns the size of the map.
|
|
77
|
+
*/
|
|
78
|
+
get size(): number;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=expirableMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expirableMap.d.ts","sourceRoot":"","sources":["../../../../src/agent/utils/expirableMap.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,EAAE,CAAC,IAAI;IACtC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;;IAKlD,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAA2B;IACvE,CAAC,MAAM,CAAC,WAAW,CAAC,SAAkB;IAEtC;;;;;OAKG;gBACS,OAAO,GAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAM;IASnD;;OAEG;IACH,KAAK;IAYL;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;IAWpB;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC;IAYV;;OAEG;IACH,KAAK;IAIL;;;OAGG;IACH,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAW9B;;;OAGG;IACH,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAWxB;;;OAGG;IACH,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC;IAItB;;;;OAIG;IACH,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IAM5F;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,CAAC;IAIb;;;OAGG;IACH,IAAI,IAAI,WAEP;CACF"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a, _b;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ExpirableMap = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* A map that expires entries after a given time.
|
|
7
|
+
* Defaults to 10 minutes.
|
|
8
|
+
*/
|
|
9
|
+
class ExpirableMap {
|
|
10
|
+
static { _a = Symbol.iterator, _b = Symbol.toStringTag; }
|
|
11
|
+
// Internals
|
|
12
|
+
#inner;
|
|
13
|
+
#expirationTime;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new ExpirableMap.
|
|
16
|
+
* @param {ExpirableMapOptions<any, any>} options - options for the map.
|
|
17
|
+
* @param {Iterable<[any, any]>} options.source - an optional source of entries to initialize the map with.
|
|
18
|
+
* @param {number} options.expirationTime - the time in milliseconds after which entries will expire.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this[_a] = this.entries.bind(this);
|
|
22
|
+
this[_b] = 'ExpirableMap';
|
|
23
|
+
const { source = [], expirationTime = 10 * 60 * 1000 } = options;
|
|
24
|
+
const currentTime = Date.now();
|
|
25
|
+
this.#inner = new Map([...source].map(([key, value]) => [key, { value, timestamp: currentTime }]));
|
|
26
|
+
this.#expirationTime = expirationTime;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Prune removes all expired entries.
|
|
30
|
+
*/
|
|
31
|
+
prune() {
|
|
32
|
+
const currentTime = Date.now();
|
|
33
|
+
for (const [key, entry] of this.#inner.entries()) {
|
|
34
|
+
if (currentTime - entry.timestamp > this.#expirationTime) {
|
|
35
|
+
this.#inner.delete(key);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
// Implementing the Map interface
|
|
41
|
+
/**
|
|
42
|
+
* Set the value for the given key. Prunes expired entries.
|
|
43
|
+
* @param key for the entry
|
|
44
|
+
* @param value of the entry
|
|
45
|
+
* @returns this
|
|
46
|
+
*/
|
|
47
|
+
set(key, value) {
|
|
48
|
+
this.prune();
|
|
49
|
+
const entry = {
|
|
50
|
+
value,
|
|
51
|
+
timestamp: Date.now(),
|
|
52
|
+
};
|
|
53
|
+
this.#inner.set(key, entry);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the value associated with the key, if it exists and has not expired.
|
|
58
|
+
* @param key K
|
|
59
|
+
* @returns the value associated with the key, or undefined if the key is not present or has expired.
|
|
60
|
+
*/
|
|
61
|
+
get(key) {
|
|
62
|
+
const entry = this.#inner.get(key);
|
|
63
|
+
if (entry === undefined) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
if (Date.now() - entry.timestamp > this.#expirationTime) {
|
|
67
|
+
this.#inner.delete(key);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return entry.value;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Clear all entries.
|
|
74
|
+
*/
|
|
75
|
+
clear() {
|
|
76
|
+
this.#inner.clear();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Entries returns the entries of the map, without the expiration time.
|
|
80
|
+
* @returns an iterator over the entries of the map.
|
|
81
|
+
*/
|
|
82
|
+
entries() {
|
|
83
|
+
const iterator = this.#inner.entries();
|
|
84
|
+
const generator = function* () {
|
|
85
|
+
for (const [key, value] of iterator) {
|
|
86
|
+
yield [key, value.value];
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
};
|
|
90
|
+
return generator();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Values returns the values of the map, without the expiration time.
|
|
94
|
+
* @returns an iterator over the values of the map.
|
|
95
|
+
*/
|
|
96
|
+
values() {
|
|
97
|
+
const iterator = this.#inner.values();
|
|
98
|
+
const generator = function* () {
|
|
99
|
+
for (const value of iterator) {
|
|
100
|
+
yield value.value;
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
};
|
|
104
|
+
return generator();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Keys returns the keys of the map
|
|
108
|
+
* @returns an iterator over the keys of the map.
|
|
109
|
+
*/
|
|
110
|
+
keys() {
|
|
111
|
+
return this.#inner.keys();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* forEach calls the callbackfn on each entry of the map.
|
|
115
|
+
* @param callbackfn to call on each entry
|
|
116
|
+
* @param thisArg to use as this when calling the callbackfn
|
|
117
|
+
*/
|
|
118
|
+
forEach(callbackfn, thisArg) {
|
|
119
|
+
for (const [key, value] of this.#inner.entries()) {
|
|
120
|
+
callbackfn.call(thisArg, value.value, key, this);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* has returns true if the key exists and has not expired.
|
|
125
|
+
* @param key K
|
|
126
|
+
* @returns true if the key exists and has not expired.
|
|
127
|
+
*/
|
|
128
|
+
has(key) {
|
|
129
|
+
return this.#inner.has(key);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* delete the entry for the given key.
|
|
133
|
+
* @param key K
|
|
134
|
+
* @returns true if the key existed and has been deleted.
|
|
135
|
+
*/
|
|
136
|
+
delete(key) {
|
|
137
|
+
return this.#inner.delete(key);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* get size of the map.
|
|
141
|
+
* @returns the size of the map.
|
|
142
|
+
*/
|
|
143
|
+
get size() {
|
|
144
|
+
return this.#inner.size;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.ExpirableMap = ExpirableMap;
|
|
148
|
+
//# sourceMappingURL=expirableMap.js.map
|