diff options
| author | akiyamn | 2023-09-24 23:22:21 +1000 |
|---|---|---|
| committer | akiyamn | 2023-09-24 23:22:21 +1000 |
| commit | 4e87195739f2a5d9a05451b48773c8afdc680765 (patch) | |
| tree | 9cba501844a4a11dcbdffc4050ed8189561c55ed /node_modules/blake3-wasm | |
| download | price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.tar.gz price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.zip | |
Initial commit (by create-cloudflare CLI)
Diffstat (limited to 'node_modules/blake3-wasm')
202 files changed, 5582 insertions, 0 deletions
diff --git a/node_modules/blake3-wasm/LICENSE b/node_modules/blake3-wasm/LICENSE new file mode 100644 index 0000000..2b05740 --- /dev/null +++ b/node_modules/blake3-wasm/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Connor Peet + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/blake3-wasm/benchmark.js b/node_modules/blake3-wasm/benchmark.js new file mode 100644 index 0000000..061748f --- /dev/null +++ b/node_modules/blake3-wasm/benchmark.js @@ -0,0 +1,22 @@ +const { hash: hashWasm } = require('./dist/node'); +const { hash: hashNative } = require('./dist/node-native'); +const { createHash } = require('crypto'); + +[ + { size: '64B', data: Buffer.alloc(64) }, + { size: '64KB', data: Buffer.alloc(1024 * 64) }, + { size: '6MB', data: Buffer.alloc(1024 * 1024 * 6) }, +].forEach(({ size, data }) => + suite(size, () => { + ['md5', 'sha1', 'sha256'].forEach(alg => + bench(alg, () => + createHash(alg) + .update(data) + .digest(), + ), + ); + + bench('blake3 wasm', () => hashWasm(data)); + bench('blake3 native', () => hashNative(data)); + }), +); diff --git a/node_modules/blake3-wasm/browser-async.d.ts b/node_modules/blake3-wasm/browser-async.d.ts new file mode 100644 index 0000000..a5a04ce --- /dev/null +++ b/node_modules/blake3-wasm/browser-async.d.ts @@ -0,0 +1,7 @@ +import * as blake3 from './esm/browser'; + +/** + * Manually loads the WebAssembly module, returning a promise that resolves + * to the BLAKE3 implementation once available. + */ +export default function load(module: string | URL | Request | object): Promise<typeof blake3>; diff --git a/node_modules/blake3-wasm/browser-async.js b/node_modules/blake3-wasm/browser-async.js new file mode 100644 index 0000000..b1b9b65 --- /dev/null +++ b/node_modules/blake3-wasm/browser-async.js @@ -0,0 +1,20 @@ +import { provideWasm } from './esm/browser/wasm.js'; +import * as wasm from './dist/wasm/web/blake3_js.js'; +import * as blake3 from './esm/browser/index.js'; + +let cached; + +/** + * Manually loads the WebAssembly module, returning a promise that resolves + * to the BLAKE3 implementation once available. + */ +export default function load(module) { + if (!cached) { + cached = wasm.default(module).then(() => { + provideWasm(wasm); + return blake3; + }); + } + + return cached; +} diff --git a/node_modules/blake3-wasm/browser.d.ts b/node_modules/blake3-wasm/browser.d.ts new file mode 100644 index 0000000..cd0c33e --- /dev/null +++ b/node_modules/blake3-wasm/browser.d.ts @@ -0,0 +1 @@ +export * from './esm/browser'; diff --git a/node_modules/blake3-wasm/browser.js b/node_modules/blake3-wasm/browser.js new file mode 100644 index 0000000..c1b06ff --- /dev/null +++ b/node_modules/blake3-wasm/browser.js @@ -0,0 +1,6 @@ +import { provideWasm } from './esm/browser/wasm'; +import * as wasm from './dist/wasm/browser'; + +provideWasm(wasm); + +export * from './esm/browser'; diff --git a/node_modules/blake3-wasm/changelog.md b/node_modules/blake3-wasm/changelog.md new file mode 100644 index 0000000..b4682ed --- /dev/null +++ b/node_modules/blake3-wasm/changelog.md @@ -0,0 +1,60 @@ +# Changelog + +## 2.1.5 - 2020-11-28 + +- fix version matching on postinstall +- build for node 15 + +## 2.1.4 - 2020-05-11 + +- add support for Node 14 +- validate native bindings before switching to them + +## 2.1.3 - 2020-03-06 + +- update to BLAKE3@0.2, providing significant speed improvements for native Node +- fixed missing file causing installation of native Node extensions to fail + +## 2.1.2 - 2020-03-01 + +- fix missing createKeyed function in browsers + +## 2.1.1 - 2020-02-11 + +- allow importing the module without a bundler or with tools like Parcel + +## 2.1.0 - 2020-01-23 + +- add keyed hash and key derivation support (fixes [#2](https://github.com/connor4312/blake3/issues/2), [#9](https://github.com/connor4312/blake3/issues/9)) +- fixed a bug in hex encoding in the browser + +## 2.0.1 - 2020-01-23 + +- fix browser bundle to use pure es modules (fixes [#8](https://github.com/connor4312/blake3/issues/8)) + +## 2.0.0 - 2020-01-19 + +- **breaking** the simple `hash` function no longer takes an encoding in its second parameter. Use `hash(data).toString(<encoding>)` instead. +- allow configuring the hash length in `hash()` and `hasher.digest()` +- add `using()` helper to deal with disposables +- add `dispose: boolean` option to Hashers' `.digest()` methods, so that you can read a head while continuing to update it +- add `hasher.reader()` method to retrieve a hash reader object, which allows seeking through and reading arbitrary amounts of data from the hash +- add helper methods for encoding and constant-time equality checking in the returned Hash within the browser + +## 1.2.0 - 2020-01-14 + +- add native Node.js bindings + +## 1.2.0-0 - 2020-01-14 (prerelease) + +- add native Node.js bindings + +## 1.1.0 - 2020-01-12 + +- add support for usage in browsers +- fix potential memory unsafety in WebAssembly land +- add support for output encoding in `Hash.digest([encoding])` + +## 1.0.0 - 2020-01-09 + +Initial release diff --git a/node_modules/blake3-wasm/dist/base/disposable.d.ts b/node_modules/blake3-wasm/dist/base/disposable.d.ts new file mode 100644 index 0000000..27db792 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/disposable.d.ts @@ -0,0 +1,17 @@ +/** + * A type which requires manual disposal to free unmanaged resources. In the + * context of this library, this usually means freeing memory from WebAssembly + * code. + */ +export interface IDisposable { + /** + * Frees unmanaged resources of the object. This method is idempotent; + * calling it multiple times will have no ill effects. + */ + dispose(): void; +} +/** + * A helper function that calls `.dispose()` on the {@link IDisposable} when + * the given function (or promise returned by the function) returns. + */ +export declare const using: <T, D extends IDisposable>(disposable: D, fn: (d: D) => T) => T; diff --git a/node_modules/blake3-wasm/dist/base/disposable.js b/node_modules/blake3-wasm/dist/base/disposable.js new file mode 100644 index 0000000..4b295c1 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/disposable.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const isPromiseLike = (value) => typeof value === 'object' && !!value && 'then' in value; +/** + * A helper function that calls `.dispose()` on the {@link IDisposable} when + * the given function (or promise returned by the function) returns. + */ +exports.using = (disposable, fn) => { + let ret; + try { + ret = fn(disposable); + } + catch (e) { + disposable.dispose(); + throw e; + } + if (!isPromiseLike(ret)) { + disposable.dispose(); + return ret; + } + return ret.then(value => { + disposable.dispose(); + return value; + }, err => { + disposable.dispose(); + throw err; + }); +}; +//# sourceMappingURL=disposable.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/disposable.js.map b/node_modules/blake3-wasm/dist/base/disposable.js.map new file mode 100644 index 0000000..a14e2a5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/disposable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"disposable.js","sourceRoot":"","sources":["../../ts/base/disposable.ts"],"names":[],"mappings":";;AAaA,MAAM,aAAa,GAAG,CAAC,KAAc,EAAiC,EAAE,CACtE,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC;AAE1D;;;GAGG;AACU,QAAA,KAAK,GAAG,CAA2B,UAAa,EAAE,EAAe,EAAK,EAAE;IACnF,IAAI,GAAmB,CAAC;IACxB,IAAI;QACF,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;KACtB;IAAC,OAAO,CAAC,EAAE;QACV,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,CAAC,CAAC;KACT;IAED,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE;QACvB,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC;KACZ;IAED,OAAQ,GAAG,CAAC,IAAI,CACd,KAAK,CAAC,EAAE;QACN,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC,EACD,GAAG,CAAC,EAAE;QACJ,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,GAAG,CAAC;IACZ,CAAC,CACe,CAAC;AACrB,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/disposable.test.d.ts b/node_modules/blake3-wasm/dist/base/disposable.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/disposable.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/base/disposable.test.js b/node_modules/blake3-wasm/dist/base/disposable.test.js new file mode 100644 index 0000000..8507b85 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/disposable.test.js @@ -0,0 +1,70 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const node_1 = require("../node"); +const chai_1 = require("chai"); +describe('disposable', () => { + describe('using', () => { + let disposed; + let disposable; + beforeEach(() => { + disposed = false; + disposable = { dispose: () => (disposed = true) }; + }); + it('disposes after sync call', () => { + const v = node_1.using(disposable, d => { + chai_1.expect(d).to.equal(disposable); + chai_1.expect(disposed).to.be.false; + return 42; + }); + chai_1.expect(v).to.equal(42); + chai_1.expect(disposed).to.be.true; + }); + it('disposes after sync throw', () => { + const err = new Error(); + try { + node_1.using(disposable, () => { + throw err; + }); + throw new Error('expected to throw'); + } + catch (e) { + chai_1.expect(e).to.equal(err); + } + chai_1.expect(disposed).to.be.true; + }); + it('disposes after promise resolve', () => __awaiter(void 0, void 0, void 0, function* () { + const v = yield node_1.using(disposable, () => __awaiter(void 0, void 0, void 0, function* () { + yield Promise.resolve(); + chai_1.expect(disposed).to.be.false; + return 42; + })); + chai_1.expect(v).to.equal(42); + chai_1.expect(disposed).to.be.true; + })); + it('disposes after promise reject', () => __awaiter(void 0, void 0, void 0, function* () { + const err = new Error(); + try { + yield node_1.using(disposable, () => __awaiter(void 0, void 0, void 0, function* () { + yield Promise.resolve(); + chai_1.expect(disposed).to.be.false; + throw err; + })); + throw new Error('expected to throw'); + } + catch (e) { + chai_1.expect(e).to.equal(err); + } + chai_1.expect(disposed).to.be.true; + })); + }); +}); +//# sourceMappingURL=disposable.test.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/disposable.test.js.map b/node_modules/blake3-wasm/dist/base/disposable.test.js.map new file mode 100644 index 0000000..ab44c7b --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/disposable.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"disposable.test.js","sourceRoot":"","sources":["../../ts/base/disposable.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kCAA6C;AAC7C,+BAA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m/dist/base/hash-fn.d.ts new file mode 100644 index 0000000..6b654a0 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-fn.d.ts @@ -0,0 +1,23 @@ +/** + * Options passed to hash functions. + */ +export interface IBaseHashOptions { + /** + * Length of the desired hash, in bytes. Note that when encoding the output + * as a string, this is *not* the string length. + */ + length?: number; +} +/** + * Default hash length, in bytes, unless otherwise specified. + */ +export declare const defaultHashLength = 32; +/** + * A type that can be hashed. + */ +export declare type BaseHashInput = Uint8Array | ArrayBuffer | SharedArrayBuffer | ArrayLike<number>; +/** + * Converts the input to an Uint8Array. + * @hidden + */ +export declare const inputToArray: (input: BaseHashInput) => Uint8Array; diff --git a/node_modules/blake3-wasm/dist/base/hash-fn.js b/node_modules/blake3-wasm/dist/base/hash-fn.js new file mode 100644 index 0000000..4498606 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-fn.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Default hash length, in bytes, unless otherwise specified. + */ +exports.defaultHashLength = 32; +/** + * Converts the input to an Uint8Array. + * @hidden + */ +exports.inputToArray = (input) => input instanceof Uint8Array ? input : new Uint8Array(input); +//# sourceMappingURL=hash-fn.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/hash-fn.js.map b/node_modules/blake3-wasm/dist/base/hash-fn.js.map new file mode 100644 index 0000000..fa0c758 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/base/hash-fn.ts"],"names":[],"mappings":";;AAWA;;GAEG;AACU,QAAA,iBAAiB,GAAG,EAAE,CAAC;AAOpC;;;GAGG;AACU,QAAA,YAAY,GAAG,CAAC,KAAoB,EAAE,EAAE,CACnD,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/hash-instance.d.ts b/node_modules/blake3-wasm/dist/base/hash-instance.d.ts new file mode 100644 index 0000000..3f55095 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-instance.d.ts @@ -0,0 +1,79 @@ +import { BaseHashInput, IBaseHashOptions } from './hash-fn'; +import { IHashReader } from './hash-reader'; +/** + * A blake3 hash. Quite similar to Node's crypto hashing. + * + * Note that you must call {@link IHash#dispose} or {@link IHash#done} when + * you're finished with it to free memory. + */ +export interface IHasher<T> { + /** + * Adds the given data to the hash. + * @throws {Error} if {@link IHash#digest} has already been called. + */ + update(data: BaseHashInput): this; + /** + * Returns a digest of the hash. + * + * If `dispose: false` is given in the options, the hash will not + * automatically be disposed of, allowing you to continue updating + * it after obtaining the current reader. + */ + digest(options?: IBaseHashOptions & { + dispose?: boolean; + }): T; + /** + * Returns a {@link HashReader} for the current hash. + * + * If `dispose: false` is given in the options, the hash will not + * automatically be disposed of, allowing you to continue updating + * it after obtaining the current reader. + */ + reader(options?: { + dispose?: boolean; + }): IHashReader<T>; + /** + * Frees data associated with the hash. This *must* be called if + * {@link IHash#digest} is not called in order to free memory. + */ + dispose(): void; +} +/** + * @hidden + */ +export interface IInternalHash<Reader> { + free(): void; + reader(): Reader; + update(bytes: Uint8Array): void; + digest(into: Uint8Array): void; +} +export interface IHasherDigestOptions extends IBaseHashOptions { + dispose?: boolean; +} +/** + * Base implementation of hashing. + */ +export declare class BaseHash<Binary extends Uint8Array, InternalReader, Reader extends IHashReader<Binary>> implements IHasher<Binary> { + private readonly alloc; + private readonly getReader; + private hash; + constructor(implementation: IInternalHash<InternalReader>, alloc: (length: number) => Binary, getReader: (internal: InternalReader) => Reader); + /** + * @inheritdoc + */ + update(data: BaseHashInput): this; + /** + * @inheritdoc + */ + digest({ length, dispose }?: IHasherDigestOptions): Binary; + /** + * @inheritdoc + */ + reader({ dispose }?: { + dispose?: boolean; + }): Reader; + /** + * @inheritdoc + */ + dispose(): void; +} diff --git a/node_modules/blake3-wasm/dist/base/hash-instance.js b/node_modules/blake3-wasm/dist/base/hash-instance.js new file mode 100644 index 0000000..aae0e56 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-instance.js @@ -0,0 +1,60 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_fn_1 = require("./hash-fn"); +/** + * Base implementation of hashing. + */ +class BaseHash { + constructor(implementation, alloc, getReader) { + this.alloc = alloc; + this.getReader = getReader; + this.hash = implementation; + } + /** + * @inheritdoc + */ + update(data) { + if (!this.hash) { + throw new Error('Cannot continue updating hashing after dispose() has been called'); + } + this.hash.update(hash_fn_1.inputToArray(data)); + return this; + } + /** + * @inheritdoc + */ + digest({ length = hash_fn_1.defaultHashLength, dispose = true } = {}) { + if (!this.hash) { + throw new Error('Cannot call digest() after dipose() has been called'); + } + const digested = this.alloc(length); + this.hash.digest(digested); + if (dispose) { + this.dispose(); + } + return digested; + } + /** + * @inheritdoc + */ + reader({ dispose = true } = {}) { + if (!this.hash) { + throw new Error('Cannot call reader() after dipose() has been called'); + } + const reader = this.getReader(this.hash.reader()); + if (dispose) { + this.dispose(); + } + return reader; + } + /** + * @inheritdoc + */ + dispose() { + var _a; + (_a = this.hash) === null || _a === void 0 ? void 0 : _a.free(); + this.hash = undefined; + } +} +exports.BaseHash = BaseHash; +//# sourceMappingURL=hash-instance.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/hash-instance.js.map b/node_modules/blake3-wasm/dist/base/hash-instance.js.map new file mode 100644 index 0000000..027dce5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/base/hash-instance.ts"],"names":[],"mappings":";;AAAA,uCAA6F;AAuD7F;;GAEG;AACH,MAAa,QAAQ;IAInB,YACE,cAA6C,EAC5B,KAAiC,EACjC,SAA+C;QAD/C,UAAK,GAAL,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AAS,CAAC;IACxB,CAAC;CACF;AAjED,4BAiEC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/hash-reader.d.ts b/node_modules/blake3-wasm/dist/base/hash-reader.d.ts new file mode 100644 index 0000000..ad6a8fa --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-reader.d.ts @@ -0,0 +1,61 @@ +import { IDisposable } from './disposable'; +/** + * The maximum number of bytes that can be read from the hash. + * + * Calculated out 2^64-1, since `Xn` syntax (for `Xn ** Yn`) requires TS + * targeting esnext/es2020 which includes features that Node 10 doesn't + * yet supported. + */ +export declare const maxHashBytes: bigint; +/** + * The HashReader is a type returned from any of the hash functions. It can + */ +export interface IHashReader<T> extends IDisposable { + /** + * Returns the position of the reader in the hash. Can be written to to seek. + */ + position: bigint; + /** + * Reads data from the hash into the target array. The target will always + * be completely filled with data. + */ + readInto(target: Uint8Array): void; + /** + * Reads and returns the given number of bytes from the hash, advancing + * the position of the reader. + */ + read(bytes: number): T; +} +/** + * Underlying native or wasm module code backing the reader. + * @hidden + */ +export interface IInternalReader { + free?(): void; + fill(target: Uint8Array): void; + set_position(position: bigint): void; +} +/** + * Base hash reader implementation. + */ +export declare abstract class BaseHashReader<T extends Uint8Array> implements IHashReader<T> { + private reader; + private pos; + get position(): bigint; + set position(value: bigint); + constructor(reader: IInternalReader); + /** + * @inheritdoc + */ + readInto(target: Uint8Array): void; + /** + * @inheritdoc + */ + read(bytes: number): T; + /** + * @inheritdoc + */ + dispose(): void; + protected abstract alloc(bytes: number): T; + private boundsCheck; +} diff --git a/node_modules/blake3-wasm/dist/base/hash-reader.js b/node_modules/blake3-wasm/dist/base/hash-reader.js new file mode 100644 index 0000000..e5eb5e5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-reader.js @@ -0,0 +1,70 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * The maximum number of bytes that can be read from the hash. + * + * Calculated out 2^64-1, since `Xn` syntax (for `Xn ** Yn`) requires TS + * targeting esnext/es2020 which includes features that Node 10 doesn't + * yet supported. + */ +exports.maxHashBytes = BigInt('18446744073709551615'); +/** + * Base hash reader implementation. + */ +class BaseHashReader { + constructor(reader) { + this.pos = BigInt(0); + this.reader = reader; + } + get position() { + return this.pos; + } + set position(value) { + var _a; + // to avoid footguns of people using numbers: + if (typeof value !== 'bigint') { + throw new Error(`Got a ${typeof value} set in to reader.position, expected a bigint`); + } + this.boundsCheck(value); + this.pos = value; + (_a = this.reader) === null || _a === void 0 ? void 0 : _a.set_position(value); + } + /** + * @inheritdoc + */ + readInto(target) { + if (!this.reader) { + throw new Error(`Cannot read from a hash after it was disposed`); + } + const next = this.pos + BigInt(target.length); + this.boundsCheck(next); + this.reader.fill(target); + this.position = next; + } + /** + * @inheritdoc + */ + read(bytes) { + const data = this.alloc(bytes); + this.readInto(data); + return data; + } + /** + * @inheritdoc + */ + dispose() { + var _a, _b; + (_b = (_a = this.reader) === null || _a === void 0 ? void 0 : _a.free) === null || _b === void 0 ? void 0 : _b.call(_a); + this.reader = undefined; + } + boundsCheck(position) { + if (position > exports.maxHashBytes) { + throw new RangeError(`Cannot read past ${exports.maxHashBytes} bytes in BLAKE3 hashes`); + } + if (position < BigInt(0)) { + throw new RangeError(`Cannot read to a negative position`); + } + } +} +exports.BaseHashReader = BaseHashReader; +//# sourceMappingURL=hash-reader.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/hash-reader.js.map b/node_modules/blake3-wasm/dist/base/hash-reader.js.map new file mode 100644 index 0000000..2b6d9ff --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/base/hash-reader.ts"],"names":[],"mappings":";;AAEA;;;;;;GAMG;AACU,QAAA,YAAY,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAkC3D;;GAEG;AACH,MAAsB,cAAc;IAmBlC,YAAY,MAAuB;QAjB3B,Q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C,IAAI,QAAQ,GAAG,oBAAY,EAAE;YAC3B,MAAM,IAAI,UAAU,CAAC,oBAAoB,oBAAY,yBAAyB,CAAC,CAAC;SACjF;QAED,IAAI,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE;YACxB,MAAM,IAAI,UAAU,CAAC,oCAAoC,CAAC,CAAC;SAC5D;IACH,CAAC;CACF;AAjED,wCAiEC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/index.d.ts b/node_modules/blake3-wasm/dist/base/index.d.ts new file mode 100644 index 0000000..fa61a59 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/index.d.ts @@ -0,0 +1,4 @@ +export * from './hash-fn'; +export * from './hash-reader'; +export * from './hash-instance'; +export * from './disposable'; diff --git a/node_modules/blake3-wasm/dist/base/index.js b/node_modules/blake3-wasm/dist/base/index.js new file mode 100644 index 0000000..4274746 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/index.js @@ -0,0 +1,10 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./hash-fn")); +__export(require("./hash-reader")); +__export(require("./hash-instance")); +__export(require("./disposable")); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/index.js.map b/node_modules/blake3-wasm/dist/base/index.js.map new file mode 100644 index 0000000..ff57e71 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/base/index.ts"],"names":[],"mappings":";;;;;AAAA,+BAA0B;AAC1B,mCAA8B;AAC9B,qCAAgC;AAChC,kCAA6B"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/test-helpers.d.ts b/node_modules/blake3-wasm/dist/base/test-helpers.d.ts new file mode 100644 index 0000000..9b4b3dd --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/test-helpers.d.ts @@ -0,0 +1,41 @@ +/// <reference types="node" /> +export declare const hello48: Buffer; +export declare const inputs: { + large: { + input: string; + hash: Buffer; + }; + hello: { + input: string; + hash: Buffer; + }; + goodbye: { + input: string; + hash: Buffer; + }; +}; +/** + * Test vectors from the BLAKE3 repo. + * + * > Each test is an input length and three outputs, one for each of the hash, + * > keyedHash, and deriveKey modes. The input in each case is filled with a + * > 251-byte-long repeating pattern: 0, 1, 2, ..., 249, 250, 0, 1, ... The + * > key used with keyedHash is the 32-byte ASCII string given in the 'key' + * > field below. For deriveKey, the test input is used as the input key, and + * > the context string is 'BLAKE3 2019-12-27 6:29:52 example context'. + * > (As good practice for following the security requirements of deriveKey, + * > test runners should make that context string a hardcoded constant, and we + * > do not provided it in machine-readable form.) Outputs are encoded as + * > hexadecimal. Each case is an extended output, and implementations should + * > also check that the first 32 bytes match their default-length output. + */ +export declare const ogTestVectors: { + key: string; + context: string; + cases: { + inputLen: number; + expectedHash: string; + expectedKeyed: string; + expectedDerive: string; + }[]; +}; diff --git a/node_modules/blake3-wasm/dist/base/test-helpers.js b/node_modules/blake3-wasm/dist/base/test-helpers.js new file mode 100644 index 0000000..6f68736 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/test-helpers.js @@ -0,0 +1,166 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs_1 = require("fs"); +exports.hello48 = Buffer.from('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200fe992405f0d785b599a2e3387f6d34d01', 'hex'); +exports.inputs = { + large: { + input: fs_1.readFileSync(__dirname + '/../../test-input.txt', 'utf-8'), + hash: Buffer.from('2a2cf9cbc9f8d48f7d089273bc2d796a3cd0677b64234dab0c59e6e29d6a7164', 'hex'), + }, + hello: { + input: 'hello', + hash: Buffer.from('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f', 'hex'), + }, + goodbye: { + input: 'goodbye', + hash: Buffer.from('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69', 'hex'), + }, +}; +/** + * Test vectors from the BLAKE3 repo. + * + * > Each test is an input length and three outputs, one for each of the hash, + * > keyedHash, and deriveKey modes. The input in each case is filled with a + * > 251-byte-long repeating pattern: 0, 1, 2, ..., 249, 250, 0, 1, ... The + * > key used with keyedHash is the 32-byte ASCII string given in the 'key' + * > field below. For deriveKey, the test input is used as the input key, and + * > the context string is 'BLAKE3 2019-12-27 6:29:52 example context'. + * > (As good practice for following the security requirements of deriveKey, + * > test runners should make that context string a hardcoded constant, and we + * > do not provided it in machine-readable form.) Outputs are encoded as + * > hexadecimal. Each case is an extended output, and implementations should + * > also check that the first 32 bytes match their default-length output. + */ +exports.ogTestVectors = { + key: 'whats the Elvish word for friend', + context: 'BLAKE3 2019-12-27 16:29:52 test vectors context', + cases: [ + { + inputLen: 0, + expectedHash: 'af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262e00f03e7b69af26b7faaf09fcd333050338ddfe085b8cc869ca98b206c08243a26f5487789e8f660afe6c99ef9e0c52b92e7393024a80459cf91f476f9ffdbda7001c22e159b402631f277ca96f2defdf1078282314e763699a31c5363165421cce14d', + expectedKeyed: '92b2b75604ed3c761f9d6f62392c8a9227ad0ea3f09573e783f1498a4ed60d26b18171a2f22a4b94822c701f107153dba24918c4bae4d2945c20ece13387627d3b73cbf97b797d5e59948c7ef788f54372df45e45e4293c7dc18c1d41144a9758be58960856be1eabbe22c2653190de560ca3b2ac4aa692a9210694254c371e851bc8f', + expectedDerive: '2cc39783c223154fea8dfb7c1b1660f2ac2dcbd1c1de8277b0b0dd39b7e50d7d905630c8be290dfcf3e6842f13bddd573c098c3f17361f1f206b8cad9d088aa4a3f746752c6b0ce6a83b0da81d59649257cdf8eb3e9f7d4998e41021fac119deefb896224ac99f860011f73609e6e0e4540f93b273e56547dfd3aa1a035ba6689d89a0', + }, + { + inputLen: 1, + expectedHash: '2d3adedff11b61f14c886e35afa036736dcd87a74d27b5c1510225d0f592e213c3a6cb8bf623e20cdb535f8d1a5ffb86342d9c0b64aca3bce1d31f60adfa137b358ad4d79f97b47c3d5e79f179df87a3b9776ef8325f8329886ba42f07fb138bb502f4081cbcec3195c5871e6c23e2cc97d3c69a613eba131e5f1351f3f1da786545e5', + expectedKeyed: '6d7878dfff2f485635d39013278ae14f1454b8c0a3a2d34bc1ab38228a80c95b6568c0490609413006fbd428eb3fd14e7756d90f73a4725fad147f7bf70fd61c4e0cf7074885e92b0e3f125978b4154986d4fb202a3f331a3fb6cf349a3a70e49990f98fe4289761c8602c4e6ab1138d31d3b62218078b2f3ba9a88e1d08d0dd4cea11', + expectedDerive: 'b3e2e340a117a499c6cf2398a19ee0d29cca2bb7404c73063382693bf66cb06c5827b91bf889b6b97c5477f535361caefca0b5d8c4746441c57617111933158950670f9aa8a05d791daae10ac683cbef8faf897c84e6114a59d2173c3f417023a35d6983f2c7dfa57e7fc559ad751dbfb9ffab39c2ef8c4aafebc9ae973a64f0c76551', + }, + { + inputLen: 1023, + expectedHash: '10108970eeda3eb932baac1428c7a2163b0e924c9a9e25b35bba72b28f70bd11a182d27a591b05592b15607500e1e8dd56bc6c7fc063715b7a1d737df5bad3339c56778957d870eb9717b57ea3d9fb68d1b55127bba6a906a4a24bbd5acb2d123a37b28f9e9a81bbaae360d58f85e5fc9d75f7c370a0cc09b6522d9c8d822f2f28f485', + expectedKeyed: 'c951ecdf03288d0fcc96ee3413563d8a6d3589547f2c2fb36d9786470f1b9d6e890316d2e6d8b8c25b0a5b2180f94fb1a158ef508c3cde45e2966bd796a696d3e13efd86259d756387d9becf5c8bf1ce2192b87025152907b6d8cc33d17826d8b7b9bc97e38c3c85108ef09f013e01c229c20a83d9e8efac5b37470da28575fd755a10', + expectedDerive: '74a16c1c3d44368a86e1ca6df64be6a2f64cce8f09220787450722d85725dea59c413264404661e9e4d955409dfe4ad3aa487871bcd454ed12abfe2c2b1eb7757588cf6cb18d2eccad49e018c0d0fec323bec82bf1644c6325717d13ea712e6840d3e6e730d35553f59eff5377a9c350bcc1556694b924b858f329c44ee64b884ef00d', + }, + { + inputLen: 1024, + expectedHash: '42214739f095a406f3fc83deb889744ac00df831c10daa55189b5d121c855af71cf8107265ecdaf8505b95d8fcec83a98a6a96ea5109d2c179c47a387ffbb404756f6eeae7883b446b70ebb144527c2075ab8ab204c0086bb22b7c93d465efc57f8d917f0b385c6df265e77003b85102967486ed57db5c5ca170ba441427ed9afa684e', + expectedKeyed: '75c46f6f3d9eb4f55ecaaee480db732e6c2105546f1e675003687c31719c7ba4a78bc838c72852d4f49c864acb7adafe2478e824afe51c8919d06168414c265f298a8094b1ad813a9b8614acabac321f24ce61c5a5346eb519520d38ecc43e89b5000236df0597243e4d2493fd626730e2ba17ac4d8824d09d1a4a8f57b8227778e2de', + expectedDerive: '7356cd7720d5b66b6d0697eb3177d9f8d73a4a5c5e968896eb6a6896843027066c23b601d3ddfb391e90d5c8eccdef4ae2a264bce9e612ba15e2bc9d654af1481b2e75dbabe615974f1070bba84d56853265a34330b4766f8e75edd1f4a1650476c10802f22b64bd3919d246ba20a17558bc51c199efdec67e80a227251808d8ce5bad', + }, + { + inputLen: 1025, + expectedHash: 'd00278ae47eb27b34faecf67b4fe263f82d5412916c1ffd97c8cb7fb814b8444f4c4a22b4b399155358a994e52bf255de60035742ec71bd08ac275a1b51cc6bfe332b0ef84b409108cda080e6269ed4b3e2c3f7d722aa4cdc98d16deb554e5627be8f955c98e1d5f9565a9194cad0c4285f93700062d9595adb992ae68ff12800ab67a', + expectedKeyed: '357dc55de0c7e382c900fd6e320acc04146be01db6a8ce7210b7189bd664ea69362396b77fdc0d2634a552970843722066c3c15902ae5097e00ff53f1e116f1cd5352720113a837ab2452cafbde4d54085d9cf5d21ca613071551b25d52e69d6c81123872b6f19cd3bc1333edf0c52b94de23ba772cf82636cff4542540a7738d5b930', + expectedDerive: 'effaa245f065fbf82ac186839a249707c3bddf6d3fdda22d1b95a3c970379bcb5d31013a167509e9066273ab6e2123bc835b408b067d88f96addb550d96b6852dad38e320b9d940f86db74d398c770f462118b35d2724efa13da97194491d96dd37c3c09cbef665953f2ee85ec83d88b88d11547a6f911c8217cca46defa2751e7f3ad', + }, + { + inputLen: 2048, + expectedHash: 'e776b6028c7cd22a4d0ba182a8bf62205d2ef576467e838ed6f2529b85fba24a9a60bf80001410ec9eea6698cd537939fad4749edd484cb541aced55cd9bf54764d063f23f6f1e32e12958ba5cfeb1bf618ad094266d4fc3c968c2088f677454c288c67ba0dba337b9d91c7e1ba586dc9a5bc2d5e90c14f53a8863ac75655461cea8f9', + expectedKeyed: '879cf1fa2ea0e79126cb1063617a05b6ad9d0b696d0d757cf053439f60a99dd10173b961cd574288194b23ece278c330fbb8585485e74967f31352a8183aa782b2b22f26cdcadb61eed1a5bc144b8198fbb0c13abbf8e3192c145d0a5c21633b0ef86054f42809df823389ee40811a5910dcbd1018af31c3b43aa55201ed4edaac74fe', + expectedDerive: '7b2945cb4fef70885cc5d78a87bf6f6207dd901ff239201351ffac04e1088a23e2c11a1ebffcea4d80447867b61badb1383d842d4e79645d48dd82ccba290769caa7af8eaa1bd78a2a5e6e94fbdab78d9c7b74e894879f6a515257ccf6f95056f4e25390f24f6b35ffbb74b766202569b1d797f2d4bd9d17524c720107f985f4ddc583', + }, + { + inputLen: 2049, + expectedHash: '5f4d72f40d7a5f82b15ca2b2e44b1de3c2ef86c426c95c1af0b687952256303096de31d71d74103403822a2e0bc1eb193e7aecc9643a76b7bbc0c9f9c52e8783aae98764ca468962b5c2ec92f0c74eb5448d519713e09413719431c802f948dd5d90425a4ecdadece9eb178d80f26efccae630734dff63340285adec2aed3b51073ad3', + expectedKeyed: '9f29700902f7c86e514ddc4df1e3049f258b2472b6dd5267f61bf13983b78dd5f9a88abfefdfa1e00b418971f2b39c64ca621e8eb37fceac57fd0c8fc8e117d43b81447be22d5d8186f8f5919ba6bcc6846bd7d50726c06d245672c2ad4f61702c646499ee1173daa061ffe15bf45a631e2946d616a4c345822f1151284712f76b2b0e', + expectedDerive: '2ea477c5515cc3dd606512ee72bb3e0e758cfae7232826f35fb98ca1bcbdf27316d8e9e79081a80b046b60f6a263616f33ca464bd78d79fa18200d06c7fc9bffd808cc4755277a7d5e09da0f29ed150f6537ea9bed946227ff184cc66a72a5f8c1e4bd8b04e81cf40fe6dc4427ad5678311a61f4ffc39d195589bdbc670f63ae70f4b6', + }, + { + inputLen: 3072, + expectedHash: 'b98cb0ff3623be03326b373de6b9095218513e64f1ee2edd2525c7ad1e5cffd29a3f6b0b978d6608335c09dc94ccf682f9951cdfc501bfe47b9c9189a6fc7b404d120258506341a6d802857322fbd20d3e5dae05b95c88793fa83db1cb08e7d8008d1599b6209d78336e24839724c191b2a52a80448306e0daa84a3fdb566661a37e11', + expectedKeyed: '044a0e7b172a312dc02a4c9a818c036ffa2776368d7f528268d2e6b5df19177022f302d0529e4174cc507c463671217975e81dab02b8fdeb0d7ccc7568dd22574c783a76be215441b32e91b9a904be8ea81f7a0afd14bad8ee7c8efc305ace5d3dd61b996febe8da4f56ca0919359a7533216e2999fc87ff7d8f176fbecb3d6f34278b', + expectedDerive: '050df97f8c2ead654d9bb3ab8c9178edcd902a32f8495949feadcc1e0480c46b3604131bbd6e3ba573b6dd682fa0a63e5b165d39fc43a625d00207607a2bfeb65ff1d29292152e26b298868e3b87be95d6458f6f2ce6118437b632415abe6ad522874bcd79e4030a5e7bad2efa90a7a7c67e93f0a18fb28369d0a9329ab5c24134ccb0', + }, + { + inputLen: 3073, + expectedHash: '7124b49501012f81cc7f11ca069ec9226cecb8a2c850cfe644e327d22d3e1cd39a27ae3b79d68d89da9bf25bc27139ae65a324918a5f9b7828181e52cf373c84f35b639b7fccbb985b6f2fa56aea0c18f531203497b8bbd3a07ceb5926f1cab74d14bd66486d9a91eba99059a98bd1cd25876b2af5a76c3e9eed554ed72ea952b603bf', + expectedKeyed: '68dede9bef00ba89e43f31a6825f4cf433389fedae75c04ee9f0cf16a427c95a96d6da3fe985054d3478865be9a092250839a697bbda74e279e8a9e69f0025e4cfddd6cfb434b1cd9543aaf97c635d1b451a4386041e4bb100f5e45407cbbc24fa53ea2de3536ccb329e4eb9466ec37093a42cf62b82903c696a93a50b702c80f3c3c5', + expectedDerive: '72613c9ec9ff7e40f8f5c173784c532ad852e827dba2bf85b2ab4b76f7079081576288e552647a9d86481c2cae75c2dd4e7c5195fb9ada1ef50e9c5098c249d743929191441301c69e1f48505a4305ec1778450ee48b8e69dc23a25960fe33070ea549119599760a8a2d28aeca06b8c5e9ba58bc19e11fe57b6ee98aa44b2a8e6b14a5', + }, + { + inputLen: 4096, + expectedHash: '015094013f57a5277b59d8475c0501042c0b642e531b0a1c8f58d2163229e9690289e9409ddb1b99768eafe1623da896faf7e1114bebeadc1be30829b6f8af707d85c298f4f0ff4d9438aef948335612ae921e76d411c3a9111df62d27eaf871959ae0062b5492a0feb98ef3ed4af277f5395172dbe5c311918ea0074ce0036454f620', + expectedKeyed: 'befc660aea2f1718884cd8deb9902811d332f4fc4a38cf7c7300d597a081bfc0bbb64a36edb564e01e4b4aaf3b060092a6b838bea44afebd2deb8298fa562b7b597c757b9df4c911c3ca462e2ac89e9a787357aaf74c3b56d5c07bc93ce899568a3eb17d9250c20f6c5f6c1e792ec9a2dcb715398d5a6ec6d5c54f586a00403a1af1de', + expectedDerive: '1e0d7f3db8c414c97c6307cbda6cd27ac3b030949da8e23be1a1a924ad2f25b9d78038f7b198596c6cc4a9ccf93223c08722d684f240ff6569075ed81591fd93f9fff1110b3a75bc67e426012e5588959cc5a4c192173a03c00731cf84544f65a2fb9378989f72e9694a6a394a8a30997c2e67f95a504e631cd2c5f55246024761b245', + }, + { + inputLen: 4097, + expectedHash: '9b4052b38f1c5fc8b1f9ff7ac7b27cd242487b3d890d15c96a1c25b8aa0fb99505f91b0b5600a11251652eacfa9497b31cd3c409ce2e45cfe6c0a016967316c426bd26f619eab5d70af9a418b845c608840390f361630bd497b1ab44019316357c61dbe091ce72fc16dc340ac3d6e009e050b3adac4b5b2c92e722cffdc46501531956', + expectedKeyed: '00df940cd36bb9fa7cbbc3556744e0dbc8191401afe70520ba292ee3ca80abbc606db4976cfdd266ae0abf667d9481831ff12e0caa268e7d3e57260c0824115a54ce595ccc897786d9dcbf495599cfd90157186a46ec800a6763f1c59e36197e9939e900809f7077c102f888caaf864b253bc41eea812656d46742e4ea42769f89b83f', + expectedDerive: 'aca51029626b55fda7117b42a7c211f8c6e9ba4fe5b7a8ca922f34299500ead8a897f66a400fed9198fd61dd2d58d382458e64e100128075fc54b860934e8de2e84170734b06e1d212a117100820dbc48292d148afa50567b8b84b1ec336ae10d40c8c975a624996e12de31abbe135d9d159375739c333798a80c64ae895e51e22f3ad', + }, + { + inputLen: 5120, + expectedHash: '9cadc15fed8b5d854562b26a9536d9707cadeda9b143978f319ab34230535833acc61c8fdc114a2010ce8038c853e121e1544985133fccdd0a2d507e8e615e611e9a0ba4f47915f49e53d721816a9198e8b30f12d20ec3689989175f1bf7a300eee0d9321fad8da232ece6efb8e9fd81b42ad161f6b9550a069e66b11b40487a5f5059', + expectedKeyed: '2c493e48e9b9bf31e0553a22b23503c0a3388f035cece68eb438d22fa1943e209b4dc9209cd80ce7c1f7c9a744658e7e288465717ae6e56d5463d4f80cdb2ef56495f6a4f5487f69749af0c34c2cdfa857f3056bf8d807336a14d7b89bf62bef2fb54f9af6a546f818dc1e98b9e07f8a5834da50fa28fb5874af91bf06020d1bf0120e', + expectedDerive: '7a7acac8a02adcf3038d74cdd1d34527de8a0fcc0ee3399d1262397ce5817f6055d0cefd84d9d57fe792d65a278fd20384ac6c30fdb340092f1a74a92ace99c482b28f0fc0ef3b923e56ade20c6dba47e49227166251337d80a037e987ad3a7f728b5ab6dfafd6e2ab1bd583a95d9c895ba9c2422c24ea0f62961f0dca45cad47bfa0d', + }, + { + inputLen: 5121, + expectedHash: '628bd2cb2004694adaab7bbd778a25df25c47b9d4155a55f8fbd79f2fe154cff96adaab0613a6146cdaabe498c3a94e529d3fc1da2bd08edf54ed64d40dcd6777647eac51d8277d70219a9694334a68bc8f0f23e20b0ff70ada6f844542dfa32cd4204ca1846ef76d811cdb296f65e260227f477aa7aa008bac878f72257484f2b6c95', + expectedKeyed: '6ccf1c34753e7a044db80798ecd0782a8f76f33563accaddbfbb2e0ea4b2d0240d07e63f13667a8d1490e5e04f13eb617aea16a8c8a5aaed1ef6fbde1b0515e3c81050b361af6ead126032998290b563e3caddeaebfab592e155f2e161fb7cba939092133f23f9e65245e58ec23457b78a2e8a125588aad6e07d7f11a85b88d375b72d', + expectedDerive: 'b07f01e518e702f7ccb44a267e9e112d403a7b3f4883a47ffbed4b48339b3c341a0add0ac032ab5aaea1e4e5b004707ec5681ae0fcbe3796974c0b1cf31a194740c14519273eedaabec832e8a784b6e7cfc2c5952677e6c3f2c3914454082d7eb1ce1766ac7d75a4d3001fc89544dd46b5147382240d689bbbaefc359fb6ae30263165', + }, + { + inputLen: 6144, + expectedHash: '3e2e5b74e048f3add6d21faab3f83aa44d3b2278afb83b80b3c35164ebeca2054d742022da6fdda444ebc384b04a54c3ac5839b49da7d39f6d8a9db03deab32aade156c1c0311e9b3435cde0ddba0dce7b26a376cad121294b689193508dd63151603c6ddb866ad16c2ee41585d1633a2cea093bea714f4c5d6b903522045b20395c83', + expectedKeyed: '3d6b6d21281d0ade5b2b016ae4034c5dec10ca7e475f90f76eac7138e9bc8f1dc35754060091dc5caf3efabe0603c60f45e415bb3407db67e6beb3d11cf8e4f7907561f05dace0c15807f4b5f389c841eb114d81a82c02a00b57206b1d11fa6e803486b048a5ce87105a686dee041207e095323dfe172df73deb8c9532066d88f9da7e', + expectedDerive: '2a95beae63ddce523762355cf4b9c1d8f131465780a391286a5d01abb5683a1597099e3c6488aab6c48f3c15dbe1942d21dbcdc12115d19a8b8465fb54e9053323a9178e4275647f1a9927f6439e52b7031a0b465c861a3fc531527f7758b2b888cf2f20582e9e2c593709c0a44f9c6e0f8b963994882ea4168827823eef1f64169fef', + }, + { + inputLen: 6145, + expectedHash: 'f1323a8631446cc50536a9f705ee5cb619424d46887f3c376c695b70e0f0507f18a2cfdd73c6e39dd75ce7c1c6e3ef238fd54465f053b25d21044ccb2093beb015015532b108313b5829c3621ce324b8e14229091b7c93f32db2e4e63126a377d2a63a3597997d4f1cba59309cb4af240ba70cebff9a23d5e3ff0cdae2cfd54e070022', + expectedKeyed: '9ac301e9e39e45e3250a7e3b3df701aa0fb6889fbd80eeecf28dbc6300fbc539f3c184ca2f59780e27a576c1d1fb9772e99fd17881d02ac7dfd39675aca918453283ed8c3169085ef4a466b91c1649cc341dfdee60e32231fc34c9c4e0b9a2ba87ca8f372589c744c15fd6f985eec15e98136f25beeb4b13c4e43dc84abcc79cd4646c', + expectedDerive: '379bcc61d0051dd489f686c13de00d5b14c505245103dc040d9e4dd1facab8e5114493d029bdbd295aaa744a59e31f35c7f52dba9c3642f773dd0b4262a9980a2aef811697e1305d37ba9d8b6d850ef07fe41108993180cf779aeece363704c76483458603bbeeb693cffbbe5588d1f3535dcad888893e53d977424bb707201569a8d2', + }, + { + inputLen: 7168, + expectedHash: '61da957ec2499a95d6b8023e2b0e604ec7f6b50e80a9678b89d2628e99ada77a5707c321c83361793b9af62a40f43b523df1c8633cecb4cd14d00bdc79c78fca5165b863893f6d38b02ff7236c5a9a8ad2dba87d24c547cab046c29fc5bc1ed142e1de4763613bb162a5a538e6ef05ed05199d751f9eb58d332791b8d73fb74e4fce95', + expectedKeyed: 'b42835e40e9d4a7f42ad8cc04f85a963a76e18198377ed84adddeaecacc6f3fca2f01d5277d69bb681c70fa8d36094f73ec06e452c80d2ff2257ed82e7ba348400989a65ee8daa7094ae0933e3d2210ac6395c4af24f91c2b590ef87d7788d7066ea3eaebca4c08a4f14b9a27644f99084c3543711b64a070b94f2c9d1d8a90d035d52', + expectedDerive: '11c37a112765370c94a51415d0d651190c288566e295d505defdad895dae223730d5a5175a38841693020669c7638f40b9bc1f9f39cf98bda7a5b54ae24218a800a2116b34665aa95d846d97ea988bfcb53dd9c055d588fa21ba78996776ea6c40bc428b53c62b5f3ccf200f647a5aae8067f0ea1976391fcc72af1945100e2a6dcb88', + }, + { + inputLen: 7169, + expectedHash: 'a003fc7a51754a9b3c7fae0367ab3d782dccf28855a03d435f8cfe74605e781798a8b20534be1ca9eb2ae2df3fae2ea60e48c6fb0b850b1385b5de0fe460dbe9d9f9b0d8db4435da75c601156df9d047f4ede008732eb17adc05d96180f8a73548522840779e6062d643b79478a6e8dbce68927f36ebf676ffa7d72d5f68f050b119c8', + expectedKeyed: 'ed9b1a922c046fdb3d423ae34e143b05ca1bf28b710432857bf738bcedbfa5113c9e28d72fcbfc020814ce3f5d4fc867f01c8f5b6caf305b3ea8a8ba2da3ab69fabcb438f19ff11f5378ad4484d75c478de425fb8e6ee809b54eec9bdb184315dc856617c09f5340451bf42fd3270a7b0b6566169f242e533777604c118a6358250f54', + expectedDerive: '554b0a5efea9ef183f2f9b931b7497995d9eb26f5c5c6dad2b97d62fc5ac31d99b20652c016d88ba2a611bbd761668d5eda3e568e940faae24b0d9991c3bd25a65f770b89fdcadabcb3d1a9c1cb63e69721cacf1ae69fefdcef1e3ef41bc5312ccc17222199e47a26552c6adc460cf47a72319cb5039369d0060eaea59d6c65130f1dd', + }, + { + inputLen: 8192, + expectedHash: 'aae792484c8efe4f19e2ca7d371d8c467ffb10748d8a5a1ae579948f718a2a635fe51a27db045a567c1ad51be5aa34c01c6651c4d9b5b5ac5d0fd58cf18dd61a47778566b797a8c67df7b1d60b97b19288d2d877bb2df417ace009dcb0241ca1257d62712b6a4043b4ff33f690d849da91ea3bf711ed583cb7b7a7da2839ba71309bbf', + expectedKeyed: 'dc9637c8845a770b4cbf76b8daec0eebf7dc2eac11498517f08d44c8fc00d58a4834464159dcbc12a0ba0c6d6eb41bac0ed6585cabfe0aca36a375e6c5480c22afdc40785c170f5a6b8a1107dbee282318d00d915ac9ed1143ad40765ec120042ee121cd2baa36250c618adaf9e27260fda2f94dea8fb6f08c04f8f10c78292aa46102', + expectedDerive: 'ad01d7ae4ad059b0d33baa3c01319dcf8088094d0359e5fd45d6aeaa8b2d0c3d4c9e58958553513b67f84f8eac653aeeb02ae1d5672dcecf91cd9985a0e67f4501910ecba25555395427ccc7241d70dc21c190e2aadee875e5aae6bf1912837e53411dabf7a56cbf8e4fb780432b0d7fe6cec45024a0788cf5874616407757e9e6bef7', + }, + { + inputLen: 8193, + expectedHash: 'bab6c09cb8ce8cf459261398d2e7aef35700bf488116ceb94a36d0f5f1b7bc3bb2282aa69be089359ea1154b9a9286c4a56af4de975a9aa4a5c497654914d279bea60bb6d2cf7225a2fa0ff5ef56bbe4b149f3ed15860f78b4e2ad04e158e375c1e0c0b551cd7dfc82f1b155c11b6b3ed51ec9edb30d133653bb5709d1dbd55f4e1ff6', + expectedKeyed: '954a2a75420c8d6547e3ba5b98d963e6fa6491addc8c023189cc519821b4a1f5f03228648fd983aef045c2fa8290934b0866b615f585149587dda2299039965328835a2b18f1d63b7e300fc76ff260b571839fe44876a4eae66cbac8c67694411ed7e09df51068a22c6e67d6d3dd2cca8ff12e3275384006c80f4db68023f24eebba57', + expectedDerive: 'af1e0346e389b17c23200270a64aa4e1ead98c61695d917de7d5b00491c9b0f12f20a01d6d622edf3de026a4db4e4526225debb93c1237934d71c7340bb5916158cbdafe9ac3225476b6ab57a12357db3abbad7a26c6e66290e44034fb08a20a8d0ec264f309994d2810c49cfba6989d7abb095897459f5425adb48aba07c5fb3c83c0', + }, + { + inputLen: 16384, + expectedHash: 'f875d6646de28985646f34ee13be9a576fd515f76b5b0a26bb324735041ddde49d764c270176e53e97bdffa58d549073f2c660be0e81293767ed4e4929f9ad34bbb39a529334c57c4a381ffd2a6d4bfdbf1482651b172aa883cc13408fa67758a3e47503f93f87720a3177325f7823251b85275f64636a8f1d599c2e49722f42e93893', + expectedKeyed: '9e9fc4eb7cf081ea7c47d1807790ed211bfec56aa25bb7037784c13c4b707b0df9e601b101e4cf63a404dfe50f2e1865bb12edc8fca166579ce0c70dba5a5c0fc960ad6f3772183416a00bd29d4c6e651ea7620bb100c9449858bf14e1ddc9ecd35725581ca5b9160de04060045993d972571c3e8f71e9d0496bfa744656861b169d65', + expectedDerive: '160e18b5878cd0df1c3af85eb25a0db5344d43a6fbd7a8ef4ed98d0714c3f7e160dc0b1f09caa35f2f417b9ef309dfe5ebd67f4c9507995a531374d099cf8ae317542e885ec6f589378864d3ea98716b3bbb65ef4ab5e0ab5bb298a501f19a41ec19af84a5e6b428ecd813b1a47ed91c9657c3fba11c406bc316768b58f6802c9e9b57', + }, + { + inputLen: 31744, + expectedHash: '62b6960e1a44bcc1eb1a611a8d6235b6b4b78f32e7abc4fb4c6cdcce94895c47860cc51f2b0c28a7b77304bd55fe73af663c02d3f52ea053ba43431ca5bab7bfea2f5e9d7121770d88f70ae9649ea713087d1914f7f312147e247f87eb2d4ffef0ac978bf7b6579d57d533355aa20b8b77b13fd09748728a5cc327a8ec470f4013226f', + expectedKeyed: 'efa53b389ab67c593dba624d898d0f7353ab99e4ac9d42302ee64cbf9939a4193a7258db2d9cd32a7a3ecfce46144114b15c2fcb68a618a976bd74515d47be08b628be420b5e830fade7c080e351a076fbc38641ad80c736c8a18fe3c66ce12f95c61c2462a9770d60d0f77115bbcd3782b593016a4e728d4c06cee4505cb0c08a42ec', + expectedDerive: '39772aef80e0ebe60596361e45b061e8f417429d529171b6764468c22928e28e9759adeb797a3fbf771b1bcea30150a020e317982bf0d6e7d14dd9f064bc11025c25f31e81bd78a921db0174f03dd481d30e93fd8e90f8b2fee209f849f2d2a52f31719a490fb0ba7aea1e09814ee912eba111a9fde9d5c274185f7bae8ba85d300a2b', + }, + ], +}; +//# sourceMappingURL=test-helpers.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/base/test-helpers.js.map b/node_modules/blake3-wasm/dist/base/test-helpers.js.map new file mode 100644 index 0000000..ad25665 --- /dev/null +++ b/node_modules/blake3-wasm/dist/base/test-helpers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test-helpers.js","sourceRoot":"","sources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;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,IAAI;YACd,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,IAAI;YACd,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,IAAI;YACd,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,IAAI;YACd,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,KAAK;YACf,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,KAAK;YACf,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;KACF;CACF,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser.test.d.ts b/node_modules/blake3-wasm/dist/browser.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/browser.test.js b/node_modules/blake3-wasm/dist/browser.test.js new file mode 100644 index 0000000..b0da1cb --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser.test.js @@ -0,0 +1,266 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai_1 = require("chai"); +const fs_1 = require("fs"); +const http_1 = require("http"); +const os_1 = require("os"); +const path_1 = require("path"); +const puppeteer_1 = __importDefault(require("puppeteer")); +const serve_handler_1 = __importDefault(require("serve-handler")); +const webpack_1 = __importDefault(require("webpack")); +const test_helpers_1 = require("./base/test-helpers"); +// Much of the browser code is also used in Node's wasm. We test things more +// thoroughly there because tests are easier to write and debug, these tests +// are primarily for sanity and checking browser-specific behavior. +describe('browser', () => { + const addInputs = `window.inputs = ${JSON.stringify(test_helpers_1.inputs)}`; + describe('webpack', () => { + const testDir = path_1.resolve(os_1.tmpdir(), 'blake3-browser-test'); + let server; + let page; + /** + * Builds the browser lib into the testDir. + */ + function buildWebpack() { + return __awaiter(this, void 0, void 0, function* () { + try { + fs_1.mkdirSync(testDir); + } + catch (_a) { + // already exists, probably + } + fs_1.writeFileSync(path_1.resolve(testDir, 'entry-src.js'), `import("blake3/browser").then(b3 => window.blake3 = b3);`); + const stats = yield new Promise((res, rej) => webpack_1.default({ + mode: 'production', + devtool: 'source-map', + entry: path_1.resolve(testDir, 'entry-src.js'), + output: { + path: testDir, + filename: 'main.js', + }, + resolve: { + alias: { + 'blake3/browser': path_1.resolve(__dirname, '../', 'browser.js'), + }, + }, + }, (err, stats) => (err ? rej(err) : res(stats)))); + if (stats.hasErrors()) { + throw stats.toString('errors-only'); + } + fs_1.writeFileSync(path_1.resolve(testDir, 'index.html'), `<script src="/main.js"></script>`); + }); + } + function serve() { + return __awaiter(this, void 0, void 0, function* () { + server = http_1.createServer((req, res) => serve_handler_1.default(req, res, { public: testDir })); + yield new Promise(resolve => server.listen(0, resolve)); + }); + } + before(function () { + return __awaiter(this, void 0, void 0, function* () { + yield buildWebpack(); + yield serve(); + this.timeout(20 * 1000); + const { port } = server.address(); + const browser = yield puppeteer_1.default.launch({ + executablePath: 'google-chrome-stable', + args: ['--no-sandbox'], + }); + page = yield browser.newPage(); + yield page.goto(`http://localhost:${port}`); + yield page.waitForFunction('!!window.blake3'); + yield page.evaluate(addInputs); + }); + }); + runTests({ + get page() { + return page; + }, + }); + after(() => { + page === null || page === void 0 ? void 0 : page.browser().close(); + server === null || server === void 0 ? void 0 : server.close(); + }); + }); + describe('native browser', () => { + let server; + let page; + function serve() { + return __awaiter(this, void 0, void 0, function* () { + server = http_1.createServer((req, res) => serve_handler_1.default(req, res, { public: path_1.resolve(__dirname, '..') })); + yield new Promise(resolve => server.listen(0, resolve)); + }); + } + before(function () { + return __awaiter(this, void 0, void 0, function* () { + yield serve(); + this.timeout(20 * 1000); + const { port } = server.address(); + const browser = yield puppeteer_1.default.launch({ + executablePath: 'google-chrome-stable', + args: ['--no-sandbox'], + }); + page = yield browser.newPage(); + page.on('console', console.log); + page.on('pageerror', console.log); + page.on('error', console.log); + yield page.goto(`http://localhost:${port}/browser-async.test.html`); + yield page.waitForFunction('!!window.blake3'); + yield page.evaluate(addInputs); + }); + }); + runTests({ + get page() { + return page; + }, + }); + after(() => { + page === null || page === void 0 ? void 0 : page.browser().close(); + server.close(); + }); + }); +}); +function runTests(opts) { + it('hashes a string', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.large.input).toString("hex")'); + chai_1.expect(result).to.equal(test_helpers_1.inputs.large.hash.toString('hex')); + })); + describe('input encoding', () => { + it('hashes a uint8array', () => __awaiter(this, void 0, void 0, function* () { + const contents = [...new Uint8Array(Buffer.from(test_helpers_1.inputs.hello.input))]; + const result = yield opts.page.evaluate(`blake3.hash(new Uint8Array([${contents.join(',')}])).toString("hex")`); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + })); + it('hashes a string', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.large.input).toString("hex")'); + chai_1.expect(result).to.equal(test_helpers_1.inputs.large.hash.toString('hex')); + })); + it('customizes output length', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.hello.input, { length: 16 }).toString("hex")'); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.slice(0, 16).toString('hex')); + })); + }); + describe('output encoding', () => { + const tcases = [ + { encoding: 'hex', expected: test_helpers_1.inputs.hello.hash.toString('hex') }, + { encoding: 'base64', expected: test_helpers_1.inputs.hello.hash.toString('base64') }, + { encoding: 'utf8', expected: test_helpers_1.inputs.hello.hash.toString('utf8') }, + ]; + tcases.forEach(({ encoding, expected }) => it(encoding, () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.hash(inputs.hello.input).toString("${encoding}")`); + chai_1.expect(result).to.equal(expected); + }))); + it('raw', () => __awaiter(this, void 0, void 0, function* () { + const result = (yield opts.page.evaluate(`blake3.hash(inputs.hello.input)`)); + const actual = Buffer.alloc(32); + for (let i = 0; i < actual.length; i++) { + actual[i] = result[i]; // it comes as a plain object, we need to convert it to a buffer + } + chai_1.expect(actual).to.deep.equal(test_helpers_1.inputs.hello.hash); + })); + }); + describe('hash class', () => { + it('digests', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + ${[...Buffer.from(test_helpers_1.inputs.hello.input)] + .map(byte => `hash.update(new Uint8Array([${byte}]));`) + .join('\n')} + return hash.digest('hex'); + })()`); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + })); + it('customizes the output length', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + hash.update(${JSON.stringify(test_helpers_1.inputs.hello.input)}); + return hash.digest('hex', { length: 16 }); + })()`); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.slice(0, 16).toString('hex')); + })); + it('returns a hash instance from digest', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + ${[...Buffer.from(test_helpers_1.inputs.hello.input)] + .map(byte => `hash.update(new Uint8Array([${byte}]));`) + .join('\n')} + return hash.digest('hex'); + })()`); + chai_1.expect(result).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + })); + }); + describe('reader', () => { + it('is sane with a Hash', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + hash.update("hello"); + + return blake3.using(hash.reader(), reader => [ + reader.read(48).toString('hex'), + reader.toArray().toString('hex'), + reader.toString('hex'), + ]); + })()`); + chai_1.expect(result).to.deep.equal([ + test_helpers_1.hello48.toString('hex'), + test_helpers_1.inputs.hello.hash.toString('hex'), + test_helpers_1.inputs.hello.hash.toString('hex'), + ]); + })); + }); + describe('original test vectors', () => { + for (const { inputLen, expectedDerive, expectedHash, expectedKeyed, } of test_helpers_1.ogTestVectors.cases.slice(0, 6)) { + describe(`${inputLen}`, () => __awaiter(this, void 0, void 0, function* () { + const input = Buffer.alloc(inputLen); + for (let i = 0; i < inputLen; i++) { + input[i] = i % 251; + } + const inputStr = `new Uint8Array([${input.join(',')}])`; + it('hash()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.hash( + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + chai_1.expect(result).to.equal(expectedHash); + })); + it('deriveKey()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.deriveKey( + ${JSON.stringify(test_helpers_1.ogTestVectors.context)}, + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + chai_1.expect(result).to.equal(expectedDerive); + })); + it('createKeyed()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hasher = blake3.createKeyed(new Uint8Array([${Buffer.from(test_helpers_1.ogTestVectors.key).join(',')}])); + hasher.update(${inputStr}); + return hasher.digest({ length: ${expectedHash.length / 2} }).toString('hex'); + })()`); + chai_1.expect(result).to.equal(expectedKeyed); + })); + it('keyedHash()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.keyedHash( + new Uint8Array([${Buffer.from(test_helpers_1.ogTestVectors.key).join(',')}]), + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + chai_1.expect(result).to.equal(expectedKeyed); + })); + })); + } + }); +} +//# sourceMappingURL=browser.test.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser.test.js.map b/node_modules/blake3-wasm/dist/browser.test.js.map new file mode 100644 index 0000000..78f1ea9 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.test.js","sourceRoot":"","sources":["../ts/browser.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,2BAA8C;AAC9C,+BAA4C;AAE5C,2BAA4B;AAC5B,+BAA+B;AAC/B,0DAA4C;AAC5C,kEAAoC;AACpC,sDAA8B;AAC9B,sDAAqE;AAErE,4EAA4E;AAC5E,4EAA4E;AAC5E,mEAAmE;AACnE,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,MAAM,SAAS,GAAG,mBAAmB,IAAI,CAAC,SAAS,CAAC,qBAAM,CAAC,EAAE,CAAC;IAE9D,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;QACvB,MAAM,OAAO,GAAG,cAAO,CAAC,WAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC;QACzD,IAAI,MAAc,CAAC;QACnB,IAAI,IAAoB,CAAC;QAEzB;;WAEG;QACH,SAAe,YAAY;;gBACzB,IAAI;oBACF,cA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C,IAAI,CAAC,4BAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CACrF,GAAG,CACJ;4BACe,QAAQ;6CACS,YAAY,CAAC,MAAM,GAAG,CAAC;eACrD,CAAC,CAAC;oBAEP,aAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBACzC,CAAC,CAAA,CAAC,CAAC;gBAEH,EAAE,CAAC,aAAa,EAAE,GAAS,EAAE;oBAC3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;8BACpB,MAAM,CAAC,IAAI,CAAC,4BAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;cACxD,QAAQ;wBACE,YAAY,CAAC,MAAM,GAAG,CAAC;4BACnB,CAAC,CAAC;oBAEpB,aAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;gBACzC,CAAC,CAAA,CAAC,CAAC;YACL,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/encoding.d.ts b/node_modules/blake3-wasm/dist/browser/encoding.d.ts new file mode 100644 index 0000000..4c8b547 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/encoding.d.ts @@ -0,0 +1,5 @@ +export declare type BrowserEncoding = 'hex' | 'base64' | 'utf8'; +/** + * @hidden + */ +export declare const mustGetEncoder: (encoding: BrowserEncoding) => (data: Uint8Array) => string; diff --git a/node_modules/blake3-wasm/dist/browser/encoding.js b/node_modules/blake3-wasm/dist/browser/encoding.js new file mode 100644 index 0000000..2d61341 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/encoding.js @@ -0,0 +1,30 @@ +"use strict"; +// A small collection of encodings for convenience of use in the browser. +Object.defineProperty(exports, "__esModule", { value: true }); +const decoder = new TextDecoder(); +const encoders = { + // certainly not the fastest, but hashes are pretty small + base64: data => btoa(String.fromCharCode(...data)), + hex: data => { + let out = ''; + for (const byte of data) { + if (byte < 0x10) { + out += '0'; + } + out += byte.toString(16); + } + return out; + }, + utf8: data => decoder.decode(data), +}; +/** + * @hidden + */ +exports.mustGetEncoder = (encoding) => { + const encoder = encoders[encoding]; + if (!encoder) { + throw new Error(`Unknown encoding ${encoding}`); + } + return encoder; +}; +//# sourceMappingURL=encoding.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/encoding.js.map b/node_modules/blake3-wasm/dist/browser/encoding.js.map new file mode 100644 index 0000000..b524e4a --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/encoding.js.map @@ -0,0 +1 @@ +{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../ts/browser/encoding.ts"],"names":[],"mappings":";AAAA,yEAAyE;;AAIzE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,QAAQ,GAA6D;IACzE,yDAAyD;IACzD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IAElD,GAAG,EAAE,IAAI,CAAC,EAAE;QACV,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;YACvB,IAAI,IAAI,GAAG,IAAI,EAAE;gBACf,GAAG,IAAI,GAAG,CAAC;aACZ;YAED,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SAC1B;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;CACnC,CAAC;AAEF;;GAEG;AACU,QAAA,cAAc,GAAG,CAAC,QAAyB,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;KACjD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-fn.d.ts b/node_modules/blake3-wasm/dist/browser/hash-fn.d.ts new file mode 100644 index 0000000..a341ea2 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-fn.d.ts @@ -0,0 +1,24 @@ +import { BaseHashInput, IBaseHashOptions } from '../base/hash-fn'; +import { Hash } from './hash'; +/** + * Input used for browser-based hashes. + */ +export declare type HashInput = BaseHashInput | string; +/** + * @hidden + */ +export declare const normalizeInput: (input: import("..").HashInput) => Uint8Array; +/** + * Returns a blake3 hash of the input. + */ +export declare function hash(input: HashInput, { length }?: IBaseHashOptions): 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. + */ +export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Hash; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export declare function keyedHash(key: Uint8Array, input: HashInput, { length }?: IBaseHashOptions): Hash; diff --git a/node_modules/blake3-wasm/dist/browser/hash-fn.js b/node_modules/blake3-wasm/dist/browser/hash-fn.js new file mode 100644 index 0000000..5259980 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-fn.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_fn_1 = require("../base/hash-fn"); +const hash_1 = require("./hash"); +const wasm_1 = require("./wasm"); +const textEncoder = new TextEncoder(); +/** + * @hidden + */ +exports.normalizeInput = (input) => hash_fn_1.inputToArray(typeof input === 'string' ? textEncoder.encode(input) : input); +/** + * Returns a blake3 hash of the input. + */ +function hash(input, { length = hash_fn_1.defaultHashLength } = {}) { + const result = new hash_1.Hash(length); + wasm_1.getWasm().hash(exports.normalizeInput(input), result); + return result; +} +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 derive = wasm_1.getWasm().create_derive(context); + derive.update(exports.normalizeInput(material)); + const result = new hash_1.Hash(length); + derive.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 } = {}) { + if (key.length !== 32) { + throw new Error(`key provided to keyedHash must be 32 bytes, got ${key.length}`); + } + const derive = wasm_1.getWasm().create_keyed(key); + derive.update(exports.normalizeInput(input)); + const result = new hash_1.Hash(length); + derive.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/browser/hash-fn.js.map b/node_modules/blake3-wasm/dist/browser/hash-fn.js.map new file mode 100644 index 0000000..9ce0b9c --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/browser/hash-fn.ts"],"names":[],"mappings":";;AAAA,6CAAmG;AACnG,iCAA8B;AAC9B,iCAAiC;AAOjC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC;;GAEG;AACU,QAAA,cAAc,GAAG,CAAC,KAAgB,EAAc,EAAE,CAC7D,sBAAY,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAE9E;;GAEG;AACH,SAAgB,IAAI,CAClB,KAAgB,EAChB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,IAAI,WAAI,CAAC,MAAM,CAAC,CAAC;IAChC,cAAO,EAAE,CAAC,IAAI,CAAC,sBAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC;AAPD,oBAOC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CACvB,OAAe,EACf,QAAmB,EACnB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,cAAO,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,IAAI,WAAI,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,8BAUC;AAED;;GAEG;AACH,SAAgB,SAAS,CACvB,GAAe,EACf,KAAgB,EAChB,EAAE,MAAM,GAAG,2BAAiB,KAAuB,EAAE;IAErD,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClF;IAED,MAAM,MAAM,GAAG,cAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,sBAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,WAAI,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAdD,8BAcC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-instance.d.ts b/node_modules/blake3-wasm/dist/browser/hash-instance.d.ts new file mode 100644 index 0000000..0a706b3 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-instance.d.ts @@ -0,0 +1,31 @@ +import { BaseHash as BaseHasher } from '../base/index'; +import { HashInput } from './hash-fn'; +import { BrowserEncoding } from './encoding'; +import { IBaseHashOptions } from '../base/hash-fn'; +import { BrowserHashReader } from './hash-reader'; +import { IInternalReader } from '../base/hash-reader'; +import { Hash } from './hash'; +/** + * @inheritdoc + */ +export declare class BrowserHasher extends BaseHasher<Hash, IInternalReader, BrowserHashReader> { + /** + * @inheritdoc + * @override + */ + update(data: HashInput): this; + /** + * Returns a digest of the hash with the given encoding. + */ + digest(options?: IBaseHashOptions): Hash; + digest(encoding: undefined, options: IBaseHashOptions): Hash; + digest(encoding: BrowserEncoding, options?: IBaseHashOptions): string; +} +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => BrowserHasher; +/** + * A Node.js crypto-like createHash method. + */ +export declare const createKeyed: (key: Uint8Array) => BrowserHasher; diff --git a/node_modules/blake3-wasm/dist/browser/hash-instance.js b/node_modules/blake3-wasm/dist/browser/hash-instance.js new file mode 100644 index 0000000..6319357 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-instance.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const index_1 = require("../base/index"); +const hash_fn_1 = require("./hash-fn"); +const encoding_1 = require("./encoding"); +const hash_reader_1 = require("./hash-reader"); +const hash_1 = require("./hash"); +const wasm_1 = require("./wasm"); +/** + * @inheritdoc + */ +class BrowserHasher extends index_1.BaseHash { + /** + * @inheritdoc + * @override + */ + update(data) { + return super.update(hash_fn_1.normalizeInput(data)); + } + digest(encoding, options) { + let resolvedOpts; + let resolvedEnc; + if (encoding && typeof encoding === 'object') { + resolvedOpts = encoding; + resolvedEnc = undefined; + } + else { + resolvedOpts = options; + resolvedEnc = encoding; + } + const result = super.digest(resolvedOpts); + return resolvedEnc ? encoding_1.mustGetEncoder(resolvedEnc)(result) : result; + } +} +exports.BrowserHasher = BrowserHasher; +/** + * A Node.js crypto-like createHash method. + */ +exports.createHash = () => new BrowserHasher(wasm_1.getWasm().create_hasher(), l => new hash_1.Hash(l), r => new hash_reader_1.BrowserHashReader(r)); +/** + * A Node.js crypto-like createHash method. + */ +exports.createKeyed = (key) => new BrowserHasher(wasm_1.getWasm().create_keyed(key), l => new hash_1.Hash(l), r => new hash_reader_1.BrowserHashReader(r)); +//# sourceMappingURL=hash-instance.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-instance.js.map b/node_modules/blake3-wasm/dist/browser/hash-instance.js.map new file mode 100644 index 0000000..211b802 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/browser/hash-instance.ts"],"names":[],"mappings":";;AAAA,yCAAuD;AACvD,uCAAsD;AACtD,yCAA6D;AAE7D,+CAAkD;AAElD,iCAA8B;AAC9B,iCAAiC;AAEjC;;GAEG;AACH,MAAa,aAAc,SAAQ,gBAAoD;IACrF;;;OAGG;IACI,MAAM,CAAC,IAAe;QAC3B,OAAO,KAAK,CAAC,MAAM,CAAC,wBAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAQM,MAAM,CACX,QAA6C,EAC7C,OAA0B;QAE1B,IAAI,YAA0C,CAAC;QAC/C,IAAI,WAAwC,CAAC;QAC7C,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAC5C,YAAY,GAAG,QAAQ,CAAC;YACxB,WAAW,GAAG,SAAS,CAAC;SACzB;aAAM;YACL,YAAY,GAAG,OAAO,CAAC;YACvB,WAAW,GAAG,QAAQ,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,CAAC,CAAC,yBAAc,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACpE,CAAC;CACF;AAhCD,sCAgCC;AAED;;GAEG;AACU,QAAA,UAAU,GAAG,GAAG,EAAE,CAC7B,IAAI,aAAa,CACf,cAAO,EAAE,CAAC,aAAa,EAAE,EACzB,CAAC,CAAC,EAAE,CAAC,IAAI,WAAI,CAAC,CAAC,CAAC,EAChB,CAAC,CAAC,EAAE,CAAC,IAAI,+BAAiB,CAAC,CAAC,CAAC,CAC9B,CAAC;AAEJ;;GAEG;AACU,QAAA,WAAW,GAAG,CAAC,GAAe,EAAE,EAAE,CAC7C,IAAI,aAAa,CACf,cAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAC3B,CAAC,CAAC,EAAE,CAAC,IAAI,WAAI,CAAC,CAAC,CAAC,EAChB,CAAC,CAAC,EAAE,CAAC,IAAI,+BAAiB,CAAC,CAAC,CAAC,CAC9B,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-reader.d.ts b/node_modules/blake3-wasm/dist/browser/hash-reader.d.ts new file mode 100644 index 0000000..f2a75c7 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-reader.d.ts @@ -0,0 +1,17 @@ +import { BaseHashReader } from '../base/hash-reader'; +import { BrowserEncoding } from './encoding'; +import { Hash } from './hash'; +/** + * A hash reader for WebAssembly targets. + */ +export declare class BrowserHashReader extends BaseHashReader<Hash> { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding?: BrowserEncoding): string; + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray(): Hash; + protected alloc(bytes: number): Hash; +} diff --git a/node_modules/blake3-wasm/dist/browser/hash-reader.js b/node_modules/blake3-wasm/dist/browser/hash-reader.js new file mode 100644 index 0000000..a48c3b2 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-reader.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_reader_1 = require("../base/hash-reader"); +const hash_1 = require("./hash"); +const index_1 = require("../base/index"); +/** + * A hash reader for WebAssembly targets. + */ +class BrowserHashReader extends hash_reader_1.BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toArray().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray() { + this.position = BigInt(0); + return this.read(index_1.defaultHashLength); + } + alloc(bytes) { + return new hash_1.Hash(bytes); + } +} +exports.BrowserHashReader = BrowserHashReader; +//# sourceMappingURL=hash-reader.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash-reader.js.map b/node_modules/blake3-wasm/dist/browser/hash-reader.js.map new file mode 100644 index 0000000..b25f1a0 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/browser/hash-reader.ts"],"names":[],"mappings":";;AAAA,qDAAqD;AAErD,iCAA8B;AAC9B,yCAAkD;AAElD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,4BAAoB;IACzD;;OAEG;IACI,QAAQ,CAAC,WAA4B,KAAK;QAC/C,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAiB,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,KAAa;QAC3B,OAAO,IAAI,WAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACF;AAnBD,8CAmBC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash.d.ts b/node_modules/blake3-wasm/dist/browser/hash.d.ts new file mode 100644 index 0000000..6487771 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash.d.ts @@ -0,0 +1,11 @@ +import { BrowserEncoding } from './encoding'; +/** + * Hash returned from functions in the browser. + */ +export declare class Hash extends Uint8Array { + /** + * A constant-time comparison against the other hash/array. + */ + equals(other: unknown): boolean; + toString(encoding?: BrowserEncoding): string; +} diff --git a/node_modules/blake3-wasm/dist/browser/hash.js b/node_modules/blake3-wasm/dist/browser/hash.js new file mode 100644 index 0000000..16145aa --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const encoding_1 = require("./encoding"); +/** + * Hash returned from functions in the browser. + */ +class Hash extends Uint8Array { + /** + * A constant-time comparison against the other hash/array. + */ + equals(other) { + if (!(other instanceof Uint8Array)) { + return false; + } + if (other.length !== this.length) { + return false; + } + let cmp = 0; + for (let i = 0; i < this.length; i++) { + cmp |= this[i] ^ other[i]; + } + return cmp === 0; + } + toString(encoding = 'hex') { + return encoding_1.mustGetEncoder(encoding)(this); + } +} +exports.Hash = Hash; +//# sourceMappingURL=hash.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/hash.js.map b/node_modules/blake3-wasm/dist/browser/hash.js.map new file mode 100644 index 0000000..33039d2 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/hash.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../ts/browser/hash.ts"],"names":[],"mappings":";;AAAA,yCAA6D;AAE7D;;GAEG;AACH,MAAa,IAAK,SAAQ,UAAU;IAClC;;OAEG;IACI,MAAM,CAAC,KAAc;QAC1B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;YAClC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3B;QAED,OAAO,GAAG,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,QAAQ,CAAC,WAA4B,KAAK;QAC/C,OAAO,yBAAc,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAxBD,oBAwBC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/index.d.ts b/node_modules/blake3-wasm/dist/browser/index.d.ts new file mode 100644 index 0000000..f44c7ed --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/index.d.ts @@ -0,0 +1,3 @@ +export { hash, HashInput, deriveKey, keyedHash } from './hash-fn'; +export * from './hash-instance'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/dist/browser/index.js b/node_modules/blake3-wasm/dist/browser/index.js new file mode 100644 index 0000000..3a8ca9e --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/index.js @@ -0,0 +1,12 @@ +"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("./hash-instance")); +__export(require("../base/index")); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/index.js.map b/node_modules/blake3-wasm/dist/browser/index.js.map new file mode 100644 index 0000000..9595245 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/browser/index.ts"],"names":[],"mappings":";;;;;AAAA,qCAAkE;AAAzD,yBAAA,IAAI,CAAA;AAAa,8BAAA,SAAS,CAAA;AAAE,8BAAA,SAAS,CAAA;AAC9C,qCAAgC;AAChC,mCAA8B"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/wasm.d.ts b/node_modules/blake3-wasm/dist/browser/wasm.d.ts new file mode 100644 index 0000000..559b61e --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/wasm.d.ts @@ -0,0 +1,10 @@ +import * as rawWasm from '../../dist/wasm/browser/blake3_js'; +/** + * Gets the webassembly module provided in provideWasm. + */ +export declare const getWasm: () => typeof rawWasm; +/** + * Sets the webassembly module used for the browser build. This indirection is + * needed to provide compatibility between the "browser" and "browser-async" modes. + */ +export declare const provideWasm: (w: typeof rawWasm) => void; diff --git a/node_modules/blake3-wasm/dist/browser/wasm.js b/node_modules/blake3-wasm/dist/browser/wasm.js new file mode 100644 index 0000000..8bef8fe --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/wasm.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let wasm; +/** + * Gets the webassembly module provided in provideWasm. + */ +exports.getWasm = () => { + if (!wasm) { + throw new Error('BLAKE3 webassembly not loaded. Please import the module via `blake3/browser` or `blake3/browser-async`'); + } + return wasm; +}; +/** + * Sets the webassembly module used for the browser build. This indirection is + * needed to provide compatibility between the "browser" and "browser-async" modes. + */ +exports.provideWasm = (w) => { + wasm = w; +}; +//# sourceMappingURL=wasm.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/browser/wasm.js.map b/node_modules/blake3-wasm/dist/browser/wasm.js.map new file mode 100644 index 0000000..7ee45c5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/browser/wasm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../ts/browser/wasm.ts"],"names":[],"mappings":";;AAEA,IAAI,IAAoB,CAAC;AAEzB;;GAEG;AACU,QAAA,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,WAAW,GAAG,CAAC,CAAiB,EAAE,EAAE;IAC/C,IAAI,GAAG,CAAC,CAAC;AACX,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/add-js-extensions.d.ts b/node_modules/blake3-wasm/dist/build/add-js-extensions.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/add-js-extensions.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/build/add-js-extensions.js b/node_modules/blake3-wasm/dist/build/add-js-extensions.js new file mode 100644 index 0000000..0aa30af --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/add-js-extensions.js @@ -0,0 +1,49 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const ts = __importStar(require("typescript")); +const fs_1 = require("fs"); +const path_1 = require("path"); +/** + * Script that adds .js extension to imports so that it's compatible with plain + * browser/non-webpack bundlers. TS doesn't support this natively yet. + * @see https://github.com/microsoft/TypeScript/issues/16577 + */ +function processFile(file) { + let source = fs_1.readFileSync(file, 'utf-8'); + const program = ts.createSourceFile(path_1.basename(file), source, ts.ScriptTarget.ES2015, true); + let offset = 0; + const process = (node) => { + if ((!ts.isImportDeclaration(node) && !ts.isExportDeclaration(node)) || !node.moduleSpecifier) { + return ts.forEachChild(node, process); + } + const specifier = node.moduleSpecifier; + if (path_1.extname(specifier.getText()) === '') { + const idx = specifier.end + offset - 1; + source = source.slice(0, idx) + '.js' + source.slice(idx); + offset += 3; + } + }; + process(program); + fs_1.writeFileSync(file, source); +} +function processDir(dir) { + const entries = fs_1.readdirSync(dir); + for (const entry of entries) { + const path = path_1.join(dir, entry); + if (path.endsWith('.js')) { + processFile(path); + } + else if (fs_1.statSync(path).isDirectory()) { + processDir(path); + } + } +} +processDir(path_1.resolve(__dirname, '..', '..', 'esm')); +//# sourceMappingURL=add-js-extensions.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/add-js-extensions.js.map b/node_modules/blake3-wasm/dist/build/add-js-extensions.js.map new file mode 100644 index 0000000..3dcb10c --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/add-js-extensions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"add-js-extensions.js","sourceRoot":"","sources":["../../ts/build/add-js-extensions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAiC;AACjC,2BAAwE;AACxE,+BAAwD;AAExD;;;;GAIG;AAEH,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,MAAM,GAAG,iBAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,eAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE1F,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,OAAO,GAAG,CAAC,IAAa,EAAQ,EAAE;QACtC,IAAI,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YAC7F,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SACvC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC;QACvC,IAAI,cAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACvC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;YACvC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1D,MAAM,IAAI,CAAC,CAAC;SACb;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjB,kBAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,OAAO,GAAG,gBAAW,CAAC,GAAG,CAAC,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,IAAI,GAAG,WAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACxB,WAAW,CAAC,IAAI,CAAC,CAAC;SACnB;aAAM,IAAI,aAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;YACvC,UAAU,CAAC,IAAI,CAAC,CAAC;SAClB;KACF;AACH,CAAC;AAED,UAAU,CAAC,cAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/generate-tasks.d.ts b/node_modules/blake3-wasm/dist/build/generate-tasks.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/generate-tasks.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/build/generate-tasks.js b/node_modules/blake3-wasm/dist/build/generate-tasks.js new file mode 100644 index 0000000..bea411b --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/generate-tasks.js @@ -0,0 +1,88 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs_1 = require("fs"); +const js_yaml_1 = require("js-yaml"); +const node_fetch_1 = __importDefault(require("node-fetch")); +const path_1 = require("path"); +const minVersion = 64; +(() => __awaiter(void 0, void 0, void 0, function* () { + const res = yield node_fetch_1.default('https://nodejs.org/dist/index.json'); + if (!res.ok) { + throw new Error(`${res.status} error from Node.js releases page`); + } + const releases = yield res.json(); + const buildVersion = new Map(); + const versionMap = {}; + for (const release of releases) { + const moduleVersion = Number(release.modules); + if (!moduleVersion || moduleVersion < minVersion) { + break; + } + versionMap[release.version] = Number(moduleVersion); + if (buildVersion.has(moduleVersion)) { + continue; + } + buildVersion.set(moduleVersion, release.version); + } + const buildYaml = { + name: 'Generate Binaries', + on: { + push: { + branches: ['generate-binary'], + }, + }, + jobs: { + build: { + name: 'Build', + 'runs-on': '${{ matrix.os }}', + strategy: { + matrix: { os: ['macos-latest', 'ubuntu-latest', 'windows-latest'] }, + }, + steps: [ + { uses: 'actions/checkout@master' }, + { run: 'mkdir dist' }, + { + uses: 'actions-rs/toolchain@v1', + with: { target: 'wasm32-unknown-unknown', toolchain: 'nightly' }, + }, + ...[...buildVersion.entries()] + .map(([moduleVersion, nodeVersion], i) => [ + { uses: 'actions/setup-node@v1', with: { 'node-version': nodeVersion } }, + { + // See: https://github.com/actions/setup-node/issues/68 + shell: 'powershell', + name: 'patch node-gyp for VS 2019', + run: 'npm install --global node-gyp@latest\r\nnpm prefix -g | % {npm config set node_gyp "$_\\node_modules\\node-gyp\\bin\\node-gyp.js"}', + if: "matrix.os == 'windows-latest'", + }, + i === 0 + ? { run: 'npm install neon-cli rimraf' } + : { run: './node_modules/.bin/rimraf rs/native/target' }, + { run: '../node_modules/.bin/neon build --release', 'working-directory': 'rs' }, + { run: `mv rs/native/index.node dist/\${{ matrix.os }}-${moduleVersion}.node` }, + ]) + .reduce((acc, v) => [...acc, ...v], []), + { + uses: 'actions/upload-artifact@v1', + with: { name: 'dist', path: 'dist' }, + }, + ], + }, + }, + }; + fs_1.writeFileSync(path_1.join(__dirname, '..', '..', '.github', 'workflows', 'build-neon.yml'), js_yaml_1.dump(buildYaml)); + fs_1.writeFileSync(path_1.join(__dirname, '..', '..', 'targets.json'), JSON.stringify(versionMap)); +}))(); +//# sourceMappingURL=generate-tasks.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/generate-tasks.js.map b/node_modules/blake3-wasm/dist/build/generate-tasks.js.map new file mode 100644 index 0000000..908f629 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/generate-tasks.js.map @@ -0,0 +1 @@ +{"version":3,"file":"generate-tasks.js","sourceRoot":"","sources":["../../ts/build/generate-tasks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2BAAmC;AACnC,qCAA+B;AAC/B,4DAA+B;AAC/B,+BAA4B;AAE5B,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,CAAC,GAAS,EAAE;IACV,MAAM,GAAG,GAAG,MAAM,oBAAK,CAAC,oCAAoC,CAAC,CAAC;IAC9D,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,mCAAmC,CAAC,CAAC;KACnE;IAED,MAAM,QAAQ,GAA2C,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1E,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC/C,MAAM,U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4BACvD,KAAK,EAAE,YAAY;4BACnB,IAAI,EAAE,4BAA4B;4BAClC,GAAG,EACD,oIAAoI;4BACtI,EAAE,EAAE,+BAA+B;yBACpC;wBACD,CAAC,KAAK,CAAC;4BACL,CAAC,CAAC,EAAE,GAAG,EAAE,6BAA6B,EAAE;4BACxC,CAAC,CAAC,EAAE,GAAG,EAAE,6CAA6C,EAAE;wBAC1D,EAAE,GAAG,EAAE,2CAA2C,EAAE,mBAAmB,EAAE,IAAI,EAAE;wBAC/E,EAAE,GAAG,EAAE,kDAAkD,aAAa,OAAO,EAAE;qBAChF,CAAC;yBACD,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;oBACzC;wBACE,IAAI,EAAE,4BAA4B;wBAClC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;qBACrC;iBACF;aACF;SACF;KACF,CAAC;IAEF,kBAAa,CACX,WAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,CAAC,EACrE,cAAI,CAAC,SAAS,CAAC,CAChB,CAAC;IACF,kBAAa,CAAC,WAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AACzF,CAAC,CAAA,CAAC,EAAE,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/install.d.ts b/node_modules/blake3-wasm/dist/build/install.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/install.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/build/install.js b/node_modules/blake3-wasm/dist/build/install.js new file mode 100644 index 0000000..20fe5f0 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/install.js @@ -0,0 +1,100 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs_1 = require("fs"); +const https_1 = require("https"); +const path_1 = require("path"); +const stream_1 = require("stream"); +const versions_1 = require("./versions"); +/** + * Post-install script. Downloads the binary for the current Node.js version + * from the Gitub releases page, if it's available. + */ +const builtPlatforms = { + win32: 'windows-latest', + linux: 'ubuntu-latest', + darwin: 'macos-latest', +}; +const { version } = require('../../package.json'); +const repoUrl = process.env.BLAKE3_REPO_URL || 'https://github.com/connor4312/blake3'; +const targets = require('../../targets.json'); +const bindingPath = path_1.join(__dirname, '..', 'native.node'); +function install() { + return __awaiter(this, void 0, void 0, function* () { + const current = versions_1.parseVersion(process.version); + const api = getBestAbiVersion(current); + if (!api) { + console.error('Your Node.js release is out of LTS and BLAKE3 bindings are not built for it. Update it to use native BLAKE3 bindings.'); + return fallback(); + } + const platform = builtPlatforms[process.platform]; + if (!platform) { + console.error(`BLAKE3 bindings are not built for your platform (${process.platform})`); + return fallback(); + } + console.log(`Retrieving native BLAKE3 bindings for Node ${api.nodeVersion} on ${process.platform}...`); + yield download(`${repoUrl}/releases/download/v${version}/${platform}-${api.abiVersion}.node`); + try { + require(bindingPath); + } + catch (e) { + console.log(`Error trying to import bindings: ${e.message}`); + return fallback(); + } + useNativeImport(); + console.log('BLAKE3 bindings retrieved'); + }); +} +function getBestAbiVersion(current) { + for (const targetVersion of Object.keys(targets)) { + const parsed = versions_1.parseVersion(targetVersion); + if (versions_1.compareVersion(current, parsed) >= 0) { + return { nodeVersion: targetVersion, abiVersion: targets[targetVersion] }; + } + } + return undefined; +} +function fallback() { + console.error('BLAKE3 will use slower WebAssembly bindings when required in Node.js'); +} +function download(url) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise(resolve => { + const onError = (err) => { + console.error(`Could not download binding from ${url}: ${err.stack || err.message}`); + resolve(false); + }; + const req = https_1.get(url, res => { + if (res.headers.location) { + resolve(download(res.headers.location)); + return; + } + if (!res.statusCode || res.statusCode >= 300) { + console.error(`Unexpected ${res.statusCode} from ${url}`); + resolve(false); + return; + } + stream_1.pipeline(res, fs_1.createWriteStream(bindingPath), err => (err ? onError(err) : resolve(true))); + }); + req.on('error', onError); + }); + }); +} +function useNativeImport() { + const indexFile = path_1.join(__dirname, '..', 'index.js'); + const contents = fs_1.readFileSync(indexFile, 'utf-8'); + fs_1.writeFileSync(indexFile, contents.replace('"./node"', '"./node-native"')); +} +install().catch(err => { + console.error(`There was an uncaught error installing native bindings: ${err.stack}`); + fallback(); +}); +//# sourceMappingURL=install.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/install.js.map b/node_modules/blake3-wasm/dist/build/install.js.map new file mode 100644 index 0000000..3bf335b --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/install.js.map @@ -0,0 +1 @@ +{"version":3,"file":"install.js","sourceRoot":"","sources":["../../ts/build/install.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2BAAoE;AACpE,iCAA4B;AAC5B,+BAA4B;AAC5B,mCAAkC;AAClC,yCAAoE;AAEpE;;;GAGG;AAEH,MAAM,cAAc,GAAwC;IAC1D,KAAK,EAAE,gBAAgB;IACvB,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,cAAc;CACvB,CAAC;AAEF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAClD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,sC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I,CAAC,CAAC,CAAC,CAAC;YAC7F,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAED,SAAS,eAAe;IACtB,MAAM,SAAS,GAAG,WAAI,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,iBAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClD,kBAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACpB,OAAO,CAAC,KAAK,CAAC,2DAA2D,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;IACtF,QAAQ,EAAE,CAAC;AACb,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/versions.d.ts b/node_modules/blake3-wasm/dist/build/versions.d.ts new file mode 100644 index 0000000..17d9841 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/versions.d.ts @@ -0,0 +1,14 @@ +export declare const minNodeVersion = 10; +/** + * @hidden + */ +export interface IVersion { + major: number; + minor: number; + patch: number; +} +/** + * @hidden + */ +export declare const parseVersion: (version: string) => IVersion; +export declare const compareVersion: (a: IVersion, b: IVersion) => number; diff --git a/node_modules/blake3-wasm/dist/build/versions.js b/node_modules/blake3-wasm/dist/build/versions.js new file mode 100644 index 0000000..e97f1af --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/versions.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.minNodeVersion = 10; +/** + * @hidden + */ +exports.parseVersion = (version) => { + const [, major, minor, patch] = /^v([0-9]+)\.([0-9]+)\.([0-9]+)/.exec(version) || []; + return { major: Number(major), minor: Number(minor), patch: Number(patch) }; +}; +exports.compareVersion = (a, b) => a.major - b.major || a.minor - b.minor || a.patch - b.patch; +//# sourceMappingURL=versions.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/build/versions.js.map b/node_modules/blake3-wasm/dist/build/versions.js.map new file mode 100644 index 0000000..74900e0 --- /dev/null +++ b/node_modules/blake3-wasm/dist/build/versions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../ts/build/versions.ts"],"names":[],"mappings":";;AAAa,QAAA,cAAc,GAAG,EAAE,CAAC;AAWjC;;GAEG;AACU,QAAA,YAAY,GAAG,CAAC,OAAe,EAAY,EAAE;IACxD,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,gCAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACrF,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC9E,CAAC,CAAC;AAEW,QAAA,cAAc,GAAG,CAAC,CAAW,EAAE,CAAW,EAAE,EAAE,CACzD,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/index.d.ts b/node_modules/blake3-wasm/dist/index.d.ts new file mode 100644 index 0000000..d0dddb6 --- /dev/null +++ b/node_modules/blake3-wasm/dist/index.d.ts @@ -0,0 +1 @@ +export * from './node'; diff --git a/node_modules/blake3-wasm/dist/index.js b/node_modules/blake3-wasm/dist/index.js new file mode 100644 index 0000000..3834342 --- /dev/null +++ b/node_modules/blake3-wasm/dist/index.js @@ -0,0 +1,19 @@ +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +// Bunlers add the `process.browser` flag to indicate the build enviroment. +// Throw a verbose error if we see people bundling the Node.js build in their +// browser, since it probably won't work for them (or at least not give them) +// nice tree shaking and such. +// +// Note that we don't check the presence of window/document, since those can +// be emulated in common test scenarios (e.g. jest's default setup with jsdom). +if (process.browser) { + throw new Error('You tried to import the Node.js version of blake3, instead of the browser ' + + 'version, in your build. You can fix this by importing "blake3/browser" ' + + 'instead of "blake3"'); +} +__export(require("./node")); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/index.js.map b/node_modules/blake3-wasm/dist/index.js.map new file mode 100644 index 0000000..8c9776b --- /dev/null +++ b/node_modules/blake3-wasm/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,8BAA8B;AAC9B,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,IAAK,OAAe,CAAC,OAAO,EAAE;IAC5B,MAAM,IAAI,KAAK,CACb,4EAA4E;QAC1E,yEAAyE;QACzE,qBAAqB,CACxB,CAAC;CACH;AAED,4BAAuB"}
\ No newline at end of file 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 diff --git a/node_modules/blake3-wasm/dist/node.test.d.ts b/node_modules/blake3-wasm/dist/node.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/dist/node.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/dist/node.test.js b/node_modules/blake3-wasm/dist/node.test.js new file mode 100644 index 0000000..c368975 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node.test.js @@ -0,0 +1,207 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const wasm = __importStar(require("./node")); +const native = __importStar(require("./node-native")); +const chai_1 = require("chai"); +const test_helpers_1 = require("./base/test-helpers"); +const stream_buffers_1 = require("stream-buffers"); +const hash_reader_1 = require("./base/hash-reader"); +function suite({ hash, createHash, keyedHash, deriveKey, createDeriveKey, createKeyed, }) { + describe('encoding', () => { + it('hashes a buffer', () => { + chai_1.expect(hash(Buffer.from(test_helpers_1.inputs.hello.input))).to.deep.equal(test_helpers_1.inputs.hello.hash); + }); + it('hashes a string', () => { + chai_1.expect(hash(test_helpers_1.inputs.hello.input)).to.deep.equal(test_helpers_1.inputs.hello.hash); + }); + it('hashes an arraybuffer', () => { + const buf = Buffer.from(test_helpers_1.inputs.hello.input); + chai_1.expect(hash(new Uint8Array(buf).buffer)).to.deep.equal(test_helpers_1.inputs.hello.hash); + }); + it('customizes the output length', () => { + chai_1.expect(hash(test_helpers_1.inputs.hello.input, { length: 16 })).to.deep.equal(test_helpers_1.inputs.hello.hash.slice(0, 16)); + }); + }); + describe('memory-safety (#5)', () => { + it('hash', () => { + const hashA = hash('hello'); + const hashB = hash('goodbye'); + chai_1.expect(hashA.toString('hex')).to.equal('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f'); + chai_1.expect(hashB.toString('hex')).to.equal('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69'); + }); + it('hasher', () => { + const hasherA = createHash(); + const hasherB = createHash(); + hasherA.update('hel'); + hasherB.update('good'); + hasherA.update('lo'); + hasherB.update('bye'); + const hashA = hasherA.digest(); + const hashB = hasherB.digest(); + chai_1.expect(hashA.toString('hex')).to.equal('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f'); + chai_1.expect(hashB.toString('hex')).to.equal('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69'); + }); + }); + describe('hasher', () => { + it('digests', callback => { + const buffer = new stream_buffers_1.ReadableStreamBuffer(); + buffer.put(Buffer.from(test_helpers_1.inputs.large.input)); + buffer.stop(); + const hash = createHash(); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest(); + chai_1.expect(actual).to.deep.equal(test_helpers_1.inputs.large.hash); + callback(); + }); + }); + it('is a transform stream', callback => { + const buffer = new stream_buffers_1.ReadableStreamBuffer(); + buffer.put(Buffer.from(test_helpers_1.inputs.large.input)); + buffer.stop(); + buffer + .pipe(createHash()) + .on('error', callback) + .on('data', hash => { + chai_1.expect(hash).to.deep.equal(test_helpers_1.inputs.large.hash); + callback(); + }); + }); + it('customizes the output length', () => { + const hash = createHash(); + hash.update(test_helpers_1.inputs.hello.input); + chai_1.expect(hash.digest('hex', { length: 16 })).to.equal(test_helpers_1.inputs.hello.hash.slice(0, 16).toString('hex')); + }); + it('throws on write after dispose', () => { + const hash = createHash(); + hash.dispose(); + chai_1.expect(() => hash.update('')).to.throw(/after dispose/); + }); + it('allows taking incremental hashes', () => { + const hasher = createHash(); + hasher.update('hel'); + const hashA = hasher.digest(undefined, { dispose: false }); + const readA = hasher.reader({ dispose: false }); + hasher.update('lo'); + const hashB = hasher.digest(undefined, { dispose: false }); + const readB = hasher.reader({ dispose: false }); + const expectedA = Buffer.from('3121c5bb1b9193123447ac7cfda042f67f967e7a8cf5c12e7570e25529746e4a', 'hex'); + chai_1.expect(hashA).to.deep.equal(expectedA); + chai_1.expect(readA.toBuffer()).to.deep.equal(expectedA); + chai_1.expect(hashB).to.deep.equal(test_helpers_1.inputs.hello.hash); + chai_1.expect(readB.toBuffer()).to.deep.equal(test_helpers_1.inputs.hello.hash); + hasher.dispose(); + readA.dispose(); + readB.dispose(); + }); + }); + describe('reader', () => { + let reader; + beforeEach(() => { + const hash = createHash(); + hash.update(test_helpers_1.inputs.hello.input); + reader = hash.reader(); + }); + afterEach(() => reader.dispose()); + it('implements toString()', () => { + chai_1.expect(reader.toString('hex')).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + reader.position = BigInt(42); + chai_1.expect(reader.toString('hex')).to.equal(test_helpers_1.inputs.hello.hash.toString('hex')); + }); + it('implements toBuffer()', () => { + chai_1.expect(reader.toBuffer()).to.deep.equal(test_helpers_1.inputs.hello.hash); + reader.position = BigInt(42); + chai_1.expect(reader.toBuffer()).to.deep.equal(test_helpers_1.inputs.hello.hash); + }); + it('implements readInto() and advances', () => { + const actual = Buffer.alloc(32); + reader.readInto(actual.slice(0, 10)); + reader.readInto(actual.slice(10)); + chai_1.expect(actual).to.deep.equal(test_helpers_1.inputs.hello.hash); + chai_1.expect(reader.position).to.equal(BigInt(32)); + }); + it('implements read() and advances', () => { + const actual = reader.read(32); + chai_1.expect(actual).to.deep.equal(test_helpers_1.inputs.hello.hash); + chai_1.expect(reader.position).to.equal(BigInt(32)); + const actualNext = reader.read(16); + chai_1.expect(actualNext).to.deep.equal(test_helpers_1.hello48.slice(32)); + chai_1.expect(reader.position).to.equal(BigInt(48)); + }); + it('manually sets position', () => { + reader.position = BigInt(32); + const actual = reader.read(16); + chai_1.expect(actual).to.deep.equal(test_helpers_1.hello48.slice(32)); + }); + it('throws if set out of range', () => { + chai_1.expect(() => (reader.position = BigInt(-1))).to.throw(RangeError); + chai_1.expect(() => (reader.position = BigInt('18446744073709551616'))).to.throw(RangeError); + reader.position = hash_reader_1.maxHashBytes - BigInt(1); + chai_1.expect(() => reader.read(2)).to.throw(RangeError); + }); + }); + describe('original test vectors', () => { + for (const { inputLen, expectedDerive, expectedKeyed, expectedHash } of test_helpers_1.ogTestVectors.cases) { + describe(`${inputLen}`, () => __awaiter(this, void 0, void 0, function* () { + const input = Buffer.alloc(inputLen); + for (let i = 0; i < inputLen; i++) { + input[i] = i % 251; + } + it('hash()', () => { + chai_1.expect(hash(input, { length: expectedHash.length / 2 }).toString('hex')).to.equal(expectedHash); + }); + it('deriveKey()', () => { + chai_1.expect(deriveKey(test_helpers_1.ogTestVectors.context, input, { length: expectedDerive.length / 2 }).toString('hex')).to.equal(expectedDerive); + }); + it('createDeriveKey()', callback => { + const buffer = new stream_buffers_1.ReadableStreamBuffer(); + buffer.put(Buffer.from(input)); + buffer.stop(); + const hash = createDeriveKey(test_helpers_1.ogTestVectors.context); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest({ length: expectedDerive.length / 2 }).toString('hex'); + chai_1.expect(actual).to.equal(expectedDerive); + callback(); + }); + }); + it('keyedHash()', () => { + chai_1.expect(keyedHash(Buffer.from(test_helpers_1.ogTestVectors.key), input, { + length: expectedKeyed.length / 2, + }).toString('hex')).to.equal(expectedKeyed); + }); + it('createKeyed()', callback => { + const buffer = new stream_buffers_1.ReadableStreamBuffer(); + buffer.put(Buffer.from(input)); + buffer.stop(); + const hash = createKeyed(Buffer.from(test_helpers_1.ogTestVectors.key)); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest({ length: expectedDerive.length / 2 }).toString('hex'); + chai_1.expect(actual).to.equal(expectedKeyed); + callback(); + }); + }); + })); + } + }); +} +describe('node.js wasm', () => suite(wasm)); +describe('node.js native', () => suite(native)); +//# sourceMappingURL=node.test.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node.test.js.map b/node_modules/blake3-wasm/dist/node.test.js.map new file mode 100644 index 0000000..6afab0a --- /dev/null +++ b/node_modules/blake3-wasm/dist/node.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"node.test.js","sourceRoot":"","sources":["../ts/node.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,sDAAwC;AACxC,+BAA8B;AAC9B,sDAAqE;AACrE,mDAAsD;AACtD,oDAAkD;AAElD,SAAS,KAAK,CAAC,EACb,IAAI,EACJ,UAAU,EACV,SAAS,EACT,SAAS,EACT,eAAe,EACf,WAAW,GACiB;IAC5B,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;QACxB,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;YACzB,aAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;YACzB,aAAM,CAAC,IAAI,CAAC,qBAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAM,CAAC,KAAK,C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AAE,MAAM,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;wBAClF,aAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;wBACvC,QAAQ,EAAE,CAAC;oBACb,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-fn.d.ts b/node_modules/blake3-wasm/dist/node/hash-fn.d.ts new file mode 100644 index 0000000..33d7927 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-fn.d.ts @@ -0,0 +1,24 @@ +/// <reference types="node" /> +import { BaseHashInput, IBaseHashOptions } from '../base/hash-fn'; +/** + * Input used for node-based hashes. + */ +export declare type HashInput = BaseHashInput | string; +/** + * @hidden + */ +export declare const normalizeInput: (input: HashInput, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Uint8Array; +/** + * 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/hash-fn.js b/node_modules/blake3-wasm/dist/node/hash-fn.js new file mode 100644 index 0000000..bad82b4 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-fn.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_fn_1 = require("../base/hash-fn"); +const blake3_js_1 = require("../../dist/wasm/nodejs/blake3_js"); +/** + * @hidden + */ +exports.normalizeInput = (input, encoding) => hash_fn_1.inputToArray(typeof input === 'string' ? Buffer.from(input, encoding) : input); +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +function hash(input, { length = hash_fn_1.defaultHashLength } = {}) { + const result = Buffer.alloc(length); + blake3_js_1.hash(exports.normalizeInput(input), result); + return result; +} +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 derive = blake3_js_1.create_derive(context); + derive.update(exports.normalizeInput(material)); + const result = Buffer.alloc(length); + derive.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 } = {}) { + if (key.length !== 32) { + throw new Error(`key provided to keyedHash must be 32 bytes, got ${key.length}`); + } + const derive = blake3_js_1.create_keyed(key); + derive.update(exports.normalizeInput(input)); + const result = Buffer.alloc(length); + derive.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/hash-fn.js.map b/node_modules/blake3-wasm/dist/node/hash-fn.js.map new file mode 100644 index 0000000..9f8fc50 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file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wBAAW,CAAC,GAAG,CAAC,CAAC;IAChC,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;AAdD,8BAcC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-instance.d.ts b/node_modules/blake3-wasm/dist/node/hash-instance.d.ts new file mode 100644 index 0000000..3a72c9f --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-instance.d.ts @@ -0,0 +1,75 @@ +/// <reference types="node" /> +import { HashInput } from './hash-fn'; +import { IHasher, IInternalHash, IHasherDigestOptions } from '../base/index'; +import { Transform, TransformCallback } from 'stream'; +import { IBaseHashOptions } from '../base/hash-fn'; +import { NodeHashReader } from './hash-reader'; +export interface INodeHash extends IHasher<Buffer> { + /** + * @inheritdoc + * @override + */ + update(data: HashInput, encoding?: BufferEncoding): this; + /** + * @inheritdoc + * @override + */ + digest(options?: IBaseHashOptions): Buffer; + /** + * Returns a digest of the hash with the given set of hash options. + */ + digest(encoding: undefined, options: IBaseHashOptions): Buffer; + /** + * Returns a digest of the hash with the given encoding. + */ + digest(encoding: BufferEncoding, options?: IBaseHashOptions): string; +} +/** + * @inheritdoc + */ +export declare class NodeHash<Reader> extends Transform implements IHasher<Buffer> { + private readonly hash; + constructor(implementation: IInternalHash<Reader>, getReader: (r: Reader) => NodeHashReader); + /** + * @reader + */ + reader(options?: { + dispose?: boolean; + }): NodeHashReader; + /** + * @inheritdoc + */ + update(data: HashInput, encoding?: BufferEncoding): this; + /** + * @inheritdoc + */ + digest(encoding?: IHasherDigestOptions): Buffer; + digest(encoding: undefined, options: IHasherDigestOptions): Buffer; + digest(encoding: BufferEncoding, options?: IHasherDigestOptions): string; + /** + * @inheritdoc + */ + dispose(): void; + /** + * @inheritdoc + * @hidden + */ + _transform(chunk: Buffer | string, encoding: string, callback: TransformCallback): void; + /** + * @inheritdoc + * @hidden + */ + _flush(callback: TransformCallback): void; +} +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => NodeHash<import("../../dist/wasm/nodejs/blake3_js").HashReader>; +/** + * Construct a new Hasher for the keyed hash function. + */ +export declare const createKeyed: (key: Buffer) => NodeHash<import("../../dist/wasm/nodejs/blake3_js").HashReader>; +/** + * Construct a new Hasher for the key derivation function. + */ +export declare const createDeriveKey: (context: string) => NodeHash<import("../../dist/wasm/nodejs/blake3_js").HashReader>; diff --git a/node_modules/blake3-wasm/dist/node/hash-instance.js b/node_modules/blake3-wasm/dist/node/hash-instance.js new file mode 100644 index 0000000..3598e0d --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-instance.js @@ -0,0 +1,79 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_fn_1 = require("./hash-fn"); +const index_1 = require("../base/index"); +const stream_1 = require("stream"); +const wasm_1 = require("./wasm"); +const hash_reader_1 = require("./hash-reader"); +/** + * @inheritdoc + */ +class NodeHash extends stream_1.Transform { + constructor(implementation, getReader) { + super(); + this.hash = new index_1.BaseHash(implementation, l => Buffer.alloc(l), getReader); + } + /** + * @reader + */ + reader(options) { + const reader = this.hash.reader(options); + return reader; + } + /** + * @inheritdoc + */ + update(data, encoding) { + this.hash.update(hash_fn_1.normalizeInput(data, encoding)); + return this; + } + digest(encoding, options) { + let resolvedOpts; + let resolvedEnc; + if (encoding && typeof encoding === 'object') { + resolvedOpts = encoding; + resolvedEnc = undefined; + } + else { + resolvedOpts = options; + resolvedEnc = encoding; + } + const result = this.hash.digest(resolvedOpts); + return resolvedEnc ? result.toString(resolvedEnc) : result; + } + /** + * @inheritdoc + */ + dispose() { + this.hash.dispose(); + } + /** + * @inheritdoc + * @hidden + */ + _transform(chunk, encoding, callback) { + this.update(chunk, encoding); + callback(); + } + /** + * @inheritdoc + * @hidden + */ + _flush(callback) { + callback(null, this.digest()); + } +} +exports.NodeHash = NodeHash; +/** + * A Node.js crypto-like createHash method. + */ +exports.createHash = () => new NodeHash(wasm_1.getWasm().create_hasher(), r => new hash_reader_1.NodeHashReader(r)); +/** + * Construct a new Hasher for the keyed hash function. + */ +exports.createKeyed = (key) => new NodeHash(wasm_1.getWasm().create_keyed(key), r => new hash_reader_1.NodeHashReader(r)); +/** + * Construct a new Hasher for the key derivation function. + */ +exports.createDeriveKey = (context) => new NodeHash(wasm_1.getWasm().create_derive(context), r => new hash_reader_1.NodeHashReader(r)); +//# sourceMappingURL=hash-instance.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-instance.js.map b/node_modules/blake3-wasm/dist/node/hash-instance.js.map new file mode 100644 index 0000000..568482b --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/node/hash-instance.ts"],"names":[],"mappings":";;AAAA,uCAAsD;AACtD,yCAAuF;AACvF,mCAAsD;AAEtD,iCAAiC;AACjC,+CAA+C;AA0B/C;;GAEG;AACH,MAAa,QAAiB,SAAQ,kBAAS;IAG7C,YAAY,cAAqC,EAAE,SAAwC;QACzF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,gBAAQ,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,OAA+B;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,IAAe,EAAE,QAAyB;QACtD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAc,CAAC,IAAI,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AAC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,4BAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE;;GAEG;AACU,QAAA,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CACjD,IAAI,QAAQ,CAAC,cAAO,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,4BAAc,CAAC,CAAC,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-reader.d.ts b/node_modules/blake3-wasm/dist/node/hash-reader.d.ts new file mode 100644 index 0000000..f217f7d --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-reader.d.ts @@ -0,0 +1,16 @@ +/// <reference types="node" /> +import { BaseHashReader } from '../base/hash-reader'; +/** + * A hash reader for WebAssembly targets. + */ +export declare class NodeHashReader extends BaseHashReader<Buffer> { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding?: BufferEncoding): string; + /** + * Converts first 32 bytes of the hash to an array. + */ + toBuffer(): Buffer; + protected alloc(bytes: number): Buffer; +} diff --git a/node_modules/blake3-wasm/dist/node/hash-reader.js b/node_modules/blake3-wasm/dist/node/hash-reader.js new file mode 100644 index 0000000..e5525e7 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-reader.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const hash_reader_1 = require("../base/hash-reader"); +const hash_fn_1 = require("../base/hash-fn"); +/** + * A hash reader for WebAssembly targets. + */ +class NodeHashReader extends hash_reader_1.BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toBuffer().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toBuffer() { + this.position = BigInt(0); + return this.read(hash_fn_1.defaultHashLength); + } + alloc(bytes) { + return Buffer.alloc(bytes); + } +} +exports.NodeHashReader = NodeHashReader; +//# sourceMappingURL=hash-reader.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/hash-reader.js.map b/node_modules/blake3-wasm/dist/node/hash-reader.js.map new file mode 100644 index 0000000..4ef5e83 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/node/hash-reader.ts"],"names":[],"mappings":";;AAAA,qDAAqD;AACrD,6CAAoD;AAEpD;;GAEG;AACH,MAAa,cAAe,SAAQ,4BAAsB;IACxD;;OAEG;IACI,QAAQ,CAAC,WAA2B,KAAK;QAC9C,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,2BAAiB,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,KAAa;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AAnBD,wCAmBC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/index.d.ts b/node_modules/blake3-wasm/dist/node/index.d.ts new file mode 100644 index 0000000..7cd09cc --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/index.d.ts @@ -0,0 +1,4 @@ +export { hash, deriveKey, keyedHash, HashInput } from './hash-fn'; +export * from './hash-instance'; +export * from './hash-reader'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/dist/node/index.js b/node_modules/blake3-wasm/dist/node/index.js new file mode 100644 index 0000000..f3052fa --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/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("./hash-instance")); +__export(require("./hash-reader")); +__export(require("../base/index")); +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/index.js.map b/node_modules/blake3-wasm/dist/node/index.js.map new file mode 100644 index 0000000..b156a6c --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/node/index.ts"],"names":[],"mappings":";;;;;AAAA,qCAAkE;AAAzD,yBAAA,IAAI,CAAA;AAAE,8BAAA,SAAS,CAAA;AAAE,8BAAA,SAAS,CAAA;AACnC,qCAAgC;AAChC,mCAA8B;AAC9B,mCAA8B"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/wasm.d.ts b/node_modules/blake3-wasm/dist/node/wasm.d.ts new file mode 100644 index 0000000..41e73fd --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/wasm.d.ts @@ -0,0 +1,6 @@ +import * as wasm from '../../dist/wasm/nodejs/blake3_js'; +/** + * Lazyily get the WebAssembly module. Used to avoid unnecessarily importing + * the wasm when extending the WebAssembly node code for native bindings. + */ +export declare const getWasm: () => typeof wasm; diff --git a/node_modules/blake3-wasm/dist/node/wasm.js b/node_modules/blake3-wasm/dist/node/wasm.js new file mode 100644 index 0000000..9d4caa5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/wasm.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let w; +/** + * Lazyily get the WebAssembly module. Used to avoid unnecessarily importing + * the wasm when extending the WebAssembly node code for native bindings. + */ +exports.getWasm = () => { + if (!w) { + w = require('../../dist/wasm/nodejs/blake3_js'); + } + return w; +}; +//# sourceMappingURL=wasm.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/node/wasm.js.map b/node_modules/blake3-wasm/dist/node/wasm.js.map new file mode 100644 index 0000000..3cf7b7f --- /dev/null +++ b/node_modules/blake3-wasm/dist/node/wasm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../ts/node/wasm.ts"],"names":[],"mappings":";;AAEA,IAAI,CAA0B,CAAC;AAE/B;;;GAGG;AACU,QAAA,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,CAAC,GAAG,OAAO,CAAC,kCAAkC,CAAgB,CAAC;KAChE;IAED,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.d.ts b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.d.ts new file mode 100644 index 0000000..963531e --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.d.ts @@ -0,0 +1,51 @@ +/* tslint:disable */ +/* eslint-disable */ +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +export function hash(data: Uint8Array, out: Uint8Array): void; +/** +* @returns {Blake3Hash} +*/ +export function create_hasher(): Blake3Hash; +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +export function create_keyed(key_slice: Uint8Array): Blake3Hash; +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +export function create_derive(context: string): Blake3Hash; +/** +*/ +export class Blake3Hash { + free(): void; +/** +* @returns {HashReader} +*/ + reader(): HashReader; +/** +* @param {Uint8Array} input_bytes +*/ + update(input_bytes: Uint8Array): void; +/** +* @param {Uint8Array} out +*/ + digest(out: Uint8Array): void; +} +/** +*/ +export class HashReader { + free(): void; +/** +* @param {Uint8Array} bytes +*/ + fill(bytes: Uint8Array): void; +/** +* @param {BigInt} position +*/ + set_position(position: BigInt): void; +} diff --git a/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.js b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.js new file mode 100644 index 0000000..da7aaed --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js.js @@ -0,0 +1,2 @@ +import * as wasm from "./blake3_js_bg.wasm"; +export * from "./blake3_js_bg.js";
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/browser/blake3_js_bg.wasm b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js_bg.wasm Binary files differnew file mode 100644 index 0000000..a26488d --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/browser/blake3_js_bg.wasm diff --git a/node_modules/blake3-wasm/dist/wasm/browser/package.json b/node_modules/blake3-wasm/dist/wasm/browser/package.json new file mode 100644 index 0000000..509802f --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/browser/package.json @@ -0,0 +1,12 @@ +{ + "name": "blake3-js", + "version": "0.1.0", + "files": [ + "blake3_js_bg.wasm", + "blake3_js.js", + "blake3_js.d.ts" + ], + "module": "blake3_js.js", + "types": "blake3_js.d.ts", + "sideEffects": false +}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.d.ts b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.d.ts new file mode 100644 index 0000000..963531e --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.d.ts @@ -0,0 +1,51 @@ +/* tslint:disable */ +/* eslint-disable */ +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +export function hash(data: Uint8Array, out: Uint8Array): void; +/** +* @returns {Blake3Hash} +*/ +export function create_hasher(): Blake3Hash; +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +export function create_keyed(key_slice: Uint8Array): Blake3Hash; +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +export function create_derive(context: string): Blake3Hash; +/** +*/ +export class Blake3Hash { + free(): void; +/** +* @returns {HashReader} +*/ + reader(): HashReader; +/** +* @param {Uint8Array} input_bytes +*/ + update(input_bytes: Uint8Array): void; +/** +* @param {Uint8Array} out +*/ + digest(out: Uint8Array): void; +} +/** +*/ +export class HashReader { + free(): void; +/** +* @param {Uint8Array} bytes +*/ + fill(bytes: Uint8Array): void; +/** +* @param {BigInt} position +*/ + set_position(position: BigInt): void; +} diff --git a/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.js b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.js new file mode 100644 index 0000000..e655b33 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js.js @@ -0,0 +1,196 @@ +let imports = {}; +imports['__wbindgen_placeholder__'] = module.exports; +let wasm; +const { TextDecoder } = require(String.raw`util`); + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachegetUint8Memory0 = null; +function getUint8Memory0() { + if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { + cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachegetUint8Memory0; +} + +function getStringFromWasm0(ptr, len) { + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +let WASM_VECTOR_LEN = 0; + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1); + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +module.exports.hash = function(data, out) { + try { + var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + var ptr1 = passArray8ToWasm0(out, wasm.__wbindgen_malloc); + var len1 = WASM_VECTOR_LEN; + wasm.hash(ptr0, len0, ptr1, len1); + } finally { + out.set(getUint8Memory0().subarray(ptr1 / 1, ptr1 / 1 + len1)); + wasm.__wbindgen_free(ptr1, len1 * 1); + } +}; + +/** +* @returns {Blake3Hash} +*/ +module.exports.create_hasher = function() { + var ret = wasm.create_hasher(); + return Blake3Hash.__wrap(ret); +}; + +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +module.exports.create_keyed = function(key_slice) { + var ptr0 = passArray8ToWasm0(key_slice, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + var ret = wasm.create_keyed(ptr0, len0); + return Blake3Hash.__wrap(ret); +}; + +let cachegetNodeBufferMemory0 = null; +function getNodeBufferMemory0() { + if (cachegetNodeBufferMemory0 === null || cachegetNodeBufferMemory0.buffer !== wasm.memory.buffer) { + cachegetNodeBufferMemory0 = Buffer.from(wasm.memory.buffer); + } + return cachegetNodeBufferMemory0; +} + +function passStringToWasm0(arg, malloc) { + + const len = Buffer.byteLength(arg); + const ptr = malloc(len); + getNodeBufferMemory0().write(arg, ptr, len); + WASM_VECTOR_LEN = len; + return ptr; +} +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +module.exports.create_derive = function(context) { + var ptr0 = passStringToWasm0(context, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + var ret = wasm.create_derive(ptr0, len0); + return Blake3Hash.__wrap(ret); +}; + +const u32CvtShim = new Uint32Array(2); + +const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); +/** +*/ +class Blake3Hash { + + static __wrap(ptr) { + const obj = Object.create(Blake3Hash.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_blake3hash_free(ptr); + } + /** + * @returns {HashReader} + */ + reader() { + var ret = wasm.blake3hash_reader(this.ptr); + return HashReader.__wrap(ret); + } + /** + * @param {Uint8Array} input_bytes + */ + update(input_bytes) { + var ptr0 = passArray8ToWasm0(input_bytes, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.blake3hash_update(this.ptr, ptr0, len0); + } + /** + * @param {Uint8Array} out + */ + digest(out) { + try { + var ptr0 = passArray8ToWasm0(out, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.blake3hash_digest(this.ptr, ptr0, len0); + } finally { + out.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } +} +module.exports.Blake3Hash = Blake3Hash; +/** +*/ +class HashReader { + + static __wrap(ptr) { + const obj = Object.create(HashReader.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_hashreader_free(ptr); + } + /** + * @param {Uint8Array} bytes + */ + fill(bytes) { + try { + var ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.hashreader_fill(this.ptr, ptr0, len0); + } finally { + bytes.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } + /** + * @param {BigInt} position + */ + set_position(position) { + uint64CvtShim[0] = position; + const low0 = u32CvtShim[0]; + const high0 = u32CvtShim[1]; + wasm.hashreader_set_position(this.ptr, low0, high0); + } +} +module.exports.HashReader = HashReader; + +module.exports.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + +const path = require('path').join(__dirname, 'blake3_js_bg.wasm'); +const bytes = require('fs').readFileSync(path); + +const wasmModule = new WebAssembly.Module(bytes); +const wasmInstance = new WebAssembly.Instance(wasmModule, imports); +wasm = wasmInstance.exports; +module.exports.__wasm = wasm; + diff --git a/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js_bg.wasm b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js_bg.wasm Binary files differnew file mode 100644 index 0000000..08c5e38 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js_bg.wasm diff --git a/node_modules/blake3-wasm/dist/wasm/nodejs/package.json b/node_modules/blake3-wasm/dist/wasm/nodejs/package.json new file mode 100644 index 0000000..18de4b5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/nodejs/package.json @@ -0,0 +1,12 @@ +{ + "name": "blake3-js", + "version": "0.1.0", + "files": [ + "blake3_js_bg.wasm", + "blake3_js.js", + "blake3_js_bg.js", + "blake3_js.d.ts" + ], + "main": "blake3_js.js", + "types": "blake3_js.d.ts" +}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/web/blake3_js.d.ts b/node_modules/blake3-wasm/dist/wasm/web/blake3_js.d.ts new file mode 100644 index 0000000..cd566ed --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/web/blake3_js.d.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +export function hash(data: Uint8Array, out: Uint8Array): void; +/** +* @returns {Blake3Hash} +*/ +export function create_hasher(): Blake3Hash; +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +export function create_keyed(key_slice: Uint8Array): Blake3Hash; +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +export function create_derive(context: string): Blake3Hash; +/** +*/ +export class Blake3Hash { + free(): void; +/** +* @returns {HashReader} +*/ + reader(): HashReader; +/** +* @param {Uint8Array} input_bytes +*/ + update(input_bytes: Uint8Array): void; +/** +* @param {Uint8Array} out +*/ + digest(out: Uint8Array): void; +} +/** +*/ +export class HashReader { + free(): void; +/** +* @param {Uint8Array} bytes +*/ + fill(bytes: Uint8Array): void; +/** +* @param {BigInt} position +*/ + set_position(position: BigInt): void; +} + +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; + +export interface InitOutput { + readonly memory: WebAssembly.Memory; + readonly hash: (a: number, b: number, c: number, d: number) => void; + readonly create_hasher: () => number; + readonly create_keyed: (a: number, b: number) => number; + readonly create_derive: (a: number, b: number) => number; + readonly __wbg_blake3hash_free: (a: number) => void; + readonly blake3hash_reader: (a: number) => number; + readonly blake3hash_update: (a: number, b: number, c: number) => void; + readonly blake3hash_digest: (a: number, b: number, c: number) => void; + readonly __wbg_hashreader_free: (a: number) => void; + readonly hashreader_fill: (a: number, b: number, c: number) => void; + readonly hashreader_set_position: (a: number, b: number, c: number) => void; + readonly __wbindgen_malloc: (a: number) => number; + readonly __wbindgen_free: (a: number, b: number) => void; + readonly __wbindgen_realloc: (a: number, b: number, c: number) => number; +} + +/** +* If `module_or_path` is {RequestInfo} or {URL}, makes a request and +* for everything else, calls `WebAssembly.instantiate` directly. +* +* @param {InitInput | Promise<InitInput>} module_or_path +* +* @returns {Promise<InitOutput>} +*/ +export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>; +
\ No newline at end of file diff --git a/node_modules/blake3-wasm/dist/wasm/web/blake3_js.js b/node_modules/blake3-wasm/dist/wasm/web/blake3_js.js new file mode 100644 index 0000000..4fa3774 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/web/blake3_js.js @@ -0,0 +1,273 @@ + +let wasm; + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachegetUint8Memory0 = null; +function getUint8Memory0() { + if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { + cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachegetUint8Memory0; +} + +function getStringFromWasm0(ptr, len) { + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + +let WASM_VECTOR_LEN = 0; + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1); + getUint8Memory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} +/** +* @param {Uint8Array} data +* @param {Uint8Array} out +*/ +export function hash(data, out) { + try { + var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + var ptr1 = passArray8ToWasm0(out, wasm.__wbindgen_malloc); + var len1 = WASM_VECTOR_LEN; + wasm.hash(ptr0, len0, ptr1, len1); + } finally { + out.set(getUint8Memory0().subarray(ptr1 / 1, ptr1 / 1 + len1)); + wasm.__wbindgen_free(ptr1, len1 * 1); + } +} + +/** +* @returns {Blake3Hash} +*/ +export function create_hasher() { + var ret = wasm.create_hasher(); + return Blake3Hash.__wrap(ret); +} + +/** +* @param {Uint8Array} key_slice +* @returns {Blake3Hash} +*/ +export function create_keyed(key_slice) { + var ptr0 = passArray8ToWasm0(key_slice, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + var ret = wasm.create_keyed(ptr0, len0); + return Blake3Hash.__wrap(ret); +} + +let cachedTextEncoder = new TextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length); + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len); + + const mem = getUint8Memory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3); + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} +/** +* @param {string} context +* @returns {Blake3Hash} +*/ +export function create_derive(context) { + var ptr0 = passStringToWasm0(context, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + var ret = wasm.create_derive(ptr0, len0); + return Blake3Hash.__wrap(ret); +} + +const u32CvtShim = new Uint32Array(2); + +const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); +/** +*/ +export class Blake3Hash { + + static __wrap(ptr) { + const obj = Object.create(Blake3Hash.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_blake3hash_free(ptr); + } + /** + * @returns {HashReader} + */ + reader() { + var ret = wasm.blake3hash_reader(this.ptr); + return HashReader.__wrap(ret); + } + /** + * @param {Uint8Array} input_bytes + */ + update(input_bytes) { + var ptr0 = passArray8ToWasm0(input_bytes, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.blake3hash_update(this.ptr, ptr0, len0); + } + /** + * @param {Uint8Array} out + */ + digest(out) { + try { + var ptr0 = passArray8ToWasm0(out, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.blake3hash_digest(this.ptr, ptr0, len0); + } finally { + out.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } +} +/** +*/ +export class HashReader { + + static __wrap(ptr) { + const obj = Object.create(HashReader.prototype); + obj.ptr = ptr; + + return obj; + } + + free() { + const ptr = this.ptr; + this.ptr = 0; + + wasm.__wbg_hashreader_free(ptr); + } + /** + * @param {Uint8Array} bytes + */ + fill(bytes) { + try { + var ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + var len0 = WASM_VECTOR_LEN; + wasm.hashreader_fill(this.ptr, ptr0, len0); + } finally { + bytes.set(getUint8Memory0().subarray(ptr0 / 1, ptr0 / 1 + len0)); + wasm.__wbindgen_free(ptr0, len0 * 1); + } + } + /** + * @param {BigInt} position + */ + set_position(position) { + uint64CvtShim[0] = position; + const low0 = u32CvtShim[0]; + const high0 = u32CvtShim[1]; + wasm.hashreader_set_position(this.ptr, low0, high0); + } +} + +async function load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + + } catch (e) { + if (module.headers.get('Content-Type') != 'application/wasm') { + 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); + + } else { + throw e; + } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + + } else { + + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + + } else { + return instance; + } + } +} + +async function init(input) { + if (typeof input === 'undefined') { + input = import.meta.url.replace(/\.js$/, '_bg.wasm'); + } + const imports = {}; + imports.wbg = {}; + imports.wbg.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }; + + if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { + input = fetch(input); + } + + const { instance, module } = await load(await input, imports); + + wasm = instance.exports; + init.__wbindgen_wasm_module = module; + + return wasm; +} + +export default init; + diff --git a/node_modules/blake3-wasm/dist/wasm/web/blake3_js_bg.wasm b/node_modules/blake3-wasm/dist/wasm/web/blake3_js_bg.wasm Binary files differnew file mode 100644 index 0000000..b3d1ad5 --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/web/blake3_js_bg.wasm diff --git a/node_modules/blake3-wasm/dist/wasm/web/package.json b/node_modules/blake3-wasm/dist/wasm/web/package.json new file mode 100644 index 0000000..509802f --- /dev/null +++ b/node_modules/blake3-wasm/dist/wasm/web/package.json @@ -0,0 +1,12 @@ +{ + "name": "blake3-js", + "version": "0.1.0", + "files": [ + "blake3_js_bg.wasm", + "blake3_js.js", + "blake3_js.d.ts" + ], + "module": "blake3_js.js", + "types": "blake3_js.d.ts", + "sideEffects": false +}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/disposable.d.ts b/node_modules/blake3-wasm/esm/base/disposable.d.ts new file mode 100644 index 0000000..27db792 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.d.ts @@ -0,0 +1,17 @@ +/** + * A type which requires manual disposal to free unmanaged resources. In the + * context of this library, this usually means freeing memory from WebAssembly + * code. + */ +export interface IDisposable { + /** + * Frees unmanaged resources of the object. This method is idempotent; + * calling it multiple times will have no ill effects. + */ + dispose(): void; +} +/** + * A helper function that calls `.dispose()` on the {@link IDisposable} when + * the given function (or promise returned by the function) returns. + */ +export declare const using: <T, D extends IDisposable>(disposable: D, fn: (d: D) => T) => T; diff --git a/node_modules/blake3-wasm/esm/base/disposable.js b/node_modules/blake3-wasm/esm/base/disposable.js new file mode 100644 index 0000000..f10f782 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.js @@ -0,0 +1,27 @@ +const isPromiseLike = (value) => typeof value === 'object' && !!value && 'then' in value; +/** + * A helper function that calls `.dispose()` on the {@link IDisposable} when + * the given function (or promise returned by the function) returns. + */ +export const using = (disposable, fn) => { + let ret; + try { + ret = fn(disposable); + } + catch (e) { + disposable.dispose(); + throw e; + } + if (!isPromiseLike(ret)) { + disposable.dispose(); + return ret; + } + return ret.then(value => { + disposable.dispose(); + return value; + }, err => { + disposable.dispose(); + throw err; + }); +}; +//# sourceMappingURL=disposable.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/disposable.js.map b/node_modules/blake3-wasm/esm/base/disposable.js.map new file mode 100644 index 0000000..bf4fe96 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.js.map @@ -0,0 +1 @@ +{"version":3,"file":"disposable.js","sourceRoot":"","sources":["../../ts/base/disposable.ts"],"names":[],"mappings":"AAaA,MAAM,aAAa,GAAG,CAAC,KAAc,EAAiC,EAAE,CACtE,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAA2B,UAAa,EAAE,EAAe,EAAK,EAAE;IACnF,IAAI,GAAmB,CAAC;IACxB,IAAI;QACF,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;KACtB;IAAC,OAAO,CAAC,EAAE;QACV,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,CAAC,CAAC;KACT;IAED,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE;QACvB,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC;KACZ;IAED,OAAQ,GAAG,CAAC,IAAI,CACd,KAAK,CAAC,EAAE;QACN,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC,EACD,GAAG,CAAC,EAAE;QACJ,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,GAAG,CAAC;IACZ,CAAC,CACe,CAAC;AACrB,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/disposable.test.d.ts b/node_modules/blake3-wasm/esm/base/disposable.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/base/disposable.test.js b/node_modules/blake3-wasm/esm/base/disposable.test.js new file mode 100644 index 0000000..94175ba --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.test.js @@ -0,0 +1,68 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { using } from '../node.js'; +import { expect } from 'chai.js'; +describe('disposable', () => { + describe('using', () => { + let disposed; + let disposable; + beforeEach(() => { + disposed = false; + disposable = { dispose: () => (disposed = true) }; + }); + it('disposes after sync call', () => { + const v = using(disposable, d => { + expect(d).to.equal(disposable); + expect(disposed).to.be.false; + return 42; + }); + expect(v).to.equal(42); + expect(disposed).to.be.true; + }); + it('disposes after sync throw', () => { + const err = new Error(); + try { + using(disposable, () => { + throw err; + }); + throw new Error('expected to throw'); + } + catch (e) { + expect(e).to.equal(err); + } + expect(disposed).to.be.true; + }); + it('disposes after promise resolve', () => __awaiter(void 0, void 0, void 0, function* () { + const v = yield using(disposable, () => __awaiter(void 0, void 0, void 0, function* () { + yield Promise.resolve(); + expect(disposed).to.be.false; + return 42; + })); + expect(v).to.equal(42); + expect(disposed).to.be.true; + })); + it('disposes after promise reject', () => __awaiter(void 0, void 0, void 0, function* () { + const err = new Error(); + try { + yield using(disposable, () => __awaiter(void 0, void 0, void 0, function* () { + yield Promise.resolve(); + expect(disposed).to.be.false; + throw err; + })); + throw new Error('expected to throw'); + } + catch (e) { + expect(e).to.equal(err); + } + expect(disposed).to.be.true; + })); + }); +}); +//# sourceMappingURL=disposable.test.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/disposable.test.js.map b/node_modules/blake3-wasm/esm/base/disposable.test.js.map new file mode 100644 index 0000000..a6879e7 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/disposable.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"disposable.test.js","sourceRoot":"","sources":["../../ts/base/disposable.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAe,KAAK,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;QACrB,IAAI,QAAiB,CAAC;QACtB,IAAI,UAAuB,CAAC;QAC5B,UAAU,CAAC,GAAG,EAAE;YACd,QAAQ,GAAG,KAAK,CAAC;YACjB,UAAU,GA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AAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;gBAC7B,OAAO,EAAE,CAAC;YACZ,CAAC,CAAA,CAAC,CAAC;YAEH,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACvB,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAC9B,CAAC,CAAA,CAAC,CAAC;QAEH,EAAE,CAAC,+BAA+B,EAAE,GAAS,EAAE;YAC7C,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,IAAI;gBACF,MAAM,KAAK,CAAC,UAAU,EAAE,GAAS,EAAE;oBACjC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;oBACxB,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;oBAC7B,MAAM,GAAG,CAAC;gBACZ,CAAC,CAAA,CAAC,CAAC;gBACH,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;aACtC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACzB;YAED,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAC9B,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-fn.d.ts b/node_modules/blake3-wasm/esm/base/hash-fn.d.ts new file mode 100644 index 0000000..6b654a0 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-fn.d.ts @@ -0,0 +1,23 @@ +/** + * Options passed to hash functions. + */ +export interface IBaseHashOptions { + /** + * Length of the desired hash, in bytes. Note that when encoding the output + * as a string, this is *not* the string length. + */ + length?: number; +} +/** + * Default hash length, in bytes, unless otherwise specified. + */ +export declare const defaultHashLength = 32; +/** + * A type that can be hashed. + */ +export declare type BaseHashInput = Uint8Array | ArrayBuffer | SharedArrayBuffer | ArrayLike<number>; +/** + * Converts the input to an Uint8Array. + * @hidden + */ +export declare const inputToArray: (input: BaseHashInput) => Uint8Array; diff --git a/node_modules/blake3-wasm/esm/base/hash-fn.js b/node_modules/blake3-wasm/esm/base/hash-fn.js new file mode 100644 index 0000000..b017bae --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-fn.js @@ -0,0 +1,10 @@ +/** + * Default hash length, in bytes, unless otherwise specified. + */ +export const defaultHashLength = 32; +/** + * Converts the input to an Uint8Array. + * @hidden + */ +export const inputToArray = (input) => input instanceof Uint8Array ? input : new Uint8Array(input); +//# sourceMappingURL=hash-fn.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-fn.js.map b/node_modules/blake3-wasm/esm/base/hash-fn.js.map new file mode 100644 index 0000000..1ec8a49 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/base/hash-fn.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAOpC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,EAAE,CACnD,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-instance.d.ts b/node_modules/blake3-wasm/esm/base/hash-instance.d.ts new file mode 100644 index 0000000..3f55095 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-instance.d.ts @@ -0,0 +1,79 @@ +import { BaseHashInput, IBaseHashOptions } from './hash-fn'; +import { IHashReader } from './hash-reader'; +/** + * A blake3 hash. Quite similar to Node's crypto hashing. + * + * Note that you must call {@link IHash#dispose} or {@link IHash#done} when + * you're finished with it to free memory. + */ +export interface IHasher<T> { + /** + * Adds the given data to the hash. + * @throws {Error} if {@link IHash#digest} has already been called. + */ + update(data: BaseHashInput): this; + /** + * Returns a digest of the hash. + * + * If `dispose: false` is given in the options, the hash will not + * automatically be disposed of, allowing you to continue updating + * it after obtaining the current reader. + */ + digest(options?: IBaseHashOptions & { + dispose?: boolean; + }): T; + /** + * Returns a {@link HashReader} for the current hash. + * + * If `dispose: false` is given in the options, the hash will not + * automatically be disposed of, allowing you to continue updating + * it after obtaining the current reader. + */ + reader(options?: { + dispose?: boolean; + }): IHashReader<T>; + /** + * Frees data associated with the hash. This *must* be called if + * {@link IHash#digest} is not called in order to free memory. + */ + dispose(): void; +} +/** + * @hidden + */ +export interface IInternalHash<Reader> { + free(): void; + reader(): Reader; + update(bytes: Uint8Array): void; + digest(into: Uint8Array): void; +} +export interface IHasherDigestOptions extends IBaseHashOptions { + dispose?: boolean; +} +/** + * Base implementation of hashing. + */ +export declare class BaseHash<Binary extends Uint8Array, InternalReader, Reader extends IHashReader<Binary>> implements IHasher<Binary> { + private readonly alloc; + private readonly getReader; + private hash; + constructor(implementation: IInternalHash<InternalReader>, alloc: (length: number) => Binary, getReader: (internal: InternalReader) => Reader); + /** + * @inheritdoc + */ + update(data: BaseHashInput): this; + /** + * @inheritdoc + */ + digest({ length, dispose }?: IHasherDigestOptions): Binary; + /** + * @inheritdoc + */ + reader({ dispose }?: { + dispose?: boolean; + }): Reader; + /** + * @inheritdoc + */ + dispose(): void; +} diff --git a/node_modules/blake3-wasm/esm/base/hash-instance.js b/node_modules/blake3-wasm/esm/base/hash-instance.js new file mode 100644 index 0000000..aae7bef --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-instance.js @@ -0,0 +1,57 @@ +import { inputToArray, defaultHashLength } from './hash-fn.js'; +/** + * Base implementation of hashing. + */ +export class BaseHash { + constructor(implementation, alloc, getReader) { + this.alloc = alloc; + this.getReader = getReader; + this.hash = implementation; + } + /** + * @inheritdoc + */ + update(data) { + if (!this.hash) { + throw new Error('Cannot continue updating hashing after dispose() has been called'); + } + this.hash.update(inputToArray(data)); + return this; + } + /** + * @inheritdoc + */ + digest({ length = defaultHashLength, dispose = true } = {}) { + if (!this.hash) { + throw new Error('Cannot call digest() after dipose() has been called'); + } + const digested = this.alloc(length); + this.hash.digest(digested); + if (dispose) { + this.dispose(); + } + return digested; + } + /** + * @inheritdoc + */ + reader({ dispose = true } = {}) { + if (!this.hash) { + throw new Error('Cannot call reader() after dipose() has been called'); + } + const reader = this.getReader(this.hash.reader()); + if (dispose) { + this.dispose(); + } + return reader; + } + /** + * @inheritdoc + */ + dispose() { + var _a; + (_a = this.hash) === null || _a === void 0 ? void 0 : _a.free(); + this.hash = undefined; + } +} +//# sourceMappingURL=hash-instance.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-instance.js.map b/node_modules/blake3-wasm/esm/base/hash-instance.js.map new file mode 100644 index 0000000..ff78db6 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/base/hash-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAoB,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAuD7F;;GAEG;AACH,MAAM,OAAO,QAAQ;IAInB,YACE,cAA6C,EAC5B,KAAiC,EACjC,SAA+C;QAD/C,UAAK,GAAL,KAAK,CAA4B;QACjC,cAAS,GAAT,SAAS,CAAsC;QAEhE,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,IAAmB;QAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB,EAAE,OAAO,GAAG,IAAI,KAA2B,EAAE;QACrF,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE3B,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,KAA4B,EAAE;QAC1D,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAClD,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,OAAO;;QACL,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,GAAG;QAClB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IACxB,CAAC;CACF"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-reader.d.ts b/node_modules/blake3-wasm/esm/base/hash-reader.d.ts new file mode 100644 index 0000000..ad6a8fa --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-reader.d.ts @@ -0,0 +1,61 @@ +import { IDisposable } from './disposable'; +/** + * The maximum number of bytes that can be read from the hash. + * + * Calculated out 2^64-1, since `Xn` syntax (for `Xn ** Yn`) requires TS + * targeting esnext/es2020 which includes features that Node 10 doesn't + * yet supported. + */ +export declare const maxHashBytes: bigint; +/** + * The HashReader is a type returned from any of the hash functions. It can + */ +export interface IHashReader<T> extends IDisposable { + /** + * Returns the position of the reader in the hash. Can be written to to seek. + */ + position: bigint; + /** + * Reads data from the hash into the target array. The target will always + * be completely filled with data. + */ + readInto(target: Uint8Array): void; + /** + * Reads and returns the given number of bytes from the hash, advancing + * the position of the reader. + */ + read(bytes: number): T; +} +/** + * Underlying native or wasm module code backing the reader. + * @hidden + */ +export interface IInternalReader { + free?(): void; + fill(target: Uint8Array): void; + set_position(position: bigint): void; +} +/** + * Base hash reader implementation. + */ +export declare abstract class BaseHashReader<T extends Uint8Array> implements IHashReader<T> { + private reader; + private pos; + get position(): bigint; + set position(value: bigint); + constructor(reader: IInternalReader); + /** + * @inheritdoc + */ + readInto(target: Uint8Array): void; + /** + * @inheritdoc + */ + read(bytes: number): T; + /** + * @inheritdoc + */ + dispose(): void; + protected abstract alloc(bytes: number): T; + private boundsCheck; +} diff --git a/node_modules/blake3-wasm/esm/base/hash-reader.js b/node_modules/blake3-wasm/esm/base/hash-reader.js new file mode 100644 index 0000000..2b4224d --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-reader.js @@ -0,0 +1,67 @@ +/** + * The maximum number of bytes that can be read from the hash. + * + * Calculated out 2^64-1, since `Xn` syntax (for `Xn ** Yn`) requires TS + * targeting esnext/es2020 which includes features that Node 10 doesn't + * yet supported. + */ +export const maxHashBytes = BigInt('18446744073709551615'); +/** + * Base hash reader implementation. + */ +export class BaseHashReader { + constructor(reader) { + this.pos = BigInt(0); + this.reader = reader; + } + get position() { + return this.pos; + } + set position(value) { + var _a; + // to avoid footguns of people using numbers: + if (typeof value !== 'bigint') { + throw new Error(`Got a ${typeof value} set in to reader.position, expected a bigint`); + } + this.boundsCheck(value); + this.pos = value; + (_a = this.reader) === null || _a === void 0 ? void 0 : _a.set_position(value); + } + /** + * @inheritdoc + */ + readInto(target) { + if (!this.reader) { + throw new Error(`Cannot read from a hash after it was disposed`); + } + const next = this.pos + BigInt(target.length); + this.boundsCheck(next); + this.reader.fill(target); + this.position = next; + } + /** + * @inheritdoc + */ + read(bytes) { + const data = this.alloc(bytes); + this.readInto(data); + return data; + } + /** + * @inheritdoc + */ + dispose() { + var _a, _b; + (_b = (_a = this.reader) === null || _a === void 0 ? void 0 : _a.free) === null || _b === void 0 ? void 0 : _b.call(_a); + this.reader = undefined; + } + boundsCheck(position) { + if (position > maxHashBytes) { + throw new RangeError(`Cannot read past ${maxHashBytes} bytes in BLAKE3 hashes`); + } + if (position < BigInt(0)) { + throw new RangeError(`Cannot read to a negative position`); + } + } +} +//# sourceMappingURL=hash-reader.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/hash-reader.js.map b/node_modules/blake3-wasm/esm/base/hash-reader.js.map new file mode 100644 index 0000000..3272e25 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/base/hash-reader.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAkC3D;;GAEG;AACH,MAAM,OAAgB,cAAc;IAmBlC,YAAY,MAAuB;QAjB3B,QAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAkBtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAjBD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAW,QAAQ,CAAC,KAAa;;QAC/B,6CAA6C;QAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,KAAK,+CAA+C,CAAC,CAAC;SACvF;QAED,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;QACjB,MAAA,IAAI,CAAC,MAAM,0CAAE,YAAY,CAAC,KAAK,EAAE;IACnC,CAAC;IAMD;;OAEG;IACI,QAAQ,CAAC,MAAkB;QAChC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAClE;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,KAAa;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,OAAO;;QACZ,YAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,mDAAK;QACtB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAIO,WAAW,CAAC,QAAgB;QAClC,IAAI,QAAQ,GAAG,YAAY,EAAE;YAC3B,MAAM,IAAI,UAAU,CAAC,oBAAoB,YAAY,yBAAyB,CAAC,CAAC;SACjF;QAED,IAAI,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE;YACxB,MAAM,IAAI,UAAU,CAAC,oCAAoC,CAAC,CAAC;SAC5D;IACH,CAAC;CACF"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/index.d.ts b/node_modules/blake3-wasm/esm/base/index.d.ts new file mode 100644 index 0000000..fa61a59 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/index.d.ts @@ -0,0 +1,4 @@ +export * from './hash-fn'; +export * from './hash-reader'; +export * from './hash-instance'; +export * from './disposable'; diff --git a/node_modules/blake3-wasm/esm/base/index.js b/node_modules/blake3-wasm/esm/base/index.js new file mode 100644 index 0000000..1bddd8b --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/index.js @@ -0,0 +1,5 @@ +export * from './hash-fn.js'; +export * from './hash-reader.js'; +export * from './hash-instance.js'; +export * from './disposable.js'; +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/index.js.map b/node_modules/blake3-wasm/esm/base/index.js.map new file mode 100644 index 0000000..e7220da --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/base/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/test-helpers.d.ts b/node_modules/blake3-wasm/esm/base/test-helpers.d.ts new file mode 100644 index 0000000..9b4b3dd --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/test-helpers.d.ts @@ -0,0 +1,41 @@ +/// <reference types="node" /> +export declare const hello48: Buffer; +export declare const inputs: { + large: { + input: string; + hash: Buffer; + }; + hello: { + input: string; + hash: Buffer; + }; + goodbye: { + input: string; + hash: Buffer; + }; +}; +/** + * Test vectors from the BLAKE3 repo. + * + * > Each test is an input length and three outputs, one for each of the hash, + * > keyedHash, and deriveKey modes. The input in each case is filled with a + * > 251-byte-long repeating pattern: 0, 1, 2, ..., 249, 250, 0, 1, ... The + * > key used with keyedHash is the 32-byte ASCII string given in the 'key' + * > field below. For deriveKey, the test input is used as the input key, and + * > the context string is 'BLAKE3 2019-12-27 6:29:52 example context'. + * > (As good practice for following the security requirements of deriveKey, + * > test runners should make that context string a hardcoded constant, and we + * > do not provided it in machine-readable form.) Outputs are encoded as + * > hexadecimal. Each case is an extended output, and implementations should + * > also check that the first 32 bytes match their default-length output. + */ +export declare const ogTestVectors: { + key: string; + context: string; + cases: { + inputLen: number; + expectedHash: string; + expectedKeyed: string; + expectedDerive: string; + }[]; +}; diff --git a/node_modules/blake3-wasm/esm/base/test-helpers.js b/node_modules/blake3-wasm/esm/base/test-helpers.js new file mode 100644 index 0000000..92bbc9d --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/test-helpers.js @@ -0,0 +1,164 @@ +import { readFileSync } from 'fs.js'; +export const hello48 = Buffer.from('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200fe992405f0d785b599a2e3387f6d34d01', 'hex'); +export const inputs = { + large: { + input: readFileSync(__dirname + '/../../test-input.txt', 'utf-8'), + hash: Buffer.from('2a2cf9cbc9f8d48f7d089273bc2d796a3cd0677b64234dab0c59e6e29d6a7164', 'hex'), + }, + hello: { + input: 'hello', + hash: Buffer.from('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f', 'hex'), + }, + goodbye: { + input: 'goodbye', + hash: Buffer.from('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69', 'hex'), + }, +}; +/** + * Test vectors from the BLAKE3 repo. + * + * > Each test is an input length and three outputs, one for each of the hash, + * > keyedHash, and deriveKey modes. The input in each case is filled with a + * > 251-byte-long repeating pattern: 0, 1, 2, ..., 249, 250, 0, 1, ... The + * > key used with keyedHash is the 32-byte ASCII string given in the 'key' + * > field below. For deriveKey, the test input is used as the input key, and + * > the context string is 'BLAKE3 2019-12-27 6:29:52 example context'. + * > (As good practice for following the security requirements of deriveKey, + * > test runners should make that context string a hardcoded constant, and we + * > do not provided it in machine-readable form.) Outputs are encoded as + * > hexadecimal. Each case is an extended output, and implementations should + * > also check that the first 32 bytes match their default-length output. + */ +export const ogTestVectors = { + key: 'whats the Elvish word for friend', + context: 'BLAKE3 2019-12-27 16:29:52 test vectors context', + cases: [ + { + inputLen: 0, + expectedHash: 'af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262e00f03e7b69af26b7faaf09fcd333050338ddfe085b8cc869ca98b206c08243a26f5487789e8f660afe6c99ef9e0c52b92e7393024a80459cf91f476f9ffdbda7001c22e159b402631f277ca96f2defdf1078282314e763699a31c5363165421cce14d', + expectedKeyed: '92b2b75604ed3c761f9d6f62392c8a9227ad0ea3f09573e783f1498a4ed60d26b18171a2f22a4b94822c701f107153dba24918c4bae4d2945c20ece13387627d3b73cbf97b797d5e59948c7ef788f54372df45e45e4293c7dc18c1d41144a9758be58960856be1eabbe22c2653190de560ca3b2ac4aa692a9210694254c371e851bc8f', + expectedDerive: '2cc39783c223154fea8dfb7c1b1660f2ac2dcbd1c1de8277b0b0dd39b7e50d7d905630c8be290dfcf3e6842f13bddd573c098c3f17361f1f206b8cad9d088aa4a3f746752c6b0ce6a83b0da81d59649257cdf8eb3e9f7d4998e41021fac119deefb896224ac99f860011f73609e6e0e4540f93b273e56547dfd3aa1a035ba6689d89a0', + }, + { + inputLen: 1, + expectedHash: '2d3adedff11b61f14c886e35afa036736dcd87a74d27b5c1510225d0f592e213c3a6cb8bf623e20cdb535f8d1a5ffb86342d9c0b64aca3bce1d31f60adfa137b358ad4d79f97b47c3d5e79f179df87a3b9776ef8325f8329886ba42f07fb138bb502f4081cbcec3195c5871e6c23e2cc97d3c69a613eba131e5f1351f3f1da786545e5', + expectedKeyed: '6d7878dfff2f485635d39013278ae14f1454b8c0a3a2d34bc1ab38228a80c95b6568c0490609413006fbd428eb3fd14e7756d90f73a4725fad147f7bf70fd61c4e0cf7074885e92b0e3f125978b4154986d4fb202a3f331a3fb6cf349a3a70e49990f98fe4289761c8602c4e6ab1138d31d3b62218078b2f3ba9a88e1d08d0dd4cea11', + expectedDerive: 'b3e2e340a117a499c6cf2398a19ee0d29cca2bb7404c73063382693bf66cb06c5827b91bf889b6b97c5477f535361caefca0b5d8c4746441c57617111933158950670f9aa8a05d791daae10ac683cbef8faf897c84e6114a59d2173c3f417023a35d6983f2c7dfa57e7fc559ad751dbfb9ffab39c2ef8c4aafebc9ae973a64f0c76551', + }, + { + inputLen: 1023, + expectedHash: '10108970eeda3eb932baac1428c7a2163b0e924c9a9e25b35bba72b28f70bd11a182d27a591b05592b15607500e1e8dd56bc6c7fc063715b7a1d737df5bad3339c56778957d870eb9717b57ea3d9fb68d1b55127bba6a906a4a24bbd5acb2d123a37b28f9e9a81bbaae360d58f85e5fc9d75f7c370a0cc09b6522d9c8d822f2f28f485', + expectedKeyed: 'c951ecdf03288d0fcc96ee3413563d8a6d3589547f2c2fb36d9786470f1b9d6e890316d2e6d8b8c25b0a5b2180f94fb1a158ef508c3cde45e2966bd796a696d3e13efd86259d756387d9becf5c8bf1ce2192b87025152907b6d8cc33d17826d8b7b9bc97e38c3c85108ef09f013e01c229c20a83d9e8efac5b37470da28575fd755a10', + expectedDerive: '74a16c1c3d44368a86e1ca6df64be6a2f64cce8f09220787450722d85725dea59c413264404661e9e4d955409dfe4ad3aa487871bcd454ed12abfe2c2b1eb7757588cf6cb18d2eccad49e018c0d0fec323bec82bf1644c6325717d13ea712e6840d3e6e730d35553f59eff5377a9c350bcc1556694b924b858f329c44ee64b884ef00d', + }, + { + inputLen: 1024, + expectedHash: '42214739f095a406f3fc83deb889744ac00df831c10daa55189b5d121c855af71cf8107265ecdaf8505b95d8fcec83a98a6a96ea5109d2c179c47a387ffbb404756f6eeae7883b446b70ebb144527c2075ab8ab204c0086bb22b7c93d465efc57f8d917f0b385c6df265e77003b85102967486ed57db5c5ca170ba441427ed9afa684e', + expectedKeyed: '75c46f6f3d9eb4f55ecaaee480db732e6c2105546f1e675003687c31719c7ba4a78bc838c72852d4f49c864acb7adafe2478e824afe51c8919d06168414c265f298a8094b1ad813a9b8614acabac321f24ce61c5a5346eb519520d38ecc43e89b5000236df0597243e4d2493fd626730e2ba17ac4d8824d09d1a4a8f57b8227778e2de', + expectedDerive: '7356cd7720d5b66b6d0697eb3177d9f8d73a4a5c5e968896eb6a6896843027066c23b601d3ddfb391e90d5c8eccdef4ae2a264bce9e612ba15e2bc9d654af1481b2e75dbabe615974f1070bba84d56853265a34330b4766f8e75edd1f4a1650476c10802f22b64bd3919d246ba20a17558bc51c199efdec67e80a227251808d8ce5bad', + }, + { + inputLen: 1025, + expectedHash: 'd00278ae47eb27b34faecf67b4fe263f82d5412916c1ffd97c8cb7fb814b8444f4c4a22b4b399155358a994e52bf255de60035742ec71bd08ac275a1b51cc6bfe332b0ef84b409108cda080e6269ed4b3e2c3f7d722aa4cdc98d16deb554e5627be8f955c98e1d5f9565a9194cad0c4285f93700062d9595adb992ae68ff12800ab67a', + expectedKeyed: '357dc55de0c7e382c900fd6e320acc04146be01db6a8ce7210b7189bd664ea69362396b77fdc0d2634a552970843722066c3c15902ae5097e00ff53f1e116f1cd5352720113a837ab2452cafbde4d54085d9cf5d21ca613071551b25d52e69d6c81123872b6f19cd3bc1333edf0c52b94de23ba772cf82636cff4542540a7738d5b930', + expectedDerive: 'effaa245f065fbf82ac186839a249707c3bddf6d3fdda22d1b95a3c970379bcb5d31013a167509e9066273ab6e2123bc835b408b067d88f96addb550d96b6852dad38e320b9d940f86db74d398c770f462118b35d2724efa13da97194491d96dd37c3c09cbef665953f2ee85ec83d88b88d11547a6f911c8217cca46defa2751e7f3ad', + }, + { + inputLen: 2048, + expectedHash: 'e776b6028c7cd22a4d0ba182a8bf62205d2ef576467e838ed6f2529b85fba24a9a60bf80001410ec9eea6698cd537939fad4749edd484cb541aced55cd9bf54764d063f23f6f1e32e12958ba5cfeb1bf618ad094266d4fc3c968c2088f677454c288c67ba0dba337b9d91c7e1ba586dc9a5bc2d5e90c14f53a8863ac75655461cea8f9', + expectedKeyed: '879cf1fa2ea0e79126cb1063617a05b6ad9d0b696d0d757cf053439f60a99dd10173b961cd574288194b23ece278c330fbb8585485e74967f31352a8183aa782b2b22f26cdcadb61eed1a5bc144b8198fbb0c13abbf8e3192c145d0a5c21633b0ef86054f42809df823389ee40811a5910dcbd1018af31c3b43aa55201ed4edaac74fe', + expectedDerive: '7b2945cb4fef70885cc5d78a87bf6f6207dd901ff239201351ffac04e1088a23e2c11a1ebffcea4d80447867b61badb1383d842d4e79645d48dd82ccba290769caa7af8eaa1bd78a2a5e6e94fbdab78d9c7b74e894879f6a515257ccf6f95056f4e25390f24f6b35ffbb74b766202569b1d797f2d4bd9d17524c720107f985f4ddc583', + }, + { + inputLen: 2049, + expectedHash: '5f4d72f40d7a5f82b15ca2b2e44b1de3c2ef86c426c95c1af0b687952256303096de31d71d74103403822a2e0bc1eb193e7aecc9643a76b7bbc0c9f9c52e8783aae98764ca468962b5c2ec92f0c74eb5448d519713e09413719431c802f948dd5d90425a4ecdadece9eb178d80f26efccae630734dff63340285adec2aed3b51073ad3', + expectedKeyed: '9f29700902f7c86e514ddc4df1e3049f258b2472b6dd5267f61bf13983b78dd5f9a88abfefdfa1e00b418971f2b39c64ca621e8eb37fceac57fd0c8fc8e117d43b81447be22d5d8186f8f5919ba6bcc6846bd7d50726c06d245672c2ad4f61702c646499ee1173daa061ffe15bf45a631e2946d616a4c345822f1151284712f76b2b0e', + expectedDerive: '2ea477c5515cc3dd606512ee72bb3e0e758cfae7232826f35fb98ca1bcbdf27316d8e9e79081a80b046b60f6a263616f33ca464bd78d79fa18200d06c7fc9bffd808cc4755277a7d5e09da0f29ed150f6537ea9bed946227ff184cc66a72a5f8c1e4bd8b04e81cf40fe6dc4427ad5678311a61f4ffc39d195589bdbc670f63ae70f4b6', + }, + { + inputLen: 3072, + expectedHash: 'b98cb0ff3623be03326b373de6b9095218513e64f1ee2edd2525c7ad1e5cffd29a3f6b0b978d6608335c09dc94ccf682f9951cdfc501bfe47b9c9189a6fc7b404d120258506341a6d802857322fbd20d3e5dae05b95c88793fa83db1cb08e7d8008d1599b6209d78336e24839724c191b2a52a80448306e0daa84a3fdb566661a37e11', + expectedKeyed: '044a0e7b172a312dc02a4c9a818c036ffa2776368d7f528268d2e6b5df19177022f302d0529e4174cc507c463671217975e81dab02b8fdeb0d7ccc7568dd22574c783a76be215441b32e91b9a904be8ea81f7a0afd14bad8ee7c8efc305ace5d3dd61b996febe8da4f56ca0919359a7533216e2999fc87ff7d8f176fbecb3d6f34278b', + expectedDerive: '050df97f8c2ead654d9bb3ab8c9178edcd902a32f8495949feadcc1e0480c46b3604131bbd6e3ba573b6dd682fa0a63e5b165d39fc43a625d00207607a2bfeb65ff1d29292152e26b298868e3b87be95d6458f6f2ce6118437b632415abe6ad522874bcd79e4030a5e7bad2efa90a7a7c67e93f0a18fb28369d0a9329ab5c24134ccb0', + }, + { + inputLen: 3073, + expectedHash: '7124b49501012f81cc7f11ca069ec9226cecb8a2c850cfe644e327d22d3e1cd39a27ae3b79d68d89da9bf25bc27139ae65a324918a5f9b7828181e52cf373c84f35b639b7fccbb985b6f2fa56aea0c18f531203497b8bbd3a07ceb5926f1cab74d14bd66486d9a91eba99059a98bd1cd25876b2af5a76c3e9eed554ed72ea952b603bf', + expectedKeyed: '68dede9bef00ba89e43f31a6825f4cf433389fedae75c04ee9f0cf16a427c95a96d6da3fe985054d3478865be9a092250839a697bbda74e279e8a9e69f0025e4cfddd6cfb434b1cd9543aaf97c635d1b451a4386041e4bb100f5e45407cbbc24fa53ea2de3536ccb329e4eb9466ec37093a42cf62b82903c696a93a50b702c80f3c3c5', + expectedDerive: '72613c9ec9ff7e40f8f5c173784c532ad852e827dba2bf85b2ab4b76f7079081576288e552647a9d86481c2cae75c2dd4e7c5195fb9ada1ef50e9c5098c249d743929191441301c69e1f48505a4305ec1778450ee48b8e69dc23a25960fe33070ea549119599760a8a2d28aeca06b8c5e9ba58bc19e11fe57b6ee98aa44b2a8e6b14a5', + }, + { + inputLen: 4096, + expectedHash: '015094013f57a5277b59d8475c0501042c0b642e531b0a1c8f58d2163229e9690289e9409ddb1b99768eafe1623da896faf7e1114bebeadc1be30829b6f8af707d85c298f4f0ff4d9438aef948335612ae921e76d411c3a9111df62d27eaf871959ae0062b5492a0feb98ef3ed4af277f5395172dbe5c311918ea0074ce0036454f620', + expectedKeyed: 'befc660aea2f1718884cd8deb9902811d332f4fc4a38cf7c7300d597a081bfc0bbb64a36edb564e01e4b4aaf3b060092a6b838bea44afebd2deb8298fa562b7b597c757b9df4c911c3ca462e2ac89e9a787357aaf74c3b56d5c07bc93ce899568a3eb17d9250c20f6c5f6c1e792ec9a2dcb715398d5a6ec6d5c54f586a00403a1af1de', + expectedDerive: '1e0d7f3db8c414c97c6307cbda6cd27ac3b030949da8e23be1a1a924ad2f25b9d78038f7b198596c6cc4a9ccf93223c08722d684f240ff6569075ed81591fd93f9fff1110b3a75bc67e426012e5588959cc5a4c192173a03c00731cf84544f65a2fb9378989f72e9694a6a394a8a30997c2e67f95a504e631cd2c5f55246024761b245', + }, + { + inputLen: 4097, + expectedHash: '9b4052b38f1c5fc8b1f9ff7ac7b27cd242487b3d890d15c96a1c25b8aa0fb99505f91b0b5600a11251652eacfa9497b31cd3c409ce2e45cfe6c0a016967316c426bd26f619eab5d70af9a418b845c608840390f361630bd497b1ab44019316357c61dbe091ce72fc16dc340ac3d6e009e050b3adac4b5b2c92e722cffdc46501531956', + expectedKeyed: '00df940cd36bb9fa7cbbc3556744e0dbc8191401afe70520ba292ee3ca80abbc606db4976cfdd266ae0abf667d9481831ff12e0caa268e7d3e57260c0824115a54ce595ccc897786d9dcbf495599cfd90157186a46ec800a6763f1c59e36197e9939e900809f7077c102f888caaf864b253bc41eea812656d46742e4ea42769f89b83f', + expectedDerive: 'aca51029626b55fda7117b42a7c211f8c6e9ba4fe5b7a8ca922f34299500ead8a897f66a400fed9198fd61dd2d58d382458e64e100128075fc54b860934e8de2e84170734b06e1d212a117100820dbc48292d148afa50567b8b84b1ec336ae10d40c8c975a624996e12de31abbe135d9d159375739c333798a80c64ae895e51e22f3ad', + }, + { + inputLen: 5120, + expectedHash: '9cadc15fed8b5d854562b26a9536d9707cadeda9b143978f319ab34230535833acc61c8fdc114a2010ce8038c853e121e1544985133fccdd0a2d507e8e615e611e9a0ba4f47915f49e53d721816a9198e8b30f12d20ec3689989175f1bf7a300eee0d9321fad8da232ece6efb8e9fd81b42ad161f6b9550a069e66b11b40487a5f5059', + expectedKeyed: '2c493e48e9b9bf31e0553a22b23503c0a3388f035cece68eb438d22fa1943e209b4dc9209cd80ce7c1f7c9a744658e7e288465717ae6e56d5463d4f80cdb2ef56495f6a4f5487f69749af0c34c2cdfa857f3056bf8d807336a14d7b89bf62bef2fb54f9af6a546f818dc1e98b9e07f8a5834da50fa28fb5874af91bf06020d1bf0120e', + expectedDerive: '7a7acac8a02adcf3038d74cdd1d34527de8a0fcc0ee3399d1262397ce5817f6055d0cefd84d9d57fe792d65a278fd20384ac6c30fdb340092f1a74a92ace99c482b28f0fc0ef3b923e56ade20c6dba47e49227166251337d80a037e987ad3a7f728b5ab6dfafd6e2ab1bd583a95d9c895ba9c2422c24ea0f62961f0dca45cad47bfa0d', + }, + { + inputLen: 5121, + expectedHash: '628bd2cb2004694adaab7bbd778a25df25c47b9d4155a55f8fbd79f2fe154cff96adaab0613a6146cdaabe498c3a94e529d3fc1da2bd08edf54ed64d40dcd6777647eac51d8277d70219a9694334a68bc8f0f23e20b0ff70ada6f844542dfa32cd4204ca1846ef76d811cdb296f65e260227f477aa7aa008bac878f72257484f2b6c95', + expectedKeyed: '6ccf1c34753e7a044db80798ecd0782a8f76f33563accaddbfbb2e0ea4b2d0240d07e63f13667a8d1490e5e04f13eb617aea16a8c8a5aaed1ef6fbde1b0515e3c81050b361af6ead126032998290b563e3caddeaebfab592e155f2e161fb7cba939092133f23f9e65245e58ec23457b78a2e8a125588aad6e07d7f11a85b88d375b72d', + expectedDerive: 'b07f01e518e702f7ccb44a267e9e112d403a7b3f4883a47ffbed4b48339b3c341a0add0ac032ab5aaea1e4e5b004707ec5681ae0fcbe3796974c0b1cf31a194740c14519273eedaabec832e8a784b6e7cfc2c5952677e6c3f2c3914454082d7eb1ce1766ac7d75a4d3001fc89544dd46b5147382240d689bbbaefc359fb6ae30263165', + }, + { + inputLen: 6144, + expectedHash: '3e2e5b74e048f3add6d21faab3f83aa44d3b2278afb83b80b3c35164ebeca2054d742022da6fdda444ebc384b04a54c3ac5839b49da7d39f6d8a9db03deab32aade156c1c0311e9b3435cde0ddba0dce7b26a376cad121294b689193508dd63151603c6ddb866ad16c2ee41585d1633a2cea093bea714f4c5d6b903522045b20395c83', + expectedKeyed: '3d6b6d21281d0ade5b2b016ae4034c5dec10ca7e475f90f76eac7138e9bc8f1dc35754060091dc5caf3efabe0603c60f45e415bb3407db67e6beb3d11cf8e4f7907561f05dace0c15807f4b5f389c841eb114d81a82c02a00b57206b1d11fa6e803486b048a5ce87105a686dee041207e095323dfe172df73deb8c9532066d88f9da7e', + expectedDerive: '2a95beae63ddce523762355cf4b9c1d8f131465780a391286a5d01abb5683a1597099e3c6488aab6c48f3c15dbe1942d21dbcdc12115d19a8b8465fb54e9053323a9178e4275647f1a9927f6439e52b7031a0b465c861a3fc531527f7758b2b888cf2f20582e9e2c593709c0a44f9c6e0f8b963994882ea4168827823eef1f64169fef', + }, + { + inputLen: 6145, + expectedHash: 'f1323a8631446cc50536a9f705ee5cb619424d46887f3c376c695b70e0f0507f18a2cfdd73c6e39dd75ce7c1c6e3ef238fd54465f053b25d21044ccb2093beb015015532b108313b5829c3621ce324b8e14229091b7c93f32db2e4e63126a377d2a63a3597997d4f1cba59309cb4af240ba70cebff9a23d5e3ff0cdae2cfd54e070022', + expectedKeyed: '9ac301e9e39e45e3250a7e3b3df701aa0fb6889fbd80eeecf28dbc6300fbc539f3c184ca2f59780e27a576c1d1fb9772e99fd17881d02ac7dfd39675aca918453283ed8c3169085ef4a466b91c1649cc341dfdee60e32231fc34c9c4e0b9a2ba87ca8f372589c744c15fd6f985eec15e98136f25beeb4b13c4e43dc84abcc79cd4646c', + expectedDerive: '379bcc61d0051dd489f686c13de00d5b14c505245103dc040d9e4dd1facab8e5114493d029bdbd295aaa744a59e31f35c7f52dba9c3642f773dd0b4262a9980a2aef811697e1305d37ba9d8b6d850ef07fe41108993180cf779aeece363704c76483458603bbeeb693cffbbe5588d1f3535dcad888893e53d977424bb707201569a8d2', + }, + { + inputLen: 7168, + expectedHash: '61da957ec2499a95d6b8023e2b0e604ec7f6b50e80a9678b89d2628e99ada77a5707c321c83361793b9af62a40f43b523df1c8633cecb4cd14d00bdc79c78fca5165b863893f6d38b02ff7236c5a9a8ad2dba87d24c547cab046c29fc5bc1ed142e1de4763613bb162a5a538e6ef05ed05199d751f9eb58d332791b8d73fb74e4fce95', + expectedKeyed: 'b42835e40e9d4a7f42ad8cc04f85a963a76e18198377ed84adddeaecacc6f3fca2f01d5277d69bb681c70fa8d36094f73ec06e452c80d2ff2257ed82e7ba348400989a65ee8daa7094ae0933e3d2210ac6395c4af24f91c2b590ef87d7788d7066ea3eaebca4c08a4f14b9a27644f99084c3543711b64a070b94f2c9d1d8a90d035d52', + expectedDerive: '11c37a112765370c94a51415d0d651190c288566e295d505defdad895dae223730d5a5175a38841693020669c7638f40b9bc1f9f39cf98bda7a5b54ae24218a800a2116b34665aa95d846d97ea988bfcb53dd9c055d588fa21ba78996776ea6c40bc428b53c62b5f3ccf200f647a5aae8067f0ea1976391fcc72af1945100e2a6dcb88', + }, + { + inputLen: 7169, + expectedHash: 'a003fc7a51754a9b3c7fae0367ab3d782dccf28855a03d435f8cfe74605e781798a8b20534be1ca9eb2ae2df3fae2ea60e48c6fb0b850b1385b5de0fe460dbe9d9f9b0d8db4435da75c601156df9d047f4ede008732eb17adc05d96180f8a73548522840779e6062d643b79478a6e8dbce68927f36ebf676ffa7d72d5f68f050b119c8', + expectedKeyed: 'ed9b1a922c046fdb3d423ae34e143b05ca1bf28b710432857bf738bcedbfa5113c9e28d72fcbfc020814ce3f5d4fc867f01c8f5b6caf305b3ea8a8ba2da3ab69fabcb438f19ff11f5378ad4484d75c478de425fb8e6ee809b54eec9bdb184315dc856617c09f5340451bf42fd3270a7b0b6566169f242e533777604c118a6358250f54', + expectedDerive: '554b0a5efea9ef183f2f9b931b7497995d9eb26f5c5c6dad2b97d62fc5ac31d99b20652c016d88ba2a611bbd761668d5eda3e568e940faae24b0d9991c3bd25a65f770b89fdcadabcb3d1a9c1cb63e69721cacf1ae69fefdcef1e3ef41bc5312ccc17222199e47a26552c6adc460cf47a72319cb5039369d0060eaea59d6c65130f1dd', + }, + { + inputLen: 8192, + expectedHash: 'aae792484c8efe4f19e2ca7d371d8c467ffb10748d8a5a1ae579948f718a2a635fe51a27db045a567c1ad51be5aa34c01c6651c4d9b5b5ac5d0fd58cf18dd61a47778566b797a8c67df7b1d60b97b19288d2d877bb2df417ace009dcb0241ca1257d62712b6a4043b4ff33f690d849da91ea3bf711ed583cb7b7a7da2839ba71309bbf', + expectedKeyed: 'dc9637c8845a770b4cbf76b8daec0eebf7dc2eac11498517f08d44c8fc00d58a4834464159dcbc12a0ba0c6d6eb41bac0ed6585cabfe0aca36a375e6c5480c22afdc40785c170f5a6b8a1107dbee282318d00d915ac9ed1143ad40765ec120042ee121cd2baa36250c618adaf9e27260fda2f94dea8fb6f08c04f8f10c78292aa46102', + expectedDerive: 'ad01d7ae4ad059b0d33baa3c01319dcf8088094d0359e5fd45d6aeaa8b2d0c3d4c9e58958553513b67f84f8eac653aeeb02ae1d5672dcecf91cd9985a0e67f4501910ecba25555395427ccc7241d70dc21c190e2aadee875e5aae6bf1912837e53411dabf7a56cbf8e4fb780432b0d7fe6cec45024a0788cf5874616407757e9e6bef7', + }, + { + inputLen: 8193, + expectedHash: 'bab6c09cb8ce8cf459261398d2e7aef35700bf488116ceb94a36d0f5f1b7bc3bb2282aa69be089359ea1154b9a9286c4a56af4de975a9aa4a5c497654914d279bea60bb6d2cf7225a2fa0ff5ef56bbe4b149f3ed15860f78b4e2ad04e158e375c1e0c0b551cd7dfc82f1b155c11b6b3ed51ec9edb30d133653bb5709d1dbd55f4e1ff6', + expectedKeyed: '954a2a75420c8d6547e3ba5b98d963e6fa6491addc8c023189cc519821b4a1f5f03228648fd983aef045c2fa8290934b0866b615f585149587dda2299039965328835a2b18f1d63b7e300fc76ff260b571839fe44876a4eae66cbac8c67694411ed7e09df51068a22c6e67d6d3dd2cca8ff12e3275384006c80f4db68023f24eebba57', + expectedDerive: 'af1e0346e389b17c23200270a64aa4e1ead98c61695d917de7d5b00491c9b0f12f20a01d6d622edf3de026a4db4e4526225debb93c1237934d71c7340bb5916158cbdafe9ac3225476b6ab57a12357db3abbad7a26c6e66290e44034fb08a20a8d0ec264f309994d2810c49cfba6989d7abb095897459f5425adb48aba07c5fb3c83c0', + }, + { + inputLen: 16384, + expectedHash: 'f875d6646de28985646f34ee13be9a576fd515f76b5b0a26bb324735041ddde49d764c270176e53e97bdffa58d549073f2c660be0e81293767ed4e4929f9ad34bbb39a529334c57c4a381ffd2a6d4bfdbf1482651b172aa883cc13408fa67758a3e47503f93f87720a3177325f7823251b85275f64636a8f1d599c2e49722f42e93893', + expectedKeyed: '9e9fc4eb7cf081ea7c47d1807790ed211bfec56aa25bb7037784c13c4b707b0df9e601b101e4cf63a404dfe50f2e1865bb12edc8fca166579ce0c70dba5a5c0fc960ad6f3772183416a00bd29d4c6e651ea7620bb100c9449858bf14e1ddc9ecd35725581ca5b9160de04060045993d972571c3e8f71e9d0496bfa744656861b169d65', + expectedDerive: '160e18b5878cd0df1c3af85eb25a0db5344d43a6fbd7a8ef4ed98d0714c3f7e160dc0b1f09caa35f2f417b9ef309dfe5ebd67f4c9507995a531374d099cf8ae317542e885ec6f589378864d3ea98716b3bbb65ef4ab5e0ab5bb298a501f19a41ec19af84a5e6b428ecd813b1a47ed91c9657c3fba11c406bc316768b58f6802c9e9b57', + }, + { + inputLen: 31744, + expectedHash: '62b6960e1a44bcc1eb1a611a8d6235b6b4b78f32e7abc4fb4c6cdcce94895c47860cc51f2b0c28a7b77304bd55fe73af663c02d3f52ea053ba43431ca5bab7bfea2f5e9d7121770d88f70ae9649ea713087d1914f7f312147e247f87eb2d4ffef0ac978bf7b6579d57d533355aa20b8b77b13fd09748728a5cc327a8ec470f4013226f', + expectedKeyed: 'efa53b389ab67c593dba624d898d0f7353ab99e4ac9d42302ee64cbf9939a4193a7258db2d9cd32a7a3ecfce46144114b15c2fcb68a618a976bd74515d47be08b628be420b5e830fade7c080e351a076fbc38641ad80c736c8a18fe3c66ce12f95c61c2462a9770d60d0f77115bbcd3782b593016a4e728d4c06cee4505cb0c08a42ec', + expectedDerive: '39772aef80e0ebe60596361e45b061e8f417429d529171b6764468c22928e28e9759adeb797a3fbf771b1bcea30150a020e317982bf0d6e7d14dd9f064bc11025c25f31e81bd78a921db0174f03dd481d30e93fd8e90f8b2fee209f849f2d2a52f31719a490fb0ba7aea1e09814ee912eba111a9fde9d5c274185f7bae8ba85d300a2b', + }, + ], +}; +//# sourceMappingURL=test-helpers.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/base/test-helpers.js.map b/node_modules/blake3-wasm/esm/base/test-helpers.js.map new file mode 100644 index 0000000..9200569 --- /dev/null +++ b/node_modules/blake3-wasm/esm/base/test-helpers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../ts/base/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAChC,kGAAkG,EAClG,KAAK,CACN,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE;QACL,KAAK,EAAE,YAAY,CAAC,SAAS,GAAG,uBAAuB,EAAE,OAAO,CAAC;QACjE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,kEAAkE,EAAE,KAAK,CAAC;KAC7F;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,MAAM,CAAC,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,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,IAAI;YACd,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,KAAK;YACf,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;QACD;YACE,QAAQ,EAAE,KAAK;YACf,YAAY,EACV,wQAAwQ;YAC1Q,aAAa,EACX,wQAAwQ;YAC1Q,cAAc,EACZ,wQAAwQ;SAC3Q;KACF;CACF,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser.test.d.ts b/node_modules/blake3-wasm/esm/browser.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/browser.test.js b/node_modules/blake3-wasm/esm/browser.test.js new file mode 100644 index 0000000..6a17124 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser.test.js @@ -0,0 +1,261 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { expect } from 'chai.js'; +import { mkdirSync, writeFileSync } from 'fs.js'; +import { createServer } from 'http.js'; +import { tmpdir } from 'os.js'; +import { resolve } from 'path.js'; +import puppeteer from 'puppeteer.js'; +import handler from 'serve-handler.js'; +import webpack from 'webpack.js'; +import { hello48, inputs, ogTestVectors } from './base/test-helpers.js'; +// Much of the browser code is also used in Node's wasm. We test things more +// thoroughly there because tests are easier to write and debug, these tests +// are primarily for sanity and checking browser-specific behavior. +describe('browser', () => { + const addInputs = `window.inputs = ${JSON.stringify(inputs)}`; + describe('webpack', () => { + const testDir = resolve(tmpdir(), 'blake3-browser-test'); + let server; + let page; + /** + * Builds the browser lib into the testDir. + */ + function buildWebpack() { + return __awaiter(this, void 0, void 0, function* () { + try { + mkdirSync(testDir); + } + catch (_a) { + // already exists, probably + } + writeFileSync(resolve(testDir, 'entry-src.js'), `import("blake3/browser").then(b3 => window.blake3 = b3);`); + const stats = yield new Promise((res, rej) => webpack({ + mode: 'production', + devtool: 'source-map', + entry: resolve(testDir, 'entry-src.js'), + output: { + path: testDir, + filename: 'main.js', + }, + resolve: { + alias: { + 'blake3/browser': resolve(__dirname, '../', 'browser.js'), + }, + }, + }, (err, stats) => (err ? rej(err) : res(stats)))); + if (stats.hasErrors()) { + throw stats.toString('errors-only'); + } + writeFileSync(resolve(testDir, 'index.html'), `<script src="/main.js"></script>`); + }); + } + function serve() { + return __awaiter(this, void 0, void 0, function* () { + server = createServer((req, res) => handler(req, res, { public: testDir })); + yield new Promise(resolve => server.listen(0, resolve)); + }); + } + before(function () { + return __awaiter(this, void 0, void 0, function* () { + yield buildWebpack(); + yield serve(); + this.timeout(20 * 1000); + const { port } = server.address(); + const browser = yield puppeteer.launch({ + executablePath: 'google-chrome-stable', + args: ['--no-sandbox'], + }); + page = yield browser.newPage(); + yield page.goto(`http://localhost:${port}`); + yield page.waitForFunction('!!window.blake3'); + yield page.evaluate(addInputs); + }); + }); + runTests({ + get page() { + return page; + }, + }); + after(() => { + page === null || page === void 0 ? void 0 : page.browser().close(); + server === null || server === void 0 ? void 0 : server.close(); + }); + }); + describe('native browser', () => { + let server; + let page; + function serve() { + return __awaiter(this, void 0, void 0, function* () { + server = createServer((req, res) => handler(req, res, { public: resolve(__dirname, '..') })); + yield new Promise(resolve => server.listen(0, resolve)); + }); + } + before(function () { + return __awaiter(this, void 0, void 0, function* () { + yield serve(); + this.timeout(20 * 1000); + const { port } = server.address(); + const browser = yield puppeteer.launch({ + executablePath: 'google-chrome-stable', + args: ['--no-sandbox'], + }); + page = yield browser.newPage(); + page.on('console', console.log); + page.on('pageerror', console.log); + page.on('error', console.log); + yield page.goto(`http://localhost:${port}/browser-async.test.html`); + yield page.waitForFunction('!!window.blake3'); + yield page.evaluate(addInputs); + }); + }); + runTests({ + get page() { + return page; + }, + }); + after(() => { + page === null || page === void 0 ? void 0 : page.browser().close(); + server.close(); + }); + }); +}); +function runTests(opts) { + it('hashes a string', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.large.input).toString("hex")'); + expect(result).to.equal(inputs.large.hash.toString('hex')); + })); + describe('input encoding', () => { + it('hashes a uint8array', () => __awaiter(this, void 0, void 0, function* () { + const contents = [...new Uint8Array(Buffer.from(inputs.hello.input))]; + const result = yield opts.page.evaluate(`blake3.hash(new Uint8Array([${contents.join(',')}])).toString("hex")`); + expect(result).to.equal(inputs.hello.hash.toString('hex')); + })); + it('hashes a string', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.large.input).toString("hex")'); + expect(result).to.equal(inputs.large.hash.toString('hex')); + })); + it('customizes output length', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate('blake3.hash(inputs.hello.input, { length: 16 }).toString("hex")'); + expect(result).to.equal(inputs.hello.hash.slice(0, 16).toString('hex')); + })); + }); + describe('output encoding', () => { + const tcases = [ + { encoding: 'hex', expected: inputs.hello.hash.toString('hex') }, + { encoding: 'base64', expected: inputs.hello.hash.toString('base64') }, + { encoding: 'utf8', expected: inputs.hello.hash.toString('utf8') }, + ]; + tcases.forEach(({ encoding, expected }) => it(encoding, () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.hash(inputs.hello.input).toString("${encoding}")`); + expect(result).to.equal(expected); + }))); + it('raw', () => __awaiter(this, void 0, void 0, function* () { + const result = (yield opts.page.evaluate(`blake3.hash(inputs.hello.input)`)); + const actual = Buffer.alloc(32); + for (let i = 0; i < actual.length; i++) { + actual[i] = result[i]; // it comes as a plain object, we need to convert it to a buffer + } + expect(actual).to.deep.equal(inputs.hello.hash); + })); + }); + describe('hash class', () => { + it('digests', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + ${[...Buffer.from(inputs.hello.input)] + .map(byte => `hash.update(new Uint8Array([${byte}]));`) + .join('\n')} + return hash.digest('hex'); + })()`); + expect(result).to.equal(inputs.hello.hash.toString('hex')); + })); + it('customizes the output length', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + hash.update(${JSON.stringify(inputs.hello.input)}); + return hash.digest('hex', { length: 16 }); + })()`); + expect(result).to.equal(inputs.hello.hash.slice(0, 16).toString('hex')); + })); + it('returns a hash instance from digest', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + ${[...Buffer.from(inputs.hello.input)] + .map(byte => `hash.update(new Uint8Array([${byte}]));`) + .join('\n')} + return hash.digest('hex'); + })()`); + expect(result).to.equal(inputs.hello.hash.toString('hex')); + })); + }); + describe('reader', () => { + it('is sane with a Hash', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hash = blake3.createHash(); + hash.update("hello"); + + return blake3.using(hash.reader(), reader => [ + reader.read(48).toString('hex'), + reader.toArray().toString('hex'), + reader.toString('hex'), + ]); + })()`); + expect(result).to.deep.equal([ + hello48.toString('hex'), + inputs.hello.hash.toString('hex'), + inputs.hello.hash.toString('hex'), + ]); + })); + }); + describe('original test vectors', () => { + for (const { inputLen, expectedDerive, expectedHash, expectedKeyed, } of ogTestVectors.cases.slice(0, 6)) { + describe(`${inputLen}`, () => __awaiter(this, void 0, void 0, function* () { + const input = Buffer.alloc(inputLen); + for (let i = 0; i < inputLen; i++) { + input[i] = i % 251; + } + const inputStr = `new Uint8Array([${input.join(',')}])`; + it('hash()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.hash( + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + expect(result).to.equal(expectedHash); + })); + it('deriveKey()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.deriveKey( + ${JSON.stringify(ogTestVectors.context)}, + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + expect(result).to.equal(expectedDerive); + })); + it('createKeyed()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`(() => { + const hasher = blake3.createKeyed(new Uint8Array([${Buffer.from(ogTestVectors.key).join(',')}])); + hasher.update(${inputStr}); + return hasher.digest({ length: ${expectedHash.length / 2} }).toString('hex'); + })()`); + expect(result).to.equal(expectedKeyed); + })); + it('keyedHash()', () => __awaiter(this, void 0, void 0, function* () { + const result = yield opts.page.evaluate(`blake3.keyedHash( + new Uint8Array([${Buffer.from(ogTestVectors.key).join(',')}]), + ${inputStr}, + { length: ${expectedHash.length / 2} } + ).toString("hex")`); + expect(result).to.equal(expectedKeyed); + })); + })); + } + }); +} +//# sourceMappingURL=browser.test.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser.test.js.map b/node_modules/blake3-wasm/esm/browser.test.js.map new file mode 100644 index 0000000..b73ffc0 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.test.js","sourceRoot":"","sources":["../ts/browser.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAU,MAAM,MAAM,CAAC;AAE5C,OAAO,EA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AC,CAAA,CAAC,CAAC;YACL,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/encoding.d.ts b/node_modules/blake3-wasm/esm/browser/encoding.d.ts new file mode 100644 index 0000000..4c8b547 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/encoding.d.ts @@ -0,0 +1,5 @@ +export declare type BrowserEncoding = 'hex' | 'base64' | 'utf8'; +/** + * @hidden + */ +export declare const mustGetEncoder: (encoding: BrowserEncoding) => (data: Uint8Array) => string; diff --git a/node_modules/blake3-wasm/esm/browser/encoding.js b/node_modules/blake3-wasm/esm/browser/encoding.js new file mode 100644 index 0000000..0b6d1e4 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/encoding.js @@ -0,0 +1,28 @@ +// A small collection of encodings for convenience of use in the browser. +const decoder = new TextDecoder(); +const encoders = { + // certainly not the fastest, but hashes are pretty small + base64: data => btoa(String.fromCharCode(...data)), + hex: data => { + let out = ''; + for (const byte of data) { + if (byte < 0x10) { + out += '0'; + } + out += byte.toString(16); + } + return out; + }, + utf8: data => decoder.decode(data), +}; +/** + * @hidden + */ +export const mustGetEncoder = (encoding) => { + const encoder = encoders[encoding]; + if (!encoder) { + throw new Error(`Unknown encoding ${encoding}`); + } + return encoder; +}; +//# sourceMappingURL=encoding.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/encoding.js.map b/node_modules/blake3-wasm/esm/browser/encoding.js.map new file mode 100644 index 0000000..2a6cfe6 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/encoding.js.map @@ -0,0 +1 @@ +{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../ts/browser/encoding.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAIzE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,QAAQ,GAA6D;IACzE,yDAAyD;IACzD,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC;IAElD,GAAG,EAAE,IAAI,CAAC,EAAE;QACV,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;YACvB,IAAI,IAAI,GAAG,IAAI,EAAE;gBACf,GAAG,IAAI,GAAG,CAAC;aACZ;YAED,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SAC1B;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAyB,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;KACjD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-fn.d.ts b/node_modules/blake3-wasm/esm/browser/hash-fn.d.ts new file mode 100644 index 0000000..a341ea2 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-fn.d.ts @@ -0,0 +1,24 @@ +import { BaseHashInput, IBaseHashOptions } from '../base/hash-fn'; +import { Hash } from './hash'; +/** + * Input used for browser-based hashes. + */ +export declare type HashInput = BaseHashInput | string; +/** + * @hidden + */ +export declare const normalizeInput: (input: import("..").HashInput) => Uint8Array; +/** + * Returns a blake3 hash of the input. + */ +export declare function hash(input: HashInput, { length }?: IBaseHashOptions): 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. + */ +export declare function deriveKey(context: string, material: HashInput, { length }?: IBaseHashOptions): Hash; +/** + * The keyed hash function. See {@link https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html}. + */ +export declare function keyedHash(key: Uint8Array, input: HashInput, { length }?: IBaseHashOptions): Hash; diff --git a/node_modules/blake3-wasm/esm/browser/hash-fn.js b/node_modules/blake3-wasm/esm/browser/hash-fn.js new file mode 100644 index 0000000..8306eed --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-fn.js @@ -0,0 +1,42 @@ +import { inputToArray, defaultHashLength } from '../base/hash-fn.js'; +import { Hash } from './hash.js'; +import { getWasm } from './wasm.js'; +const textEncoder = new TextEncoder(); +/** + * @hidden + */ +export const normalizeInput = (input) => inputToArray(typeof input === 'string' ? textEncoder.encode(input) : input); +/** + * Returns a blake3 hash of the input. + */ +export function hash(input, { length = defaultHashLength } = {}) { + const result = new Hash(length); + getWasm().hash(normalizeInput(input), result); + return result; +} +/** + * 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 derive = getWasm().create_derive(context); + derive.update(normalizeInput(material)); + const result = new Hash(length); + derive.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 } = {}) { + if (key.length !== 32) { + throw new Error(`key provided to keyedHash must be 32 bytes, got ${key.length}`); + } + const derive = getWasm().create_keyed(key); + derive.update(normalizeInput(input)); + const result = new Hash(length); + derive.digest(result); + return result; +} +//# sourceMappingURL=hash-fn.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-fn.js.map b/node_modules/blake3-wasm/esm/browser/hash-fn.js.map new file mode 100644 index 0000000..d43aa6b --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":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GAAG,iBAAiB,KAAuB,EAAE;IAErD,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClF;IAED,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAChC,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/browser/hash-instance.d.ts b/node_modules/blake3-wasm/esm/browser/hash-instance.d.ts new file mode 100644 index 0000000..0a706b3 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-instance.d.ts @@ -0,0 +1,31 @@ +import { BaseHash as BaseHasher } from '../base/index'; +import { HashInput } from './hash-fn'; +import { BrowserEncoding } from './encoding'; +import { IBaseHashOptions } from '../base/hash-fn'; +import { BrowserHashReader } from './hash-reader'; +import { IInternalReader } from '../base/hash-reader'; +import { Hash } from './hash'; +/** + * @inheritdoc + */ +export declare class BrowserHasher extends BaseHasher<Hash, IInternalReader, BrowserHashReader> { + /** + * @inheritdoc + * @override + */ + update(data: HashInput): this; + /** + * Returns a digest of the hash with the given encoding. + */ + digest(options?: IBaseHashOptions): Hash; + digest(encoding: undefined, options: IBaseHashOptions): Hash; + digest(encoding: BrowserEncoding, options?: IBaseHashOptions): string; +} +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => BrowserHasher; +/** + * A Node.js crypto-like createHash method. + */ +export declare const createKeyed: (key: Uint8Array) => BrowserHasher; diff --git a/node_modules/blake3-wasm/esm/browser/hash-instance.js b/node_modules/blake3-wasm/esm/browser/hash-instance.js new file mode 100644 index 0000000..6f93c20 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-instance.js @@ -0,0 +1,41 @@ +import { BaseHash as BaseHasher } from '../base/index.js'; +import { normalizeInput } from './hash-fn.js'; +import { mustGetEncoder } from './encoding.js'; +import { BrowserHashReader } from './hash-reader.js'; +import { Hash } from './hash.js'; +import { getWasm } from './wasm.js'; +/** + * @inheritdoc + */ +export class BrowserHasher extends BaseHasher { + /** + * @inheritdoc + * @override + */ + update(data) { + return super.update(normalizeInput(data)); + } + digest(encoding, options) { + let resolvedOpts; + let resolvedEnc; + if (encoding && typeof encoding === 'object') { + resolvedOpts = encoding; + resolvedEnc = undefined; + } + else { + resolvedOpts = options; + resolvedEnc = encoding; + } + const result = super.digest(resolvedOpts); + return resolvedEnc ? mustGetEncoder(resolvedEnc)(result) : result; + } +} +/** + * A Node.js crypto-like createHash method. + */ +export const createHash = () => new BrowserHasher(getWasm().create_hasher(), l => new Hash(l), r => new BrowserHashReader(r)); +/** + * A Node.js crypto-like createHash method. + */ +export const createKeyed = (key) => new BrowserHasher(getWasm().create_keyed(key), l => new Hash(l), r => new BrowserHashReader(r)); +//# sourceMappingURL=hash-instance.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-instance.js.map b/node_modules/blake3-wasm/esm/browser/hash-instance.js.map new file mode 100644 index 0000000..717166f --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/browser/hash-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,cAAc,EAAa,MAAM,WAAW,CAAC;AACtD,OAAO,EAAmB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC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AC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-reader.d.ts b/node_modules/blake3-wasm/esm/browser/hash-reader.d.ts new file mode 100644 index 0000000..f2a75c7 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-reader.d.ts @@ -0,0 +1,17 @@ +import { BaseHashReader } from '../base/hash-reader'; +import { BrowserEncoding } from './encoding'; +import { Hash } from './hash'; +/** + * A hash reader for WebAssembly targets. + */ +export declare class BrowserHashReader extends BaseHashReader<Hash> { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding?: BrowserEncoding): string; + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray(): Hash; + protected alloc(bytes: number): Hash; +} diff --git a/node_modules/blake3-wasm/esm/browser/hash-reader.js b/node_modules/blake3-wasm/esm/browser/hash-reader.js new file mode 100644 index 0000000..1843eb0 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-reader.js @@ -0,0 +1,25 @@ +import { BaseHashReader } from '../base/hash-reader.js'; +import { Hash } from './hash.js'; +import { defaultHashLength } from '../base/index.js'; +/** + * A hash reader for WebAssembly targets. + */ +export class BrowserHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toArray().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toArray() { + this.position = BigInt(0); + return this.read(defaultHashLength); + } + alloc(bytes) { + return new Hash(bytes); + } +} +//# sourceMappingURL=hash-reader.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash-reader.js.map b/node_modules/blake3-wasm/esm/browser/hash-reader.js.map new file mode 100644 index 0000000..e4549e0 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/browser/hash-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAoB;IACzD;;OAEG;IACI,QAAQ,CAAC,WAA4B,KAAK;QAC/C,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,KAAa;QAC3B,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACF"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash.d.ts b/node_modules/blake3-wasm/esm/browser/hash.d.ts new file mode 100644 index 0000000..6487771 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash.d.ts @@ -0,0 +1,11 @@ +import { BrowserEncoding } from './encoding'; +/** + * Hash returned from functions in the browser. + */ +export declare class Hash extends Uint8Array { + /** + * A constant-time comparison against the other hash/array. + */ + equals(other: unknown): boolean; + toString(encoding?: BrowserEncoding): string; +} diff --git a/node_modules/blake3-wasm/esm/browser/hash.js b/node_modules/blake3-wasm/esm/browser/hash.js new file mode 100644 index 0000000..9940c74 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash.js @@ -0,0 +1,26 @@ +import { mustGetEncoder } from './encoding.js'; +/** + * Hash returned from functions in the browser. + */ +export class Hash extends Uint8Array { + /** + * A constant-time comparison against the other hash/array. + */ + equals(other) { + if (!(other instanceof Uint8Array)) { + return false; + } + if (other.length !== this.length) { + return false; + } + let cmp = 0; + for (let i = 0; i < this.length; i++) { + cmp |= this[i] ^ other[i]; + } + return cmp === 0; + } + toString(encoding = 'hex') { + return mustGetEncoder(encoding)(this); + } +} +//# sourceMappingURL=hash.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/hash.js.map b/node_modules/blake3-wasm/esm/browser/hash.js.map new file mode 100644 index 0000000..0012b8b --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/hash.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../ts/browser/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IAClC;;OAEG;IACI,MAAM,CAAC,KAAc;QAC1B,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,EAAE;YAClC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;YAChC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SAC3B;QAED,OAAO,GAAG,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,QAAQ,CAAC,WAA4B,KAAK;QAC/C,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/index.d.ts b/node_modules/blake3-wasm/esm/browser/index.d.ts new file mode 100644 index 0000000..f44c7ed --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/index.d.ts @@ -0,0 +1,3 @@ +export { hash, HashInput, deriveKey, keyedHash } from './hash-fn'; +export * from './hash-instance'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/esm/browser/index.js b/node_modules/blake3-wasm/esm/browser/index.js new file mode 100644 index 0000000..e9de3ec --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/index.js @@ -0,0 +1,4 @@ +export { hash, deriveKey, keyedHash } from './hash-fn.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/browser/index.js.map b/node_modules/blake3-wasm/esm/browser/index.js.map new file mode 100644 index 0000000..cefc8f5 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAa,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAClE,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/wasm.d.ts b/node_modules/blake3-wasm/esm/browser/wasm.d.ts new file mode 100644 index 0000000..559b61e --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/wasm.d.ts @@ -0,0 +1,10 @@ +import * as rawWasm from '../../dist/wasm/browser/blake3_js'; +/** + * Gets the webassembly module provided in provideWasm. + */ +export declare const getWasm: () => typeof rawWasm; +/** + * Sets the webassembly module used for the browser build. This indirection is + * needed to provide compatibility between the "browser" and "browser-async" modes. + */ +export declare const provideWasm: (w: typeof rawWasm) => void; diff --git a/node_modules/blake3-wasm/esm/browser/wasm.js b/node_modules/blake3-wasm/esm/browser/wasm.js new file mode 100644 index 0000000..2fe61f3 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/wasm.js @@ -0,0 +1,18 @@ +let wasm; +/** + * Gets the webassembly module provided in provideWasm. + */ +export const getWasm = () => { + if (!wasm) { + throw new Error('BLAKE3 webassembly not loaded. Please import the module via `blake3/browser` or `blake3/browser-async`'); + } + return wasm; +}; +/** + * Sets the webassembly module used for the browser build. This indirection is + * needed to provide compatibility between the "browser" and "browser-async" modes. + */ +export const provideWasm = (w) => { + wasm = w; +}; +//# sourceMappingURL=wasm.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/browser/wasm.js.map b/node_modules/blake3-wasm/esm/browser/wasm.js.map new file mode 100644 index 0000000..40ec937 --- /dev/null +++ b/node_modules/blake3-wasm/esm/browser/wasm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../ts/browser/wasm.ts"],"names":[],"mappings":"AAEA,IAAI,IAAoB,CAAC;AAEzB;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;KACH;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAiB,EAAE,EAAE;IAC/C,IAAI,GAAG,CAAC,CAAC;AACX,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/add-js-extensions.d.ts b/node_modules/blake3-wasm/esm/build/add-js-extensions.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/add-js-extensions.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/build/add-js-extensions.js b/node_modules/blake3-wasm/esm/build/add-js-extensions.js new file mode 100644 index 0000000..d7f4b40 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/add-js-extensions.js @@ -0,0 +1,40 @@ +import * as ts from 'typescript.js'; +import { readFileSync, writeFileSync, readdirSync, statSync } from 'fs.js'; +import { extname, basename, join, resolve } from 'path.js'; +/** + * Script that adds .js extension to imports so that it's compatible with plain + * browser/non-webpack bundlers. TS doesn't support this natively yet. + * @see https://github.com/microsoft/TypeScript/issues/16577 + */ +function processFile(file) { + let source = readFileSync(file, 'utf-8'); + const program = ts.createSourceFile(basename(file), source, ts.ScriptTarget.ES2015, true); + let offset = 0; + const process = (node) => { + if ((!ts.isImportDeclaration(node) && !ts.isExportDeclaration(node)) || !node.moduleSpecifier) { + return ts.forEachChild(node, process); + } + const specifier = node.moduleSpecifier; + if (extname(specifier.getText()) === '') { + const idx = specifier.end + offset - 1; + source = source.slice(0, idx) + '.js' + source.slice(idx); + offset += 3; + } + }; + process(program); + writeFileSync(file, source); +} +function processDir(dir) { + const entries = readdirSync(dir); + for (const entry of entries) { + const path = join(dir, entry); + if (path.endsWith('.js')) { + processFile(path); + } + else if (statSync(path).isDirectory()) { + processDir(path); + } + } +} +processDir(resolve(__dirname, '..', '..', 'esm')); +//# sourceMappingURL=add-js-extensions.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/add-js-extensions.js.map b/node_modules/blake3-wasm/esm/build/add-js-extensions.js.map new file mode 100644 index 0000000..a953f5d --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/add-js-extensions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"add-js-extensions.js","sourceRoot":"","sources":["../../ts/build/add-js-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAExD;;;;GAIG;AAEH,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC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AAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/generate-tasks.d.ts b/node_modules/blake3-wasm/esm/build/generate-tasks.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/generate-tasks.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/build/generate-tasks.js b/node_modules/blake3-wasm/esm/build/generate-tasks.js new file mode 100644 index 0000000..0993219 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/generate-tasks.js @@ -0,0 +1,83 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { writeFileSync } from 'fs.js'; +import { dump } from 'js-yaml.js'; +import fetch from 'node-fetch.js'; +import { join } from 'path.js'; +const minVersion = 64; +(() => __awaiter(void 0, void 0, void 0, function* () { + const res = yield fetch('https://nodejs.org/dist/index.json'); + if (!res.ok) { + throw new Error(`${res.status} error from Node.js releases page`); + } + const releases = yield res.json(); + const buildVersion = new Map(); + const versionMap = {}; + for (const release of releases) { + const moduleVersion = Number(release.modules); + if (!moduleVersion || moduleVersion < minVersion) { + break; + } + versionMap[release.version] = Number(moduleVersion); + if (buildVersion.has(moduleVersion)) { + continue; + } + buildVersion.set(moduleVersion, release.version); + } + const buildYaml = { + name: 'Generate Binaries', + on: { + push: { + branches: ['generate-binary'], + }, + }, + jobs: { + build: { + name: 'Build', + 'runs-on': '${{ matrix.os }}', + strategy: { + matrix: { os: ['macos-latest', 'ubuntu-latest', 'windows-latest'] }, + }, + steps: [ + { uses: 'actions/checkout@master' }, + { run: 'mkdir dist' }, + { + uses: 'actions-rs/toolchain@v1', + with: { target: 'wasm32-unknown-unknown', toolchain: 'nightly' }, + }, + ...[...buildVersion.entries()] + .map(([moduleVersion, nodeVersion], i) => [ + { uses: 'actions/setup-node@v1', with: { 'node-version': nodeVersion } }, + { + // See: https://github.com/actions/setup-node/issues/68 + shell: 'powershell', + name: 'patch node-gyp for VS 2019', + run: 'npm install --global node-gyp@latest\r\nnpm prefix -g | % {npm config set node_gyp "$_\\node_modules\\node-gyp\\bin\\node-gyp.js"}', + if: "matrix.os == 'windows-latest'", + }, + i === 0 + ? { run: 'npm install neon-cli rimraf' } + : { run: './node_modules/.bin/rimraf rs/native/target' }, + { run: '../node_modules/.bin/neon build --release', 'working-directory': 'rs' }, + { run: `mv rs/native/index.node dist/\${{ matrix.os }}-${moduleVersion}.node` }, + ]) + .reduce((acc, v) => [...acc, ...v], []), + { + uses: 'actions/upload-artifact@v1', + with: { name: 'dist', path: 'dist' }, + }, + ], + }, + }, + }; + writeFileSync(join(__dirname, '..', '..', '.github', 'workflows', 'build-neon.yml'), dump(buildYaml)); + writeFileSync(join(__dirname, '..', '..', 'targets.json'), JSON.stringify(versionMap)); +}))(); +//# sourceMappingURL=generate-tasks.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/generate-tasks.js.map b/node_modules/blake3-wasm/esm/build/generate-tasks.js.map new file mode 100644 index 0000000..a7e23b7 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/generate-tasks.js.map @@ -0,0 +1 @@ +{"version":3,"file":"generate-tasks.js","sourceRoot":"","sources":["../../ts/build/generate-tasks.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,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AAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AACzF,CAAC,CAAA,CAAC,EAAE,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/install.d.ts b/node_modules/blake3-wasm/esm/build/install.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/install.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/build/install.js b/node_modules/blake3-wasm/esm/build/install.js new file mode 100644 index 0000000..2110284 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/install.js @@ -0,0 +1,98 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { createWriteStream, readFileSync, writeFileSync } from 'fs.js'; +import { get } from 'https.js'; +import { join } from 'path.js'; +import { pipeline } from 'stream.js'; +import { compareVersion, parseVersion } from './versions.js'; +/** + * Post-install script. Downloads the binary for the current Node.js version + * from the Gitub releases page, if it's available. + */ +const builtPlatforms = { + win32: 'windows-latest', + linux: 'ubuntu-latest', + darwin: 'macos-latest', +}; +const { version } = require('../../package.json'); +const repoUrl = process.env.BLAKE3_REPO_URL || 'https://github.com/connor4312/blake3'; +const targets = require('../../targets.json'); +const bindingPath = join(__dirname, '..', 'native.node'); +function install() { + return __awaiter(this, void 0, void 0, function* () { + const current = parseVersion(process.version); + const api = getBestAbiVersion(current); + if (!api) { + console.error('Your Node.js release is out of LTS and BLAKE3 bindings are not built for it. Update it to use native BLAKE3 bindings.'); + return fallback(); + } + const platform = builtPlatforms[process.platform]; + if (!platform) { + console.error(`BLAKE3 bindings are not built for your platform (${process.platform})`); + return fallback(); + } + console.log(`Retrieving native BLAKE3 bindings for Node ${api.nodeVersion} on ${process.platform}...`); + yield download(`${repoUrl}/releases/download/v${version}/${platform}-${api.abiVersion}.node`); + try { + require(bindingPath); + } + catch (e) { + console.log(`Error trying to import bindings: ${e.message}`); + return fallback(); + } + useNativeImport(); + console.log('BLAKE3 bindings retrieved'); + }); +} +function getBestAbiVersion(current) { + for (const targetVersion of Object.keys(targets)) { + const parsed = parseVersion(targetVersion); + if (compareVersion(current, parsed) >= 0) { + return { nodeVersion: targetVersion, abiVersion: targets[targetVersion] }; + } + } + return undefined; +} +function fallback() { + console.error('BLAKE3 will use slower WebAssembly bindings when required in Node.js'); +} +function download(url) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise(resolve => { + const onError = (err) => { + console.error(`Could not download binding from ${url}: ${err.stack || err.message}`); + resolve(false); + }; + const req = get(url, res => { + if (res.headers.location) { + resolve(download(res.headers.location)); + return; + } + if (!res.statusCode || res.statusCode >= 300) { + console.error(`Unexpected ${res.statusCode} from ${url}`); + resolve(false); + return; + } + pipeline(res, createWriteStream(bindingPath), err => (err ? onError(err) : resolve(true))); + }); + req.on('error', onError); + }); + }); +} +function useNativeImport() { + const indexFile = join(__dirname, '..', 'index.js'); + const contents = readFileSync(indexFile, 'utf-8'); + writeFileSync(indexFile, contents.replace('"./node"', '"./node-native"')); +} +install().catch(err => { + console.error(`There was an uncaught error installing native bindings: ${err.stack}`); + fallback(); +}); +//# sourceMappingURL=install.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/install.js.map b/node_modules/blake3-wasm/esm/build/install.js.map new file mode 100644 index 0000000..ebdb3b2 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/install.js.map @@ -0,0 +1 @@ +{"version":3,"file":"install.js","sourceRoot":"","sources":["../../ts/build/install.ts"],"names":[],"mappings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ts new file mode 100644 index 0000000..17d9841 --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/versions.d.ts @@ -0,0 +1,14 @@ +export declare const minNodeVersion = 10; +/** + * @hidden + */ +export interface IVersion { + major: number; + minor: number; + patch: number; +} +/** + * @hidden + */ +export declare const parseVersion: (version: string) => IVersion; +export declare const compareVersion: (a: IVersion, b: IVersion) => number; diff --git a/node_modules/blake3-wasm/esm/build/versions.js b/node_modules/blake3-wasm/esm/build/versions.js new file mode 100644 index 0000000..be5ab4b --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/versions.js @@ -0,0 +1,10 @@ +export const minNodeVersion = 10; +/** + * @hidden + */ +export const parseVersion = (version) => { + const [, major, minor, patch] = /^v([0-9]+)\.([0-9]+)\.([0-9]+)/.exec(version) || []; + return { major: Number(major), minor: Number(minor), patch: Number(patch) }; +}; +export const compareVersion = (a, b) => a.major - b.major || a.minor - b.minor || a.patch - b.patch; +//# sourceMappingURL=versions.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/build/versions.js.map b/node_modules/blake3-wasm/esm/build/versions.js.map new file mode 100644 index 0000000..fef0d7e --- /dev/null +++ b/node_modules/blake3-wasm/esm/build/versions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../ts/build/versions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAWjC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAY,EAAE;IACxD,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,gCAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACrF,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC9E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAW,EAAE,CAAW,EAAE,EAAE,CACzD,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/index.d.ts b/node_modules/blake3-wasm/esm/index.d.ts new file mode 100644 index 0000000..d0dddb6 --- /dev/null +++ b/node_modules/blake3-wasm/esm/index.d.ts @@ -0,0 +1 @@ +export * from './node'; diff --git a/node_modules/blake3-wasm/esm/index.js b/node_modules/blake3-wasm/esm/index.js new file mode 100644 index 0000000..8d88eda --- /dev/null +++ b/node_modules/blake3-wasm/esm/index.js @@ -0,0 +1,14 @@ +// Bunlers add the `process.browser` flag to indicate the build enviroment. +// Throw a verbose error if we see people bundling the Node.js build in their +// browser, since it probably won't work for them (or at least not give them) +// nice tree shaking and such. +// +// Note that we don't check the presence of window/document, since those can +// be emulated in common test scenarios (e.g. jest's default setup with jsdom). +if (process.browser) { + throw new Error('You tried to import the Node.js version of blake3, instead of the browser ' + + 'version, in your build. You can fix this by importing "blake3/browser" ' + + 'instead of "blake3"'); +} +export * from './node.js'; +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/index.js.map b/node_modules/blake3-wasm/esm/index.js.map new file mode 100644 index 0000000..d44991f --- /dev/null +++ b/node_modules/blake3-wasm/esm/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,8BAA8B;AAC9B,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E,IAAK,OAAe,CAAC,OAAO,EAAE;IAC5B,MAAM,IAAI,KAAK,CACb,4EAA4E;QAC1E,yEAAyE;QACzE,qBAAqB,CACxB,CAAC;CACH;AAED,cAAc,QAAQ,CAAC"}
\ No newline at end of file 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 diff --git a/node_modules/blake3-wasm/esm/node.test.d.ts b/node_modules/blake3-wasm/esm/node.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/blake3-wasm/esm/node.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/blake3-wasm/esm/node.test.js b/node_modules/blake3-wasm/esm/node.test.js new file mode 100644 index 0000000..4523c31 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node.test.js @@ -0,0 +1,198 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import * as wasm from './node.js'; +import * as native from './node-native.js'; +import { expect } from 'chai.js'; +import { inputs, hello48, ogTestVectors } from './base/test-helpers.js'; +import { ReadableStreamBuffer } from 'stream-buffers.js'; +import { maxHashBytes } from './base/hash-reader.js'; +function suite({ hash, createHash, keyedHash, deriveKey, createDeriveKey, createKeyed, }) { + describe('encoding', () => { + it('hashes a buffer', () => { + expect(hash(Buffer.from(inputs.hello.input))).to.deep.equal(inputs.hello.hash); + }); + it('hashes a string', () => { + expect(hash(inputs.hello.input)).to.deep.equal(inputs.hello.hash); + }); + it('hashes an arraybuffer', () => { + const buf = Buffer.from(inputs.hello.input); + expect(hash(new Uint8Array(buf).buffer)).to.deep.equal(inputs.hello.hash); + }); + it('customizes the output length', () => { + expect(hash(inputs.hello.input, { length: 16 })).to.deep.equal(inputs.hello.hash.slice(0, 16)); + }); + }); + describe('memory-safety (#5)', () => { + it('hash', () => { + const hashA = hash('hello'); + const hashB = hash('goodbye'); + expect(hashA.toString('hex')).to.equal('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f'); + expect(hashB.toString('hex')).to.equal('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69'); + }); + it('hasher', () => { + const hasherA = createHash(); + const hasherB = createHash(); + hasherA.update('hel'); + hasherB.update('good'); + hasherA.update('lo'); + hasherB.update('bye'); + const hashA = hasherA.digest(); + const hashB = hasherB.digest(); + expect(hashA.toString('hex')).to.equal('ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f'); + expect(hashB.toString('hex')).to.equal('f94a694227c5f31a07551908ad5fb252f5f0964030df5f2f200adedfae4d9b69'); + }); + }); + describe('hasher', () => { + it('digests', callback => { + const buffer = new ReadableStreamBuffer(); + buffer.put(Buffer.from(inputs.large.input)); + buffer.stop(); + const hash = createHash(); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest(); + expect(actual).to.deep.equal(inputs.large.hash); + callback(); + }); + }); + it('is a transform stream', callback => { + const buffer = new ReadableStreamBuffer(); + buffer.put(Buffer.from(inputs.large.input)); + buffer.stop(); + buffer + .pipe(createHash()) + .on('error', callback) + .on('data', hash => { + expect(hash).to.deep.equal(inputs.large.hash); + callback(); + }); + }); + it('customizes the output length', () => { + const hash = createHash(); + hash.update(inputs.hello.input); + expect(hash.digest('hex', { length: 16 })).to.equal(inputs.hello.hash.slice(0, 16).toString('hex')); + }); + it('throws on write after dispose', () => { + const hash = createHash(); + hash.dispose(); + expect(() => hash.update('')).to.throw(/after dispose/); + }); + it('allows taking incremental hashes', () => { + const hasher = createHash(); + hasher.update('hel'); + const hashA = hasher.digest(undefined, { dispose: false }); + const readA = hasher.reader({ dispose: false }); + hasher.update('lo'); + const hashB = hasher.digest(undefined, { dispose: false }); + const readB = hasher.reader({ dispose: false }); + const expectedA = Buffer.from('3121c5bb1b9193123447ac7cfda042f67f967e7a8cf5c12e7570e25529746e4a', 'hex'); + expect(hashA).to.deep.equal(expectedA); + expect(readA.toBuffer()).to.deep.equal(expectedA); + expect(hashB).to.deep.equal(inputs.hello.hash); + expect(readB.toBuffer()).to.deep.equal(inputs.hello.hash); + hasher.dispose(); + readA.dispose(); + readB.dispose(); + }); + }); + describe('reader', () => { + let reader; + beforeEach(() => { + const hash = createHash(); + hash.update(inputs.hello.input); + reader = hash.reader(); + }); + afterEach(() => reader.dispose()); + it('implements toString()', () => { + expect(reader.toString('hex')).to.equal(inputs.hello.hash.toString('hex')); + reader.position = BigInt(42); + expect(reader.toString('hex')).to.equal(inputs.hello.hash.toString('hex')); + }); + it('implements toBuffer()', () => { + expect(reader.toBuffer()).to.deep.equal(inputs.hello.hash); + reader.position = BigInt(42); + expect(reader.toBuffer()).to.deep.equal(inputs.hello.hash); + }); + it('implements readInto() and advances', () => { + const actual = Buffer.alloc(32); + reader.readInto(actual.slice(0, 10)); + reader.readInto(actual.slice(10)); + expect(actual).to.deep.equal(inputs.hello.hash); + expect(reader.position).to.equal(BigInt(32)); + }); + it('implements read() and advances', () => { + const actual = reader.read(32); + expect(actual).to.deep.equal(inputs.hello.hash); + expect(reader.position).to.equal(BigInt(32)); + const actualNext = reader.read(16); + expect(actualNext).to.deep.equal(hello48.slice(32)); + expect(reader.position).to.equal(BigInt(48)); + }); + it('manually sets position', () => { + reader.position = BigInt(32); + const actual = reader.read(16); + expect(actual).to.deep.equal(hello48.slice(32)); + }); + it('throws if set out of range', () => { + expect(() => (reader.position = BigInt(-1))).to.throw(RangeError); + expect(() => (reader.position = BigInt('18446744073709551616'))).to.throw(RangeError); + reader.position = maxHashBytes - BigInt(1); + expect(() => reader.read(2)).to.throw(RangeError); + }); + }); + describe('original test vectors', () => { + for (const { inputLen, expectedDerive, expectedKeyed, expectedHash } of ogTestVectors.cases) { + describe(`${inputLen}`, () => __awaiter(this, void 0, void 0, function* () { + const input = Buffer.alloc(inputLen); + for (let i = 0; i < inputLen; i++) { + input[i] = i % 251; + } + it('hash()', () => { + expect(hash(input, { length: expectedHash.length / 2 }).toString('hex')).to.equal(expectedHash); + }); + it('deriveKey()', () => { + expect(deriveKey(ogTestVectors.context, input, { length: expectedDerive.length / 2 }).toString('hex')).to.equal(expectedDerive); + }); + it('createDeriveKey()', callback => { + const buffer = new ReadableStreamBuffer(); + buffer.put(Buffer.from(input)); + buffer.stop(); + const hash = createDeriveKey(ogTestVectors.context); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest({ length: expectedDerive.length / 2 }).toString('hex'); + expect(actual).to.equal(expectedDerive); + callback(); + }); + }); + it('keyedHash()', () => { + expect(keyedHash(Buffer.from(ogTestVectors.key), input, { + length: expectedKeyed.length / 2, + }).toString('hex')).to.equal(expectedKeyed); + }); + it('createKeyed()', callback => { + const buffer = new ReadableStreamBuffer(); + buffer.put(Buffer.from(input)); + buffer.stop(); + const hash = createKeyed(Buffer.from(ogTestVectors.key)); + buffer.on('data', b => hash.update(b)); + buffer.on('end', () => { + const actual = hash.digest({ length: expectedDerive.length / 2 }).toString('hex'); + expect(actual).to.equal(expectedKeyed); + callback(); + }); + }); + })); + } + }); +} +describe('node.js wasm', () => suite(wasm)); +describe('node.js native', () => suite(native)); +//# sourceMappingURL=node.test.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node.test.js.map b/node_modules/blake3-wasm/esm/node.test.js.map new file mode 100644 index 0000000..836aa6b --- /dev/null +++ b/node_modules/blake3-wasm/esm/node.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"node.test.js","sourceRoot":"","sources":["../ts/node.test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC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modules/blake3-wasm/esm/node/hash-fn.d.ts b/node_modules/blake3-wasm/esm/node/hash-fn.d.ts new file mode 100644 index 0000000..33d7927 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-fn.d.ts @@ -0,0 +1,24 @@ +/// <reference types="node" /> +import { BaseHashInput, IBaseHashOptions } from '../base/hash-fn'; +/** + * Input used for node-based hashes. + */ +export declare type HashInput = BaseHashInput | string; +/** + * @hidden + */ +export declare const normalizeInput: (input: HashInput, encoding?: "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex" | undefined) => Uint8Array; +/** + * 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/hash-fn.js b/node_modules/blake3-wasm/esm/node/hash-fn.js new file mode 100644 index 0000000..6c47599 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-fn.js @@ -0,0 +1,40 @@ +import { inputToArray, defaultHashLength } from '../base/hash-fn.js'; +import { hash as rawHash, create_derive as createDerive, create_keyed as createKeyed, } from '../../dist/wasm/nodejs/blake3_js.js'; +/** + * @hidden + */ +export const normalizeInput = (input, encoding) => inputToArray(typeof input === 'string' ? Buffer.from(input, encoding) : input); +/** + * Returns a blake3 hash of the input, returning the binary hash data. + */ +export function hash(input, { length = defaultHashLength } = {}) { + const result = Buffer.alloc(length); + rawHash(normalizeInput(input), result); + return result; +} +/** + * 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 derive = createDerive(context); + derive.update(normalizeInput(material)); + const result = Buffer.alloc(length); + derive.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 } = {}) { + if (key.length !== 32) { + throw new Error(`key provided to keyedHash must be 32 bytes, got ${key.length}`); + } + const derive = createKeyed(key); + derive.update(normalizeInput(input)); + const result = Buffer.alloc(length); + derive.digest(result); + return result; +} +//# sourceMappingURL=hash-fn.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-fn.js.map b/node_modules/blake3-wasm/esm/node/hash-fn.js.map new file mode 100644 index 0000000..f8d886e --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-fn.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-fn.js","sourceRoot":"","sources":["../../ts/node/hash-fn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAoB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EACL,IAAI,IAAI,OAAO,EACf,aAAa,IAAI,YAAY,EAC7B,YAAY,IAAI,WAAW,GAC5B,MAAM,kCAAkC,CAAC;AAO1C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAgB,EAAE,QAAyB,EAAc,EAAE,CACxF,YAAY,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAEjF;;GAEG;AACH,MAAM,UAAU,IAAI,CAClB,KAAgB,EAChB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,OAAe,EACf,QAAmB,EACnB,EAAE,MAAM,GAAG,iBAAiB,KAAuB,EAAE;IAErD,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,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,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;KAClF;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAChC,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/hash-instance.d.ts b/node_modules/blake3-wasm/esm/node/hash-instance.d.ts new file mode 100644 index 0000000..3a72c9f --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-instance.d.ts @@ -0,0 +1,75 @@ +/// <reference types="node" /> +import { HashInput } from './hash-fn'; +import { IHasher, IInternalHash, IHasherDigestOptions } from '../base/index'; +import { Transform, TransformCallback } from 'stream'; +import { IBaseHashOptions } from '../base/hash-fn'; +import { NodeHashReader } from './hash-reader'; +export interface INodeHash extends IHasher<Buffer> { + /** + * @inheritdoc + * @override + */ + update(data: HashInput, encoding?: BufferEncoding): this; + /** + * @inheritdoc + * @override + */ + digest(options?: IBaseHashOptions): Buffer; + /** + * Returns a digest of the hash with the given set of hash options. + */ + digest(encoding: undefined, options: IBaseHashOptions): Buffer; + /** + * Returns a digest of the hash with the given encoding. + */ + digest(encoding: BufferEncoding, options?: IBaseHashOptions): string; +} +/** + * @inheritdoc + */ +export declare class NodeHash<Reader> extends Transform implements IHasher<Buffer> { + private readonly hash; + constructor(implementation: IInternalHash<Reader>, getReader: (r: Reader) => NodeHashReader); + /** + * @reader + */ + reader(options?: { + dispose?: boolean; + }): NodeHashReader; + /** + * @inheritdoc + */ + update(data: HashInput, encoding?: BufferEncoding): this; + /** + * @inheritdoc + */ + digest(encoding?: IHasherDigestOptions): Buffer; + digest(encoding: undefined, options: IHasherDigestOptions): Buffer; + digest(encoding: BufferEncoding, options?: IHasherDigestOptions): string; + /** + * @inheritdoc + */ + dispose(): void; + /** + * @inheritdoc + * @hidden + */ + _transform(chunk: Buffer | string, encoding: string, callback: TransformCallback): void; + /** + * @inheritdoc + * @hidden + */ + _flush(callback: TransformCallback): void; +} +/** + * A Node.js crypto-like createHash method. + */ +export declare const createHash: () => NodeHash<import("../../dist/wasm/nodejs/blake3_js").HashReader>; +/** + * Construct a new Hasher for the keyed hash function. + */ +export declare const createKeyed: (key: Buffer) => NodeHash<import("../../dist/wasm/nodejs/blake3_js").HashReader>; +/** + * Construct a new Hasher for the key derivation function. + */ +export declare const createDeriveKey: (context: string) => NodeHash<import("../../dist/wasm/nodejs/blake3_js").HashReader>; diff --git a/node_modules/blake3-wasm/esm/node/hash-instance.js b/node_modules/blake3-wasm/esm/node/hash-instance.js new file mode 100644 index 0000000..4e08d4f --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-instance.js @@ -0,0 +1,76 @@ +import { normalizeInput } from './hash-fn.js'; +import { BaseHash } from '../base/index.js'; +import { Transform } from 'stream.js'; +import { getWasm } from './wasm.js'; +import { NodeHashReader } from './hash-reader.js'; +/** + * @inheritdoc + */ +export class NodeHash extends Transform { + constructor(implementation, getReader) { + super(); + this.hash = new BaseHash(implementation, l => Buffer.alloc(l), getReader); + } + /** + * @reader + */ + reader(options) { + const reader = this.hash.reader(options); + return reader; + } + /** + * @inheritdoc + */ + update(data, encoding) { + this.hash.update(normalizeInput(data, encoding)); + return this; + } + digest(encoding, options) { + let resolvedOpts; + let resolvedEnc; + if (encoding && typeof encoding === 'object') { + resolvedOpts = encoding; + resolvedEnc = undefined; + } + else { + resolvedOpts = options; + resolvedEnc = encoding; + } + const result = this.hash.digest(resolvedOpts); + return resolvedEnc ? result.toString(resolvedEnc) : result; + } + /** + * @inheritdoc + */ + dispose() { + this.hash.dispose(); + } + /** + * @inheritdoc + * @hidden + */ + _transform(chunk, encoding, callback) { + this.update(chunk, encoding); + callback(); + } + /** + * @inheritdoc + * @hidden + */ + _flush(callback) { + callback(null, this.digest()); + } +} +/** + * A Node.js crypto-like createHash method. + */ +export const createHash = () => new NodeHash(getWasm().create_hasher(), r => new NodeHashReader(r)); +/** + * Construct a new Hasher for the keyed hash function. + */ +export const createKeyed = (key) => new NodeHash(getWasm().create_keyed(key), r => new NodeHashReader(r)); +/** + * Construct a new Hasher for the key derivation function. + */ +export const createDeriveKey = (context) => new NodeHash(getWasm().create_derive(context), r => new NodeHashReader(r)); +//# sourceMappingURL=hash-instance.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-instance.js.map b/node_modules/blake3-wasm/esm/node/hash-instance.js.map new file mode 100644 index 0000000..a5679a8 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-instance.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-instance.js","sourceRoot":"","sources":["../../ts/node/hash-instance.ts"],"names":[],"mappings":"A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CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC7D,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,KAAsB,EAAE,QAAgB,EAAE,QAA2B;QAC9E,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,QAA0B,CAAC,CAAC;QAC/C,QAAQ,EAAE,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAA2B;QAChC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAChC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CACzC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAe,EAAE,EAAE,CACjD,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-reader.d.ts b/node_modules/blake3-wasm/esm/node/hash-reader.d.ts new file mode 100644 index 0000000..f217f7d --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-reader.d.ts @@ -0,0 +1,16 @@ +/// <reference types="node" /> +import { BaseHashReader } from '../base/hash-reader'; +/** + * A hash reader for WebAssembly targets. + */ +export declare class NodeHashReader extends BaseHashReader<Buffer> { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding?: BufferEncoding): string; + /** + * Converts first 32 bytes of the hash to an array. + */ + toBuffer(): Buffer; + protected alloc(bytes: number): Buffer; +} diff --git a/node_modules/blake3-wasm/esm/node/hash-reader.js b/node_modules/blake3-wasm/esm/node/hash-reader.js new file mode 100644 index 0000000..fdb6d97 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-reader.js @@ -0,0 +1,24 @@ +import { BaseHashReader } from '../base/hash-reader.js'; +import { defaultHashLength } from '../base/hash-fn.js'; +/** + * A hash reader for WebAssembly targets. + */ +export class NodeHashReader extends BaseHashReader { + /** + * Converts first 32 bytes of the hash to a string with the given encoding. + */ + toString(encoding = 'hex') { + return this.toBuffer().toString(encoding); + } + /** + * Converts first 32 bytes of the hash to an array. + */ + toBuffer() { + this.position = BigInt(0); + return this.read(defaultHashLength); + } + alloc(bytes) { + return Buffer.alloc(bytes); + } +} +//# sourceMappingURL=hash-reader.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/hash-reader.js.map b/node_modules/blake3-wasm/esm/node/hash-reader.js.map new file mode 100644 index 0000000..d84088d --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/hash-reader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash-reader.js","sourceRoot":"","sources":["../../ts/node/hash-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,cAAsB;IACxD;;OAEG;IACI,QAAQ,CAAC,WAA2B,KAAK;QAC9C,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,KAAa;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/index.d.ts b/node_modules/blake3-wasm/esm/node/index.d.ts new file mode 100644 index 0000000..7cd09cc --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/index.d.ts @@ -0,0 +1,4 @@ +export { hash, deriveKey, keyedHash, HashInput } from './hash-fn'; +export * from './hash-instance'; +export * from './hash-reader'; +export * from '../base/index'; diff --git a/node_modules/blake3-wasm/esm/node/index.js b/node_modules/blake3-wasm/esm/node/index.js new file mode 100644 index 0000000..86df783 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/index.js @@ -0,0 +1,5 @@ +export { hash, deriveKey, keyedHash } from './hash-fn.js'; +export * from './hash-instance.js'; +export * from './hash-reader.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/index.js.map b/node_modules/blake3-wasm/esm/node/index.js.map new file mode 100644 index 0000000..22c4bc7 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAa,MAAM,WAAW,CAAC;AAClE,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/wasm.d.ts b/node_modules/blake3-wasm/esm/node/wasm.d.ts new file mode 100644 index 0000000..41e73fd --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/wasm.d.ts @@ -0,0 +1,6 @@ +import * as wasm from '../../dist/wasm/nodejs/blake3_js'; +/** + * Lazyily get the WebAssembly module. Used to avoid unnecessarily importing + * the wasm when extending the WebAssembly node code for native bindings. + */ +export declare const getWasm: () => typeof wasm; diff --git a/node_modules/blake3-wasm/esm/node/wasm.js b/node_modules/blake3-wasm/esm/node/wasm.js new file mode 100644 index 0000000..026a374 --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/wasm.js @@ -0,0 +1,12 @@ +let w; +/** + * Lazyily get the WebAssembly module. Used to avoid unnecessarily importing + * the wasm when extending the WebAssembly node code for native bindings. + */ +export const getWasm = () => { + if (!w) { + w = require('../../dist/wasm/nodejs/blake3_js'); + } + return w; +}; +//# sourceMappingURL=wasm.js.map
\ No newline at end of file diff --git a/node_modules/blake3-wasm/esm/node/wasm.js.map b/node_modules/blake3-wasm/esm/node/wasm.js.map new file mode 100644 index 0000000..5249d6c --- /dev/null +++ b/node_modules/blake3-wasm/esm/node/wasm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../ts/node/wasm.ts"],"names":[],"mappings":"AAEA,IAAI,CAA0B,CAAC;AAE/B;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,CAAC,GAAG,OAAO,CAAC,kCAAkC,CAAgB,CAAC;KAChE;IAED,OAAO,CAAC,CAAC;AACX,CAAC,CAAC"}
\ No newline at end of file diff --git a/node_modules/blake3-wasm/package.json b/node_modules/blake3-wasm/package.json new file mode 100644 index 0000000..eeeb80f --- /dev/null +++ b/node_modules/blake3-wasm/package.json @@ -0,0 +1,63 @@ +{ + "name": "blake3-wasm", + "version": "2.1.5", + "description": "BLAKE3 hashing for JavaScript: native Node bindings (where available) and WebAssembly", + "keywords": [ + "blake3", + "node-addon", + "hash", + "webassembly", + "wasm" + ], + "module": "./esm/index", + "browser": "./esm/browser/index", + "main": "./dist/index", + "scripts": { + "prepack": "make clean && make MODE=release && npm test && rimraf dist/native.node", + "test": "mocha --require source-map-support/register --recursive \"dist/**/*.test.js\" --timeout 5000", + "fmt": "make fmt", + "compile": "tsc && tsc -p tsconfig.esm.json && node dist/build/add-js-extensions", + "watch": "tsc --watch" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/connor4312/blake3.git" + }, + "bugs": { + "url": "https://github.com/connor4312/blake3/issues" + }, + "homepage": "https://github.com/connor4312/blake3#readme", + "author": "Connor Peet <connor@peet.io>", + "license": "MIT", + "devDependencies": { + "@types/chai": "^4.2.7", + "@types/js-yaml": "^3.12.1", + "@types/mocha": "^5.2.7", + "@types/node": "^13.1.6", + "@types/node-fetch": "^2.5.4", + "@types/puppeteer": "^2.0.0", + "@types/serve-handler": "^6.1.0", + "@types/stream-buffers": "^3.0.3", + "@types/webpack": "^4.41.2", + "chai": "^4.2.0", + "js-yaml": "^3.13.1", + "mocha": "^7.0.0", + "neon-cli": "^0.3.3", + "node-fetch": "^2.6.0", + "prettier": "^1.19.1", + "puppeteer": "^2.0.0", + "remark-cli": "^7.0.1", + "remark-toc": "^6.0.0", + "rimraf": "^3.0.0", + "serve-handler": "^6.1.2", + "source-map-support": "^0.5.16", + "stream-buffers": "^3.0.2", + "typescript": "^3.8.0-beta", + "webpack": "^4.41.5" + }, + "prettier": { + "printWidth": 100, + "singleQuote": true, + "trailingComma": "all" + } +} diff --git a/node_modules/blake3-wasm/readme.md b/node_modules/blake3-wasm/readme.md new file mode 100644 index 0000000..5ce9c73 --- /dev/null +++ b/node_modules/blake3-wasm/readme.md @@ -0,0 +1,406 @@ +# BLAKE3 + +[BLAKE3](https://github.com/BLAKE3-team/BLAKE3) running in JavaScript (node.js and browsers) via native bindings, where available, or WebAssembly. + + npm install blake3 + +Additionally, there's a flavor of the package which is identical except that it will not download native Node.js bindings: + + npm install blake3-wasm + +## Table of Contents + +- [Quickstart](#quickstart) +- [API](#api) + - [Node.js](#nodejs) + - [`hash(data: BinaryLike, options?: { length: number }): Buffer`](#hashdata-binarylike-options--length-number--buffer) + - [`keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Buffer`](#keyedhashkey-buffer-data-binarylike-options--length-number--buffer) + - [`deriveKey(context: string, material: BinaryLike, options?: { length: number }): Buffer`](#derivekeycontext-string-material-binarylike-options--length-number--buffer) + - [Hasher](#hasher) + - [`createHash(): Hasher`](#createhash-hasher) + - [`createKeyed(key: Buffer): Hasher`](#createkeyedkey-buffer-hasher) + - [`createDeriveKey(context: string): Hasher`](#createderivekeycontext-string-hasher) + - [`hasher.update(data: BinaryLike): this`](#hasherupdatedata-binarylike-this) + - [`hasher.digest(encoding?: string, options?: { length: number, dispose: boolean })): Buffer | string`](#hasherdigestencoding-string-options--length-number-dispose-boolean--buffer--string) + - [`hasher.reader(options?: { dispose: boolean }): HashReader`](#hasherreaderoptions--dispose-boolean--hashreader) + - [`hasher.dispose()`](#hasherdispose) + - [HashReader](#hashreader) + - [`reader.position: bigint`](#readerposition-bigint) + - [`reader.readInto(target: Buffer): void`](#readerreadintotarget-buffer-void) + - [`reader.read(bytes: number): Buffer`](#readerreadbytes-number-buffer) + - [`reader.toString([encoding]): string`](#readertostringencoding-string) + - [`reader.toBuffer(): Buffer`](#readertobuffer-buffer) + - [`reader.dispose()`](#readerdispose) + - [`using(disposable: IDisposable, fn: disposable => T): T`](#usingdisposable-idisposable-fn-disposable--t-t) + - [Browser](#browser) + - [`hash(data: BinaryLike, options?: { length: number }): Hash`](#hashdata-binarylike-options--length-number--hash) + - [`keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Hash`](#keyedhashkey-buffer-data-binarylike-options--length-number--hash) + - [`deriveKey(context: string, material: BinaryLike, options?: { length: number }): Hash`](#derivekeycontext-string-material-binarylike-options--length-number--hash) + - [`Hash`](#hash) + - [`hash.equals(other: Uint8Array)`](#hashequalsother-uint8array) + - [`hash.toString(encoding: 'hex' | 'base64' | 'utf8'): string`](#hashtostringencoding-hex--base64--utf8-string) + - [Hasher](#hasher-1) + - [`createHash(): Hasher`](#createhash-hasher-1) + - [`createKeyed(key: Buffer): Hasher`](#createkeyedkey-buffer-hasher-1) + - [`createDeriveKey(context: string): Hasher`](#createderivekeycontext-string-hasher-1) + - [`hasher.update(data: BinaryLike): this`](#hasherupdatedata-binarylike-this-1) + - [`hasher.digest(encoding?: 'hex' | 'base64' | 'utf8', options?: { length: number, dispose: boolean })): Hash | string`](#hasherdigestencoding-hex--base64--utf8-options--length-number-dispose-boolean--hash--string) + - [`hasher.reader(options?: { dispose: boolean }): HashReader`](#hasherreaderoptions--dispose-boolean--hashreader-1) + - [`hasher.dispose()`](#hasherdispose-1) + - [HashReader](#hashreader-1) + - [`reader.position: bigint`](#readerposition-bigint-1) + - [`reader.readInto(target: Uint8Array): void`](#readerreadintotarget-uint8array-void) + - [`reader.read(bytes: number): Hash`](#readerreadbytes-number-hash) + - [`reader.toString(encoding?: string): string`](#readertostringencoding-string-string) + - [`reader.toArray(): Uint8Array`](#readertoarray-uint8array) + - [`reader.dispose()`](#readerdispose-1) + - [`using(disposable: IDisposable, fn: disposable => T): T`](#usingdisposable-idisposable-fn-disposable--t-t-1) +- [Speed](#speed) +- [Contributing](#contributing) + - [Publishing](#publishing) + +## Quickstart + +If you're on Node, import the module via + +```js +const blake3 = require('blake3'); + +blake3.hash('foo'); // => Buffer +``` + +If you're in the browser, import `blake3/browser`. This includes a WebAssembly binary, so you probably want to import it asynchronously, like so: + +```js +import('blake3/browser').then(blake3 => { + blake3.hash('foo'); // => Uint8Array +}); +``` + +The API is very similar in Node.js and browsers, but Node supports and returns Buffers and a wider range of input and output encoding. + +More complete example: + +```js +const { hash, createHash } = require('blake3'); + +hash('some string'); // => hash a string to a uint8array + +// Update incrementally (Node and Browsers): +const hash = createHash(); +stream.on('data', d => hash.update(d)); +stream.on('error', err => { + // hashes use unmanaged memory in WebAssembly, always free them if you don't digest()! + hash.dispose(); + throw err; +}); +stream.on('end', () => finishedHash(hash.digest())); + +// Or, in Node, it's also a transform stream: +createReadStream('file.txt') + .pipe(createHash()) + .on('data', hash => console.log(hash.toString('hex'))); +``` + +## API + +### Node.js + +The Node API can be imported via `require('blake3')`. + +#### `hash(data: BinaryLike, options?: { length: number }): Buffer` + +Returns a hash for the given data. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer. + +#### `keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Buffer` + +Returns keyed a hash for the given data. The key must be exactly 32 bytes. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer. + +For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html). + +#### `deriveKey(context: string, material: BinaryLike, options?: { length: number }): Buffer` + +The key derivation function. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer. + +For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html). + +#### Hasher + +The hasher is a type that lets you incrementally build a hash. It's compatible with Node's crypto hash instance. For instance, it implements a transform stream, so you could do something like: + +```js +createReadStream('file.txt') + .pipe(createHash()) + .on('data', hash => console.log(hash.toString('hex'))); +``` + +##### `createHash(): Hasher` + +Creates a new hasher instance using the standard hash function. + +##### `createKeyed(key: Buffer): Hasher` + +Creates a new hasher instance for a keyed hash. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html). + +##### `createDeriveKey(context: string): Hasher` + +Creates a new hasher instance for the key derivation function. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html). + +##### `hasher.update(data: BinaryLike): this` + +Adds data to a hash. The data can be a string, buffer, typedarray, array buffer, or array. This will throw if called after `digest()` or `dispose()`. + +##### `hasher.digest(encoding?: string, options?: { length: number, dispose: boolean })): Buffer | string` + +Returns the hash of the data. If an `encoding` is given, a string will be returned. Otherwise, a Buffer is returned. Optionally, you can specify the requested byte length of the hash. + +If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader. + +##### `hasher.reader(options?: { dispose: boolean }): HashReader` + +Returns a [HashReader](#HashReader) for the current hash. + +If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader. + +##### `hasher.dispose()` + +Disposes of unmanaged resources. You should _always_ call this if you don't call `digest()` to free umanaged (WebAssembly-based) memory. + +#### HashReader + +The hash reader can be returned from hashing functions. Up to 2<sup>64</sup>-1 bytes of data can be read from BLAKE3 hashes; this structure lets you read those. Note that, like `hash`, this is an object which needs to be manually disposed of. + +##### `reader.position: bigint` + +A property which gets or sets the position of the reader in the output stream. A `RangeError` is thrown if setting this to a value less than 0 or greater than 2<sup>64</sup>-1. Note that this is a bigint, not a standard number. + +```js +reader.position += 32n; // advance the reader 32 bytes +``` + +##### `reader.readInto(target: Buffer): void` + +Reads bytes into the target array, filling it up and advancing the reader's position. A `RangeError` is thrown if reading this data puts the reader past 2<sup>64</sup>-1 bytes. + +##### `reader.read(bytes: number): Buffer` + +Reads and returns the given number of bytes from the reader, and advances the position. A `RangeError` is thrown if reading this data puts the reader past 2<sup>64</sup>-1 bytes. + +##### `reader.toString([encoding]): string` + +Converts first 32 bytes of the hash to a string with the given encoding. Defaults to hex encoding. + +##### `reader.toBuffer(): Buffer` + +Converts first 32 bytes of the hash to a Buffer. + +##### `reader.dispose()` + +Disposes of unmanaged resources. You should _always_ call this to free umanaged (WebAssembly-based) memory, or you application will leak memory. + +#### `using(disposable: IDisposable, fn: disposable => T): T` + +A helper method that takes a disposable, and automatically calls the dispose method when the function returns, or the promise returned from the function is settled. + +```js +// read and auto-dispose the first 64 bytes +const first64Bytes = using(hash.reader(), reader => reader.toBuffer(64)); + +// you can also return promises/use async methods: +using(hash.reader(), async reader => { + do { + await send(reader.read(64)); + } while (needsMoreData()); +}); +``` + +### Browser + +The browser API can be imported via `import('blake3/browser')`, which works well with Webpack. + +If you aren't using a bundler or using a more "pure" bundler like Parcel, you can import `blake3/browser-async` which exports a function to asynchronously load the WebAssembly code and resolves to the package contents. + +```js +import load from 'blake3/browser-async'; + +load().then(blake3 => { + console.log(blake3.hash('hello world')); +}); +``` + +#### `hash(data: BinaryLike, options?: { length: number }): Hash` + +Returns a hash for the given data. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance. + +#### `keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Hash` + +Returns keyed a hash for the given data. The key must be exactly 32 bytes. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance. + +For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html). + +#### `deriveKey(context: string, material: BinaryLike, options?: { length: number }): Hash` + +The key derivation function. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance. + +For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html). + +#### `Hash` + +A Hash is the type returned from hash functions and the hasher in the browser. It's a `Uint8Array` with a few additional helper methods. + +##### `hash.equals(other: Uint8Array)` + +Returns whether this hash equals the other hash, via a constant-time equality check. + +##### `hash.toString(encoding: 'hex' | 'base64' | 'utf8'): string` + +#### Hasher + +The hasher is a type that lets you incrementally build a hash. For instance, you can hash a `fetch`ed page like: + +```js +const res = await fetch('https://example.com'); +const body = await res.body; + +const hasher = blake3.createHash(); +const reader = body.getReader(); + +while (true) { + const { done, value } = await reader.read(); + if (done) { + break; + } + + hasher.update(value); +} + +console.log('Hash of', res.url, 'is', hasher.digest('hex')); +``` + +Converts the hash to a string with the given encoding. + +##### `createHash(): Hasher` + +Creates a new hasher instance using the standard hash function. + +##### `createKeyed(key: Buffer): Hasher` + +Creates a new hasher instance for a keyed hash. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html). + +##### `createDeriveKey(context: string): Hasher` + +Creates a new hasher instance for the key derivation function. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html). + +##### `hasher.update(data: BinaryLike): this` + +Adds data to a hash. The data can be a string, buffer, typedarray, array buffer, or array. This will throw if called after `digest()` or `dispose()`. + +##### `hasher.digest(encoding?: 'hex' | 'base64' | 'utf8', options?: { length: number, dispose: boolean })): Hash | string` + +Returns the hash of the data. If an `encoding` is given, a string will be returned. Otherwise, a [Hash](#hash) is returned. Optionally, you can specify the requested byte length of the hash. + +If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader. + +##### `hasher.reader(options?: { dispose: boolean }): HashReader` + +Returns a [HashReader](#HashReader) for the current hash. + +If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader. + +##### `hasher.dispose()` + +Disposes of unmanaged resources. You should _always_ call this if you don't call `digest()` to free umanaged (WebAssembly-based) memory. + +#### HashReader + +The hash reader can be returned from hashing functions. Up to 2<sup>64</sup>-1 bytes of data can be read from BLAKE3 hashes; this structure lets you read those. Note that, like `hash`, this is an object which needs to be manually disposed of. + +##### `reader.position: bigint` + +A property which gets or sets the position of the reader in the output stream. A `RangeError` is thrown if setting this to a value less than 0 or greater than 2<sup>64</sup>-1. Note that this is a bigint, not a standard number. + +```js +reader.position += 32n; // advance the reader 32 bytes +``` + +##### `reader.readInto(target: Uint8Array): void` + +Reads bytes into the target array, filling it up and advancing the reader's position. A `RangeError` is thrown if reading this data puts the reader past 2<sup>64</sup>-1 bytes. + +##### `reader.read(bytes: number): Hash` + +Reads and returns the given number of bytes from the reader, and advances the position. A `RangeError` is thrown if reading this data puts the reader past 2<sup>64</sup>-1 bytes. + +##### `reader.toString(encoding?: string): string` + +Converts first 32 bytes of the hash to a string with the given encoding. Defaults to hex encoding. + +##### `reader.toArray(): Uint8Array` + +Converts first 32 bytes of the hash to an array. + +##### `reader.dispose()` + +Disposes of unmanaged resources. You should _always_ call this to free umanaged (WebAssembly-based) memory, or you application will leak memory. + +#### `using(disposable: IDisposable, fn: disposable => T): T` + +A helper method that takes a disposable, and automatically calls the dispose method when the function returns, or the promise returned from the function is settled. + +```js +// read and auto-dispose the first 64 bytes +const first64Bytes = using(hash.reader(), reader => reader.toArray(64)); + +// you can also return promises/use async methods: +using(hash.reader(), async reader => { + do { + await send(reader.read(64)); + } while (needsMoreData()); +}); +``` + +## Speed + +> Native Node.js bindings are a work in progress. + +You can run benchmarks by installing `npm install -g @c4312/matcha`, then running `matcha benchmark.js`. These are the results running on Node 12 on my MacBook. Blake3 is significantly faster than Node's built-in hashing. + + 276,000 ops/sec > 64B#md5 (4,240x) + 263,000 ops/sec > 64B#sha1 (4,040x) + 271,000 ops/sec > 64B#sha256 (4,160x) + 1,040,000 ops/sec > 64B#blake3 wasm (15,900x) + 625,000 ops/sec > 64B#blake3 native (9,590x) + + 9,900 ops/sec > 64KB#md5 (152x) + 13,900 ops/sec > 64KB#sha1 (214x) + 6,470 ops/sec > 64KB#sha256 (99.2x) + 6,410 ops/sec > 64KB#blake3 wasm (98.4x) + 48,900 ops/sec > 64KB#blake3 native (750x) + + 106 ops/sec > 6MB#md5 (1.63x) + 150 ops/sec > 6MB#sha1 (2.3x) + 69.2 ops/sec > 6MB#sha256 (1.06x) + 65.2 ops/sec > 6MB#blake3 wasm (1x) + 502 ops/sec > 6MB#blake3 native (7.7x) + +## Contributing + +This build is a little esoteric due to the mixing of languages. We use a `Makefile` to coodinate things. + +To get set up, you'll want to open the repository in VS Code. Make sure you have [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed, and then accept the "Reopen in Container" prompt when opening the folder. This will get the environment set up with everything you need. Then, run `make prepare` to install local dependencies. + +Finally, `make` will create a build for you; you can run `make MODE=release` for a production release, and certainly should if you want to [benchmark it](#speed). + +- Rust code is compiled from `src/lib.rs` to `pkg/browser` and `pkg/node` +- TypeScript code is compiled from `ts/*.ts` into `dist` + +### Publishing + +In case I get hit by a bus or get other contributors, these are the steps for publishing: + +1. Get all your code ready to go in master, pushed up to Github. +2. Run `make prepare-binaries`. This will update the branch `generate-binary`, which kicks off a build via Github actions to create `.node` binaries for every relevant Node.js version. +3. When the build completes, it'll generate a zip file of artifacts. Download those. +4. Back on master, run `npm version <type>` to update the version in git. `git push --tags`. +5. On Github, upload the contents of the artifacts folder to the release for the newly tagged version. +6. Run `npm publish`. diff --git a/node_modules/blake3-wasm/targets.json b/node_modules/blake3-wasm/targets.json new file mode 100644 index 0000000..0e43916 --- /dev/null +++ b/node_modules/blake3-wasm/targets.json @@ -0,0 +1 @@ +{"v15.3.0":88,"v15.2.1":88,"v15.2.0":88,"v15.1.0":88,"v15.0.1":88,"v15.0.0":88,"v14.15.1":83,"v14.15.0":83,"v14.14.0":83,"v14.13.1":83,"v14.13.0":83,"v14.12.0":83,"v14.11.0":83,"v14.10.1":83,"v14.10.0":83,"v14.9.0":83,"v14.8.0":83,"v14.7.0":83,"v14.6.0":83,"v14.5.0":83,"v14.4.0":83,"v14.3.0":83,"v14.2.0":83,"v14.1.0":83,"v14.0.0":83,"v13.14.0":79,"v13.13.0":79,"v13.12.0":79,"v13.11.0":79,"v13.10.1":79,"v13.10.0":79,"v13.9.0":79,"v13.8.0":79,"v13.7.0":79,"v13.6.0":79,"v13.5.0":79,"v13.4.0":79,"v13.3.0":79,"v13.2.0":79,"v13.1.0":79,"v13.0.1":79,"v13.0.0":79,"v12.20.0":72,"v12.19.1":72,"v12.19.0":72,"v12.18.4":72,"v12.18.3":72,"v12.18.2":72,"v12.18.1":72,"v12.18.0":72,"v12.17.0":72,"v12.16.3":72,"v12.16.2":72,"v12.16.1":72,"v12.16.0":72,"v12.15.0":72,"v12.14.1":72,"v12.14.0":72,"v12.13.1":72,"v12.13.0":72,"v12.12.0":72,"v12.11.1":72,"v12.11.0":72,"v12.10.0":72,"v12.9.1":72,"v12.9.0":72,"v12.8.1":72,"v12.8.0":72,"v12.7.0":72,"v12.6.0":72,"v12.5.0":72,"v12.4.0":72,"v12.3.1":72,"v12.3.0":72,"v12.2.0":72,"v12.1.0":72,"v12.0.0":72,"v11.15.0":67,"v11.14.0":67,"v11.13.0":67,"v11.12.0":67,"v11.11.0":67,"v11.10.1":67,"v11.10.0":67,"v11.9.0":67,"v11.8.0":67,"v11.7.0":67,"v11.6.0":67,"v11.5.0":67,"v11.4.0":67,"v11.3.0":67,"v11.2.0":67,"v11.1.0":67,"v11.0.0":67,"v10.23.0":64,"v10.22.1":64,"v10.22.0":64,"v10.21.0":64,"v10.20.1":64,"v10.20.0":64,"v10.19.0":64,"v10.18.1":64,"v10.18.0":64,"v10.17.0":64,"v10.16.3":64,"v10.16.2":64,"v10.16.1":64,"v10.16.0":64,"v10.15.3":64,"v10.15.2":64,"v10.15.1":64,"v10.15.0":64,"v10.14.2":64,"v10.14.1":64,"v10.14.0":64,"v10.13.0":64,"v10.12.0":64,"v10.11.0":64,"v10.10.0":64,"v10.9.0":64,"v10.8.0":64,"v10.7.0":64,"v10.6.0":64,"v10.5.0":64,"v10.4.1":64,"v10.4.0":64,"v10.3.0":64,"v10.2.1":64,"v10.2.0":64,"v10.1.0":64,"v10.0.0":64}
\ No newline at end of file |
