@ceramicnetwork/streamid 2.4.0 → 2.6.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commit-id.d.ts +8 -2
- package/lib/commit-id.d.ts.map +1 -1
- package/lib/commit-id.js +21 -63
- package/lib/commit-id.js.map +1 -1
- package/lib/reading-bytes.d.ts +0 -1
- package/lib/reading-bytes.d.ts.map +1 -1
- package/lib/reading-bytes.js +4 -11
- package/lib/reading-bytes.js.map +1 -1
- package/lib/stream-id.d.ts +7 -1
- package/lib/stream-id.d.ts.map +1 -1
- package/lib/stream-id.js +24 -28
- package/lib/stream-id.js.map +1 -1
- package/lib/stream-ref-parsing.d.ts +18 -0
- package/lib/stream-ref-parsing.d.ts.map +1 -0
- package/lib/stream-ref-parsing.js +82 -0
- package/lib/stream-ref-parsing.js.map +1 -0
- package/lib/stream-ref.d.ts +5 -1
- package/lib/stream-ref.d.ts.map +1 -1
- package/lib/stream-ref.js +32 -24
- package/lib/stream-ref.js.map +1 -1
- package/lib/try-catch.util.d.ts +2 -0
- package/lib/try-catch.util.d.ts.map +1 -0
- package/lib/try-catch.util.js +9 -0
- package/lib/try-catch.util.js.map +1 -0
- package/package.json +2 -2
package/lib/commit-id.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { CID } from 'multiformats/cid';
|
|
2
2
|
import { StreamID } from './stream-id.js';
|
|
3
|
-
import { StreamRef } from './stream-ref.js';
|
|
3
|
+
import type { StreamRef } from './stream-ref.js';
|
|
4
|
+
export declare class InvalidCommitIDBytesError extends Error {
|
|
5
|
+
constructor(bytes: Uint8Array);
|
|
6
|
+
}
|
|
7
|
+
export declare class InvalidCommitIDStringError extends Error {
|
|
8
|
+
constructor(input: string);
|
|
9
|
+
}
|
|
4
10
|
declare function fromBytes(bytes: Uint8Array): CommitID;
|
|
5
11
|
declare function fromBytesNoThrow(bytes: Uint8Array): CommitID | Error;
|
|
6
12
|
declare function fromString(input: string): CommitID;
|
|
@@ -15,7 +21,7 @@ export declare class CommitID implements StreamRef {
|
|
|
15
21
|
static fromStringNoThrow: typeof fromStringNoThrow;
|
|
16
22
|
static make: typeof make;
|
|
17
23
|
static isInstance(instance: any): instance is CommitID;
|
|
18
|
-
constructor(type: string | number, cid: CID | string, commit?: CID | string | number);
|
|
24
|
+
constructor(type: string | number, cid: CID | string, commit?: CID | string | number | null);
|
|
19
25
|
get baseID(): StreamID;
|
|
20
26
|
get type(): number;
|
|
21
27
|
get typeName(): string;
|
package/lib/commit-id.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-id.d.ts","sourceRoot":"","sources":["../src/commit-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"commit-id.d.ts","sourceRoot":"","sources":["../src/commit-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAOtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAIhD,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,KAAK,EAAE,UAAU;CAO9B;AAED,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,KAAK,EAAE,MAAM;CAG1B;AASD,iBAAS,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAM9C;AASD,iBAAS,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,GAAG,KAAK,CAE7D;AASD,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAM3C;AASD,iBAAS,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAE1D;AAOD,iBAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAEvE;AASD,qBAAa,QAAS,YAAW,SAAS;;IACxC,SAAS,CAAC,QAAQ,CAAC,IAAI,SAAM;IAM7B,MAAM,CAAC,SAAS,mBAAY;IAC5B,MAAM,CAAC,gBAAgB,0BAAmB;IAC1C,MAAM,CAAC,UAAU,oBAAa;IAC9B,MAAM,CAAC,iBAAiB,2BAAoB;IAC5C,MAAM,CAAC,IAAI,cAAO;IAKlB,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,IAAI,QAAQ;gBAgBpD,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,GAAG,EAAE,GAAG,GAAG,MAAM,EACjB,MAAM,GAAE,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,IAAW;IAY7C,IACI,MAAM,IAAI,QAAQ,CAErB;IAKD,IAAI,IAAI,IAAI,MAAM,CAEjB;IAKD,IACI,QAAQ,IAAI,MAAM,CAErB;IAKD,IAAI,GAAG,IAAI,GAAG,CAEb;IAKD,IACI,MAAM,IAAI,GAAG,CAEhB;IAKD,IACI,KAAK,IAAI,UAAU,CAMtB;IAKD,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAUhC,QAAQ,IAAI,MAAM;IAQlB,KAAK,IAAI,MAAM;IAoBf,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,GAAG,UAAU;CAG5C"}
|
package/lib/commit-id.js
CHANGED
|
@@ -26,80 +26,38 @@ import varint from 'varint';
|
|
|
26
26
|
import { concat as uint8ArrayConcat } from 'uint8arrays';
|
|
27
27
|
import { Memoize } from 'typescript-memoize';
|
|
28
28
|
import { STREAMID_CODEC } from './constants.js';
|
|
29
|
-
import { readCid, readVarint } from './reading-bytes.js';
|
|
30
29
|
import { StreamID } from './stream-id.js';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
import { tryCatch } from './try-catch.util.js';
|
|
31
|
+
import * as parsing from './stream-ref-parsing.js';
|
|
32
|
+
export class InvalidCommitIDBytesError extends Error {
|
|
33
|
+
constructor(bytes) {
|
|
34
|
+
super(`Error while parsing CommitID from bytes ${base36.encode(bytes)}: no commit information provided`);
|
|
35
35
|
}
|
|
36
|
-
return result;
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return new Error('fromBytes: invalid streamid, does not include streamid codec');
|
|
42
|
-
const [type, streamtypeRemainder] = readVarint(streamCodecRemainder);
|
|
43
|
-
const cidResult = readCid(streamtypeRemainder);
|
|
44
|
-
if (cidResult instanceof Error) {
|
|
45
|
-
return cidResult;
|
|
46
|
-
}
|
|
47
|
-
const [base, baseRemainder] = cidResult;
|
|
48
|
-
if (baseRemainder.length === 0) {
|
|
49
|
-
return new Error(`No commit information provided`);
|
|
50
|
-
}
|
|
51
|
-
else if (baseRemainder.length === 1) {
|
|
52
|
-
return new CommitID(type, base, baseRemainder[0]);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const [commit] = readCid(baseRemainder);
|
|
56
|
-
return new CommitID(type, base, commit);
|
|
37
|
+
export class InvalidCommitIDStringError extends Error {
|
|
38
|
+
constructor(input) {
|
|
39
|
+
super(`Error while parsing CommitID from string ${input}: no commit information provided`);
|
|
57
40
|
}
|
|
58
41
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
catch {
|
|
64
|
-
return undefined;
|
|
42
|
+
function fromBytes(bytes) {
|
|
43
|
+
const parsed = parsing.fromBytes(bytes, 'CommitID');
|
|
44
|
+
if (parsed.kind === 'commit-id') {
|
|
45
|
+
return new CommitID(parsed.type, parsed.genesis, parsed.commit);
|
|
65
46
|
}
|
|
47
|
+
throw new InvalidCommitIDBytesError(bytes);
|
|
66
48
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
return null;
|
|
70
|
-
const commitCID = parseCID(commit);
|
|
71
|
-
if (commitCID) {
|
|
72
|
-
if (genesis.equals(commitCID)) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return commitCID;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else if (String(commit) === '0') {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
throw new Error('Cannot specify commit as a number except to request commit 0 (the genesis commit)');
|
|
84
|
-
}
|
|
49
|
+
function fromBytesNoThrow(bytes) {
|
|
50
|
+
return tryCatch(() => fromBytes(bytes));
|
|
85
51
|
}
|
|
86
52
|
function fromString(input) {
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
|
|
53
|
+
const parsed = parsing.fromString(input, 'CommitID');
|
|
54
|
+
if (parsed.kind === 'commit-id') {
|
|
55
|
+
return new CommitID(parsed.type, parsed.genesis, parsed.commit);
|
|
90
56
|
}
|
|
91
|
-
|
|
57
|
+
throw new InvalidCommitIDStringError(input);
|
|
92
58
|
}
|
|
93
59
|
function fromStringNoThrow(input) {
|
|
94
|
-
|
|
95
|
-
if (protocolFree.includes('commit')) {
|
|
96
|
-
const commit = protocolFree.split('?')[1].split('=')[1];
|
|
97
|
-
const base = protocolFree.split('?')[0];
|
|
98
|
-
return make(StreamID.fromString(base), commit);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
return fromBytesNoThrow(base36.decode(protocolFree));
|
|
102
|
-
}
|
|
60
|
+
return tryCatch(() => fromString(input));
|
|
103
61
|
}
|
|
104
62
|
const TAG = Symbol.for('@ceramicnetwork/streamid/CommitID');
|
|
105
63
|
function make(stream, commit) {
|
|
@@ -117,7 +75,7 @@ export class CommitID {
|
|
|
117
75
|
throw new Error('constructor: cid required');
|
|
118
76
|
__classPrivateFieldSet(this, _CommitID_type, typeof type === 'string' ? StreamType.codeByName(type) : type, "f");
|
|
119
77
|
__classPrivateFieldSet(this, _CommitID_cid, typeof cid === 'string' ? CID.parse(cid) : cid, "f");
|
|
120
|
-
__classPrivateFieldSet(this, _CommitID_commit, parseCommit(__classPrivateFieldGet(this, _CommitID_cid, "f"), commit), "f");
|
|
78
|
+
__classPrivateFieldSet(this, _CommitID_commit, parsing.parseCommit(__classPrivateFieldGet(this, _CommitID_cid, "f"), commit), "f");
|
|
121
79
|
}
|
|
122
80
|
static isInstance(instance) {
|
|
123
81
|
return typeof instance === 'object' && '_tag' in instance && instance._tag === TAG;
|
package/lib/commit-id.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-id.js","sourceRoot":"","sources":["../src/commit-id.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"commit-id.js","sourceRoot":"","sources":["../src/commit-id.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,cAAc,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AAO,aAAa,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAA;IACvC,CAAC;IAWD,mGAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAC;QACxC,OAAO,YAAY,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAA;IACvC,CAAC;IAKD,CAAC,MAAM,CAAC,WAAW,CAAC;QAClB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;;AAjIM,kBAAS,GAAG,SAAS,CAAA;AACrB,yBAAgB,GAAG,gBAAgB,CAAA;AACnC,mBAAU,GAAG,UAAU,CAAA;AACvB,0BAAiB,GAAG,iBAAiB,CAAA;AACrC,aAAI,GAAG,IAAI,CAAA;AAoClB;IADC,OAAO,EAAE;8BACI,QAAQ;;sCAErB;AAaD;IADC,OAAO,EAAE;;;wCAGT;AAaD;IADC,OAAO,EAAE;8BACI,GAAG;;sCAEhB;AAMD;IADC,OAAO,EAAE;8BACG,UAAU;;qCAMtB;AAeD;IADC,OAAO,EAAE;;;;wCAGT;AAMD;IADC,OAAO,EAAE;;;;qCAGT"}
|
package/lib/reading-bytes.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CID } from 'multiformats/cid';
|
|
2
2
|
export declare function readVarint(bytes: Uint8Array): [number, Uint8Array, number];
|
|
3
3
|
export declare function readCid(bytes: Uint8Array): [CID, Uint8Array];
|
|
4
|
-
export declare function readCidNoThrow(bytes: Uint8Array): [CID, Uint8Array] | Error;
|
|
5
4
|
//# sourceMappingURL=reading-bytes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reading-bytes.d.ts","sourceRoot":"","sources":["../src/reading-bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAItC,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAK1E;AAMD,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"reading-bytes.d.ts","sourceRoot":"","sources":["../src/reading-bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAItC,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAK1E;AAMD,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAW5D"}
|
package/lib/reading-bytes.js
CHANGED
|
@@ -4,29 +4,22 @@ import { decode as decodeMultiHash } from 'multiformats/hashes/digest';
|
|
|
4
4
|
export function readVarint(bytes) {
|
|
5
5
|
const value = varint.decode(bytes);
|
|
6
6
|
const readLength = varint.decode.bytes;
|
|
7
|
-
const remainder = bytes.
|
|
7
|
+
const remainder = bytes.subarray(readLength);
|
|
8
8
|
return [value, remainder, readLength];
|
|
9
9
|
}
|
|
10
10
|
function isCidVersion(input) {
|
|
11
11
|
return input === 0 || input === 1;
|
|
12
12
|
}
|
|
13
13
|
export function readCid(bytes) {
|
|
14
|
-
const result = readCidNoThrow(bytes);
|
|
15
|
-
if (result instanceof Error) {
|
|
16
|
-
throw result;
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
export function readCidNoThrow(bytes) {
|
|
21
14
|
const [cidVersion, cidVersionRemainder] = readVarint(bytes);
|
|
22
15
|
if (!isCidVersion(cidVersion)) {
|
|
23
|
-
|
|
16
|
+
throw new Error(`Unknown CID version ${cidVersion}`);
|
|
24
17
|
}
|
|
25
18
|
const [codec, codecRemainder] = readVarint(cidVersionRemainder);
|
|
26
19
|
const [, mhCodecRemainder, mhCodecLength] = readVarint(codecRemainder);
|
|
27
20
|
const [mhLength, , mhLengthLength] = readVarint(mhCodecRemainder);
|
|
28
|
-
const multihashBytes = codecRemainder.
|
|
29
|
-
const multihashBytesRemainder = codecRemainder.
|
|
21
|
+
const multihashBytes = codecRemainder.subarray(0, mhCodecLength + mhLengthLength + mhLength);
|
|
22
|
+
const multihashBytesRemainder = codecRemainder.subarray(mhCodecLength + mhLengthLength + mhLength);
|
|
30
23
|
return [CID.create(cidVersion, codec, decodeMultiHash(multihashBytes)), multihashBytesRemainder];
|
|
31
24
|
}
|
|
32
25
|
//# sourceMappingURL=reading-bytes.js.map
|
package/lib/reading-bytes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reading-bytes.js","sourceRoot":"","sources":["../src/reading-bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEtE,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAClC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAA;IACtC,MAAM,SAAS,GAAG,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"reading-bytes.js","sourceRoot":"","sources":["../src/reading-bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEtE,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAClC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAA;IACtC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IAC5C,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAA;AACvC,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAiB;IACvC,MAAM,CAAC,UAAU,EAAE,mBAAmB,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IAC3D,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,uBAAuB,UAAU,EAAE,CAAC,CAAA;KACrD;IACD,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAA;IAC/D,MAAM,CAAC,EAAE,gBAAgB,EAAE,aAAa,CAAC,GAAG,UAAU,CAAC,cAAc,CAAC,CAAA;IACtE,MAAM,CAAC,QAAQ,EAAE,AAAD,EAAG,cAAc,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAA;IACjE,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,QAAQ,CAAC,CAAA;IAC5F,MAAM,uBAAuB,GAAG,cAAc,CAAC,QAAQ,CAAC,aAAa,GAAG,cAAc,GAAG,QAAQ,CAAC,CAAA;IAClG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,eAAe,CAAC,cAAc,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAA;AAClG,CAAC"}
|
package/lib/stream-id.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { CID } from 'multiformats/cid';
|
|
2
|
-
import { StreamRef } from './stream-ref.js';
|
|
2
|
+
import type { StreamRef } from './stream-ref.js';
|
|
3
|
+
export declare class InvalidStreamIDBytesError extends Error {
|
|
4
|
+
constructor(bytes: Uint8Array);
|
|
5
|
+
}
|
|
6
|
+
export declare class InvalidStreamIDStringError extends Error {
|
|
7
|
+
constructor(input: string);
|
|
8
|
+
}
|
|
3
9
|
declare function fromBytes(bytes: Uint8Array): StreamID;
|
|
4
10
|
declare function fromBytesNoThrow(bytes: Uint8Array): StreamID | Error;
|
|
5
11
|
declare function fromString(input: string): StreamID;
|
package/lib/stream-id.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-id.d.ts","sourceRoot":"","sources":["../src/stream-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"stream-id.d.ts","sourceRoot":"","sources":["../src/stream-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAStC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAKhD,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,KAAK,EAAE,UAAU;CAG9B;AAED,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,KAAK,EAAE,MAAM;CAG1B;AASD,iBAAS,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAM9C;AASD,iBAAS,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,GAAG,KAAK,CAE7D;AASD,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAM3C;AASD,iBAAS,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAE1D;AAaD,qBAAa,QAAS,YAAW,SAAS;IACxC,SAAS,CAAC,QAAQ,CAAC,IAAI,SAAM;IAE7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAK;IAE1B,MAAM,CAAC,SAAS,mBAAY;IAC5B,MAAM,CAAC,gBAAgB,0BAAmB;IAC1C,MAAM,CAAC,UAAU,oBAAa;IAC9B,MAAM,CAAC,iBAAiB,2BAAoB;IAK5C,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,IAAI,QAAQ;gBAiB1C,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM;WAuBvC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQhG,IAAI,IAAI,IAAI,MAAM,CAEjB;IAKD,IACI,QAAQ,IAAI,MAAM,CAErB;IAKD,IAAI,GAAG,IAAI,GAAG,CAEb;IAKD,IACI,KAAK,IAAI,UAAU,CAKtB;IAMD,IACI,MAAM,IAAI,QAAQ,CAErB;IAKD,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAYhC,QAAQ,IAAI,MAAM;IAQlB,KAAK,IAAI,MAAM;IAcf,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM;CAG/B"}
|
package/lib/stream-id.js
CHANGED
|
@@ -15,52 +15,48 @@ import varint from 'varint';
|
|
|
15
15
|
import * as codec from '@ipld/dag-cbor';
|
|
16
16
|
import { concat as uint8ArrayConcat } from 'uint8arrays';
|
|
17
17
|
import { STREAMID_CODEC } from './constants.js';
|
|
18
|
-
import { readCidNoThrow, readVarint } from './reading-bytes.js';
|
|
19
18
|
import { Memoize } from 'typescript-memoize';
|
|
20
19
|
import { StreamType } from './stream-type.js';
|
|
20
|
+
import { tryCatch } from './try-catch.util.js';
|
|
21
|
+
import * as parsing from './stream-ref-parsing.js';
|
|
22
|
+
export class InvalidStreamIDBytesError extends Error {
|
|
23
|
+
constructor(bytes) {
|
|
24
|
+
super(`Invalid StreamID bytes ${base36.encode(bytes)}: contains commit`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class InvalidStreamIDStringError extends Error {
|
|
28
|
+
constructor(input) {
|
|
29
|
+
super(`Invalid StreamID string ${input}: contains commit`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
21
32
|
function fromBytes(bytes) {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
|
|
33
|
+
const parsed = parsing.fromBytes(bytes, 'StreamID');
|
|
34
|
+
if (parsed.kind === 'stream-id') {
|
|
35
|
+
return new StreamID(parsed.type, parsed.genesis);
|
|
25
36
|
}
|
|
26
|
-
|
|
37
|
+
throw new InvalidStreamIDBytesError(bytes);
|
|
27
38
|
}
|
|
28
39
|
function fromBytesNoThrow(bytes) {
|
|
29
|
-
|
|
30
|
-
if (streamCodec !== STREAMID_CODEC)
|
|
31
|
-
return new Error('fromBytes: invalid streamid, does not include streamid codec');
|
|
32
|
-
const [type, streamTypeRemainder] = readVarint(streamCodecRemainder);
|
|
33
|
-
const cidResult = readCidNoThrow(streamTypeRemainder);
|
|
34
|
-
if (cidResult instanceof Error) {
|
|
35
|
-
return cidResult;
|
|
36
|
-
}
|
|
37
|
-
const [cid, cidRemainder] = cidResult;
|
|
38
|
-
if (cidRemainder.length > 0) {
|
|
39
|
-
return new Error(`Invalid StreamID: contains commit`);
|
|
40
|
-
}
|
|
41
|
-
return new StreamID(type, cid);
|
|
40
|
+
return tryCatch(() => fromBytes(bytes));
|
|
42
41
|
}
|
|
43
42
|
function fromString(input) {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
|
|
43
|
+
const parsed = parsing.fromString(input, 'StreamID');
|
|
44
|
+
if (parsed.kind === 'stream-id') {
|
|
45
|
+
return new StreamID(parsed.type, parsed.genesis);
|
|
47
46
|
}
|
|
48
|
-
|
|
47
|
+
throw new InvalidStreamIDStringError(input);
|
|
49
48
|
}
|
|
50
49
|
function fromStringNoThrow(input) {
|
|
51
|
-
|
|
52
|
-
const commitFree = protocolFree.includes('commit') ? protocolFree.split('?')[0] : protocolFree;
|
|
53
|
-
const bytes = base36.decode(commitFree);
|
|
54
|
-
return fromBytesNoThrow(bytes);
|
|
50
|
+
return tryCatch(() => fromString(input));
|
|
55
51
|
}
|
|
56
52
|
const TAG = Symbol.for('@ceramicnetwork/streamid/StreamID');
|
|
57
53
|
export class StreamID {
|
|
58
54
|
constructor(type, cid) {
|
|
59
55
|
this._tag = TAG;
|
|
60
56
|
if (!(type || type === 0))
|
|
61
|
-
throw new Error('constructor: type required');
|
|
57
|
+
throw new Error('StreamID constructor: type required');
|
|
62
58
|
if (!cid)
|
|
63
|
-
throw new Error('constructor: cid required');
|
|
59
|
+
throw new Error('StreamID constructor: cid required');
|
|
64
60
|
this._type = typeof type === 'string' ? StreamType.codeByName(type) : type;
|
|
65
61
|
this._cid = typeof cid === 'string' ? CID.parse(cid) : cid;
|
|
66
62
|
}
|
package/lib/stream-id.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-id.js","sourceRoot":"","sources":["../src/stream-id.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"stream-id.js","sourceRoot":"","sources":["../src/stream-id.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,O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AC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAMD,KAAK;QACH,OAAO,aAAa,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAA;IACvC,CAAC;IAKD,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACxC,OAAO,YAAY,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAA;IACvC,CAAC;IAKD,CAAC,MAAM,CAAC,WAAW,CAAC;QAClB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;;AAtIM,kBAAS,GAAG,SAAS,CAAA;AACrB,yBAAgB,GAAG,gBAAgB,CAAA;AACnC,mBAAU,GAAG,UAAU,CAAA;AACvB,0BAAiB,GAAG,iBAAiB,CAAA;AA6D5C;IADC,OAAO,EAAE;;;wCAGT;AAaD;IADC,OAAO,EAAE;8BACG,UAAU;;qCAKtB;AAOD;IADC,OAAO,EAAE;8BACI,QAAQ;;sCAErB;AAiBD;IADC,OAAO,EAAE;;;;wCAGT;AAMD;IADC,OAAO,EAAE;;;;qCAGT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CID } from 'multiformats/cid';
|
|
2
|
+
export declare type StreamIDComponents = {
|
|
3
|
+
kind: 'stream-id';
|
|
4
|
+
type: number;
|
|
5
|
+
genesis: CID;
|
|
6
|
+
};
|
|
7
|
+
export declare type CommitIDComponents = {
|
|
8
|
+
kind: 'commit-id';
|
|
9
|
+
type: number;
|
|
10
|
+
genesis: CID;
|
|
11
|
+
commit: CID | null;
|
|
12
|
+
};
|
|
13
|
+
export declare type StreamRefComponents = StreamIDComponents | CommitIDComponents;
|
|
14
|
+
export declare function fromBytes(input: Uint8Array, title?: string): StreamRefComponents;
|
|
15
|
+
export declare function fromString(input: string, title?: string): StreamRefComponents;
|
|
16
|
+
export declare function parseCID(input: any): CID | null;
|
|
17
|
+
export declare function parseCommit(genesis: CID, commit?: CID | string | number | null): CID | null;
|
|
18
|
+
//# sourceMappingURL=stream-ref-parsing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-ref-parsing.d.ts","sourceRoot":"","sources":["../src/stream-ref-parsing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE,WAAW,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,GAAG,CAAA;CACb,CAAA;AAED,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE,WAAW,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,GAAG,CAAA;IACZ,MAAM,EAAE,GAAG,GAAG,IAAI,CAAA;CACnB,CAAA;AAED,oBAAY,mBAAmB,GAAG,kBAAkB,GAAG,kBAAkB,CAAA;AAKzE,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,SAAc,GAAG,mBAAmB,CA+BrF;AAOD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAc,GAAG,mBAAmB,CAgBlF;AAQD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,CAM/C;AAWD,wBAAgB,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,GAAE,GAAG,GAAG,MAAM,GAAG,MAAM,GAAG,IAAW,GAAG,GAAG,GAAG,IAAI,CAiBjG"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { readCid, readVarint } from './reading-bytes.js';
|
|
2
|
+
import { STREAMID_CODEC } from './constants.js';
|
|
3
|
+
import { CID } from 'multiformats/cid';
|
|
4
|
+
import { base36 } from 'multiformats/bases/base36';
|
|
5
|
+
export function fromBytes(input, title = 'StreamRef') {
|
|
6
|
+
const [streamCodec, streamCodecRemainder] = readVarint(input);
|
|
7
|
+
if (streamCodec !== STREAMID_CODEC)
|
|
8
|
+
throw new Error(`Invalid ${title}, does not include streamid codec`);
|
|
9
|
+
const [type, streamtypeRemainder] = readVarint(streamCodecRemainder);
|
|
10
|
+
const cidResult = readCid(streamtypeRemainder);
|
|
11
|
+
const [genesis, genesisRemainder] = cidResult;
|
|
12
|
+
if (genesisRemainder.length === 0) {
|
|
13
|
+
return {
|
|
14
|
+
kind: 'stream-id',
|
|
15
|
+
type: type,
|
|
16
|
+
genesis: genesis,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
else if (genesisRemainder.length === 1 && genesisRemainder[0] === 0) {
|
|
20
|
+
return {
|
|
21
|
+
kind: 'commit-id',
|
|
22
|
+
type: type,
|
|
23
|
+
genesis: genesis,
|
|
24
|
+
commit: null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const [commit] = readCid(genesisRemainder);
|
|
29
|
+
return {
|
|
30
|
+
kind: 'commit-id',
|
|
31
|
+
type: type,
|
|
32
|
+
genesis: genesis,
|
|
33
|
+
commit: commit,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const URL_PATTERN = /(ceramic:\/\/|\/ceramic\/)?([a-zA-Z0-9]+)(\?commit=([a-zA-Z0-9]+))?/;
|
|
38
|
+
export function fromString(input, title = 'StreamRef') {
|
|
39
|
+
const protocolMatch = URL_PATTERN.exec(input) || [];
|
|
40
|
+
const base = protocolMatch[2];
|
|
41
|
+
if (!base)
|
|
42
|
+
throw new Error(`Malformed ${title} string: ${input}`);
|
|
43
|
+
const bytes = base36.decode(base);
|
|
44
|
+
const streamRef = fromBytes(bytes);
|
|
45
|
+
const commit = protocolMatch[4];
|
|
46
|
+
if (commit) {
|
|
47
|
+
return {
|
|
48
|
+
kind: 'commit-id',
|
|
49
|
+
type: streamRef.type,
|
|
50
|
+
genesis: streamRef.genesis,
|
|
51
|
+
commit: parseCommit(streamRef.genesis, commit),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return streamRef;
|
|
55
|
+
}
|
|
56
|
+
export function parseCID(input) {
|
|
57
|
+
try {
|
|
58
|
+
return typeof input === 'string' ? CID.parse(input) : CID.asCID(input);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function parseCommit(genesis, commit = null) {
|
|
65
|
+
if (!commit)
|
|
66
|
+
return null;
|
|
67
|
+
if (commit === '0')
|
|
68
|
+
return null;
|
|
69
|
+
const commitCID = parseCID(commit);
|
|
70
|
+
if (commitCID) {
|
|
71
|
+
if (genesis.equals(commitCID)) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return commitCID;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
throw new Error('Cannot specify commit as a number except to request commit 0 (the genesis commit)');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=stream-ref-parsing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-ref-parsing.js","sourceRoot":"","sources":["../src/stream-ref-parsing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAoBlD,MAAM,UAAU,SAAS,CAAC,KAAiB,EAAE,KAAK,GAAG,WAAW;IAC9D,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7D,IAAI,WAAW,KAAK,cAAc;QAChC,MAAM,IAAI,KAAK,CAAC,WAAW,KAAK,mCAAmC,CAAC,CAAA;IACtE,MAAM,CAAC,IAAI,EAA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CAAC,CAAC,CAAC,CAAA;IAC/B,IAAI,MAAM,EAAE;QACV,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,OAAO,EAAE,SAAS,CAAC,OAAO;YAC1B,MAAM,EAAE,WAAW,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;SAC/C,CAAA;KACF;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAQD,MAAM,UAAU,QAAQ,CAAC,KAAU;IACjC,IAAI;QACF,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;KACvE;IAAC,MAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAWD,MAAM,UAAU,WAAW,CAAC,OAAY,EAAE,SAAuC,IAAI;IACnF,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IAE/B,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IAClC,IAAI,SAAS,EAAE;QAEb,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAA;SACZ;aAAM;YACL,OAAO,SAAS,CAAA;SACjB;KACF;SAAM;QACL,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAA;KACF;AACH,CAAC"}
|
package/lib/stream-ref.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export interface StreamRef {
|
|
|
12
12
|
toUrl(): string;
|
|
13
13
|
}
|
|
14
14
|
export declare namespace StreamRef {
|
|
15
|
-
function
|
|
15
|
+
function fromBytes(input: Uint8Array): StreamID | CommitID;
|
|
16
|
+
function fromString(input: string): CommitID | StreamID;
|
|
17
|
+
function from(input: StreamID): StreamID;
|
|
18
|
+
function from(input: CommitID): CommitID;
|
|
19
|
+
function from(input: string | Uint8Array | unknown): StreamID | CommitID;
|
|
16
20
|
}
|
|
17
21
|
//# sourceMappingURL=stream-ref.d.ts.map
|
package/lib/stream-ref.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-ref.d.ts","sourceRoot":"","sources":["../src/stream-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"stream-ref.d.ts","sourceRoot":"","sources":["../src/stream-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAOzC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IACjB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAA;IACzB,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAA;IAC5B,QAAQ,IAAI,MAAM,CAAA;IAClB,KAAK,IAAI,MAAM,CAAA;CAChB;AAGD,yBAAiB,SAAS,CAAC;IACzB,SAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAUhE;IAED,SAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAU7D;IAKD,SAAgB,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/C,SAAgB,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/C,SAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAkBhF"}
|
package/lib/stream-ref.js
CHANGED
|
@@ -1,39 +1,47 @@
|
|
|
1
1
|
import { StreamID } from './stream-id.js';
|
|
2
2
|
import { CommitID } from './commit-id.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return f();
|
|
6
|
-
}
|
|
7
|
-
catch {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
3
|
+
import { base36 } from 'multiformats/bases/base36';
|
|
4
|
+
import * as parsing from './stream-ref-parsing.js';
|
|
11
5
|
export var StreamRef;
|
|
12
6
|
(function (StreamRef) {
|
|
7
|
+
function fromBytes(input) {
|
|
8
|
+
const parsed = parsing.fromBytes(input);
|
|
9
|
+
switch (parsed.kind) {
|
|
10
|
+
case 'commit-id':
|
|
11
|
+
return new CommitID(parsed.type, parsed.genesis, parsed.commit);
|
|
12
|
+
case 'stream-id':
|
|
13
|
+
return new StreamID(parsed.type, parsed.genesis);
|
|
14
|
+
default:
|
|
15
|
+
throw new Error(`Malformed StreamRef bytes: ${base36.encode(input)}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
StreamRef.fromBytes = fromBytes;
|
|
19
|
+
function fromString(input) {
|
|
20
|
+
const parsed = parsing.fromString(input);
|
|
21
|
+
switch (parsed.kind) {
|
|
22
|
+
case 'commit-id':
|
|
23
|
+
return new CommitID(parsed.type, parsed.genesis, parsed.commit);
|
|
24
|
+
case 'stream-id':
|
|
25
|
+
return new StreamID(parsed.type, parsed.genesis);
|
|
26
|
+
default:
|
|
27
|
+
throw new Error(`Malformed StreamRef string: ${input}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
StreamRef.fromString = fromString;
|
|
13
31
|
function from(input) {
|
|
14
32
|
if (StreamID.isInstance(input)) {
|
|
15
33
|
return input;
|
|
16
34
|
}
|
|
17
|
-
|
|
35
|
+
if (CommitID.isInstance(input)) {
|
|
18
36
|
return input;
|
|
19
37
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (commitId instanceof Error) {
|
|
23
|
-
return StreamID.fromBytes(input);
|
|
24
|
-
}
|
|
25
|
-
return commitId;
|
|
26
|
-
}
|
|
27
|
-
else if (typeof input === 'string') {
|
|
28
|
-
const commitId = CommitID.fromStringNoThrow(input);
|
|
29
|
-
if (commitId instanceof Error) {
|
|
30
|
-
return StreamID.fromString(input);
|
|
31
|
-
}
|
|
32
|
-
return commitId;
|
|
38
|
+
if (input instanceof Uint8Array) {
|
|
39
|
+
return fromBytes(input);
|
|
33
40
|
}
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
if (typeof input === 'string') {
|
|
42
|
+
return fromString(input);
|
|
36
43
|
}
|
|
44
|
+
throw new Error(`Can not build CommitID or StreamID from ${JSON.stringify(input)}`);
|
|
37
45
|
}
|
|
38
46
|
StreamRef.from = from;
|
|
39
47
|
})(StreamRef || (StreamRef = {}));
|
package/lib/stream-ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-ref.js","sourceRoot":"","sources":["../src/stream-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"stream-ref.js","sourceRoot":"","sources":["../src/stream-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,K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K,CAAC,EAAE;YAC9B,OAAO,KAAK,CAAA;SACb;QACD,IAAI,KAAK,YAAY,UAAU,EAAE;YAC/B,OAAO,SAAS,CAAC,KAAK,CAAC,CAAA;SACxB;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,UAAU,CAAC,KAAK,CAAC,CAAA;SACzB;QACD,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACrF,CAAC;IAhBe,cAAI,OAgBnB,CAAA;AACH,CAAC,EAhDgB,SAAS,KAAT,SAAS,QAgDzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"try-catch.util.d.ts","sourceRoot":"","sources":["../src/try-catch.util.ts"],"names":[],"mappings":"AAGA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAMlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"try-catch.util.js","sourceRoot":"","sources":["../src/try-catch.util.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,QAAQ,CAAI,EAAW;IACrC,IAAI;QACF,OAAO,EAAE,EAAE,CAAA;KACZ;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAU,CAAA;KAClB;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ceramicnetwork/streamid",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0-rc.0",
|
|
4
4
|
"description": "Ceramic Stream Ids",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ceramic",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "b839eaf03024cbd4df4029281d9a8821fa931192"
|
|
43
43
|
}
|