summaryrefslogtreecommitdiff
path: root/node_modules/blake3-wasm/dist/node-native
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/blake3-wasm/dist/node-native')
-rw-r--r--node_modules/blake3-wasm/dist/node-native/hash-fn.d.ts21
-rw-r--r--node_modules/blake3-wasm/dist/node-native/hash-fn.js51
-rw-r--r--node_modules/blake3-wasm/dist/node-native/hash-fn.js.map1
-rw-r--r--node_modules/blake3-wasm/dist/node-native/hash-instance.d.ts15
-rw-r--r--node_modules/blake3-wasm/dist/node-native/hash-instance.js31
-rw-r--r--node_modules/blake3-wasm/dist/node-native/hash-instance.js.map1
-rw-r--r--node_modules/blake3-wasm/dist/node-native/index.d.ts5
-rw-r--r--node_modules/blake3-wasm/dist/node-native/index.js13
-rw-r--r--node_modules/blake3-wasm/dist/node-native/index.js.map1
-rw-r--r--node_modules/blake3-wasm/dist/node-native/native.d.ts16
-rw-r--r--node_modules/blake3-wasm/dist/node-native/native.js5
-rw-r--r--node_modules/blake3-wasm/dist/node-native/native.js.map1
12 files changed, 161 insertions, 0 deletions
diff --git a/node_modules/blake3-wasm/dist/node-native/hash-fn.d.ts b/node_modules/blake3-wasm/dist/node-native/hash-fn.d.ts
new file mode 100644
index 0000000..573cb22
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/hash-fn.d.ts
@@ -0,0 +1,21 @@
+/// <reference types="node" />
+import { HashInput } from '../node/hash-fn';
+import { IBaseHashOptions } from '../base/hash-fn';
+/**
+ * @hidden
+ */
+export declare const normalizeInput: (input: HashInput, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Buffer;
+/**
+ * Returns a blake3 hash of the input, returning the binary hash data.
+ */
+export declare function hash(input: HashInput, { length }?: IBaseHashOptions): Buffer | string;
+/**
+ * Given cryptographic key material and a context string, services a subkey of
+ * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html}
+ * for more information.
+ */
+export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Buffer;
+/**
+ * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}.
+ */
+export declare function keyedHash(key: Buffer, input: HashInput, { length }?: IBaseHashOptions): Buffer;
diff --git a/node_modules/blake3-wasm/dist/node-native/hash-fn.js b/node_modules/blake3-wasm/dist/node-native/hash-fn.js
new file mode 100644
index 0000000..5281988
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/hash-fn.js
@@ -0,0 +1,51 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const native_1 = __importDefault(require("./native"));
+const hash_fn_1 = require("../base/hash-fn");
+/**
+ * @hidden
+ */
+exports.normalizeInput = (input, encoding) => {
+ if (input instanceof Buffer) {
+ return input;
+ }
+ if (typeof input === 'string') {
+ return Buffer.from(input, encoding);
+ }
+ return Buffer.from(input);
+};
+/**
+ * Returns a blake3 hash of the input, returning the binary hash data.
+ */
+function hash(input, { length = hash_fn_1.defaultHashLength } = {}) {
+ return native_1.default.hash(exports.normalizeInput(input), length);
+}
+exports.hash = hash;
+/**
+ * Given cryptographic key material and a context string, services a subkey of
+ * any length. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html}
+ * for more information.
+ */
+function deriveKey(context, material, { length = hash_fn_1.defaultHashLength } = {}) {
+ const hasher = new native_1.default.Hasher(undefined, context);
+ hasher.update(exports.normalizeInput(material));
+ const result = Buffer.alloc(length);
+ hasher.digest(result);
+ return result;
+}
+exports.deriveKey = deriveKey;
+/**
+ * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}.
+ */
+function keyedHash(key, input, { length = hash_fn_1.defaultHashLength } = {}) {
+ const hasher = new native_1.default.Hasher(key);
+ hasher.update(exports.normalizeInput(input));
+ const result = Buffer.alloc(length);
+ hasher.digest(result);
+ return result;
+}
+exports.keyedHash = keyedHash;
+//# sourceMappingURL=hash-fn.js.map \ No newline at end of file
diff --git a/node_modules/blake3-wasm/dist/node-native/hash-fn.js.map b/node_modules/blake3-wasm/dist/node-native/hash-fn.js.map
new file mode 100644
index 0000000..794f5b3
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/hash-fn.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/node-native/hash-fn.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAE9B,6CAAsE;AAEtE;;GAEG;AACU,QAAA,cAAc,GAAG,CAAC,KAAgB,EAAE,QAAyB,EAAU,EAAE;IACpF,IAAI,KAAK,YAAY,MAAM,EAAE;QAC3B,OAAO,KAAK,CAAC;KACd;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;KACrC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,KAAmB,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF;;GAEG;AACH,SAAgB,IAAI,CAClB,KAAgB,EAChB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,OAAO,gBAAM,CAAC,IAAI,CAAC,sBAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AALD,oBAKC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CACvB,OAAe,EACf,QAAmB,EACnB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,8BAUC;AAED;;GAEG;AACH,SAAgB,SAAS,CACvB,GAAW,EACX,KAAgB,EAChB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,8BAUC"} \ No newline at end of file
diff --git a/node_modules/blake3-wasm/dist/node-native/hash-instance.d.ts b/node_modules/blake3-wasm/dist/node-native/hash-instance.d.ts
new file mode 100644
index 0000000..f1d97ba
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/hash-instance.d.ts
@@ -0,0 +1,15 @@
+/// <reference types="node" />
+import { INativeReader } from './native';
+import { NodeHash } from '../node/hash-instance';
+/**
+ * A Node.js crypto-like createHash method.
+ */
+export declare const createHash: () => NodeHash<INativeReader>;
+/**
+ * Construct a new Hasher for the keyed hash function.
+ */
+export declare const createKeyed: (key: Buffer) => NodeHash<INativeReader>;
+/**
+ * Construct a new Hasher for the key derivation function.
+ */
+export declare const createDeriveKey: (context: string) => NodeHash<INativeReader>;
diff --git a/node_modules/blake3-wasm/dist/node-native/hash-instance.js b/node_modules/blake3-wasm/dist/node-native/hash-instance.js
new file mode 100644
index 0000000..cd30204
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/hash-instance.js
@@ -0,0 +1,31 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const native_1 = __importDefault(require("./native"));
+const hash_instance_1 = require("../node/hash-instance");
+const hash_reader_1 = require("../node/hash-reader");
+// A buffer we reuse for sending bigints. set_position is synchronous, so
+// this just saves creating garbage.
+const bigIntBuffer = Buffer.alloc(8);
+const readerFactory = (r) => new hash_reader_1.NodeHashReader({
+ fill: target => r.fill(target),
+ set_position: position => {
+ bigIntBuffer.writeBigUInt64BE(position);
+ r.set_position(bigIntBuffer);
+ },
+});
+/**
+ * A Node.js crypto-like createHash method.
+ */
+exports.createHash = () => new hash_instance_1.NodeHash(new native_1.default.Hasher(), readerFactory);
+/**
+ * Construct a new Hasher for the keyed hash function.
+ */
+exports.createKeyed = (key) => new hash_instance_1.NodeHash(new native_1.default.Hasher(key), readerFactory);
+/**
+ * Construct a new Hasher for the key derivation function.
+ */
+exports.createDeriveKey = (context) => new hash_instance_1.NodeHash(new native_1.default.Hasher(undefined, context), readerFactory);
+//# sourceMappingURL=hash-instance.js.map \ No newline at end of file
diff --git a/node_modules/blake3-wasm/dist/node-native/hash-instance.js.map b/node_modules/blake3-wasm/dist/node-native/hash-instance.js.map
new file mode 100644
index 0000000..cd20ddf
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/hash-instance.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/node-native/hash-instance.ts"],"names":[],"mappings":";;;;;AAAA,sDAAiD;AACjD,yDAAiD;AACjD,qDAAqD;AAErD,yEAAyE;AACzE,oCAAoC;AACpC,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAErC,MAAM,aAAa,GAAG,CAAC,CAAgB,EAAE,EAAE,CACzC,IAAI,4BAAc,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B,YAAY,EAAE,QAAQ,CAAC,EAAE;QACvB,YAAY,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC,CAAC;AAEL;;GAEG;AACU,QAAA,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,wBAAQ,CAAC,IAAI,gBAAM,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC;AAEjF;;GAEG;AACU,QAAA,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,wBAAQ,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;AAEhG;;GAEG;AACU,QAAA,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CACjD,IAAI,wBAAQ,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC"} \ No newline at end of file
diff --git a/node_modules/blake3-wasm/dist/node-native/index.d.ts b/node_modules/blake3-wasm/dist/node-native/index.d.ts
new file mode 100644
index 0000000..e37c80e
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/index.d.ts
@@ -0,0 +1,5 @@
+export { HashInput } from '../node/hash-fn';
+export { hash, deriveKey, keyedHash } from './hash-fn';
+export * from '../node/hash-reader';
+export * from './hash-instance';
+export * from '../base/index';
diff --git a/node_modules/blake3-wasm/dist/node-native/index.js b/node_modules/blake3-wasm/dist/node-native/index.js
new file mode 100644
index 0000000..defe1dc
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/index.js
@@ -0,0 +1,13 @@
+"use strict";
+function __export(m) {
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
+}
+Object.defineProperty(exports, "__esModule", { value: true });
+var hash_fn_1 = require("./hash-fn");
+exports.hash = hash_fn_1.hash;
+exports.deriveKey = hash_fn_1.deriveKey;
+exports.keyedHash = hash_fn_1.keyedHash;
+__export(require("../node/hash-reader"));
+__export(require("./hash-instance"));
+__export(require("../base/index"));
+//# sourceMappingURL=index.js.map \ No newline at end of file
diff --git a/node_modules/blake3-wasm/dist/node-native/index.js.map b/node_modules/blake3-wasm/dist/node-native/index.js.map
new file mode 100644
index 0000000..95a404f
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/node-native/index.ts"],"names":[],"mappings":";;;;;AACA,qCAAuD;AAA9C,yBAAA,IAAI,CAAA;AAAE,8BAAA,SAAS,CAAA;AAAE,8BAAA,SAAS,CAAA;AACnC,yCAAoC;AACpC,qCAAgC;AAChC,mCAA8B"} \ No newline at end of file
diff --git a/node_modules/blake3-wasm/dist/node-native/native.d.ts b/node_modules/blake3-wasm/dist/node-native/native.d.ts
new file mode 100644
index 0000000..be1a909
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/native.d.ts
@@ -0,0 +1,16 @@
+/// <reference types="node" />
+import { IInternalHash } from '../base/index';
+export interface INativeReader {
+ free?(): void;
+ fill(target: Uint8Array): void;
+ set_position(position: Buffer): void;
+}
+export interface INativeHash extends IInternalHash<INativeReader> {
+ new (hashKey?: Buffer, context?: string): INativeHash;
+}
+export interface INativeModule {
+ Hasher: INativeHash;
+ hash(input: Buffer, length: number): Buffer;
+}
+declare const native: INativeModule;
+export default native;
diff --git a/node_modules/blake3-wasm/dist/node-native/native.js b/node_modules/blake3-wasm/dist/node-native/native.js
new file mode 100644
index 0000000..47d4173
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/native.js
@@ -0,0 +1,5 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const native = require('../native.node');
+exports.default = native;
+//# sourceMappingURL=native.js.map \ No newline at end of file
diff --git a/node_modules/blake3-wasm/dist/node-native/native.js.map b/node_modules/blake3-wasm/dist/node-native/native.js.map
new file mode 100644
index 0000000..545e1ef
--- /dev/null
+++ b/node_modules/blake3-wasm/dist/node-native/native.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"native.js","sourceRoot":"","sources":["../../ts/node-native/native.ts"],"names":[],"mappings":";;AAiBA,MAAM,MAAM,GAAkB,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAExD,kBAAe,MAAM,CAAC"} \ No newline at end of file