cf-workers-native 0.1.4 → 0.1.5
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/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/isolated/transport.js +3 -2
- package/dist/browser/request/index.js +3 -2
- 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 +19 -0
- package/dist/compat/crypto/LICENSE-APACHE +177 -0
- package/dist/compat/crypto/LICENSE.emscripten +102 -0
- package/dist/compat/crypto/LICENSE.musl +193 -0
- package/dist/compat/crypto/LICENSE.openssl +177 -0
- package/dist/compat/crypto/asymmetric.d.ts +13 -0
- package/dist/compat/crypto/asymmetric.js +239 -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/ecdh.d.ts +15 -0
- package/dist/compat/crypto/ecdh.js +109 -0
- package/dist/compat/crypto/hkdf.d.ts +2 -0
- package/dist/compat/crypto/hkdf.js +52 -0
- package/dist/compat/crypto/index.cjs +2 -0
- package/dist/compat/crypto/index.d.cts +2 -0
- package/dist/compat/crypto/index.d.ts +30 -0
- package/dist/compat/crypto/index.js +83 -0
- package/dist/compat/crypto/key-formats.d.ts +6 -0
- package/dist/compat/crypto/key-formats.js +120 -0
- package/dist/compat/crypto/key-state.d.ts +9 -0
- package/dist/compat/crypto/key-state.js +4 -0
- package/dist/compat/crypto/keys.d.ts +50 -0
- package/dist/compat/crypto/keys.js +209 -0
- package/dist/compat/crypto/metadata.d.ts +4 -0
- package/dist/compat/crypto/metadata.js +22 -0
- package/dist/compat/crypto/native-crypto.d.ts +68 -0
- package/dist/compat/crypto/native-crypto.js +569 -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 +7 -0
- package/dist/compat/crypto/random.js +123 -0
- package/dist/compat/crypto/rsa.d.ts +5 -0
- package/dist/compat/crypto/rsa.js +173 -0
- package/dist/compat/crypto/scrypt.d.ts +25 -0
- package/dist/compat/crypto/scrypt.js +150 -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 +105 -0
- package/dist/compat/crypto/signatures.d.ts +28 -0
- package/dist/compat/crypto/signatures.js +252 -0
- package/dist/compat/crypto/symmetric.d.ts +29 -0
- package/dist/compat/crypto/symmetric.js +104 -0
- package/dist/compat/crypto/validation.d.ts +3 -0
- package/dist/compat/crypto/validation.js +19 -0
- package/dist/compat/crypto/x509.d.ts +30 -0
- package/dist/compat/crypto/x509.js +406 -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/embedded.d.ts +85 -0
- package/dist/compat/fs/embedded.js +255 -0
- package/dist/compat/fs/index.d.ts +7 -84
- package/dist/compat/fs/index.js +218 -252
- 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 +1 -1
- package/dist/compat/fs/promises/index.js +1 -1
- package/dist/compat/fs/writable.d.ts +6 -0
- package/dist/compat/fs/writable.js +142 -0
- package/dist/compat/http/symbols.d.ts +5 -0
- package/dist/compat/http/symbols.js +9 -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 +13 -0
- package/dist/compat/http-outgoing/index.js +32 -0
- package/dist/compat/http-server/index.d.ts +18 -0
- package/dist/compat/http-server/index.js +107 -0
- 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 +74 -13
- package/dist/compat/process/index.cjs +2 -0
- package/dist/compat/process/index.d.cts +4 -0
- package/dist/compat/process/index.d.ts +18 -0
- package/dist/compat/process/index.js +140 -0
- package/dist/compat/process/metadata.d.ts +135 -0
- package/dist/compat/process/metadata.js +251 -0
- package/dist/compat/process/state.d.ts +4 -0
- package/dist/compat/process/state.js +4 -0
- 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 +186 -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 +544 -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/types/index.d.ts +3 -0
- package/dist/compat/util/types/index.js +5 -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.zstd +30 -0
- package/dist/compat/zlib/compression.d.ts +55 -0
- package/dist/compat/zlib/compression.js +259 -0
- package/dist/compat/zlib/constants.d.ts +172 -0
- package/dist/compat/zlib/constants.js +173 -0
- package/dist/compat/zlib/index.d.ts +180 -0
- package/dist/compat/zlib/index.js +177 -0
- package/dist/compat/zlib/native-codecs.d.ts +17 -0
- package/dist/compat/zlib/native-codecs.js +168 -0
- package/dist/shared/globals/inject.d.ts +2 -1
- package/dist/shared/globals/inject.js +2 -1
- package/dist/shared/globals/runtime.d.ts +1 -2
- package/dist/shared/globals/runtime.js +1 -2
- package/dist/shared/request-scope.d.ts +4 -0
- package/dist/shared/request-scope.js +11 -0
- package/dist/tooling/async.js +36 -14
- package/dist/tooling/shared.d.ts +1 -0
- package/dist/tooling/shared.js +20 -1
- package/dist/tooling/vite.js +4 -3
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +56 -8
- 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 +3 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { exportJwk } from "./key-formats.js";
|
|
2
|
+
// API behavior follows workerd@5358e3d337336eaf696a48bc1563d808b10feba5
|
|
3
|
+
// crypto_keys.ts (Apache-2.0 and Node MIT). Host CryptoKey export is an explicit
|
|
4
|
+
// synchronous-engine boundary; adapter-created secret keys own copied bytes.
|
|
5
|
+
import { Buffer } from "node:buffer";
|
|
6
|
+
import { keyStates } from "./key-state.js";
|
|
7
|
+
import { bytes, validateInteger } from "./validation.js";
|
|
8
|
+
import { validateObject, validateString, validateOneOf, } from "../net/validators.js";
|
|
9
|
+
import { ERR_INVALID_ARG_TYPE } from "../net/errors.js";
|
|
10
|
+
function state(value) {
|
|
11
|
+
const result = keyStates.get(value);
|
|
12
|
+
if (!result)
|
|
13
|
+
throw new ERR_INVALID_ARG_TYPE("key", "KeyObject", value);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
function boundary() {
|
|
17
|
+
throw Object.assign(new Error("Synchronous export of a host CryptoKey is unavailable in this WebView runtime"), { code: "ERR_METHOD_NOT_IMPLEMENTED" });
|
|
18
|
+
}
|
|
19
|
+
export function create(type, value) {
|
|
20
|
+
const Class = type === "secret"
|
|
21
|
+
? SecretKeyObject
|
|
22
|
+
: type === "public"
|
|
23
|
+
? PublicKeyObject
|
|
24
|
+
: PrivateKeyObject;
|
|
25
|
+
const result = Object.create(Class.prototype);
|
|
26
|
+
keyStates.set(result, { type, ...value });
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
export class KeyObject {
|
|
30
|
+
constructor() {
|
|
31
|
+
throw new Error("Illegal constructor");
|
|
32
|
+
}
|
|
33
|
+
static from(key) {
|
|
34
|
+
if (!(key instanceof globalThis.CryptoKey))
|
|
35
|
+
throw new ERR_INVALID_ARG_TYPE("key", "CryptoKey", key);
|
|
36
|
+
return create(key.type, { native: key });
|
|
37
|
+
}
|
|
38
|
+
get [Symbol.toStringTag]() {
|
|
39
|
+
return "KeyObject";
|
|
40
|
+
}
|
|
41
|
+
export(options = {}) {
|
|
42
|
+
validateObject(options, "options");
|
|
43
|
+
if (options.format === undefined)
|
|
44
|
+
options.format = "buffer";
|
|
45
|
+
validateString(options.format, "options.format");
|
|
46
|
+
if (options.type !== undefined)
|
|
47
|
+
validateString(options.type, "options.type");
|
|
48
|
+
const current = state(this);
|
|
49
|
+
if (current.asymmetric) {
|
|
50
|
+
if (options.format === "jwk")
|
|
51
|
+
return exportJwk(current.asymmetric, current.type === "private");
|
|
52
|
+
validateOneOf(options.format, "options.format", ["pem", "der"]);
|
|
53
|
+
validateOneOf(options.type, "options.type", current.type === "private"
|
|
54
|
+
? ["pkcs1", "pkcs8", "sec1"]
|
|
55
|
+
: ["pkcs1", "spki"]);
|
|
56
|
+
if (options.cipher !== undefined)
|
|
57
|
+
validateString(options.cipher, "options.cipher");
|
|
58
|
+
const passphrase = options.passphrase === undefined
|
|
59
|
+
? undefined
|
|
60
|
+
: bytes(options.passphrase, "options.passphrase");
|
|
61
|
+
const result = current.asymmetric.export(current.type === "private", options.format === "pem", options.type, options.cipher, passphrase);
|
|
62
|
+
return options.format === "pem"
|
|
63
|
+
? new TextDecoder().decode(result)
|
|
64
|
+
: Buffer.from(result);
|
|
65
|
+
}
|
|
66
|
+
const data = current.bytes;
|
|
67
|
+
if (!data)
|
|
68
|
+
return boundary();
|
|
69
|
+
if (options.format === "buffer")
|
|
70
|
+
return Buffer.from(data);
|
|
71
|
+
if (options.format === "jwk")
|
|
72
|
+
return {
|
|
73
|
+
kty: "oct",
|
|
74
|
+
ext: true,
|
|
75
|
+
k: Buffer.from(data)
|
|
76
|
+
.toString("base64")
|
|
77
|
+
.replace(/=/g, "")
|
|
78
|
+
.replace(/\+/g, "-")
|
|
79
|
+
.replace(/\//g, "_"),
|
|
80
|
+
};
|
|
81
|
+
throw new TypeError(`Invalid format for secret key export: ${options.format}`);
|
|
82
|
+
}
|
|
83
|
+
equals(other) {
|
|
84
|
+
if (other == null)
|
|
85
|
+
throw new TypeError("Cannot read properties of null or undefined");
|
|
86
|
+
const a = state(this), b = keyStates.get(other);
|
|
87
|
+
if (this === other || (a.native && a.native === b?.native))
|
|
88
|
+
return true;
|
|
89
|
+
if (a.type !== other?.type)
|
|
90
|
+
return false;
|
|
91
|
+
if (!b)
|
|
92
|
+
throw new ERR_INVALID_ARG_TYPE("otherKeyObject", "KeyObject", other);
|
|
93
|
+
if (a.asymmetric && b.asymmetric)
|
|
94
|
+
return a.asymmetric.equals(b.asymmetric);
|
|
95
|
+
if (!a.bytes || !b.bytes)
|
|
96
|
+
return boundary();
|
|
97
|
+
if (a.bytes.length !== b.bytes.length)
|
|
98
|
+
return false;
|
|
99
|
+
let difference = 0;
|
|
100
|
+
for (let i = 0; i < a.bytes.length; i++)
|
|
101
|
+
difference |= a.bytes[i] ^ b.bytes[i];
|
|
102
|
+
return difference === 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export class SecretKeyObject extends KeyObject {
|
|
106
|
+
get type() {
|
|
107
|
+
return "secret";
|
|
108
|
+
}
|
|
109
|
+
export(options) {
|
|
110
|
+
return super.export(options);
|
|
111
|
+
}
|
|
112
|
+
get symmetricKeySize() {
|
|
113
|
+
const key = state(this);
|
|
114
|
+
return (key.bytes?.length ?? (key.native?.algorithm?.length ?? 0) | 0);
|
|
115
|
+
}
|
|
116
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
117
|
+
return `SecretKeyObject { size: ${this.symmetricKeySize} }`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
class AsymmetricKeyObject extends KeyObject {
|
|
121
|
+
get asymmetricKeyType() {
|
|
122
|
+
const key = state(this).asymmetric;
|
|
123
|
+
if (!key)
|
|
124
|
+
return boundary();
|
|
125
|
+
return key.type;
|
|
126
|
+
}
|
|
127
|
+
get asymmetricKeyDetails() {
|
|
128
|
+
const key = state(this).asymmetric;
|
|
129
|
+
if (!key)
|
|
130
|
+
return boundary();
|
|
131
|
+
if (key.type === "rsa")
|
|
132
|
+
return {
|
|
133
|
+
modulusLength: key.bits,
|
|
134
|
+
publicExponent: BigInt("0x" + Buffer.from(key.parameter("e")).toString("hex")),
|
|
135
|
+
};
|
|
136
|
+
if (key.type === "ec")
|
|
137
|
+
return { namedCurve: key.group };
|
|
138
|
+
return {};
|
|
139
|
+
}
|
|
140
|
+
toCryptoKey() {
|
|
141
|
+
throw Object.assign(new Error("The toCryptoKey method is not implemented"), { code: "ERR_METHOD_NOT_IMPLEMENTED" });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export class PublicKeyObject extends AsymmetricKeyObject {
|
|
145
|
+
get type() {
|
|
146
|
+
return "public";
|
|
147
|
+
}
|
|
148
|
+
export(options) {
|
|
149
|
+
return super.export(options);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export class PrivateKeyObject extends AsymmetricKeyObject {
|
|
153
|
+
get type() {
|
|
154
|
+
return "private";
|
|
155
|
+
}
|
|
156
|
+
export(options) {
|
|
157
|
+
return super.export(options);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export function createSecretKey(value, encoding) {
|
|
161
|
+
if (typeof value !== "string" &&
|
|
162
|
+
!(value instanceof ArrayBuffer) &&
|
|
163
|
+
!ArrayBuffer.isView(value) &&
|
|
164
|
+
!(typeof SharedArrayBuffer !== "undefined" &&
|
|
165
|
+
value instanceof SharedArrayBuffer))
|
|
166
|
+
throw new ERR_INVALID_ARG_TYPE("key", ["string", "ArrayBuffer", "TypedArray", "DataView"], value);
|
|
167
|
+
const data = typeof value === "string"
|
|
168
|
+
? Buffer.from(value, encoding)
|
|
169
|
+
: typeof SharedArrayBuffer !== "undefined" &&
|
|
170
|
+
value instanceof SharedArrayBuffer
|
|
171
|
+
? new Uint8Array(value)
|
|
172
|
+
: bytes(value, "key");
|
|
173
|
+
return create("secret", { bytes: new Uint8Array(data) });
|
|
174
|
+
}
|
|
175
|
+
export function secretMaterial(value) {
|
|
176
|
+
if (typeof value !== "object" || value === null || !keyStates.has(value))
|
|
177
|
+
return value;
|
|
178
|
+
const key = state(value);
|
|
179
|
+
if (key.type !== "secret")
|
|
180
|
+
throw new TypeError("Expected a secret key");
|
|
181
|
+
if (!key.bytes)
|
|
182
|
+
return boundary();
|
|
183
|
+
return Buffer.from(key.bytes);
|
|
184
|
+
}
|
|
185
|
+
export function generateKeySync(type, options) {
|
|
186
|
+
validateOneOf(type, "type", ["hmac", "aes"]);
|
|
187
|
+
validateObject(options, "options");
|
|
188
|
+
if (type === "hmac")
|
|
189
|
+
validateInteger(options.length, "options.length", 8, 65536);
|
|
190
|
+
else
|
|
191
|
+
validateOneOf(options.length, "options.length", [128, 192, 256]);
|
|
192
|
+
const material = new Uint8Array(Math.floor(options.length / 8));
|
|
193
|
+
globalThis.crypto.getRandomValues(material);
|
|
194
|
+
return createSecretKey(material);
|
|
195
|
+
}
|
|
196
|
+
export function generateKey(type, options, callback) {
|
|
197
|
+
let key, failure;
|
|
198
|
+
try {
|
|
199
|
+
key = generateKeySync(type, options);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
failure = error;
|
|
203
|
+
}
|
|
204
|
+
queueMicrotask(() => callback(failure ?? null, key));
|
|
205
|
+
}
|
|
206
|
+
export { isKeyObject } from "./key-state.js";
|
|
207
|
+
export function getKeyObjectHandle(key) {
|
|
208
|
+
return key;
|
|
209
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
2
|
+
// Licensed under Apache-2.0: https://opensource.org/licenses/Apache-2.0
|
|
3
|
+
// Adapted from workerd@5358e3d337336eaf696a48bc1563d808b10feba5.
|
|
4
|
+
export function getCurves() {
|
|
5
|
+
return ["secp224r1", "prime256v1", "secp384r1", "secp521r1"];
|
|
6
|
+
}
|
|
7
|
+
export function secureHeapUsed() {
|
|
8
|
+
return { total: 0, used: 0, utilization: 0, min: 0 };
|
|
9
|
+
}
|
|
10
|
+
function unavailable(method) {
|
|
11
|
+
throw Object.assign(new Error(`The ${method} method is not implemented`), {
|
|
12
|
+
code: "ERR_METHOD_NOT_IMPLEMENTED",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export function setEngine(_engine, _flags) {
|
|
16
|
+
return unavailable("setEngine");
|
|
17
|
+
}
|
|
18
|
+
export function setFips(_enabled) {
|
|
19
|
+
return unavailable("setFips");
|
|
20
|
+
}
|
|
21
|
+
// Do not copy Workers' fips=true: this adapter uses JavaScript algorithms,
|
|
22
|
+
// not Workers' FIPS backend. That capability remains an explicit boundary.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare class NativeKey {
|
|
2
|
+
private pointer;
|
|
3
|
+
checkCertificate(cert: number, operation: number): boolean;
|
|
4
|
+
rsa(operation: number, data: Uint8Array, options: any): Uint8Array;
|
|
5
|
+
constructor(pointer: number);
|
|
6
|
+
dispose(): void;
|
|
7
|
+
private handle;
|
|
8
|
+
static parse(data: Uint8Array, pem: boolean, privateKey: boolean, password?: Uint8Array): NativeKey;
|
|
9
|
+
static generate(type: string, bits?: number, curve?: string, exponent?: number): NativeKey;
|
|
10
|
+
get type(): string;
|
|
11
|
+
get bits(): number;
|
|
12
|
+
equals(other: NativeKey): boolean;
|
|
13
|
+
export(privateKey: boolean, pem: boolean, type: "pkcs8" | "pkcs1" | "sec1" | "spki", cipher?: string, password?: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
14
|
+
parameter(name: string): Uint8Array<ArrayBufferLike>;
|
|
15
|
+
raw(privateKey: boolean): Uint8Array<ArrayBufferLike>;
|
|
16
|
+
get group(): string;
|
|
17
|
+
sign(digest: string | null, data: Uint8Array, padding?: number, saltLength?: number, p1363?: boolean): Uint8Array<ArrayBufferLike>;
|
|
18
|
+
verify(digest: string | null, data: Uint8Array, signature: Uint8Array, padding?: number, saltLength?: number, p1363?: boolean): boolean;
|
|
19
|
+
signHash(digest: string, data: Uint8Array, padding?: number, saltLength?: number): Uint8Array<ArrayBufferLike>;
|
|
20
|
+
verifyHash(digest: string, data: Uint8Array, signature: Uint8Array, padding?: number, saltLength?: number): boolean;
|
|
21
|
+
derive(peer: NativeKey): Uint8Array<ArrayBufferLike>;
|
|
22
|
+
}
|
|
23
|
+
export declare function nativeTimingEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
24
|
+
export declare function nativePrimeCheck(data: Uint8Array, checks: number): boolean;
|
|
25
|
+
export declare function nativePrimeGenerate(bits: number, safe: boolean, add?: Uint8Array, rem?: Uint8Array): Uint8Array;
|
|
26
|
+
export declare class NativeDigest {
|
|
27
|
+
private context;
|
|
28
|
+
private pointer;
|
|
29
|
+
constructor(algorithm: string, context?: string);
|
|
30
|
+
update(data: Uint8Array): void;
|
|
31
|
+
final(): Uint8Array<ArrayBufferLike>;
|
|
32
|
+
}
|
|
33
|
+
export declare class NativeECDH {
|
|
34
|
+
private pointer;
|
|
35
|
+
constructor(curve: string);
|
|
36
|
+
generateKeys(): void;
|
|
37
|
+
getPrivateKey(): Uint8Array<ArrayBufferLike>;
|
|
38
|
+
getPublicKey(format: string): Uint8Array<ArrayBufferLike>;
|
|
39
|
+
setPrivateKey(data: Uint8Array): void;
|
|
40
|
+
computeSecret(data: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
41
|
+
static convertKey(data: Uint8Array, curve: string, format: string): Uint8Array<ArrayBufferLike>;
|
|
42
|
+
}
|
|
43
|
+
export declare function nativeSpkac(data: Uint8Array, operation: number): boolean | Uint8Array;
|
|
44
|
+
export declare class NativeX509 {
|
|
45
|
+
private pointer;
|
|
46
|
+
private constructor();
|
|
47
|
+
static parse(data: Uint8Array): NativeX509 | undefined;
|
|
48
|
+
field(field: number): Uint8Array | undefined;
|
|
49
|
+
string(field: number): string | undefined;
|
|
50
|
+
get isCA(): boolean;
|
|
51
|
+
get publicKey(): NativeKey | undefined;
|
|
52
|
+
check(name: string, flags: number, operation: number): string | undefined;
|
|
53
|
+
checkIssued(other: NativeX509): boolean;
|
|
54
|
+
checkKey(key: NativeKey, operation: number): boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare class NativeTLS {
|
|
57
|
+
private pointer;
|
|
58
|
+
constructor(host: string);
|
|
59
|
+
private handle;
|
|
60
|
+
dispose(): void;
|
|
61
|
+
feed(data: Uint8Array): void;
|
|
62
|
+
handshake(): number;
|
|
63
|
+
read(): number | Uint8Array;
|
|
64
|
+
write(data: Uint8Array): number;
|
|
65
|
+
shutdown(): number;
|
|
66
|
+
drain(): Uint8Array[];
|
|
67
|
+
certificates(): Uint8Array[];
|
|
68
|
+
}
|