@darkbio/crypto 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/index.js +393 -393
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/wasm/darkbio_crypto_wasm.js","../src/rand.ts","../src/hkdf.ts","../src/argon2.ts","../src/xdsa.ts","../src/xhpke.ts","../node_modules/cborg/lib/is.js","../node_modules/cborg/lib/token.js","../node_modules/cborg/lib/byte-utils.js","../node_modules/cborg/lib/bl.js","../node_modules/cborg/lib/common.js","../node_modules/cborg/lib/0uint.js","../node_modules/cborg/lib/1negint.js","../node_modules/cborg/lib/2bytes.js","../node_modules/cborg/lib/3string.js","../node_modules/cborg/lib/4array.js","../node_modules/cborg/lib/5map.js","../node_modules/cborg/lib/6tag.js","../node_modules/cborg/lib/7float.js","../node_modules/cborg/lib/jump.js","../node_modules/cborg/lib/encode.js","../node_modules/cborg/lib/decode.js","../src/cose.ts"],"sourcesContent":["/* @ts-self-types=\"./darkbio_crypto_wasm.d.ts\" */\n\n/**\n * Derives a key from the password, salt, and cost parameters using Argon2id,\n * returning a byte array that can be used as a cryptographic key. The CPU cost\n * and parallelism degree must be greater than zero.\n *\n * RFC 9106 Section 7.4 recommends time=1, and memory=2048*1024 as a sensible\n * number. If using that amount of memory (2GB) is not possible in some contexts\n * then the time parameter can be increased to compensate.\n *\n * The time parameter specifies the number of passes over the memory and the\n * memory parameter specifies the size of the memory in KiB. The number of threads\n * can be adjusted to the numbers of available CPUs. The cost parameters should be\n * increased as memory latency and CPU parallelism increases. Remember to get a\n * good random salt.\n * @param {Uint8Array} password\n * @param {Uint8Array} salt\n * @param {number} time\n * @param {number} memory\n * @param {number} threads\n * @param {number} out_len\n * @returns {Uint8Array}\n */\nexport function argon2_key(password, salt, time, memory, threads, out_len) {\n const ptr0 = passArray8ToWasm0(password, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.argon2_key(ptr0, len0, ptr1, len1, time, memory, threads, out_len);\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Verifies that data is valid CBOR using the restricted type system.\n * @param {Uint8Array} data\n */\nexport function cbor_verify(data) {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cbor_verify(ptr0, len0);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n}\n\n/**\n * Decrypts a sealed message without verifying the signature.\n * @param {Uint8Array} msg_to_open\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} recipient\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_decrypt(msg_to_open, msg_to_auth, recipient, domain) {\n const ptr0 = passArray8ToWasm0(msg_to_open, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(recipient, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_decrypt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Encrypts an already-signed COSE_Sign1 to a recipient.\n * @param {Uint8Array} sign1\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} recipient\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_encrypt(sign1, msg_to_auth, recipient, domain) {\n const ptr0 = passArray8ToWasm0(sign1, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(recipient, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_encrypt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Decrypts and verifies a sealed message.\n * @param {Uint8Array} msg_to_open\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} recipient\n * @param {Uint8Array} sender\n * @param {Uint8Array} domain\n * @param {bigint | null} [max_drift_secs]\n * @returns {Uint8Array}\n */\nexport function cose_open(msg_to_open, msg_to_auth, recipient, sender, domain, max_drift_secs) {\n const ptr0 = passArray8ToWasm0(msg_to_open, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(recipient, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(sender, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ptr4 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len4 = WASM_VECTOR_LEN;\n const ret = wasm.cose_open(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, !isLikeNone(max_drift_secs), isLikeNone(max_drift_secs) ? BigInt(0) : max_drift_secs);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v6;\n}\n\n/**\n * Extracts the embedded payload from a COSE_Sign1 without verifying.\n * @param {Uint8Array} signature\n * @returns {Uint8Array}\n */\nexport function cose_peek(signature) {\n const ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cose_peek(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Extracts the recipient's fingerprint from a COSE_Encrypt0 without decrypting.\n * @param {Uint8Array} ciphertext\n * @returns {Uint8Array}\n */\nexport function cose_recipient(ciphertext) {\n const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cose_recipient(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Signs a message then encrypts it to a recipient (sign-then-encrypt).\n * @param {Uint8Array} msg_to_seal\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} signer\n * @param {Uint8Array} recipient\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_seal(msg_to_seal, msg_to_auth, signer, recipient, domain) {\n const ptr0 = passArray8ToWasm0(msg_to_seal, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(recipient, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ptr4 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len4 = WASM_VECTOR_LEN;\n const ret = wasm.cose_seal(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v6;\n}\n\n/**\n * Creates a COSE_Sign1 signature with an embedded payload.\n * @param {Uint8Array} msg_to_embed\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} signer\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_sign(msg_to_embed, msg_to_auth, signer, domain) {\n const ptr0 = passArray8ToWasm0(msg_to_embed, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_sign(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Creates a COSE_Sign1 signature without an embedded payload (detached mode).\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} signer\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_sign_detached(msg_to_auth, signer, domain) {\n const ptr0 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.cose_sign_detached(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v4;\n}\n\n/**\n * Extracts the signer's fingerprint from a COSE_Sign1 without verifying.\n * @param {Uint8Array} signature\n * @returns {Uint8Array}\n */\nexport function cose_signer(signature) {\n const ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cose_signer(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Verifies a COSE_Sign1 signature and returns the embedded payload.\n * @param {Uint8Array} msg_to_check\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} verifier\n * @param {Uint8Array} domain\n * @param {bigint | null} [max_drift_secs]\n * @returns {Uint8Array}\n */\nexport function cose_verify(msg_to_check, msg_to_auth, verifier, domain, max_drift_secs) {\n const ptr0 = passArray8ToWasm0(msg_to_check, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(verifier, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, !isLikeNone(max_drift_secs), isLikeNone(max_drift_secs) ? BigInt(0) : max_drift_secs);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Verifies a COSE_Sign1 signature with a detached payload.\n * @param {Uint8Array} msg_to_check\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} verifier\n * @param {Uint8Array} domain\n * @param {bigint | null} [max_drift_secs]\n */\nexport function cose_verify_detached(msg_to_check, msg_to_auth, verifier, domain, max_drift_secs) {\n const ptr0 = passArray8ToWasm0(msg_to_check, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(verifier, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_verify_detached(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, !isLikeNone(max_drift_secs), isLikeNone(max_drift_secs) ? BigInt(0) : max_drift_secs);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n}\n\n/**\n * Derives a key using the given pseudorandom key and optional context info,\n * skipping the extraction step.\n *\n * The pseudorandom key should have been generated by hkdf_extract, or be a\n * uniformly random or pseudorandom cryptographically strong key. See RFC 5869,\n * Section 3.3. Most common scenarios will want to use hkdf_key instead.\n * @param {Uint8Array} prk\n * @param {Uint8Array} info\n * @param {number} out_len\n * @returns {Uint8Array}\n */\nexport function hkdf_expand(prk, info, out_len) {\n const ptr0 = passArray8ToWasm0(prk, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.hkdf_expand(ptr0, len0, ptr1, len1, out_len);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Generates a pseudorandom key for use with hkdf_expand from an input secret\n * and an optional independent salt.\n *\n * Only use this function if you need to reuse the extracted key with multiple\n * expand invocations and different context values. Most common scenarios,\n * including the generation of multiple keys, should use hkdf_key instead.\n * @param {Uint8Array} secret\n * @param {Uint8Array} salt\n * @returns {Uint8Array}\n */\nexport function hkdf_extract(secret, salt) {\n const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.hkdf_extract(ptr0, len0, ptr1, len1);\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Derives a key from the secret, salt, and info using HKDF-SHA256, returning a\n * byte array that can be used as a cryptographic key.\n *\n * Panics if out_len exceeds the maximum output length for SHA-256 HKDF, which is\n * 255 * 32 = 8160 bytes.\n * @param {Uint8Array} secret\n * @param {Uint8Array} salt\n * @param {Uint8Array} info\n * @param {number} out_len\n * @returns {Uint8Array}\n */\nexport function hkdf_key(secret, salt, info, out_len) {\n const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.hkdf_key(ptr0, len0, ptr1, len1, ptr2, len2, out_len);\n var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v4;\n}\n\n/**\n * Generates an arbitrarily large buffer filled with randomness.\n * @param {number} bytes\n * @returns {Uint8Array}\n */\nexport function rand_generate(bytes) {\n const ret = wasm.rand_generate(bytes);\n var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v1;\n}\n\n/**\n * Computes the fingerprint (SHA-256 hash) of a public key.\n * @param {Uint8Array} public_key\n * @returns {Uint8Array}\n */\nexport function xdsa_fingerprint(public_key) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_fingerprint(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of a key fingerprint in bytes.\n * @returns {number}\n */\nexport function xdsa_fingerprint_size() {\n const ret = wasm.xdsa_fingerprint_size();\n return ret >>> 0;\n}\n\n/**\n * Generates a new random private key.\n * @returns {Uint8Array}\n */\nexport function xdsa_generate() {\n const ret = wasm.xdsa_generate();\n var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v1;\n}\n\n/**\n * Derives the public key from a secret key.\n * @param {Uint8Array} secret_key\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key(secret_key) {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Parses a public key from a DER-encoded X.509 certificate, verifying the signature.\n * Returns: public key (1984 bytes) || not_before (8 bytes BE) || not_after (8 bytes BE)\n * @param {Uint8Array} der\n * @param {Uint8Array} signer\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key_from_cert_der(der, signer) {\n const ptr0 = passArray8ToWasm0(der, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_from_cert_der(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Parses a public key from a PEM-encoded X.509 certificate, verifying the signature.\n * Returns: public key (1984 bytes) || not_before (8 bytes BE) || not_after (8 bytes BE)\n * @param {string} pem\n * @param {Uint8Array} signer\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key_from_cert_pem(pem, signer) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_from_cert_pem(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Parses a public key from PEM format.\n * @param {string} pem\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key_from_pem(pem) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_from_pem(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the public key in bytes.\n * Format: ML-DSA (1952 bytes) || Ed25519 (32 bytes)\n * @returns {number}\n */\nexport function xdsa_public_key_size() {\n const ret = wasm.xdsa_public_key_size();\n return ret >>> 0;\n}\n\n/**\n * Generates a DER-encoded X.509 certificate for a public key, signed by an issuer.\n * @param {Uint8Array} public_key\n * @param {Uint8Array} signer\n * @param {string} subject_name\n * @param {string} issuer_name\n * @param {bigint} not_before\n * @param {bigint} not_after\n * @param {boolean} is_ca\n * @param {number | null} [path_len]\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key_to_cert_der(public_key, signer, subject_name, issuer_name, not_before, not_after, is_ca, path_len) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(subject_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(issuer_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_to_cert_der(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, not_before, not_after, is_ca, isLikeNone(path_len) ? 0xFFFFFF : path_len);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Generates a PEM-encoded X.509 certificate for a public key, signed by an issuer.\n * @param {Uint8Array} public_key\n * @param {Uint8Array} signer\n * @param {string} subject_name\n * @param {string} issuer_name\n * @param {bigint} not_before\n * @param {bigint} not_after\n * @param {boolean} is_ca\n * @param {number | null} [path_len]\n * @returns {string}\n */\nexport function xdsa_public_key_to_cert_pem(public_key, signer, subject_name, issuer_name, not_before, not_after, is_ca, path_len) {\n let deferred6_0;\n let deferred6_1;\n try {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(subject_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(issuer_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_to_cert_pem(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, not_before, not_after, is_ca, isLikeNone(path_len) ? 0xFFFFFF : path_len);\n var ptr5 = ret[0];\n var len5 = ret[1];\n if (ret[3]) {\n ptr5 = 0; len5 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred6_0 = ptr5;\n deferred6_1 = len5;\n return getStringFromWasm0(ptr5, len5);\n } finally {\n wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);\n }\n}\n\n/**\n * Serializes a public key to PEM format.\n * @param {Uint8Array} public_key\n * @returns {string}\n */\nexport function xdsa_public_key_to_pem(public_key) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_to_pem(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Parses a secret key from PEM format.\n * @param {string} pem\n * @returns {Uint8Array}\n */\nexport function xdsa_secret_key_from_pem(pem) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_secret_key_from_pem(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the secret key in bytes.\n * Format: ML-DSA seed (32 bytes) || Ed25519 seed (32 bytes)\n * @returns {number}\n */\nexport function xdsa_secret_key_size() {\n const ret = wasm.xdsa_secret_key_size();\n return ret >>> 0;\n}\n\n/**\n * Serializes a secret key to PEM format.\n * @param {Uint8Array} secret_key\n * @returns {string}\n */\nexport function xdsa_secret_key_to_pem(secret_key) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_secret_key_to_pem(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Signs a message with a secret key.\n * @param {Uint8Array} secret_key\n * @param {Uint8Array} message\n * @returns {Uint8Array}\n */\nexport function xdsa_sign(secret_key, message) {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_sign(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Size of a composite signature in bytes.\n * Format: ML-DSA (3309 bytes) || Ed25519 (64 bytes)\n * @returns {number}\n */\nexport function xdsa_signature_size() {\n const ret = wasm.xdsa_signature_size();\n return ret >>> 0;\n}\n\n/**\n * Verifies a signature on a message with a public key.\n * @param {Uint8Array} public_key\n * @param {Uint8Array} message\n * @param {Uint8Array} signature\n * @returns {boolean}\n */\nexport function xdsa_verify(public_key, message, signature) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_verify(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n}\n\n/**\n * Size of the encapsulated key in bytes.\n * @returns {number}\n */\nexport function xhpke_encap_key_size() {\n const ret = wasm.xhpke_encap_key_size();\n return ret >>> 0;\n}\n\n/**\n * Computes the fingerprint (SHA-256 hash) of a public key.\n * @param {Uint8Array} public_key\n * @returns {Uint8Array}\n */\nexport function xhpke_fingerprint(public_key) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_fingerprint(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the fingerprint in bytes.\n * @returns {number}\n */\nexport function xhpke_fingerprint_size() {\n const ret = wasm.xdsa_fingerprint_size();\n return ret >>> 0;\n}\n\n/**\n * Generates a new random private key.\n * @returns {Uint8Array}\n */\nexport function xhpke_generate() {\n const ret = wasm.xhpke_generate();\n var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v1;\n}\n\n/**\n * Opens (decrypts) a sealed message with a secret key.\n * Input: encapsulated key (1120 bytes) || ciphertext\n * @param {Uint8Array} secret_key\n * @param {Uint8Array} sealed\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function xhpke_open(secret_key, sealed, msg_to_auth, domain) {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(sealed, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_open(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Derives the public key from a secret key.\n * @param {Uint8Array} secret_key\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key(secret_key) {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Parses a public key from a DER-encoded X.509 certificate, verifying the signature.\n * Returns: public key (1216 bytes) || not_before (8 bytes BE) || not_after (8 bytes BE)\n * @param {Uint8Array} der\n * @param {Uint8Array} signer\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key_from_cert_der(der, signer) {\n const ptr0 = passArray8ToWasm0(der, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_from_cert_der(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Parses a public key from a PEM-encoded X.509 certificate, verifying the signature.\n * Returns: public key (1216 bytes) || not_before (8 bytes BE) || not_after (8 bytes BE)\n * @param {string} pem\n * @param {Uint8Array} signer\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key_from_cert_pem(pem, signer) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_from_cert_pem(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Parses a public key from PEM format.\n * @param {string} pem\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key_from_pem(pem) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_from_pem(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the public key in bytes.\n * @returns {number}\n */\nexport function xhpke_public_key_size() {\n const ret = wasm.xhpke_public_key_size();\n return ret >>> 0;\n}\n\n/**\n * Generates a DER-encoded X.509 certificate for a public key, signed by an xDSA issuer.\n * Note: HPKE certificates are always end-entity certificates (is_ca is ignored).\n * @param {Uint8Array} public_key\n * @param {Uint8Array} signer\n * @param {string} subject_name\n * @param {string} issuer_name\n * @param {bigint} not_before\n * @param {bigint} not_after\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key_to_cert_der(public_key, signer, subject_name, issuer_name, not_before, not_after) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(subject_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(issuer_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_to_cert_der(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, not_before, not_after);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Generates a PEM-encoded X.509 certificate for a public key, signed by an xDSA issuer.\n * Note: HPKE certificates are always end-entity certificates (is_ca is ignored).\n * @param {Uint8Array} public_key\n * @param {Uint8Array} signer\n * @param {string} subject_name\n * @param {string} issuer_name\n * @param {bigint} not_before\n * @param {bigint} not_after\n * @returns {string}\n */\nexport function xhpke_public_key_to_cert_pem(public_key, signer, subject_name, issuer_name, not_before, not_after) {\n let deferred6_0;\n let deferred6_1;\n try {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(subject_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(issuer_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_to_cert_pem(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, not_before, not_after);\n var ptr5 = ret[0];\n var len5 = ret[1];\n if (ret[3]) {\n ptr5 = 0; len5 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred6_0 = ptr5;\n deferred6_1 = len5;\n return getStringFromWasm0(ptr5, len5);\n } finally {\n wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);\n }\n}\n\n/**\n * Serializes a public key to PEM format.\n * @param {Uint8Array} public_key\n * @returns {string}\n */\nexport function xhpke_public_key_to_pem(public_key) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_to_pem(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Seals (encrypts) a message to a public key.\n * Returns: encapsulated key (1120 bytes) || ciphertext\n * @param {Uint8Array} public_key\n * @param {Uint8Array} msg_to_seal\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function xhpke_seal(public_key, msg_to_seal, msg_to_auth, domain) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_seal, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_seal(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Parses a secret key from PEM format.\n * @param {string} pem\n * @returns {Uint8Array}\n */\nexport function xhpke_secret_key_from_pem(pem) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_secret_key_from_pem(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the secret key seed in bytes.\n * @returns {number}\n */\nexport function xhpke_secret_key_size() {\n const ret = wasm.xdsa_fingerprint_size();\n return ret >>> 0;\n}\n\n/**\n * Serializes a secret key to PEM format.\n * @param {Uint8Array} secret_key\n * @returns {string}\n */\nexport function xhpke_secret_key_to_pem(secret_key) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_secret_key_to_pem(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {\n const ret = typeof(arg0) === 'function';\n return ret;\n },\n __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {\n const val = arg0;\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n },\n __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {\n const ret = typeof(arg0) === 'string';\n return ret;\n },\n __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {\n const ret = arg0 === undefined;\n return ret;\n },\n __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {\n const ret = arg0.call(arg1);\n return ret;\n }, arguments); },\n __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.call(arg1, arg2);\n return ret;\n }, arguments); },\n __wbg_crypto_86f2631e91b51511: function(arg0) {\n const ret = arg0.crypto;\n return ret;\n },\n __wbg_getRandomValues_1c61fac11405ffdc: function() { return handleError(function (arg0, arg1) {\n globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));\n }, arguments); },\n __wbg_getRandomValues_71618e716bf191cd: function() { return handleError(function (arg0, arg1) {\n globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));\n }, arguments); },\n __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {\n arg0.getRandomValues(arg1);\n }, arguments); },\n __wbg_length_32ed9a279acd054c: function(arg0) {\n const ret = arg0.length;\n return ret;\n },\n __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {\n const ret = arg0.msCrypto;\n return ret;\n },\n __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {\n const ret = new Function(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {\n const ret = new Uint8Array(arg0 >>> 0);\n return ret;\n },\n __wbg_node_e1f24f89a7336c2e: function(arg0) {\n const ret = arg0.node;\n return ret;\n },\n __wbg_now_a3af9a2f4bbaa4d1: function() {\n const ret = Date.now();\n return ret;\n },\n __wbg_process_3975fd6c72f520aa: function(arg0) {\n const ret = arg0.process;\n return ret;\n },\n __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {\n Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);\n },\n __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {\n arg0.randomFillSync(arg1);\n }, arguments); },\n __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {\n const ret = module.require;\n return ret;\n }, arguments); },\n __wbg_static_accessor_GLOBAL_12837167ad935116: function() {\n const ret = typeof global === 'undefined' ? null : global;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {\n const ret = typeof globalThis === 'undefined' ? null : globalThis;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {\n const ret = typeof self === 'undefined' ? null : self;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {\n const ret = typeof window === 'undefined' ? null : window;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {\n const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);\n return ret;\n },\n __wbg_versions_4e31226f5e8dc909: function(arg0) {\n const ret = arg0.versions;\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0, arg1) {\n // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref(\"Uint8Array\")`.\n const ret = getArrayU8FromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_cast_0000000000000002: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./darkbio_crypto_wasm_bg.js\": import0,\n };\n}\n\nfunction addToExternrefTable0(obj) {\n const idx = wasm.__externref_table_alloc();\n wasm.__wbindgen_externrefs.set(idx, obj);\n return idx;\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n const idx = addToExternrefTable0(e);\n wasm.__wbindgen_exn_store(idx);\n }\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('darkbio_crypto_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, { rand_generate } from \"./wasm/darkbio_crypto_wasm.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/**\n * Generate cryptographically secure random bytes.\n *\n * @param bytes - Number of random bytes to generate\n * @returns A Uint8Array containing the random bytes\n */\nexport async function generate(bytes: number): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(rand_generate(bytes));\n}\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, {\n hkdf_key,\n hkdf_extract,\n hkdf_expand,\n} from \"./wasm/darkbio_crypto_wasm.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/**\n * Derive a key from secret, salt, and info using HKDF-SHA256.\n *\n * @param secret - The input keying material\n * @param salt - Optional salt value (can be empty)\n * @param info - Optional context/application-specific info (can be empty)\n * @param outLen - Desired output length in bytes (max 8160)\n * @returns The derived key\n */\nexport async function key(\n secret: Uint8Array,\n salt: Uint8Array,\n info: Uint8Array,\n outLen: number,\n): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(hkdf_key(secret, salt, info, outLen));\n}\n\n/**\n * Extract a pseudorandom key from secret and salt using HKDF-SHA256.\n *\n * Only use this if you need to reuse the extracted key with multiple\n * expand invocations. Most scenarios should use `key` instead.\n *\n * @param secret - The input keying material\n * @param salt - Optional salt value (can be empty)\n * @returns A 32-byte pseudorandom key\n */\nexport async function extract(\n secret: Uint8Array,\n salt: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(hkdf_extract(secret, salt));\n}\n\n/**\n * Expand a pseudorandom key with info using HKDF-SHA256.\n *\n * The prk should have been generated by `extract` or be a uniformly\n * random 32-byte key.\n *\n * @param prk - A 32-byte pseudorandom key\n * @param info - Optional context/application-specific info (can be empty)\n * @param outLen - Desired output length in bytes (max 8160)\n * @returns The derived key\n */\nexport async function expand(\n prk: Uint8Array,\n info: Uint8Array,\n outLen: number,\n): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(hkdf_expand(prk, info, outLen));\n}\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, { argon2_key } from \"./wasm/darkbio_crypto_wasm.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/**\n * Derive a key from password, salt, and cost parameters using Argon2id.\n *\n * RFC 9106 Section 7.4 recommends time=1, memory=2048*1024 (2GB) as sensible\n * defaults. If that much memory isn't available, increase time to compensate.\n *\n * @param password - The password to derive from\n * @param salt - A random salt (should be at least 16 bytes)\n * @param time - Number of passes over memory (iterations)\n * @param memory - Memory size in KiB\n * @param threads - Degree of parallelism\n * @param outLen - Desired output length in bytes\n * @returns The derived key\n */\nexport async function key(\n password: Uint8Array,\n salt: Uint8Array,\n time: number,\n memory: number,\n threads: number,\n outLen: number,\n): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(\n argon2_key(password, salt, time, memory, threads, outLen),\n );\n}\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, {\n xdsa_secret_key_size,\n xdsa_public_key_size,\n xdsa_signature_size,\n xdsa_fingerprint_size,\n xdsa_generate,\n xdsa_public_key,\n xdsa_fingerprint,\n xdsa_sign,\n xdsa_verify,\n xdsa_secret_key_from_pem,\n xdsa_secret_key_to_pem,\n xdsa_public_key_from_pem,\n xdsa_public_key_to_pem,\n xdsa_public_key_from_cert_pem,\n xdsa_public_key_from_cert_der,\n xdsa_public_key_to_cert_pem,\n xdsa_public_key_to_cert_der,\n} from \"./wasm/darkbio_crypto_wasm.js\";\n\nimport type { Params } from \"./x509.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/** Size of the secret key in bytes (64). */\nexport const SECRET_KEY_SIZE = 64;\n\n/** Size of the public key in bytes (1984). */\nexport const PUBLIC_KEY_SIZE = 1984;\n\n/** Size of a signature in bytes (3373). */\nexport const SIGNATURE_SIZE = 3373;\n\n/** Size of a fingerprint in bytes (32). */\nexport const FINGERPRINT_SIZE = 32;\n\n/**\n * Get the size constants (requires WASM initialization).\n */\nexport async function sizes(): Promise<{\n secretKey: number;\n publicKey: number;\n signature: number;\n fingerprint: number;\n}> {\n await ensureInit();\n return {\n secretKey: xdsa_secret_key_size(),\n publicKey: xdsa_public_key_size(),\n signature: xdsa_signature_size(),\n fingerprint: xdsa_fingerprint_size(),\n };\n}\n\n/**\n * Fingerprint is a 32-byte unique identifier for an xDSA key.\n */\nexport class Fingerprint {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Converts a 32-byte array into a fingerprint. */\n static fromBytes(bytes: Uint8Array): Fingerprint {\n if (bytes.length !== FINGERPRINT_SIZE) {\n throw new Error(`Fingerprint must be ${FINGERPRINT_SIZE} bytes`);\n }\n return new Fingerprint(new Uint8Array(bytes));\n }\n\n /** Converts a fingerprint into a 32-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n}\n\n/**\n * Signature is a 3373-byte xDSA signature.\n * Format: ML-DSA (3309 bytes) || Ed25519 (64 bytes)\n */\nexport class Signature {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Converts a 3373-byte array into a signature. */\n static fromBytes(bytes: Uint8Array): Signature {\n if (bytes.length !== SIGNATURE_SIZE) {\n throw new Error(`Signature must be ${SIGNATURE_SIZE} bytes`);\n }\n return new Signature(new Uint8Array(bytes));\n }\n\n /** Converts a signature into a 3373-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n}\n\n/**\n * PublicKey is an ML-DSA-65 public key paired with an Ed25519 public key for\n * verifying quantum resistant digital signatures.\n * Format: ML-DSA (1952 bytes) || Ed25519 (32 bytes)\n */\nexport class PublicKey {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Converts a 1984-byte array into a public key. */\n static fromBytes(bytes: Uint8Array): PublicKey {\n if (bytes.length !== PUBLIC_KEY_SIZE) {\n throw new Error(`PublicKey must be ${PUBLIC_KEY_SIZE} bytes`);\n }\n return new PublicKey(new Uint8Array(bytes));\n }\n\n /** Parses a PEM string into a public key. */\n static async fromPem(pem: string): Promise<PublicKey> {\n await ensureInit();\n const bytes = new Uint8Array(xdsa_public_key_from_pem(pem));\n return new PublicKey(bytes);\n }\n\n /**\n * Parses a public key from a PEM-encoded X.509 certificate.\n * Verifies the certificate signature against the provided signer.\n *\n * @param pem - PEM-encoded X.509 certificate\n * @param signer - The xDSA public key that signed this certificate\n * @returns The parsed public key and validity period (notBefore, notAfter as Unix timestamps)\n */\n static async fromCertPem(\n pem: string,\n signer: PublicKey,\n ): Promise<{ key: PublicKey; notBefore: bigint; notAfter: bigint }> {\n await ensureInit();\n const result = new Uint8Array(\n xdsa_public_key_from_cert_pem(pem, signer.toBytes()),\n );\n const key = new PublicKey(result.slice(0, PUBLIC_KEY_SIZE));\n const view = new DataView(\n result.buffer,\n result.byteOffset + PUBLIC_KEY_SIZE,\n );\n const notBefore = view.getBigUint64(0, false);\n const notAfter = view.getBigUint64(8, false);\n return { key, notBefore, notAfter };\n }\n\n /**\n * Parses a public key from a DER-encoded X.509 certificate.\n * Verifies the certificate signature against the provided signer.\n *\n * @param der - DER-encoded X.509 certificate\n * @param signer - The xDSA public key that signed this certificate\n * @returns The parsed public key and validity period (notBefore, notAfter as Unix timestamps)\n */\n static async fromCertDer(\n der: Uint8Array,\n signer: PublicKey,\n ): Promise<{ key: PublicKey; notBefore: bigint; notAfter: bigint }> {\n await ensureInit();\n const result = new Uint8Array(\n xdsa_public_key_from_cert_der(der, signer.toBytes()),\n );\n const key = new PublicKey(result.slice(0, PUBLIC_KEY_SIZE));\n const view = new DataView(\n result.buffer,\n result.byteOffset + PUBLIC_KEY_SIZE,\n );\n const notBefore = view.getBigUint64(0, false);\n const notAfter = view.getBigUint64(8, false);\n return { key, notBefore, notAfter };\n }\n\n /** Converts a public key into a 1984-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n\n /** Serializes a public key into a PEM string. */\n async toPem(): Promise<string> {\n await ensureInit();\n return xdsa_public_key_to_pem(this.bytes);\n }\n\n /** Returns a 256-bit unique identifier for this key. */\n async fingerprint(): Promise<Fingerprint> {\n await ensureInit();\n const fp = new Uint8Array(xdsa_fingerprint(this.bytes));\n return Fingerprint.fromBytes(fp);\n }\n\n /** Verifies a digital signature of the message. */\n async verify(message: Uint8Array, signature: Signature): Promise<boolean> {\n await ensureInit();\n return xdsa_verify(this.bytes, message, signature.toBytes());\n }\n\n /**\n * Generates a PEM-encoded X.509 certificate for this public key.\n *\n * @param signer - The xDSA secret key to sign the certificate\n * @param params - Certificate parameters (subject, issuer, validity, etc.)\n * @returns PEM-encoded X.509 certificate\n */\n async toCertPem(signer: SecretKey, params: Params): Promise<string> {\n await ensureInit();\n return xdsa_public_key_to_cert_pem(\n this.bytes,\n signer.toBytes(),\n params.subjectName,\n params.issuerName,\n params.notBefore,\n params.notAfter,\n params.isCa ?? false,\n params.pathLen,\n );\n }\n\n /**\n * Generates a DER-encoded X.509 certificate for this public key.\n *\n * @param signer - The xDSA secret key to sign the certificate\n * @param params - Certificate parameters (subject, issuer, validity, etc.)\n * @returns DER-encoded X.509 certificate\n */\n async toCertDer(signer: SecretKey, params: Params): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(\n xdsa_public_key_to_cert_der(\n this.bytes,\n signer.toBytes(),\n params.subjectName,\n params.issuerName,\n params.notBefore,\n params.notAfter,\n params.isCa ?? false,\n params.pathLen,\n ),\n );\n }\n}\n\n/**\n * SecretKey is an ML-DSA-65 private key paired with an Ed25519 private key for\n * creating quantum resistant digital signatures.\n * Format: ML-DSA seed (32 bytes) || Ed25519 seed (32 bytes)\n */\nexport class SecretKey {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Creates a new, random private key. */\n static async generate(): Promise<SecretKey> {\n await ensureInit();\n const bytes = new Uint8Array(xdsa_generate());\n return new SecretKey(bytes);\n }\n\n /** Creates a private key from a 64-byte seed. */\n static fromBytes(bytes: Uint8Array): SecretKey {\n if (bytes.length !== SECRET_KEY_SIZE) {\n throw new Error(`SecretKey must be ${SECRET_KEY_SIZE} bytes`);\n }\n return new SecretKey(new Uint8Array(bytes));\n }\n\n /** Parses a PEM string into a private key. */\n static async fromPem(pem: string): Promise<SecretKey> {\n await ensureInit();\n const bytes = new Uint8Array(xdsa_secret_key_from_pem(pem));\n return new SecretKey(bytes);\n }\n\n /** Converts a secret key into a 64-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n\n /** Serializes a private key into a PEM string. */\n async toPem(): Promise<string> {\n await ensureInit();\n return xdsa_secret_key_to_pem(this.bytes);\n }\n\n /** Retrieves the public counterpart of the secret key. */\n async publicKey(): Promise<PublicKey> {\n await ensureInit();\n const pk = new Uint8Array(xdsa_public_key(this.bytes));\n return PublicKey.fromBytes(pk);\n }\n\n /** Returns a 256-bit unique identifier for this key. */\n async fingerprint(): Promise<Fingerprint> {\n const pk = await this.publicKey();\n return pk.fingerprint();\n }\n\n /** Creates a digital signature of the message. */\n async sign(message: Uint8Array): Promise<Signature> {\n await ensureInit();\n const sig = new Uint8Array(xdsa_sign(this.bytes, message));\n return Signature.fromBytes(sig);\n }\n}\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, {\n xhpke_secret_key_size,\n xhpke_public_key_size,\n xhpke_encap_key_size,\n xhpke_fingerprint_size,\n xhpke_generate,\n xhpke_public_key,\n xhpke_fingerprint,\n xhpke_seal,\n xhpke_open,\n xhpke_secret_key_from_pem,\n xhpke_secret_key_to_pem,\n xhpke_public_key_from_pem,\n xhpke_public_key_to_pem,\n xhpke_public_key_from_cert_pem,\n xhpke_public_key_from_cert_der,\n xhpke_public_key_to_cert_pem,\n xhpke_public_key_to_cert_der,\n} from \"./wasm/darkbio_crypto_wasm.js\";\n\nimport {\n PublicKey as XdsaPublicKey,\n SecretKey as XdsaSecretKey,\n} from \"./xdsa.js\";\nimport type { Params } from \"./x509.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/** Size of the secret key seed in bytes (32). */\nexport const SECRET_KEY_SIZE = 32;\n\n/** Size of the public key in bytes (1216). */\nexport const PUBLIC_KEY_SIZE = 1216;\n\n/** Size of the encapsulated key in bytes (1120). */\nexport const ENCAP_KEY_SIZE = 1120;\n\n/** Size of a fingerprint in bytes (32). */\nexport const FINGERPRINT_SIZE = 32;\n\n/**\n * Get the size constants (requires WASM initialization).\n */\nexport async function sizes(): Promise<{\n secretKey: number;\n publicKey: number;\n encapKey: number;\n fingerprint: number;\n}> {\n await ensureInit();\n return {\n secretKey: xhpke_secret_key_size(),\n publicKey: xhpke_public_key_size(),\n encapKey: xhpke_encap_key_size(),\n fingerprint: xhpke_fingerprint_size(),\n };\n}\n\n/**\n * Fingerprint is a 32-byte unique identifier for an xHPKE key.\n * It is the SHA256 hash of the raw public key.\n */\nexport class Fingerprint {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Converts a 32-byte array into a fingerprint. */\n static fromBytes(bytes: Uint8Array): Fingerprint {\n if (bytes.length !== FINGERPRINT_SIZE) {\n throw new Error(`Fingerprint must be ${FINGERPRINT_SIZE} bytes`);\n }\n return new Fingerprint(new Uint8Array(bytes));\n }\n\n /** Converts a fingerprint into a 32-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n}\n\n/**\n * PublicKey contains an X-Wing public key for hybrid post-quantum encryption.\n * Uses X-Wing KEM (ML-KEM-768 + X25519) with HPKE Base mode.\n */\nexport class PublicKey {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /**\n * Converts a 1216-byte array into a public key.\n *\n * This validates the ML-KEM-768 component by checking that all polynomial\n * coefficients are in the valid range [0, 3329).\n */\n static fromBytes(bytes: Uint8Array): PublicKey {\n if (bytes.length !== PUBLIC_KEY_SIZE) {\n throw new Error(`PublicKey must be ${PUBLIC_KEY_SIZE} bytes`);\n }\n return new PublicKey(new Uint8Array(bytes));\n }\n\n /** Parses a PEM string into a public key. */\n static async fromPem(pem: string): Promise<PublicKey> {\n await ensureInit();\n const bytes = new Uint8Array(xhpke_public_key_from_pem(pem));\n return new PublicKey(bytes);\n }\n\n /**\n * Parses a public key from a PEM-encoded X.509 certificate.\n * Verifies the certificate signature against the provided xDSA signer.\n *\n * @param pem - PEM-encoded X.509 certificate\n * @param signer - The xDSA public key that signed this certificate\n * @returns The parsed public key and validity period (notBefore, notAfter as Unix timestamps)\n */\n static async fromCertPem(\n pem: string,\n signer: XdsaPublicKey,\n ): Promise<{ key: PublicKey; notBefore: bigint; notAfter: bigint }> {\n await ensureInit();\n const result = new Uint8Array(\n xhpke_public_key_from_cert_pem(pem, signer.toBytes()),\n );\n const key = new PublicKey(result.slice(0, PUBLIC_KEY_SIZE));\n const view = new DataView(\n result.buffer,\n result.byteOffset + PUBLIC_KEY_SIZE,\n );\n const notBefore = view.getBigUint64(0, false);\n const notAfter = view.getBigUint64(8, false);\n return { key, notBefore, notAfter };\n }\n\n /**\n * Parses a public key from a DER-encoded X.509 certificate.\n * Verifies the certificate signature against the provided xDSA signer.\n *\n * @param der - DER-encoded X.509 certificate\n * @param signer - The xDSA public key that signed this certificate\n * @returns The parsed public key and validity period (notBefore, notAfter as Unix timestamps)\n */\n static async fromCertDer(\n der: Uint8Array,\n signer: XdsaPublicKey,\n ): Promise<{ key: PublicKey; notBefore: bigint; notAfter: bigint }> {\n await ensureInit();\n const result = new Uint8Array(\n xhpke_public_key_from_cert_der(der, signer.toBytes()),\n );\n const key = new PublicKey(result.slice(0, PUBLIC_KEY_SIZE));\n const view = new DataView(\n result.buffer,\n result.byteOffset + PUBLIC_KEY_SIZE,\n );\n const notBefore = view.getBigUint64(0, false);\n const notAfter = view.getBigUint64(8, false);\n return { key, notBefore, notAfter };\n }\n\n /** Converts a public key into a 1216-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n\n /** Serializes a public key into a PEM string. */\n async toPem(): Promise<string> {\n await ensureInit();\n return xhpke_public_key_to_pem(this.bytes);\n }\n\n /** Returns a 256-bit unique identifier for this key (SHA256 of raw public key). */\n async fingerprint(): Promise<Fingerprint> {\n await ensureInit();\n const fp = new Uint8Array(xhpke_fingerprint(this.bytes));\n return Fingerprint.fromBytes(fp);\n }\n\n /**\n * Seal (encrypt) a message to this public key.\n *\n * Uses X-Wing KEM (ML-KEM-768 + X25519) with HPKE Base mode.\n *\n * @param msgToSeal - The message to encrypt\n * @param msgToAuth - Additional data to authenticate (but not encrypt)\n * @param domain - Application domain for context separation\n * @returns Sealed data (encapsulated key + ciphertext)\n */\n async seal(\n msgToSeal: Uint8Array,\n msgToAuth: Uint8Array,\n domain: Uint8Array,\n ): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(xhpke_seal(this.bytes, msgToSeal, msgToAuth, domain));\n }\n\n /**\n * Generates a PEM-encoded X.509 certificate for this public key.\n * Note: HPKE certificates are always end-entity certificates.\n *\n * @param signer - The xDSA secret key to sign the certificate\n * @param params - Certificate parameters (subject, issuer, validity)\n * @returns PEM-encoded X.509 certificate\n */\n async toCertPem(signer: XdsaSecretKey, params: Params): Promise<string> {\n await ensureInit();\n return xhpke_public_key_to_cert_pem(\n this.bytes,\n signer.toBytes(),\n params.subjectName,\n params.issuerName,\n params.notBefore,\n params.notAfter,\n );\n }\n\n /**\n * Generates a DER-encoded X.509 certificate for this public key.\n * Note: HPKE certificates are always end-entity certificates.\n *\n * @param signer - The xDSA secret key to sign the certificate\n * @param params - Certificate parameters (subject, issuer, validity)\n * @returns DER-encoded X.509 certificate\n */\n async toCertDer(signer: XdsaSecretKey, params: Params): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(\n xhpke_public_key_to_cert_der(\n this.bytes,\n signer.toBytes(),\n params.subjectName,\n params.issuerName,\n params.notBefore,\n params.notAfter,\n ),\n );\n }\n}\n\n/**\n * SecretKey contains an X-Wing private key for hybrid post-quantum encryption.\n * Uses X-Wing KEM (ML-KEM-768 + X25519) with HPKE Base mode.\n */\nexport class SecretKey {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Creates a new, random private key. */\n static async generate(): Promise<SecretKey> {\n await ensureInit();\n const bytes = new Uint8Array(xhpke_generate());\n return new SecretKey(bytes);\n }\n\n /** Converts a 32-byte seed into a private key. */\n static fromBytes(bytes: Uint8Array): SecretKey {\n if (bytes.length !== SECRET_KEY_SIZE) {\n throw new Error(`SecretKey must be ${SECRET_KEY_SIZE} bytes`);\n }\n return new SecretKey(new Uint8Array(bytes));\n }\n\n /** Parses a PEM string into a private key. */\n static async fromPem(pem: string): Promise<SecretKey> {\n await ensureInit();\n const bytes = new Uint8Array(xhpke_secret_key_from_pem(pem));\n return new SecretKey(bytes);\n }\n\n /** Converts a private key into a 32-byte seed. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n\n /** Serializes a private key into a PEM string. */\n async toPem(): Promise<string> {\n await ensureInit();\n return xhpke_secret_key_to_pem(this.bytes);\n }\n\n /** Retrieves the public counterpart of the secret key. */\n async publicKey(): Promise<PublicKey> {\n await ensureInit();\n const pk = new Uint8Array(xhpke_public_key(this.bytes));\n return PublicKey.fromBytes(pk);\n }\n\n /** Returns a 256-bit unique identifier for this key (SHA256 of raw public key). */\n async fingerprint(): Promise<Fingerprint> {\n const pk = await this.publicKey();\n return pk.fingerprint();\n }\n\n /**\n * Open (decrypt) a sealed message with this secret key.\n *\n * Deconstructs the encapsulated key and ciphertext, verifying the\n * authenticity of the (unencrypted) message-to-auth.\n *\n * Note: X-Wing uses Base mode (no sender authentication). The sender's\n * identity cannot be verified from the ciphertext alone.\n *\n * @param sealed - The sealed data from `seal()`\n * @param msgToAuth - The same additional authenticated data used during sealing\n * @param domain - The same application domain used during sealing\n * @returns The decrypted message\n * @throws If decryption fails (wrong key, tampered data, or wrong AAD/domain)\n */\n async open(\n sealed: Uint8Array,\n msgToAuth: Uint8Array,\n domain: Uint8Array,\n ): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(xhpke_open(this.bytes, sealed, msgToAuth, domain));\n }\n}\n","// This is an unfortunate replacement for @sindresorhus/is that we need to\n// re-implement for performance purposes. In particular the is.observable()\n// check is expensive, and unnecessary for our purposes. The values returned\n// are compatible with @sindresorhus/is, however.\n\n// Types that reach getObjectType() - excludes types with fast-paths above:\n// primitives (typeof), Array (isArray), Uint8Array (instanceof), plain Object (constructor)\nconst objectTypeNames = [\n 'Object', // for Object.create(null) and other non-plain objects\n 'RegExp',\n 'Date',\n 'Error',\n 'Map',\n 'Set',\n 'WeakMap',\n 'WeakSet',\n 'ArrayBuffer',\n 'SharedArrayBuffer',\n 'DataView',\n 'Promise',\n 'URL',\n 'HTMLElement',\n 'Int8Array',\n 'Uint8ClampedArray',\n 'Int16Array',\n 'Uint16Array',\n 'Int32Array',\n 'Uint32Array',\n 'Float32Array',\n 'Float64Array',\n 'BigInt64Array',\n 'BigUint64Array'\n]\n\n/**\n * @param {any} value\n * @returns {string}\n */\nexport function is (value) {\n if (value === null) {\n return 'null'\n }\n if (value === undefined) {\n return 'undefined'\n }\n if (value === true || value === false) {\n return 'boolean'\n }\n const typeOf = typeof value\n if (typeOf === 'string' || typeOf === 'number' || typeOf === 'bigint' || typeOf === 'symbol') {\n return typeOf\n }\n /* c8 ignore next 3 */\n if (typeOf === 'function') {\n return 'Function'\n }\n if (Array.isArray(value)) {\n return 'Array'\n }\n // Also catches Node.js Buffer which extends Uint8Array\n if (value instanceof Uint8Array) {\n return 'Uint8Array'\n }\n // Fast path for plain objects (most common case after primitives/arrays/bytes)\n if (value.constructor === Object) {\n return 'Object'\n }\n const objectType = getObjectType(value)\n if (objectType) {\n return objectType\n }\n /* c8 ignore next */\n return 'Object'\n}\n\n/**\n * @param {any} value\n * @returns {string|undefined}\n */\nfunction getObjectType (value) {\n const objectTypeName = Object.prototype.toString.call(value).slice(8, -1)\n if (objectTypeNames.includes(objectTypeName)) {\n return objectTypeName\n }\n /* c8 ignore next */\n return undefined\n}\n","class Type {\n /**\n * @param {number} major\n * @param {string} name\n * @param {boolean} terminal\n */\n constructor (major, name, terminal) {\n this.major = major\n this.majorEncoded = major << 5\n this.name = name\n this.terminal = terminal\n }\n\n /* c8 ignore next 3 */\n toString () {\n return `Type[${this.major}].${this.name}`\n }\n\n /**\n * @param {Type} typ\n * @returns {number}\n */\n compare (typ) {\n /* c8 ignore next 1 */\n return this.major < typ.major ? -1 : this.major > typ.major ? 1 : 0\n }\n\n /**\n * Check equality between two Type instances. Safe to use across different\n * copies of the Type class (e.g., when bundlers duplicate the module).\n * (major, name) uniquely identifies a Type; terminal is implied by these.\n * @param {Type} a\n * @param {Type} b\n * @returns {boolean}\n */\n static equals (a, b) {\n return a === b || (a.major === b.major && a.name === b.name)\n }\n}\n\n// convert to static fields when better supported\nType.uint = new Type(0, 'uint', true)\nType.negint = new Type(1, 'negint', true)\nType.bytes = new Type(2, 'bytes', true)\nType.string = new Type(3, 'string', true)\nType.array = new Type(4, 'array', false)\nType.map = new Type(5, 'map', false)\nType.tag = new Type(6, 'tag', false) // terminal?\nType.float = new Type(7, 'float', true)\nType.false = new Type(7, 'false', true)\nType.true = new Type(7, 'true', true)\nType.null = new Type(7, 'null', true)\nType.undefined = new Type(7, 'undefined', true)\nType.break = new Type(7, 'break', true)\n// Type.indefiniteLength = new Type(0, 'indefiniteLength', true)\n\nclass Token {\n /**\n * @param {Type} type\n * @param {any} [value]\n * @param {number} [encodedLength]\n */\n constructor (type, value, encodedLength) {\n this.type = type\n this.value = value\n this.encodedLength = encodedLength\n /** @type {Uint8Array|undefined} */\n this.encodedBytes = undefined\n /** @type {Uint8Array|undefined} */\n this.byteValue = undefined\n }\n\n /* c8 ignore next 3 */\n toString () {\n return `Token[${this.type}].${this.value}`\n }\n}\n\nexport { Type, Token }\n","// Use Uint8Array directly in the browser, use Buffer in Node.js but don't\n// speak its name directly to avoid bundlers pulling in the `Buffer` polyfill\n\n// @ts-ignore\nexport const useBuffer = globalThis.process &&\n // @ts-ignore\n !globalThis.process.browser &&\n // @ts-ignore\n globalThis.Buffer &&\n // @ts-ignore\n typeof globalThis.Buffer.isBuffer === 'function'\n\nconst textEncoder = new TextEncoder()\n\n/**\n * @param {Uint8Array} buf\n * @returns {boolean}\n */\nfunction isBuffer (buf) {\n // @ts-ignore\n return useBuffer && globalThis.Buffer.isBuffer(buf)\n}\n\n/**\n * @param {Uint8Array|number[]} buf\n * @returns {Uint8Array}\n */\nexport function asU8A (buf) {\n /* c8 ignore next */\n if (!(buf instanceof Uint8Array)) {\n return Uint8Array.from(buf)\n }\n return isBuffer(buf) ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : buf\n}\n\n// Threshold for manual UTF-8 encoding vs native methods.\n// Node.js Buffer.from: crossover ~24 chars\n// Browser TextEncoder: crossover ~200 chars\nconst FROM_STRING_THRESHOLD_BUFFER = 24\nconst FROM_STRING_THRESHOLD_TEXTENCODER = 200\n\nexport const fromString = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {string} string\n */\n (string) => {\n return string.length >= FROM_STRING_THRESHOLD_BUFFER\n ? // eslint-disable-line operator-linebreak\n // @ts-ignore\n globalThis.Buffer.from(string)\n : utf8ToBytes(string)\n }\n /* c8 ignore next 7 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {string} string\n */\n (string) => {\n return string.length >= FROM_STRING_THRESHOLD_TEXTENCODER ? textEncoder.encode(string) : utf8ToBytes(string)\n }\n\n/**\n * Buffer variant not fast enough for what we need\n * @param {number[]} arr\n * @returns {Uint8Array}\n */\nexport const fromArray = (arr) => {\n return Uint8Array.from(arr)\n}\n\nexport const slice = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array} bytes\n * @param {number} start\n * @param {number} end\n */\n // Buffer.slice() returns a view, not a copy, so we need special handling\n (bytes, start, end) => {\n if (isBuffer(bytes)) {\n return new Uint8Array(bytes.subarray(start, end))\n }\n return bytes.slice(start, end)\n }\n /* c8 ignore next 9 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array} bytes\n * @param {number} start\n * @param {number} end\n */\n (bytes, start, end) => {\n return bytes.slice(start, end)\n }\n\nexport const concat = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array[]} chunks\n * @param {number} length\n * @returns {Uint8Array}\n */\n (chunks, length) => {\n // might get a stray plain Array here\n /* c8 ignore next 1 */\n chunks = chunks.map((c) => c instanceof Uint8Array\n ? c\n // this case is occasionally missed during test runs so becomes coverage-flaky\n /* c8 ignore next 4 */\n : // eslint-disable-line operator-linebreak\n // @ts-ignore\n globalThis.Buffer.from(c))\n // @ts-ignore\n return asU8A(globalThis.Buffer.concat(chunks, length))\n }\n /* c8 ignore next 19 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array[]} chunks\n * @param {number} length\n * @returns {Uint8Array}\n */\n (chunks, length) => {\n const out = new Uint8Array(length)\n let off = 0\n for (let b of chunks) {\n if (off + b.length > out.length) {\n // final chunk that's bigger than we need\n b = b.subarray(0, out.length - off)\n }\n out.set(b, off)\n off += b.length\n }\n return out\n }\n\nexport const alloc = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {number} size\n * @returns {Uint8Array}\n */\n (size) => {\n // we always write over the contents we expose so this should be safe\n // @ts-ignore\n return globalThis.Buffer.allocUnsafe(size)\n }\n /* c8 ignore next 8 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {number} size\n * @returns {Uint8Array}\n */\n (size) => {\n return new Uint8Array(size)\n }\n\nexport const toHex = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array} d\n * @returns {string}\n */\n (d) => {\n if (typeof d === 'string') {\n return d\n }\n // @ts-ignore\n return globalThis.Buffer.from(toBytes(d)).toString('hex')\n }\n /* c8 ignore next 12 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array} d\n * @returns {string}\n */\n (d) => {\n if (typeof d === 'string') {\n return d\n }\n // @ts-ignore not smart enough to figure this out\n return Array.prototype.reduce.call(toBytes(d), (p, c) => `${p}${c.toString(16).padStart(2, '0')}`, '')\n }\n\nexport const fromHex = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {string|Uint8Array} hex\n * @returns {Uint8Array}\n */\n (hex) => {\n if (hex instanceof Uint8Array) {\n return hex\n }\n // @ts-ignore\n return globalThis.Buffer.from(hex, 'hex')\n }\n /* c8 ignore next 17 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {string|Uint8Array} hex\n * @returns {Uint8Array}\n */\n (hex) => {\n if (hex instanceof Uint8Array) {\n return hex\n }\n if (!hex.length) {\n return new Uint8Array(0)\n }\n return new Uint8Array(hex.split('')\n .map((/** @type {string} */ c, /** @type {number} */ i, /** @type {string[]} */ d) => i % 2 === 0 ? `0x${c}${d[i + 1]}` : '')\n .filter(Boolean)\n .map((/** @type {string} */ e) => parseInt(e, 16)))\n }\n\n/**\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} obj\n * @returns {Uint8Array}\n */\nfunction toBytes (obj) {\n if (obj instanceof Uint8Array && obj.constructor.name === 'Uint8Array') {\n return obj\n }\n if (obj instanceof ArrayBuffer) {\n return new Uint8Array(obj)\n }\n if (ArrayBuffer.isView(obj)) {\n return new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength)\n }\n /* c8 ignore next */\n throw new Error('Unknown type, must be binary type')\n}\n\n/**\n * @param {Uint8Array} b1\n * @param {Uint8Array} b2\n * @returns {number}\n */\nexport function compare (b1, b2) {\n /* c8 ignore next 5 */\n if (isBuffer(b1) && isBuffer(b2)) {\n // probably not possible to get here in the current API\n // @ts-ignore Buffer\n return b1.compare(b2)\n }\n for (let i = 0; i < b1.length; i++) {\n if (b1[i] === b2[i]) {\n continue\n }\n return b1[i] < b2[i] ? -1 : 1\n } /* c8 ignore next 3 */\n return 0\n}\n\n// The below code is taken from https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143\n// Licensed Apache-2.0.\n\n/**\n * @param {string} str\n * @returns {number[]}\n */\nfunction utf8ToBytes (str) {\n const out = []\n let p = 0\n for (let i = 0; i < str.length; i++) {\n let c = str.charCodeAt(i)\n if (c < 128) {\n out[p++] = c\n } else if (c < 2048) {\n out[p++] = (c >> 6) | 192\n out[p++] = (c & 63) | 128\n } else if (\n ((c & 0xFC00) === 0xD800) && (i + 1) < str.length &&\n ((str.charCodeAt(i + 1) & 0xFC00) === 0xDC00)) {\n // Surrogate Pair\n c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF)\n out[p++] = (c >> 18) | 240\n out[p++] = ((c >> 12) & 63) | 128\n out[p++] = ((c >> 6) & 63) | 128\n out[p++] = (c & 63) | 128\n } else {\n if ((c >= 0xD800) && (c <= 0xDFFF)) {\n c = 0xFFFD // Unpaired Surrogate\n }\n out[p++] = (c >> 12) | 224\n out[p++] = ((c >> 6) & 63) | 128\n out[p++] = (c & 63) | 128\n }\n }\n return out\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst MAX_ARGUMENTS_LENGTH = 0x1000\n\n/**\n * @param {number[]} codePoints\n * @returns {string}\n */\nexport function decodeCodePointsArray (codePoints) {\n const len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n /* c8 ignore next 10 */\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = ''\n let i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n","/**\n * Bl is a list of byte chunks, similar to https://github.com/rvagg/bl but for\n * writing rather than reading.\n * A Bl object accepts set() operations for individual bytes and copyTo() for\n * inserting byte arrays. These write operations don't automatically increment\n * the internal cursor so its \"length\" won't be changed. Instead, increment()\n * must be called to extend its length to cover the inserted data.\n * The toBytes() call will convert all internal memory to a single Uint8Array of\n * the correct length, truncating any data that is stored but hasn't been\n * included by an increment().\n * get() can retrieve a single byte.\n * All operations (except toBytes()) take an \"offset\" argument that will perform\n * the write at the offset _from the current cursor_. For most operations this\n * will be `0` to write at the current cursor position but it can be ahead of\n * the current cursor. Negative offsets probably work but are untested.\n */\n\n// TODO: ipjs doesn't support this, only for test files: https://github.com/mikeal/ipjs/blob/master/src/package/testFile.js#L39\nimport { alloc, concat, slice } from './byte-utils.js'\n\n// the ts-ignores in this file are almost all for the `Uint8Array|number[]` duality that exists\n// for perf reasons. Consider better approaches to this or removing it entirely, it is quite\n// risky because of some assumptions about small chunks === number[] and everything else === Uint8Array.\n\nconst defaultChunkSize = 256\n\nexport class Bl {\n /**\n * @param {number} [chunkSize]\n */\n constructor (chunkSize = defaultChunkSize) {\n this.chunkSize = chunkSize\n /** @type {number} */\n this.cursor = 0\n /** @type {number} */\n this.maxCursor = -1\n /** @type {(Uint8Array|number[])[]} */\n this.chunks = []\n // keep the first chunk around if we can to save allocations for future encodes\n /** @type {Uint8Array|number[]|null} */\n this._initReuseChunk = null\n }\n\n reset () {\n this.cursor = 0\n this.maxCursor = -1\n if (this.chunks.length) {\n this.chunks = []\n }\n if (this._initReuseChunk !== null) {\n this.chunks.push(this._initReuseChunk)\n this.maxCursor = this._initReuseChunk.length - 1\n }\n }\n\n /**\n * @param {Uint8Array|number[]} bytes\n */\n push (bytes) {\n let topChunk = this.chunks[this.chunks.length - 1]\n const newMax = this.cursor + bytes.length\n if (newMax <= this.maxCursor + 1) {\n // we have at least one chunk and we can fit these bytes into that chunk\n const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1\n // @ts-ignore\n topChunk.set(bytes, chunkPos)\n } else {\n // can't fit it in\n if (topChunk) {\n // trip the last chunk to `cursor` if we need to\n const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1\n if (chunkPos < topChunk.length) {\n // @ts-ignore\n this.chunks[this.chunks.length - 1] = topChunk.subarray(0, chunkPos)\n this.maxCursor = this.cursor - 1\n }\n }\n if (bytes.length < 64 && bytes.length < this.chunkSize) {\n // make a new chunk and copy the new one into it\n topChunk = alloc(this.chunkSize)\n this.chunks.push(topChunk)\n this.maxCursor += topChunk.length\n if (this._initReuseChunk === null) {\n this._initReuseChunk = topChunk\n }\n // @ts-ignore\n topChunk.set(bytes, 0)\n } else {\n // push the new bytes in as its own chunk\n this.chunks.push(bytes)\n this.maxCursor += bytes.length\n }\n }\n this.cursor += bytes.length\n }\n\n /**\n * @param {boolean} [reset]\n * @returns {Uint8Array}\n */\n toBytes (reset = false) {\n let byts\n if (this.chunks.length === 1) {\n const chunk = this.chunks[0]\n if (reset && this.cursor > chunk.length / 2) {\n /* c8 ignore next 2 */\n // @ts-ignore\n byts = this.cursor === chunk.length ? chunk : chunk.subarray(0, this.cursor)\n this._initReuseChunk = null\n this.chunks = []\n } else {\n // @ts-ignore\n byts = slice(chunk, 0, this.cursor)\n }\n } else {\n // @ts-ignore\n byts = concat(this.chunks, this.cursor)\n }\n if (reset) {\n this.reset()\n }\n return byts\n }\n}\n\n/**\n * U8Bl is a buffer list that writes directly to a user-provided Uint8Array.\n * It provides the same interface as Bl but writes to a fixed destination.\n */\nexport class U8Bl {\n /**\n * @param {Uint8Array} dest\n */\n constructor (dest) {\n this.dest = dest\n /** @type {number} */\n this.cursor = 0\n // chunks is for interface compatibility with Bl - encode.js checks chunks.length\n // as a sanity check for pre-calculated sizes. For U8Bl this is always [dest].\n /** @type {Uint8Array[]} */\n this.chunks = [dest]\n }\n\n reset () {\n this.cursor = 0\n }\n\n /**\n * @param {Uint8Array|number[]} bytes\n */\n push (bytes) {\n if (this.cursor + bytes.length > this.dest.length) {\n throw new Error('write out of bounds, destination buffer is too small')\n }\n this.dest.set(bytes, this.cursor)\n this.cursor += bytes.length\n }\n\n /**\n * @param {boolean} [reset]\n * @returns {Uint8Array}\n */\n toBytes (reset = false) {\n const byts = this.dest.subarray(0, this.cursor)\n if (reset) {\n this.reset()\n }\n return byts\n }\n}\n","const decodeErrPrefix = 'CBOR decode error:'\nconst encodeErrPrefix = 'CBOR encode error:'\n\nconst uintMinorPrefixBytes = []\nuintMinorPrefixBytes[23] = 1\nuintMinorPrefixBytes[24] = 2\nuintMinorPrefixBytes[25] = 3\nuintMinorPrefixBytes[26] = 5\nuintMinorPrefixBytes[27] = 9\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} need\n */\nfunction assertEnoughData (data, pos, need) {\n if (data.length - pos < need) {\n throw new Error(`${decodeErrPrefix} not enough data for type`)\n }\n}\n\nexport {\n decodeErrPrefix,\n encodeErrPrefix,\n uintMinorPrefixBytes,\n assertEnoughData\n}\n","/* globals BigInt */\n\nimport { Token, Type } from './token.js'\nimport { decodeErrPrefix, assertEnoughData } from './common.js'\n\nexport const uintBoundaries = [24, 256, 65536, 4294967296, BigInt('18446744073709551616')]\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} data\n * @param {number} offset\n * @param {DecodeOptions} options\n * @returns {number}\n */\nexport function readUint8 (data, offset, options) {\n assertEnoughData(data, offset, 1)\n const value = data[offset]\n if (options.strict === true && value < uintBoundaries[0]) {\n throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)\n }\n return value\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} offset\n * @param {DecodeOptions} options\n * @returns {number}\n */\nexport function readUint16 (data, offset, options) {\n assertEnoughData(data, offset, 2)\n const value = (data[offset] << 8) | data[offset + 1]\n if (options.strict === true && value < uintBoundaries[1]) {\n throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)\n }\n return value\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} offset\n * @param {DecodeOptions} options\n * @returns {number}\n */\nexport function readUint32 (data, offset, options) {\n assertEnoughData(data, offset, 4)\n const value = (data[offset] * 16777216 /* 2 ** 24 */) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3]\n if (options.strict === true && value < uintBoundaries[2]) {\n throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)\n }\n return value\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} offset\n * @param {DecodeOptions} options\n * @returns {number|bigint}\n */\nexport function readUint64 (data, offset, options) {\n // assume BigInt, convert back to Number if within safe range\n assertEnoughData(data, offset, 8)\n const hi = (data[offset] * 16777216 /* 2 ** 24 */) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3]\n const lo = (data[offset + 4] * 16777216 /* 2 ** 24 */) + (data[offset + 5] << 16) + (data[offset + 6] << 8) + data[offset + 7]\n const value = (BigInt(hi) << BigInt(32)) + BigInt(lo)\n if (options.strict === true && value < uintBoundaries[3]) {\n throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)\n }\n if (value <= Number.MAX_SAFE_INTEGER) {\n return Number(value)\n }\n if (options.allowBigInt === true) {\n return value\n }\n throw new Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`)\n}\n\n/* not required thanks to quick[] list\nconst oneByteTokens = new Array(24).fill(0).map((v, i) => new Token(Type.uint, i, 1))\nexport function decodeUintCompact (data, pos, minor, options) {\n return oneByteTokens[minor]\n}\n*/\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUint8 (data, pos, _minor, options) {\n return new Token(Type.uint, readUint8(data, pos + 1, options), 2)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUint16 (data, pos, _minor, options) {\n return new Token(Type.uint, readUint16(data, pos + 1, options), 3)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUint32 (data, pos, _minor, options) {\n return new Token(Type.uint, readUint32(data, pos + 1, options), 5)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUint64 (data, pos, _minor, options) {\n return new Token(Type.uint, readUint64(data, pos + 1, options), 9)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeUint (writer, token) {\n return encodeUintValue(writer, 0, token.value)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {number} major\n * @param {number|bigint} uint\n */\nexport function encodeUintValue (writer, major, uint) {\n if (uint < uintBoundaries[0]) {\n const nuint = Number(uint)\n // pack into one byte, minor=0, additional=value\n writer.push([major | nuint])\n } else if (uint < uintBoundaries[1]) {\n const nuint = Number(uint)\n // pack into two byte, minor=0, additional=24\n writer.push([major | 24, nuint])\n } else if (uint < uintBoundaries[2]) {\n const nuint = Number(uint)\n // pack into three byte, minor=0, additional=25\n writer.push([major | 25, nuint >>> 8, nuint & 0xff])\n } else if (uint < uintBoundaries[3]) {\n const nuint = Number(uint)\n // pack into five byte, minor=0, additional=26\n writer.push([major | 26, (nuint >>> 24) & 0xff, (nuint >>> 16) & 0xff, (nuint >>> 8) & 0xff, nuint & 0xff])\n } else {\n const buint = BigInt(uint)\n if (buint < uintBoundaries[4]) {\n // pack into nine byte, minor=0, additional=27\n const set = [major | 27, 0, 0, 0, 0, 0, 0, 0]\n // simulate bitwise above 32 bits\n let lo = Number(buint & BigInt(0xffffffff))\n let hi = Number(buint >> BigInt(32) & BigInt(0xffffffff))\n set[8] = lo & 0xff\n lo = lo >> 8\n set[7] = lo & 0xff\n lo = lo >> 8\n set[6] = lo & 0xff\n lo = lo >> 8\n set[5] = lo & 0xff\n set[4] = hi & 0xff\n hi = hi >> 8\n set[3] = hi & 0xff\n hi = hi >> 8\n set[2] = hi & 0xff\n hi = hi >> 8\n set[1] = hi & 0xff\n writer.push(set)\n } else {\n throw new Error(`${decodeErrPrefix} encountered BigInt larger than allowable range`)\n }\n }\n}\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeUint.encodedSize = function encodedSize (token) {\n return encodeUintValue.encodedSize(token.value)\n}\n\n/**\n * @param {number} uint\n * @returns {number}\n */\nencodeUintValue.encodedSize = function encodedSize (uint) {\n if (uint < uintBoundaries[0]) {\n return 1\n }\n if (uint < uintBoundaries[1]) {\n return 2\n }\n if (uint < uintBoundaries[2]) {\n return 3\n }\n if (uint < uintBoundaries[3]) {\n return 5\n }\n return 9\n}\n\n/**\n * @param {Token} tok1\n * @param {Token} tok2\n * @returns {number}\n */\nencodeUint.compareTokens = function compareTokens (tok1, tok2) {\n return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : /* c8 ignore next */ 0\n}\n","/* eslint-env es2020 */\n\nimport { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\nimport { decodeErrPrefix } from './common.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeNegint8 (data, pos, _minor, options) {\n return new Token(Type.negint, -1 - uint.readUint8(data, pos + 1, options), 2)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeNegint16 (data, pos, _minor, options) {\n return new Token(Type.negint, -1 - uint.readUint16(data, pos + 1, options), 3)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeNegint32 (data, pos, _minor, options) {\n return new Token(Type.negint, -1 - uint.readUint32(data, pos + 1, options), 5)\n}\n\nconst neg1b = BigInt(-1)\nconst pos1b = BigInt(1)\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeNegint64 (data, pos, _minor, options) {\n const int = uint.readUint64(data, pos + 1, options)\n if (typeof int !== 'bigint') {\n const value = -1 - int\n if (value >= Number.MIN_SAFE_INTEGER) {\n return new Token(Type.negint, value, 9)\n }\n }\n if (options.allowBigInt !== true) {\n throw new Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`)\n }\n return new Token(Type.negint, neg1b - BigInt(int), 9)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeNegint (writer, token) {\n const negint = token.value\n const unsigned = (typeof negint === 'bigint' ? (negint * neg1b - pos1b) : (negint * -1 - 1))\n uint.encodeUintValue(writer, token.type.majorEncoded, unsigned)\n}\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeNegint.encodedSize = function encodedSize (token) {\n const negint = token.value\n const unsigned = (typeof negint === 'bigint' ? (negint * neg1b - pos1b) : (negint * -1 - 1))\n /* c8 ignore next 4 */\n // handled by quickEncode, we shouldn't get here but it's included for completeness\n if (unsigned < uint.uintBoundaries[0]) {\n return 1\n }\n if (unsigned < uint.uintBoundaries[1]) {\n return 2\n }\n if (unsigned < uint.uintBoundaries[2]) {\n return 3\n }\n if (unsigned < uint.uintBoundaries[3]) {\n return 5\n }\n return 9\n}\n\n/**\n * @param {Token} tok1\n * @param {Token} tok2\n * @returns {number}\n */\nencodeNegint.compareTokens = function compareTokens (tok1, tok2) {\n // opposite of the uint comparison since we store the uint version in bytes\n return tok1.value < tok2.value ? 1 : tok1.value > tok2.value ? -1 : /* c8 ignore next */ 0\n}\n","import { Token, Type } from './token.js'\nimport { assertEnoughData, decodeErrPrefix } from './common.js'\nimport * as uint from './0uint.js'\nimport { compare, fromString } from './byte-utils.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} prefix\n * @param {number} length\n * @returns {Token}\n */\nfunction toToken (data, pos, prefix, length) {\n assertEnoughData(data, pos, prefix + length)\n const buf = data.slice(pos + prefix, pos + prefix + length)\n return new Token(Type.bytes, buf, prefix + length)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n * @param {DecodeOptions} _options\n * @returns {Token}\n */\nexport function decodeBytesCompact (data, pos, minor, _options) {\n return toToken(data, pos, 1, minor)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBytes8 (data, pos, _minor, options) {\n return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBytes16 (data, pos, _minor, options) {\n return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBytes32 (data, pos, _minor, options) {\n return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options))\n}\n\n// TODO: maybe we shouldn't support this ..\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBytes64 (data, pos, _minor, options) {\n const l = uint.readUint64(data, pos + 1, options)\n if (typeof l === 'bigint') {\n throw new Error(`${decodeErrPrefix} 64-bit integer bytes lengths not supported`)\n }\n return toToken(data, pos, 9, l)\n}\n\n/**\n * `encodedBytes` allows for caching when we do a byte version of a string\n * for key sorting purposes\n * @param {Token} token\n * @returns {Uint8Array}\n */\nfunction tokenBytes (token) {\n if (token.encodedBytes === undefined) {\n token.encodedBytes = Type.equals(token.type, Type.string) ? fromString(token.value) : token.value\n }\n // @ts-ignore c'mon\n return token.encodedBytes\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeBytes (writer, token) {\n const bytes = tokenBytes(token)\n uint.encodeUintValue(writer, token.type.majorEncoded, bytes.length)\n writer.push(bytes)\n}\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeBytes.encodedSize = function encodedSize (token) {\n const bytes = tokenBytes(token)\n return uint.encodeUintValue.encodedSize(bytes.length) + bytes.length\n}\n\n/**\n * @param {Token} tok1\n * @param {Token} tok2\n * @returns {number}\n */\nencodeBytes.compareTokens = function compareTokens (tok1, tok2) {\n return compareBytes(tokenBytes(tok1), tokenBytes(tok2))\n}\n\n/**\n * @param {Uint8Array} b1\n * @param {Uint8Array} b2\n * @returns {number}\n */\nexport function compareBytes (b1, b2) {\n return b1.length < b2.length ? -1 : b1.length > b2.length ? 1 : compare(b1, b2)\n}\n","import { Token, Type } from './token.js'\nimport { assertEnoughData, decodeErrPrefix } from './common.js'\nimport * as uint from './0uint.js'\nimport { encodeBytes } from './2bytes.js'\n\nconst textDecoder = new TextDecoder()\n\n// Threshold for ASCII fast-path vs TextDecoder. Short ASCII strings (common for\n// map keys) are faster to decode with a simple loop than TextDecoder overhead.\nconst ASCII_THRESHOLD = 32\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * Decode UTF-8 bytes to string. For short ASCII strings (common case for map keys),\n * a simple loop is faster than TextDecoder.\n * @param {Uint8Array} bytes\n * @param {number} start\n * @param {number} end\n * @returns {string}\n */\nfunction toStr (bytes, start, end) {\n const len = end - start\n if (len < ASCII_THRESHOLD) {\n let str = ''\n for (let i = start; i < end; i++) {\n const c = bytes[i]\n if (c & 0x80) { // non-ASCII, fall back to TextDecoder\n return textDecoder.decode(bytes.subarray(start, end))\n }\n str += String.fromCharCode(c)\n }\n return str\n }\n return textDecoder.decode(bytes.subarray(start, end))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} prefix\n * @param {number} length\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nfunction toToken (data, pos, prefix, length, options) {\n const totLength = prefix + length\n assertEnoughData(data, pos, totLength)\n const tok = new Token(Type.string, toStr(data, pos + prefix, pos + totLength), totLength)\n if (options.retainStringBytes === true) {\n tok.byteValue = data.slice(pos + prefix, pos + totLength)\n }\n return tok\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeStringCompact (data, pos, minor, options) {\n return toToken(data, pos, 1, minor, options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeString8 (data, pos, _minor, options) {\n return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options), options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeString16 (data, pos, _minor, options) {\n return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options), options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeString32 (data, pos, _minor, options) {\n return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options), options)\n}\n\n// TODO: maybe we shouldn't support this ..\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeString64 (data, pos, _minor, options) {\n const l = uint.readUint64(data, pos + 1, options)\n if (typeof l === 'bigint') {\n throw new Error(`${decodeErrPrefix} 64-bit integer string lengths not supported`)\n }\n return toToken(data, pos, 9, l, options)\n}\n\nexport const encodeString = encodeBytes\n","import { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\nimport { decodeErrPrefix } from './common.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} prefix\n * @param {number} length\n * @returns {Token}\n */\nfunction toToken (_data, _pos, prefix, length) {\n return new Token(Type.array, length, prefix)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n * @param {DecodeOptions} _options\n * @returns {Token}\n */\nexport function decodeArrayCompact (data, pos, minor, _options) {\n return toToken(data, pos, 1, minor)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArray8 (data, pos, _minor, options) {\n return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArray16 (data, pos, _minor, options) {\n return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArray32 (data, pos, _minor, options) {\n return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options))\n}\n\n// TODO: maybe we shouldn't support this ..\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArray64 (data, pos, _minor, options) {\n const l = uint.readUint64(data, pos + 1, options)\n if (typeof l === 'bigint') {\n throw new Error(`${decodeErrPrefix} 64-bit integer array lengths not supported`)\n }\n return toToken(data, pos, 9, l)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArrayIndefinite (data, pos, _minor, options) {\n if (options.allowIndefinite === false) {\n throw new Error(`${decodeErrPrefix} indefinite length items not allowed`)\n }\n return toToken(data, pos, 1, Infinity)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeArray (writer, token) {\n uint.encodeUintValue(writer, Type.array.majorEncoded, token.value)\n}\n\n// using an array as a map key, are you sure about this? we can only sort\n// by map length here, it's up to the encoder to decide to look deeper\nencodeArray.compareTokens = uint.encodeUint.compareTokens\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeArray.encodedSize = function encodedSize (token) {\n return uint.encodeUintValue.encodedSize(token.value)\n}\n","import { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\nimport { decodeErrPrefix } from './common.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} prefix\n * @param {number} length\n * @returns {Token}\n */\nfunction toToken (_data, _pos, prefix, length) {\n return new Token(Type.map, length, prefix)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n * @param {DecodeOptions} _options\n * @returns {Token}\n */\nexport function decodeMapCompact (data, pos, minor, _options) {\n return toToken(data, pos, 1, minor)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMap8 (data, pos, _minor, options) {\n return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMap16 (data, pos, _minor, options) {\n return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMap32 (data, pos, _minor, options) {\n return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options))\n}\n\n// TODO: maybe we shouldn't support this ..\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMap64 (data, pos, _minor, options) {\n const l = uint.readUint64(data, pos + 1, options)\n if (typeof l === 'bigint') {\n throw new Error(`${decodeErrPrefix} 64-bit integer map lengths not supported`)\n }\n return toToken(data, pos, 9, l)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMapIndefinite (data, pos, _minor, options) {\n if (options.allowIndefinite === false) {\n throw new Error(`${decodeErrPrefix} indefinite length items not allowed`)\n }\n return toToken(data, pos, 1, Infinity)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeMap (writer, token) {\n uint.encodeUintValue(writer, Type.map.majorEncoded, token.value)\n}\n\n// using a map as a map key, are you sure about this? we can only sort\n// by map length here, it's up to the encoder to decide to look deeper\nencodeMap.compareTokens = uint.encodeUint.compareTokens\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeMap.encodedSize = function encodedSize (token) {\n return uint.encodeUintValue.encodedSize(token.value)\n}\n","import { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} minor\n * @param {DecodeOptions} _options\n * @returns {Token}\n */\nexport function decodeTagCompact (_data, _pos, minor, _options) {\n return new Token(Type.tag, minor, 1)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeTag8 (data, pos, _minor, options) {\n return new Token(Type.tag, uint.readUint8(data, pos + 1, options), 2)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeTag16 (data, pos, _minor, options) {\n return new Token(Type.tag, uint.readUint16(data, pos + 1, options), 3)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeTag32 (data, pos, _minor, options) {\n return new Token(Type.tag, uint.readUint32(data, pos + 1, options), 5)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeTag64 (data, pos, _minor, options) {\n return new Token(Type.tag, uint.readUint64(data, pos + 1, options), 9)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeTag (writer, token) {\n uint.encodeUintValue(writer, Type.tag.majorEncoded, token.value)\n}\n\nencodeTag.compareTokens = uint.encodeUint.compareTokens\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeTag.encodedSize = function encodedSize (token) {\n return uint.encodeUintValue.encodedSize(token.value)\n}\n","// TODO: shift some of the bytes logic to bytes-utils so we can use Buffer\n// where possible\n\nimport { Token, Type } from './token.js'\nimport { decodeErrPrefix } from './common.js'\nimport { encodeUint } from './0uint.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n * @typedef {import('../interface').EncodeOptions} EncodeOptions\n */\n\nexport const MINOR_FALSE = 20\nexport const MINOR_TRUE = 21\nexport const MINOR_NULL = 22\nexport const MINOR_UNDEFINED = 23\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUndefined (_data, _pos, _minor, options) {\n if (options.allowUndefined === false) {\n throw new Error(`${decodeErrPrefix} undefined values are not supported`)\n } else if (options.coerceUndefinedToNull === true) {\n return new Token(Type.null, null, 1)\n }\n return new Token(Type.undefined, undefined, 1)\n}\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBreak (_data, _pos, _minor, options) {\n if (options.allowIndefinite === false) {\n throw new Error(`${decodeErrPrefix} indefinite length items not allowed`)\n }\n return new Token(Type.break, undefined, 1)\n}\n\n/**\n * @param {number} value\n * @param {number} bytes\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nfunction createToken (value, bytes, options) {\n if (options) {\n if (options.allowNaN === false && Number.isNaN(value)) {\n throw new Error(`${decodeErrPrefix} NaN values are not supported`)\n }\n if (options.allowInfinity === false && (value === Infinity || value === -Infinity)) {\n throw new Error(`${decodeErrPrefix} Infinity values are not supported`)\n }\n }\n return new Token(Type.float, value, bytes)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeFloat16 (data, pos, _minor, options) {\n return createToken(readFloat16(data, pos + 1), 3, options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeFloat32 (data, pos, _minor, options) {\n return createToken(readFloat32(data, pos + 1), 5, options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeFloat64 (data, pos, _minor, options) {\n return createToken(readFloat64(data, pos + 1), 9, options)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n * @param {EncodeOptions} options\n */\nexport function encodeFloat (writer, token, options) {\n const float = token.value\n\n if (float === false) {\n writer.push([Type.float.majorEncoded | MINOR_FALSE])\n } else if (float === true) {\n writer.push([Type.float.majorEncoded | MINOR_TRUE])\n } else if (float === null) {\n writer.push([Type.float.majorEncoded | MINOR_NULL])\n } else if (float === undefined) {\n writer.push([Type.float.majorEncoded | MINOR_UNDEFINED])\n } else {\n let decoded\n let success = false\n if (!options || options.float64 !== true) {\n encodeFloat16(float)\n decoded = readFloat16(ui8a, 1)\n if (float === decoded || Number.isNaN(float)) {\n ui8a[0] = 0xf9\n writer.push(ui8a.slice(0, 3))\n success = true\n } else {\n encodeFloat32(float)\n decoded = readFloat32(ui8a, 1)\n if (float === decoded) {\n ui8a[0] = 0xfa\n writer.push(ui8a.slice(0, 5))\n success = true\n }\n }\n }\n if (!success) {\n encodeFloat64(float)\n decoded = readFloat64(ui8a, 1)\n ui8a[0] = 0xfb\n writer.push(ui8a.slice(0, 9))\n }\n }\n}\n\n/**\n * @param {Token} token\n * @param {EncodeOptions} options\n * @returns {number}\n */\nencodeFloat.encodedSize = function encodedSize (token, options) {\n const float = token.value\n\n if (float === false || float === true || float === null || float === undefined) {\n return 1\n }\n\n if (!options || options.float64 !== true) {\n encodeFloat16(float)\n let decoded = readFloat16(ui8a, 1)\n if (float === decoded || Number.isNaN(float)) {\n return 3\n }\n encodeFloat32(float)\n decoded = readFloat32(ui8a, 1)\n if (float === decoded) {\n return 5\n }\n }\n return 9\n}\n\nconst buffer = new ArrayBuffer(9)\nconst dataView = new DataView(buffer, 1)\nconst ui8a = new Uint8Array(buffer, 0)\n\n/**\n * @param {number} inp\n */\nfunction encodeFloat16 (inp) {\n if (inp === Infinity) {\n dataView.setUint16(0, 0x7c00, false)\n } else if (inp === -Infinity) {\n dataView.setUint16(0, 0xfc00, false)\n } else if (Number.isNaN(inp)) {\n dataView.setUint16(0, 0x7e00, false)\n } else {\n dataView.setFloat32(0, inp)\n const valu32 = dataView.getUint32(0)\n const exponent = (valu32 & 0x7f800000) >> 23\n const mantissa = valu32 & 0x7fffff\n\n /* c8 ignore next 6 */\n if (exponent === 0xff) {\n // too big, Infinity, but this should be hard (impossible?) to trigger\n dataView.setUint16(0, 0x7c00, false)\n } else if (exponent === 0x00) {\n // 0.0, -0.0 and subnormals, shouldn't be possible to get here because 0.0 should be counted as an int\n dataView.setUint16(0, ((inp & 0x80000000) >> 16) | (mantissa >> 13), false)\n } else { // standard numbers\n // chunks of logic here borrowed from https://github.com/PJK/libcbor/blob/c78f437182533e3efa8d963ff4b945bb635c2284/src/cbor/encoding.c#L127\n const logicalExponent = exponent - 127\n // Now we know that 2^exponent <= 0 logically\n /* c8 ignore next 6 */\n if (logicalExponent < -24) {\n /* No unambiguous representation exists, this float is not a half float\n and is too small to be represented using a half, round off to zero.\n Consistent with the reference implementation. */\n // should be difficult (impossible?) to get here in JS\n dataView.setUint16(0, 0)\n } else if (logicalExponent < -14) {\n /* Offset the remaining decimal places by shifting the significand, the\n value is lost. This is an implementation decision that works around the\n absence of standard half-float in the language. */\n dataView.setUint16(0, ((valu32 & 0x80000000) >> 16) | /* sign bit */ (1 << (24 + logicalExponent)), false)\n } else {\n dataView.setUint16(0, ((valu32 & 0x80000000) >> 16) | ((logicalExponent + 15) << 10) | (mantissa >> 13), false)\n }\n }\n }\n}\n\n/**\n * @param {Uint8Array} ui8a\n * @param {number} pos\n * @returns {number}\n */\nfunction readFloat16 (ui8a, pos) {\n if (ui8a.length - pos < 2) {\n throw new Error(`${decodeErrPrefix} not enough data for float16`)\n }\n\n const half = (ui8a[pos] << 8) + ui8a[pos + 1]\n if (half === 0x7c00) {\n return Infinity\n }\n if (half === 0xfc00) {\n return -Infinity\n }\n if (half === 0x7e00) {\n return NaN\n }\n const exp = (half >> 10) & 0x1f\n const mant = half & 0x3ff\n let val\n if (exp === 0) {\n val = mant * (2 ** -24)\n } else if (exp !== 31) {\n val = (mant + 1024) * (2 ** (exp - 25))\n /* c8 ignore next 4 */\n } else {\n // may not be possible to get here\n val = mant === 0 ? Infinity : NaN\n }\n return (half & 0x8000) ? -val : val\n}\n\n/**\n * @param {number} inp\n */\nfunction encodeFloat32 (inp) {\n dataView.setFloat32(0, inp, false)\n}\n\n/**\n * @param {Uint8Array} ui8a\n * @param {number} pos\n * @returns {number}\n */\nfunction readFloat32 (ui8a, pos) {\n if (ui8a.length - pos < 4) {\n throw new Error(`${decodeErrPrefix} not enough data for float32`)\n }\n const offset = (ui8a.byteOffset || 0) + pos\n return new DataView(ui8a.buffer, offset, 4).getFloat32(0, false)\n}\n\n/**\n * @param {number} inp\n */\nfunction encodeFloat64 (inp) {\n dataView.setFloat64(0, inp, false)\n}\n\n/**\n * @param {Uint8Array} ui8a\n * @param {number} pos\n * @returns {number}\n */\nfunction readFloat64 (ui8a, pos) {\n if (ui8a.length - pos < 8) {\n throw new Error(`${decodeErrPrefix} not enough data for float64`)\n }\n const offset = (ui8a.byteOffset || 0) + pos\n return new DataView(ui8a.buffer, offset, 8).getFloat64(0, false)\n}\n\n/**\n * @param {Token} _tok1\n * @param {Token} _tok2\n * @returns {number}\n */\nencodeFloat.compareTokens = encodeUint.compareTokens\n/*\nencodeFloat.compareTokens = function compareTokens (_tok1, _tok2) {\n return _tok1\n throw new Error(`${encodeErrPrefix} cannot use floats as map keys`)\n}\n*/\n","import { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\nimport * as negint from './1negint.js'\nimport * as bytes from './2bytes.js'\nimport * as string from './3string.js'\nimport * as array from './4array.js'\nimport * as map from './5map.js'\nimport * as tag from './6tag.js'\nimport * as float from './7float.js'\nimport { decodeErrPrefix } from './common.js'\nimport { fromArray } from './byte-utils.js'\n\n/**\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n */\nfunction invalidMinor (data, pos, minor) {\n throw new Error(`${decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`)\n}\n\n/**\n * @param {string} msg\n * @returns {()=>any}\n */\nfunction errorer (msg) {\n return () => { throw new Error(`${decodeErrPrefix} ${msg}`) }\n}\n\n/** @type {((data:Uint8Array, pos:number, minor:number, options?:DecodeOptions) => any)[]} */\nexport const jump = []\n\n// unsigned integer, 0x00..0x17 (0..23)\nfor (let i = 0; i <= 0x17; i++) {\n jump[i] = invalidMinor // uint.decodeUintCompact, handled by quick[]\n}\njump[0x18] = uint.decodeUint8 // unsigned integer, one-byte uint8_t follows\njump[0x19] = uint.decodeUint16 // unsigned integer, two-byte uint16_t follows\njump[0x1a] = uint.decodeUint32 // unsigned integer, four-byte uint32_t follows\njump[0x1b] = uint.decodeUint64 // unsigned integer, eight-byte uint64_t follows\njump[0x1c] = invalidMinor\njump[0x1d] = invalidMinor\njump[0x1e] = invalidMinor\njump[0x1f] = invalidMinor\n// negative integer, -1-0x00..-1-0x17 (-1..-24)\nfor (let i = 0x20; i <= 0x37; i++) {\n jump[i] = invalidMinor // negintDecode, handled by quick[]\n}\njump[0x38] = negint.decodeNegint8 // negative integer, -1-n one-byte uint8_t for n follows\njump[0x39] = negint.decodeNegint16 // negative integer, -1-n two-byte uint16_t for n follows\njump[0x3a] = negint.decodeNegint32 // negative integer, -1-n four-byte uint32_t for follows\njump[0x3b] = negint.decodeNegint64 // negative integer, -1-n eight-byte uint64_t for follows\njump[0x3c] = invalidMinor\njump[0x3d] = invalidMinor\njump[0x3e] = invalidMinor\njump[0x3f] = invalidMinor\n// byte string, 0x00..0x17 bytes follow\nfor (let i = 0x40; i <= 0x57; i++) {\n jump[i] = bytes.decodeBytesCompact\n}\njump[0x58] = bytes.decodeBytes8 // byte string, one-byte uint8_t for n, and then n bytes follow\njump[0x59] = bytes.decodeBytes16 // byte string, two-byte uint16_t for n, and then n bytes follow\njump[0x5a] = bytes.decodeBytes32 // byte string, four-byte uint32_t for n, and then n bytes follow\njump[0x5b] = bytes.decodeBytes64 // byte string, eight-byte uint64_t for n, and then n bytes follow\njump[0x5c] = invalidMinor\njump[0x5d] = invalidMinor\njump[0x5e] = invalidMinor\njump[0x5f] = errorer('indefinite length bytes/strings are not supported') // byte string, byte strings follow, terminated by \"break\"\n// UTF-8 string 0x00..0x17 bytes follow\nfor (let i = 0x60; i <= 0x77; i++) {\n jump[i] = string.decodeStringCompact\n}\njump[0x78] = string.decodeString8 // UTF-8 string, one-byte uint8_t for n, and then n bytes follow\njump[0x79] = string.decodeString16 // UTF-8 string, two-byte uint16_t for n, and then n bytes follow\njump[0x7a] = string.decodeString32 // UTF-8 string, four-byte uint32_t for n, and then n bytes follow\njump[0x7b] = string.decodeString64 // UTF-8 string, eight-byte uint64_t for n, and then n bytes follow\njump[0x7c] = invalidMinor\njump[0x7d] = invalidMinor\njump[0x7e] = invalidMinor\njump[0x7f] = errorer('indefinite length bytes/strings are not supported') // UTF-8 strings follow, terminated by \"break\"\n// array, 0x00..0x17 data items follow\nfor (let i = 0x80; i <= 0x97; i++) {\n jump[i] = array.decodeArrayCompact\n}\njump[0x98] = array.decodeArray8 // array, one-byte uint8_t for n, and then n data items follow\njump[0x99] = array.decodeArray16 // array, two-byte uint16_t for n, and then n data items follow\njump[0x9a] = array.decodeArray32 // array, four-byte uint32_t for n, and then n data items follow\njump[0x9b] = array.decodeArray64 // array, eight-byte uint64_t for n, and then n data items follow\njump[0x9c] = invalidMinor\njump[0x9d] = invalidMinor\njump[0x9e] = invalidMinor\njump[0x9f] = array.decodeArrayIndefinite // array, data items follow, terminated by \"break\"\n// map, 0x00..0x17 pairs of data items follow\nfor (let i = 0xa0; i <= 0xb7; i++) {\n jump[i] = map.decodeMapCompact\n}\njump[0xb8] = map.decodeMap8 // map, one-byte uint8_t for n, and then n pairs of data items follow\njump[0xb9] = map.decodeMap16 // map, two-byte uint16_t for n, and then n pairs of data items follow\njump[0xba] = map.decodeMap32 // map, four-byte uint32_t for n, and then n pairs of data items follow\njump[0xbb] = map.decodeMap64 // map, eight-byte uint64_t for n, and then n pairs of data items follow\njump[0xbc] = invalidMinor\njump[0xbd] = invalidMinor\njump[0xbe] = invalidMinor\njump[0xbf] = map.decodeMapIndefinite // map, pairs of data items follow, terminated by \"break\"\n// tags\nfor (let i = 0xc0; i <= 0xd7; i++) {\n jump[i] = tag.decodeTagCompact\n}\njump[0xd8] = tag.decodeTag8\njump[0xd9] = tag.decodeTag16\njump[0xda] = tag.decodeTag32\njump[0xdb] = tag.decodeTag64\njump[0xdc] = invalidMinor\njump[0xdd] = invalidMinor\njump[0xde] = invalidMinor\njump[0xdf] = invalidMinor\n// 0xe0..0xf3 simple values, unsupported\nfor (let i = 0xe0; i <= 0xf3; i++) {\n jump[i] = errorer('simple values are not supported')\n}\njump[0xf4] = invalidMinor // false, handled by quick[]\njump[0xf5] = invalidMinor // true, handled by quick[]\njump[0xf6] = invalidMinor // null, handled by quick[]\njump[0xf7] = float.decodeUndefined // undefined\njump[0xf8] = errorer('simple values are not supported') // simple value, one byte follows, unsupported\njump[0xf9] = float.decodeFloat16 // half-precision float (two-byte IEEE 754)\njump[0xfa] = float.decodeFloat32 // single-precision float (four-byte IEEE 754)\njump[0xfb] = float.decodeFloat64 // double-precision float (eight-byte IEEE 754)\njump[0xfc] = invalidMinor\njump[0xfd] = invalidMinor\njump[0xfe] = invalidMinor\njump[0xff] = float.decodeBreak // \"break\" stop code\n\n/** @type {Token[]} */\nexport const quick = []\n// ints <24\nfor (let i = 0; i < 24; i++) {\n quick[i] = new Token(Type.uint, i, 1)\n}\n// negints >= -24\nfor (let i = -1; i >= -24; i--) {\n quick[31 - i] = new Token(Type.negint, i, 1)\n}\n// empty bytes\nquick[0x40] = new Token(Type.bytes, new Uint8Array(0), 1)\n// empty string\nquick[0x60] = new Token(Type.string, '', 1)\n// empty list\nquick[0x80] = new Token(Type.array, 0, 1)\n// empty map\nquick[0xa0] = new Token(Type.map, 0, 1)\n// false\nquick[0xf4] = new Token(Type.false, false, 1)\n// true\nquick[0xf5] = new Token(Type.true, true, 1)\n// null\nquick[0xf6] = new Token(Type.null, null, 1)\n\n/**\n * @param {Token} token\n * @returns {Uint8Array|undefined}\n */\nexport function quickEncodeToken (token) {\n switch (token.type) {\n case Type.false:\n return fromArray([0xf4])\n case Type.true:\n return fromArray([0xf5])\n case Type.null:\n return fromArray([0xf6])\n case Type.bytes:\n if (!token.value.length) {\n return fromArray([0x40])\n }\n return\n case Type.string:\n if (token.value === '') {\n return fromArray([0x60])\n }\n return\n case Type.array:\n if (token.value === 0) {\n return fromArray([0x80])\n }\n /* c8 ignore next 2 */\n // shouldn't be possible if this were called when there was only one token\n return\n case Type.map:\n if (token.value === 0) {\n return fromArray([0xa0])\n }\n /* c8 ignore next 2 */\n // shouldn't be possible if this were called when there was only one token\n return\n case Type.uint:\n if (token.value < 24) {\n return fromArray([Number(token.value)])\n }\n return\n case Type.negint:\n if (token.value >= -24) {\n return fromArray([31 - Number(token.value)])\n }\n }\n}\n","import { is } from './is.js'\nimport { Token, Type } from './token.js'\nimport { Bl, U8Bl } from './bl.js'\nimport { encodeErrPrefix } from './common.js'\nimport { quickEncodeToken } from './jump.js'\nimport { asU8A, compare, fromString } from './byte-utils.js'\n\nimport { encodeUint, encodeUintValue } from './0uint.js'\nimport { encodeNegint } from './1negint.js'\nimport { encodeBytes } from './2bytes.js'\nimport { encodeString } from './3string.js'\nimport { encodeArray } from './4array.js'\nimport { encodeMap } from './5map.js'\nimport { encodeTag } from './6tag.js'\nimport { encodeFloat, MINOR_FALSE, MINOR_TRUE, MINOR_NULL, MINOR_UNDEFINED } from './7float.js'\n\n/**\n * @typedef {import('../interface').EncodeOptions} EncodeOptions\n * @typedef {import('../interface').OptionalTypeEncoder} OptionalTypeEncoder\n * @typedef {import('../interface').Reference} Reference\n * @typedef {import('../interface').StrictTypeEncoder} StrictTypeEncoder\n * @typedef {import('../interface').TokenTypeEncoder} TokenTypeEncoder\n * @typedef {import('../interface').TokenOrNestedTokens} TokenOrNestedTokens\n * @typedef {import('../interface').ByteWriter} ByteWriter\n */\n\n/** @type {EncodeOptions} */\nconst defaultEncodeOptions = {\n float64: false,\n mapSorter,\n quickEncodeToken\n}\n\n/** @type {EncodeOptions} */\nexport const rfc8949EncodeOptions = Object.freeze({\n float64: true,\n mapSorter: rfc8949MapSorter,\n quickEncodeToken\n})\n\n/** @returns {TokenTypeEncoder[]} */\nexport function makeCborEncoders () {\n const encoders = []\n encoders[Type.uint.major] = encodeUint\n encoders[Type.negint.major] = encodeNegint\n encoders[Type.bytes.major] = encodeBytes\n encoders[Type.string.major] = encodeString\n encoders[Type.array.major] = encodeArray\n encoders[Type.map.major] = encodeMap\n encoders[Type.tag.major] = encodeTag\n encoders[Type.float.major] = encodeFloat\n return encoders\n}\n\nconst cborEncoders = makeCborEncoders()\n\nconst defaultWriter = new Bl()\n\n/** @implements {Reference} */\nclass Ref {\n /**\n * @param {object|any[]} obj\n * @param {Reference|undefined} parent\n */\n constructor (obj, parent) {\n this.obj = obj\n this.parent = parent\n }\n\n /**\n * @param {object|any[]} obj\n * @returns {boolean}\n */\n includes (obj) {\n /** @type {Reference|undefined} */\n let p = this\n do {\n if (p.obj === obj) {\n return true\n }\n } while (p = p.parent) // eslint-disable-line\n return false\n }\n\n /**\n * @param {Reference|undefined} stack\n * @param {object|any[]} obj\n * @returns {Reference}\n */\n static createCheck (stack, obj) {\n if (stack && stack.includes(obj)) {\n throw new Error(`${encodeErrPrefix} object contains circular references`)\n }\n return new Ref(obj, stack)\n }\n}\n\nconst simpleTokens = {\n null: new Token(Type.null, null),\n undefined: new Token(Type.undefined, undefined),\n true: new Token(Type.true, true),\n false: new Token(Type.false, false),\n emptyArray: new Token(Type.array, 0),\n emptyMap: new Token(Type.map, 0)\n}\n\n/** @type {{[typeName: string]: StrictTypeEncoder}} */\nconst typeEncoders = {\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n number (obj, _typ, _options, _refStack) {\n if (!Number.isInteger(obj) || !Number.isSafeInteger(obj)) {\n return new Token(Type.float, obj)\n } else if (obj >= 0) {\n return new Token(Type.uint, obj)\n } else {\n return new Token(Type.negint, obj)\n }\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n bigint (obj, _typ, _options, _refStack) {\n if (obj >= BigInt(0)) {\n return new Token(Type.uint, obj)\n } else {\n return new Token(Type.negint, obj)\n }\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n Uint8Array (obj, _typ, _options, _refStack) {\n return new Token(Type.bytes, obj)\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n string (obj, _typ, _options, _refStack) {\n return new Token(Type.string, obj)\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n boolean (obj, _typ, _options, _refStack) {\n return obj ? simpleTokens.true : simpleTokens.false\n },\n\n /**\n * @param {any} _obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n null (_obj, _typ, _options, _refStack) {\n return simpleTokens.null\n },\n\n /**\n * @param {any} _obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n undefined (_obj, _typ, _options, _refStack) {\n return simpleTokens.undefined\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n ArrayBuffer (obj, _typ, _options, _refStack) {\n return new Token(Type.bytes, new Uint8Array(obj))\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n DataView (obj, _typ, _options, _refStack) {\n return new Token(Type.bytes, new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength))\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} options\n * @param {Reference} [refStack]\n * @returns {TokenOrNestedTokens}\n */\n Array (obj, _typ, options, refStack) {\n if (!obj.length) {\n if (options.addBreakTokens === true) {\n return [simpleTokens.emptyArray, new Token(Type.break)]\n }\n return simpleTokens.emptyArray\n }\n refStack = Ref.createCheck(refStack, obj)\n const entries = []\n let i = 0\n for (const e of obj) {\n entries[i++] = objectToTokens(e, options, refStack)\n }\n if (options.addBreakTokens) {\n return [new Token(Type.array, obj.length), entries, new Token(Type.break)]\n }\n return [new Token(Type.array, obj.length), entries]\n },\n\n /**\n * @param {any} obj\n * @param {string} typ\n * @param {EncodeOptions} options\n * @param {Reference} [refStack]\n * @returns {TokenOrNestedTokens}\n */\n Object (obj, typ, options, refStack) {\n // could be an Object or a Map\n const isMap = typ !== 'Object'\n // it's slightly quicker to use Object.keys() than Object.entries()\n const keys = isMap ? obj.keys() : Object.keys(obj)\n const maxLength = isMap ? obj.size : keys.length\n\n /** @type {undefined | [TokenOrNestedTokens, TokenOrNestedTokens][]} */\n let entries\n\n if (maxLength) {\n // Pre-allocate the array with the expected size\n entries = new Array(maxLength)\n refStack = Ref.createCheck(refStack, obj)\n const skipUndefined = !isMap && options.ignoreUndefinedProperties\n\n let i = 0\n for (const key of keys) {\n const value = isMap ? obj.get(key) : obj[key]\n if (skipUndefined && value === undefined) {\n continue\n }\n entries[i++] = [\n objectToTokens(key, options, refStack),\n objectToTokens(value, options, refStack)\n ]\n }\n\n // Truncate only if properties were skipped\n if (i < maxLength) {\n entries.length = i\n }\n }\n\n if (!entries?.length) {\n if (options.addBreakTokens === true) {\n return [simpleTokens.emptyMap, new Token(Type.break)]\n }\n return simpleTokens.emptyMap\n }\n\n sortMapEntries(entries, options)\n if (options.addBreakTokens) {\n return [new Token(Type.map, entries.length), entries, new Token(Type.break)]\n }\n return [new Token(Type.map, entries.length), entries]\n }\n}\n\ntypeEncoders.Map = typeEncoders.Object\ntypeEncoders.Buffer = typeEncoders.Uint8Array\nfor (const typ of 'Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64'.split(' ')) {\n typeEncoders[`${typ}Array`] = typeEncoders.DataView\n}\n\n/**\n * @param {any} obj\n * @param {EncodeOptions} [options]\n * @param {Reference} [refStack]\n * @returns {TokenOrNestedTokens}\n */\nfunction objectToTokens (obj, options = {}, refStack) {\n const typ = is(obj)\n const customTypeEncoder = (options && options.typeEncoders && /** @type {OptionalTypeEncoder} */ options.typeEncoders[typ]) || typeEncoders[typ]\n if (typeof customTypeEncoder === 'function') {\n const tokens = customTypeEncoder(obj, typ, options, refStack)\n if (tokens != null) {\n return tokens\n }\n }\n const typeEncoder = typeEncoders[typ]\n if (!typeEncoder) {\n throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`)\n }\n return typeEncoder(obj, typ, options, refStack)\n}\n\n/*\nCBOR key sorting is a mess.\n\nThe canonicalisation recommendation from https://tools.ietf.org/html/rfc7049#section-3.9\nincludes the wording:\n\n> The keys in every map must be sorted lowest value to highest.\n> Sorting is performed on the bytes of the representation of the key\n> data items without paying attention to the 3/5 bit splitting for\n> major types.\n> ...\n> * If two keys have different lengths, the shorter one sorts\n earlier;\n> * If two keys have the same length, the one with the lower value\n in (byte-wise) lexical order sorts earlier.\n\n1. It is not clear what \"bytes of the representation of the key\" means: is it\n the CBOR representation, or the binary representation of the object itself?\n Consider the int and uint difference here.\n2. It is not clear what \"without paying attention to\" means: do we include it\n and compare on that? Or do we omit the special prefix byte, (mostly) treating\n the key in its plain binary representation form.\n\nThe FIDO 2.0: Client To Authenticator Protocol spec takes the original CBOR\nwording and clarifies it according to their understanding.\nhttps://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html#message-encoding\n\n> The keys in every map must be sorted lowest value to highest. Sorting is\n> performed on the bytes of the representation of the key data items without\n> paying attention to the 3/5 bit splitting for major types. The sorting rules\n> are:\n> * If the major types are different, the one with the lower value in numerical\n> order sorts earlier.\n> * If two keys have different lengths, the shorter one sorts earlier;\n> * If two keys have the same length, the one with the lower value in\n> (byte-wise) lexical order sorts earlier.\n\nSome other implementations, such as borc, do a full encode then do a\nlength-first, byte-wise-second comparison:\nhttps://github.com/dignifiedquire/borc/blob/b6bae8b0bcde7c3976b0f0f0957208095c392a36/src/encoder.js#L358\nhttps://github.com/dignifiedquire/borc/blob/b6bae8b0bcde7c3976b0f0f0957208095c392a36/src/utils.js#L143-L151\n\nThis has the benefit of being able to easily handle arbitrary keys, including\ncomplex types (maps and arrays).\n\nWe'll opt for the FIDO approach, since it affords some efficies since we don't\nneed a full encode of each key to determine order and can defer to the types\nto determine how to most efficiently order their values (i.e. int and uint\nordering can be done on the numbers, no need for byte-wise, for example).\n\nRecommendation: stick to single key types or you'll get into trouble, and prefer\nstring keys because it's much simpler that way.\n*/\n\n/**\n * @param {TokenOrNestedTokens[]} entries\n * @param {EncodeOptions} options\n */\nfunction sortMapEntries (entries, options) {\n if (options.mapSorter) {\n entries.sort(options.mapSorter)\n }\n}\n\n/**\n * @param {(Token|Token[])[]} e1\n * @param {(Token|Token[])[]} e2\n * @returns {number}\n */\nfunction mapSorter (e1, e2) {\n // the key position ([0]) could have a single token or an array\n // almost always it'll be a single token but complex key might get involved\n /* c8 ignore next 2 */\n const keyToken1 = Array.isArray(e1[0]) ? e1[0][0] : e1[0]\n const keyToken2 = Array.isArray(e2[0]) ? e2[0][0] : e2[0]\n\n // different key types\n if (keyToken1.type !== keyToken2.type) {\n return keyToken1.type.compare(keyToken2.type)\n }\n\n const major = keyToken1.type.major\n // TODO: handle case where cmp === 0 but there are more keyToken e. complex type)\n const tcmp = cborEncoders[major].compareTokens(keyToken1, keyToken2)\n /* c8 ignore next 5 */\n if (tcmp === 0) {\n // duplicate key or complex type where the first token matched,\n // i.e. a map or array and we're only comparing the opening token\n console.warn('WARNING: complex key types used, CBOR key sorting guarantees are gone')\n }\n return tcmp\n}\n\n/**\n * @typedef {Token & { _keyBytes?: Uint8Array }} TokenEx\n *\n * @param {(Token|Token[])[]} e1\n * @param {(Token|Token[])[]} e2\n * @returns {number}\n */\nfunction rfc8949MapSorter (e1, e2) {\n if (e1[0] instanceof Token && e2[0] instanceof Token) {\n const t1 = /** @type {TokenEx} */ (e1[0])\n const t2 = /** @type {TokenEx} */ (e2[0])\n\n if (!t1._keyBytes) {\n t1._keyBytes = encodeRfc8949(t1.value)\n }\n\n if (!t2._keyBytes) {\n t2._keyBytes = encodeRfc8949(t2.value)\n }\n\n return compare(t1._keyBytes, t2._keyBytes)\n }\n\n throw new Error('rfc8949MapSorter: complex key types are not supported yet')\n}\n\n/**\n * @param {any} data\n * @returns {Uint8Array}\n */\nfunction encodeRfc8949 (data) {\n return encodeCustom(data, cborEncoders, rfc8949EncodeOptions)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {TokenOrNestedTokens} tokens\n * @param {TokenTypeEncoder[]} encoders\n * @param {EncodeOptions} options\n */\nfunction tokensToEncoded (writer, tokens, encoders, options) {\n if (Array.isArray(tokens)) {\n for (const token of tokens) {\n tokensToEncoded(writer, token, encoders, options)\n }\n } else {\n encoders[tokens.type.major](writer, tokens, options)\n }\n}\n\n// CBOR major type prefixes, cached from Type for hot path performance\nconst MAJOR_UINT = Type.uint.majorEncoded\nconst MAJOR_NEGINT = Type.negint.majorEncoded\nconst MAJOR_BYTES = Type.bytes.majorEncoded\nconst MAJOR_STRING = Type.string.majorEncoded\nconst MAJOR_ARRAY = Type.array.majorEncoded\n\n// Simple value bytes (CBOR major type 7 + minor value)\nconst SIMPLE_FALSE = Type.float.majorEncoded | MINOR_FALSE\nconst SIMPLE_TRUE = Type.float.majorEncoded | MINOR_TRUE\nconst SIMPLE_NULL = Type.float.majorEncoded | MINOR_NULL\nconst SIMPLE_UNDEFINED = Type.float.majorEncoded | MINOR_UNDEFINED\n\nconst neg1b = BigInt(-1)\nconst pos1b = BigInt(1)\n\n/**\n * Check if direct encoding can be used for the given options.\n * Direct encoding bypasses token creation for most values.\n * @param {EncodeOptions} options\n * @returns {boolean}\n */\nfunction canDirectEncode (options) {\n // Cannot use direct encode with addBreakTokens (needs special break token handling).\n // Direct encode checks typeEncoders per-value, falling back to tokens as needed.\n // Maps fall back to token-based encoding for efficient key sorting.\n return options.addBreakTokens !== true\n}\n\n/**\n * Direct encode a value to the writer, bypassing token creation for most types.\n * Falls back to token-based encoding for custom type encoders.\n * @param {ByteWriter} writer\n * @param {any} data\n * @param {EncodeOptions} options\n * @param {Reference|undefined} refStack\n */\nfunction directEncode (writer, data, options, refStack) {\n const typ = is(data)\n\n // Check for custom encoder for THIS specific type\n const customEncoder = options.typeEncoders && options.typeEncoders[typ]\n if (customEncoder) {\n const tokens = customEncoder(data, typ, options, refStack)\n if (tokens != null) {\n // Custom encoder returned tokens, serialize immediately\n tokensToEncoded(writer, tokens, cborEncoders, options)\n return\n }\n // Custom encoder returned null, fall through to default handling\n }\n\n // Direct encode based on type\n switch (typ) {\n case 'null':\n writer.push([SIMPLE_NULL])\n return\n\n case 'undefined':\n writer.push([SIMPLE_UNDEFINED])\n return\n\n case 'boolean':\n writer.push([data ? SIMPLE_TRUE : SIMPLE_FALSE])\n return\n\n case 'number':\n if (!Number.isInteger(data) || !Number.isSafeInteger(data)) {\n // Float, use token encoder for complex float encoding\n encodeFloat(writer, new Token(Type.float, data), options)\n } else if (data >= 0) {\n encodeUintValue(writer, MAJOR_UINT, data)\n } else {\n // Negative integer\n encodeUintValue(writer, MAJOR_NEGINT, data * -1 - 1)\n }\n return\n\n case 'bigint':\n if (data >= BigInt(0)) {\n encodeUintValue(writer, MAJOR_UINT, data)\n } else {\n encodeUintValue(writer, MAJOR_NEGINT, data * neg1b - pos1b)\n }\n return\n\n case 'string': {\n const bytes = fromString(data)\n encodeUintValue(writer, MAJOR_STRING, bytes.length)\n writer.push(bytes)\n return\n }\n\n case 'Uint8Array':\n encodeUintValue(writer, MAJOR_BYTES, data.length)\n writer.push(data)\n return\n\n case 'Array':\n if (!data.length) {\n writer.push([MAJOR_ARRAY]) // Empty array: 0x80\n return\n }\n refStack = Ref.createCheck(refStack, data)\n encodeUintValue(writer, MAJOR_ARRAY, data.length)\n for (const elem of data) {\n directEncode(writer, elem, options, refStack)\n }\n return\n\n case 'Object':\n case 'Map':\n // Maps require key sorting, use token-based encoding for efficiency\n // (pre-encoding all keys for sorting is expensive)\n {\n const tokens = typeEncoders.Object(data, typ, options, refStack)\n tokensToEncoded(writer, tokens, cborEncoders, options)\n }\n return\n\n default:\n // Fall back to token-based encoding for other types (DataView, TypedArrays, etc.)\n {\n const typeEncoder = typeEncoders[typ]\n if (!typeEncoder) {\n throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`)\n }\n const tokens = typeEncoder(data, typ, options, refStack)\n tokensToEncoded(writer, tokens, cborEncoders, options)\n }\n }\n}\n\n/**\n * @param {any} data\n * @param {TokenTypeEncoder[]} encoders\n * @param {EncodeOptions} options\n * @param {Uint8Array} [destination]\n * @returns {Uint8Array}\n */\nfunction encodeCustom (data, encoders, options, destination) {\n // arg ordering is different to encodeInto for backward compatibility\n const hasDest = destination instanceof Uint8Array\n let writeTo = hasDest ? new U8Bl(destination) : defaultWriter\n\n const tokens = objectToTokens(data, options)\n if (!Array.isArray(tokens) && options.quickEncodeToken) {\n const quickBytes = options.quickEncodeToken(tokens)\n if (quickBytes) {\n if (hasDest) {\n // Copy quick bytes into destination buffer\n writeTo.push(quickBytes)\n return writeTo.toBytes()\n }\n return quickBytes\n }\n const encoder = encoders[tokens.type.major]\n if (encoder.encodedSize) {\n const size = encoder.encodedSize(tokens, options)\n if (!hasDest) {\n writeTo = new Bl(size)\n }\n encoder(writeTo, tokens, options)\n /* c8 ignore next 4 */\n // this would be a problem with encodedSize() functions\n if (writeTo.chunks.length !== 1) {\n throw new Error(`Unexpected error: pre-calculated length for ${tokens} was wrong`)\n }\n return hasDest ? writeTo.toBytes() : asU8A(writeTo.chunks[0])\n }\n }\n writeTo.reset()\n tokensToEncoded(writeTo, tokens, encoders, options)\n return writeTo.toBytes(true)\n}\n\n/**\n * @param {any} data\n * @param {EncodeOptions} [options]\n * @returns {Uint8Array}\n */\nfunction encode (data, options) {\n options = Object.assign({}, defaultEncodeOptions, options)\n\n // Use direct encode path when possible\n if (canDirectEncode(options)) {\n defaultWriter.reset()\n directEncode(defaultWriter, data, options, undefined)\n return defaultWriter.toBytes(true)\n }\n\n return encodeCustom(data, cborEncoders, options)\n}\n\n/**\n * @param {any} data\n * @param {Uint8Array} destination\n * @param {EncodeOptions} [options]\n * @returns {{ written: number }}\n */\nfunction encodeInto (data, destination, options) {\n options = Object.assign({}, defaultEncodeOptions, options)\n\n // Use direct encode path when possible\n if (canDirectEncode(options)) {\n const writer = new U8Bl(destination)\n directEncode(writer, data, options, undefined)\n return { written: writer.toBytes().length }\n }\n\n const result = encodeCustom(data, cborEncoders, options, destination)\n return { written: result.length }\n}\n\nexport { objectToTokens, encode, encodeCustom, encodeInto, Ref }\n","import { decodeErrPrefix } from './common.js'\nimport { Type } from './token.js'\nimport { jump, quick } from './jump.js'\nimport { asU8A } from './byte-utils.js'\n\n/**\n * @typedef {import('./token.js').Token} Token\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n * @typedef {import('../interface').DecodeTokenizer} DecodeTokenizer\n */\n\nconst defaultDecodeOptions = {\n strict: false,\n allowIndefinite: true,\n allowUndefined: true,\n allowBigInt: true\n}\n\n/**\n * @implements {DecodeTokenizer}\n */\nclass Tokeniser {\n /**\n * @param {Uint8Array} data\n * @param {DecodeOptions} options\n */\n constructor (data, options = {}) {\n this._pos = 0\n this.data = data\n this.options = options\n }\n\n pos () {\n return this._pos\n }\n\n done () {\n return this._pos >= this.data.length\n }\n\n next () {\n const byt = this.data[this._pos]\n let token = quick[byt]\n if (token === undefined) {\n const decoder = jump[byt]\n /* c8 ignore next 4 */\n // if we're here then there's something wrong with our jump or quick lists!\n if (!decoder) {\n throw new Error(`${decodeErrPrefix} no decoder for major type ${byt >>> 5} (byte 0x${byt.toString(16).padStart(2, '0')})`)\n }\n const minor = byt & 31\n token = decoder(this.data, this._pos, minor, this.options)\n }\n // @ts-ignore we get to assume encodedLength is set (crossing fingers slightly)\n this._pos += token.encodedLength\n return token\n }\n}\n\nconst DONE = Symbol.for('DONE')\nconst BREAK = Symbol.for('BREAK')\n\n/**\n * @param {Token} token\n * @param {DecodeTokenizer} tokeniser\n * @param {DecodeOptions} options\n * @returns {any|BREAK|DONE}\n */\nfunction tokenToArray (token, tokeniser, options) {\n const arr = []\n for (let i = 0; i < token.value; i++) {\n const value = tokensToObject(tokeniser, options)\n if (value === BREAK) {\n if (token.value === Infinity) {\n // normal end to indefinite length array\n break\n }\n throw new Error(`${decodeErrPrefix} got unexpected break to lengthed array`)\n }\n if (value === DONE) {\n throw new Error(`${decodeErrPrefix} found array but not enough entries (got ${i}, expected ${token.value})`)\n }\n arr[i] = value\n }\n return arr\n}\n\n/**\n * @param {Token} token\n * @param {DecodeTokenizer} tokeniser\n * @param {DecodeOptions} options\n * @returns {any|BREAK|DONE}\n */\nfunction tokenToMap (token, tokeniser, options) {\n const useMaps = options.useMaps === true\n const rejectDuplicateMapKeys = options.rejectDuplicateMapKeys === true\n const obj = useMaps ? undefined : {}\n const m = useMaps ? new Map() : undefined\n for (let i = 0; i < token.value; i++) {\n const key = tokensToObject(tokeniser, options)\n if (key === BREAK) {\n if (token.value === Infinity) {\n // normal end to indefinite length map\n break\n }\n throw new Error(`${decodeErrPrefix} got unexpected break to lengthed map`)\n }\n if (key === DONE) {\n throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no key], expected ${token.value})`)\n }\n if (!useMaps && typeof key !== 'string') {\n throw new Error(`${decodeErrPrefix} non-string keys not supported (got ${typeof key})`)\n }\n if (rejectDuplicateMapKeys) {\n // @ts-ignore\n if ((useMaps && m.has(key)) || (!useMaps && Object.hasOwn(obj, key))) {\n throw new Error(`${decodeErrPrefix} found repeat map key \"${key}\"`)\n }\n }\n const value = tokensToObject(tokeniser, options)\n if (value === DONE) {\n throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no value], expected ${token.value})`)\n }\n if (useMaps) {\n // @ts-ignore TODO reconsider this .. maybe needs to be strict about key types\n m.set(key, value)\n } else {\n // @ts-ignore TODO reconsider this .. maybe needs to be strict about key types\n obj[key] = value\n }\n }\n // @ts-ignore c'mon man\n return useMaps ? m : obj\n}\n\n/**\n * @param {DecodeTokenizer} tokeniser\n * @param {DecodeOptions} options\n * @returns {any|BREAK|DONE}\n */\nfunction tokensToObject (tokeniser, options) {\n // should we support array as an argument?\n // check for tokenIter[Symbol.iterator] and replace tokenIter with what that returns?\n if (tokeniser.done()) {\n return DONE\n }\n\n const token = tokeniser.next()\n\n if (Type.equals(token.type, Type.break)) {\n return BREAK\n }\n\n if (token.type.terminal) {\n return token.value\n }\n\n if (Type.equals(token.type, Type.array)) {\n return tokenToArray(token, tokeniser, options)\n }\n\n if (Type.equals(token.type, Type.map)) {\n return tokenToMap(token, tokeniser, options)\n }\n\n if (Type.equals(token.type, Type.tag)) {\n if (options.tags && typeof options.tags[token.value] === 'function') {\n const tagged = tokensToObject(tokeniser, options)\n return options.tags[token.value](tagged)\n }\n throw new Error(`${decodeErrPrefix} tag not supported (${token.value})`)\n }\n /* c8 ignore next */\n throw new Error('unsupported')\n}\n\n/**\n * @param {Uint8Array} data\n * @param {DecodeOptions} [options]\n * @returns {[any, Uint8Array]}\n */\nfunction decodeFirst (data, options) {\n if (!(data instanceof Uint8Array)) {\n throw new Error(`${decodeErrPrefix} data to decode must be a Uint8Array`)\n }\n options = Object.assign({}, defaultDecodeOptions, options)\n // Convert Buffer to plain Uint8Array for faster slicing in decode path\n const u8aData = asU8A(data)\n const tokeniser = options.tokenizer || new Tokeniser(u8aData, options)\n const decoded = tokensToObject(tokeniser, options)\n if (decoded === DONE) {\n throw new Error(`${decodeErrPrefix} did not find any content to decode`)\n }\n if (decoded === BREAK) {\n throw new Error(`${decodeErrPrefix} got unexpected break`)\n }\n return [decoded, data.subarray(tokeniser.pos())]\n}\n\n/**\n * @param {Uint8Array} data\n * @param {DecodeOptions} [options]\n * @returns {any}\n */\nfunction decode (data, options) {\n const [decoded, remainder] = decodeFirst(data, options)\n if (remainder.length > 0) {\n throw new Error(`${decodeErrPrefix} too many terminals, data makes no sense`)\n }\n return decoded\n}\n\nexport { Tokeniser, tokensToObject, decode, decodeFirst }\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport { encode as cborEncode, decode as cborDecodeRaw } from \"cborg\";\nimport {\n SecretKey as XdsaSecretKey,\n PublicKey as XdsaPublicKey,\n Fingerprint as XdsaFingerprint,\n} from \"./xdsa.js\";\nimport {\n SecretKey as XhpkeSecretKey,\n PublicKey as XhpkePublicKey,\n Fingerprint as XhpkeFingerprint,\n} from \"./xhpke.js\";\n\nfunction cborDecode<T>(data: Uint8Array): T {\n return cborDecodeRaw(data, { useMaps: true }) as T;\n}\n\nimport init, {\n cose_sign,\n cose_sign_detached,\n cose_verify,\n cose_verify_detached,\n cose_signer,\n cose_peek,\n cose_recipient,\n cose_seal,\n cose_open,\n cose_encrypt,\n cose_decrypt,\n} from \"./wasm/darkbio_crypto_wasm.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/**\n * Create a COSE_Sign1 signature with an embedded payload.\n *\n * @param msgToEmbed - The payload to embed and sign (will be CBOR encoded)\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param signer - The xDSA secret key\n * @param domain - Application-specific domain separator\n * @returns The serialized COSE_Sign1 structure\n */\nexport async function sign<E, A>(\n msgToEmbed: E,\n msgToAuth: A,\n signer: XdsaSecretKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const embedBytes = cborEncode(msgToEmbed);\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_sign(embedBytes, authBytes, signer.toBytes(), domain),\n );\n}\n\n/**\n * Create a COSE_Sign1 signature without an embedded payload (detached mode).\n *\n * @param msgToAuth - The message to authenticate (will be CBOR encoded)\n * @param signer - The xDSA secret key\n * @param domain - Application-specific domain separator\n * @returns The serialized COSE_Sign1 structure (with null payload)\n */\nexport async function signDetached<A>(\n msgToAuth: A,\n signer: XdsaSecretKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_sign_detached(authBytes, signer.toBytes(), domain),\n );\n}\n\n/**\n * Verify a COSE_Sign1 signature and return the embedded payload.\n *\n * @param msgToCheck - The COSE_Sign1 structure to verify\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param verifier - The xDSA public key\n * @param domain - Application-specific domain separator\n * @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)\n * @returns The decoded embedded payload\n */\nexport async function verify<T, A>(\n msgToCheck: Uint8Array,\n msgToAuth: A,\n verifier: XdsaPublicKey,\n domain: Uint8Array,\n maxDriftSecs?: number,\n): Promise<T> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n const payloadBytes = cose_verify(\n msgToCheck,\n authBytes,\n verifier.toBytes(),\n domain,\n maxDriftSecs !== undefined ? BigInt(maxDriftSecs) : undefined,\n );\n return cborDecode(new Uint8Array(payloadBytes)) as T;\n}\n\n/**\n * Verify a COSE_Sign1 signature with a detached payload.\n *\n * @param msgToCheck - The COSE_Sign1 structure to verify\n * @param msgToAuth - The detached message to authenticate (will be CBOR encoded)\n * @param verifier - The xDSA public key\n * @param domain - Application-specific domain separator\n * @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)\n */\nexport async function verifyDetached<A>(\n msgToCheck: Uint8Array,\n msgToAuth: A,\n verifier: XdsaPublicKey,\n domain: Uint8Array,\n maxDriftSecs?: number,\n): Promise<void> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n cose_verify_detached(\n msgToCheck,\n authBytes,\n verifier.toBytes(),\n domain,\n maxDriftSecs !== undefined ? BigInt(maxDriftSecs) : undefined,\n );\n}\n\n/**\n * Extract the signer's fingerprint from a COSE_Sign1 without verifying.\n *\n * @param signature - The COSE_Sign1 structure\n * @returns The signer fingerprint\n */\nexport async function signer(signature: Uint8Array): Promise<XdsaFingerprint> {\n await ensureInit();\n const fp = new Uint8Array(cose_signer(signature));\n return XdsaFingerprint.fromBytes(fp);\n}\n\n/**\n * Extract the embedded payload from a COSE_Sign1 without verifying.\n *\n * Warning: The returned payload is unauthenticated and should not be\n * trusted until verified with `verify`.\n *\n * @param signature - The COSE_Sign1 structure\n * @returns The decoded (but unverified) payload\n */\nexport async function peek<T>(signature: Uint8Array): Promise<T> {\n await ensureInit();\n const payloadBytes = cose_peek(signature);\n return cborDecode(new Uint8Array(payloadBytes)) as T;\n}\n\n/**\n * Extract the recipient's fingerprint from a COSE_Encrypt0 without decrypting.\n *\n * @param ciphertext - The COSE_Encrypt0 structure\n * @returns The recipient fingerprint\n */\nexport async function recipient(\n ciphertext: Uint8Array,\n): Promise<XhpkeFingerprint> {\n await ensureInit();\n const fp = new Uint8Array(cose_recipient(ciphertext));\n return XhpkeFingerprint.fromBytes(fp);\n}\n\n/**\n * Sign a message then encrypt it to a recipient (sign-then-encrypt).\n *\n * @param msgToSeal - The payload to sign and encrypt (will be CBOR encoded)\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param signerKey - The xDSA secret key to sign with\n * @param recipientKey - The xHPKE public key to encrypt to\n * @param domain - Application-specific domain separator\n * @returns The sealed COSE structure\n */\nexport async function seal<S, A>(\n msgToSeal: S,\n msgToAuth: A,\n signerKey: XdsaSecretKey,\n recipientKey: XhpkePublicKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const sealBytes = cborEncode(msgToSeal);\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_seal(\n sealBytes,\n authBytes,\n signerKey.toBytes(),\n recipientKey.toBytes(),\n domain,\n ),\n );\n}\n\n/**\n * Decrypt and verify a sealed message.\n *\n * @param msgToOpen - The sealed COSE structure\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param recipientKey - The xHPKE secret key to decrypt with\n * @param senderKey - The xDSA public key to verify against\n * @param domain - Application-specific domain separator\n * @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)\n * @returns The decoded payload\n */\nexport async function open<T, A>(\n msgToOpen: Uint8Array,\n msgToAuth: A,\n recipientKey: XhpkeSecretKey,\n senderKey: XdsaPublicKey,\n domain: Uint8Array,\n maxDriftSecs?: number,\n): Promise<T> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n const payloadBytes = cose_open(\n msgToOpen,\n authBytes,\n recipientKey.toBytes(),\n senderKey.toBytes(),\n domain,\n maxDriftSecs !== undefined ? BigInt(maxDriftSecs) : undefined,\n );\n return cborDecode(new Uint8Array(payloadBytes)) as T;\n}\n\n/**\n * Encrypt an already-signed COSE_Sign1 to a recipient.\n *\n * For most use cases, prefer `seal` which signs and encrypts in one step.\n * Use this only when re-encrypting a message to a different recipient\n * without access to the original signer's key.\n *\n * @param sign1 - The COSE_Sign1 structure to encrypt\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param recipientKey - The xHPKE public key to encrypt to\n * @param domain - Application-specific domain separator\n * @returns The COSE_Encrypt0 structure\n */\nexport async function encrypt<A>(\n sign1: Uint8Array,\n msgToAuth: A,\n recipientKey: XhpkePublicKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_encrypt(sign1, authBytes, recipientKey.toBytes(), domain),\n );\n}\n\n/**\n * Decrypt a sealed message without verifying the signature.\n *\n * This allows inspecting the signer before verification. Use `signer` to\n * extract the signer's fingerprint, then verify with `verify`.\n *\n * @param msgToOpen - The COSE_Encrypt0 structure\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param recipientKey - The xHPKE secret key to decrypt with\n * @param domain - Application-specific domain separator\n * @returns The decrypted COSE_Sign1 structure (not yet verified)\n */\nexport async function decrypt<A>(\n msgToOpen: Uint8Array,\n msgToAuth: A,\n recipientKey: XhpkeSecretKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_decrypt(msgToOpen, authBytes, recipientKey.toBytes(), domain),\n );\n}\n"],"names":["argon2_key","password","salt","time","memory","threads","out_len","ptr0","passArray8ToWasm0","wasm","len0","WASM_VECTOR_LEN","ptr1","len1","ret","v3","getArrayU8FromWasm0","cose_decrypt","msg_to_open","msg_to_auth","recipient","domain","ptr2","len2","ptr3","len3","takeFromExternrefTable0","v5","cose_encrypt","sign1","cose_open","sender","max_drift_secs","ptr4","len4","isLikeNone","v6","cose_peek","signature","v2","cose_recipient","ciphertext","cose_seal","msg_to_seal","signer","cose_sign","msg_to_embed","cose_sign_detached","v4","cose_signer","cose_verify","msg_to_check","verifier","cose_verify_detached","hkdf_expand","prk","info","hkdf_extract","secret","hkdf_key","rand_generate","bytes","v1","xdsa_fingerprint","public_key","xdsa_fingerprint_size","xdsa_generate","xdsa_public_key","secret_key","xdsa_public_key_from_cert_der","der","xdsa_public_key_from_cert_pem","pem","passStringToWasm0","xdsa_public_key_from_pem","xdsa_public_key_size","xdsa_public_key_to_cert_der","subject_name","issuer_name","not_before","not_after","is_ca","path_len","xdsa_public_key_to_cert_pem","deferred6_0","deferred6_1","ptr5","len5","getStringFromWasm0","xdsa_public_key_to_pem","deferred3_0","deferred3_1","xdsa_secret_key_from_pem","xdsa_secret_key_size","xdsa_secret_key_to_pem","xdsa_sign","message","xdsa_signature_size","xdsa_verify","xhpke_encap_key_size","xhpke_fingerprint","xhpke_fingerprint_size","xhpke_generate","xhpke_open","sealed","xhpke_public_key","xhpke_public_key_from_cert_der","xhpke_public_key_from_cert_pem","xhpke_public_key_from_pem","xhpke_public_key_size","xhpke_public_key_to_cert_der","xhpke_public_key_to_cert_pem","xhpke_public_key_to_pem","xhpke_seal","xhpke_secret_key_from_pem","xhpke_secret_key_size","xhpke_secret_key_to_pem","__wbg_get_imports","arg0","arg1","val","handleError","arg2","addToExternrefTable0","table","offset","obj","idx","ptr","len","getUint8ArrayMemory0","decodeText","cachedUint8ArrayMemory0","f","args","e","x","arg","malloc","realloc","buf","cachedTextEncoder","mem","code","view","value","cachedTextDecoder","MAX_SAFARI_DECODE_BYTES","numBytesDecoded","__wbg_finalize_init","instance","module","__wbg_load","imports","expectedResponseType","type","__wbg_init","module_or_path","initialized","ensureInit","init","generate","key","outLen","extract","expand","SECRET_KEY_SIZE","PUBLIC_KEY_SIZE","SIGNATURE_SIZE","FINGERPRINT_SIZE","sizes","Fingerprint$1","Fingerprint","Signature","PublicKey$1","PublicKey","result","notBefore","notAfter","fp","params","SecretKey$1","SecretKey","pk","sig","ENCAP_KEY_SIZE","msgToSeal","msgToAuth","objectTypeNames","is","typeOf","objectType","getObjectType","objectTypeName","Type","major","name","terminal","typ","a","b","Token","encodedLength","useBuffer","textEncoder","isBuffer","asU8A","FROM_STRING_THRESHOLD_BUFFER","FROM_STRING_THRESHOLD_TEXTENCODER","fromString","string","utf8ToBytes","fromArray","arr","slice","start","end","concat","chunks","length","c","out","off","alloc","size","compare","b1","b2","i","str","p","defaultChunkSize","Bl","chunkSize","topChunk","chunkPos","reset","byts","chunk","U8Bl","dest","decodeErrPrefix","encodeErrPrefix","assertEnoughData","data","pos","need","uintBoundaries","readUint8","options","readUint16","readUint32","readUint64","hi","lo","decodeUint8","_minor","decodeUint16","decodeUint32","decodeUint64","encodeUint","writer","token","encodeUintValue","uint","nuint","buint","set","tok1","tok2","decodeNegint8","uint.readUint8","decodeNegint16","uint.readUint16","decodeNegint32","uint.readUint32","neg1b","pos1b","decodeNegint64","int","uint.readUint64","encodeNegint","negint","unsigned","uint.encodeUintValue","uint.uintBoundaries","toToken","prefix","decodeBytesCompact","minor","_options","decodeBytes8","decodeBytes16","decodeBytes32","decodeBytes64","l","tokenBytes","encodeBytes","compareBytes","textDecoder","ASCII_THRESHOLD","toStr","totLength","tok","decodeStringCompact","decodeString8","decodeString16","decodeString32","decodeString64","encodeString","_data","_pos","decodeArrayCompact","decodeArray8","decodeArray16","decodeArray32","decodeArray64","decodeArrayIndefinite","encodeArray","uint.encodeUint","decodeMapCompact","decodeMap8","decodeMap16","decodeMap32","decodeMap64","decodeMapIndefinite","encodeMap","decodeTagCompact","decodeTag8","decodeTag16","decodeTag32","decodeTag64","encodeTag","MINOR_FALSE","MINOR_TRUE","MINOR_NULL","MINOR_UNDEFINED","decodeUndefined","decodeBreak","createToken","decodeFloat16","readFloat16","decodeFloat32","readFloat32","decodeFloat64","readFloat64","encodeFloat","float","decoded","success","encodeFloat16","ui8a","encodeFloat32","encodeFloat64","buffer","dataView","inp","valu32","exponent","mantissa","logicalExponent","half","exp","mant","invalidMinor","errorer","msg","jump","uint.decodeUint8","uint.decodeUint16","uint.decodeUint32","uint.decodeUint64","negint.decodeNegint8","negint.decodeNegint16","negint.decodeNegint32","negint.decodeNegint64","bytes.decodeBytesCompact","bytes.decodeBytes8","bytes.decodeBytes16","bytes.decodeBytes32","bytes.decodeBytes64","string.decodeStringCompact","string.decodeString8","string.decodeString16","string.decodeString32","string.decodeString64","array.decodeArrayCompact","array.decodeArray8","array.decodeArray16","array.decodeArray32","array.decodeArray64","array.decodeArrayIndefinite","map.decodeMapCompact","map.decodeMap8","map.decodeMap16","map.decodeMap32","map.decodeMap64","map.decodeMapIndefinite","tag.decodeTagCompact","tag.decodeTag8","tag.decodeTag16","tag.decodeTag32","tag.decodeTag64","float.decodeUndefined","float.decodeFloat16","float.decodeFloat32","float.decodeFloat64","float.decodeBreak","quick","quickEncodeToken","defaultEncodeOptions","mapSorter","makeCborEncoders","encoders","cborEncoders","defaultWriter","Ref","parent","stack","simpleTokens","typeEncoders","_typ","_refStack","_obj","refStack","entries","objectToTokens","isMap","keys","maxLength","skipUndefined","sortMapEntries","customTypeEncoder","tokens","typeEncoder","e1","e2","keyToken1","keyToken2","tcmp","tokensToEncoded","MAJOR_UINT","MAJOR_NEGINT","MAJOR_BYTES","MAJOR_STRING","MAJOR_ARRAY","SIMPLE_FALSE","SIMPLE_TRUE","SIMPLE_NULL","SIMPLE_UNDEFINED","canDirectEncode","directEncode","customEncoder","elem","encodeCustom","destination","hasDest","writeTo","quickBytes","encoder","encode","defaultDecodeOptions","Tokeniser","byt","decoder","DONE","BREAK","tokenToArray","tokeniser","tokensToObject","tokenToMap","useMaps","rejectDuplicateMapKeys","m","tagged","decodeFirst","u8aData","decode","remainder","cborDecode","cborDecodeRaw","sign","msgToEmbed","embedBytes","cborEncode","authBytes","signDetached","verify","msgToCheck","maxDriftSecs","payloadBytes","verifyDetached","XdsaFingerprint","peek","XhpkeFingerprint","seal","signerKey","recipientKey","sealBytes","open","msgToOpen","senderKey","encrypt","decrypt"],"mappings":"AAwBO,SAASA,GAAWC,GAAUC,GAAMC,GAAMC,GAAQC,GAASC,GAAS;AACvE,QAAMC,IAAOC,EAAkBP,GAAUQ,EAAK,iBAAiB,GACzDC,IAAOC,GACPC,IAAOJ,EAAkBN,GAAMO,EAAK,iBAAiB,GACrDI,IAAOF,GACPG,IAAML,EAAK,WAAWF,GAAMG,GAAME,GAAMC,GAAMV,GAAMC,GAAQC,GAASC,CAAO;AAClF,MAAIS,IAAKC,EAAoBF,EAAI,CAAC,GAAGA,EAAI,CAAC,CAAC,EAAE,MAAK;AAClD,SAAAL,EAAK,gBAAgBK,EAAI,CAAC,GAAGA,EAAI,CAAC,IAAI,GAAG,CAAC,GACnCC;AACX;AAuBO,SAASE,GAAaC,GAAaC,GAAaC,GAAWC,GAAQ;AACtE,QAAMd,IAAOC,EAAkBU,GAAaT,EAAK,iBAAiB,GAC5DC,IAAOC,GACPC,IAAOJ,EAAkBW,GAAaV,EAAK,iBAAiB,GAC5DI,IAAOF,GACPW,IAAOd,EAAkBY,GAAWX,EAAK,iBAAiB,GAC1Dc,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eA,eAAsBY,GACpBzd,GACA8J,GACAsT,GACA5d,GACqB;AACrB,QAAM0I,EAAA;AACN,QAAMsU,IAAYD,EAAWzS,CAAS;AACtC,SAAO,IAAI;AAAA,IACT/J,GAAaC,GAAOwc,GAAWY,EAAa,QAAA,GAAW5d,CAAM;AAAA,EAAA;AAEjE;AAcA,eAAsBke,GACpBH,GACAzT,GACAsT,GACA5d,GACqB;AACrB,QAAM0I,EAAA;AACN,QAAMsU,IAAYD,EAAWzS,CAAS;AACtC,SAAO,IAAI;AAAA,IACT1K,GAAame,GAAWf,GAAWY,EAAa,QAAA,GAAW5d,CAAM;AAAA,EAAA;AAErE;;;;;;;;;;;;;;;","x_google_ignoreList":[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/wasm/darkbio_crypto_wasm.js","../src/rand.ts","../src/hkdf.ts","../src/argon2.ts","../src/xdsa.ts","../src/xhpke.ts","../node_modules/cborg/lib/is.js","../node_modules/cborg/lib/token.js","../node_modules/cborg/lib/byte-utils.js","../node_modules/cborg/lib/bl.js","../node_modules/cborg/lib/common.js","../node_modules/cborg/lib/0uint.js","../node_modules/cborg/lib/1negint.js","../node_modules/cborg/lib/2bytes.js","../node_modules/cborg/lib/3string.js","../node_modules/cborg/lib/4array.js","../node_modules/cborg/lib/5map.js","../node_modules/cborg/lib/6tag.js","../node_modules/cborg/lib/7float.js","../node_modules/cborg/lib/jump.js","../node_modules/cborg/lib/encode.js","../node_modules/cborg/lib/decode.js","../src/cose.ts"],"sourcesContent":["/* @ts-self-types=\"./darkbio_crypto_wasm.d.ts\" */\n\n/**\n * Derives a key from the password, salt, and cost parameters using Argon2id,\n * returning a byte array that can be used as a cryptographic key. The CPU cost\n * and parallelism degree must be greater than zero.\n *\n * RFC 9106 Section 7.4 recommends time=1, and memory=2048*1024 as a sensible\n * number. If using that amount of memory (2GB) is not possible in some contexts\n * then the time parameter can be increased to compensate.\n *\n * The time parameter specifies the number of passes over the memory and the\n * memory parameter specifies the size of the memory in KiB. The number of threads\n * can be adjusted to the numbers of available CPUs. The cost parameters should be\n * increased as memory latency and CPU parallelism increases. Remember to get a\n * good random salt.\n * @param {Uint8Array} password\n * @param {Uint8Array} salt\n * @param {number} time\n * @param {number} memory\n * @param {number} threads\n * @param {number} out_len\n * @returns {Uint8Array}\n */\nexport function argon2_key(password, salt, time, memory, threads, out_len) {\n const ptr0 = passArray8ToWasm0(password, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.argon2_key(ptr0, len0, ptr1, len1, time, memory, threads, out_len);\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Verifies that data is valid CBOR using the restricted type system.\n * @param {Uint8Array} data\n */\nexport function cbor_verify(data) {\n const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cbor_verify(ptr0, len0);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n}\n\n/**\n * Decrypts a sealed message without verifying the signature.\n * @param {Uint8Array} msg_to_open\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} recipient\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_decrypt(msg_to_open, msg_to_auth, recipient, domain) {\n const ptr0 = passArray8ToWasm0(msg_to_open, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(recipient, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_decrypt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Encrypts an already-signed COSE_Sign1 to a recipient.\n * @param {Uint8Array} sign1\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} recipient\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_encrypt(sign1, msg_to_auth, recipient, domain) {\n const ptr0 = passArray8ToWasm0(sign1, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(recipient, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_encrypt(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Decrypts and verifies a sealed message.\n * @param {Uint8Array} msg_to_open\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} recipient\n * @param {Uint8Array} sender\n * @param {Uint8Array} domain\n * @param {bigint | null} [max_drift_secs]\n * @returns {Uint8Array}\n */\nexport function cose_open(msg_to_open, msg_to_auth, recipient, sender, domain, max_drift_secs) {\n const ptr0 = passArray8ToWasm0(msg_to_open, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(recipient, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(sender, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ptr4 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len4 = WASM_VECTOR_LEN;\n const ret = wasm.cose_open(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, !isLikeNone(max_drift_secs), isLikeNone(max_drift_secs) ? BigInt(0) : max_drift_secs);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v6;\n}\n\n/**\n * Extracts the embedded payload from a COSE_Sign1 without verifying.\n * @param {Uint8Array} signature\n * @returns {Uint8Array}\n */\nexport function cose_peek(signature) {\n const ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cose_peek(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Extracts the recipient's fingerprint from a COSE_Encrypt0 without decrypting.\n * @param {Uint8Array} ciphertext\n * @returns {Uint8Array}\n */\nexport function cose_recipient(ciphertext) {\n const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cose_recipient(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Signs a message then encrypts it to a recipient (sign-then-encrypt).\n * @param {Uint8Array} msg_to_seal\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} signer\n * @param {Uint8Array} recipient\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_seal(msg_to_seal, msg_to_auth, signer, recipient, domain) {\n const ptr0 = passArray8ToWasm0(msg_to_seal, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(recipient, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ptr4 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len4 = WASM_VECTOR_LEN;\n const ret = wasm.cose_seal(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v6;\n}\n\n/**\n * Creates a COSE_Sign1 signature with an embedded payload.\n * @param {Uint8Array} msg_to_embed\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} signer\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_sign(msg_to_embed, msg_to_auth, signer, domain) {\n const ptr0 = passArray8ToWasm0(msg_to_embed, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_sign(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Creates a COSE_Sign1 signature without an embedded payload (detached mode).\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} signer\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function cose_sign_detached(msg_to_auth, signer, domain) {\n const ptr0 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.cose_sign_detached(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v4;\n}\n\n/**\n * Extracts the signer's fingerprint from a COSE_Sign1 without verifying.\n * @param {Uint8Array} signature\n * @returns {Uint8Array}\n */\nexport function cose_signer(signature) {\n const ptr0 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.cose_signer(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Verifies a COSE_Sign1 signature and returns the embedded payload.\n * @param {Uint8Array} msg_to_check\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} verifier\n * @param {Uint8Array} domain\n * @param {bigint | null} [max_drift_secs]\n * @returns {Uint8Array}\n */\nexport function cose_verify(msg_to_check, msg_to_auth, verifier, domain, max_drift_secs) {\n const ptr0 = passArray8ToWasm0(msg_to_check, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(verifier, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, !isLikeNone(max_drift_secs), isLikeNone(max_drift_secs) ? BigInt(0) : max_drift_secs);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Verifies a COSE_Sign1 signature with a detached payload.\n * @param {Uint8Array} msg_to_check\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} verifier\n * @param {Uint8Array} domain\n * @param {bigint | null} [max_drift_secs]\n */\nexport function cose_verify_detached(msg_to_check, msg_to_auth, verifier, domain, max_drift_secs) {\n const ptr0 = passArray8ToWasm0(msg_to_check, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(verifier, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.cose_verify_detached(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, !isLikeNone(max_drift_secs), isLikeNone(max_drift_secs) ? BigInt(0) : max_drift_secs);\n if (ret[1]) {\n throw takeFromExternrefTable0(ret[0]);\n }\n}\n\n/**\n * Derives a key using the given pseudorandom key and optional context info,\n * skipping the extraction step.\n *\n * The pseudorandom key should have been generated by hkdf_extract, or be a\n * uniformly random or pseudorandom cryptographically strong key. See RFC 5869,\n * Section 3.3. Most common scenarios will want to use hkdf_key instead.\n * @param {Uint8Array} prk\n * @param {Uint8Array} info\n * @param {number} out_len\n * @returns {Uint8Array}\n */\nexport function hkdf_expand(prk, info, out_len) {\n const ptr0 = passArray8ToWasm0(prk, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.hkdf_expand(ptr0, len0, ptr1, len1, out_len);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Generates a pseudorandom key for use with hkdf_expand from an input secret\n * and an optional independent salt.\n *\n * Only use this function if you need to reuse the extracted key with multiple\n * expand invocations and different context values. Most common scenarios,\n * including the generation of multiple keys, should use hkdf_key instead.\n * @param {Uint8Array} secret\n * @param {Uint8Array} salt\n * @returns {Uint8Array}\n */\nexport function hkdf_extract(secret, salt) {\n const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.hkdf_extract(ptr0, len0, ptr1, len1);\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Derives a key from the secret, salt, and info using HKDF-SHA256, returning a\n * byte array that can be used as a cryptographic key.\n *\n * Panics if out_len exceeds the maximum output length for SHA-256 HKDF, which is\n * 255 * 32 = 8160 bytes.\n * @param {Uint8Array} secret\n * @param {Uint8Array} salt\n * @param {Uint8Array} info\n * @param {number} out_len\n * @returns {Uint8Array}\n */\nexport function hkdf_key(secret, salt, info, out_len) {\n const ptr0 = passArray8ToWasm0(secret, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.hkdf_key(ptr0, len0, ptr1, len1, ptr2, len2, out_len);\n var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v4;\n}\n\n/**\n * Generates an arbitrarily large buffer filled with randomness.\n * @param {number} bytes\n * @returns {Uint8Array}\n */\nexport function rand_generate(bytes) {\n const ret = wasm.rand_generate(bytes);\n var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v1;\n}\n\n/**\n * Computes the fingerprint (SHA-256 hash) of a public key.\n * @param {Uint8Array} public_key\n * @returns {Uint8Array}\n */\nexport function xdsa_fingerprint(public_key) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_fingerprint(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of a key fingerprint in bytes.\n * @returns {number}\n */\nexport function xdsa_fingerprint_size() {\n const ret = wasm.xdsa_fingerprint_size();\n return ret >>> 0;\n}\n\n/**\n * Generates a new random private key.\n * @returns {Uint8Array}\n */\nexport function xdsa_generate() {\n const ret = wasm.xdsa_generate();\n var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v1;\n}\n\n/**\n * Derives the public key from a secret key.\n * @param {Uint8Array} secret_key\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key(secret_key) {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Parses a public key from a DER-encoded X.509 certificate, verifying the signature.\n * Returns: public key (1984 bytes) || not_before (8 bytes BE) || not_after (8 bytes BE)\n * @param {Uint8Array} der\n * @param {Uint8Array} signer\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key_from_cert_der(der, signer) {\n const ptr0 = passArray8ToWasm0(der, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_from_cert_der(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Parses a public key from a PEM-encoded X.509 certificate, verifying the signature.\n * Returns: public key (1984 bytes) || not_before (8 bytes BE) || not_after (8 bytes BE)\n * @param {string} pem\n * @param {Uint8Array} signer\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key_from_cert_pem(pem, signer) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_from_cert_pem(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Parses a public key from PEM format.\n * @param {string} pem\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key_from_pem(pem) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_from_pem(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the public key in bytes.\n * Format: ML-DSA (1952 bytes) || Ed25519 (32 bytes)\n * @returns {number}\n */\nexport function xdsa_public_key_size() {\n const ret = wasm.xdsa_public_key_size();\n return ret >>> 0;\n}\n\n/**\n * Generates a DER-encoded X.509 certificate for a public key, signed by an issuer.\n * @param {Uint8Array} public_key\n * @param {Uint8Array} signer\n * @param {string} subject_name\n * @param {string} issuer_name\n * @param {bigint} not_before\n * @param {bigint} not_after\n * @param {boolean} is_ca\n * @param {number | null} [path_len]\n * @returns {Uint8Array}\n */\nexport function xdsa_public_key_to_cert_der(public_key, signer, subject_name, issuer_name, not_before, not_after, is_ca, path_len) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(subject_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(issuer_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_to_cert_der(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, not_before, not_after, is_ca, isLikeNone(path_len) ? 0xFFFFFF : path_len);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Generates a PEM-encoded X.509 certificate for a public key, signed by an issuer.\n * @param {Uint8Array} public_key\n * @param {Uint8Array} signer\n * @param {string} subject_name\n * @param {string} issuer_name\n * @param {bigint} not_before\n * @param {bigint} not_after\n * @param {boolean} is_ca\n * @param {number | null} [path_len]\n * @returns {string}\n */\nexport function xdsa_public_key_to_cert_pem(public_key, signer, subject_name, issuer_name, not_before, not_after, is_ca, path_len) {\n let deferred6_0;\n let deferred6_1;\n try {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(subject_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(issuer_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_to_cert_pem(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, not_before, not_after, is_ca, isLikeNone(path_len) ? 0xFFFFFF : path_len);\n var ptr5 = ret[0];\n var len5 = ret[1];\n if (ret[3]) {\n ptr5 = 0; len5 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred6_0 = ptr5;\n deferred6_1 = len5;\n return getStringFromWasm0(ptr5, len5);\n } finally {\n wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);\n }\n}\n\n/**\n * Serializes a public key to PEM format.\n * @param {Uint8Array} public_key\n * @returns {string}\n */\nexport function xdsa_public_key_to_pem(public_key) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_public_key_to_pem(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Parses a secret key from PEM format.\n * @param {string} pem\n * @returns {Uint8Array}\n */\nexport function xdsa_secret_key_from_pem(pem) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_secret_key_from_pem(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the secret key in bytes.\n * Format: ML-DSA seed (32 bytes) || Ed25519 seed (32 bytes)\n * @returns {number}\n */\nexport function xdsa_secret_key_size() {\n const ret = wasm.xdsa_secret_key_size();\n return ret >>> 0;\n}\n\n/**\n * Serializes a secret key to PEM format.\n * @param {Uint8Array} secret_key\n * @returns {string}\n */\nexport function xdsa_secret_key_to_pem(secret_key) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_secret_key_to_pem(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Signs a message with a secret key.\n * @param {Uint8Array} secret_key\n * @param {Uint8Array} message\n * @returns {Uint8Array}\n */\nexport function xdsa_sign(secret_key, message) {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_sign(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Size of a composite signature in bytes.\n * Format: ML-DSA (3309 bytes) || Ed25519 (64 bytes)\n * @returns {number}\n */\nexport function xdsa_signature_size() {\n const ret = wasm.xdsa_signature_size();\n return ret >>> 0;\n}\n\n/**\n * Verifies a signature on a message with a public key.\n * @param {Uint8Array} public_key\n * @param {Uint8Array} message\n * @param {Uint8Array} signature\n * @returns {boolean}\n */\nexport function xdsa_verify(public_key, message, signature) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.xdsa_verify(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n}\n\n/**\n * Size of the encapsulated key in bytes.\n * @returns {number}\n */\nexport function xhpke_encap_key_size() {\n const ret = wasm.xhpke_encap_key_size();\n return ret >>> 0;\n}\n\n/**\n * Computes the fingerprint (SHA-256 hash) of a public key.\n * @param {Uint8Array} public_key\n * @returns {Uint8Array}\n */\nexport function xhpke_fingerprint(public_key) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_fingerprint(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the fingerprint in bytes.\n * @returns {number}\n */\nexport function xhpke_fingerprint_size() {\n const ret = wasm.xdsa_fingerprint_size();\n return ret >>> 0;\n}\n\n/**\n * Generates a new random private key.\n * @returns {Uint8Array}\n */\nexport function xhpke_generate() {\n const ret = wasm.xhpke_generate();\n var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v1;\n}\n\n/**\n * Opens (decrypts) a sealed message with a secret key.\n * Input: encapsulated key (1120 bytes) || ciphertext\n * @param {Uint8Array} secret_key\n * @param {Uint8Array} sealed\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function xhpke_open(secret_key, sealed, msg_to_auth, domain) {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(sealed, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_open(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Derives the public key from a secret key.\n * @param {Uint8Array} secret_key\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key(secret_key) {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Parses a public key from a DER-encoded X.509 certificate, verifying the signature.\n * Returns: public key (1216 bytes) || not_before (8 bytes BE) || not_after (8 bytes BE)\n * @param {Uint8Array} der\n * @param {Uint8Array} signer\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key_from_cert_der(der, signer) {\n const ptr0 = passArray8ToWasm0(der, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_from_cert_der(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Parses a public key from a PEM-encoded X.509 certificate, verifying the signature.\n * Returns: public key (1216 bytes) || not_before (8 bytes BE) || not_after (8 bytes BE)\n * @param {string} pem\n * @param {Uint8Array} signer\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key_from_cert_pem(pem, signer) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_from_cert_pem(ptr0, len0, ptr1, len1);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v3;\n}\n\n/**\n * Parses a public key from PEM format.\n * @param {string} pem\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key_from_pem(pem) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_from_pem(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the public key in bytes.\n * @returns {number}\n */\nexport function xhpke_public_key_size() {\n const ret = wasm.xhpke_public_key_size();\n return ret >>> 0;\n}\n\n/**\n * Generates a DER-encoded X.509 certificate for a public key, signed by an xDSA issuer.\n * Note: HPKE certificates are always end-entity certificates (is_ca is ignored).\n * @param {Uint8Array} public_key\n * @param {Uint8Array} signer\n * @param {string} subject_name\n * @param {string} issuer_name\n * @param {bigint} not_before\n * @param {bigint} not_after\n * @returns {Uint8Array}\n */\nexport function xhpke_public_key_to_cert_der(public_key, signer, subject_name, issuer_name, not_before, not_after) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(subject_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(issuer_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_to_cert_der(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, not_before, not_after);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Generates a PEM-encoded X.509 certificate for a public key, signed by an xDSA issuer.\n * Note: HPKE certificates are always end-entity certificates (is_ca is ignored).\n * @param {Uint8Array} public_key\n * @param {Uint8Array} signer\n * @param {string} subject_name\n * @param {string} issuer_name\n * @param {bigint} not_before\n * @param {bigint} not_after\n * @returns {string}\n */\nexport function xhpke_public_key_to_cert_pem(public_key, signer, subject_name, issuer_name, not_before, not_after) {\n let deferred6_0;\n let deferred6_1;\n try {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(signer, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(subject_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passStringToWasm0(issuer_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_to_cert_pem(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, not_before, not_after);\n var ptr5 = ret[0];\n var len5 = ret[1];\n if (ret[3]) {\n ptr5 = 0; len5 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred6_0 = ptr5;\n deferred6_1 = len5;\n return getStringFromWasm0(ptr5, len5);\n } finally {\n wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);\n }\n}\n\n/**\n * Serializes a public key to PEM format.\n * @param {Uint8Array} public_key\n * @returns {string}\n */\nexport function xhpke_public_key_to_pem(public_key) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_public_key_to_pem(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Seals (encrypts) a message to a public key.\n * Returns: encapsulated key (1120 bytes) || ciphertext\n * @param {Uint8Array} public_key\n * @param {Uint8Array} msg_to_seal\n * @param {Uint8Array} msg_to_auth\n * @param {Uint8Array} domain\n * @returns {Uint8Array}\n */\nexport function xhpke_seal(public_key, msg_to_seal, msg_to_auth, domain) {\n const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(msg_to_seal, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passArray8ToWasm0(msg_to_auth, wasm.__wbindgen_malloc);\n const len2 = WASM_VECTOR_LEN;\n const ptr3 = passArray8ToWasm0(domain, wasm.__wbindgen_malloc);\n const len3 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_seal(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v5;\n}\n\n/**\n * Parses a secret key from PEM format.\n * @param {string} pem\n * @returns {Uint8Array}\n */\nexport function xhpke_secret_key_from_pem(pem) {\n const ptr0 = passStringToWasm0(pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_secret_key_from_pem(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\n/**\n * Size of the secret key seed in bytes.\n * @returns {number}\n */\nexport function xhpke_secret_key_size() {\n const ret = wasm.xdsa_fingerprint_size();\n return ret >>> 0;\n}\n\n/**\n * Serializes a secret key to PEM format.\n * @param {Uint8Array} secret_key\n * @returns {string}\n */\nexport function xhpke_secret_key_to_pem(secret_key) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.xhpke_secret_key_to_pem(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {\n const ret = typeof(arg0) === 'function';\n return ret;\n },\n __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {\n const val = arg0;\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n },\n __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {\n const ret = typeof(arg0) === 'string';\n return ret;\n },\n __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {\n const ret = arg0 === undefined;\n return ret;\n },\n __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {\n const ret = arg0.call(arg1);\n return ret;\n }, arguments); },\n __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.call(arg1, arg2);\n return ret;\n }, arguments); },\n __wbg_crypto_86f2631e91b51511: function(arg0) {\n const ret = arg0.crypto;\n return ret;\n },\n __wbg_getRandomValues_1c61fac11405ffdc: function() { return handleError(function (arg0, arg1) {\n globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));\n }, arguments); },\n __wbg_getRandomValues_2a91986308c74a93: function() { return handleError(function (arg0, arg1) {\n globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));\n }, arguments); },\n __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {\n arg0.getRandomValues(arg1);\n }, arguments); },\n __wbg_length_32ed9a279acd054c: function(arg0) {\n const ret = arg0.length;\n return ret;\n },\n __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {\n const ret = arg0.msCrypto;\n return ret;\n },\n __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {\n const ret = new Function(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {\n const ret = new Uint8Array(arg0 >>> 0);\n return ret;\n },\n __wbg_node_e1f24f89a7336c2e: function(arg0) {\n const ret = arg0.node;\n return ret;\n },\n __wbg_now_a3af9a2f4bbaa4d1: function() {\n const ret = Date.now();\n return ret;\n },\n __wbg_process_3975fd6c72f520aa: function(arg0) {\n const ret = arg0.process;\n return ret;\n },\n __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {\n Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);\n },\n __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {\n arg0.randomFillSync(arg1);\n }, arguments); },\n __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {\n const ret = module.require;\n return ret;\n }, arguments); },\n __wbg_static_accessor_GLOBAL_12837167ad935116: function() {\n const ret = typeof global === 'undefined' ? null : global;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {\n const ret = typeof globalThis === 'undefined' ? null : globalThis;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {\n const ret = typeof self === 'undefined' ? null : self;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {\n const ret = typeof window === 'undefined' ? null : window;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {\n const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);\n return ret;\n },\n __wbg_versions_4e31226f5e8dc909: function(arg0) {\n const ret = arg0.versions;\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0, arg1) {\n // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref(\"Uint8Array\")`.\n const ret = getArrayU8FromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_cast_0000000000000002: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./darkbio_crypto_wasm_bg.js\": import0,\n };\n}\n\nfunction addToExternrefTable0(obj) {\n const idx = wasm.__externref_table_alloc();\n wasm.__wbindgen_externrefs.set(idx, obj);\n return idx;\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n const idx = addToExternrefTable0(e);\n wasm.__wbindgen_exn_store(idx);\n }\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('darkbio_crypto_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, { rand_generate } from \"./wasm/darkbio_crypto_wasm.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/**\n * Generate cryptographically secure random bytes.\n *\n * @param bytes - Number of random bytes to generate\n * @returns A Uint8Array containing the random bytes\n */\nexport async function generate(bytes: number): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(rand_generate(bytes));\n}\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, {\n hkdf_key,\n hkdf_extract,\n hkdf_expand,\n} from \"./wasm/darkbio_crypto_wasm.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/**\n * Derive a key from secret, salt, and info using HKDF-SHA256.\n *\n * @param secret - The input keying material\n * @param salt - Optional salt value (can be empty)\n * @param info - Optional context/application-specific info (can be empty)\n * @param outLen - Desired output length in bytes (max 8160)\n * @returns The derived key\n */\nexport async function key(\n secret: Uint8Array,\n salt: Uint8Array,\n info: Uint8Array,\n outLen: number,\n): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(hkdf_key(secret, salt, info, outLen));\n}\n\n/**\n * Extract a pseudorandom key from secret and salt using HKDF-SHA256.\n *\n * Only use this if you need to reuse the extracted key with multiple\n * expand invocations. Most scenarios should use `key` instead.\n *\n * @param secret - The input keying material\n * @param salt - Optional salt value (can be empty)\n * @returns A 32-byte pseudorandom key\n */\nexport async function extract(\n secret: Uint8Array,\n salt: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(hkdf_extract(secret, salt));\n}\n\n/**\n * Expand a pseudorandom key with info using HKDF-SHA256.\n *\n * The prk should have been generated by `extract` or be a uniformly\n * random 32-byte key.\n *\n * @param prk - A 32-byte pseudorandom key\n * @param info - Optional context/application-specific info (can be empty)\n * @param outLen - Desired output length in bytes (max 8160)\n * @returns The derived key\n */\nexport async function expand(\n prk: Uint8Array,\n info: Uint8Array,\n outLen: number,\n): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(hkdf_expand(prk, info, outLen));\n}\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, { argon2_key } from \"./wasm/darkbio_crypto_wasm.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/**\n * Derive a key from password, salt, and cost parameters using Argon2id.\n *\n * RFC 9106 Section 7.4 recommends time=1, memory=2048*1024 (2GB) as sensible\n * defaults. If that much memory isn't available, increase time to compensate.\n *\n * @param password - The password to derive from\n * @param salt - A random salt (should be at least 16 bytes)\n * @param time - Number of passes over memory (iterations)\n * @param memory - Memory size in KiB\n * @param threads - Degree of parallelism\n * @param outLen - Desired output length in bytes\n * @returns The derived key\n */\nexport async function key(\n password: Uint8Array,\n salt: Uint8Array,\n time: number,\n memory: number,\n threads: number,\n outLen: number,\n): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(\n argon2_key(password, salt, time, memory, threads, outLen),\n );\n}\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, {\n xdsa_secret_key_size,\n xdsa_public_key_size,\n xdsa_signature_size,\n xdsa_fingerprint_size,\n xdsa_generate,\n xdsa_public_key,\n xdsa_fingerprint,\n xdsa_sign,\n xdsa_verify,\n xdsa_secret_key_from_pem,\n xdsa_secret_key_to_pem,\n xdsa_public_key_from_pem,\n xdsa_public_key_to_pem,\n xdsa_public_key_from_cert_pem,\n xdsa_public_key_from_cert_der,\n xdsa_public_key_to_cert_pem,\n xdsa_public_key_to_cert_der,\n} from \"./wasm/darkbio_crypto_wasm.js\";\n\nimport type { Params } from \"./x509.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/** Size of the secret key in bytes (64). */\nexport const SECRET_KEY_SIZE = 64;\n\n/** Size of the public key in bytes (1984). */\nexport const PUBLIC_KEY_SIZE = 1984;\n\n/** Size of a signature in bytes (3373). */\nexport const SIGNATURE_SIZE = 3373;\n\n/** Size of a fingerprint in bytes (32). */\nexport const FINGERPRINT_SIZE = 32;\n\n/**\n * Get the size constants (requires WASM initialization).\n */\nexport async function sizes(): Promise<{\n secretKey: number;\n publicKey: number;\n signature: number;\n fingerprint: number;\n}> {\n await ensureInit();\n return {\n secretKey: xdsa_secret_key_size(),\n publicKey: xdsa_public_key_size(),\n signature: xdsa_signature_size(),\n fingerprint: xdsa_fingerprint_size(),\n };\n}\n\n/**\n * Fingerprint is a 32-byte unique identifier for an xDSA key.\n */\nexport class Fingerprint {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Converts a 32-byte array into a fingerprint. */\n static fromBytes(bytes: Uint8Array): Fingerprint {\n if (bytes.length !== FINGERPRINT_SIZE) {\n throw new Error(`Fingerprint must be ${FINGERPRINT_SIZE} bytes`);\n }\n return new Fingerprint(new Uint8Array(bytes));\n }\n\n /** Converts a fingerprint into a 32-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n}\n\n/**\n * Signature is a 3373-byte xDSA signature.\n * Format: ML-DSA (3309 bytes) || Ed25519 (64 bytes)\n */\nexport class Signature {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Converts a 3373-byte array into a signature. */\n static fromBytes(bytes: Uint8Array): Signature {\n if (bytes.length !== SIGNATURE_SIZE) {\n throw new Error(`Signature must be ${SIGNATURE_SIZE} bytes`);\n }\n return new Signature(new Uint8Array(bytes));\n }\n\n /** Converts a signature into a 3373-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n}\n\n/**\n * PublicKey is an ML-DSA-65 public key paired with an Ed25519 public key for\n * verifying quantum resistant digital signatures.\n * Format: ML-DSA (1952 bytes) || Ed25519 (32 bytes)\n */\nexport class PublicKey {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Converts a 1984-byte array into a public key. */\n static fromBytes(bytes: Uint8Array): PublicKey {\n if (bytes.length !== PUBLIC_KEY_SIZE) {\n throw new Error(`PublicKey must be ${PUBLIC_KEY_SIZE} bytes`);\n }\n return new PublicKey(new Uint8Array(bytes));\n }\n\n /** Parses a PEM string into a public key. */\n static async fromPem(pem: string): Promise<PublicKey> {\n await ensureInit();\n const bytes = new Uint8Array(xdsa_public_key_from_pem(pem));\n return new PublicKey(bytes);\n }\n\n /**\n * Parses a public key from a PEM-encoded X.509 certificate.\n * Verifies the certificate signature against the provided signer.\n *\n * @param pem - PEM-encoded X.509 certificate\n * @param signer - The xDSA public key that signed this certificate\n * @returns The parsed public key and validity period (notBefore, notAfter as Unix timestamps)\n */\n static async fromCertPem(\n pem: string,\n signer: PublicKey,\n ): Promise<{ key: PublicKey; notBefore: bigint; notAfter: bigint }> {\n await ensureInit();\n const result = new Uint8Array(\n xdsa_public_key_from_cert_pem(pem, signer.toBytes()),\n );\n const key = new PublicKey(result.slice(0, PUBLIC_KEY_SIZE));\n const view = new DataView(\n result.buffer,\n result.byteOffset + PUBLIC_KEY_SIZE,\n );\n const notBefore = view.getBigUint64(0, false);\n const notAfter = view.getBigUint64(8, false);\n return { key, notBefore, notAfter };\n }\n\n /**\n * Parses a public key from a DER-encoded X.509 certificate.\n * Verifies the certificate signature against the provided signer.\n *\n * @param der - DER-encoded X.509 certificate\n * @param signer - The xDSA public key that signed this certificate\n * @returns The parsed public key and validity period (notBefore, notAfter as Unix timestamps)\n */\n static async fromCertDer(\n der: Uint8Array,\n signer: PublicKey,\n ): Promise<{ key: PublicKey; notBefore: bigint; notAfter: bigint }> {\n await ensureInit();\n const result = new Uint8Array(\n xdsa_public_key_from_cert_der(der, signer.toBytes()),\n );\n const key = new PublicKey(result.slice(0, PUBLIC_KEY_SIZE));\n const view = new DataView(\n result.buffer,\n result.byteOffset + PUBLIC_KEY_SIZE,\n );\n const notBefore = view.getBigUint64(0, false);\n const notAfter = view.getBigUint64(8, false);\n return { key, notBefore, notAfter };\n }\n\n /** Converts a public key into a 1984-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n\n /** Serializes a public key into a PEM string. */\n async toPem(): Promise<string> {\n await ensureInit();\n return xdsa_public_key_to_pem(this.bytes);\n }\n\n /** Returns a 256-bit unique identifier for this key. */\n async fingerprint(): Promise<Fingerprint> {\n await ensureInit();\n const fp = new Uint8Array(xdsa_fingerprint(this.bytes));\n return Fingerprint.fromBytes(fp);\n }\n\n /** Verifies a digital signature of the message. */\n async verify(message: Uint8Array, signature: Signature): Promise<boolean> {\n await ensureInit();\n return xdsa_verify(this.bytes, message, signature.toBytes());\n }\n\n /**\n * Generates a PEM-encoded X.509 certificate for this public key.\n *\n * @param signer - The xDSA secret key to sign the certificate\n * @param params - Certificate parameters (subject, issuer, validity, etc.)\n * @returns PEM-encoded X.509 certificate\n */\n async toCertPem(signer: SecretKey, params: Params): Promise<string> {\n await ensureInit();\n return xdsa_public_key_to_cert_pem(\n this.bytes,\n signer.toBytes(),\n params.subjectName,\n params.issuerName,\n params.notBefore,\n params.notAfter,\n params.isCa ?? false,\n params.pathLen,\n );\n }\n\n /**\n * Generates a DER-encoded X.509 certificate for this public key.\n *\n * @param signer - The xDSA secret key to sign the certificate\n * @param params - Certificate parameters (subject, issuer, validity, etc.)\n * @returns DER-encoded X.509 certificate\n */\n async toCertDer(signer: SecretKey, params: Params): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(\n xdsa_public_key_to_cert_der(\n this.bytes,\n signer.toBytes(),\n params.subjectName,\n params.issuerName,\n params.notBefore,\n params.notAfter,\n params.isCa ?? false,\n params.pathLen,\n ),\n );\n }\n}\n\n/**\n * SecretKey is an ML-DSA-65 private key paired with an Ed25519 private key for\n * creating quantum resistant digital signatures.\n * Format: ML-DSA seed (32 bytes) || Ed25519 seed (32 bytes)\n */\nexport class SecretKey {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Creates a new, random private key. */\n static async generate(): Promise<SecretKey> {\n await ensureInit();\n const bytes = new Uint8Array(xdsa_generate());\n return new SecretKey(bytes);\n }\n\n /** Creates a private key from a 64-byte seed. */\n static fromBytes(bytes: Uint8Array): SecretKey {\n if (bytes.length !== SECRET_KEY_SIZE) {\n throw new Error(`SecretKey must be ${SECRET_KEY_SIZE} bytes`);\n }\n return new SecretKey(new Uint8Array(bytes));\n }\n\n /** Parses a PEM string into a private key. */\n static async fromPem(pem: string): Promise<SecretKey> {\n await ensureInit();\n const bytes = new Uint8Array(xdsa_secret_key_from_pem(pem));\n return new SecretKey(bytes);\n }\n\n /** Converts a secret key into a 64-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n\n /** Serializes a private key into a PEM string. */\n async toPem(): Promise<string> {\n await ensureInit();\n return xdsa_secret_key_to_pem(this.bytes);\n }\n\n /** Retrieves the public counterpart of the secret key. */\n async publicKey(): Promise<PublicKey> {\n await ensureInit();\n const pk = new Uint8Array(xdsa_public_key(this.bytes));\n return PublicKey.fromBytes(pk);\n }\n\n /** Returns a 256-bit unique identifier for this key. */\n async fingerprint(): Promise<Fingerprint> {\n const pk = await this.publicKey();\n return pk.fingerprint();\n }\n\n /** Creates a digital signature of the message. */\n async sign(message: Uint8Array): Promise<Signature> {\n await ensureInit();\n const sig = new Uint8Array(xdsa_sign(this.bytes, message));\n return Signature.fromBytes(sig);\n }\n}\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport init, {\n xhpke_secret_key_size,\n xhpke_public_key_size,\n xhpke_encap_key_size,\n xhpke_fingerprint_size,\n xhpke_generate,\n xhpke_public_key,\n xhpke_fingerprint,\n xhpke_seal,\n xhpke_open,\n xhpke_secret_key_from_pem,\n xhpke_secret_key_to_pem,\n xhpke_public_key_from_pem,\n xhpke_public_key_to_pem,\n xhpke_public_key_from_cert_pem,\n xhpke_public_key_from_cert_der,\n xhpke_public_key_to_cert_pem,\n xhpke_public_key_to_cert_der,\n} from \"./wasm/darkbio_crypto_wasm.js\";\n\nimport {\n PublicKey as XdsaPublicKey,\n SecretKey as XdsaSecretKey,\n} from \"./xdsa.js\";\nimport type { Params } from \"./x509.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/** Size of the secret key seed in bytes (32). */\nexport const SECRET_KEY_SIZE = 32;\n\n/** Size of the public key in bytes (1216). */\nexport const PUBLIC_KEY_SIZE = 1216;\n\n/** Size of the encapsulated key in bytes (1120). */\nexport const ENCAP_KEY_SIZE = 1120;\n\n/** Size of a fingerprint in bytes (32). */\nexport const FINGERPRINT_SIZE = 32;\n\n/**\n * Get the size constants (requires WASM initialization).\n */\nexport async function sizes(): Promise<{\n secretKey: number;\n publicKey: number;\n encapKey: number;\n fingerprint: number;\n}> {\n await ensureInit();\n return {\n secretKey: xhpke_secret_key_size(),\n publicKey: xhpke_public_key_size(),\n encapKey: xhpke_encap_key_size(),\n fingerprint: xhpke_fingerprint_size(),\n };\n}\n\n/**\n * Fingerprint is a 32-byte unique identifier for an xHPKE key.\n * It is the SHA256 hash of the raw public key.\n */\nexport class Fingerprint {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Converts a 32-byte array into a fingerprint. */\n static fromBytes(bytes: Uint8Array): Fingerprint {\n if (bytes.length !== FINGERPRINT_SIZE) {\n throw new Error(`Fingerprint must be ${FINGERPRINT_SIZE} bytes`);\n }\n return new Fingerprint(new Uint8Array(bytes));\n }\n\n /** Converts a fingerprint into a 32-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n}\n\n/**\n * PublicKey contains an X-Wing public key for hybrid post-quantum encryption.\n * Uses X-Wing KEM (ML-KEM-768 + X25519) with HPKE Base mode.\n */\nexport class PublicKey {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /**\n * Converts a 1216-byte array into a public key.\n *\n * This validates the ML-KEM-768 component by checking that all polynomial\n * coefficients are in the valid range [0, 3329).\n */\n static fromBytes(bytes: Uint8Array): PublicKey {\n if (bytes.length !== PUBLIC_KEY_SIZE) {\n throw new Error(`PublicKey must be ${PUBLIC_KEY_SIZE} bytes`);\n }\n return new PublicKey(new Uint8Array(bytes));\n }\n\n /** Parses a PEM string into a public key. */\n static async fromPem(pem: string): Promise<PublicKey> {\n await ensureInit();\n const bytes = new Uint8Array(xhpke_public_key_from_pem(pem));\n return new PublicKey(bytes);\n }\n\n /**\n * Parses a public key from a PEM-encoded X.509 certificate.\n * Verifies the certificate signature against the provided xDSA signer.\n *\n * @param pem - PEM-encoded X.509 certificate\n * @param signer - The xDSA public key that signed this certificate\n * @returns The parsed public key and validity period (notBefore, notAfter as Unix timestamps)\n */\n static async fromCertPem(\n pem: string,\n signer: XdsaPublicKey,\n ): Promise<{ key: PublicKey; notBefore: bigint; notAfter: bigint }> {\n await ensureInit();\n const result = new Uint8Array(\n xhpke_public_key_from_cert_pem(pem, signer.toBytes()),\n );\n const key = new PublicKey(result.slice(0, PUBLIC_KEY_SIZE));\n const view = new DataView(\n result.buffer,\n result.byteOffset + PUBLIC_KEY_SIZE,\n );\n const notBefore = view.getBigUint64(0, false);\n const notAfter = view.getBigUint64(8, false);\n return { key, notBefore, notAfter };\n }\n\n /**\n * Parses a public key from a DER-encoded X.509 certificate.\n * Verifies the certificate signature against the provided xDSA signer.\n *\n * @param der - DER-encoded X.509 certificate\n * @param signer - The xDSA public key that signed this certificate\n * @returns The parsed public key and validity period (notBefore, notAfter as Unix timestamps)\n */\n static async fromCertDer(\n der: Uint8Array,\n signer: XdsaPublicKey,\n ): Promise<{ key: PublicKey; notBefore: bigint; notAfter: bigint }> {\n await ensureInit();\n const result = new Uint8Array(\n xhpke_public_key_from_cert_der(der, signer.toBytes()),\n );\n const key = new PublicKey(result.slice(0, PUBLIC_KEY_SIZE));\n const view = new DataView(\n result.buffer,\n result.byteOffset + PUBLIC_KEY_SIZE,\n );\n const notBefore = view.getBigUint64(0, false);\n const notAfter = view.getBigUint64(8, false);\n return { key, notBefore, notAfter };\n }\n\n /** Converts a public key into a 1216-byte array. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n\n /** Serializes a public key into a PEM string. */\n async toPem(): Promise<string> {\n await ensureInit();\n return xhpke_public_key_to_pem(this.bytes);\n }\n\n /** Returns a 256-bit unique identifier for this key (SHA256 of raw public key). */\n async fingerprint(): Promise<Fingerprint> {\n await ensureInit();\n const fp = new Uint8Array(xhpke_fingerprint(this.bytes));\n return Fingerprint.fromBytes(fp);\n }\n\n /**\n * Seal (encrypt) a message to this public key.\n *\n * Uses X-Wing KEM (ML-KEM-768 + X25519) with HPKE Base mode.\n *\n * @param msgToSeal - The message to encrypt\n * @param msgToAuth - Additional data to authenticate (but not encrypt)\n * @param domain - Application domain for context separation\n * @returns Sealed data (encapsulated key + ciphertext)\n */\n async seal(\n msgToSeal: Uint8Array,\n msgToAuth: Uint8Array,\n domain: Uint8Array,\n ): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(xhpke_seal(this.bytes, msgToSeal, msgToAuth, domain));\n }\n\n /**\n * Generates a PEM-encoded X.509 certificate for this public key.\n * Note: HPKE certificates are always end-entity certificates.\n *\n * @param signer - The xDSA secret key to sign the certificate\n * @param params - Certificate parameters (subject, issuer, validity)\n * @returns PEM-encoded X.509 certificate\n */\n async toCertPem(signer: XdsaSecretKey, params: Params): Promise<string> {\n await ensureInit();\n return xhpke_public_key_to_cert_pem(\n this.bytes,\n signer.toBytes(),\n params.subjectName,\n params.issuerName,\n params.notBefore,\n params.notAfter,\n );\n }\n\n /**\n * Generates a DER-encoded X.509 certificate for this public key.\n * Note: HPKE certificates are always end-entity certificates.\n *\n * @param signer - The xDSA secret key to sign the certificate\n * @param params - Certificate parameters (subject, issuer, validity)\n * @returns DER-encoded X.509 certificate\n */\n async toCertDer(signer: XdsaSecretKey, params: Params): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(\n xhpke_public_key_to_cert_der(\n this.bytes,\n signer.toBytes(),\n params.subjectName,\n params.issuerName,\n params.notBefore,\n params.notAfter,\n ),\n );\n }\n}\n\n/**\n * SecretKey contains an X-Wing private key for hybrid post-quantum encryption.\n * Uses X-Wing KEM (ML-KEM-768 + X25519) with HPKE Base mode.\n */\nexport class SecretKey {\n private readonly bytes: Uint8Array;\n\n private constructor(bytes: Uint8Array) {\n this.bytes = bytes;\n }\n\n /** Creates a new, random private key. */\n static async generate(): Promise<SecretKey> {\n await ensureInit();\n const bytes = new Uint8Array(xhpke_generate());\n return new SecretKey(bytes);\n }\n\n /** Converts a 32-byte seed into a private key. */\n static fromBytes(bytes: Uint8Array): SecretKey {\n if (bytes.length !== SECRET_KEY_SIZE) {\n throw new Error(`SecretKey must be ${SECRET_KEY_SIZE} bytes`);\n }\n return new SecretKey(new Uint8Array(bytes));\n }\n\n /** Parses a PEM string into a private key. */\n static async fromPem(pem: string): Promise<SecretKey> {\n await ensureInit();\n const bytes = new Uint8Array(xhpke_secret_key_from_pem(pem));\n return new SecretKey(bytes);\n }\n\n /** Converts a private key into a 32-byte seed. */\n toBytes(): Uint8Array {\n return new Uint8Array(this.bytes);\n }\n\n /** Serializes a private key into a PEM string. */\n async toPem(): Promise<string> {\n await ensureInit();\n return xhpke_secret_key_to_pem(this.bytes);\n }\n\n /** Retrieves the public counterpart of the secret key. */\n async publicKey(): Promise<PublicKey> {\n await ensureInit();\n const pk = new Uint8Array(xhpke_public_key(this.bytes));\n return PublicKey.fromBytes(pk);\n }\n\n /** Returns a 256-bit unique identifier for this key (SHA256 of raw public key). */\n async fingerprint(): Promise<Fingerprint> {\n const pk = await this.publicKey();\n return pk.fingerprint();\n }\n\n /**\n * Open (decrypt) a sealed message with this secret key.\n *\n * Deconstructs the encapsulated key and ciphertext, verifying the\n * authenticity of the (unencrypted) message-to-auth.\n *\n * Note: X-Wing uses Base mode (no sender authentication). The sender's\n * identity cannot be verified from the ciphertext alone.\n *\n * @param sealed - The sealed data from `seal()`\n * @param msgToAuth - The same additional authenticated data used during sealing\n * @param domain - The same application domain used during sealing\n * @returns The decrypted message\n * @throws If decryption fails (wrong key, tampered data, or wrong AAD/domain)\n */\n async open(\n sealed: Uint8Array,\n msgToAuth: Uint8Array,\n domain: Uint8Array,\n ): Promise<Uint8Array> {\n await ensureInit();\n return new Uint8Array(xhpke_open(this.bytes, sealed, msgToAuth, domain));\n }\n}\n","// This is an unfortunate replacement for @sindresorhus/is that we need to\n// re-implement for performance purposes. In particular the is.observable()\n// check is expensive, and unnecessary for our purposes. The values returned\n// are compatible with @sindresorhus/is, however.\n\n// Types that reach getObjectType() - excludes types with fast-paths above:\n// primitives (typeof), Array (isArray), Uint8Array (instanceof), plain Object (constructor)\nconst objectTypeNames = [\n 'Object', // for Object.create(null) and other non-plain objects\n 'RegExp',\n 'Date',\n 'Error',\n 'Map',\n 'Set',\n 'WeakMap',\n 'WeakSet',\n 'ArrayBuffer',\n 'SharedArrayBuffer',\n 'DataView',\n 'Promise',\n 'URL',\n 'HTMLElement',\n 'Int8Array',\n 'Uint8ClampedArray',\n 'Int16Array',\n 'Uint16Array',\n 'Int32Array',\n 'Uint32Array',\n 'Float32Array',\n 'Float64Array',\n 'BigInt64Array',\n 'BigUint64Array'\n]\n\n/**\n * @param {any} value\n * @returns {string}\n */\nexport function is (value) {\n if (value === null) {\n return 'null'\n }\n if (value === undefined) {\n return 'undefined'\n }\n if (value === true || value === false) {\n return 'boolean'\n }\n const typeOf = typeof value\n if (typeOf === 'string' || typeOf === 'number' || typeOf === 'bigint' || typeOf === 'symbol') {\n return typeOf\n }\n /* c8 ignore next 3 */\n if (typeOf === 'function') {\n return 'Function'\n }\n if (Array.isArray(value)) {\n return 'Array'\n }\n // Also catches Node.js Buffer which extends Uint8Array\n if (value instanceof Uint8Array) {\n return 'Uint8Array'\n }\n // Fast path for plain objects (most common case after primitives/arrays/bytes)\n if (value.constructor === Object) {\n return 'Object'\n }\n const objectType = getObjectType(value)\n if (objectType) {\n return objectType\n }\n /* c8 ignore next */\n return 'Object'\n}\n\n/**\n * @param {any} value\n * @returns {string|undefined}\n */\nfunction getObjectType (value) {\n const objectTypeName = Object.prototype.toString.call(value).slice(8, -1)\n if (objectTypeNames.includes(objectTypeName)) {\n return objectTypeName\n }\n /* c8 ignore next */\n return undefined\n}\n","class Type {\n /**\n * @param {number} major\n * @param {string} name\n * @param {boolean} terminal\n */\n constructor (major, name, terminal) {\n this.major = major\n this.majorEncoded = major << 5\n this.name = name\n this.terminal = terminal\n }\n\n /* c8 ignore next 3 */\n toString () {\n return `Type[${this.major}].${this.name}`\n }\n\n /**\n * @param {Type} typ\n * @returns {number}\n */\n compare (typ) {\n /* c8 ignore next 1 */\n return this.major < typ.major ? -1 : this.major > typ.major ? 1 : 0\n }\n\n /**\n * Check equality between two Type instances. Safe to use across different\n * copies of the Type class (e.g., when bundlers duplicate the module).\n * (major, name) uniquely identifies a Type; terminal is implied by these.\n * @param {Type} a\n * @param {Type} b\n * @returns {boolean}\n */\n static equals (a, b) {\n return a === b || (a.major === b.major && a.name === b.name)\n }\n}\n\n// convert to static fields when better supported\nType.uint = new Type(0, 'uint', true)\nType.negint = new Type(1, 'negint', true)\nType.bytes = new Type(2, 'bytes', true)\nType.string = new Type(3, 'string', true)\nType.array = new Type(4, 'array', false)\nType.map = new Type(5, 'map', false)\nType.tag = new Type(6, 'tag', false) // terminal?\nType.float = new Type(7, 'float', true)\nType.false = new Type(7, 'false', true)\nType.true = new Type(7, 'true', true)\nType.null = new Type(7, 'null', true)\nType.undefined = new Type(7, 'undefined', true)\nType.break = new Type(7, 'break', true)\n// Type.indefiniteLength = new Type(0, 'indefiniteLength', true)\n\nclass Token {\n /**\n * @param {Type} type\n * @param {any} [value]\n * @param {number} [encodedLength]\n */\n constructor (type, value, encodedLength) {\n this.type = type\n this.value = value\n this.encodedLength = encodedLength\n /** @type {Uint8Array|undefined} */\n this.encodedBytes = undefined\n /** @type {Uint8Array|undefined} */\n this.byteValue = undefined\n }\n\n /* c8 ignore next 3 */\n toString () {\n return `Token[${this.type}].${this.value}`\n }\n}\n\nexport { Type, Token }\n","// Use Uint8Array directly in the browser, use Buffer in Node.js but don't\n// speak its name directly to avoid bundlers pulling in the `Buffer` polyfill\n\n// @ts-ignore\nexport const useBuffer = globalThis.process &&\n // @ts-ignore\n !globalThis.process.browser &&\n // @ts-ignore\n globalThis.Buffer &&\n // @ts-ignore\n typeof globalThis.Buffer.isBuffer === 'function'\n\nconst textEncoder = new TextEncoder()\n\n/**\n * @param {Uint8Array} buf\n * @returns {boolean}\n */\nfunction isBuffer (buf) {\n // @ts-ignore\n return useBuffer && globalThis.Buffer.isBuffer(buf)\n}\n\n/**\n * @param {Uint8Array|number[]} buf\n * @returns {Uint8Array}\n */\nexport function asU8A (buf) {\n /* c8 ignore next */\n if (!(buf instanceof Uint8Array)) {\n return Uint8Array.from(buf)\n }\n return isBuffer(buf) ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : buf\n}\n\n// Threshold for manual UTF-8 encoding vs native methods.\n// Node.js Buffer.from: crossover ~24 chars\n// Browser TextEncoder: crossover ~200 chars\nconst FROM_STRING_THRESHOLD_BUFFER = 24\nconst FROM_STRING_THRESHOLD_TEXTENCODER = 200\n\nexport const fromString = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {string} string\n */\n (string) => {\n return string.length >= FROM_STRING_THRESHOLD_BUFFER\n ? // eslint-disable-line operator-linebreak\n // @ts-ignore\n globalThis.Buffer.from(string)\n : utf8ToBytes(string)\n }\n /* c8 ignore next 7 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {string} string\n */\n (string) => {\n return string.length >= FROM_STRING_THRESHOLD_TEXTENCODER ? textEncoder.encode(string) : utf8ToBytes(string)\n }\n\n/**\n * Buffer variant not fast enough for what we need\n * @param {number[]} arr\n * @returns {Uint8Array}\n */\nexport const fromArray = (arr) => {\n return Uint8Array.from(arr)\n}\n\nexport const slice = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array} bytes\n * @param {number} start\n * @param {number} end\n */\n // Buffer.slice() returns a view, not a copy, so we need special handling\n (bytes, start, end) => {\n if (isBuffer(bytes)) {\n return new Uint8Array(bytes.subarray(start, end))\n }\n return bytes.slice(start, end)\n }\n /* c8 ignore next 9 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array} bytes\n * @param {number} start\n * @param {number} end\n */\n (bytes, start, end) => {\n return bytes.slice(start, end)\n }\n\nexport const concat = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array[]} chunks\n * @param {number} length\n * @returns {Uint8Array}\n */\n (chunks, length) => {\n // might get a stray plain Array here\n /* c8 ignore next 1 */\n chunks = chunks.map((c) => c instanceof Uint8Array\n ? c\n // this case is occasionally missed during test runs so becomes coverage-flaky\n /* c8 ignore next 4 */\n : // eslint-disable-line operator-linebreak\n // @ts-ignore\n globalThis.Buffer.from(c))\n // @ts-ignore\n return asU8A(globalThis.Buffer.concat(chunks, length))\n }\n /* c8 ignore next 19 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array[]} chunks\n * @param {number} length\n * @returns {Uint8Array}\n */\n (chunks, length) => {\n const out = new Uint8Array(length)\n let off = 0\n for (let b of chunks) {\n if (off + b.length > out.length) {\n // final chunk that's bigger than we need\n b = b.subarray(0, out.length - off)\n }\n out.set(b, off)\n off += b.length\n }\n return out\n }\n\nexport const alloc = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {number} size\n * @returns {Uint8Array}\n */\n (size) => {\n // we always write over the contents we expose so this should be safe\n // @ts-ignore\n return globalThis.Buffer.allocUnsafe(size)\n }\n /* c8 ignore next 8 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {number} size\n * @returns {Uint8Array}\n */\n (size) => {\n return new Uint8Array(size)\n }\n\nexport const toHex = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array} d\n * @returns {string}\n */\n (d) => {\n if (typeof d === 'string') {\n return d\n }\n // @ts-ignore\n return globalThis.Buffer.from(toBytes(d)).toString('hex')\n }\n /* c8 ignore next 12 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {Uint8Array} d\n * @returns {string}\n */\n (d) => {\n if (typeof d === 'string') {\n return d\n }\n // @ts-ignore not smart enough to figure this out\n return Array.prototype.reduce.call(toBytes(d), (p, c) => `${p}${c.toString(16).padStart(2, '0')}`, '')\n }\n\nexport const fromHex = useBuffer\n ? // eslint-disable-line operator-linebreak\n /**\n * @param {string|Uint8Array} hex\n * @returns {Uint8Array}\n */\n (hex) => {\n if (hex instanceof Uint8Array) {\n return hex\n }\n // @ts-ignore\n return globalThis.Buffer.from(hex, 'hex')\n }\n /* c8 ignore next 17 */\n : // eslint-disable-line operator-linebreak\n /**\n * @param {string|Uint8Array} hex\n * @returns {Uint8Array}\n */\n (hex) => {\n if (hex instanceof Uint8Array) {\n return hex\n }\n if (!hex.length) {\n return new Uint8Array(0)\n }\n return new Uint8Array(hex.split('')\n .map((/** @type {string} */ c, /** @type {number} */ i, /** @type {string[]} */ d) => i % 2 === 0 ? `0x${c}${d[i + 1]}` : '')\n .filter(Boolean)\n .map((/** @type {string} */ e) => parseInt(e, 16)))\n }\n\n/**\n * @param {Uint8Array|ArrayBuffer|ArrayBufferView} obj\n * @returns {Uint8Array}\n */\nfunction toBytes (obj) {\n if (obj instanceof Uint8Array && obj.constructor.name === 'Uint8Array') {\n return obj\n }\n if (obj instanceof ArrayBuffer) {\n return new Uint8Array(obj)\n }\n if (ArrayBuffer.isView(obj)) {\n return new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength)\n }\n /* c8 ignore next */\n throw new Error('Unknown type, must be binary type')\n}\n\n/**\n * @param {Uint8Array} b1\n * @param {Uint8Array} b2\n * @returns {number}\n */\nexport function compare (b1, b2) {\n /* c8 ignore next 5 */\n if (isBuffer(b1) && isBuffer(b2)) {\n // probably not possible to get here in the current API\n // @ts-ignore Buffer\n return b1.compare(b2)\n }\n for (let i = 0; i < b1.length; i++) {\n if (b1[i] === b2[i]) {\n continue\n }\n return b1[i] < b2[i] ? -1 : 1\n } /* c8 ignore next 3 */\n return 0\n}\n\n// The below code is taken from https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143\n// Licensed Apache-2.0.\n\n/**\n * @param {string} str\n * @returns {number[]}\n */\nfunction utf8ToBytes (str) {\n const out = []\n let p = 0\n for (let i = 0; i < str.length; i++) {\n let c = str.charCodeAt(i)\n if (c < 128) {\n out[p++] = c\n } else if (c < 2048) {\n out[p++] = (c >> 6) | 192\n out[p++] = (c & 63) | 128\n } else if (\n ((c & 0xFC00) === 0xD800) && (i + 1) < str.length &&\n ((str.charCodeAt(i + 1) & 0xFC00) === 0xDC00)) {\n // Surrogate Pair\n c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF)\n out[p++] = (c >> 18) | 240\n out[p++] = ((c >> 12) & 63) | 128\n out[p++] = ((c >> 6) & 63) | 128\n out[p++] = (c & 63) | 128\n } else {\n if ((c >= 0xD800) && (c <= 0xDFFF)) {\n c = 0xFFFD // Unpaired Surrogate\n }\n out[p++] = (c >> 12) | 224\n out[p++] = ((c >> 6) & 63) | 128\n out[p++] = (c & 63) | 128\n }\n }\n return out\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst MAX_ARGUMENTS_LENGTH = 0x1000\n\n/**\n * @param {number[]} codePoints\n * @returns {string}\n */\nexport function decodeCodePointsArray (codePoints) {\n const len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n /* c8 ignore next 10 */\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = ''\n let i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n","/**\n * Bl is a list of byte chunks, similar to https://github.com/rvagg/bl but for\n * writing rather than reading.\n * A Bl object accepts set() operations for individual bytes and copyTo() for\n * inserting byte arrays. These write operations don't automatically increment\n * the internal cursor so its \"length\" won't be changed. Instead, increment()\n * must be called to extend its length to cover the inserted data.\n * The toBytes() call will convert all internal memory to a single Uint8Array of\n * the correct length, truncating any data that is stored but hasn't been\n * included by an increment().\n * get() can retrieve a single byte.\n * All operations (except toBytes()) take an \"offset\" argument that will perform\n * the write at the offset _from the current cursor_. For most operations this\n * will be `0` to write at the current cursor position but it can be ahead of\n * the current cursor. Negative offsets probably work but are untested.\n */\n\n// TODO: ipjs doesn't support this, only for test files: https://github.com/mikeal/ipjs/blob/master/src/package/testFile.js#L39\nimport { alloc, concat, slice } from './byte-utils.js'\n\n// the ts-ignores in this file are almost all for the `Uint8Array|number[]` duality that exists\n// for perf reasons. Consider better approaches to this or removing it entirely, it is quite\n// risky because of some assumptions about small chunks === number[] and everything else === Uint8Array.\n\nconst defaultChunkSize = 256\n\nexport class Bl {\n /**\n * @param {number} [chunkSize]\n */\n constructor (chunkSize = defaultChunkSize) {\n this.chunkSize = chunkSize\n /** @type {number} */\n this.cursor = 0\n /** @type {number} */\n this.maxCursor = -1\n /** @type {(Uint8Array|number[])[]} */\n this.chunks = []\n // keep the first chunk around if we can to save allocations for future encodes\n /** @type {Uint8Array|number[]|null} */\n this._initReuseChunk = null\n }\n\n reset () {\n this.cursor = 0\n this.maxCursor = -1\n if (this.chunks.length) {\n this.chunks = []\n }\n if (this._initReuseChunk !== null) {\n this.chunks.push(this._initReuseChunk)\n this.maxCursor = this._initReuseChunk.length - 1\n }\n }\n\n /**\n * @param {Uint8Array|number[]} bytes\n */\n push (bytes) {\n let topChunk = this.chunks[this.chunks.length - 1]\n const newMax = this.cursor + bytes.length\n if (newMax <= this.maxCursor + 1) {\n // we have at least one chunk and we can fit these bytes into that chunk\n const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1\n // @ts-ignore\n topChunk.set(bytes, chunkPos)\n } else {\n // can't fit it in\n if (topChunk) {\n // trip the last chunk to `cursor` if we need to\n const chunkPos = topChunk.length - (this.maxCursor - this.cursor) - 1\n if (chunkPos < topChunk.length) {\n // @ts-ignore\n this.chunks[this.chunks.length - 1] = topChunk.subarray(0, chunkPos)\n this.maxCursor = this.cursor - 1\n }\n }\n if (bytes.length < 64 && bytes.length < this.chunkSize) {\n // make a new chunk and copy the new one into it\n topChunk = alloc(this.chunkSize)\n this.chunks.push(topChunk)\n this.maxCursor += topChunk.length\n if (this._initReuseChunk === null) {\n this._initReuseChunk = topChunk\n }\n // @ts-ignore\n topChunk.set(bytes, 0)\n } else {\n // push the new bytes in as its own chunk\n this.chunks.push(bytes)\n this.maxCursor += bytes.length\n }\n }\n this.cursor += bytes.length\n }\n\n /**\n * @param {boolean} [reset]\n * @returns {Uint8Array}\n */\n toBytes (reset = false) {\n let byts\n if (this.chunks.length === 1) {\n const chunk = this.chunks[0]\n if (reset && this.cursor > chunk.length / 2) {\n /* c8 ignore next 2 */\n // @ts-ignore\n byts = this.cursor === chunk.length ? chunk : chunk.subarray(0, this.cursor)\n this._initReuseChunk = null\n this.chunks = []\n } else {\n // @ts-ignore\n byts = slice(chunk, 0, this.cursor)\n }\n } else {\n // @ts-ignore\n byts = concat(this.chunks, this.cursor)\n }\n if (reset) {\n this.reset()\n }\n return byts\n }\n}\n\n/**\n * U8Bl is a buffer list that writes directly to a user-provided Uint8Array.\n * It provides the same interface as Bl but writes to a fixed destination.\n */\nexport class U8Bl {\n /**\n * @param {Uint8Array} dest\n */\n constructor (dest) {\n this.dest = dest\n /** @type {number} */\n this.cursor = 0\n // chunks is for interface compatibility with Bl - encode.js checks chunks.length\n // as a sanity check for pre-calculated sizes. For U8Bl this is always [dest].\n /** @type {Uint8Array[]} */\n this.chunks = [dest]\n }\n\n reset () {\n this.cursor = 0\n }\n\n /**\n * @param {Uint8Array|number[]} bytes\n */\n push (bytes) {\n if (this.cursor + bytes.length > this.dest.length) {\n throw new Error('write out of bounds, destination buffer is too small')\n }\n this.dest.set(bytes, this.cursor)\n this.cursor += bytes.length\n }\n\n /**\n * @param {boolean} [reset]\n * @returns {Uint8Array}\n */\n toBytes (reset = false) {\n const byts = this.dest.subarray(0, this.cursor)\n if (reset) {\n this.reset()\n }\n return byts\n }\n}\n","const decodeErrPrefix = 'CBOR decode error:'\nconst encodeErrPrefix = 'CBOR encode error:'\n\nconst uintMinorPrefixBytes = []\nuintMinorPrefixBytes[23] = 1\nuintMinorPrefixBytes[24] = 2\nuintMinorPrefixBytes[25] = 3\nuintMinorPrefixBytes[26] = 5\nuintMinorPrefixBytes[27] = 9\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} need\n */\nfunction assertEnoughData (data, pos, need) {\n if (data.length - pos < need) {\n throw new Error(`${decodeErrPrefix} not enough data for type`)\n }\n}\n\nexport {\n decodeErrPrefix,\n encodeErrPrefix,\n uintMinorPrefixBytes,\n assertEnoughData\n}\n","/* globals BigInt */\n\nimport { Token, Type } from './token.js'\nimport { decodeErrPrefix, assertEnoughData } from './common.js'\n\nexport const uintBoundaries = [24, 256, 65536, 4294967296, BigInt('18446744073709551616')]\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} data\n * @param {number} offset\n * @param {DecodeOptions} options\n * @returns {number}\n */\nexport function readUint8 (data, offset, options) {\n assertEnoughData(data, offset, 1)\n const value = data[offset]\n if (options.strict === true && value < uintBoundaries[0]) {\n throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)\n }\n return value\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} offset\n * @param {DecodeOptions} options\n * @returns {number}\n */\nexport function readUint16 (data, offset, options) {\n assertEnoughData(data, offset, 2)\n const value = (data[offset] << 8) | data[offset + 1]\n if (options.strict === true && value < uintBoundaries[1]) {\n throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)\n }\n return value\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} offset\n * @param {DecodeOptions} options\n * @returns {number}\n */\nexport function readUint32 (data, offset, options) {\n assertEnoughData(data, offset, 4)\n const value = (data[offset] * 16777216 /* 2 ** 24 */) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3]\n if (options.strict === true && value < uintBoundaries[2]) {\n throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)\n }\n return value\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} offset\n * @param {DecodeOptions} options\n * @returns {number|bigint}\n */\nexport function readUint64 (data, offset, options) {\n // assume BigInt, convert back to Number if within safe range\n assertEnoughData(data, offset, 8)\n const hi = (data[offset] * 16777216 /* 2 ** 24 */) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3]\n const lo = (data[offset + 4] * 16777216 /* 2 ** 24 */) + (data[offset + 5] << 16) + (data[offset + 6] << 8) + data[offset + 7]\n const value = (BigInt(hi) << BigInt(32)) + BigInt(lo)\n if (options.strict === true && value < uintBoundaries[3]) {\n throw new Error(`${decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)\n }\n if (value <= Number.MAX_SAFE_INTEGER) {\n return Number(value)\n }\n if (options.allowBigInt === true) {\n return value\n }\n throw new Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`)\n}\n\n/* not required thanks to quick[] list\nconst oneByteTokens = new Array(24).fill(0).map((v, i) => new Token(Type.uint, i, 1))\nexport function decodeUintCompact (data, pos, minor, options) {\n return oneByteTokens[minor]\n}\n*/\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUint8 (data, pos, _minor, options) {\n return new Token(Type.uint, readUint8(data, pos + 1, options), 2)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUint16 (data, pos, _minor, options) {\n return new Token(Type.uint, readUint16(data, pos + 1, options), 3)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUint32 (data, pos, _minor, options) {\n return new Token(Type.uint, readUint32(data, pos + 1, options), 5)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUint64 (data, pos, _minor, options) {\n return new Token(Type.uint, readUint64(data, pos + 1, options), 9)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeUint (writer, token) {\n return encodeUintValue(writer, 0, token.value)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {number} major\n * @param {number|bigint} uint\n */\nexport function encodeUintValue (writer, major, uint) {\n if (uint < uintBoundaries[0]) {\n const nuint = Number(uint)\n // pack into one byte, minor=0, additional=value\n writer.push([major | nuint])\n } else if (uint < uintBoundaries[1]) {\n const nuint = Number(uint)\n // pack into two byte, minor=0, additional=24\n writer.push([major | 24, nuint])\n } else if (uint < uintBoundaries[2]) {\n const nuint = Number(uint)\n // pack into three byte, minor=0, additional=25\n writer.push([major | 25, nuint >>> 8, nuint & 0xff])\n } else if (uint < uintBoundaries[3]) {\n const nuint = Number(uint)\n // pack into five byte, minor=0, additional=26\n writer.push([major | 26, (nuint >>> 24) & 0xff, (nuint >>> 16) & 0xff, (nuint >>> 8) & 0xff, nuint & 0xff])\n } else {\n const buint = BigInt(uint)\n if (buint < uintBoundaries[4]) {\n // pack into nine byte, minor=0, additional=27\n const set = [major | 27, 0, 0, 0, 0, 0, 0, 0]\n // simulate bitwise above 32 bits\n let lo = Number(buint & BigInt(0xffffffff))\n let hi = Number(buint >> BigInt(32) & BigInt(0xffffffff))\n set[8] = lo & 0xff\n lo = lo >> 8\n set[7] = lo & 0xff\n lo = lo >> 8\n set[6] = lo & 0xff\n lo = lo >> 8\n set[5] = lo & 0xff\n set[4] = hi & 0xff\n hi = hi >> 8\n set[3] = hi & 0xff\n hi = hi >> 8\n set[2] = hi & 0xff\n hi = hi >> 8\n set[1] = hi & 0xff\n writer.push(set)\n } else {\n throw new Error(`${decodeErrPrefix} encountered BigInt larger than allowable range`)\n }\n }\n}\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeUint.encodedSize = function encodedSize (token) {\n return encodeUintValue.encodedSize(token.value)\n}\n\n/**\n * @param {number} uint\n * @returns {number}\n */\nencodeUintValue.encodedSize = function encodedSize (uint) {\n if (uint < uintBoundaries[0]) {\n return 1\n }\n if (uint < uintBoundaries[1]) {\n return 2\n }\n if (uint < uintBoundaries[2]) {\n return 3\n }\n if (uint < uintBoundaries[3]) {\n return 5\n }\n return 9\n}\n\n/**\n * @param {Token} tok1\n * @param {Token} tok2\n * @returns {number}\n */\nencodeUint.compareTokens = function compareTokens (tok1, tok2) {\n return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : /* c8 ignore next */ 0\n}\n","/* eslint-env es2020 */\n\nimport { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\nimport { decodeErrPrefix } from './common.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeNegint8 (data, pos, _minor, options) {\n return new Token(Type.negint, -1 - uint.readUint8(data, pos + 1, options), 2)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeNegint16 (data, pos, _minor, options) {\n return new Token(Type.negint, -1 - uint.readUint16(data, pos + 1, options), 3)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeNegint32 (data, pos, _minor, options) {\n return new Token(Type.negint, -1 - uint.readUint32(data, pos + 1, options), 5)\n}\n\nconst neg1b = BigInt(-1)\nconst pos1b = BigInt(1)\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeNegint64 (data, pos, _minor, options) {\n const int = uint.readUint64(data, pos + 1, options)\n if (typeof int !== 'bigint') {\n const value = -1 - int\n if (value >= Number.MIN_SAFE_INTEGER) {\n return new Token(Type.negint, value, 9)\n }\n }\n if (options.allowBigInt !== true) {\n throw new Error(`${decodeErrPrefix} integers outside of the safe integer range are not supported`)\n }\n return new Token(Type.negint, neg1b - BigInt(int), 9)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeNegint (writer, token) {\n const negint = token.value\n const unsigned = (typeof negint === 'bigint' ? (negint * neg1b - pos1b) : (negint * -1 - 1))\n uint.encodeUintValue(writer, token.type.majorEncoded, unsigned)\n}\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeNegint.encodedSize = function encodedSize (token) {\n const negint = token.value\n const unsigned = (typeof negint === 'bigint' ? (negint * neg1b - pos1b) : (negint * -1 - 1))\n /* c8 ignore next 4 */\n // handled by quickEncode, we shouldn't get here but it's included for completeness\n if (unsigned < uint.uintBoundaries[0]) {\n return 1\n }\n if (unsigned < uint.uintBoundaries[1]) {\n return 2\n }\n if (unsigned < uint.uintBoundaries[2]) {\n return 3\n }\n if (unsigned < uint.uintBoundaries[3]) {\n return 5\n }\n return 9\n}\n\n/**\n * @param {Token} tok1\n * @param {Token} tok2\n * @returns {number}\n */\nencodeNegint.compareTokens = function compareTokens (tok1, tok2) {\n // opposite of the uint comparison since we store the uint version in bytes\n return tok1.value < tok2.value ? 1 : tok1.value > tok2.value ? -1 : /* c8 ignore next */ 0\n}\n","import { Token, Type } from './token.js'\nimport { assertEnoughData, decodeErrPrefix } from './common.js'\nimport * as uint from './0uint.js'\nimport { compare, fromString } from './byte-utils.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} prefix\n * @param {number} length\n * @returns {Token}\n */\nfunction toToken (data, pos, prefix, length) {\n assertEnoughData(data, pos, prefix + length)\n const buf = data.slice(pos + prefix, pos + prefix + length)\n return new Token(Type.bytes, buf, prefix + length)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n * @param {DecodeOptions} _options\n * @returns {Token}\n */\nexport function decodeBytesCompact (data, pos, minor, _options) {\n return toToken(data, pos, 1, minor)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBytes8 (data, pos, _minor, options) {\n return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBytes16 (data, pos, _minor, options) {\n return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBytes32 (data, pos, _minor, options) {\n return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options))\n}\n\n// TODO: maybe we shouldn't support this ..\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBytes64 (data, pos, _minor, options) {\n const l = uint.readUint64(data, pos + 1, options)\n if (typeof l === 'bigint') {\n throw new Error(`${decodeErrPrefix} 64-bit integer bytes lengths not supported`)\n }\n return toToken(data, pos, 9, l)\n}\n\n/**\n * `encodedBytes` allows for caching when we do a byte version of a string\n * for key sorting purposes\n * @param {Token} token\n * @returns {Uint8Array}\n */\nfunction tokenBytes (token) {\n if (token.encodedBytes === undefined) {\n token.encodedBytes = Type.equals(token.type, Type.string) ? fromString(token.value) : token.value\n }\n // @ts-ignore c'mon\n return token.encodedBytes\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeBytes (writer, token) {\n const bytes = tokenBytes(token)\n uint.encodeUintValue(writer, token.type.majorEncoded, bytes.length)\n writer.push(bytes)\n}\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeBytes.encodedSize = function encodedSize (token) {\n const bytes = tokenBytes(token)\n return uint.encodeUintValue.encodedSize(bytes.length) + bytes.length\n}\n\n/**\n * @param {Token} tok1\n * @param {Token} tok2\n * @returns {number}\n */\nencodeBytes.compareTokens = function compareTokens (tok1, tok2) {\n return compareBytes(tokenBytes(tok1), tokenBytes(tok2))\n}\n\n/**\n * @param {Uint8Array} b1\n * @param {Uint8Array} b2\n * @returns {number}\n */\nexport function compareBytes (b1, b2) {\n return b1.length < b2.length ? -1 : b1.length > b2.length ? 1 : compare(b1, b2)\n}\n","import { Token, Type } from './token.js'\nimport { assertEnoughData, decodeErrPrefix } from './common.js'\nimport * as uint from './0uint.js'\nimport { encodeBytes } from './2bytes.js'\n\nconst textDecoder = new TextDecoder()\n\n// Threshold for ASCII fast-path vs TextDecoder. Short ASCII strings (common for\n// map keys) are faster to decode with a simple loop than TextDecoder overhead.\nconst ASCII_THRESHOLD = 32\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * Decode UTF-8 bytes to string. For short ASCII strings (common case for map keys),\n * a simple loop is faster than TextDecoder.\n * @param {Uint8Array} bytes\n * @param {number} start\n * @param {number} end\n * @returns {string}\n */\nfunction toStr (bytes, start, end) {\n const len = end - start\n if (len < ASCII_THRESHOLD) {\n let str = ''\n for (let i = start; i < end; i++) {\n const c = bytes[i]\n if (c & 0x80) { // non-ASCII, fall back to TextDecoder\n return textDecoder.decode(bytes.subarray(start, end))\n }\n str += String.fromCharCode(c)\n }\n return str\n }\n return textDecoder.decode(bytes.subarray(start, end))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} prefix\n * @param {number} length\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nfunction toToken (data, pos, prefix, length, options) {\n const totLength = prefix + length\n assertEnoughData(data, pos, totLength)\n const tok = new Token(Type.string, toStr(data, pos + prefix, pos + totLength), totLength)\n if (options.retainStringBytes === true) {\n tok.byteValue = data.slice(pos + prefix, pos + totLength)\n }\n return tok\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeStringCompact (data, pos, minor, options) {\n return toToken(data, pos, 1, minor, options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeString8 (data, pos, _minor, options) {\n return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options), options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeString16 (data, pos, _minor, options) {\n return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options), options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeString32 (data, pos, _minor, options) {\n return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options), options)\n}\n\n// TODO: maybe we shouldn't support this ..\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeString64 (data, pos, _minor, options) {\n const l = uint.readUint64(data, pos + 1, options)\n if (typeof l === 'bigint') {\n throw new Error(`${decodeErrPrefix} 64-bit integer string lengths not supported`)\n }\n return toToken(data, pos, 9, l, options)\n}\n\nexport const encodeString = encodeBytes\n","import { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\nimport { decodeErrPrefix } from './common.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} prefix\n * @param {number} length\n * @returns {Token}\n */\nfunction toToken (_data, _pos, prefix, length) {\n return new Token(Type.array, length, prefix)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n * @param {DecodeOptions} _options\n * @returns {Token}\n */\nexport function decodeArrayCompact (data, pos, minor, _options) {\n return toToken(data, pos, 1, minor)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArray8 (data, pos, _minor, options) {\n return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArray16 (data, pos, _minor, options) {\n return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArray32 (data, pos, _minor, options) {\n return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options))\n}\n\n// TODO: maybe we shouldn't support this ..\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArray64 (data, pos, _minor, options) {\n const l = uint.readUint64(data, pos + 1, options)\n if (typeof l === 'bigint') {\n throw new Error(`${decodeErrPrefix} 64-bit integer array lengths not supported`)\n }\n return toToken(data, pos, 9, l)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeArrayIndefinite (data, pos, _minor, options) {\n if (options.allowIndefinite === false) {\n throw new Error(`${decodeErrPrefix} indefinite length items not allowed`)\n }\n return toToken(data, pos, 1, Infinity)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeArray (writer, token) {\n uint.encodeUintValue(writer, Type.array.majorEncoded, token.value)\n}\n\n// using an array as a map key, are you sure about this? we can only sort\n// by map length here, it's up to the encoder to decide to look deeper\nencodeArray.compareTokens = uint.encodeUint.compareTokens\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeArray.encodedSize = function encodedSize (token) {\n return uint.encodeUintValue.encodedSize(token.value)\n}\n","import { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\nimport { decodeErrPrefix } from './common.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} prefix\n * @param {number} length\n * @returns {Token}\n */\nfunction toToken (_data, _pos, prefix, length) {\n return new Token(Type.map, length, prefix)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n * @param {DecodeOptions} _options\n * @returns {Token}\n */\nexport function decodeMapCompact (data, pos, minor, _options) {\n return toToken(data, pos, 1, minor)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMap8 (data, pos, _minor, options) {\n return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMap16 (data, pos, _minor, options) {\n return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options))\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMap32 (data, pos, _minor, options) {\n return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options))\n}\n\n// TODO: maybe we shouldn't support this ..\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMap64 (data, pos, _minor, options) {\n const l = uint.readUint64(data, pos + 1, options)\n if (typeof l === 'bigint') {\n throw new Error(`${decodeErrPrefix} 64-bit integer map lengths not supported`)\n }\n return toToken(data, pos, 9, l)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeMapIndefinite (data, pos, _minor, options) {\n if (options.allowIndefinite === false) {\n throw new Error(`${decodeErrPrefix} indefinite length items not allowed`)\n }\n return toToken(data, pos, 1, Infinity)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeMap (writer, token) {\n uint.encodeUintValue(writer, Type.map.majorEncoded, token.value)\n}\n\n// using a map as a map key, are you sure about this? we can only sort\n// by map length here, it's up to the encoder to decide to look deeper\nencodeMap.compareTokens = uint.encodeUint.compareTokens\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeMap.encodedSize = function encodedSize (token) {\n return uint.encodeUintValue.encodedSize(token.value)\n}\n","import { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} minor\n * @param {DecodeOptions} _options\n * @returns {Token}\n */\nexport function decodeTagCompact (_data, _pos, minor, _options) {\n return new Token(Type.tag, minor, 1)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeTag8 (data, pos, _minor, options) {\n return new Token(Type.tag, uint.readUint8(data, pos + 1, options), 2)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeTag16 (data, pos, _minor, options) {\n return new Token(Type.tag, uint.readUint16(data, pos + 1, options), 3)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeTag32 (data, pos, _minor, options) {\n return new Token(Type.tag, uint.readUint32(data, pos + 1, options), 5)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeTag64 (data, pos, _minor, options) {\n return new Token(Type.tag, uint.readUint64(data, pos + 1, options), 9)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n */\nexport function encodeTag (writer, token) {\n uint.encodeUintValue(writer, Type.tag.majorEncoded, token.value)\n}\n\nencodeTag.compareTokens = uint.encodeUint.compareTokens\n\n/**\n * @param {Token} token\n * @returns {number}\n */\nencodeTag.encodedSize = function encodedSize (token) {\n return uint.encodeUintValue.encodedSize(token.value)\n}\n","// TODO: shift some of the bytes logic to bytes-utils so we can use Buffer\n// where possible\n\nimport { Token, Type } from './token.js'\nimport { decodeErrPrefix } from './common.js'\nimport { encodeUint } from './0uint.js'\n\n/**\n * @typedef {import('../interface').ByteWriter} ByteWriter\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n * @typedef {import('../interface').EncodeOptions} EncodeOptions\n */\n\nexport const MINOR_FALSE = 20\nexport const MINOR_TRUE = 21\nexport const MINOR_NULL = 22\nexport const MINOR_UNDEFINED = 23\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeUndefined (_data, _pos, _minor, options) {\n if (options.allowUndefined === false) {\n throw new Error(`${decodeErrPrefix} undefined values are not supported`)\n } else if (options.coerceUndefinedToNull === true) {\n return new Token(Type.null, null, 1)\n }\n return new Token(Type.undefined, undefined, 1)\n}\n\n/**\n * @param {Uint8Array} _data\n * @param {number} _pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeBreak (_data, _pos, _minor, options) {\n if (options.allowIndefinite === false) {\n throw new Error(`${decodeErrPrefix} indefinite length items not allowed`)\n }\n return new Token(Type.break, undefined, 1)\n}\n\n/**\n * @param {number} value\n * @param {number} bytes\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nfunction createToken (value, bytes, options) {\n if (options) {\n if (options.allowNaN === false && Number.isNaN(value)) {\n throw new Error(`${decodeErrPrefix} NaN values are not supported`)\n }\n if (options.allowInfinity === false && (value === Infinity || value === -Infinity)) {\n throw new Error(`${decodeErrPrefix} Infinity values are not supported`)\n }\n }\n return new Token(Type.float, value, bytes)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeFloat16 (data, pos, _minor, options) {\n return createToken(readFloat16(data, pos + 1), 3, options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeFloat32 (data, pos, _minor, options) {\n return createToken(readFloat32(data, pos + 1), 5, options)\n}\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} _minor\n * @param {DecodeOptions} options\n * @returns {Token}\n */\nexport function decodeFloat64 (data, pos, _minor, options) {\n return createToken(readFloat64(data, pos + 1), 9, options)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {Token} token\n * @param {EncodeOptions} options\n */\nexport function encodeFloat (writer, token, options) {\n const float = token.value\n\n if (float === false) {\n writer.push([Type.float.majorEncoded | MINOR_FALSE])\n } else if (float === true) {\n writer.push([Type.float.majorEncoded | MINOR_TRUE])\n } else if (float === null) {\n writer.push([Type.float.majorEncoded | MINOR_NULL])\n } else if (float === undefined) {\n writer.push([Type.float.majorEncoded | MINOR_UNDEFINED])\n } else {\n let decoded\n let success = false\n if (!options || options.float64 !== true) {\n encodeFloat16(float)\n decoded = readFloat16(ui8a, 1)\n if (float === decoded || Number.isNaN(float)) {\n ui8a[0] = 0xf9\n writer.push(ui8a.slice(0, 3))\n success = true\n } else {\n encodeFloat32(float)\n decoded = readFloat32(ui8a, 1)\n if (float === decoded) {\n ui8a[0] = 0xfa\n writer.push(ui8a.slice(0, 5))\n success = true\n }\n }\n }\n if (!success) {\n encodeFloat64(float)\n decoded = readFloat64(ui8a, 1)\n ui8a[0] = 0xfb\n writer.push(ui8a.slice(0, 9))\n }\n }\n}\n\n/**\n * @param {Token} token\n * @param {EncodeOptions} options\n * @returns {number}\n */\nencodeFloat.encodedSize = function encodedSize (token, options) {\n const float = token.value\n\n if (float === false || float === true || float === null || float === undefined) {\n return 1\n }\n\n if (!options || options.float64 !== true) {\n encodeFloat16(float)\n let decoded = readFloat16(ui8a, 1)\n if (float === decoded || Number.isNaN(float)) {\n return 3\n }\n encodeFloat32(float)\n decoded = readFloat32(ui8a, 1)\n if (float === decoded) {\n return 5\n }\n }\n return 9\n}\n\nconst buffer = new ArrayBuffer(9)\nconst dataView = new DataView(buffer, 1)\nconst ui8a = new Uint8Array(buffer, 0)\n\n/**\n * @param {number} inp\n */\nfunction encodeFloat16 (inp) {\n if (inp === Infinity) {\n dataView.setUint16(0, 0x7c00, false)\n } else if (inp === -Infinity) {\n dataView.setUint16(0, 0xfc00, false)\n } else if (Number.isNaN(inp)) {\n dataView.setUint16(0, 0x7e00, false)\n } else {\n dataView.setFloat32(0, inp)\n const valu32 = dataView.getUint32(0)\n const exponent = (valu32 & 0x7f800000) >> 23\n const mantissa = valu32 & 0x7fffff\n\n /* c8 ignore next 6 */\n if (exponent === 0xff) {\n // too big, Infinity, but this should be hard (impossible?) to trigger\n dataView.setUint16(0, 0x7c00, false)\n } else if (exponent === 0x00) {\n // 0.0, -0.0 and subnormals, shouldn't be possible to get here because 0.0 should be counted as an int\n dataView.setUint16(0, ((inp & 0x80000000) >> 16) | (mantissa >> 13), false)\n } else { // standard numbers\n // chunks of logic here borrowed from https://github.com/PJK/libcbor/blob/c78f437182533e3efa8d963ff4b945bb635c2284/src/cbor/encoding.c#L127\n const logicalExponent = exponent - 127\n // Now we know that 2^exponent <= 0 logically\n /* c8 ignore next 6 */\n if (logicalExponent < -24) {\n /* No unambiguous representation exists, this float is not a half float\n and is too small to be represented using a half, round off to zero.\n Consistent with the reference implementation. */\n // should be difficult (impossible?) to get here in JS\n dataView.setUint16(0, 0)\n } else if (logicalExponent < -14) {\n /* Offset the remaining decimal places by shifting the significand, the\n value is lost. This is an implementation decision that works around the\n absence of standard half-float in the language. */\n dataView.setUint16(0, ((valu32 & 0x80000000) >> 16) | /* sign bit */ (1 << (24 + logicalExponent)), false)\n } else {\n dataView.setUint16(0, ((valu32 & 0x80000000) >> 16) | ((logicalExponent + 15) << 10) | (mantissa >> 13), false)\n }\n }\n }\n}\n\n/**\n * @param {Uint8Array} ui8a\n * @param {number} pos\n * @returns {number}\n */\nfunction readFloat16 (ui8a, pos) {\n if (ui8a.length - pos < 2) {\n throw new Error(`${decodeErrPrefix} not enough data for float16`)\n }\n\n const half = (ui8a[pos] << 8) + ui8a[pos + 1]\n if (half === 0x7c00) {\n return Infinity\n }\n if (half === 0xfc00) {\n return -Infinity\n }\n if (half === 0x7e00) {\n return NaN\n }\n const exp = (half >> 10) & 0x1f\n const mant = half & 0x3ff\n let val\n if (exp === 0) {\n val = mant * (2 ** -24)\n } else if (exp !== 31) {\n val = (mant + 1024) * (2 ** (exp - 25))\n /* c8 ignore next 4 */\n } else {\n // may not be possible to get here\n val = mant === 0 ? Infinity : NaN\n }\n return (half & 0x8000) ? -val : val\n}\n\n/**\n * @param {number} inp\n */\nfunction encodeFloat32 (inp) {\n dataView.setFloat32(0, inp, false)\n}\n\n/**\n * @param {Uint8Array} ui8a\n * @param {number} pos\n * @returns {number}\n */\nfunction readFloat32 (ui8a, pos) {\n if (ui8a.length - pos < 4) {\n throw new Error(`${decodeErrPrefix} not enough data for float32`)\n }\n const offset = (ui8a.byteOffset || 0) + pos\n return new DataView(ui8a.buffer, offset, 4).getFloat32(0, false)\n}\n\n/**\n * @param {number} inp\n */\nfunction encodeFloat64 (inp) {\n dataView.setFloat64(0, inp, false)\n}\n\n/**\n * @param {Uint8Array} ui8a\n * @param {number} pos\n * @returns {number}\n */\nfunction readFloat64 (ui8a, pos) {\n if (ui8a.length - pos < 8) {\n throw new Error(`${decodeErrPrefix} not enough data for float64`)\n }\n const offset = (ui8a.byteOffset || 0) + pos\n return new DataView(ui8a.buffer, offset, 8).getFloat64(0, false)\n}\n\n/**\n * @param {Token} _tok1\n * @param {Token} _tok2\n * @returns {number}\n */\nencodeFloat.compareTokens = encodeUint.compareTokens\n/*\nencodeFloat.compareTokens = function compareTokens (_tok1, _tok2) {\n return _tok1\n throw new Error(`${encodeErrPrefix} cannot use floats as map keys`)\n}\n*/\n","import { Token, Type } from './token.js'\nimport * as uint from './0uint.js'\nimport * as negint from './1negint.js'\nimport * as bytes from './2bytes.js'\nimport * as string from './3string.js'\nimport * as array from './4array.js'\nimport * as map from './5map.js'\nimport * as tag from './6tag.js'\nimport * as float from './7float.js'\nimport { decodeErrPrefix } from './common.js'\nimport { fromArray } from './byte-utils.js'\n\n/**\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n */\n\n/**\n * @param {Uint8Array} data\n * @param {number} pos\n * @param {number} minor\n */\nfunction invalidMinor (data, pos, minor) {\n throw new Error(`${decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`)\n}\n\n/**\n * @param {string} msg\n * @returns {()=>any}\n */\nfunction errorer (msg) {\n return () => { throw new Error(`${decodeErrPrefix} ${msg}`) }\n}\n\n/** @type {((data:Uint8Array, pos:number, minor:number, options?:DecodeOptions) => any)[]} */\nexport const jump = []\n\n// unsigned integer, 0x00..0x17 (0..23)\nfor (let i = 0; i <= 0x17; i++) {\n jump[i] = invalidMinor // uint.decodeUintCompact, handled by quick[]\n}\njump[0x18] = uint.decodeUint8 // unsigned integer, one-byte uint8_t follows\njump[0x19] = uint.decodeUint16 // unsigned integer, two-byte uint16_t follows\njump[0x1a] = uint.decodeUint32 // unsigned integer, four-byte uint32_t follows\njump[0x1b] = uint.decodeUint64 // unsigned integer, eight-byte uint64_t follows\njump[0x1c] = invalidMinor\njump[0x1d] = invalidMinor\njump[0x1e] = invalidMinor\njump[0x1f] = invalidMinor\n// negative integer, -1-0x00..-1-0x17 (-1..-24)\nfor (let i = 0x20; i <= 0x37; i++) {\n jump[i] = invalidMinor // negintDecode, handled by quick[]\n}\njump[0x38] = negint.decodeNegint8 // negative integer, -1-n one-byte uint8_t for n follows\njump[0x39] = negint.decodeNegint16 // negative integer, -1-n two-byte uint16_t for n follows\njump[0x3a] = negint.decodeNegint32 // negative integer, -1-n four-byte uint32_t for follows\njump[0x3b] = negint.decodeNegint64 // negative integer, -1-n eight-byte uint64_t for follows\njump[0x3c] = invalidMinor\njump[0x3d] = invalidMinor\njump[0x3e] = invalidMinor\njump[0x3f] = invalidMinor\n// byte string, 0x00..0x17 bytes follow\nfor (let i = 0x40; i <= 0x57; i++) {\n jump[i] = bytes.decodeBytesCompact\n}\njump[0x58] = bytes.decodeBytes8 // byte string, one-byte uint8_t for n, and then n bytes follow\njump[0x59] = bytes.decodeBytes16 // byte string, two-byte uint16_t for n, and then n bytes follow\njump[0x5a] = bytes.decodeBytes32 // byte string, four-byte uint32_t for n, and then n bytes follow\njump[0x5b] = bytes.decodeBytes64 // byte string, eight-byte uint64_t for n, and then n bytes follow\njump[0x5c] = invalidMinor\njump[0x5d] = invalidMinor\njump[0x5e] = invalidMinor\njump[0x5f] = errorer('indefinite length bytes/strings are not supported') // byte string, byte strings follow, terminated by \"break\"\n// UTF-8 string 0x00..0x17 bytes follow\nfor (let i = 0x60; i <= 0x77; i++) {\n jump[i] = string.decodeStringCompact\n}\njump[0x78] = string.decodeString8 // UTF-8 string, one-byte uint8_t for n, and then n bytes follow\njump[0x79] = string.decodeString16 // UTF-8 string, two-byte uint16_t for n, and then n bytes follow\njump[0x7a] = string.decodeString32 // UTF-8 string, four-byte uint32_t for n, and then n bytes follow\njump[0x7b] = string.decodeString64 // UTF-8 string, eight-byte uint64_t for n, and then n bytes follow\njump[0x7c] = invalidMinor\njump[0x7d] = invalidMinor\njump[0x7e] = invalidMinor\njump[0x7f] = errorer('indefinite length bytes/strings are not supported') // UTF-8 strings follow, terminated by \"break\"\n// array, 0x00..0x17 data items follow\nfor (let i = 0x80; i <= 0x97; i++) {\n jump[i] = array.decodeArrayCompact\n}\njump[0x98] = array.decodeArray8 // array, one-byte uint8_t for n, and then n data items follow\njump[0x99] = array.decodeArray16 // array, two-byte uint16_t for n, and then n data items follow\njump[0x9a] = array.decodeArray32 // array, four-byte uint32_t for n, and then n data items follow\njump[0x9b] = array.decodeArray64 // array, eight-byte uint64_t for n, and then n data items follow\njump[0x9c] = invalidMinor\njump[0x9d] = invalidMinor\njump[0x9e] = invalidMinor\njump[0x9f] = array.decodeArrayIndefinite // array, data items follow, terminated by \"break\"\n// map, 0x00..0x17 pairs of data items follow\nfor (let i = 0xa0; i <= 0xb7; i++) {\n jump[i] = map.decodeMapCompact\n}\njump[0xb8] = map.decodeMap8 // map, one-byte uint8_t for n, and then n pairs of data items follow\njump[0xb9] = map.decodeMap16 // map, two-byte uint16_t for n, and then n pairs of data items follow\njump[0xba] = map.decodeMap32 // map, four-byte uint32_t for n, and then n pairs of data items follow\njump[0xbb] = map.decodeMap64 // map, eight-byte uint64_t for n, and then n pairs of data items follow\njump[0xbc] = invalidMinor\njump[0xbd] = invalidMinor\njump[0xbe] = invalidMinor\njump[0xbf] = map.decodeMapIndefinite // map, pairs of data items follow, terminated by \"break\"\n// tags\nfor (let i = 0xc0; i <= 0xd7; i++) {\n jump[i] = tag.decodeTagCompact\n}\njump[0xd8] = tag.decodeTag8\njump[0xd9] = tag.decodeTag16\njump[0xda] = tag.decodeTag32\njump[0xdb] = tag.decodeTag64\njump[0xdc] = invalidMinor\njump[0xdd] = invalidMinor\njump[0xde] = invalidMinor\njump[0xdf] = invalidMinor\n// 0xe0..0xf3 simple values, unsupported\nfor (let i = 0xe0; i <= 0xf3; i++) {\n jump[i] = errorer('simple values are not supported')\n}\njump[0xf4] = invalidMinor // false, handled by quick[]\njump[0xf5] = invalidMinor // true, handled by quick[]\njump[0xf6] = invalidMinor // null, handled by quick[]\njump[0xf7] = float.decodeUndefined // undefined\njump[0xf8] = errorer('simple values are not supported') // simple value, one byte follows, unsupported\njump[0xf9] = float.decodeFloat16 // half-precision float (two-byte IEEE 754)\njump[0xfa] = float.decodeFloat32 // single-precision float (four-byte IEEE 754)\njump[0xfb] = float.decodeFloat64 // double-precision float (eight-byte IEEE 754)\njump[0xfc] = invalidMinor\njump[0xfd] = invalidMinor\njump[0xfe] = invalidMinor\njump[0xff] = float.decodeBreak // \"break\" stop code\n\n/** @type {Token[]} */\nexport const quick = []\n// ints <24\nfor (let i = 0; i < 24; i++) {\n quick[i] = new Token(Type.uint, i, 1)\n}\n// negints >= -24\nfor (let i = -1; i >= -24; i--) {\n quick[31 - i] = new Token(Type.negint, i, 1)\n}\n// empty bytes\nquick[0x40] = new Token(Type.bytes, new Uint8Array(0), 1)\n// empty string\nquick[0x60] = new Token(Type.string, '', 1)\n// empty list\nquick[0x80] = new Token(Type.array, 0, 1)\n// empty map\nquick[0xa0] = new Token(Type.map, 0, 1)\n// false\nquick[0xf4] = new Token(Type.false, false, 1)\n// true\nquick[0xf5] = new Token(Type.true, true, 1)\n// null\nquick[0xf6] = new Token(Type.null, null, 1)\n\n/**\n * @param {Token} token\n * @returns {Uint8Array|undefined}\n */\nexport function quickEncodeToken (token) {\n switch (token.type) {\n case Type.false:\n return fromArray([0xf4])\n case Type.true:\n return fromArray([0xf5])\n case Type.null:\n return fromArray([0xf6])\n case Type.bytes:\n if (!token.value.length) {\n return fromArray([0x40])\n }\n return\n case Type.string:\n if (token.value === '') {\n return fromArray([0x60])\n }\n return\n case Type.array:\n if (token.value === 0) {\n return fromArray([0x80])\n }\n /* c8 ignore next 2 */\n // shouldn't be possible if this were called when there was only one token\n return\n case Type.map:\n if (token.value === 0) {\n return fromArray([0xa0])\n }\n /* c8 ignore next 2 */\n // shouldn't be possible if this were called when there was only one token\n return\n case Type.uint:\n if (token.value < 24) {\n return fromArray([Number(token.value)])\n }\n return\n case Type.negint:\n if (token.value >= -24) {\n return fromArray([31 - Number(token.value)])\n }\n }\n}\n","import { is } from './is.js'\nimport { Token, Type } from './token.js'\nimport { Bl, U8Bl } from './bl.js'\nimport { encodeErrPrefix } from './common.js'\nimport { quickEncodeToken } from './jump.js'\nimport { asU8A, compare, fromString } from './byte-utils.js'\n\nimport { encodeUint, encodeUintValue } from './0uint.js'\nimport { encodeNegint } from './1negint.js'\nimport { encodeBytes } from './2bytes.js'\nimport { encodeString } from './3string.js'\nimport { encodeArray } from './4array.js'\nimport { encodeMap } from './5map.js'\nimport { encodeTag } from './6tag.js'\nimport { encodeFloat, MINOR_FALSE, MINOR_TRUE, MINOR_NULL, MINOR_UNDEFINED } from './7float.js'\n\n/**\n * @typedef {import('../interface').EncodeOptions} EncodeOptions\n * @typedef {import('../interface').OptionalTypeEncoder} OptionalTypeEncoder\n * @typedef {import('../interface').Reference} Reference\n * @typedef {import('../interface').StrictTypeEncoder} StrictTypeEncoder\n * @typedef {import('../interface').TokenTypeEncoder} TokenTypeEncoder\n * @typedef {import('../interface').TokenOrNestedTokens} TokenOrNestedTokens\n * @typedef {import('../interface').ByteWriter} ByteWriter\n */\n\n/** @type {EncodeOptions} */\nconst defaultEncodeOptions = {\n float64: false,\n mapSorter,\n quickEncodeToken\n}\n\n/** @type {EncodeOptions} */\nexport const rfc8949EncodeOptions = Object.freeze({\n float64: true,\n mapSorter: rfc8949MapSorter,\n quickEncodeToken\n})\n\n/** @returns {TokenTypeEncoder[]} */\nexport function makeCborEncoders () {\n const encoders = []\n encoders[Type.uint.major] = encodeUint\n encoders[Type.negint.major] = encodeNegint\n encoders[Type.bytes.major] = encodeBytes\n encoders[Type.string.major] = encodeString\n encoders[Type.array.major] = encodeArray\n encoders[Type.map.major] = encodeMap\n encoders[Type.tag.major] = encodeTag\n encoders[Type.float.major] = encodeFloat\n return encoders\n}\n\nconst cborEncoders = makeCborEncoders()\n\nconst defaultWriter = new Bl()\n\n/** @implements {Reference} */\nclass Ref {\n /**\n * @param {object|any[]} obj\n * @param {Reference|undefined} parent\n */\n constructor (obj, parent) {\n this.obj = obj\n this.parent = parent\n }\n\n /**\n * @param {object|any[]} obj\n * @returns {boolean}\n */\n includes (obj) {\n /** @type {Reference|undefined} */\n let p = this\n do {\n if (p.obj === obj) {\n return true\n }\n } while (p = p.parent) // eslint-disable-line\n return false\n }\n\n /**\n * @param {Reference|undefined} stack\n * @param {object|any[]} obj\n * @returns {Reference}\n */\n static createCheck (stack, obj) {\n if (stack && stack.includes(obj)) {\n throw new Error(`${encodeErrPrefix} object contains circular references`)\n }\n return new Ref(obj, stack)\n }\n}\n\nconst simpleTokens = {\n null: new Token(Type.null, null),\n undefined: new Token(Type.undefined, undefined),\n true: new Token(Type.true, true),\n false: new Token(Type.false, false),\n emptyArray: new Token(Type.array, 0),\n emptyMap: new Token(Type.map, 0)\n}\n\n/** @type {{[typeName: string]: StrictTypeEncoder}} */\nconst typeEncoders = {\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n number (obj, _typ, _options, _refStack) {\n if (!Number.isInteger(obj) || !Number.isSafeInteger(obj)) {\n return new Token(Type.float, obj)\n } else if (obj >= 0) {\n return new Token(Type.uint, obj)\n } else {\n return new Token(Type.negint, obj)\n }\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n bigint (obj, _typ, _options, _refStack) {\n if (obj >= BigInt(0)) {\n return new Token(Type.uint, obj)\n } else {\n return new Token(Type.negint, obj)\n }\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n Uint8Array (obj, _typ, _options, _refStack) {\n return new Token(Type.bytes, obj)\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n string (obj, _typ, _options, _refStack) {\n return new Token(Type.string, obj)\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n boolean (obj, _typ, _options, _refStack) {\n return obj ? simpleTokens.true : simpleTokens.false\n },\n\n /**\n * @param {any} _obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n null (_obj, _typ, _options, _refStack) {\n return simpleTokens.null\n },\n\n /**\n * @param {any} _obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n undefined (_obj, _typ, _options, _refStack) {\n return simpleTokens.undefined\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n ArrayBuffer (obj, _typ, _options, _refStack) {\n return new Token(Type.bytes, new Uint8Array(obj))\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} _options\n * @param {Reference} [_refStack]\n * @returns {TokenOrNestedTokens}\n */\n DataView (obj, _typ, _options, _refStack) {\n return new Token(Type.bytes, new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength))\n },\n\n /**\n * @param {any} obj\n * @param {string} _typ\n * @param {EncodeOptions} options\n * @param {Reference} [refStack]\n * @returns {TokenOrNestedTokens}\n */\n Array (obj, _typ, options, refStack) {\n if (!obj.length) {\n if (options.addBreakTokens === true) {\n return [simpleTokens.emptyArray, new Token(Type.break)]\n }\n return simpleTokens.emptyArray\n }\n refStack = Ref.createCheck(refStack, obj)\n const entries = []\n let i = 0\n for (const e of obj) {\n entries[i++] = objectToTokens(e, options, refStack)\n }\n if (options.addBreakTokens) {\n return [new Token(Type.array, obj.length), entries, new Token(Type.break)]\n }\n return [new Token(Type.array, obj.length), entries]\n },\n\n /**\n * @param {any} obj\n * @param {string} typ\n * @param {EncodeOptions} options\n * @param {Reference} [refStack]\n * @returns {TokenOrNestedTokens}\n */\n Object (obj, typ, options, refStack) {\n // could be an Object or a Map\n const isMap = typ !== 'Object'\n // it's slightly quicker to use Object.keys() than Object.entries()\n const keys = isMap ? obj.keys() : Object.keys(obj)\n const maxLength = isMap ? obj.size : keys.length\n\n /** @type {undefined | [TokenOrNestedTokens, TokenOrNestedTokens][]} */\n let entries\n\n if (maxLength) {\n // Pre-allocate the array with the expected size\n entries = new Array(maxLength)\n refStack = Ref.createCheck(refStack, obj)\n const skipUndefined = !isMap && options.ignoreUndefinedProperties\n\n let i = 0\n for (const key of keys) {\n const value = isMap ? obj.get(key) : obj[key]\n if (skipUndefined && value === undefined) {\n continue\n }\n entries[i++] = [\n objectToTokens(key, options, refStack),\n objectToTokens(value, options, refStack)\n ]\n }\n\n // Truncate only if properties were skipped\n if (i < maxLength) {\n entries.length = i\n }\n }\n\n if (!entries?.length) {\n if (options.addBreakTokens === true) {\n return [simpleTokens.emptyMap, new Token(Type.break)]\n }\n return simpleTokens.emptyMap\n }\n\n sortMapEntries(entries, options)\n if (options.addBreakTokens) {\n return [new Token(Type.map, entries.length), entries, new Token(Type.break)]\n }\n return [new Token(Type.map, entries.length), entries]\n }\n}\n\ntypeEncoders.Map = typeEncoders.Object\ntypeEncoders.Buffer = typeEncoders.Uint8Array\nfor (const typ of 'Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64'.split(' ')) {\n typeEncoders[`${typ}Array`] = typeEncoders.DataView\n}\n\n/**\n * @param {any} obj\n * @param {EncodeOptions} [options]\n * @param {Reference} [refStack]\n * @returns {TokenOrNestedTokens}\n */\nfunction objectToTokens (obj, options = {}, refStack) {\n const typ = is(obj)\n const customTypeEncoder = (options && options.typeEncoders && /** @type {OptionalTypeEncoder} */ options.typeEncoders[typ]) || typeEncoders[typ]\n if (typeof customTypeEncoder === 'function') {\n const tokens = customTypeEncoder(obj, typ, options, refStack)\n if (tokens != null) {\n return tokens\n }\n }\n const typeEncoder = typeEncoders[typ]\n if (!typeEncoder) {\n throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`)\n }\n return typeEncoder(obj, typ, options, refStack)\n}\n\n/*\nCBOR key sorting is a mess.\n\nThe canonicalisation recommendation from https://tools.ietf.org/html/rfc7049#section-3.9\nincludes the wording:\n\n> The keys in every map must be sorted lowest value to highest.\n> Sorting is performed on the bytes of the representation of the key\n> data items without paying attention to the 3/5 bit splitting for\n> major types.\n> ...\n> * If two keys have different lengths, the shorter one sorts\n earlier;\n> * If two keys have the same length, the one with the lower value\n in (byte-wise) lexical order sorts earlier.\n\n1. It is not clear what \"bytes of the representation of the key\" means: is it\n the CBOR representation, or the binary representation of the object itself?\n Consider the int and uint difference here.\n2. It is not clear what \"without paying attention to\" means: do we include it\n and compare on that? Or do we omit the special prefix byte, (mostly) treating\n the key in its plain binary representation form.\n\nThe FIDO 2.0: Client To Authenticator Protocol spec takes the original CBOR\nwording and clarifies it according to their understanding.\nhttps://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html#message-encoding\n\n> The keys in every map must be sorted lowest value to highest. Sorting is\n> performed on the bytes of the representation of the key data items without\n> paying attention to the 3/5 bit splitting for major types. The sorting rules\n> are:\n> * If the major types are different, the one with the lower value in numerical\n> order sorts earlier.\n> * If two keys have different lengths, the shorter one sorts earlier;\n> * If two keys have the same length, the one with the lower value in\n> (byte-wise) lexical order sorts earlier.\n\nSome other implementations, such as borc, do a full encode then do a\nlength-first, byte-wise-second comparison:\nhttps://github.com/dignifiedquire/borc/blob/b6bae8b0bcde7c3976b0f0f0957208095c392a36/src/encoder.js#L358\nhttps://github.com/dignifiedquire/borc/blob/b6bae8b0bcde7c3976b0f0f0957208095c392a36/src/utils.js#L143-L151\n\nThis has the benefit of being able to easily handle arbitrary keys, including\ncomplex types (maps and arrays).\n\nWe'll opt for the FIDO approach, since it affords some efficies since we don't\nneed a full encode of each key to determine order and can defer to the types\nto determine how to most efficiently order their values (i.e. int and uint\nordering can be done on the numbers, no need for byte-wise, for example).\n\nRecommendation: stick to single key types or you'll get into trouble, and prefer\nstring keys because it's much simpler that way.\n*/\n\n/**\n * @param {TokenOrNestedTokens[]} entries\n * @param {EncodeOptions} options\n */\nfunction sortMapEntries (entries, options) {\n if (options.mapSorter) {\n entries.sort(options.mapSorter)\n }\n}\n\n/**\n * @param {(Token|Token[])[]} e1\n * @param {(Token|Token[])[]} e2\n * @returns {number}\n */\nfunction mapSorter (e1, e2) {\n // the key position ([0]) could have a single token or an array\n // almost always it'll be a single token but complex key might get involved\n /* c8 ignore next 2 */\n const keyToken1 = Array.isArray(e1[0]) ? e1[0][0] : e1[0]\n const keyToken2 = Array.isArray(e2[0]) ? e2[0][0] : e2[0]\n\n // different key types\n if (keyToken1.type !== keyToken2.type) {\n return keyToken1.type.compare(keyToken2.type)\n }\n\n const major = keyToken1.type.major\n // TODO: handle case where cmp === 0 but there are more keyToken e. complex type)\n const tcmp = cborEncoders[major].compareTokens(keyToken1, keyToken2)\n /* c8 ignore next 5 */\n if (tcmp === 0) {\n // duplicate key or complex type where the first token matched,\n // i.e. a map or array and we're only comparing the opening token\n console.warn('WARNING: complex key types used, CBOR key sorting guarantees are gone')\n }\n return tcmp\n}\n\n/**\n * @typedef {Token & { _keyBytes?: Uint8Array }} TokenEx\n *\n * @param {(Token|Token[])[]} e1\n * @param {(Token|Token[])[]} e2\n * @returns {number}\n */\nfunction rfc8949MapSorter (e1, e2) {\n if (e1[0] instanceof Token && e2[0] instanceof Token) {\n const t1 = /** @type {TokenEx} */ (e1[0])\n const t2 = /** @type {TokenEx} */ (e2[0])\n\n if (!t1._keyBytes) {\n t1._keyBytes = encodeRfc8949(t1.value)\n }\n\n if (!t2._keyBytes) {\n t2._keyBytes = encodeRfc8949(t2.value)\n }\n\n return compare(t1._keyBytes, t2._keyBytes)\n }\n\n throw new Error('rfc8949MapSorter: complex key types are not supported yet')\n}\n\n/**\n * @param {any} data\n * @returns {Uint8Array}\n */\nfunction encodeRfc8949 (data) {\n return encodeCustom(data, cborEncoders, rfc8949EncodeOptions)\n}\n\n/**\n * @param {ByteWriter} writer\n * @param {TokenOrNestedTokens} tokens\n * @param {TokenTypeEncoder[]} encoders\n * @param {EncodeOptions} options\n */\nfunction tokensToEncoded (writer, tokens, encoders, options) {\n if (Array.isArray(tokens)) {\n for (const token of tokens) {\n tokensToEncoded(writer, token, encoders, options)\n }\n } else {\n encoders[tokens.type.major](writer, tokens, options)\n }\n}\n\n// CBOR major type prefixes, cached from Type for hot path performance\nconst MAJOR_UINT = Type.uint.majorEncoded\nconst MAJOR_NEGINT = Type.negint.majorEncoded\nconst MAJOR_BYTES = Type.bytes.majorEncoded\nconst MAJOR_STRING = Type.string.majorEncoded\nconst MAJOR_ARRAY = Type.array.majorEncoded\n\n// Simple value bytes (CBOR major type 7 + minor value)\nconst SIMPLE_FALSE = Type.float.majorEncoded | MINOR_FALSE\nconst SIMPLE_TRUE = Type.float.majorEncoded | MINOR_TRUE\nconst SIMPLE_NULL = Type.float.majorEncoded | MINOR_NULL\nconst SIMPLE_UNDEFINED = Type.float.majorEncoded | MINOR_UNDEFINED\n\nconst neg1b = BigInt(-1)\nconst pos1b = BigInt(1)\n\n/**\n * Check if direct encoding can be used for the given options.\n * Direct encoding bypasses token creation for most values.\n * @param {EncodeOptions} options\n * @returns {boolean}\n */\nfunction canDirectEncode (options) {\n // Cannot use direct encode with addBreakTokens (needs special break token handling).\n // Direct encode checks typeEncoders per-value, falling back to tokens as needed.\n // Maps fall back to token-based encoding for efficient key sorting.\n return options.addBreakTokens !== true\n}\n\n/**\n * Direct encode a value to the writer, bypassing token creation for most types.\n * Falls back to token-based encoding for custom type encoders.\n * @param {ByteWriter} writer\n * @param {any} data\n * @param {EncodeOptions} options\n * @param {Reference|undefined} refStack\n */\nfunction directEncode (writer, data, options, refStack) {\n const typ = is(data)\n\n // Check for custom encoder for THIS specific type\n const customEncoder = options.typeEncoders && options.typeEncoders[typ]\n if (customEncoder) {\n const tokens = customEncoder(data, typ, options, refStack)\n if (tokens != null) {\n // Custom encoder returned tokens, serialize immediately\n tokensToEncoded(writer, tokens, cborEncoders, options)\n return\n }\n // Custom encoder returned null, fall through to default handling\n }\n\n // Direct encode based on type\n switch (typ) {\n case 'null':\n writer.push([SIMPLE_NULL])\n return\n\n case 'undefined':\n writer.push([SIMPLE_UNDEFINED])\n return\n\n case 'boolean':\n writer.push([data ? SIMPLE_TRUE : SIMPLE_FALSE])\n return\n\n case 'number':\n if (!Number.isInteger(data) || !Number.isSafeInteger(data)) {\n // Float, use token encoder for complex float encoding\n encodeFloat(writer, new Token(Type.float, data), options)\n } else if (data >= 0) {\n encodeUintValue(writer, MAJOR_UINT, data)\n } else {\n // Negative integer\n encodeUintValue(writer, MAJOR_NEGINT, data * -1 - 1)\n }\n return\n\n case 'bigint':\n if (data >= BigInt(0)) {\n encodeUintValue(writer, MAJOR_UINT, data)\n } else {\n encodeUintValue(writer, MAJOR_NEGINT, data * neg1b - pos1b)\n }\n return\n\n case 'string': {\n const bytes = fromString(data)\n encodeUintValue(writer, MAJOR_STRING, bytes.length)\n writer.push(bytes)\n return\n }\n\n case 'Uint8Array':\n encodeUintValue(writer, MAJOR_BYTES, data.length)\n writer.push(data)\n return\n\n case 'Array':\n if (!data.length) {\n writer.push([MAJOR_ARRAY]) // Empty array: 0x80\n return\n }\n refStack = Ref.createCheck(refStack, data)\n encodeUintValue(writer, MAJOR_ARRAY, data.length)\n for (const elem of data) {\n directEncode(writer, elem, options, refStack)\n }\n return\n\n case 'Object':\n case 'Map':\n // Maps require key sorting, use token-based encoding for efficiency\n // (pre-encoding all keys for sorting is expensive)\n {\n const tokens = typeEncoders.Object(data, typ, options, refStack)\n tokensToEncoded(writer, tokens, cborEncoders, options)\n }\n return\n\n default:\n // Fall back to token-based encoding for other types (DataView, TypedArrays, etc.)\n {\n const typeEncoder = typeEncoders[typ]\n if (!typeEncoder) {\n throw new Error(`${encodeErrPrefix} unsupported type: ${typ}`)\n }\n const tokens = typeEncoder(data, typ, options, refStack)\n tokensToEncoded(writer, tokens, cborEncoders, options)\n }\n }\n}\n\n/**\n * @param {any} data\n * @param {TokenTypeEncoder[]} encoders\n * @param {EncodeOptions} options\n * @param {Uint8Array} [destination]\n * @returns {Uint8Array}\n */\nfunction encodeCustom (data, encoders, options, destination) {\n // arg ordering is different to encodeInto for backward compatibility\n const hasDest = destination instanceof Uint8Array\n let writeTo = hasDest ? new U8Bl(destination) : defaultWriter\n\n const tokens = objectToTokens(data, options)\n if (!Array.isArray(tokens) && options.quickEncodeToken) {\n const quickBytes = options.quickEncodeToken(tokens)\n if (quickBytes) {\n if (hasDest) {\n // Copy quick bytes into destination buffer\n writeTo.push(quickBytes)\n return writeTo.toBytes()\n }\n return quickBytes\n }\n const encoder = encoders[tokens.type.major]\n if (encoder.encodedSize) {\n const size = encoder.encodedSize(tokens, options)\n if (!hasDest) {\n writeTo = new Bl(size)\n }\n encoder(writeTo, tokens, options)\n /* c8 ignore next 4 */\n // this would be a problem with encodedSize() functions\n if (writeTo.chunks.length !== 1) {\n throw new Error(`Unexpected error: pre-calculated length for ${tokens} was wrong`)\n }\n return hasDest ? writeTo.toBytes() : asU8A(writeTo.chunks[0])\n }\n }\n writeTo.reset()\n tokensToEncoded(writeTo, tokens, encoders, options)\n return writeTo.toBytes(true)\n}\n\n/**\n * @param {any} data\n * @param {EncodeOptions} [options]\n * @returns {Uint8Array}\n */\nfunction encode (data, options) {\n options = Object.assign({}, defaultEncodeOptions, options)\n\n // Use direct encode path when possible\n if (canDirectEncode(options)) {\n defaultWriter.reset()\n directEncode(defaultWriter, data, options, undefined)\n return defaultWriter.toBytes(true)\n }\n\n return encodeCustom(data, cborEncoders, options)\n}\n\n/**\n * @param {any} data\n * @param {Uint8Array} destination\n * @param {EncodeOptions} [options]\n * @returns {{ written: number }}\n */\nfunction encodeInto (data, destination, options) {\n options = Object.assign({}, defaultEncodeOptions, options)\n\n // Use direct encode path when possible\n if (canDirectEncode(options)) {\n const writer = new U8Bl(destination)\n directEncode(writer, data, options, undefined)\n return { written: writer.toBytes().length }\n }\n\n const result = encodeCustom(data, cborEncoders, options, destination)\n return { written: result.length }\n}\n\nexport { objectToTokens, encode, encodeCustom, encodeInto, Ref }\n","import { decodeErrPrefix } from './common.js'\nimport { Type } from './token.js'\nimport { jump, quick } from './jump.js'\nimport { asU8A } from './byte-utils.js'\n\n/**\n * @typedef {import('./token.js').Token} Token\n * @typedef {import('../interface').DecodeOptions} DecodeOptions\n * @typedef {import('../interface').DecodeTokenizer} DecodeTokenizer\n */\n\nconst defaultDecodeOptions = {\n strict: false,\n allowIndefinite: true,\n allowUndefined: true,\n allowBigInt: true\n}\n\n/**\n * @implements {DecodeTokenizer}\n */\nclass Tokeniser {\n /**\n * @param {Uint8Array} data\n * @param {DecodeOptions} options\n */\n constructor (data, options = {}) {\n this._pos = 0\n this.data = data\n this.options = options\n }\n\n pos () {\n return this._pos\n }\n\n done () {\n return this._pos >= this.data.length\n }\n\n next () {\n const byt = this.data[this._pos]\n let token = quick[byt]\n if (token === undefined) {\n const decoder = jump[byt]\n /* c8 ignore next 4 */\n // if we're here then there's something wrong with our jump or quick lists!\n if (!decoder) {\n throw new Error(`${decodeErrPrefix} no decoder for major type ${byt >>> 5} (byte 0x${byt.toString(16).padStart(2, '0')})`)\n }\n const minor = byt & 31\n token = decoder(this.data, this._pos, minor, this.options)\n }\n // @ts-ignore we get to assume encodedLength is set (crossing fingers slightly)\n this._pos += token.encodedLength\n return token\n }\n}\n\nconst DONE = Symbol.for('DONE')\nconst BREAK = Symbol.for('BREAK')\n\n/**\n * @param {Token} token\n * @param {DecodeTokenizer} tokeniser\n * @param {DecodeOptions} options\n * @returns {any|BREAK|DONE}\n */\nfunction tokenToArray (token, tokeniser, options) {\n const arr = []\n for (let i = 0; i < token.value; i++) {\n const value = tokensToObject(tokeniser, options)\n if (value === BREAK) {\n if (token.value === Infinity) {\n // normal end to indefinite length array\n break\n }\n throw new Error(`${decodeErrPrefix} got unexpected break to lengthed array`)\n }\n if (value === DONE) {\n throw new Error(`${decodeErrPrefix} found array but not enough entries (got ${i}, expected ${token.value})`)\n }\n arr[i] = value\n }\n return arr\n}\n\n/**\n * @param {Token} token\n * @param {DecodeTokenizer} tokeniser\n * @param {DecodeOptions} options\n * @returns {any|BREAK|DONE}\n */\nfunction tokenToMap (token, tokeniser, options) {\n const useMaps = options.useMaps === true\n const rejectDuplicateMapKeys = options.rejectDuplicateMapKeys === true\n const obj = useMaps ? undefined : {}\n const m = useMaps ? new Map() : undefined\n for (let i = 0; i < token.value; i++) {\n const key = tokensToObject(tokeniser, options)\n if (key === BREAK) {\n if (token.value === Infinity) {\n // normal end to indefinite length map\n break\n }\n throw new Error(`${decodeErrPrefix} got unexpected break to lengthed map`)\n }\n if (key === DONE) {\n throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no key], expected ${token.value})`)\n }\n if (!useMaps && typeof key !== 'string') {\n throw new Error(`${decodeErrPrefix} non-string keys not supported (got ${typeof key})`)\n }\n if (rejectDuplicateMapKeys) {\n // @ts-ignore\n if ((useMaps && m.has(key)) || (!useMaps && Object.hasOwn(obj, key))) {\n throw new Error(`${decodeErrPrefix} found repeat map key \"${key}\"`)\n }\n }\n const value = tokensToObject(tokeniser, options)\n if (value === DONE) {\n throw new Error(`${decodeErrPrefix} found map but not enough entries (got ${i} [no value], expected ${token.value})`)\n }\n if (useMaps) {\n // @ts-ignore TODO reconsider this .. maybe needs to be strict about key types\n m.set(key, value)\n } else {\n // @ts-ignore TODO reconsider this .. maybe needs to be strict about key types\n obj[key] = value\n }\n }\n // @ts-ignore c'mon man\n return useMaps ? m : obj\n}\n\n/**\n * @param {DecodeTokenizer} tokeniser\n * @param {DecodeOptions} options\n * @returns {any|BREAK|DONE}\n */\nfunction tokensToObject (tokeniser, options) {\n // should we support array as an argument?\n // check for tokenIter[Symbol.iterator] and replace tokenIter with what that returns?\n if (tokeniser.done()) {\n return DONE\n }\n\n const token = tokeniser.next()\n\n if (Type.equals(token.type, Type.break)) {\n return BREAK\n }\n\n if (token.type.terminal) {\n return token.value\n }\n\n if (Type.equals(token.type, Type.array)) {\n return tokenToArray(token, tokeniser, options)\n }\n\n if (Type.equals(token.type, Type.map)) {\n return tokenToMap(token, tokeniser, options)\n }\n\n if (Type.equals(token.type, Type.tag)) {\n if (options.tags && typeof options.tags[token.value] === 'function') {\n const tagged = tokensToObject(tokeniser, options)\n return options.tags[token.value](tagged)\n }\n throw new Error(`${decodeErrPrefix} tag not supported (${token.value})`)\n }\n /* c8 ignore next */\n throw new Error('unsupported')\n}\n\n/**\n * @param {Uint8Array} data\n * @param {DecodeOptions} [options]\n * @returns {[any, Uint8Array]}\n */\nfunction decodeFirst (data, options) {\n if (!(data instanceof Uint8Array)) {\n throw new Error(`${decodeErrPrefix} data to decode must be a Uint8Array`)\n }\n options = Object.assign({}, defaultDecodeOptions, options)\n // Convert Buffer to plain Uint8Array for faster slicing in decode path\n const u8aData = asU8A(data)\n const tokeniser = options.tokenizer || new Tokeniser(u8aData, options)\n const decoded = tokensToObject(tokeniser, options)\n if (decoded === DONE) {\n throw new Error(`${decodeErrPrefix} did not find any content to decode`)\n }\n if (decoded === BREAK) {\n throw new Error(`${decodeErrPrefix} got unexpected break`)\n }\n return [decoded, data.subarray(tokeniser.pos())]\n}\n\n/**\n * @param {Uint8Array} data\n * @param {DecodeOptions} [options]\n * @returns {any}\n */\nfunction decode (data, options) {\n const [decoded, remainder] = decodeFirst(data, options)\n if (remainder.length > 0) {\n throw new Error(`${decodeErrPrefix} too many terminals, data makes no sense`)\n }\n return decoded\n}\n\nexport { Tokeniser, tokensToObject, decode, decodeFirst }\n","// crypto-ts: cryptography primitives and wrappers\n// Copyright 2026 Dark Bio AG. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\nimport { encode as cborEncode, decode as cborDecodeRaw } from \"cborg\";\nimport {\n SecretKey as XdsaSecretKey,\n PublicKey as XdsaPublicKey,\n Fingerprint as XdsaFingerprint,\n} from \"./xdsa.js\";\nimport {\n SecretKey as XhpkeSecretKey,\n PublicKey as XhpkePublicKey,\n Fingerprint as XhpkeFingerprint,\n} from \"./xhpke.js\";\n\nfunction cborDecode<T>(data: Uint8Array): T {\n return cborDecodeRaw(data, { useMaps: true }) as T;\n}\n\nimport init, {\n cose_sign,\n cose_sign_detached,\n cose_verify,\n cose_verify_detached,\n cose_signer,\n cose_peek,\n cose_recipient,\n cose_seal,\n cose_open,\n cose_encrypt,\n cose_decrypt,\n} from \"./wasm/darkbio_crypto_wasm.js\";\n\nlet initialized = false;\n\nasync function ensureInit(): Promise<void> {\n if (!initialized) {\n await init();\n initialized = true;\n }\n}\n\n/**\n * Create a COSE_Sign1 signature with an embedded payload.\n *\n * @param msgToEmbed - The payload to embed and sign (will be CBOR encoded)\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param signer - The xDSA secret key\n * @param domain - Application-specific domain separator\n * @returns The serialized COSE_Sign1 structure\n */\nexport async function sign<E, A>(\n msgToEmbed: E,\n msgToAuth: A,\n signer: XdsaSecretKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const embedBytes = cborEncode(msgToEmbed);\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_sign(embedBytes, authBytes, signer.toBytes(), domain),\n );\n}\n\n/**\n * Create a COSE_Sign1 signature without an embedded payload (detached mode).\n *\n * @param msgToAuth - The message to authenticate (will be CBOR encoded)\n * @param signer - The xDSA secret key\n * @param domain - Application-specific domain separator\n * @returns The serialized COSE_Sign1 structure (with null payload)\n */\nexport async function signDetached<A>(\n msgToAuth: A,\n signer: XdsaSecretKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_sign_detached(authBytes, signer.toBytes(), domain),\n );\n}\n\n/**\n * Verify a COSE_Sign1 signature and return the embedded payload.\n *\n * @param msgToCheck - The COSE_Sign1 structure to verify\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param verifier - The xDSA public key\n * @param domain - Application-specific domain separator\n * @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)\n * @returns The decoded embedded payload\n */\nexport async function verify<T, A>(\n msgToCheck: Uint8Array,\n msgToAuth: A,\n verifier: XdsaPublicKey,\n domain: Uint8Array,\n maxDriftSecs?: number,\n): Promise<T> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n const payloadBytes = cose_verify(\n msgToCheck,\n authBytes,\n verifier.toBytes(),\n domain,\n maxDriftSecs !== undefined ? BigInt(maxDriftSecs) : undefined,\n );\n return cborDecode(new Uint8Array(payloadBytes)) as T;\n}\n\n/**\n * Verify a COSE_Sign1 signature with a detached payload.\n *\n * @param msgToCheck - The COSE_Sign1 structure to verify\n * @param msgToAuth - The detached message to authenticate (will be CBOR encoded)\n * @param verifier - The xDSA public key\n * @param domain - Application-specific domain separator\n * @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)\n */\nexport async function verifyDetached<A>(\n msgToCheck: Uint8Array,\n msgToAuth: A,\n verifier: XdsaPublicKey,\n domain: Uint8Array,\n maxDriftSecs?: number,\n): Promise<void> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n cose_verify_detached(\n msgToCheck,\n authBytes,\n verifier.toBytes(),\n domain,\n maxDriftSecs !== undefined ? BigInt(maxDriftSecs) : undefined,\n );\n}\n\n/**\n * Extract the signer's fingerprint from a COSE_Sign1 without verifying.\n *\n * @param signature - The COSE_Sign1 structure\n * @returns The signer fingerprint\n */\nexport async function signer(signature: Uint8Array): Promise<XdsaFingerprint> {\n await ensureInit();\n const fp = new Uint8Array(cose_signer(signature));\n return XdsaFingerprint.fromBytes(fp);\n}\n\n/**\n * Extract the embedded payload from a COSE_Sign1 without verifying.\n *\n * Warning: The returned payload is unauthenticated and should not be\n * trusted until verified with `verify`.\n *\n * @param signature - The COSE_Sign1 structure\n * @returns The decoded (but unverified) payload\n */\nexport async function peek<T>(signature: Uint8Array): Promise<T> {\n await ensureInit();\n const payloadBytes = cose_peek(signature);\n return cborDecode(new Uint8Array(payloadBytes)) as T;\n}\n\n/**\n * Extract the recipient's fingerprint from a COSE_Encrypt0 without decrypting.\n *\n * @param ciphertext - The COSE_Encrypt0 structure\n * @returns The recipient fingerprint\n */\nexport async function recipient(\n ciphertext: Uint8Array,\n): Promise<XhpkeFingerprint> {\n await ensureInit();\n const fp = new Uint8Array(cose_recipient(ciphertext));\n return XhpkeFingerprint.fromBytes(fp);\n}\n\n/**\n * Sign a message then encrypt it to a recipient (sign-then-encrypt).\n *\n * @param msgToSeal - The payload to sign and encrypt (will be CBOR encoded)\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param signerKey - The xDSA secret key to sign with\n * @param recipientKey - The xHPKE public key to encrypt to\n * @param domain - Application-specific domain separator\n * @returns The sealed COSE structure\n */\nexport async function seal<S, A>(\n msgToSeal: S,\n msgToAuth: A,\n signerKey: XdsaSecretKey,\n recipientKey: XhpkePublicKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const sealBytes = cborEncode(msgToSeal);\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_seal(\n sealBytes,\n authBytes,\n signerKey.toBytes(),\n recipientKey.toBytes(),\n domain,\n ),\n );\n}\n\n/**\n * Decrypt and verify a sealed message.\n *\n * @param msgToOpen - The sealed COSE structure\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param recipientKey - The xHPKE secret key to decrypt with\n * @param senderKey - The xDSA public key to verify against\n * @param domain - Application-specific domain separator\n * @param maxDriftSecs - Maximum allowed clock drift (undefined for no time check)\n * @returns The decoded payload\n */\nexport async function open<T, A>(\n msgToOpen: Uint8Array,\n msgToAuth: A,\n recipientKey: XhpkeSecretKey,\n senderKey: XdsaPublicKey,\n domain: Uint8Array,\n maxDriftSecs?: number,\n): Promise<T> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n const payloadBytes = cose_open(\n msgToOpen,\n authBytes,\n recipientKey.toBytes(),\n senderKey.toBytes(),\n domain,\n maxDriftSecs !== undefined ? BigInt(maxDriftSecs) : undefined,\n );\n return cborDecode(new Uint8Array(payloadBytes)) as T;\n}\n\n/**\n * Encrypt an already-signed COSE_Sign1 to a recipient.\n *\n * For most use cases, prefer `seal` which signs and encrypts in one step.\n * Use this only when re-encrypting a message to a different recipient\n * without access to the original signer's key.\n *\n * @param sign1 - The COSE_Sign1 structure to encrypt\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param recipientKey - The xHPKE public key to encrypt to\n * @param domain - Application-specific domain separator\n * @returns The COSE_Encrypt0 structure\n */\nexport async function encrypt<A>(\n sign1: Uint8Array,\n msgToAuth: A,\n recipientKey: XhpkePublicKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_encrypt(sign1, authBytes, recipientKey.toBytes(), domain),\n );\n}\n\n/**\n * Decrypt a sealed message without verifying the signature.\n *\n * This allows inspecting the signer before verification. Use `signer` to\n * extract the signer's fingerprint, then verify with `verify`.\n *\n * @param msgToOpen - The COSE_Encrypt0 structure\n * @param msgToAuth - Additional authenticated data (will be CBOR encoded)\n * @param recipientKey - The xHPKE secret key to decrypt with\n * @param domain - Application-specific domain separator\n * @returns The decrypted COSE_Sign1 structure (not yet verified)\n */\nexport async function decrypt<A>(\n msgToOpen: Uint8Array,\n msgToAuth: A,\n recipientKey: XhpkeSecretKey,\n domain: Uint8Array,\n): Promise<Uint8Array> {\n await ensureInit();\n const authBytes = cborEncode(msgToAuth);\n return new Uint8Array(\n cose_decrypt(msgToOpen, authBytes, recipientKey.toBytes(), domain),\n );\n}\n"],"names":["argon2_key","password","salt","time","memory","threads","out_len","ptr0","passArray8ToWasm0","wasm","len0","WASM_VECTOR_LEN","ptr1","len1","ret","v3","getArrayU8FromWasm0","cose_decrypt","msg_to_open","msg_to_auth","recipient","domain","ptr2","len2","ptr3","len3","takeFromExternrefTable0","v5","cose_encrypt","sign1","cose_open","sender","max_drift_secs","ptr4","len4","isLikeNone","v6","cose_peek","signature","v2","cose_recipient","ciphertext","cose_seal","msg_to_seal","signer","cose_sign","msg_to_embed","cose_sign_detached","v4","cose_signer","cose_verify","msg_to_check","verifier","cose_verify_detached","hkdf_expand","prk","info","hkdf_extract","secret","hkdf_key","rand_generate","bytes","v1","xdsa_fingerprint","public_key","xdsa_fingerprint_size","xdsa_generate","xdsa_public_key","secret_key","xdsa_public_key_from_cert_der","der","xdsa_public_key_from_cert_pem","pem","passStringToWasm0","xdsa_public_key_from_pem","xdsa_public_key_size","xdsa_public_key_to_cert_der","subject_name","issuer_name","not_before","not_after","is_ca","path_len","xdsa_public_key_to_cert_pem","deferred6_0","deferred6_1","ptr5","len5","getStringFromWasm0","xdsa_public_key_to_pem","deferred3_0","deferred3_1","xdsa_secret_key_from_pem","xdsa_secret_key_size","xdsa_secret_key_to_pem","xdsa_sign","message","xdsa_signature_size","xdsa_verify","xhpke_encap_key_size","xhpke_fingerprint","xhpke_fingerprint_size","xhpke_generate","xhpke_open","sealed","xhpke_public_key","xhpke_public_key_from_cert_der","xhpke_public_key_from_cert_pem","xhpke_public_key_from_pem","xhpke_public_key_size","xhpke_public_key_to_cert_der","xhpke_public_key_to_cert_pem","xhpke_public_key_to_pem","xhpke_seal","xhpke_secret_key_from_pem","xhpke_secret_key_size","xhpke_secret_key_to_pem","__wbg_get_imports","arg0","arg1","val","handleError","arg2","addToExternrefTable0","table","offset","obj","idx","ptr","len","getUint8ArrayMemory0","decodeText","cachedUint8ArrayMemory0","f","args","e","x","arg","malloc","realloc","buf","cachedTextEncoder","mem","code","view","value","cachedTextDecoder","MAX_SAFARI_DECODE_BYTES","numBytesDecoded","__wbg_finalize_init","instance","module","__wbg_load","imports","expectedResponseType","type","__wbg_init","module_or_path","initialized","ensureInit","init","generate","key","outLen","extract","expand","SECRET_KEY_SIZE","PUBLIC_KEY_SIZE","SIGNATURE_SIZE","FINGERPRINT_SIZE","sizes","Fingerprint$1","Fingerprint","Signature","PublicKey$1","PublicKey","result","notBefore","notAfter","fp","params","SecretKey$1","SecretKey","pk","sig","ENCAP_KEY_SIZE","msgToSeal","msgToAuth","objectTypeNames","is","typeOf","objectType","getObjectType","objectTypeName","Type","major","name","terminal","typ","a","b","Token","encodedLength","useBuffer","textEncoder","isBuffer","asU8A","FROM_STRING_THRESHOLD_BUFFER","FROM_STRING_THRESHOLD_TEXTENCODER","fromString","string","utf8ToBytes","fromArray","arr","slice","start","end","concat","chunks","length","c","out","off","alloc","size","compare","b1","b2","i","str","p","defaultChunkSize","Bl","chunkSize","topChunk","chunkPos","reset","byts","chunk","U8Bl","dest","decodeErrPrefix","encodeErrPrefix","assertEnoughData","data","pos","need","uintBoundaries","readUint8","options","readUint16","readUint32","readUint64","hi","lo","decodeUint8","_minor","decodeUint16","decodeUint32","decodeUint64","encodeUint","writer","token","encodeUintValue","uint","nuint","buint","set","tok1","tok2","decodeNegint8","uint.readUint8","decodeNegint16","uint.readUint16","decodeNegint32","uint.readUint32","neg1b","pos1b","decodeNegint64","int","uint.readUint64","encodeNegint","negint","unsigned","uint.encodeUintValue","uint.uintBoundaries","toToken","prefix","decodeBytesCompact","minor","_options","decodeBytes8","decodeBytes16","decodeBytes32","decodeBytes64","l","tokenBytes","encodeBytes","compareBytes","textDecoder","ASCII_THRESHOLD","toStr","totLength","tok","decodeStringCompact","decodeString8","decodeString16","decodeString32","decodeString64","encodeString","_data","_pos","decodeArrayCompact","decodeArray8","decodeArray16","decodeArray32","decodeArray64","decodeArrayIndefinite","encodeArray","uint.encodeUint","decodeMapCompact","decodeMap8","decodeMap16","decodeMap32","decodeMap64","decodeMapIndefinite","encodeMap","decodeTagCompact","decodeTag8","decodeTag16","decodeTag32","decodeTag64","encodeTag","MINOR_FALSE","MINOR_TRUE","MINOR_NULL","MINOR_UNDEFINED","decodeUndefined","decodeBreak","createToken","decodeFloat16","readFloat16","decodeFloat32","readFloat32","decodeFloat64","readFloat64","encodeFloat","float","decoded","success","encodeFloat16","ui8a","encodeFloat32","encodeFloat64","buffer","dataView","inp","valu32","exponent","mantissa","logicalExponent","half","exp","mant","invalidMinor","errorer","msg","jump","uint.decodeUint8","uint.decodeUint16","uint.decodeUint32","uint.decodeUint64","negint.decodeNegint8","negint.decodeNegint16","negint.decodeNegint32","negint.decodeNegint64","bytes.decodeBytesCompact","bytes.decodeBytes8","bytes.decodeBytes16","bytes.decodeBytes32","bytes.decodeBytes64","string.decodeStringCompact","string.decodeString8","string.decodeString16","string.decodeString32","string.decodeString64","array.decodeArrayCompact","array.decodeArray8","array.decodeArray16","array.decodeArray32","array.decodeArray64","array.decodeArrayIndefinite","map.decodeMapCompact","map.decodeMap8","map.decodeMap16","map.decodeMap32","map.decodeMap64","map.decodeMapIndefinite","tag.decodeTagCompact","tag.decodeTag8","tag.decodeTag16","tag.decodeTag32","tag.decodeTag64","float.decodeUndefined","float.decodeFloat16","float.decodeFloat32","float.decodeFloat64","float.decodeBreak","quick","quickEncodeToken","defaultEncodeOptions","mapSorter","makeCborEncoders","encoders","cborEncoders","defaultWriter","Ref","parent","stack","simpleTokens","typeEncoders","_typ","_refStack","_obj","refStack","entries","objectToTokens","isMap","keys","maxLength","skipUndefined","sortMapEntries","customTypeEncoder","tokens","typeEncoder","e1","e2","keyToken1","keyToken2","tcmp","tokensToEncoded","MAJOR_UINT","MAJOR_NEGINT","MAJOR_BYTES","MAJOR_STRING","MAJOR_ARRAY","SIMPLE_FALSE","SIMPLE_TRUE","SIMPLE_NULL","SIMPLE_UNDEFINED","canDirectEncode","directEncode","customEncoder","elem","encodeCustom","destination","hasDest","writeTo","quickBytes","encoder","encode","defaultDecodeOptions","Tokeniser","byt","decoder","DONE","BREAK","tokenToArray","tokeniser","tokensToObject","tokenToMap","useMaps","rejectDuplicateMapKeys","m","tagged","decodeFirst","u8aData","decode","remainder","cborDecode","cborDecodeRaw","sign","msgToEmbed","embedBytes","cborEncode","authBytes","signDetached","verify","msgToCheck","maxDriftSecs","payloadBytes","verifyDetached","XdsaFingerprint","peek","XhpkeFingerprint","seal","signerKey","recipientKey","sealBytes","open","msgToOpen","senderKey","encrypt","decrypt"],"mappings":"AAwBO,SAASA,GAAWC,GAAUC,GAAMC,GAAMC,GAAQC,GAASC,GAAS;AACvE,QAAMC,IAAOC,EAAkBP,GAAUQ,EAAK,iBAAiB,GACzDC,IAAOC,GACPC,IAAOJ,EAAkBN,GAAMO,EAAK,iBAAiB,GACrDI,IAAOF,GACPG,IAAML,EAAK,WAAWF,GAAMG,GAAME,GAAMC,GAAMV,GAAMC,GAAQC,GAASC,CAAO;AAClF,MAAIS,IAAKC,EAAoBF,EAAI,CAAC,GAAGA,EAAI,CAAC,CAAC,EAAE,MAAK;AAClD,SAAAL,EAAK,gBAAgBK,EAAI,CAAC,GAAGA,EAAI,CAAC,I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