+25
@@ -0,0 +1,25 @@
|
||||
import type { MultihashDigest } from './interface.js';
|
||||
/**
|
||||
* Creates a multihash digest.
|
||||
*/
|
||||
export declare function create<Code extends number>(code: Code, digest: Uint8Array): Digest<Code, number>;
|
||||
/**
|
||||
* Turns bytes representation of multihash digest into an instance.
|
||||
*/
|
||||
export declare function decode(multihash: Uint8Array): MultihashDigest;
|
||||
export declare function equals(a: MultihashDigest, b: unknown): b is MultihashDigest;
|
||||
/**
|
||||
* Represents a multihash digest which carries information about the
|
||||
* hashing algorithm and an actual hash digest.
|
||||
*/
|
||||
export declare class Digest<Code extends number, Size extends number> implements MultihashDigest {
|
||||
readonly code: Code;
|
||||
readonly size: Size;
|
||||
readonly digest: Uint8Array;
|
||||
readonly bytes: Uint8Array;
|
||||
/**
|
||||
* Creates a multihash digest.
|
||||
*/
|
||||
constructor(code: Code, size: Size, digest: Uint8Array, bytes: Uint8Array);
|
||||
}
|
||||
//# sourceMappingURL=digest.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../../src/hashes/digest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD;;GAEG;AACH,wBAAgB,MAAM,CAAE,IAAI,SAAS,MAAM,EAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAWlG;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAE,SAAS,EAAE,UAAU,GAAG,eAAe,CAW9D;AAED,wBAAgB,MAAM,CAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,eAAe,CAa5E;AAED;;;GAGG;AACH,qBAAa,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,CAAE,YAAW,eAAe;IACtF,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAE1B;;OAEG;gBACU,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU;CAM3E"}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
import { coerce, equals as equalBytes } from '../bytes.js';
|
||||
import * as varint from '../varint.js';
|
||||
/**
|
||||
* Creates a multihash digest.
|
||||
*/
|
||||
export function create(code, digest) {
|
||||
const size = digest.byteLength;
|
||||
const sizeOffset = varint.encodingLength(code);
|
||||
const digestOffset = sizeOffset + varint.encodingLength(size);
|
||||
const bytes = new Uint8Array(digestOffset + size);
|
||||
varint.encodeTo(code, bytes, 0);
|
||||
varint.encodeTo(size, bytes, sizeOffset);
|
||||
bytes.set(digest, digestOffset);
|
||||
return new Digest(code, size, digest, bytes);
|
||||
}
|
||||
/**
|
||||
* Turns bytes representation of multihash digest into an instance.
|
||||
*/
|
||||
export function decode(multihash) {
|
||||
const bytes = coerce(multihash);
|
||||
const [code, sizeOffset] = varint.decode(bytes);
|
||||
const [size, digestOffset] = varint.decode(bytes.subarray(sizeOffset));
|
||||
const digest = bytes.subarray(sizeOffset + digestOffset);
|
||||
if (digest.byteLength !== size) {
|
||||
throw new Error('Incorrect length');
|
||||
}
|
||||
return new Digest(code, size, digest, bytes);
|
||||
}
|
||||
export function equals(a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
const data = b;
|
||||
return (a.code === data.code &&
|
||||
a.size === data.size &&
|
||||
data.bytes instanceof Uint8Array &&
|
||||
equalBytes(a.bytes, data.bytes));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Represents a multihash digest which carries information about the
|
||||
* hashing algorithm and an actual hash digest.
|
||||
*/
|
||||
export class Digest {
|
||||
code;
|
||||
size;
|
||||
digest;
|
||||
bytes;
|
||||
/**
|
||||
* Creates a multihash digest.
|
||||
*/
|
||||
constructor(code, size, digest, bytes) {
|
||||
this.code = code;
|
||||
this.size = size;
|
||||
this.digest = digest;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=digest.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"digest.js","sourceRoot":"","sources":["../../../src/hashes/digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAGtC;;GAEG;AACH,MAAM,UAAU,MAAM,CAAwB,IAAU,EAAE,MAAkB;IAC1E,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAA;IAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;IAC9C,MAAM,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;IAE7D,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC,CAAA;IACjD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IAC/B,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;IACxC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAE/B,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAE,SAAqB;IAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;IAC/B,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAA;IACtE,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,GAAG,YAAY,CAAC,CAAA;IAExD,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,MAAM,CAAE,CAAkB,EAAE,CAAU;IACpD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAA;IACb,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,CAAwD,CAAA;QAErE,OAAO,CACL,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;YACpB,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;YACpB,IAAI,CAAC,KAAK,YAAY,UAAU;YAChC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAChC,CAAA;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,MAAM;IACR,IAAI,CAAM;IACV,IAAI,CAAM;IACV,MAAM,CAAY;IAClB,KAAK,CAAY;IAE1B;;OAEG;IACH,YAAa,IAAU,EAAE,IAAU,EAAE,MAAkB,EAAE,KAAiB;QACxE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF"}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import * as Digest from './digest.js';
|
||||
import type { MultihashHasher } from './interface.js';
|
||||
type Await<T> = Promise<T> | T;
|
||||
export declare function from<Name extends string, Code extends number>({ name, code, encode }: {
|
||||
name: Name;
|
||||
code: Code;
|
||||
encode(input: Uint8Array): Await<Uint8Array>;
|
||||
}): Hasher<Name, Code>;
|
||||
/**
|
||||
* Hasher represents a hashing algorithm implementation that produces as
|
||||
* `MultihashDigest`.
|
||||
*/
|
||||
export declare class Hasher<Name extends string, Code extends number> implements MultihashHasher<Code> {
|
||||
readonly name: Name;
|
||||
readonly code: Code;
|
||||
readonly encode: (input: Uint8Array) => Await<Uint8Array>;
|
||||
constructor(name: Name, code: Code, encode: (input: Uint8Array) => Await<Uint8Array>);
|
||||
digest(input: Uint8Array): Await<Digest.Digest<Code, number>>;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=hasher.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"hasher.d.ts","sourceRoot":"","sources":["../../../src/hashes/hasher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,KAAK,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAE9B,wBAAgB,IAAI,CAAE,IAAI,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,EAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAErL;AAED;;;GAGG;AACH,qBAAa,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,CAAE,YAAW,eAAe,CAAC,IAAI,CAAC;IAC5F,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,KAAK,CAAC,UAAU,CAAC,CAAA;gBAE5C,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,KAAK,CAAC,UAAU,CAAC;IAMrF,MAAM,CAAE,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;CAY/D"}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import * as Digest from './digest.js';
|
||||
export function from({ name, code, encode }) {
|
||||
return new Hasher(name, code, encode);
|
||||
}
|
||||
/**
|
||||
* Hasher represents a hashing algorithm implementation that produces as
|
||||
* `MultihashDigest`.
|
||||
*/
|
||||
export class Hasher {
|
||||
name;
|
||||
code;
|
||||
encode;
|
||||
constructor(name, code, encode) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
this.encode = encode;
|
||||
}
|
||||
digest(input) {
|
||||
if (input instanceof Uint8Array) {
|
||||
const result = this.encode(input);
|
||||
return result instanceof Uint8Array
|
||||
? Digest.create(this.code, result)
|
||||
/* c8 ignore next 1 */
|
||||
: result.then(digest => Digest.create(this.code, digest));
|
||||
}
|
||||
else {
|
||||
throw Error('Unknown type, must be binary type');
|
||||
/* c8 ignore next 1 */
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=hasher.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"hasher.js","sourceRoot":"","sources":["../../../src/hashes/hasher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAKrC,MAAM,UAAU,IAAI,CAA6C,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAA4E;IAC/J,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,MAAM;IACR,IAAI,CAAM;IACV,IAAI,CAAM;IACV,MAAM,CAA0C;IAEzD,YAAa,IAAU,EAAE,IAAU,EAAE,MAAgD;QACnF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,MAAM,CAAE,KAAiB;QACvB,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;YAChC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACjC,OAAO,MAAM,YAAY,UAAU;gBACjC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;gBAClC,sBAAsB;gBACtB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;QAC7D,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAC,mCAAmC,CAAC,CAAA;YAChD,sBAAsB;QACxB,CAAC;IACH,CAAC;CACF"}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as Digest from './digest.js';
|
||||
declare const code = 0;
|
||||
declare function digest(input: Uint8Array): Digest.Digest<typeof code, number>;
|
||||
export declare const identity: {
|
||||
code: number;
|
||||
name: string;
|
||||
encode: (input: Uint8Array) => Uint8Array;
|
||||
digest: typeof digest;
|
||||
};
|
||||
export {};
|
||||
//# sourceMappingURL=identity.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/hashes/identity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,QAAA,MAAM,IAAI,IAAM,CAAA;AAKhB,iBAAS,MAAM,CAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,MAAM,CAAC,CAEtE;AAED,eAAO,MAAM,QAAQ;;;oBANC,UAAU,KAAK,UAAU;;CAMO,CAAA"}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { coerce } from '../bytes.js';
|
||||
import * as Digest from './digest.js';
|
||||
const code = 0x0;
|
||||
const name = 'identity';
|
||||
const encode = coerce;
|
||||
function digest(input) {
|
||||
return Digest.create(code, encode(input));
|
||||
}
|
||||
export const identity = { code, name, encode, digest };
|
||||
//# sourceMappingURL=identity.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/hashes/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,IAAI,GAAG,UAAU,CAAA;AAEvB,MAAM,MAAM,GAAsC,MAAM,CAAA;AAExD,SAAS,MAAM,CAAE,KAAiB;IAChC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA"}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Represents a multihash digest which carries information about the
|
||||
* hashing algorithm and an actual hash digest.
|
||||
*/
|
||||
export interface MultihashDigest<Code extends number = number> {
|
||||
/**
|
||||
* Code of the multihash
|
||||
*/
|
||||
code: Code;
|
||||
/**
|
||||
* Raw digest (without a hashing algorithm info)
|
||||
*/
|
||||
digest: Uint8Array;
|
||||
/**
|
||||
* byte length of the `this.digest`
|
||||
*/
|
||||
size: number;
|
||||
/**
|
||||
* Binary representation of this multihash digest.
|
||||
*/
|
||||
bytes: Uint8Array;
|
||||
}
|
||||
/**
|
||||
* Hasher represents a hashing algorithm implementation that produces as
|
||||
* `MultihashDigest`.
|
||||
*/
|
||||
export interface MultihashHasher<Code extends number = number> {
|
||||
/**
|
||||
* Takes binary `input` and returns it (multi) hash digest. Return value is
|
||||
* either promise of a digest or a digest. This way general use can `await`
|
||||
* while performance critical code may asses return value to decide whether
|
||||
* await is needed.
|
||||
*/
|
||||
digest(input: Uint8Array): Promise<MultihashDigest<Code>> | MultihashDigest<Code>;
|
||||
/**
|
||||
* Name of the multihash
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Code of the multihash
|
||||
*/
|
||||
code: Code;
|
||||
}
|
||||
/**
|
||||
* Sync variant of `MultihashHasher` that refines return type of the `digest`
|
||||
* to `MultihashDigest`. It is subtype of `MultihashHasher` so implementations
|
||||
* of this interface can be passed anywhere `MultihashHasher` is expected,
|
||||
* allowing consumer to either `await` or check the return type to decide
|
||||
* whether to await or proceed with return value.
|
||||
*
|
||||
* `SyncMultihashHasher` is useful in certain APIs where async hashing would be
|
||||
* impractical e.g. implementation of Hash Array Mapped Trie (HAMT).
|
||||
*/
|
||||
export interface SyncMultihashHasher<Code extends number = number> extends MultihashHasher<Code> {
|
||||
digest(input: Uint8Array): MultihashDigest<Code>;
|
||||
}
|
||||
//# sourceMappingURL=interface.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/hashes/interface.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAMH,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IAC3D;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,EAAE,UAAU,CAAA;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IAC3D;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IAEjF;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;CACX;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,eAAe,CAAC,IAAI,CAAC;IAC9F,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;CACjD"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// # Multihash
|
||||
export {};
|
||||
//# sourceMappingURL=interface.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/hashes/interface.ts"],"names":[],"mappings":"AAAA,cAAc"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export declare const sha1: import("./hasher.js").Hasher<"sha-1", 17>;
|
||||
//# sourceMappingURL=sha1-browser.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha1-browser.d.ts","sourceRoot":"","sources":["../../../src/hashes/sha1-browser.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,IAAI,2CAIf,CAAA"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/* global crypto */
|
||||
import { from } from './hasher.js';
|
||||
const sha = (name) => async (data) => new Uint8Array(await crypto.subtle.digest(name, data));
|
||||
export const sha1 = from({
|
||||
name: 'sha-1',
|
||||
code: 0x11,
|
||||
encode: sha('SHA-1')
|
||||
});
|
||||
//# sourceMappingURL=sha1-browser.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha1-browser.js","sourceRoot":"","sources":["../../../src/hashes/sha1-browser.ts"],"names":[],"mappings":"AAAA,mBAAmB;AAEnB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,MAAM,GAAG,GAAG,CAAC,IAAyB,EAAE,EAAE,CACxC,KAAK,EAAE,IAAgB,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AAEpF,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC;CACrB,CAAC,CAAA"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export declare const sha1: import("./hasher.js").Hasher<"sha-1", 17>;
|
||||
//# sourceMappingURL=sha1.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha1.d.ts","sourceRoot":"","sources":["../../../src/hashes/sha1.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,2CAIf,CAAA"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import crypto from 'crypto';
|
||||
import { coerce } from '../bytes.js';
|
||||
import { from } from './hasher.js';
|
||||
export const sha1 = from({
|
||||
name: 'sha-1',
|
||||
code: 0x11,
|
||||
encode: (input) => coerce(crypto.createHash('sha1').update(input).digest())
|
||||
});
|
||||
//# sourceMappingURL=sha1.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha1.js","sourceRoot":"","sources":["../../../src/hashes/sha1.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;CAC5E,CAAC,CAAA"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export declare const sha256: import("./hasher.js").Hasher<"sha2-256", 18>;
|
||||
export declare const sha512: import("./hasher.js").Hasher<"sha2-512", 19>;
|
||||
//# sourceMappingURL=sha2-browser.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha2-browser.d.ts","sourceRoot":"","sources":["../../../src/hashes/sha2-browser.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,MAAM,8CAIjB,CAAA;AAEF,eAAO,MAAM,MAAM,8CAIjB,CAAA"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/* global crypto */
|
||||
import { from } from './hasher.js';
|
||||
function sha(name) {
|
||||
return async (data) => new Uint8Array(await crypto.subtle.digest(name, data));
|
||||
}
|
||||
export const sha256 = from({
|
||||
name: 'sha2-256',
|
||||
code: 0x12,
|
||||
encode: sha('SHA-256')
|
||||
});
|
||||
export const sha512 = from({
|
||||
name: 'sha2-512',
|
||||
code: 0x13,
|
||||
encode: sha('SHA-512')
|
||||
});
|
||||
//# sourceMappingURL=sha2-browser.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha2-browser.js","sourceRoot":"","sources":["../../../src/hashes/sha2-browser.ts"],"names":[],"mappings":"AAAA,mBAAmB;AAEnB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,SAAS,GAAG,CAAE,IAAyB;IACrC,OAAO,KAAK,EAAC,IAAI,EAAC,EAAE,CAAC,IAAI,UAAU,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AAC7E,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,GAAG,CAAC,SAAS,CAAC;CACvB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,GAAG,CAAC,SAAS,CAAC;CACvB,CAAC,CAAA"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export declare const sha256: import("./hasher.js").Hasher<"sha2-256", 18>;
|
||||
export declare const sha512: import("./hasher.js").Hasher<"sha2-512", 19>;
|
||||
//# sourceMappingURL=sha2.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha2.d.ts","sourceRoot":"","sources":["../../../src/hashes/sha2.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,8CAIjB,CAAA;AAEF,eAAO,MAAM,MAAM,8CAIjB,CAAA"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import crypto from 'crypto';
|
||||
import { coerce } from '../bytes.js';
|
||||
import { from } from './hasher.js';
|
||||
export const sha256 = from({
|
||||
name: 'sha2-256',
|
||||
code: 0x12,
|
||||
encode: (input) => coerce(crypto.createHash('sha256').update(input).digest())
|
||||
});
|
||||
export const sha512 = from({
|
||||
name: 'sha2-512',
|
||||
code: 0x13,
|
||||
encode: input => coerce(crypto.createHash('sha512').update(input).digest())
|
||||
});
|
||||
//# sourceMappingURL=sha2.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha2.js","sourceRoot":"","sources":["../../../src/hashes/sha2.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;CAC9E,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;CAC5E,CAAC,CAAA"}
|
||||
Reference in New Issue
Block a user