cf-workers-native 0.1.4 → 0.1.6
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 +2 -2
- package/dist/browser/documents/page-source.js +1 -1
- package/dist/browser/fetch/host-call.js +6 -1
- package/dist/browser/fetch/native-network.d.ts +1 -1
- package/dist/browser/fetch/relay.js +2 -0
- package/dist/browser/headers/index.d.ts +2 -0
- package/dist/browser/headers/index.js +5 -0
- package/dist/browser/isolated/transport.js +3 -2
- package/dist/browser/request/index.js +3 -2
- package/dist/browser/response/index.d.ts +2 -0
- package/dist/browser/response/index.js +11 -3
- package/dist/browser/structured-clone/index.d.ts +3 -0
- package/dist/browser/structured-clone/index.js +75 -7
- package/dist/browser/websocket/attachment-size.d.ts +3 -0
- package/dist/browser/websocket/attachment-size.js +336 -0
- package/dist/browser/websocket/brand.d.ts +4 -0
- package/dist/browser/websocket/brand.js +16 -0
- package/dist/browser/websocket/close-event.d.ts +7 -0
- package/dist/browser/websocket/close-event.js +30 -0
- package/dist/browser/websocket/compression.d.ts +5 -0
- package/dist/browser/websocket/compression.js +124 -0
- package/dist/browser/websocket/conversion.d.ts +2 -0
- package/dist/browser/websocket/conversion.js +13 -0
- package/dist/browser/websocket/endpoint.d.ts +39 -0
- package/dist/browser/websocket/endpoint.js +379 -0
- package/dist/browser/websocket/frames.d.ts +21 -0
- package/dist/browser/websocket/frames.js +121 -0
- package/dist/browser/websocket/native.d.ts +14 -0
- package/dist/browser/websocket/native.js +226 -0
- package/dist/cloudflare/apis/cloudflare-node/index.js +11 -23
- package/dist/cloudflare/workers/worker-runtime.js +2 -1
- package/dist/compat/console/index.d.ts +35 -0
- package/dist/compat/console/index.js +92 -0
- package/dist/compat/crypto/LICENSE-3RD-PARTY.md +39 -0
- package/dist/compat/crypto/LICENSE-APACHE +177 -0
- package/dist/compat/crypto/LICENSE.boringssl +238 -0
- package/dist/compat/crypto/LICENSE.emscripten +102 -0
- package/dist/compat/crypto/LICENSE.musl +193 -0
- package/dist/compat/crypto/LICENSE.ncrypto +21 -0
- package/dist/compat/crypto/LICENSE.openssl +177 -0
- package/dist/compat/crypto/asymmetric.d.ts +13 -0
- package/dist/compat/crypto/asymmetric.js +312 -0
- package/dist/compat/crypto/brorand.cjs +74 -0
- package/dist/compat/crypto/brorand.d.cts +6 -0
- package/dist/compat/crypto/certificate.d.ts +14 -0
- package/dist/compat/crypto/certificate.js +66 -0
- package/dist/compat/crypto/cipher-handle.d.ts +27 -0
- package/dist/compat/crypto/cipher-handle.js +239 -0
- package/dist/compat/crypto/cipher-info.d.ts +12 -0
- package/dist/compat/crypto/cipher-info.js +324 -0
- package/dist/compat/crypto/constants.d.ts +62 -0
- package/dist/compat/crypto/constants.js +68 -0
- package/dist/compat/crypto/dh-handle.d.ts +17 -0
- package/dist/compat/crypto/dh-handle.js +180 -0
- package/dist/compat/crypto/dh.d.ts +53 -0
- package/dist/compat/crypto/dh.js +138 -0
- package/dist/compat/crypto/digest-stream.d.ts +15 -0
- package/dist/compat/crypto/digest-stream.js +213 -0
- package/dist/compat/crypto/digests.d.ts +3 -0
- package/dist/compat/crypto/digests.js +32 -0
- package/dist/compat/crypto/ecdh.d.ts +25 -0
- package/dist/compat/crypto/ecdh.js +109 -0
- package/dist/compat/crypto/hash-handle.d.ts +23 -0
- package/dist/compat/crypto/hash-handle.js +70 -0
- package/dist/compat/crypto/hash.d.ts +37 -0
- package/dist/compat/crypto/hash.js +218 -0
- package/dist/compat/crypto/hkdf.d.ts +2 -0
- package/dist/compat/crypto/hkdf.js +78 -0
- package/dist/compat/crypto/index.cjs +2 -0
- package/dist/compat/crypto/index.d.cts +169 -0
- package/dist/compat/crypto/index.d.ts +213 -0
- package/dist/compat/crypto/index.js +96 -0
- package/dist/compat/crypto/key-errors.d.ts +10 -0
- package/dist/compat/crypto/key-errors.js +17 -0
- package/dist/compat/crypto/key-export.d.ts +8 -0
- package/dist/compat/crypto/key-export.js +49 -0
- package/dist/compat/crypto/key-formats.d.ts +7 -0
- package/dist/compat/crypto/key-formats.js +251 -0
- package/dist/compat/crypto/key-options.d.ts +1 -0
- package/dist/compat/crypto/key-options.js +74 -0
- package/dist/compat/crypto/key-state.d.ts +10 -0
- package/dist/compat/crypto/key-state.js +4 -0
- package/dist/compat/crypto/keys.d.ts +58 -0
- package/dist/compat/crypto/keys.js +278 -0
- package/dist/compat/crypto/metadata.d.ts +13 -0
- package/dist/compat/crypto/metadata.js +109 -0
- package/dist/compat/crypto/native-cipher.d.ts +17 -0
- package/dist/compat/crypto/native-cipher.js +192 -0
- package/dist/compat/crypto/native-crypto.d.ts +81 -0
- package/dist/compat/crypto/native-crypto.js +681 -0
- package/dist/compat/crypto/pbkdf2-handle.d.ts +4 -0
- package/dist/compat/crypto/pbkdf2-handle.js +26 -0
- package/dist/compat/crypto/pbkdf2.d.ts +5 -0
- package/dist/compat/crypto/pbkdf2.js +60 -0
- package/dist/compat/crypto/prime.d.ts +19 -0
- package/dist/compat/crypto/prime.js +146 -0
- package/dist/compat/crypto/random.d.ts +18 -0
- package/dist/compat/crypto/random.js +203 -0
- package/dist/compat/crypto/rsa.d.ts +21 -0
- package/dist/compat/crypto/rsa.js +177 -0
- package/dist/compat/crypto/scrypt.d.ts +25 -0
- package/dist/compat/crypto/scrypt.js +152 -0
- package/dist/compat/crypto/sign-errors.d.ts +8 -0
- package/dist/compat/crypto/sign-errors.js +13 -0
- package/dist/compat/crypto/sign-handle.d.ts +22 -0
- package/dist/compat/crypto/sign-handle.js +149 -0
- package/dist/compat/crypto/signatures.d.ts +34 -0
- package/dist/compat/crypto/signatures.js +252 -0
- package/dist/compat/crypto/subtle-digest.d.ts +1 -0
- package/dist/compat/crypto/subtle-digest.js +56 -0
- package/dist/compat/crypto/symmetric.d.ts +45 -0
- package/dist/compat/crypto/symmetric.js +239 -0
- package/dist/compat/crypto/validation.d.ts +7 -0
- package/dist/compat/crypto/validation.js +46 -0
- package/dist/compat/crypto/webcrypto.d.ts +13 -0
- package/dist/compat/crypto/webcrypto.js +51 -0
- package/dist/compat/crypto/x509.d.ts +30 -0
- package/dist/compat/crypto/x509.js +407 -0
- package/dist/compat/events/errors.d.ts +8 -0
- package/dist/compat/events/errors.js +39 -0
- package/dist/compat/events/index.cjs +2 -0
- package/dist/compat/events/index.d.cts +2 -0
- package/dist/compat/events/index.d.ts +64 -0
- package/dist/compat/events/index.js +792 -0
- package/dist/compat/events/intrinsics.d.ts +1 -0
- package/dist/compat/events/intrinsics.js +2 -0
- package/dist/compat/fs/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/fs/LICENSE-APACHE +177 -0
- package/dist/compat/fs/directory-backend.d.ts +6 -0
- package/dist/compat/fs/directory-backend.js +51 -0
- package/dist/compat/fs/directory.d.ts +37 -0
- package/dist/compat/fs/directory.js +137 -0
- package/dist/compat/fs/embedded.d.ts +85 -0
- package/dist/compat/fs/embedded.js +260 -0
- package/dist/compat/fs/file-handle.d.ts +75 -0
- package/dist/compat/fs/file-handle.js +226 -0
- package/dist/compat/fs/glob-internal.d.ts +15 -0
- package/dist/compat/fs/glob-internal.js +417 -0
- package/dist/compat/fs/glob.d.ts +10 -0
- package/dist/compat/fs/glob.js +71 -0
- package/dist/compat/fs/index.d.ts +8 -82
- package/dist/compat/fs/index.js +736 -238
- package/dist/compat/fs/io-validation.d.ts +14 -0
- package/dist/compat/fs/io-validation.js +130 -0
- package/dist/compat/fs/io.d.ts +1 -0
- package/dist/compat/fs/io.js +282 -0
- package/dist/compat/fs/mode.d.ts +1 -0
- package/dist/compat/fs/mode.js +13 -0
- package/dist/compat/fs/promises/index.d.ts +3 -1
- package/dist/compat/fs/promises/index.js +1 -1
- package/dist/compat/fs/public-types.d.ts +120 -0
- package/dist/compat/fs/public-types.js +1 -0
- package/dist/compat/fs/stream-errors.d.ts +6 -0
- package/dist/compat/fs/stream-errors.js +8 -0
- package/dist/compat/fs/stream-utils.d.ts +16 -0
- package/dist/compat/fs/stream-utils.js +29 -0
- package/dist/compat/fs/streams.d.ts +104 -0
- package/dist/compat/fs/streams.js +794 -0
- package/dist/compat/fs/writable.d.ts +14 -0
- package/dist/compat/fs/writable.js +532 -0
- package/dist/compat/http/index.d.ts +11 -28
- package/dist/compat/http/index.js +81 -125
- package/dist/compat/http/server-options.d.ts +1 -0
- package/dist/compat/http/server-options.js +87 -0
- package/dist/compat/http/symbols.d.ts +5 -0
- package/dist/compat/http/symbols.js +9 -0
- package/dist/compat/http/unique-headers.d.ts +1 -0
- package/dist/compat/http/unique-headers.js +21 -0
- package/dist/compat/http-common/index.d.ts +37 -0
- package/dist/compat/http-common/index.js +43 -0
- package/dist/compat/http-outgoing/index.d.ts +14 -0
- package/dist/compat/http-outgoing/index.js +17 -0
- package/dist/compat/http-server/index.d.ts +18 -0
- package/dist/compat/http-server/index.js +26 -0
- package/dist/compat/https/index.d.ts +4 -2
- package/dist/compat/module/builtins.d.ts +1 -0
- package/dist/compat/module/builtins.js +101 -0
- package/dist/compat/module/index.d.ts +4 -2
- package/dist/compat/module/index.js +22 -17
- package/dist/compat/module/metadata.d.ts +44 -0
- package/dist/compat/module/metadata.js +127 -0
- package/dist/compat/net/internal-net.js +4 -0
- package/dist/compat/net/sockets.d.ts +5 -0
- package/dist/compat/net/sockets.js +153 -14
- package/dist/compat/net/validators.d.ts +1 -0
- package/dist/compat/net/validators.js +8 -0
- package/dist/compat/process/configuration.d.ts +113 -0
- package/dist/compat/process/configuration.js +115 -0
- package/dist/compat/process/directory.d.ts +4 -0
- package/dist/compat/process/directory.js +28 -0
- package/dist/compat/process/files.d.ts +3 -0
- package/dist/compat/process/files.js +10 -0
- package/dist/compat/process/index.cjs +2 -0
- package/dist/compat/process/index.d.cts +4 -0
- package/dist/compat/process/index.d.ts +20 -0
- package/dist/compat/process/index.js +113 -0
- package/dist/compat/process/metadata.d.ts +135 -0
- package/dist/compat/process/metadata.js +251 -0
- package/dist/compat/process/scheduling.d.ts +2 -0
- package/dist/compat/process/scheduling.js +60 -0
- package/dist/compat/process/state.d.ts +4 -0
- package/dist/compat/process/state.js +5 -0
- package/dist/compat/process/stdio.d.ts +18 -0
- package/dist/compat/process/stdio.js +66 -0
- package/dist/compat/stream/destroy.d.ts +1 -0
- package/dist/compat/stream/destroy.js +21 -1
- package/dist/compat/stream/readable.js +10 -2
- package/dist/compat/stream-web/LICENSE +22 -0
- package/dist/compat/stream-web/ponyfill.d.ts +1 -1
- package/dist/compat/stream-web/ponyfill.js +2369 -1775
- package/dist/compat/stream-web/runtime.d.ts +1 -1
- package/dist/compat/stream-web/runtime.js +3 -2
- package/dist/compat/stream-wrap/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/stream-wrap/LICENSE-APACHE +177 -0
- package/dist/compat/stream-wrap/index.d.ts +1 -0
- package/dist/compat/stream-wrap/index.js +1 -0
- package/dist/compat/tls/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/tls/LICENSE-APACHE +177 -0
- package/dist/compat/tls/constants.d.ts +7 -0
- package/dist/compat/tls/constants.js +14 -0
- package/dist/compat/tls/errors.d.ts +35 -0
- package/dist/compat/tls/errors.js +68 -0
- package/dist/compat/tls/helpers.d.ts +9 -0
- package/dist/compat/tls/helpers.js +207 -0
- package/dist/compat/tls/index.d.ts +26 -0
- package/dist/compat/tls/index.js +50 -0
- package/dist/compat/tls/jsstream.d.ts +19 -0
- package/dist/compat/tls/jsstream.js +196 -0
- package/dist/compat/tls/native-session.d.ts +3 -0
- package/dist/compat/tls/native-session.js +187 -0
- package/dist/compat/tls/wrap.d.ts +65 -0
- package/dist/compat/tls/wrap.js +541 -0
- package/dist/compat/tls-wrap/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/tls-wrap/LICENSE-APACHE +177 -0
- package/dist/compat/tls-wrap/index.d.ts +7 -0
- package/dist/compat/tls-wrap/index.js +3 -0
- package/dist/compat/util/index.js +43 -1
- package/dist/compat/util/inspect.js +5 -1
- package/dist/compat/util/types/index.d.ts +3 -0
- package/dist/compat/util/types/index.js +5 -0
- package/dist/compat/zlib/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/zlib/LICENSE-APACHE +177 -0
- package/dist/compat/zlib/LICENSE.brotli +19 -0
- package/dist/compat/zlib/LICENSE.emscripten +102 -0
- package/dist/compat/zlib/LICENSE.musl +193 -0
- package/dist/compat/zlib/LICENSE.zlib +22 -0
- package/dist/compat/zlib/LICENSE.zstd +30 -0
- package/dist/compat/zlib/classic-base.cjs +600 -0
- package/dist/compat/zlib/classic-base.d.cts +39 -0
- package/dist/compat/zlib/classic-binding.d.ts +28 -0
- package/dist/compat/zlib/classic-binding.js +105 -0
- package/dist/compat/zlib/classic.d.ts +44 -0
- package/dist/compat/zlib/classic.js +199 -0
- package/dist/compat/zlib/codec-binding.d.ts +33 -0
- package/dist/compat/zlib/codec-binding.js +141 -0
- package/dist/compat/zlib/compression.d.ts +26 -0
- package/dist/compat/zlib/compression.js +170 -0
- package/dist/compat/zlib/constants.d.ts +172 -0
- package/dist/compat/zlib/constants.js +173 -0
- package/dist/compat/zlib/errors.d.ts +21 -0
- package/dist/compat/zlib/errors.js +32 -0
- package/dist/compat/zlib/index.d.ts +544 -0
- package/dist/compat/zlib/index.js +194 -0
- package/dist/compat/zlib/input.d.ts +16 -0
- package/dist/compat/zlib/input.js +132 -0
- package/dist/compat/zlib/native-codecs.d.ts +24 -0
- package/dist/compat/zlib/native-codecs.js +180 -0
- package/dist/compat/zlib/native-zlib.d.ts +5 -0
- package/dist/compat/zlib/native-zlib.js +52 -0
- package/dist/compat/zlib/public-types.d.ts +48 -0
- package/dist/compat/zlib/public-types.js +1 -0
- package/dist/compat/zlib/validators.d.ts +3 -0
- package/dist/compat/zlib/validators.js +18 -0
- package/dist/shared/buffer-source.d.ts +5 -0
- package/dist/shared/buffer-source.js +70 -0
- package/dist/shared/globals/inject.d.ts +2 -1
- package/dist/shared/globals/inject.js +2 -1
- package/dist/shared/globals/platform.d.ts +8 -0
- package/dist/shared/globals/platform.js +1 -0
- package/dist/shared/globals/runtime.d.ts +1 -2
- package/dist/shared/globals/runtime.js +1 -2
- package/dist/shared/globals/web.js +5 -0
- package/dist/shared/request-context.d.ts +2 -0
- package/dist/shared/request-context.js +11 -0
- package/dist/shared/request-scope.d.ts +4 -0
- package/dist/shared/request-scope.js +14 -0
- package/dist/tooling/async.js +36 -14
- package/dist/tooling/shared.d.ts +1 -0
- package/dist/tooling/shared.js +26 -1
- package/dist/tooling/vite.js +8 -3
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +92 -13
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +4 -2
- package/native/ios/NetworkBridge.swift +11 -1
- package/native/ios/SocketBridge.swift +37 -2
- package/native/ios/WorkersCapacitorPlugin.swift +4 -0
- package/package.json +4 -2
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { signatureDigest } from "./digests.js";
|
|
2
|
+
import { curveName, generateDh, deriveDh, decodeKey } from "./native-cipher.js";
|
|
3
|
+
import { validateExportOptions } from "./key-options.js";
|
|
4
|
+
import { ERR_INCOMPATIBLE_OPTION_PAIR, ERR_MISSING_OPTION, } from "./key-errors.js";
|
|
5
|
+
import { Buffer } from "node:buffer";
|
|
6
|
+
import { NativeKey, nativeTimingEqual } from "./native-crypto.js";
|
|
7
|
+
import { importJwk } from "./key-formats.js";
|
|
8
|
+
import { create, KeyObject, } from "./keys.js";
|
|
9
|
+
import { keyStates } from "./key-state.js";
|
|
10
|
+
import { bytes, isAnyBuffer } from "./validation.js";
|
|
11
|
+
import { validateObject, validateString, validateOneOf, validateFunction, validateUint32, validateInt32, } from "../net/validators.js";
|
|
12
|
+
import { ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE } from "../net/errors.js";
|
|
13
|
+
function handle(key) {
|
|
14
|
+
const value = keyStates.get(key)?.asymmetric;
|
|
15
|
+
if (!value)
|
|
16
|
+
throw Object.assign(new Error("Synchronous access to opaque host key material is unavailable"), { code: "ERR_METHOD_NOT_IMPLEMENTED" });
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function input(value, privateKey) {
|
|
20
|
+
if (value == null)
|
|
21
|
+
throw new ERR_INVALID_ARG_TYPE("key", ["ArrayBuffer", "Buffer", "TypedArray", "DataView", "string", "object"], value);
|
|
22
|
+
const options = typeof value === "string" || isAnyBuffer(value) || ArrayBuffer.isView(value)
|
|
23
|
+
? { key: value }
|
|
24
|
+
: value;
|
|
25
|
+
const { key: data, encoding = "utf8", format = "pem", type, passphrase, } = options;
|
|
26
|
+
if (data == null ||
|
|
27
|
+
data instanceof KeyObject ||
|
|
28
|
+
data instanceof globalThis.CryptoKey)
|
|
29
|
+
throw new ERR_INVALID_ARG_TYPE("options.key", ["ArrayBuffer", "Buffer", "TypedArray", "DataView", "string", "object"], data);
|
|
30
|
+
if (typeof data === "object" &&
|
|
31
|
+
!isAnyBuffer(data) &&
|
|
32
|
+
!ArrayBuffer.isView(data))
|
|
33
|
+
return importJwk(data, privateKey);
|
|
34
|
+
if (typeof data !== "string" &&
|
|
35
|
+
!isAnyBuffer(data) &&
|
|
36
|
+
!ArrayBuffer.isView(data))
|
|
37
|
+
throw new ERR_INVALID_ARG_TYPE("key", ["ArrayBuffer", "Buffer", "TypedArray", "DataView", "string", "object"], value);
|
|
38
|
+
validateOneOf(format, "format", ["pem", "der"]);
|
|
39
|
+
if (type !== undefined)
|
|
40
|
+
validateOneOf(type, "type", privateKey ? ["pkcs1", "pkcs8", "sec1"] : ["pkcs1", "spki"]);
|
|
41
|
+
const raw = typeof data === "string" ? Buffer.from(data, encoding) : bytes(data, "key");
|
|
42
|
+
const password = passphrase == null
|
|
43
|
+
? undefined
|
|
44
|
+
: typeof passphrase === "string"
|
|
45
|
+
? Buffer.from(passphrase, encoding)
|
|
46
|
+
: bytes(passphrase, "passphrase");
|
|
47
|
+
const decoded = decodeKey(raw, format === "pem", privateKey, type, password);
|
|
48
|
+
try {
|
|
49
|
+
return NativeKey.parse(decoded.data, false, decoded.privateKey);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
decoded.data.fill(0);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function createPrivateKey(value) {
|
|
56
|
+
return create("private", {
|
|
57
|
+
asymmetric: input(value, true),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export function createPublicKey(value) {
|
|
61
|
+
if (keyStates.has(value)) {
|
|
62
|
+
if (value.type !== "private")
|
|
63
|
+
throw new ERR_INVALID_ARG_TYPE("key", "PrivateKeyObject", value);
|
|
64
|
+
return create("public", {
|
|
65
|
+
asymmetric: handle(value),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return create("public", {
|
|
69
|
+
asymmetric: input(value, false),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function generateKeyPairSync(type, options = {}) {
|
|
73
|
+
validateOneOf(type, "type", ["rsa", "ec", "ed25519", "x25519", "dh"]);
|
|
74
|
+
validateObject(options, "options");
|
|
75
|
+
const { modulusLength, publicExponent = 65537, namedCurve, prime, primeLength, generator, group, groupName, paramEncoding = "named", publicKeyEncoding, privateKeyEncoding, } = options;
|
|
76
|
+
if (publicKeyEncoding !== undefined)
|
|
77
|
+
validateExportOptions(publicKeyEncoding, "public", "options.publicKeyEncoding");
|
|
78
|
+
if (privateKeyEncoding !== undefined)
|
|
79
|
+
validateExportOptions(privateKeyEncoding, "private", "options.privateKeyEncoding", type);
|
|
80
|
+
let key;
|
|
81
|
+
if (type === "rsa") {
|
|
82
|
+
validateUint32(modulusLength, "options.modulusLength");
|
|
83
|
+
validateUint32(publicExponent, "options.publicExponent");
|
|
84
|
+
if (modulusLength > 16384)
|
|
85
|
+
throw new RangeError("RSA modulusLength exceeds maximum (16384)");
|
|
86
|
+
if (modulusLength < 256)
|
|
87
|
+
throw new Error("Failed to set modulus length");
|
|
88
|
+
if (modulusLength < 512 || publicExponent < 3 || publicExponent % 2 === 0)
|
|
89
|
+
throw new Error("Failed to generate key");
|
|
90
|
+
try {
|
|
91
|
+
key = NativeKey.generate("RSA", modulusLength & ~127, undefined, publicExponent);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
throw new Error("Failed to generate key");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (type === "ec") {
|
|
98
|
+
validateString(namedCurve, "options.namedCurve");
|
|
99
|
+
validateOneOf(paramEncoding, "options.paramEncoding", [
|
|
100
|
+
"named",
|
|
101
|
+
"explicit",
|
|
102
|
+
]);
|
|
103
|
+
key = NativeKey.generate("EC", 0, curveName(namedCurve));
|
|
104
|
+
key.ecEncoding = paramEncoding === "named" ? 1 : 0;
|
|
105
|
+
}
|
|
106
|
+
else if (type === "dh") {
|
|
107
|
+
if (generator != null)
|
|
108
|
+
validateInt32(generator, "options.generator", 0);
|
|
109
|
+
if (group != null || groupName != null) {
|
|
110
|
+
for (const [name, value] of [
|
|
111
|
+
["prime", prime],
|
|
112
|
+
["primeLength", primeLength],
|
|
113
|
+
["generator", generator],
|
|
114
|
+
])
|
|
115
|
+
if (value != null)
|
|
116
|
+
throw new ERR_INCOMPATIBLE_OPTION_PAIR("group", name);
|
|
117
|
+
const selected = group || groupName;
|
|
118
|
+
validateString(selected, "options.group");
|
|
119
|
+
const groups = Object.assign(Object.create(null), {
|
|
120
|
+
modp5: "modp_1536",
|
|
121
|
+
modp14: "modp_2048",
|
|
122
|
+
modp15: "modp_3072",
|
|
123
|
+
modp16: "modp_4096",
|
|
124
|
+
modp17: "modp_6144",
|
|
125
|
+
modp18: "modp_8192",
|
|
126
|
+
});
|
|
127
|
+
const nativeGroup = groups[selected.toLowerCase()];
|
|
128
|
+
if (!nativeGroup)
|
|
129
|
+
throw new Error("Invalid or unsupported group");
|
|
130
|
+
key = NativeKey.generate("DH", 0, nativeGroup);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
if (prime != null) {
|
|
134
|
+
if (primeLength != null)
|
|
135
|
+
throw new ERR_INCOMPATIBLE_OPTION_PAIR("prime", "primeLength");
|
|
136
|
+
if (!ArrayBuffer.isView(prime) && !isAnyBuffer(prime))
|
|
137
|
+
throw new ERR_INVALID_ARG_TYPE("options.prime", ["Buffer", "TypedArray", "ArrayBuffer"], prime);
|
|
138
|
+
}
|
|
139
|
+
else if (primeLength != null)
|
|
140
|
+
validateInt32(primeLength, "options.primeLength", 0);
|
|
141
|
+
else
|
|
142
|
+
throw new ERR_MISSING_OPTION("At least one of the group, prime, or primeLength options");
|
|
143
|
+
if (prime) {
|
|
144
|
+
const data = bytes(prime, "options.prime");
|
|
145
|
+
if (data.byteLength > 1024)
|
|
146
|
+
throw new RangeError("DH prime exceeds maximum size");
|
|
147
|
+
const components = generateDh(data, generator ?? 2);
|
|
148
|
+
try {
|
|
149
|
+
key = NativeKey.generateDh(data, generator ?? 2, components);
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
components.fill(0);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else
|
|
156
|
+
throw new Error("Generating DH keys from a prime length is not yet implemented");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else
|
|
160
|
+
key = NativeKey.generate(type.toUpperCase());
|
|
161
|
+
const privateKey = create("private", { asymmetric: key });
|
|
162
|
+
// Workers constructs a separate public-only EC key. Other generated pairs
|
|
163
|
+
// retain the same key material under their public and private wrappers.
|
|
164
|
+
const publicKey = create("public", {
|
|
165
|
+
asymmetric: type === "ec"
|
|
166
|
+
? NativeKey.parse(key.export(false, false, "spki"), false, false)
|
|
167
|
+
: key,
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
publicKey: publicKeyEncoding !== undefined
|
|
171
|
+
? publicKey.export(publicKeyEncoding)
|
|
172
|
+
: publicKey,
|
|
173
|
+
privateKey: privateKeyEncoding !== undefined
|
|
174
|
+
? privateKey.export(privateKeyEncoding)
|
|
175
|
+
: privateKey,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export function generateKeyPair(type, options, callback) {
|
|
179
|
+
validateFunction(callback, "callback");
|
|
180
|
+
let result, failure;
|
|
181
|
+
try {
|
|
182
|
+
result = generateKeyPairSync(type, options);
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
failure = error;
|
|
186
|
+
}
|
|
187
|
+
queueMicrotask(() => failure
|
|
188
|
+
? callback(failure)
|
|
189
|
+
: callback(null, result.publicKey, result.privateKey));
|
|
190
|
+
}
|
|
191
|
+
Object.defineProperty(generateKeyPair, Symbol.for("nodejs.util.promisify.custom.args"), { value: ["publicKey", "privateKey"], enumerable: false });
|
|
192
|
+
function optionsOf(value) {
|
|
193
|
+
return value &&
|
|
194
|
+
typeof value === "object" &&
|
|
195
|
+
!keyStates.has(value) &&
|
|
196
|
+
"key" in value
|
|
197
|
+
? value
|
|
198
|
+
: { key: value };
|
|
199
|
+
}
|
|
200
|
+
function operationKey(value, privateKey) {
|
|
201
|
+
const key = optionsOf(value).key;
|
|
202
|
+
if (keyStates.has(key)) {
|
|
203
|
+
if (key.type === "secret" || (privateKey && key.type !== "private"))
|
|
204
|
+
throw new TypeError("Invalid key type");
|
|
205
|
+
return key;
|
|
206
|
+
}
|
|
207
|
+
return privateKey ? createPrivateKey(value) : createPublicKey(value);
|
|
208
|
+
}
|
|
209
|
+
function digestName(algorithm) {
|
|
210
|
+
if (algorithm == null)
|
|
211
|
+
return null;
|
|
212
|
+
validateString(algorithm, "algorithm");
|
|
213
|
+
return algorithm;
|
|
214
|
+
}
|
|
215
|
+
export function sign(algorithm, data, key, callback) {
|
|
216
|
+
if (callback !== undefined)
|
|
217
|
+
validateFunction(callback, "callback");
|
|
218
|
+
const digest = digestName(algorithm), raw = bytes(data, "data");
|
|
219
|
+
const execute = () => {
|
|
220
|
+
const options = optionsOf(key), native = handle(operationKey(key, true));
|
|
221
|
+
if (native.type === "dsa")
|
|
222
|
+
throw new Error("Signing with DSA keys is not currently supported");
|
|
223
|
+
const normalized = digest === null ? null : signatureDigest(digest);
|
|
224
|
+
if (native.type === "x25519" ||
|
|
225
|
+
(native.type === "ed25519" && normalized !== null) ||
|
|
226
|
+
(native.type !== "ed25519" && normalized === null))
|
|
227
|
+
throw new Error("Failed to initialize signing context");
|
|
228
|
+
return Buffer.from(native.sign(normalized, raw, 0, -1, options.dsaEncoding === "ieee-p1363"));
|
|
229
|
+
};
|
|
230
|
+
if (callback === undefined)
|
|
231
|
+
return execute();
|
|
232
|
+
let result, failure;
|
|
233
|
+
try {
|
|
234
|
+
result = execute();
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
failure = error;
|
|
238
|
+
}
|
|
239
|
+
queueMicrotask(() => callback(failure ?? null, result));
|
|
240
|
+
}
|
|
241
|
+
export function verify(algorithm, data, key, signature, callback) {
|
|
242
|
+
if (callback !== undefined)
|
|
243
|
+
validateFunction(callback, "callback");
|
|
244
|
+
const digest = digestName(algorithm), raw = bytes(data, "data"), sig = bytes(signature, "signature");
|
|
245
|
+
const execute = () => {
|
|
246
|
+
const options = optionsOf(key), native = handle(operationKey(key, false));
|
|
247
|
+
if (native.type === "dsa")
|
|
248
|
+
throw new Error("Verifying with DSA keys is not currently supported");
|
|
249
|
+
const normalized = digest === null ? null : signatureDigest(digest);
|
|
250
|
+
if (native.type === "x25519" ||
|
|
251
|
+
(native.type === "ed25519" && normalized !== null) ||
|
|
252
|
+
(native.type !== "ed25519" && normalized === null))
|
|
253
|
+
throw new Error("Failed to initialize verification context");
|
|
254
|
+
return native.verify(normalized, raw, sig, 0, -1, options.dsaEncoding === "ieee-p1363");
|
|
255
|
+
};
|
|
256
|
+
if (callback === undefined)
|
|
257
|
+
return execute();
|
|
258
|
+
let result, failure;
|
|
259
|
+
try {
|
|
260
|
+
result = execute();
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
failure = error;
|
|
264
|
+
}
|
|
265
|
+
queueMicrotask(() => callback(failure ?? null, result));
|
|
266
|
+
}
|
|
267
|
+
export function diffieHellman(options) {
|
|
268
|
+
validateObject(options, "options");
|
|
269
|
+
const { publicKey, privateKey } = options;
|
|
270
|
+
if (!keyStates.has(publicKey))
|
|
271
|
+
throw new ERR_INVALID_ARG_TYPE("options.publicKey", "KeyObject", publicKey);
|
|
272
|
+
if (!keyStates.has(privateKey))
|
|
273
|
+
throw new ERR_INVALID_ARG_TYPE("options.privateKey", "KeyObject", privateKey);
|
|
274
|
+
if (publicKey.type !== "public")
|
|
275
|
+
throw new ERR_INVALID_ARG_TYPE("options.publicKey", "public key", publicKey);
|
|
276
|
+
if (privateKey.type !== "private")
|
|
277
|
+
throw new ERR_INVALID_ARG_TYPE("options.privateKey", "private key", privateKey);
|
|
278
|
+
if (publicKey.asymmetricKeyType !== privateKey.asymmetricKeyType)
|
|
279
|
+
throw new ERR_INVALID_ARG_VALUE("options.publicKey.asymmetricKeyType", publicKey.asymmetricKeyType, "must equal privateKey.asymmetricKeyType");
|
|
280
|
+
const publicHandle = handle(publicKey), privateHandle = handle(privateKey);
|
|
281
|
+
// The pinned workerd crypto-keys.c++ passes the public key as the first
|
|
282
|
+
// DHPointer::stateless argument. Preserve its observable failure rather than
|
|
283
|
+
// silently substituting standalone Node behavior.
|
|
284
|
+
try {
|
|
285
|
+
if (publicHandle.type === "dh") {
|
|
286
|
+
for (const name of ["p", "g"])
|
|
287
|
+
if (!Buffer.from(publicHandle.parameter(name)).equals(Buffer.from(privateHandle.parameter(name))))
|
|
288
|
+
throw new Error("Failed to derive shared diffie-hellman secret");
|
|
289
|
+
const secret = publicHandle.parameter("priv");
|
|
290
|
+
try {
|
|
291
|
+
return Buffer.from(deriveDh(publicHandle.parameter("p"), publicHandle.parameter("g"), secret, privateHandle.parameter("pub")));
|
|
292
|
+
}
|
|
293
|
+
finally {
|
|
294
|
+
secret.fill(0);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return Buffer.from(publicHandle.derive(privateHandle));
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
throw new Error("Failed to derive shared diffie-hellman secret");
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
export function timingSafeEqual(a, b) {
|
|
304
|
+
if (!(a instanceof ArrayBuffer) && !ArrayBuffer.isView(a))
|
|
305
|
+
throw new ERR_INVALID_ARG_TYPE("buf1", ["ArrayBuffer", "Buffer", "TypedArray", "DataView"], a);
|
|
306
|
+
if (!(b instanceof ArrayBuffer) && !ArrayBuffer.isView(b))
|
|
307
|
+
throw new ERR_INVALID_ARG_TYPE("buf2", ["ArrayBuffer", "Buffer", "TypedArray", "DataView"], b);
|
|
308
|
+
const left = bytes(a, "buf1"), right = bytes(b, "buf2");
|
|
309
|
+
if (left.length !== right.length)
|
|
310
|
+
throw Object.assign(new RangeError("Input buffers must have the same byte length"), { code: "ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH" });
|
|
311
|
+
return nativeTimingEqual(left, right);
|
|
312
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Browser-only adaptation of brorand 1.1.0.
|
|
3
|
+
|
|
4
|
+
This software is licensed under the MIT License.
|
|
5
|
+
|
|
6
|
+
Copyright Fedor Indutny, 2014.
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
copy of this software and associated documentation files (the
|
|
10
|
+
"Software"), to deal in the Software without restriction, including
|
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
13
|
+
persons to whom the Software is furnished to do so, subject to the
|
|
14
|
+
following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included
|
|
17
|
+
in all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
22
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
25
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
*/
|
|
28
|
+
var r;
|
|
29
|
+
module.exports = function rand(len) {
|
|
30
|
+
if (!r)
|
|
31
|
+
r = new Rand(null);
|
|
32
|
+
return r.generate(len);
|
|
33
|
+
};
|
|
34
|
+
function Rand(rand) {
|
|
35
|
+
this.rand = rand;
|
|
36
|
+
}
|
|
37
|
+
module.exports.Rand = Rand;
|
|
38
|
+
Rand.prototype.generate = function generate(len) {
|
|
39
|
+
return this._rand(len);
|
|
40
|
+
};
|
|
41
|
+
// Emulate crypto API using randy
|
|
42
|
+
Rand.prototype._rand = function _rand(n) {
|
|
43
|
+
if (this.rand.getBytes)
|
|
44
|
+
return this.rand.getBytes(n);
|
|
45
|
+
var res = new Uint8Array(n);
|
|
46
|
+
for (var i = 0; i < res.length; i++)
|
|
47
|
+
res[i] = this.rand.getByte();
|
|
48
|
+
return res;
|
|
49
|
+
};
|
|
50
|
+
if (typeof self === "object") {
|
|
51
|
+
if (self.crypto && self.crypto.getRandomValues) {
|
|
52
|
+
// Modern browsers
|
|
53
|
+
Rand.prototype._rand = function _rand(n) {
|
|
54
|
+
var arr = new Uint8Array(n);
|
|
55
|
+
self.crypto.getRandomValues(arr);
|
|
56
|
+
return arr;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
else if (self.msCrypto && self.msCrypto.getRandomValues) {
|
|
60
|
+
// IE
|
|
61
|
+
Rand.prototype._rand = function _rand(n) {
|
|
62
|
+
var arr = new Uint8Array(n);
|
|
63
|
+
self.msCrypto.getRandomValues(arr);
|
|
64
|
+
return arr;
|
|
65
|
+
};
|
|
66
|
+
// Safari's WebWorkers do not have `crypto`
|
|
67
|
+
}
|
|
68
|
+
else if (typeof window === "object") {
|
|
69
|
+
// Old junk
|
|
70
|
+
Rand.prototype._rand = function () {
|
|
71
|
+
throw new Error("Not implemented yet");
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
export declare function verifySpkac(spkac: Buffer | ArrayBuffer | ArrayBufferView | string, encoding?: string): boolean;
|
|
3
|
+
export declare function exportPublicKey(spkac: Buffer | ArrayBuffer | ArrayBufferView | string, encoding?: string): Buffer;
|
|
4
|
+
export declare function exportChallenge(spkac: Buffer | ArrayBuffer | ArrayBufferView | string, encoding?: string): Buffer;
|
|
5
|
+
export declare class Certificate {
|
|
6
|
+
constructor();
|
|
7
|
+
verifySpkac: typeof verifySpkac;
|
|
8
|
+
exportPublicKey: typeof exportPublicKey;
|
|
9
|
+
exportChallenge: typeof exportChallenge;
|
|
10
|
+
static verifySpkac: typeof verifySpkac;
|
|
11
|
+
static exportPublicKey: typeof exportPublicKey;
|
|
12
|
+
static exportChallenge: typeof exportChallenge;
|
|
13
|
+
}
|
|
14
|
+
export declare function Certificate(this: unknown): Certificate;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
3
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
4
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
7
|
+
//
|
|
8
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
// copy of this software and associated documentation files (the
|
|
10
|
+
// "Software"), to deal in the Software without restriction, including
|
|
11
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
13
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
14
|
+
// following conditions:
|
|
15
|
+
//
|
|
16
|
+
// The above copyright notice and this permission notice shall be included
|
|
17
|
+
// in all copies or substantial portions of the Software.
|
|
18
|
+
//
|
|
19
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
22
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
25
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
import { nativeSpkac } from "./native-crypto.js";
|
|
27
|
+
import { bytes } from "./validation.js";
|
|
28
|
+
import { isAnyArrayBuffer } from "../util/types/index.js";
|
|
29
|
+
const cryptoImpl = {
|
|
30
|
+
verifySpkac: (data) => nativeSpkac(data, 0),
|
|
31
|
+
exportPublicKey: (data) => nativeSpkac(data, 1),
|
|
32
|
+
exportChallenge: (data) => nativeSpkac(data, 2),
|
|
33
|
+
};
|
|
34
|
+
import { Buffer } from "node:buffer";
|
|
35
|
+
function getArrayBufferOrView(value, name, encoding) {
|
|
36
|
+
if (typeof value === "string")
|
|
37
|
+
return Buffer.from(value, encoding === "buffer" ? undefined : encoding);
|
|
38
|
+
if (isAnyArrayBuffer(value))
|
|
39
|
+
return new Uint8Array(value);
|
|
40
|
+
return bytes(value, name);
|
|
41
|
+
}
|
|
42
|
+
export function verifySpkac(spkac, encoding) {
|
|
43
|
+
return cryptoImpl.verifySpkac(getArrayBufferOrView(spkac, "spkac", encoding));
|
|
44
|
+
}
|
|
45
|
+
export function exportPublicKey(spkac, encoding) {
|
|
46
|
+
const ret = cryptoImpl.exportPublicKey(getArrayBufferOrView(spkac, "spkac", encoding));
|
|
47
|
+
return ret ? Buffer.from(ret) : Buffer.alloc(0);
|
|
48
|
+
}
|
|
49
|
+
export function exportChallenge(spkac, encoding) {
|
|
50
|
+
const ret = cryptoImpl.exportChallenge(getArrayBufferOrView(spkac, "spkac", encoding));
|
|
51
|
+
return ret ? Buffer.from(ret) : Buffer.alloc(0);
|
|
52
|
+
}
|
|
53
|
+
// For backwards compatibility reasons, this cannot be converted into a
|
|
54
|
+
// ES6 Class.
|
|
55
|
+
export function Certificate() {
|
|
56
|
+
if (!(this instanceof Certificate)) {
|
|
57
|
+
return new Certificate();
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
Certificate.prototype.verifySpkac = verifySpkac;
|
|
62
|
+
Certificate.prototype.exportPublicKey = exportPublicKey;
|
|
63
|
+
Certificate.prototype.exportChallenge = exportChallenge;
|
|
64
|
+
Certificate.exportChallenge = exportChallenge;
|
|
65
|
+
Certificate.exportPublicKey = exportPublicKey;
|
|
66
|
+
Certificate.verifySpkac = verifySpkac;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class CipherHandle {
|
|
2
|
+
private pointer;
|
|
3
|
+
private aead;
|
|
4
|
+
private auth;
|
|
5
|
+
private mode;
|
|
6
|
+
private block;
|
|
7
|
+
private iv;
|
|
8
|
+
private aad?;
|
|
9
|
+
private tag?;
|
|
10
|
+
private tagLength?;
|
|
11
|
+
private tagPassed;
|
|
12
|
+
private updated;
|
|
13
|
+
private decrypt;
|
|
14
|
+
constructor(direction: number, algorithm: string, key: unknown, iv: ArrayBuffer | ArrayBufferView, tagLength?: number);
|
|
15
|
+
private dispose;
|
|
16
|
+
private passTag;
|
|
17
|
+
update(value: ArrayBuffer | ArrayBufferView): Uint8Array<ArrayBufferLike>;
|
|
18
|
+
final(): Uint8Array<ArrayBufferLike>;
|
|
19
|
+
setAAD(value: ArrayBuffer | ArrayBufferView, plaintextLength?: number): void;
|
|
20
|
+
setAutoPadding(value: boolean): void;
|
|
21
|
+
setAuthTag(value: ArrayBuffer | ArrayBufferView): void;
|
|
22
|
+
getAuthTag(): Uint8Array<ArrayBufferLike>;
|
|
23
|
+
}
|
|
24
|
+
declare const _default: {
|
|
25
|
+
newHandle: (...args: ConstructorParameters<typeof CipherHandle>) => CipherHandle;
|
|
26
|
+
};
|
|
27
|
+
export default _default;
|