diff options
Diffstat (limited to 'node_modules/blake3-wasm/esm/node-native')
12 files changed, 138 insertions, 0 deletions
diff --git a/node_modules/blake3-wasm/esm/node-native/hash-fn.d.ts b/node_modules/blake3-wasm/esm/node-native/hash-fn.d.ts new file mode 100644 index 0000000..573cb22 --- /dev/null +++ b/node_modules/blake3-wasm/esm/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/esm/node-native/hash-fn.js b/node_modules/blake3-wasm/esm/node-native/hash-fn.js new file mode 100644 index 0000000..a38d8c1 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-fn.js @@ -0,0 +1,43 @@ +import native from './native.js'; +import { defaultHashLength } from '../base/hash-fn.js'; +/** + * @hidden + */ +export const 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. + */ +export function hash(input, { length = defaultHashLength } = {}) { + return native.hash(normalizeInput(input), length); +} +/** + * 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 function deriveKey(context, material, { length = defaultHashLength } = {}) { + const hasher = new native.Hasher(undefined, context); + hasher.update(normalizeInput(material)); + const result = Buffer.alloc(length); + hasher.digest(result); + return result; +} +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export function keyedHash(key, input, { length = defaultHashLength } = {}) { + const hasher = new native.Hasher(key); + hasher.update(normalizeInput(input)); + const result = Buffer.alloc(length); + hasher.digest(result); + return result; +} +//# sourceMappingURL=hash-fn.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/hash-fn.js.map b/node_modules/blake3-wasm/esm/node-native/hash-fn.js.map new file mode 100644 index 0000000..96b02af --- /dev/null +++ b/node_modules/blake3-wasm/esm/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,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAoB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,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,MAAM,UAAU,IAAI,CAClB,KAAgB,EAChB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,OAAe,EACf,QAAmB,EACnB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,CAAC,MAAM,CAAC,cAAc,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;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACvB,GAAW,EACX,KAAgB,EAChB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,CAAC,MAAM,CAAC,cAAc,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"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/hash-instance.d.ts b/node_modules/blake3-wasm/esm/node-native/hash-instance.d.ts new file mode 100644 index 0000000..f1d97ba --- /dev/null +++ b/node_modules/blake3-wasm/esm/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/esm/node-native/hash-instance.js b/node_modules/blake3-wasm/esm/node-native/hash-instance.js new file mode 100644 index 0000000..86da52d --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/hash-instance.js @@ -0,0 +1,26 @@ +import native from './native.js'; +import { NodeHash } from '../node/hash-instance.js'; +import { NodeHashReader } from '../node/hash-reader.js'; +// 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 NodeHashReader({ + fill: target => r.fill(target), + set_position: position => { + bigIntBuffer.writeBigUInt64BE(position); + r.set_position(bigIntBuffer); + }, +}); +/** + * A Node.js crypto-like createHash method. + */ +export const createHash = () => new NodeHash(new native.Hasher(), readerFactory); +/** + * Construct a new Hasher for the keyed hash function. + */ +export const createKeyed = (key) => new NodeHash(new native.Hasher(key), readerFactory); +/** + * Construct a new Hasher for the key derivation function. + */ +export const createDeriveKey = (context) => new NodeHash(new native.Hasher(undefined, context), readerFactory); +//# sourceMappingURL=hash-instance.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/hash-instance.js.map b/node_modules/blake3-wasm/esm/node-native/hash-instance.js.map new file mode 100644 index 0000000..9339845 --- /dev/null +++ b/node_modules/blake3-wasm/esm/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,OAAO,MAAyB,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;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,cAAc,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;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC;AAEjF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;AAEhG;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CACjD,IAAI,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/index.d.ts b/node_modules/blake3-wasm/esm/node-native/index.d.ts new file mode 100644 index 0000000..e37c80e --- /dev/null +++ b/node_modules/blake3-wasm/esm/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/esm/node-native/index.js b/node_modules/blake3-wasm/esm/node-native/index.js new file mode 100644 index 0000000..52595ee --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/index.js @@ -0,0 +1,5 @@ +export { hash, deriveKey, keyedHash } from './hash-fn.js'; +export * from '../node/hash-reader.js'; +export * from './hash-instance.js'; +export * from '../base/index.js'; +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/index.js.map b/node_modules/blake3-wasm/esm/node-native/index.js.map new file mode 100644 index 0000000..a46564a --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/node-native/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/native.d.ts b/node_modules/blake3-wasm/esm/node-native/native.d.ts new file mode 100644 index 0000000..be1a909 --- /dev/null +++ b/node_modules/blake3-wasm/esm/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/esm/node-native/native.js b/node_modules/blake3-wasm/esm/node-native/native.js new file mode 100644 index 0000000..d858319 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node-native/native.js @@ -0,0 +1,3 @@ +const native = require('../native.node'); +export default native; +//# sourceMappingURL=native.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node-native/native.js.map b/node_modules/blake3-wasm/esm/node-native/native.js.map new file mode 100644 index 0000000..5fdca1c --- /dev/null +++ b/node_modules/blake3-wasm/esm/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,eAAe,MAAM,CAAC"}
\ No newline at end of file |
