Add comprehensive installation and setup documentation

- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
This commit is contained in:
Dorian
2026-01-27 17:18:21 +00:00
parent a81f655133
commit 0d073fa89e
22658 changed files with 4494151 additions and 6 deletions
File diff suppressed because one or more lines are too long
+92
View File
@@ -0,0 +1,92 @@
{
"Codec": "https://multiformats.github.io/js-multiformats/classes/bases_base10._internal_.Codec.html",
"ComposedDecoder": "https://multiformats.github.io/js-multiformats/classes/bases_base10._internal_.ComposedDecoder.html",
"Decoder": "https://multiformats.github.io/js-multiformats/classes/bases_base10._internal_.Decoder.html",
"Encoder": "https://multiformats.github.io/js-multiformats/classes/bases_base10._internal_.Encoder.html",
"Decoders": "https://multiformats.github.io/js-multiformats/types/bases_base10._internal_.Decoders.html",
"base10": "https://multiformats.github.io/js-multiformats/variables/bases_base10.base10.html",
"base16": "https://multiformats.github.io/js-multiformats/variables/bases_base16.base16.html",
"base16upper": "https://multiformats.github.io/js-multiformats/variables/bases_base16.base16upper.html",
"base2": "https://multiformats.github.io/js-multiformats/variables/bases_base2.base2.html",
"base256emoji": "https://multiformats.github.io/js-multiformats/variables/bases_base256emoji.base256emoji.html",
"base32": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32.html",
"base32hex": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hex.html",
"base32hexpad": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexpad.html",
"base32hexpadupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexpadupper.html",
"base32hexupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32hexupper.html",
"base32pad": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32pad.html",
"base32padupper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32padupper.html",
"base32upper": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32upper.html",
"base32z": "https://multiformats.github.io/js-multiformats/variables/bases_base32.base32z.html",
"base36": "https://multiformats.github.io/js-multiformats/variables/bases_base36.base36.html",
"base36upper": "https://multiformats.github.io/js-multiformats/variables/bases_base36.base36upper.html",
"base58btc": "https://multiformats.github.io/js-multiformats/variables/bases_base58.base58btc.html",
"base58flickr": "https://multiformats.github.io/js-multiformats/variables/bases_base58.base58flickr.html",
"base64": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64.html",
"base64pad": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64pad.html",
"base64url": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64url.html",
"base64urlpad": "https://multiformats.github.io/js-multiformats/variables/bases_base64.base64urlpad.html",
"base8": "https://multiformats.github.io/js-multiformats/variables/bases_base8.base8.html",
"identity": "https://multiformats.github.io/js-multiformats/variables/bases_identity.identity.html",
"bases": "https://multiformats.github.io/js-multiformats/variables/basics.bases.html",
"codecs": "https://multiformats.github.io/js-multiformats/variables/basics.codecs.html",
"hashes": "https://multiformats.github.io/js-multiformats/variables/basics.hashes.html",
"Block": "https://multiformats.github.io/js-multiformats/classes/block.Block.html",
"RequiredCreateOptions": "https://multiformats.github.io/js-multiformats/interfaces/block.RequiredCreateOptions.html",
"create": "https://multiformats.github.io/js-multiformats/functions/block.create.html",
"createUnsafe": "https://multiformats.github.io/js-multiformats/functions/block.createUnsafe.html",
"decode": "https://multiformats.github.io/js-multiformats/functions/block.decode.html",
"encode": "https://multiformats.github.io/js-multiformats/functions/block.encode.html",
"empty": "https://multiformats.github.io/js-multiformats/variables/bytes.empty.html",
"coerce": "https://multiformats.github.io/js-multiformats/functions/bytes.coerce.html",
"equals": "https://multiformats.github.io/js-multiformats/functions/bytes.equals.html",
"fromHex": "https://multiformats.github.io/js-multiformats/functions/bytes.fromHex.html",
"fromString": "https://multiformats.github.io/js-multiformats/functions/bytes.fromString.html",
"isBinary": "https://multiformats.github.io/js-multiformats/functions/bytes.isBinary.html",
"toHex": "https://multiformats.github.io/js-multiformats/functions/bytes.toHex.html",
"CID": "https://multiformats.github.io/js-multiformats/classes/cid.CID.html",
"format": "https://multiformats.github.io/js-multiformats/functions/cid.format.html",
"fromJSON": "https://multiformats.github.io/js-multiformats/functions/cid.fromJSON.html",
"toJSON": "https://multiformats.github.io/js-multiformats/functions/cid.toJSON.html",
"ByteView": "https://multiformats.github.io/js-multiformats/types/codecs_json.ByteView.html",
"code": "https://multiformats.github.io/js-multiformats/variables/codecs_json.code.html",
"name": "https://multiformats.github.io/js-multiformats/variables/codecs_json.name.html",
"Digest": "https://multiformats.github.io/js-multiformats/classes/hashes_digest.Digest.html",
"MultihashDigest": "https://multiformats.github.io/js-multiformats/types/hashes_digest.MultihashDigest.html",
"Hasher": "https://multiformats.github.io/js-multiformats/classes/hashes_hasher.Hasher.html",
"MultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/hashes_hasher.MultihashHasher.html",
"Await": "https://multiformats.github.io/js-multiformats/types/hashes_hasher.Await.html",
"from": "https://multiformats.github.io/js-multiformats/functions/hashes_hasher.from.html",
"sha256": "https://multiformats.github.io/js-multiformats/variables/hashes_sha2.sha256.html",
"sha512": "https://multiformats.github.io/js-multiformats/variables/hashes_sha2.sha512.html",
"encodeTo": "https://multiformats.github.io/js-multiformats/functions/index.varint.encodeTo.html",
"encodingLength": "https://multiformats.github.io/js-multiformats/functions/index.varint.encodingLength.html",
"BaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseCodec.html",
"BaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseDecoder.html",
"BaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseEncoder.html",
"BlockCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockCodec.html",
"BlockDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockDecoder.html",
"BlockEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockEncoder.html",
"CombobaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.CombobaseDecoder.html",
"LegacyLink": "https://multiformats.github.io/js-multiformats/interfaces/index.LegacyLink.html",
"Link": "https://multiformats.github.io/js-multiformats/interfaces/index.Link.html",
"LinkJSON": "https://multiformats.github.io/js-multiformats/interfaces/index.LinkJSON.html",
"MultibaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseCodec.html",
"MultibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseDecoder.html",
"MultibaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseEncoder.html",
"Phantom": "https://multiformats.github.io/js-multiformats/interfaces/index.Phantom.html",
"SyncMultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/index.SyncMultihashHasher.html",
"UnibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.UnibaseDecoder.html",
"BlockCursorView": "https://multiformats.github.io/js-multiformats/types/index.BlockCursorView.html",
"DAG_PB": "https://multiformats.github.io/js-multiformats/types/index.DAG_PB.html",
"Multibase": "https://multiformats.github.io/js-multiformats/types/index.Multibase.html",
"SHA_256": "https://multiformats.github.io/js-multiformats/types/index.SHA_256.html",
"ToString": "https://multiformats.github.io/js-multiformats/types/index.ToString.html",
"UnknownLink": "https://multiformats.github.io/js-multiformats/types/index.UnknownLink.html",
"Version": "https://multiformats.github.io/js-multiformats/types/index.Version.html",
"createLegacy": "https://multiformats.github.io/js-multiformats/functions/link.createLegacy.html",
"isLink": "https://multiformats.github.io/js-multiformats/functions/link.isLink.html",
"parse": "https://multiformats.github.io/js-multiformats/functions/link.parse.html",
"BlockView": "https://multiformats.github.io/js-multiformats/interfaces/traversal.BlockView.html",
"walk": "https://multiformats.github.io/js-multiformats/functions/traversal.walk.html"
}
+148
View File
@@ -0,0 +1,148 @@
export function or<L extends string, R extends string>(left: API.UnibaseDecoder<L> | API.CombobaseDecoder<L>, right: API.UnibaseDecoder<R> | API.CombobaseDecoder<R>): ComposedDecoder<L | R>;
/**
* @class
* @template {string} Base
* @template {string} Prefix
* @implements {API.MultibaseCodec<Prefix>}
* @implements {API.MultibaseEncoder<Prefix>}
* @implements {API.MultibaseDecoder<Prefix>}
* @implements {API.BaseCodec}
* @implements {API.BaseEncoder}
* @implements {API.BaseDecoder}
*/
export class Codec<Base extends string, Prefix extends string> implements API.MultibaseCodec<Prefix>, API.MultibaseEncoder<Prefix>, API.MultibaseDecoder<Prefix>, API.BaseCodec, API.BaseEncoder, API.BaseDecoder {
/**
* @param {Base} name
* @param {Prefix} prefix
* @param {(bytes:Uint8Array) => string} baseEncode
* @param {(text:string) => Uint8Array} baseDecode
*/
constructor(name: Base, prefix: Prefix, baseEncode: (bytes: Uint8Array) => string, baseDecode: (text: string) => Uint8Array);
name: Base;
prefix: Prefix;
baseEncode: (bytes: Uint8Array) => string;
baseDecode: (text: string) => Uint8Array;
encoder: Encoder<Base, Prefix>;
decoder: Decoder<Base, Prefix>;
/**
* @param {Uint8Array} input
*/
encode(input: Uint8Array): API.Multibase<Prefix>;
/**
* @param {string} input
*/
decode(input: string): Uint8Array;
}
export function from<Base extends string, Prefix extends string>({ name, prefix, encode, decode }: {
name: Base;
prefix: Prefix;
encode: (bytes: Uint8Array) => string;
decode: (input: string) => Uint8Array;
}): Codec<Base, Prefix>;
export function baseX<Base extends string, Prefix extends string>({ prefix, name, alphabet }: {
name: Base;
prefix: Prefix;
alphabet: string;
}): Codec<Base, Prefix>;
export function rfc4648<Base extends string, Prefix extends string>({ name, prefix, bitsPerChar, alphabet }: {
name: Base;
prefix: Prefix;
alphabet: string;
bitsPerChar: number;
}): Codec<Base, Prefix>;
export type Decoders<Prefix extends string> = Record<Prefix, API.UnibaseDecoder<Prefix>>;
import * as API from "./interface.js";
/**
* @template {string} Prefix
* @typedef {Record<Prefix, API.UnibaseDecoder<Prefix>>} Decoders
*/
/**
* @template {string} Prefix
* @implements {API.MultibaseDecoder<Prefix>}
* @implements {API.CombobaseDecoder<Prefix>}
*/
declare class ComposedDecoder<Prefix extends string> implements API.MultibaseDecoder<Prefix>, API.CombobaseDecoder<Prefix> {
/**
* @param {Decoders<Prefix>} decoders
*/
constructor(decoders: Decoders<Prefix>);
decoders: Decoders<Prefix>;
/**
* @template {string} OtherPrefix
* @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder
* @returns {ComposedDecoder<Prefix|OtherPrefix>}
*/
or<OtherPrefix extends string>(decoder: API.UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix>;
/**
* @param {string} input
* @returns {Uint8Array}
*/
decode(input: string): Uint8Array;
}
/**
* Class represents both BaseEncoder and MultibaseEncoder meaning it
* can be used to encode to multibase or base encode without multibase
* prefix.
*
* @class
* @template {string} Base
* @template {string} Prefix
* @implements {API.MultibaseEncoder<Prefix>}
* @implements {API.BaseEncoder}
*/
declare class Encoder<Base extends string, Prefix extends string> implements API.MultibaseEncoder<Prefix>, API.BaseEncoder {
/**
* @param {Base} name
* @param {Prefix} prefix
* @param {(bytes:Uint8Array) => string} baseEncode
*/
constructor(name: Base, prefix: Prefix, baseEncode: (bytes: Uint8Array) => string);
name: Base;
prefix: Prefix;
baseEncode: (bytes: Uint8Array) => string;
/**
* @param {Uint8Array} bytes
* @returns {API.Multibase<Prefix>}
*/
encode(bytes: Uint8Array): API.Multibase<Prefix>;
}
/**
* @template {string} Prefix
*/
/**
* Class represents both BaseDecoder and MultibaseDecoder so it could be used
* to decode multibases (with matching prefix) or just base decode strings
* with corresponding base encoding.
*
* @class
* @template {string} Base
* @template {string} Prefix
* @implements {API.MultibaseDecoder<Prefix>}
* @implements {API.UnibaseDecoder<Prefix>}
* @implements {API.BaseDecoder}
*/
declare class Decoder<Base extends string, Prefix extends string> implements API.MultibaseDecoder<Prefix>, API.UnibaseDecoder<Prefix>, API.BaseDecoder {
/**
* @param {Base} name
* @param {Prefix} prefix
* @param {(text:string) => Uint8Array} baseDecode
*/
constructor(name: Base, prefix: Prefix, baseDecode: (text: string) => Uint8Array);
name: Base;
prefix: Prefix;
/** @private */
private prefixCodePoint;
baseDecode: (text: string) => Uint8Array;
/**
* @param {string} text
*/
decode(text: string): Uint8Array;
/**
* @template {string} OtherPrefix
* @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder
* @returns {ComposedDecoder<Prefix|OtherPrefix>}
*/
or<OtherPrefix extends string>(decoder: API.UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix>;
}
export {};
//# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/bases/base.js"],"names":[],"mappings":"AAoJO,8LAGJ;AAEH;;;;;;;;;;GAUG;AACH,0EAPgB,GAAG,CAAC,cAAc,CAAC,MAAM,GACzB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,SAAS,EACb,GAAG,CAAC,WAAW,EACf,GAAG,CAAC,WAAW;IAG7B;;;;;OAKG;IACH,kBALW,IAAI,UACJ,MAAM,sBACC,UAAU,KAAK,MAAM,qBACtB,MAAM,KAAK,UAAU,EASrC;IANC,WAAgB;IAChB,eAAoB;IACpB,oBANgB,UAAU,KAAK,MAAM,CAMT;IAC5B,mBANe,MAAM,KAAK,UAAU,CAMR;IAC5B,+BAAoD;IACpD,+BAAoD;IAGtD;;OAEG;IACH,cAFW,UAAU,yBAIpB;IAED;;OAEG;IACH,cAFW,MAAM,cAIhB;CACF;AAYM;;;oBAJW,UAAU,KAAK,MAAM;oBACrB,MAAM,KAAK,UAAU;wBAIE;AAWlC;;;cAHI,MAAM;wBAchB;AA2GM;;;cAHI,MAAM;iBACN,MAAM;wBAahB;8CArPY,OAAO,MAAM,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;;AAFvD;;;GAGG;AAEH;;;;GAIG;AACH,gEAHgB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,gBAAgB,CAAC,MAAM;IAGzC;;OAEG;IACH,sBAFW,SAAS,MAAM,CAAC,EAI1B;IADC,2BAAwB;IAG1B;;;;OAIG;IACH,+IAEC;IAED;;;OAGG;IACH,cAHW,MAAM,GACJ,UAAU,CAUtB;CACF;AArID;;;;;;;;;;GAUG;AACH,6EAHgB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,WAAW;IAG7B;;;;OAIG;IACH,kBAJW,IAAI,UACJ,MAAM,sBACC,UAAU,KAAK,MAAM,EAMtC;IAHC,WAAgB;IAChB,eAAoB;IACpB,oBALgB,UAAU,KAAK,MAAM,CAKT;IAG9B;;;OAGG;IACH,cAHW,UAAU,GACR,IAAI,SAAS,CAAC,MAAM,CAAC,CAQjC;CACF;AAED;;GAEG;AACH;;;;;;;;;;;GAWG;AACH,6EAJgB,GAAG,CAAC,gBAAgB,CAAC,MAAM,GAC3B,GAAG,CAAC,cAAc,CAAC,MAAM,GACzB,GAAG,CAAC,WAAW;IAG7B;;;;OAIG;IACH,kBAJW,IAAI,UACJ,MAAM,qBACA,MAAM,KAAK,UAAU,EAYrC;IATC,WAAgB;IAChB,eAAoB;IAKpB,eAAe;IACf,wBAAoE;IACpE,mBAXe,MAAM,KAAK,UAAU,CAWR;IAG9B;;OAEG;IACH,aAFW,MAAM,cAWhB;IAED;;;;OAIG;IACH,+IAEC;CACF"}
@@ -0,0 +1,2 @@
export const base10: import("./base.js").Codec<"base10", "9">;
//# sourceMappingURL=base10.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base10.d.ts","sourceRoot":"","sources":["../../../../src/bases/base10.js"],"names":[],"mappings":"AAEA,8DAIE"}
@@ -0,0 +1,3 @@
export const base16: import("./base.js").Codec<"base16", "f">;
export const base16upper: import("./base.js").Codec<"base16upper", "F">;
//# sourceMappingURL=base16.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base16.d.ts","sourceRoot":"","sources":["../../../../src/bases/base16.js"],"names":[],"mappings":"AAIA,8DAKE;AAEF,wEAKE"}
@@ -0,0 +1,2 @@
export const base2: import("./base.js").Codec<"base2", "0">;
//# sourceMappingURL=base2.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base2.d.ts","sourceRoot":"","sources":["../../../../src/bases/base2.js"],"names":[],"mappings":"AAIA,4DAKE"}
@@ -0,0 +1,2 @@
export const base256emoji: import("./base.js").Codec<"base256emoji", "🚀">;
//# sourceMappingURL=base256emoji.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base256emoji.d.ts","sourceRoot":"","sources":["../../../../src/bases/base256emoji.js"],"names":[],"mappings":"AAiCA,2EAKE"}
@@ -0,0 +1,10 @@
export const base32: import("./base.js").Codec<"base32", "b">;
export const base32upper: import("./base.js").Codec<"base32upper", "B">;
export const base32pad: import("./base.js").Codec<"base32pad", "c">;
export const base32padupper: import("./base.js").Codec<"base32padupper", "C">;
export const base32hex: import("./base.js").Codec<"base32hex", "v">;
export const base32hexupper: import("./base.js").Codec<"base32hexupper", "V">;
export const base32hexpad: import("./base.js").Codec<"base32hexpad", "t">;
export const base32hexpadupper: import("./base.js").Codec<"base32hexpadupper", "T">;
export const base32z: import("./base.js").Codec<"base32z", "h">;
//# sourceMappingURL=base32.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base32.d.ts","sourceRoot":"","sources":["../../../../src/bases/base32.js"],"names":[],"mappings":"AAEA,8DAKE;AAEF,wEAKE;AAEF,oEAKE;AAEF,8EAKE;AAEF,oEAKE;AAEF,8EAKE;AAEF,0EAKE;AAEF,oFAKE;AAEF,gEAKE"}
@@ -0,0 +1,3 @@
export const base36: import("./base.js").Codec<"base36", "k">;
export const base36upper: import("./base.js").Codec<"base36upper", "K">;
//# sourceMappingURL=base36.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base36.d.ts","sourceRoot":"","sources":["../../../../src/bases/base36.js"],"names":[],"mappings":"AAEA,8DAIE;AAEF,wEAIE"}
@@ -0,0 +1,3 @@
export const base58btc: import("./base.js").Codec<"base58btc", "z">;
export const base58flickr: import("./base.js").Codec<"base58flickr", "Z">;
//# sourceMappingURL=base58.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../../../src/bases/base58.js"],"names":[],"mappings":"AAEA,oEAIE;AAEF,0EAIE"}
@@ -0,0 +1,5 @@
export const base64: import("./base.js").Codec<"base64", "m">;
export const base64pad: import("./base.js").Codec<"base64pad", "M">;
export const base64url: import("./base.js").Codec<"base64url", "u">;
export const base64urlpad: import("./base.js").Codec<"base64urlpad", "U">;
//# sourceMappingURL=base64.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../src/bases/base64.js"],"names":[],"mappings":"AAIA,8DAKE;AAEF,oEAKE;AAEF,oEAKE;AAEF,0EAKE"}
@@ -0,0 +1,2 @@
export const base8: import("./base.js").Codec<"base8", "7">;
//# sourceMappingURL=base8.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"base8.d.ts","sourceRoot":"","sources":["../../../../src/bases/base8.js"],"names":[],"mappings":"AAIA,4DAKE"}
@@ -0,0 +1,2 @@
export const identity: import("./base.js").Codec<"identity", "\0">;
//# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../../src/bases/identity.js"],"names":[],"mappings":"AAKA,mEAKE"}
@@ -0,0 +1,89 @@
/**
* Base encoder just encodes bytes into base encoded string.
*/
export interface BaseEncoder {
/**
* Base encodes to a **plain** (and not a multibase) string. Unlike
* `encode` no multibase prefix is added.
*
* @param bytes
*/
baseEncode: (bytes: Uint8Array) => string;
}
/**
* Base decoder decodes encoded with matching base encoding into bytes.
*/
export interface BaseDecoder {
/**
* Decodes **plain** (and not a multibase) string. Unlike
* decode
*
* @param text
*/
baseDecode: (text: string) => Uint8Array;
}
/**
* Base codec is just dual of encoder and decoder.
*/
export interface BaseCodec {
encoder: BaseEncoder;
decoder: BaseDecoder;
}
/**
* Multibase represents base encoded strings with a prefix first character
* describing it's encoding.
*/
export type Multibase<Prefix extends string> = string | string & {
[0]: Prefix;
};
/**
* Multibase encoder for the specific base encoding encodes bytes into
* multibase of that encoding.
*/
export interface MultibaseEncoder<Prefix extends string> {
/**
* Name of the encoding.
*/
name: string;
/**
* Prefix character for that base encoding.
*/
prefix: Prefix;
/**
* Encodes binary data into **multibase** string (which will have a
* prefix added).
*/
encode: (bytes: Uint8Array) => Multibase<Prefix>;
}
/**
* Interface implemented by multibase decoder, that takes multibase strings
* to bytes. It may support single encoding like base32 or multiple encodings
* like base32, base58btc, base64. If passed multibase is incompatible it will
* throw an exception.
*/
export interface MultibaseDecoder<Prefix extends string> {
/**
* Decodes **multibase** string (which must have a multibase prefix added).
* If prefix does not match
*
* @param multibase
*/
decode: (multibase: Multibase<Prefix>) => Uint8Array;
}
/**
* Dual of multibase encoder and decoder.
*/
export interface MultibaseCodec<Prefix extends string> {
name: string;
prefix: Prefix;
encoder: MultibaseEncoder<Prefix>;
decoder: MultibaseDecoder<Prefix>;
}
export interface UnibaseDecoder<Prefix extends string> extends MultibaseDecoder<Prefix> {
readonly decoders?: null;
readonly prefix: Prefix;
}
export interface CombobaseDecoder<Prefix extends string> extends MultibaseDecoder<Prefix> {
readonly decoders: Record<Prefix, UnibaseDecoder<Prefix>>;
}
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/bases/interface.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,MAAM,CAAA;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,CAAA;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,WAAW,CAAA;IACpB,OAAO,EAAE,WAAW,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,MAAM,IACvC,MAAM,GACN,MAAM,GAAG;IAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5B;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,MAAM,SAAS,MAAM;IACrD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC,MAAM,CAAC,CAAA;CACjD;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,MAAM,SAAS,MAAM;IACrD;;;;;OAKG;IACH,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,KAAK,UAAU,CAAA;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,MAAM;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,MAAM,CAAE,SAAQ,gBAAgB,CAAC,MAAM,CAAC;IAErF,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAA;IAExB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,gBAAgB,CAAC,MAAM,SAAS,MAAM,CAAE,SAAQ,gBAAgB,CAAC,MAAM,CAAC;IACvF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;CAC1D"}
+49
View File
@@ -0,0 +1,49 @@
import { CID } from "./index.js";
import { hasher } from "./index.js";
import { digest } from "./index.js";
import { varint } from "./index.js";
import { bytes } from "./index.js";
export const hashes: {
identity: {
code: number;
name: string;
encode: (input: Uint8Array) => Uint8Array;
digest: (input: Uint8Array) => digest.Digest<0, number>;
};
sha256: hasher.Hasher<"sha2-256", 18>;
sha512: hasher.Hasher<"sha2-512", 19>;
};
export const bases: {
base256emoji: import("./bases/base.js").Codec<"base256emoji", "🚀">;
base64: import("./bases/base.js").Codec<"base64", "m">;
base64pad: import("./bases/base.js").Codec<"base64pad", "M">;
base64url: import("./bases/base.js").Codec<"base64url", "u">;
base64urlpad: import("./bases/base.js").Codec<"base64urlpad", "U">;
base58btc: import("./bases/base.js").Codec<"base58btc", "z">;
base58flickr: import("./bases/base.js").Codec<"base58flickr", "Z">;
base36: import("./bases/base.js").Codec<"base36", "k">;
base36upper: import("./bases/base.js").Codec<"base36upper", "K">;
base32: import("./bases/base.js").Codec<"base32", "b">;
base32upper: import("./bases/base.js").Codec<"base32upper", "B">;
base32pad: import("./bases/base.js").Codec<"base32pad", "c">;
base32padupper: import("./bases/base.js").Codec<"base32padupper", "C">;
base32hex: import("./bases/base.js").Codec<"base32hex", "v">;
base32hexupper: import("./bases/base.js").Codec<"base32hexupper", "V">;
base32hexpad: import("./bases/base.js").Codec<"base32hexpad", "t">;
base32hexpadupper: import("./bases/base.js").Codec<"base32hexpadupper", "T">;
base32z: import("./bases/base.js").Codec<"base32z", "h">;
base16: import("./bases/base.js").Codec<"base16", "f">;
base16upper: import("./bases/base.js").Codec<"base16upper", "F">;
base10: import("./bases/base.js").Codec<"base10", "9">;
base8: import("./bases/base.js").Codec<"base8", "7">;
base2: import("./bases/base.js").Codec<"base2", "0">;
identity: import("./bases/base.js").Codec<"identity", "\0">;
};
export namespace codecs {
export { raw };
export { json };
}
import * as raw from "./codecs/raw.js";
import * as json from "./codecs/json.js";
export { CID, hasher, digest, varint, bytes };
//# sourceMappingURL=basics.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../../src/basics.js"],"names":[],"mappings":";;;;;AAqBA;;;;;;;;;EAAuC;AADvC;;;;;;;;;;;;;;;;;;;;;;;;;EAAwI"}
+109
View File
@@ -0,0 +1,109 @@
export type RequiredCreateOptions = {
cid: CID;
};
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} Code - multicodec code corresponding to codec used to encode the block
* @template {number} Alg - multicodec code corresponding to the hashing algorithm used in CID creation.
* @param {object} options
* @param {T} options.value
* @param {API.BlockEncoder<Code, T>} options.codec
* @param {API.MultihashHasher<Alg>} options.hasher
* @returns {Promise<API.BlockView<T, Code, Alg>>}
*/
export function encode<T extends unknown, Code extends number, Alg extends number>({ value, codec, hasher }: {
value: T;
codec: API.BlockEncoder<Code, T>;
hasher: API.MultihashHasher<Alg>;
}): Promise<API.BlockView<T, Code, Alg, 1>>;
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} Code - multicodec code corresponding to codec used to encode the block
* @template {number} Alg - multicodec code corresponding to the hashing algorithm used in CID creation.
* @param {object} options
* @param {API.ByteView<T>} options.bytes
* @param {API.BlockDecoder<Code, T>} options.codec
* @param {API.MultihashHasher<Alg>} options.hasher
* @returns {Promise<API.BlockView<T, Code, Alg>>}
*/
export function decode<T extends unknown, Code extends number, Alg extends number>({ bytes, codec, hasher }: {
bytes: API.ByteView<T>;
codec: API.BlockDecoder<Code, T>;
hasher: API.MultihashHasher<Alg>;
}): Promise<API.BlockView<T, Code, Alg, 1>>;
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} Code - multicodec code corresponding to codec used to encode the block
* @template {number} Alg - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template {API.Version} V - CID version
* @param {object} options
* @param {API.Link<T, Code, Alg, V>} options.cid
* @param {API.ByteView<T>} options.bytes
* @param {API.BlockDecoder<Code, T>} options.codec
* @param {API.MultihashHasher<Alg>} options.hasher
* @returns {Promise<API.BlockView<T, Code, Alg, V>>}
*/
export function create<T extends unknown, Code extends number, Alg extends number, V extends API.Version>({ bytes, cid, hasher, codec }: {
cid: API.Link<T, Code, Alg, V>;
bytes: API.ByteView<T>;
codec: API.BlockDecoder<Code, T>;
hasher: API.MultihashHasher<Alg>;
}): Promise<API.BlockView<T, Code, Alg, V>>;
/**
* @typedef {object} RequiredCreateOptions
* @property {CID} options.cid
*/
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} Code - multicodec code corresponding to codec used to encode the block
* @template {number} Alg - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template {API.Version} V - CID version
* @param {{ cid: API.Link<T, Code, Alg, V>, value:T, codec?: API.BlockDecoder<Code, T>, bytes: API.ByteView<T> }|{cid:API.Link<T, Code, Alg, V>, bytes:API.ByteView<T>, value?:void, codec:API.BlockDecoder<Code, T>}} options
* @returns {API.BlockView<T, Code, Alg, V>}
*/
export function createUnsafe<T extends unknown, Code extends number, Alg extends number, V extends API.Version>({ bytes, cid, value: maybeValue, codec }: {
cid: API.Link<T, Code, Alg, V>;
value: T;
codec?: API.BlockDecoder<Code, T> | undefined;
bytes: API.ByteView<T>;
} | {
cid: API.Link<T, Code, Alg, V>;
bytes: API.ByteView<T>;
value?: void | undefined;
codec: API.BlockDecoder<Code, T>;
}): API.BlockView<T, Code, Alg, V>;
/**
* @template {unknown} T - Logical type of the data encoded in the block
* @template {number} C - multicodec code corresponding to codec used to encode the block
* @template {number} A - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template {API.Version} V - CID version
* @implements {API.BlockView<T, C, A, V>}
*/
export class Block<T extends unknown, C extends number, A extends number, V extends API.Version> implements API.BlockView<T, C, A, V> {
/**
* @param {object} options
* @param {CID<T, C, A, V>} options.cid
* @param {API.ByteView<T>} options.bytes
* @param {T} options.value
*/
constructor({ cid, bytes, value }: {
cid: CID<T, C, A, V>;
bytes: API.ByteView<T>;
value: T;
});
cid: CID<T, C, A, V>;
bytes: API.ByteView<T>;
value: T;
asBlock: Block<T, C, A, V>;
links(): Iterable<[string, CID<any, number, number, API.Version>]>;
tree(): Iterable<string>;
/**
*
* @param {string} [path]
* @returns {API.BlockCursorView<unknown>}
*/
get(path?: string | undefined): API.BlockCursorView<unknown>;
}
import * as API from "./interface.js";
import { CID } from "./index.js";
//# sourceMappingURL=block.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/block.js"],"names":[],"mappings":";SAwNc,GAAG;;AAlDjB;;;;;;;;;GASG;AACH;;;;4CAcC;AAED;;;;;;;;;GASG;AACH;;;;4CAUC;AA8BD;;;;;;;;;;;GAWG;AACH;;;;;4CAeC;AAvDD;;;GAGG;AAEH;;;;;;;GAOG;AACH;;;;;;;;;;mCAaC;AA3HD;;;;;;GAMG;AACH,4GAFgB,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAGtC;;;;;OAKG;IACH;QAJoC,GAAG,EAA5B,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACU,KAAK,EAA9B,IAAI,QAAQ,CAAC,CAAC,CAAC;QACJ,KAAK,EAAhB,CAAC;OAiBX;IAZC,qBAAc;IACd,uBAAkB;IAClB,SAAkB;IAClB,2BAAmB;IAWrB,mEAEC;IAED,yBAEC;IAED;;;;OAIG;IACH,gCAFa,IAAI,eAAe,CAAC,OAAO,CAAC,CAIxC;CACF"}
@@ -0,0 +1,58 @@
import { Link, Version } from '../link/interface.js';
import { CID } from '../cid.js';
/**
* A byte-encoded representation of some type of `Data`.
*
* A `ByteView` is essentially a `Uint8Array` that's been "tagged" with
* a `Data` type parameter indicating the type of encoded data.
*
* For example, a `ByteView<{ hello: "world" }>` is a `Uint8Array` containing a
* binary representation of a `{hello: "world"}`.
*/
export interface ByteView<Data> extends Uint8Array, Phantom<Data> {
}
declare const Marker: unique symbol;
/**
* A utility type to retain an unused type parameter `T`.
* Similar to [phantom type parameters in Rust](https://doc.rust-lang.org/rust-by-example/generics/phantom.html).
*
* Capturing unused type parameters allows us to define "nominal types," which
* TypeScript does not natively support. Nominal types in turn allow us to capture
* semantics not represented in the actual type structure, without requiring us to define
* new classes or pay additional runtime costs.
*
* For a concrete example, see {@link ByteView}, which extends the `Uint8Array` type to capture
* type information about the structure of the data encoded into the array.
*/
export interface Phantom<T> {
[Marker]?: T;
}
/**
* Represents an IPLD block (including its CID) that can be decoded to data of
* type `T`.
*
* @template T - Logical type of the data encoded in the block
* @template C - multicodec code corresponding to codec used to encode the block
* @template A - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template V - CID version
*/
export interface Block<T = unknown, C extends number = number, A extends number = number, V extends Version = 1> {
bytes: ByteView<T>;
cid: Link<T, C, A, V>;
}
export type BlockCursorView<T extends unknown = unknown> = {
value: T;
remaining?: undefined;
} | {
value: CID;
remaining: string;
};
export interface BlockView<T = unknown, C extends number = number, A extends number = number, V extends Version = 1> extends Block<T, C, A, V> {
cid: CID<T, C, A, V>;
value: T;
links: () => Iterable<[string, CID]>;
tree: () => Iterable<string>;
get: (path: string) => BlockCursorView<unknown>;
}
export {};
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/block/interface.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE/B;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ,CAAC,IAAI,CAAE,SAAQ,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC;CAAG;AAEpE,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,CAAA;AAEnC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC;IAIxB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,KAAK,CACpB,CAAC,GAAG,OAAO,EACX,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,OAAO,GAAG,CAAC;IAErB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;IAClB,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CACtB;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IACnD;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,GACnC;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAErC,MAAM,WAAW,SAAS,CACxB,CAAC,GAAG,OAAO,EACX,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,OAAO,GAAG,CAAC,CACrB,SAAQ,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACzB,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACpB,KAAK,EAAE,CAAC,CAAA;IAER,KAAK,EAAE,MAAM,QAAQ,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;IACpC,IAAI,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC5B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,eAAe,CAAC,OAAO,CAAC,CAAA;CAChD"}
+35
View File
@@ -0,0 +1,35 @@
/**
* @param {Uint8Array} aa
* @param {Uint8Array} bb
*/
export function equals(aa: Uint8Array, bb: Uint8Array): boolean;
/**
* @param {ArrayBufferView|ArrayBuffer|Uint8Array} o
* @returns {Uint8Array}
*/
export function coerce(o: ArrayBufferView | ArrayBuffer | Uint8Array): Uint8Array;
/**
* @param {any} o
* @returns {o is ArrayBuffer|ArrayBufferView}
*/
export function isBinary(o: any): o is ArrayBufferView | ArrayBuffer;
/**
* @param {string} hex
*/
export function fromHex(hex: string): Uint8Array;
/**
* @param {Uint8Array} d
*/
export function toHex(d: Uint8Array): string;
/**
* @param {string} str
* @returns {Uint8Array}
*/
export function fromString(str: string): Uint8Array;
/**
* @param {Uint8Array} b
* @returns {string}
*/
export function toString(b: Uint8Array): string;
export const empty: Uint8Array;
//# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../src/bytes.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,2BAHW,UAAU,MACV,UAAU,WAepB;AAED;;;GAGG;AACH,0BAHW,eAAe,GAAC,WAAW,GAAC,UAAU,GACpC,UAAU,CAStB;AAED;;;GAGG;AACH,4BAHW,GAAG,sCAIqC;AA7CnD;;GAEG;AACH,6BAFW,MAAM,cAKhB;AAXD;;GAEG;AACH,yBAFW,UAAU,UAEmE;AAiDxF;;;GAGG;AACH,gCAHW,MAAM,GACJ,UAAU,CAEkC;AAEzD;;;GAGG;AACH,4BAHW,UAAU,GACR,MAAM,CAEgC;AAhEnD,+BAA+B"}
+199
View File
@@ -0,0 +1,199 @@
export * from "./link/interface.js";
export function format<T extends API.Link<unknown, number, number, API.Version>, Prefix extends string>(link: T, base?: API.MultibaseEncoder<Prefix> | undefined): API.ToString<T, Prefix>;
export function toJSON<Link extends API.UnknownLink>(link: Link): API.LinkJSON<Link>;
export function fromJSON<Link extends API.UnknownLink>(json: API.LinkJSON<Link>): CID<unknown, number, number, API.Version>;
/**
* @template {unknown} [Data=unknown]
* @template {number} [Format=number]
* @template {number} [Alg=number]
* @template {API.Version} [Version=API.Version]
* @implements {API.Link<Data, Format, Alg, Version>}
*/
export class CID<Data extends unknown = unknown, Format extends number = number, Alg extends number = number, Version extends API.Version = API.Version> implements API.Link<Data, Format, Alg, Version> {
/**
* @template {unknown} Data
* @template {number} Format
* @template {number} Alg
* @template {API.Version} Version
* @param {API.Link<Data, Format, Alg, Version>} self
* @param {unknown} other
* @returns {other is CID}
*/
static equals<Data_1 extends unknown, Format_1 extends number, Alg_1 extends number, Version_1 extends API.Version>(self: API.Link<Data_1, Format_1, Alg_1, Version_1>, other: unknown): other is CID<any, number, number, API.Version>;
/**
* Takes any input `value` and returns a `CID` instance if it was
* a `CID` otherwise returns `null`. If `value` is instanceof `CID`
* it will return value back. If `value` is not instance of this CID
* class, but is compatible CID it will return new instance of this
* `CID` class. Otherwise returns null.
*
* This allows two different incompatible versions of CID library to
* co-exist and interop as long as binary interface is compatible.
*
* @template {unknown} Data
* @template {number} Format
* @template {number} Alg
* @template {API.Version} Version
* @template {unknown} U
* @param {API.Link<Data, Format, Alg, Version>|U} input
* @returns {CID<Data, Format, Alg, Version>|null}
*/
static asCID<Data_2 extends unknown, Format_2 extends number, Alg_2 extends number, Version_2 extends API.Version, U extends unknown>(input: U | API.Link<Data_2, Format_2, Alg_2, Version_2>): CID<Data_2, Format_2, Alg_2, Version_2> | null;
/**
*
* @template {unknown} Data
* @template {number} Format
* @template {number} Alg
* @template {API.Version} Version
* @param {Version} version - Version of the CID
* @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
* @param {API.MultihashDigest<Alg>} digest - (Multi)hash of the of the content.
* @returns {CID<Data, Format, Alg, Version>}
*/
static create<Data_3 extends unknown, Format_3 extends number, Alg_3 extends number, Version_3 extends API.Version>(version: Version_3, code: Format_3, digest: API.MultihashDigest<Alg_3>): CID<Data_3, Format_3, Alg_3, Version_3>;
/**
* Simplified version of `create` for CIDv0.
*
* @template {unknown} [T=unknown]
* @param {API.MultihashDigest<typeof SHA_256_CODE>} digest - Multihash.
* @returns {CID<T, typeof DAG_PB_CODE, typeof SHA_256_CODE, 0>}
*/
static createV0<T extends unknown = unknown>(digest: API.MultihashDigest<typeof SHA_256_CODE>): CID<T, 112, 18, 0>;
/**
* Simplified version of `create` for CIDv1.
*
* @template {unknown} Data
* @template {number} Code
* @template {number} Alg
* @param {Code} code - Content encoding format code.
* @param {API.MultihashDigest<Alg>} digest - Miltihash of the content.
* @returns {CID<Data, Code, Alg, 1>}
*/
static createV1<Data_4 extends unknown, Code extends number, Alg_4 extends number>(code: Code, digest: API.MultihashDigest<Alg_4>): CID<Data_4, Code, Alg_4, 1>;
/**
* Decoded a CID from its binary representation. The byte array must contain
* only the CID with no additional bytes.
*
* An error will be thrown if the bytes provided do not contain a valid
* binary representation of a CID.
*
* @template {unknown} Data
* @template {number} Code
* @template {number} Alg
* @template {API.Version} Ver
* @param {API.ByteView<API.Link<Data, Code, Alg, Ver>>} bytes
* @returns {CID<Data, Code, Alg, Ver>}
*/
static decode<Data_5 extends unknown, Code_1 extends number, Alg_5 extends number, Ver extends API.Version>(bytes: API.ByteView<API.Link<Data_5, Code_1, Alg_5, Ver>>): CID<Data_5, Code_1, Alg_5, Ver>;
/**
* Decoded a CID from its binary representation at the beginning of a byte
* array.
*
* Returns an array with the first element containing the CID and the second
* element containing the remainder of the original byte array. The remainder
* will be a zero-length byte array if the provided bytes only contained a
* binary CID representation.
*
* @template {unknown} T
* @template {number} C
* @template {number} A
* @template {API.Version} V
* @param {API.ByteView<API.Link<T, C, A, V>>} bytes
* @returns {[CID<T, C, A, V>, Uint8Array]}
*/
static decodeFirst<T_1 extends unknown, C extends number, A extends number, V extends API.Version>(bytes: API.ByteView<API.Link<T_1, C, A, V>>): [CID<T_1, C, A, V>, Uint8Array];
/**
* Inspect the initial bytes of a CID to determine its properties.
*
* Involves decoding up to 4 varints. Typically this will require only 4 to 6
* bytes but for larger multicodec code values and larger multihash digest
* lengths these varints can be quite large. It is recommended that at least
* 10 bytes be made available in the `initialBytes` argument for a complete
* inspection.
*
* @template {unknown} T
* @template {number} C
* @template {number} A
* @template {API.Version} V
* @param {API.ByteView<API.Link<T, C, A, V>>} initialBytes
* @returns {{ version:V, codec:C, multihashCode:A, digestSize:number, multihashSize:number, size:number }}
*/
static inspectBytes<T_2 extends unknown, C_1 extends number, A_1 extends number, V_1 extends API.Version>(initialBytes: API.ByteView<API.Link<T_2, C_1, A_1, V_1>>): {
version: V_1;
codec: C_1;
multihashCode: A_1;
digestSize: number;
multihashSize: number;
size: number;
};
/**
* Takes cid in a string representation and creates an instance. If `base`
* decoder is not provided will use a default from the configuration. It will
* throw an error if encoding of the CID is not compatible with supplied (or
* a default decoder).
*
* @template {string} Prefix
* @template {unknown} Data
* @template {number} Code
* @template {number} Alg
* @template {API.Version} Ver
* @param {API.ToString<API.Link<Data, Code, Alg, Ver>, Prefix>} source
* @param {API.MultibaseDecoder<Prefix>} [base]
* @returns {CID<Data, Code, Alg, Ver>}
*/
static parse<Prefix extends string, Data_6 extends unknown, Code_2 extends number, Alg_6 extends number, Ver_1 extends API.Version>(source: API.ToString<API.Link<Data_6, Code_2, Alg_6, Ver_1>, Prefix>, base?: API.MultibaseDecoder<Prefix> | undefined): CID<Data_6, Code_2, Alg_6, Ver_1>;
/**
* @param {Version} version - Version of the CID
* @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
* @param {API.MultihashDigest<Alg>} multihash - (Multi)hash of the of the content.
* @param {Uint8Array} bytes
*
*/
constructor(version: Version, code: Format, multihash: API.MultihashDigest<Alg>, bytes: Uint8Array);
/** @readonly */
readonly code: Format;
/** @readonly */
readonly version: Version;
/** @readonly */
readonly multihash: API.MultihashDigest<Alg>;
/** @readonly */
readonly bytes: Uint8Array;
/** @readonly */
readonly '/': Uint8Array;
/**
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
* please either use `CID.asCID(cid)` or switch to new signalling mechanism
*
* @deprecated
*/
get asCID(): CID<Data, Format, Alg, Version>;
get byteOffset(): number;
get byteLength(): number;
/**
* @returns {CID<Data, API.DAG_PB, API.SHA_256, 0>}
*/
toV0(): CID<Data, API.DAG_PB, API.SHA_256, 0>;
/**
* @returns {CID<Data, Format, Alg, 1>}
*/
toV1(): CID<Data, Format, Alg, 1>;
/**
* @param {unknown} other
* @returns {other is CID<Data, Format, Alg, Version>}
*/
equals(other: unknown): other is CID<Data, Format, Alg, Version>;
/**
* @param {API.MultibaseEncoder<string>} [base]
* @returns {string}
*/
toString(base?: API.MultibaseEncoder<string> | undefined): string;
toJSON(): {
'/': API.ToString<CID<Data, Format, Alg, Version>, string>;
};
link(): CID<Data, Format, Alg, Version>;
get [Symbol.toStringTag](): string;
}
import * as API from "./link/interface.js";
declare const SHA_256_CODE: 18;
declare const DAG_PB_CODE: 112;
//# sourceMappingURL=cid.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../../src/cid.js"],"names":[],"mappings":";AAmBO,2LAgBN;AAOM,qFAEL;AAMK,4HACe;AAmBtB;;;;;;GAMG;AAEH,oKAHgB,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO;IAgHjD;;;;;;;;OAQG;IACH,+KAHW,OAAO,kDAcjB;IA4BD;;;;;;;;;;;;;;;;;OAiBG;IACH,+OAoCC;IAED;;;;;;;;;;OAUG;IACH,qOA2BC;IAED;;;;;;OAMG;IACH,qDAHW,IAAI,eAAe,CAAC,mBAAmB,CAAC,sBAKlD;IAED;;;;;;;;;OASG;IACH,gKAEC;IAED;;;;;;;;;;;;;OAaG;IACH,wMAMC;IAED;;;;;;;;;;;;;;;OAeG;IACH,iLAuBC;IAED;;;;;;;;;;;;;;;OAeG;IACH;;;;oBAF+D,MAAM;uBAAgB,MAAM;cAAO,MAAM;MA+BvG;IAED;;;;;;;;;;;;;;OAcG;IACH,8RAaC;IA/ZD;;;;;;OAMG;IACH,qBANW,OAAO,QACP,MAAM,aACN,IAAI,eAAe,CAAC,GAAG,CAAC,SACxB,UAAU,EAiBpB;IAbC,gBAAgB;IAChB,sBAAgB;IAChB,gBAAgB;IAChB,0BAAsB;IACtB,gBAAgB;IAChB,6CAA0B;IAC1B,gBAAgB;IAChB,2BAAkB;IAIlB,gBAAgB;IAChB,yBAAiB;IAGnB;;;;;OAKG;IACH,6CAEC;IAGD,yBAEC;IAGD,yBAEC;IAED;;OAEG;IACH,QAFa,IAAI,IAAI,EAAE,IAAI,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC,CA+BjD;IAED;;OAEG;IACH,QAFa,IAAI,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAoBrC;IAED;;;OAGG;IACH,cAHW,OAAO,4CAKjB;IAwBD;;;OAGG;IACH,2DAFa,MAAM,CAIlB;IAED;;MAEC;IAED,wCAEC;IAED,mCAEC;CA4QF;;AAkFD,+BAAyB;AADzB,+BAAwB"}
@@ -0,0 +1,23 @@
import type { ByteView } from '../block/interface.js';
/**
* IPLD encoder part of the codec.
*/
export interface BlockEncoder<Code extends number, T> {
name: string;
code: Code;
encode: (data: T) => ByteView<T>;
}
/**
* IPLD decoder part of the codec.
*/
export interface BlockDecoder<Code extends number, T> {
code: Code;
decode: (bytes: ByteView<T>) => T;
}
/**
* An IPLD codec is a combination of both encoder and decoder.
*/
export interface BlockCodec<Code extends number, T> extends BlockEncoder<Code, T>, BlockDecoder<Code, T> {
}
export type { ByteView };
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/codecs/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC;IAClD,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,CAAE,SAAQ,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;CAAG;AAE3G,YAAY,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,6 @@
export const name: "json";
export const code: 512;
export function encode<T>(node: T): import("./interface.js").ByteView<T>;
export function decode<T>(data: import("./interface.js").ByteView<T>): T;
export type ByteView<T> = import('./interface.js').ByteView<T>;
//# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../../src/codecs/json.js"],"names":[],"mappings":"AAUA,0BAA0B;AAC1B,uBAA0B;AAOnB,yEAAiE;AAOjE,yEAA6D;0BArBvD,OAAO,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC"}
+10
View File
@@ -0,0 +1,10 @@
/**
* @template T
* @typedef {import('./interface.js').ByteView<T>} ByteView
*/
export const name: "raw";
export const code: 85;
export function encode(node: Uint8Array): ByteView<Uint8Array>;
export function decode(data: ByteView<Uint8Array>): Uint8Array;
export type ByteView<T> = import('./interface.js').ByteView<T>;
//# sourceMappingURL=raw.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../../../src/codecs/raw.js"],"names":[],"mappings":"AAIA;;;GAGG;AAEH,yBAAyB;AACzB,sBAAwB;AAMjB,6BAHI,UAAU,GACR,SAAS,UAAU,CAAC,CAEW;AAMrC,6BAHI,SAAS,UAAU,CAAC,GAClB,UAAU,CAEqB;0BAhB/B,OAAO,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,32 @@
export function create<Code extends number>(code: Code, digest: Uint8Array): Digest<Code, number>;
export function decode(multihash: Uint8Array): MultihashDigest;
export function equals(a: MultihashDigest, b: unknown): b is import("./interface.js").MultihashDigest<number>;
/**
* @typedef {import('./interface.js').MultihashDigest} MultihashDigest
*/
/**
* Represents a multihash digest which carries information about the
* hashing algorithm and an actual hash digest.
*
* @template {number} Code
* @template {number} Size
* @class
* @implements {MultihashDigest}
*/
export class Digest<Code extends number, Size extends number> implements MultihashDigest {
/**
* Creates a multihash digest.
*
* @param {Code} code
* @param {Size} size
* @param {Uint8Array} digest
* @param {Uint8Array} bytes
*/
constructor(code: Code, size: Size, digest: Uint8Array, bytes: Uint8Array);
code: Code;
size: Size;
digest: Uint8Array;
bytes: Uint8Array;
}
export type MultihashDigest = import('./interface.js').MultihashDigest;
//# sourceMappingURL=digest.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../../../src/hashes/digest.js"],"names":[],"mappings":"AAUO,gEAFI,UAAU,wBAapB;AAQM,kCAHI,UAAU,GACR,eAAe,CAa3B;AAOM,0BAJI,eAAe,KACf,OAAO,yDAgBjB;AAED;;GAEG;AAEH;;;;;;;;GAQG;AACH;IACE;;;;;;;OAOG;IACH,kBALW,IAAI,QACJ,IAAI,UACJ,UAAU,SACV,UAAU,EAOpB;IAJC,WAAgB;IAChB,WAAgB;IAChB,mBAAoB;IACpB,kBAAkB;CAErB;8BA3BY,OAAO,gBAAgB,EAAE,eAAe"}
@@ -0,0 +1,35 @@
export 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`.
*
* @template {string} Name
* @template {number} Code
* @class
* @implements {MultihashHasher<Code>}
*/
export class Hasher<Name extends string, Code extends number> implements MultihashHasher<Code> {
/**
*
* @param {Name} name
* @param {Code} code
* @param {(input: Uint8Array) => Await<Uint8Array>} encode
*/
constructor(name: Name, code: Code, encode: (input: Uint8Array) => Await<Uint8Array>);
name: Name;
code: Code;
encode: (input: Uint8Array) => Await<Uint8Array>;
/**
* @param {Uint8Array} input
* @returns {Await<Digest.Digest<Code, number>>}
*/
digest(input: Uint8Array): Await<Digest.Digest<Code, number>>;
}
export type MultihashHasher<Alg extends number> = import('./interface.js').MultihashHasher;
export type Await<T> = Promise<T> | T;
import * as Digest from "./digest.js";
//# sourceMappingURL=hasher.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"hasher.d.ts","sourceRoot":"","sources":["../../../../src/hashes/hasher.js"],"names":[],"mappings":"AAUO;;;oBAFY,UAAU,KAAK,MAAM,UAAU,CAAC;uBAE2B;AAE9E;;;;;;;;GAQG;AACH,yFAFgC,IAAI;IAGlC;;;;;OAKG;IACH,kBAJW,IAAI,QACJ,IAAI,kBACI,UAAU,KAAK,MAAM,UAAU,CAAC,EAMlD;IAHC,WAAgB;IAChB,WAAgB;IAChB,gBALiB,UAAU,KAAK,MAAM,UAAU,CAAC,CAK7B;IAGtB;;;OAGG;IACH,cAHW,UAAU,GACR,MAAM,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAa9C;CACF;kDAIY,OAAO,gBAAgB,EAAE,eAAe;uBAKxC,QAAQ,CAAC,CAAC,GAAC,CAAC"}
@@ -0,0 +1,18 @@
export namespace identity {
export { code };
export { name };
export { encode };
export { digest };
}
declare const code: 0;
declare const name: "identity";
/** @type {(input:Uint8Array) => Uint8Array} */
declare const encode: (input: Uint8Array) => Uint8Array;
/**
* @param {Uint8Array} input
* @returns {Digest.Digest<typeof code, number>}
*/
declare function digest(input: Uint8Array): Digest.Digest<typeof code, number>;
import * as Digest from "./digest.js";
export {};
//# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../../src/hashes/identity.js"],"names":[],"mappings":";;;;;;AAGA,sBAAgB;AAChB,+BAAuB;AAEvB,+CAA+C;AAC/C,8BADkB,UAAU,KAAK,UAAU,CACtB;AAErB;;;GAGG;AACH,+BAHW,UAAU,GACR,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAEa"}
@@ -0,0 +1,59 @@
/**
* 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.
*
* @param {Uint8Array} input
*/
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
@@ -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;;;;;;;OAOG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IAErF;;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,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,eAAe,CAAC,IAAI,CAAC,CAAA;CACrD"}
@@ -0,0 +1,3 @@
export const sha256: import("./hasher.js").Hasher<"sha2-256", 18>;
export const sha512: import("./hasher.js").Hasher<"sha2-512", 19>;
//# sourceMappingURL=sha2-browser.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"sha2-browser.d.ts","sourceRoot":"","sources":["../../../../src/hashes/sha2-browser.js"],"names":[],"mappings":"AAaA,kEAIE;AAEF,kEAIE"}
@@ -0,0 +1,3 @@
export const sha256: import("./hasher.js").Hasher<"sha2-256", 18>;
export const sha512: import("./hasher.js").Hasher<"sha2-512", 19>;
//# sourceMappingURL=sha2.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"sha2.d.ts","sourceRoot":"","sources":["../../../../src/hashes/sha2.js"],"names":[],"mappings":"AAMA,kEAIE;AAEF,kEAIE"}
+8
View File
@@ -0,0 +1,8 @@
export * from "./interface.js";
import { CID } from "./cid.js";
import * as hasher from "./hashes/hasher.js";
import * as digest from "./hashes/digest.js";
import * as varint from "./varint.js";
import * as bytes from "./bytes.js";
export { CID, hasher, digest, varint, bytes };
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
export * from './bases/interface.js';
export * from './hashes/interface.js';
export * from './codecs/interface.js';
export * from './link/interface.js';
export * from './block/interface.js';
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/interface.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA"}
+14
View File
@@ -0,0 +1,14 @@
export * from "./link/interface.js";
export function createLegacy(digest: API.MultihashDigest<typeof SHA_256_CODE>): API.LegacyLink;
export function create<Data extends unknown, Code extends number, Alg extends number>(code: Code, digest: API.MultihashDigest<Alg>): API.Link<Data, Code, Alg, 1>;
export function isLink<L extends API.Link<unknown, number, number, 0 | 1>>(value: unknown): value is L & CID<any, number, number, API.Version>;
export function parse<Prefix extends string, Data extends unknown, Code extends number, Alg extends number, Ver extends API.Version>(source: API.ToString<API.Link<Data, Code, Alg, Ver>, Prefix>, base?: API.MultibaseDecoder<Prefix> | undefined): API.Link<Data, Code, Alg, Ver>;
export function decode<Data extends unknown, Code extends number, Alg extends number, Ver extends API.Version>(bytes: API.ByteView<API.Link<Data, Code, Alg, Ver>>): API.Link<Data, Code, Alg, Ver>;
import * as API from "./link/interface.js";
declare const SHA_256_CODE: 18;
import { CID } from "./cid.js";
import { format } from "./cid.js";
import { toJSON } from "./cid.js";
import { fromJSON } from "./cid.js";
export { format, toJSON, fromJSON };
//# sourceMappingURL=link.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/link.js"],"names":[],"mappings":";AAiBO,qCAHI,IAAI,eAAe,CAAC,mBAAmB,CAAC,GACtC,IAAI,UAAU,CAE6C;AAYjE,kKAA4D;AAS5D,+IAkBN;AAiBM,oRAAuD;AAkBvD,oMAAyC;;AAlFhD,+BAAyB"}
@@ -0,0 +1,36 @@
import type { MultihashDigest } from '../hashes/interface.js';
import type { MultibaseEncoder, MultibaseDecoder, Multibase } from '../bases/interface.js';
import type { Phantom, ByteView } from '../block/interface.js';
export type { MultihashDigest, MultibaseEncoder, MultibaseDecoder };
export type Version = 0 | 1;
export type DAG_PB = 0x70;
export type SHA_256 = 0x12;
/**
* Represents an IPLD link to a specific data of type `T`.
*
* @template T - Logical type of the data being linked to.
* @template C - multicodec code corresponding to a codec linked data is encoded with
* @template A - multicodec code corresponding to the hashing algorithm of the CID
* @template V - CID version
*/
export interface Link<Data extends unknown = unknown, Format extends number = number, Alg extends number = number, V extends Version = 1> extends Phantom<Data> {
readonly version: V;
readonly code: Format;
readonly multihash: MultihashDigest<Alg>;
readonly byteOffset: number;
readonly byteLength: number;
readonly bytes: ByteView<Link<Data, Format, Alg, V>>;
equals: (other: unknown) => other is Link<Data, Format, Alg, Version>;
toString: <Prefix extends string>(base?: MultibaseEncoder<Prefix>) => ToString<Link<Data, Format, Alg, Version>, Prefix>;
link: () => Link<Data, Format, Alg, V>;
toV1: () => Link<Data, Format, Alg, 1>;
}
export interface LinkJSON<T extends UnknownLink = UnknownLink> {
'/': ToString<T>;
}
export interface LegacyLink<T extends unknown = unknown> extends Link<T, DAG_PB, SHA_256, 0> {
}
export type UnknownLink = LegacyLink<unknown> | Link<unknown, number, number, Version>;
export type ToString<T, Prefix extends string = string> = Multibase<Prefix> & Phantom<T>;
export type { ByteView };
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/link/interface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC1F,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAE9D,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAA;AACnE,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAA;AAE3B,MAAM,MAAM,MAAM,GAAG,IAAI,CAAA;AACzB,MAAM,MAAM,OAAO,GAAG,IAAI,CAAA;AAE1B;;;;;;;GAOG;AACH,MAAM,WAAW,IAAI,CACnB,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,CAAC,SAAS,OAAO,GAAG,CAAC,CACnB,SAAQ,OAAO,CAAC,IAAI,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG,CAAC,CAAA;IAExC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;IAEpD,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;IAErE,QAAQ,EAAE,CAAC,MAAM,SAAS,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAA;IACxH,IAAI,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;IAEtC,IAAI,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAC3D,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CACjB;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,CAAE,SAAQ,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;CAC3F;AAED,MAAM,MAAM,WAAW,GACnB,UAAU,CAAC,OAAO,CAAC,GACnB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AAE1C,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAExF,YAAY,EAAE,QAAQ,EAAE,CAAA"}
+27
View File
@@ -0,0 +1,27 @@
export type CID<C = number, A = number, V = 0 | 1> = import('./cid').CID<unknown, C, A, V>;
export type BlockView<T = unknown, C = number, A = number, V = 0 | 1> = import('./block/interface.js').BlockView<T, C, A, V>;
/**
* @template [C=number] - multicodec code corresponding to codec used to encode the block
* @template [A=number] - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template [V=0|1] - CID version
* @typedef {import('./cid').CID<unknown, C, A, V>} CID
*/
/**
* @template [T=unknown] - Logical type of the data encoded in the block
* @template [C=number] - multicodec code corresponding to codec used to encode the block
* @template [A=number] - multicodec code corresponding to the hashing algorithm used in CID creation.
* @template [V=0|1] - CID version
* @typedef {import('./block/interface.js').BlockView<T, C, A, V>} BlockView
*/
/**
* @param {object} options
* @param {CID} options.cid
* @param {(cid: CID) => Promise<BlockView|null>} options.load
* @param {Set<string>} [options.seen]
*/
export function walk({ cid, load, seen }: {
cid: CID;
load: (cid: CID) => Promise<BlockView | null>;
seen?: Set<string> | undefined;
}): Promise<void>;
//# sourceMappingURL=traversal.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../../../src/traversal.js"],"names":[],"mappings":"qDAMa,OAAO,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;wEAQrC,OAAO,sBAAsB,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAZjE;;;;;GAKG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AACH;SAJW,GAAG;gBACG,GAAG,KAAK,QAAQ,SAAS,GAAC,IAAI,CAAC;;kBAoB/C"}
+4
View File
@@ -0,0 +1,4 @@
export function decode(data: Uint8Array, offset?: number | undefined): [number, number];
export function encodeTo(int: number, target: Uint8Array, offset?: number | undefined): Uint8Array;
export function encodingLength(int: number): number;
//# sourceMappingURL=varint.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"varint.d.ts","sourceRoot":"","sources":["../../../src/varint.js"],"names":[],"mappings":"AAOO,6BAJI,UAAU,gCAER,CAAC,MAAM,EAAE,MAAM,CAAC,CAK5B;AAOM,8BAJI,MAAM,UACN,UAAU,2CAMpB;AAMM,oCAHI,MAAM,GACJ,MAAM,CAIlB"}
@@ -0,0 +1,8 @@
declare const _default: {
code: number;
size: number;
hex: string;
message: string;
}[];
export default _default;
//# sourceMappingURL=invalid-multihash.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"invalid-multihash.d.ts","sourceRoot":"","sources":["../../../../test/fixtures/invalid-multihash.js"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
declare const _default: ({
encoding: {
code: number;
name: string;
varint?: undefined;
};
hex: string;
size: number;
} | {
encoding: {
code: number;
name: string;
varint: string;
};
hex: string;
size: number;
})[];
export default _default;
//# sourceMappingURL=valid-multihash.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"valid-multihash.d.ts","sourceRoot":"","sources":["../../../../test/fixtures/valid-multihash.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-block.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-block.spec.d.ts","sourceRoot":"","sources":["../../../test/test-block.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-bytes.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-bytes.spec.d.ts","sourceRoot":"","sources":["../../../test/test-bytes.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-cid.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-cid.spec.d.ts","sourceRoot":"","sources":["../../../test/test-cid.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-link.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-link.spec.d.ts","sourceRoot":"","sources":["../../../test/test-link.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-multibase-spec.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-multibase-spec.spec.d.ts","sourceRoot":"","sources":["../../../test/test-multibase-spec.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-multibase.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-multibase.spec.d.ts","sourceRoot":"","sources":["../../../test/test-multibase.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-multicodec.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-multicodec.spec.d.ts","sourceRoot":"","sources":["../../../test/test-multicodec.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-multihash.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-multihash.spec.d.ts","sourceRoot":"","sources":["../../../test/test-multihash.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
export type CID = import('../src/cid.js').CID;
//# sourceMappingURL=test-traversal.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-traversal.spec.d.ts","sourceRoot":"","sources":["../../../test/test-traversal.spec.js"],"names":[],"mappings":"kBAQc,OAAO,eAAe,EAAE,GAAG"}
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=test-varint.spec.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"test-varint.spec.d.ts","sourceRoot":"","sources":["../../../test/test-varint.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
declare const main: () => Promise<void>;
export default main;
//# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../../test/ts-use/src/main.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,IAAI,qBAST,CAAA;AAED,eAAe,IAAI,CAAA"}