@atproto/lex-data 0.0.10 → 0.0.12
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/CHANGELOG.md +14 -0
- package/dist/blob.d.ts +143 -6
- package/dist/blob.d.ts.map +1 -1
- package/dist/blob.js +23 -0
- package/dist/blob.js.map +1 -1
- package/dist/cid.d.ts +211 -27
- package/dist/cid.d.ts.map +1 -1
- package/dist/cid.js +115 -19
- package/dist/cid.js.map +1 -1
- package/dist/lex-equals.d.ts +38 -0
- package/dist/lex-equals.d.ts.map +1 -1
- package/dist/lex-equals.js +38 -0
- package/dist/lex-equals.js.map +1 -1
- package/dist/lex-error.d.ts +80 -1
- package/dist/lex-error.d.ts.map +1 -1
- package/dist/lex-error.js +49 -1
- package/dist/lex-error.js.map +1 -1
- package/dist/lex.d.ts +184 -2
- package/dist/lex.d.ts.map +1 -1
- package/dist/lex.js +113 -34
- package/dist/lex.js.map +1 -1
- package/dist/object.d.ts +54 -4
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +54 -4
- package/dist/object.js.map +1 -1
- package/dist/uint8array.d.ts +96 -4
- package/dist/uint8array.d.ts.map +1 -1
- package/dist/uint8array.js +96 -4
- package/dist/uint8array.js.map +1 -1
- package/dist/utf8.d.ts +77 -0
- package/dist/utf8.d.ts.map +1 -1
- package/dist/utf8.js +77 -0
- package/dist/utf8.js.map +1 -1
- package/package.json +2 -2
- package/src/blob.ts +143 -6
- package/src/cid-implementation.test.ts +7 -13
- package/src/cid.test.ts +14 -14
- package/src/cid.ts +228 -52
- package/src/lex-equals.ts +38 -0
- package/src/lex-error.ts +80 -1
- package/src/lex.test.ts +3 -3
- package/src/lex.ts +198 -30
- package/src/object.ts +54 -4
- package/src/uint8array.ts +96 -4
- package/src/utf8.ts +77 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atproto/lex-data
|
|
2
2
|
|
|
3
|
+
## 0.0.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4660](https://github.com/bluesky-social/atproto/pull/4660) [`ea5df64`](https://github.com/bluesky-social/atproto/commit/ea5df64db9e408d2b320f5f75eb2878aef6bc6df) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Minor code simplification
|
|
8
|
+
|
|
9
|
+
## 0.0.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#4601](https://github.com/bluesky-social/atproto/pull/4601) [`ed61c62`](https://github.com/bluesky-social/atproto/commit/ed61c62f3161fcde85ee9a93f8ed339c7e06c015) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Fix `exports` field in package.json
|
|
14
|
+
|
|
15
|
+
- [#4601](https://github.com/bluesky-social/atproto/pull/4601) [`ed61c62`](https://github.com/bluesky-social/atproto/commit/ed61c62f3161fcde85ee9a93f8ed339c7e06c015) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add JSDoc
|
|
16
|
+
|
|
3
17
|
## 0.0.10
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/blob.d.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import { Cid, RawCid } from './cid.js';
|
|
2
2
|
import { LexValue } from './lex.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Reference to binary data (like images, videos, etc.) in the AT Protocol data model.
|
|
5
|
+
*
|
|
6
|
+
* A BlobRef is a {@link LexMap} with a specific structure that identifies binary
|
|
7
|
+
* content by its content hash (CID), along with metadata about the content type
|
|
8
|
+
* and size.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam Ref - The type of CID reference, defaults to any {@link Cid}
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import type { BlobRef } from '@atproto/lex-data'
|
|
15
|
+
*
|
|
16
|
+
* const imageRef: BlobRef = {
|
|
17
|
+
* $type: 'blob',
|
|
18
|
+
* mimeType: 'image/jpeg',
|
|
19
|
+
* ref: cid, // CID of the blob content
|
|
20
|
+
* size: 12345
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @see {@link isBlobRef} to check if a value is a valid BlobRef
|
|
25
|
+
* @see {@link LegacyBlobRef} for the older blob reference format
|
|
5
26
|
*/
|
|
6
27
|
export type BlobRef<Ref extends Cid = Cid> = {
|
|
7
28
|
$type: 'blob';
|
|
@@ -9,46 +30,162 @@ export type BlobRef<Ref extends Cid = Cid> = {
|
|
|
9
30
|
ref: Ref;
|
|
10
31
|
size: number;
|
|
11
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Options for validating a {@link BlobRef}.
|
|
35
|
+
*/
|
|
12
36
|
export type BlobRefCheckOptions = {
|
|
13
37
|
/**
|
|
14
38
|
* If `false`, skips strict CID validation of {@link BlobRef.ref}, allowing
|
|
15
39
|
* any valid CID. Otherwise, validates that the CID is v1, uses the raw
|
|
16
40
|
* multicodec, and has a sha256 multihash.
|
|
17
41
|
*
|
|
18
|
-
* @
|
|
42
|
+
* @default true
|
|
19
43
|
*/
|
|
20
44
|
strict?: boolean;
|
|
21
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Infers the BlobRef type based on the check options.
|
|
48
|
+
*
|
|
49
|
+
* @typeParam TOptions - The options used for checking
|
|
50
|
+
*/
|
|
22
51
|
export type InferCheckedBlobRef<TOptions extends BlobRefCheckOptions> = TOptions extends {
|
|
23
52
|
strict: false;
|
|
24
53
|
} ? BlobRef : {
|
|
25
54
|
strict: boolean;
|
|
26
55
|
} extends TOptions ? BlobRef : BlobRef<RawCid>;
|
|
56
|
+
/**
|
|
57
|
+
* Type guard to check if a value is a valid {@link BlobRef}.
|
|
58
|
+
*
|
|
59
|
+
* Validates the structure of the input including:
|
|
60
|
+
* - `$type` must be `'blob'`
|
|
61
|
+
* - `mimeType` must be a valid MIME type string (containing '/')
|
|
62
|
+
* - `size` must be a non-negative safe integer
|
|
63
|
+
* - `ref` must be a valid CID (strict validation by default)
|
|
64
|
+
*
|
|
65
|
+
* @param input - The value to check
|
|
66
|
+
* @param options - Optional validation options
|
|
67
|
+
* @returns `true` if the input is a valid BlobRef
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* import { isBlobRef } from '@atproto/lex-data'
|
|
72
|
+
*
|
|
73
|
+
* if (isBlobRef(data)) {
|
|
74
|
+
* console.log(data.mimeType) // e.g., 'image/jpeg'
|
|
75
|
+
* console.log(data.size) // e.g., 12345
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* // Allow any valid CID (not just raw CIDs)
|
|
79
|
+
* if (isBlobRef(data, { strict: false })) {
|
|
80
|
+
* // ...
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
27
84
|
export declare function isBlobRef(input: unknown): input is BlobRef<RawCid>;
|
|
28
85
|
export declare function isBlobRef<TOptions extends BlobRefCheckOptions>(input: unknown, options: TOptions): input is InferCheckedBlobRef<TOptions>;
|
|
29
86
|
export declare function isBlobRef(input: unknown, options?: BlobRefCheckOptions): input is BlobRef;
|
|
30
87
|
/**
|
|
31
|
-
*
|
|
88
|
+
* Legacy format for blob references used in older AT Protocol data.
|
|
89
|
+
*
|
|
90
|
+
* This is the older format that stores the CID as a string rather than
|
|
91
|
+
* as a structured CID object. New code should use {@link BlobRef} instead.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* import type { LegacyBlobRef } from '@atproto/lex-data'
|
|
96
|
+
*
|
|
97
|
+
* const legacyRef: LegacyBlobRef = {
|
|
98
|
+
* cid: 'bafyreib...',
|
|
99
|
+
* mimeType: 'image/jpeg'
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @see {@link isLegacyBlobRef} to check if a value is a LegacyBlobRef
|
|
104
|
+
* @see {@link BlobRef} for the current blob reference format
|
|
105
|
+
* @deprecated Use {@link BlobRef} for new code
|
|
32
106
|
*/
|
|
33
107
|
export type LegacyBlobRef = {
|
|
34
108
|
cid: string;
|
|
35
109
|
mimeType: string;
|
|
36
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Type guard to check if a value is a valid {@link LegacyBlobRef}.
|
|
113
|
+
*
|
|
114
|
+
* Validates the structure of the input:
|
|
115
|
+
* - `cid` must be a valid CID string
|
|
116
|
+
* - `mimeType` must be a non-empty string
|
|
117
|
+
* - No additional properties allowed
|
|
118
|
+
*
|
|
119
|
+
* @param input - The value to check
|
|
120
|
+
* @returns `true` if the input is a valid LegacyBlobRef
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { isLegacyBlobRef } from '@atproto/lex-data'
|
|
125
|
+
*
|
|
126
|
+
* if (isLegacyBlobRef(data)) {
|
|
127
|
+
* console.log(data.cid) // CID as string
|
|
128
|
+
* console.log(data.mimeType) // e.g., 'image/jpeg'
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @see {@link isBlobRef} for checking the current blob reference format
|
|
133
|
+
*/
|
|
37
134
|
export declare function isLegacyBlobRef(input: unknown): input is LegacyBlobRef;
|
|
135
|
+
/**
|
|
136
|
+
* Options for enumerating blob references within a {@link LexValue}.
|
|
137
|
+
*/
|
|
38
138
|
export type EnumBlobRefsOptions = BlobRefCheckOptions & {
|
|
39
139
|
/**
|
|
40
|
-
* @
|
|
140
|
+
* If `true`, also yields {@link LegacyBlobRef} objects in addition to
|
|
141
|
+
* {@link BlobRef} objects.
|
|
142
|
+
*
|
|
143
|
+
* @default false
|
|
41
144
|
*/
|
|
42
145
|
allowLegacy?: boolean;
|
|
43
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Infers the yielded type of {@link enumBlobRefs} based on options.
|
|
149
|
+
*
|
|
150
|
+
* @typeParam TOptions - The options used for enumeration
|
|
151
|
+
*/
|
|
44
152
|
export type InferEnumBlobRefs<TOptions extends EnumBlobRefsOptions> = TOptions extends {
|
|
45
153
|
allowLegacy: true;
|
|
46
154
|
} ? InferCheckedBlobRef<TOptions> | LegacyBlobRef : {
|
|
47
155
|
allowLegacy: boolean;
|
|
48
156
|
} extends TOptions ? InferCheckedBlobRef<TOptions> | LegacyBlobRef : InferCheckedBlobRef<TOptions>;
|
|
49
157
|
/**
|
|
50
|
-
*
|
|
51
|
-
* found within a {@link LexValue}.
|
|
158
|
+
* Generator that enumerates all {@link BlobRef}s (and, optionally,
|
|
159
|
+
* {@link LegacyBlobRef}s) found within a {@link LexValue}.
|
|
160
|
+
*
|
|
161
|
+
* Performs a deep traversal of the input value, yielding any blob references
|
|
162
|
+
* found. This is useful for extracting all media references from a record.
|
|
163
|
+
*
|
|
164
|
+
* @param input - The LexValue to search for blob references
|
|
165
|
+
* @param options - Optional configuration for the enumeration
|
|
166
|
+
* @yields Each blob reference found in the input
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* import { enumBlobRefs } from '@atproto/lex-data'
|
|
171
|
+
*
|
|
172
|
+
* const record = {
|
|
173
|
+
* text: 'Hello',
|
|
174
|
+
* images: [
|
|
175
|
+
* { $type: 'blob', mimeType: 'image/jpeg', ref: cid1, size: 1000 },
|
|
176
|
+
* { $type: 'blob', mimeType: 'image/png', ref: cid2, size: 2000 }
|
|
177
|
+
* ]
|
|
178
|
+
* }
|
|
179
|
+
*
|
|
180
|
+
* for (const blobRef of enumBlobRefs(record)) {
|
|
181
|
+
* console.log(blobRef.mimeType, blobRef.size)
|
|
182
|
+
* }
|
|
183
|
+
*
|
|
184
|
+
* // Include legacy blob references
|
|
185
|
+
* for (const ref of enumBlobRefs(record, { allowLegacy: true })) {
|
|
186
|
+
* // ref may be BlobRef or LegacyBlobRef
|
|
187
|
+
* }
|
|
188
|
+
* ```
|
|
52
189
|
*/
|
|
53
190
|
export declare function enumBlobRefs(input: LexValue): Generator<BlobRef<RawCid>, void, unknown>;
|
|
54
191
|
export declare function enumBlobRefs<TOptions extends EnumBlobRefsOptions>(input: LexValue, options: TOptions): Generator<InferEnumBlobRefs<TOptions>, void, unknown>;
|
package/dist/blob.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../src/blob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAA4B,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC
|
|
1
|
+
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../src/blob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAA4B,MAAM,UAAU,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,OAAO,CAAC,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI;IAC3C,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,QAAQ,SAAS,mBAAmB,IAClE,QAAQ,SAAS;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,GAC9B,OAAO,GACP;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,SAAS,QAAQ,GAClC,OAAO,GACP,OAAO,CAAC,MAAM,CAAC,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG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,EACf,OAAO,EAAE,QAAQ,GAChB,SAAS,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AACxD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,QAAQ,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC5B,SAAS,CAAC,OAAO,GAAG,aAAa,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA"}
|
package/dist/blob.js
CHANGED
|
@@ -39,6 +39,29 @@ function isBlobRef(input, options) {
|
|
|
39
39
|
}
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Type guard to check if a value is a valid {@link LegacyBlobRef}.
|
|
44
|
+
*
|
|
45
|
+
* Validates the structure of the input:
|
|
46
|
+
* - `cid` must be a valid CID string
|
|
47
|
+
* - `mimeType` must be a non-empty string
|
|
48
|
+
* - No additional properties allowed
|
|
49
|
+
*
|
|
50
|
+
* @param input - The value to check
|
|
51
|
+
* @returns `true` if the input is a valid LegacyBlobRef
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import { isLegacyBlobRef } from '@atproto/lex-data'
|
|
56
|
+
*
|
|
57
|
+
* if (isLegacyBlobRef(data)) {
|
|
58
|
+
* console.log(data.cid) // CID as string
|
|
59
|
+
* console.log(data.mimeType) // e.g., 'image/jpeg'
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @see {@link isBlobRef} for checking the current blob reference format
|
|
64
|
+
*/
|
|
42
65
|
function isLegacyBlobRef(input) {
|
|
43
66
|
if (!(0, object_js_1.isPlainObject)(input)) {
|
|
44
67
|
return false;
|
package/dist/blob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../src/blob.ts"],"names":[],"mappings":";;AAyCA,8BA+CC;AAUD,0CAyBC;AA+BD,oCAyCC;AAnMD,qCAAgE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E,SAAQ;gBAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBAClB,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;YACtB,CAAC;iBAAM,IAAI,IAAA,wBAAY,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;oBAAE,SAAQ;gBAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBAClB,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;oBAC9B,MAAM,KAAK,CAAA;gBACb,CAAC;qBAAM,IAAI,aAAa,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnD,MAAM,KAAK,CAAA;gBACb,CAAC;qBAAM,CAAC;oBACN,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;wBACrC,IAAI,CAAC,IAAI,IAAI;4BAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBAC9B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,QAAQ,KAAK,CAAC,MAAM,GAAG,CAAC,EAAC;IAE1B,+BAA+B;IAC/B,OAAO,CAAC,KAAK,EAAE,CAAA;AACjB,CAAC","sourcesContent":["import { Cid, RawCid, ifCid, validateCidString } from './cid.js'\nimport { LexValue } from './lex.js'\nimport { isPlainObject, isPlainProto } from './object.js'\n\n/**\n * @note {@link BlobRef} is just a {@link LexMap} with a specific shape.\n */\nexport type BlobRef<Ref extends Cid = Cid> = {\n $type: 'blob'\n mimeType: string\n ref: Ref\n size: number\n}\n\nexport type BlobRefCheckOptions = {\n /**\n * If `false`, skips strict CID validation of {@link BlobRef.ref}, allowing\n * any valid CID. Otherwise, validates that the CID is v1, uses the raw\n * multicodec, and has a sha256 multihash.\n *\n * @defaults to `true`\n */\n strict?: boolean\n}\n\nexport type InferCheckedBlobRef<TOptions extends BlobRefCheckOptions> =\n TOptions extends { strict: false }\n ? BlobRef\n : { strict: boolean } extends TOptions\n ? BlobRef\n : BlobRef<RawCid>\n\nexport function isBlobRef(input: unknown): input is BlobRef<RawCid>\nexport function isBlobRef<TOptions extends BlobRefCheckOptions>(\n input: unknown,\n options: TOptions,\n): input is InferCheckedBlobRef<TOptions>\nexport function isBlobRef(\n input: unknown,\n options?: BlobRefCheckOptions,\n): input is BlobRef\nexport function isBlobRef(\n input: unknown,\n options?: BlobRefCheckOptions,\n): input is BlobRef {\n if (!isPlainObject(input)) {\n return false\n }\n\n if (input?.$type !== 'blob') {\n return false\n }\n\n const { mimeType, size, ref } = input\n // @NOTE Very basic mime validation\n if (typeof mimeType !== 'string' || !mimeType.includes('/')) {\n return false\n }\n\n if (typeof size !== 'number' || size < 0 || !Number.isSafeInteger(size)) {\n return false\n }\n\n if (typeof ref !== 'object' || ref === null) {\n return false\n }\n\n for (const key in input) {\n if (\n key !== '$type' &&\n key !== 'mimeType' &&\n key !== 'ref' &&\n key !== 'size'\n ) {\n return false\n }\n }\n\n const cid = ifCid(\n ref,\n // Strict unless explicitly disabled\n options?.strict === false ? undefined : { flavor: 'raw' },\n )\n if (!cid) {\n return false\n }\n\n return true\n}\n\n/**\n * @note {@link LegacyBlobRef} is just a {@link LexMap} with a specific shape.\n */\nexport type LegacyBlobRef = {\n cid: string\n mimeType: string\n}\n\nexport function isLegacyBlobRef(input: unknown): input is LegacyBlobRef {\n if (!isPlainObject(input)) {\n return false\n }\n\n const { cid, mimeType } = input\n if (typeof cid !== 'string') {\n return false\n }\n\n if (typeof mimeType !== 'string' || mimeType.length === 0) {\n return false\n }\n\n for (const key in input) {\n if (key !== 'cid' && key !== 'mimeType') {\n return false\n }\n }\n\n if (!validateCidString(cid)) {\n return false\n }\n\n return true\n}\n\nexport type EnumBlobRefsOptions = BlobRefCheckOptions & {\n /**\n * @defaults to `false`\n */\n allowLegacy?: boolean\n}\n\nexport type InferEnumBlobRefs<TOptions extends EnumBlobRefsOptions> =\n TOptions extends { allowLegacy: true }\n ? InferCheckedBlobRef<TOptions> | LegacyBlobRef\n : { allowLegacy: boolean } extends TOptions\n ? InferCheckedBlobRef<TOptions> | LegacyBlobRef\n : InferCheckedBlobRef<TOptions>\n\n/**\n * Enumerates all {@link BlobRef}s (and, optionally, {@link LegacyBlobRef}s)\n * found within a {@link LexValue}.\n */\nexport function enumBlobRefs(\n input: LexValue,\n): Generator<BlobRef<RawCid>, void, unknown>\nexport function enumBlobRefs<TOptions extends EnumBlobRefsOptions>(\n input: LexValue,\n options: TOptions,\n): Generator<InferEnumBlobRefs<TOptions>, void, unknown>\nexport function enumBlobRefs(\n input: LexValue,\n options?: EnumBlobRefsOptions,\n): Generator<BlobRef | LegacyBlobRef, void, unknown>\nexport function* enumBlobRefs(\n input: LexValue,\n options?: EnumBlobRefsOptions,\n): Generator<BlobRef | LegacyBlobRef, void, unknown> {\n // LegacyBlobRef not included by default\n const includeLegacy = options?.allowLegacy === true\n\n // Using a stack to avoid recursion depth issues.\n const stack: LexValue[] = [input]\n\n // Since we are using a stack, we could end-up in an infinite loop with cyclic\n // structures. Cyclic structures are not valid LexValues and should, thus,\n // never occur, but let's be safe.\n const visited = new Set<object>()\n\n do {\n const value = stack.pop()!\n\n if (value != null && typeof value === 'object') {\n if (Array.isArray(value)) {\n if (visited.has(value)) continue\n visited.add(value)\n stack.push(...value)\n } else if (isPlainProto(value)) {\n if (visited.has(value)) continue\n visited.add(value)\n if (isBlobRef(value, options)) {\n yield value\n } else if (includeLegacy && isLegacyBlobRef(value)) {\n yield value\n } else {\n for (const v of Object.values(value)) {\n if (v != null) stack.push(v)\n }\n }\n }\n }\n } while (stack.length > 0)\n\n // Optimization: ease GC's work\n visited.clear()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../src/blob.ts"],"names":[],"mappings":";;AAkGA,8BA+CC;AAkDD,0CAyBC;AAuED,oCAyCC;AA5UD,qCAA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AAO,CAAC,GAAG,CAAC,KAAK,CAAC;oBAAE,SAAQ;gBAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBAClB,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;YACtB,CAAC;iBAAM,IAAI,IAAA,wBAAY,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;oBAAE,SAAQ;gBAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;gBAClB,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;oBAC9B,MAAM,KAAK,CAAA;gBACb,CAAC;qBAAM,IAAI,aAAa,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnD,MAAM,KAAK,CAAA;gBACb,CAAC;qBAAM,CAAC;oBACN,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;wBACrC,IAAI,CAAC,IAAI,IAAI;4BAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBAC9B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,QAAQ,KAAK,CAAC,MAAM,GAAG,CAAC,EAAC;IAE1B,+BAA+B;IAC/B,OAAO,CAAC,KAAK,EAAE,CAAA;AACjB,CAAC","sourcesContent":["import { Cid, RawCid, ifCid, validateCidString } from './cid.js'\nimport { LexValue } from './lex.js'\nimport { isPlainObject, isPlainProto } from './object.js'\n\n/**\n * Reference to binary data (like images, videos, etc.) in the AT Protocol data model.\n *\n * A BlobRef is a {@link LexMap} with a specific structure that identifies binary\n * content by its content hash (CID), along with metadata about the content type\n * and size.\n *\n * @typeParam Ref - The type of CID reference, defaults to any {@link Cid}\n *\n * @example\n * ```typescript\n * import type { BlobRef } from '@atproto/lex-data'\n *\n * const imageRef: BlobRef = {\n * $type: 'blob',\n * mimeType: 'image/jpeg',\n * ref: cid, // CID of the blob content\n * size: 12345\n * }\n * ```\n *\n * @see {@link isBlobRef} to check if a value is a valid BlobRef\n * @see {@link LegacyBlobRef} for the older blob reference format\n */\nexport type BlobRef<Ref extends Cid = Cid> = {\n $type: 'blob'\n mimeType: string\n ref: Ref\n size: number\n}\n\n/**\n * Options for validating a {@link BlobRef}.\n */\nexport type BlobRefCheckOptions = {\n /**\n * If `false`, skips strict CID validation of {@link BlobRef.ref}, allowing\n * any valid CID. Otherwise, validates that the CID is v1, uses the raw\n * multicodec, and has a sha256 multihash.\n *\n * @default true\n */\n strict?: boolean\n}\n\n/**\n * Infers the BlobRef type based on the check options.\n *\n * @typeParam TOptions - The options used for checking\n */\nexport type InferCheckedBlobRef<TOptions extends BlobRefCheckOptions> =\n TOptions extends { strict: false }\n ? BlobRef\n : { strict: boolean } extends TOptions\n ? BlobRef\n : BlobRef<RawCid>\n\n/**\n * Type guard to check if a value is a valid {@link BlobRef}.\n *\n * Validates the structure of the input including:\n * - `$type` must be `'blob'`\n * - `mimeType` must be a valid MIME type string (containing '/')\n * - `size` must be a non-negative safe integer\n * - `ref` must be a valid CID (strict validation by default)\n *\n * @param input - The value to check\n * @param options - Optional validation options\n * @returns `true` if the input is a valid BlobRef\n *\n * @example\n * ```typescript\n * import { isBlobRef } from '@atproto/lex-data'\n *\n * if (isBlobRef(data)) {\n * console.log(data.mimeType) // e.g., 'image/jpeg'\n * console.log(data.size) // e.g., 12345\n * }\n *\n * // Allow any valid CID (not just raw CIDs)\n * if (isBlobRef(data, { strict: false })) {\n * // ...\n * }\n * ```\n */\nexport function isBlobRef(input: unknown): input is BlobRef<RawCid>\nexport function isBlobRef<TOptions extends BlobRefCheckOptions>(\n input: unknown,\n options: TOptions,\n): input is InferCheckedBlobRef<TOptions>\nexport function isBlobRef(\n input: unknown,\n options?: BlobRefCheckOptions,\n): input is BlobRef\nexport function isBlobRef(\n input: unknown,\n options?: BlobRefCheckOptions,\n): input is BlobRef {\n if (!isPlainObject(input)) {\n return false\n }\n\n if (input?.$type !== 'blob') {\n return false\n }\n\n const { mimeType, size, ref } = input\n // @NOTE Very basic mime validation\n if (typeof mimeType !== 'string' || !mimeType.includes('/')) {\n return false\n }\n\n if (typeof size !== 'number' || size < 0 || !Number.isSafeInteger(size)) {\n return false\n }\n\n if (typeof ref !== 'object' || ref === null) {\n return false\n }\n\n for (const key in input) {\n if (\n key !== '$type' &&\n key !== 'mimeType' &&\n key !== 'ref' &&\n key !== 'size'\n ) {\n return false\n }\n }\n\n const cid = ifCid(\n ref,\n // Strict unless explicitly disabled\n options?.strict === false ? undefined : { flavor: 'raw' },\n )\n if (!cid) {\n return false\n }\n\n return true\n}\n\n/**\n * Legacy format for blob references used in older AT Protocol data.\n *\n * This is the older format that stores the CID as a string rather than\n * as a structured CID object. New code should use {@link BlobRef} instead.\n *\n * @example\n * ```typescript\n * import type { LegacyBlobRef } from '@atproto/lex-data'\n *\n * const legacyRef: LegacyBlobRef = {\n * cid: 'bafyreib...',\n * mimeType: 'image/jpeg'\n * }\n * ```\n *\n * @see {@link isLegacyBlobRef} to check if a value is a LegacyBlobRef\n * @see {@link BlobRef} for the current blob reference format\n * @deprecated Use {@link BlobRef} for new code\n */\nexport type LegacyBlobRef = {\n cid: string\n mimeType: string\n}\n\n/**\n * Type guard to check if a value is a valid {@link LegacyBlobRef}.\n *\n * Validates the structure of the input:\n * - `cid` must be a valid CID string\n * - `mimeType` must be a non-empty string\n * - No additional properties allowed\n *\n * @param input - The value to check\n * @returns `true` if the input is a valid LegacyBlobRef\n *\n * @example\n * ```typescript\n * import { isLegacyBlobRef } from '@atproto/lex-data'\n *\n * if (isLegacyBlobRef(data)) {\n * console.log(data.cid) // CID as string\n * console.log(data.mimeType) // e.g., 'image/jpeg'\n * }\n * ```\n *\n * @see {@link isBlobRef} for checking the current blob reference format\n */\nexport function isLegacyBlobRef(input: unknown): input is LegacyBlobRef {\n if (!isPlainObject(input)) {\n return false\n }\n\n const { cid, mimeType } = input\n if (typeof cid !== 'string') {\n return false\n }\n\n if (typeof mimeType !== 'string' || mimeType.length === 0) {\n return false\n }\n\n for (const key in input) {\n if (key !== 'cid' && key !== 'mimeType') {\n return false\n }\n }\n\n if (!validateCidString(cid)) {\n return false\n }\n\n return true\n}\n\n/**\n * Options for enumerating blob references within a {@link LexValue}.\n */\nexport type EnumBlobRefsOptions = BlobRefCheckOptions & {\n /**\n * If `true`, also yields {@link LegacyBlobRef} objects in addition to\n * {@link BlobRef} objects.\n *\n * @default false\n */\n allowLegacy?: boolean\n}\n\n/**\n * Infers the yielded type of {@link enumBlobRefs} based on options.\n *\n * @typeParam TOptions - The options used for enumeration\n */\nexport type InferEnumBlobRefs<TOptions extends EnumBlobRefsOptions> =\n TOptions extends { allowLegacy: true }\n ? InferCheckedBlobRef<TOptions> | LegacyBlobRef\n : { allowLegacy: boolean } extends TOptions\n ? InferCheckedBlobRef<TOptions> | LegacyBlobRef\n : InferCheckedBlobRef<TOptions>\n\n/**\n * Generator that enumerates all {@link BlobRef}s (and, optionally,\n * {@link LegacyBlobRef}s) found within a {@link LexValue}.\n *\n * Performs a deep traversal of the input value, yielding any blob references\n * found. This is useful for extracting all media references from a record.\n *\n * @param input - The LexValue to search for blob references\n * @param options - Optional configuration for the enumeration\n * @yields Each blob reference found in the input\n *\n * @example\n * ```typescript\n * import { enumBlobRefs } from '@atproto/lex-data'\n *\n * const record = {\n * text: 'Hello',\n * images: [\n * { $type: 'blob', mimeType: 'image/jpeg', ref: cid1, size: 1000 },\n * { $type: 'blob', mimeType: 'image/png', ref: cid2, size: 2000 }\n * ]\n * }\n *\n * for (const blobRef of enumBlobRefs(record)) {\n * console.log(blobRef.mimeType, blobRef.size)\n * }\n *\n * // Include legacy blob references\n * for (const ref of enumBlobRefs(record, { allowLegacy: true })) {\n * // ref may be BlobRef or LegacyBlobRef\n * }\n * ```\n */\nexport function enumBlobRefs(\n input: LexValue,\n): Generator<BlobRef<RawCid>, void, unknown>\nexport function enumBlobRefs<TOptions extends EnumBlobRefsOptions>(\n input: LexValue,\n options: TOptions,\n): Generator<InferEnumBlobRefs<TOptions>, void, unknown>\nexport function enumBlobRefs(\n input: LexValue,\n options?: EnumBlobRefsOptions,\n): Generator<BlobRef | LegacyBlobRef, void, unknown>\nexport function* enumBlobRefs(\n input: LexValue,\n options?: EnumBlobRefsOptions,\n): Generator<BlobRef | LegacyBlobRef, void, unknown> {\n // LegacyBlobRef not included by default\n const includeLegacy = options?.allowLegacy === true\n\n // Using a stack to avoid recursion depth issues.\n const stack: LexValue[] = [input]\n\n // Since we are using a stack, we could end-up in an infinite loop with cyclic\n // structures. Cyclic structures are not valid LexValues and should, thus,\n // never occur, but let's be safe.\n const visited = new Set<object>()\n\n do {\n const value = stack.pop()!\n\n if (value != null && typeof value === 'object') {\n if (Array.isArray(value)) {\n if (visited.has(value)) continue\n visited.add(value)\n stack.push(...value)\n } else if (isPlainProto(value)) {\n if (visited.has(value)) continue\n visited.add(value)\n if (isBlobRef(value, options)) {\n yield value\n } else if (includeLegacy && isLegacyBlobRef(value)) {\n yield value\n } else {\n for (const v of Object.values(value)) {\n if (v != null) stack.push(v)\n }\n }\n }\n }\n } while (stack.length > 0)\n\n // Optimization: ease GC's work\n visited.clear()\n}\n"]}
|
package/dist/cid.d.ts
CHANGED
|
@@ -1,22 +1,55 @@
|
|
|
1
1
|
import { CID } from 'multiformats/cid';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
export
|
|
2
|
+
/**
|
|
3
|
+
* Codec code that indicates the CID references a CBOR-encoded data structure.
|
|
4
|
+
*
|
|
5
|
+
* Used when encoding structured data in AT Protocol repositories.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link https://dasl.ing/cid.html Content IDs (DASL)}
|
|
8
|
+
*/
|
|
9
|
+
export declare const CBOR_DATA_CODEC = 113;
|
|
10
|
+
export type CBOR_DATA_CODEC = typeof CBOR_DATA_CODEC;
|
|
11
|
+
/**
|
|
12
|
+
* Codec code that indicates the CID references raw binary data (like media blobs).
|
|
13
|
+
*
|
|
14
|
+
* Used in DASL CIDs for binary blobs like images and media.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://dasl.ing/cid.html Content IDs (DASL)}
|
|
17
|
+
*/
|
|
18
|
+
export declare const RAW_DATA_CODEC = 85;
|
|
19
|
+
export type RAW_DATA_CODEC = typeof RAW_DATA_CODEC;
|
|
20
|
+
/**
|
|
21
|
+
* Hash code that indicates that a CID uses SHA-256.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SHA256_HASH_CODE: 18;
|
|
24
|
+
export type SHA256_HASH_CODE = typeof SHA256_HASH_CODE;
|
|
25
|
+
/**
|
|
26
|
+
* Hash code that indicates that a CID uses SHA-512.
|
|
27
|
+
*/
|
|
28
|
+
export declare const SHA512_HASH_CODE: 19;
|
|
29
|
+
export type SHA512_HASH_CODE = typeof SHA512_HASH_CODE;
|
|
30
|
+
/**
|
|
31
|
+
* Represent the hash part of a CID, which includes the hash algorithm code and
|
|
32
|
+
* the raw digest bytes.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link https://dasl.ing/cid.html Content IDs (DASL)}
|
|
35
|
+
*/
|
|
36
|
+
export interface Multihash<THashCode extends number = number> {
|
|
11
37
|
/**
|
|
12
|
-
* Code of the
|
|
38
|
+
* Code of the hash algorithm (e.g., SHA256_HASH_CODE).
|
|
13
39
|
*/
|
|
14
|
-
code:
|
|
40
|
+
code: THashCode;
|
|
15
41
|
/**
|
|
16
|
-
* Raw digest
|
|
42
|
+
* Raw digest bytes.
|
|
17
43
|
*/
|
|
18
44
|
digest: Uint8Array;
|
|
19
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Compares two {@link Multihash} for equality.
|
|
48
|
+
*
|
|
49
|
+
* @param a - First {@link Multihash}
|
|
50
|
+
* @param b - Second {@link Multihash}
|
|
51
|
+
* @returns `true` if both multihashes have the same code and digest
|
|
52
|
+
*/
|
|
20
53
|
export declare function multihashEquals(a: Multihash, b: Multihash): boolean;
|
|
21
54
|
declare module 'multiformats/cid' {
|
|
22
55
|
/**
|
|
@@ -50,45 +83,124 @@ export { /** @deprecated */ CID };
|
|
|
50
83
|
* implementation directly. This is to avoid compatibility issues, and in order
|
|
51
84
|
* to allow better portability, compatibility and future updates.
|
|
52
85
|
*/
|
|
53
|
-
export declare function asMultiformatsCID<TVersion extends 0 | 1 = 0 | 1,
|
|
86
|
+
export declare function asMultiformatsCID<TVersion extends 0 | 1 = 0 | 1, TCodec extends number = number, THashCode extends number = number>(input: Cid<TVersion, TCodec, THashCode>): CID & Cid<TVersion, TCodec, THashCode>;
|
|
54
87
|
/**
|
|
55
|
-
*
|
|
88
|
+
* Content Identifier (CID) for addressing content by its hash.
|
|
89
|
+
*
|
|
90
|
+
* CIDs are self-describing content addresses used throughout AT Protocol for
|
|
91
|
+
* linking to data by its cryptographic hash. This interface provides a
|
|
92
|
+
* stable API that is compatible with the `multiformats` library but avoids
|
|
93
|
+
* direct dependency issues.
|
|
94
|
+
*
|
|
95
|
+
* @typeParam TVersion - CID version (0 or 1)
|
|
96
|
+
* @typeParam TCodec - Multicodec content type code
|
|
97
|
+
* @typeParam THashCode - Multihash algorithm code
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* import type { Cid } from '@atproto/lex-data'
|
|
102
|
+
* import { parseCid, isCid } from '@atproto/lex-data'
|
|
103
|
+
*
|
|
104
|
+
* // Parse a CID from a string
|
|
105
|
+
* const cid: Cid = parseCid('bafyreib...')
|
|
106
|
+
*
|
|
107
|
+
* // Check if a value is a CID
|
|
108
|
+
* if (isCid(value)) {
|
|
109
|
+
* console.log(cid.toString())
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @see {@link isCid} to check if a value is a valid CID
|
|
114
|
+
* @see {@link parseCid} to parse a CID from a string
|
|
115
|
+
* @see {@link decodeCid} to decode a CID from bytes
|
|
116
|
+
* @see {@link https://dasl.ing/cid.html Content IDs (DASL)}
|
|
56
117
|
*/
|
|
57
|
-
export interface Cid<TVersion extends 0 | 1 = 0 | 1,
|
|
118
|
+
export interface Cid<TVersion extends 0 | 1 = 0 | 1, TCodec extends number = number, THashCode extends number = number> {
|
|
119
|
+
/** CID version (0 or 1). AT Protocol uses CIDv1. */
|
|
58
120
|
readonly version: TVersion;
|
|
59
|
-
|
|
60
|
-
readonly
|
|
121
|
+
/** Coded (e.g., {@link CBOR_DATA_CODEC}, {@link RAW_DATA_CODEC}). */
|
|
122
|
+
readonly code: TCodec;
|
|
123
|
+
/** The multihash containing the hash algorithm and digest. */
|
|
124
|
+
readonly multihash: Multihash<THashCode>;
|
|
61
125
|
/**
|
|
62
126
|
* Binary representation of the whole CID.
|
|
63
127
|
*/
|
|
64
128
|
readonly bytes: Uint8Array;
|
|
129
|
+
/**
|
|
130
|
+
* Compares this CID with another for equality.
|
|
131
|
+
*
|
|
132
|
+
* @param other - The CID to compare with
|
|
133
|
+
* @returns `true` if the CIDs are equal
|
|
134
|
+
*/
|
|
65
135
|
equals(other: Cid): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the string representation of this CID (base32 for v1, base58btc for v0).
|
|
138
|
+
*/
|
|
66
139
|
toString(): string;
|
|
67
140
|
}
|
|
68
141
|
/**
|
|
69
|
-
* Represents the
|
|
142
|
+
* Represents the CID of raw binary data (like media blobs).
|
|
70
143
|
*
|
|
71
|
-
* The use of {@link
|
|
144
|
+
* The use of {@link SHA256_HASH_CODE} is recommended but not required for raw CIDs.
|
|
72
145
|
*
|
|
73
|
-
* @see {@link https://atproto.com/specs/data-model#link-and-cid-formats
|
|
146
|
+
* @see {@link https://atproto.com/specs/data-model#link-and-cid-formats AT Protocol Data Model - Link and CID Formats}
|
|
147
|
+
*/
|
|
148
|
+
export type RawCid = Cid<1, RAW_DATA_CODEC>;
|
|
149
|
+
/**
|
|
150
|
+
* Type guard to check if a CID is a raw binary CID.
|
|
151
|
+
*
|
|
152
|
+
* @param cid - The CID to check
|
|
153
|
+
* @returns `true` if the CID is a version 1 CID with raw multicodec
|
|
74
154
|
*/
|
|
75
|
-
export type RawCid = Cid<1, RAW_MULTICODEC>;
|
|
76
155
|
export declare function isRawCid(cid: Cid): cid is RawCid;
|
|
77
156
|
/**
|
|
78
157
|
* Represents a DASL compliant CID.
|
|
79
|
-
*
|
|
158
|
+
*
|
|
159
|
+
* DASL CIDs are version 1 CIDs using either raw or DAG-CBOR multicodec
|
|
160
|
+
* with SHA-256 multihash.
|
|
161
|
+
*
|
|
162
|
+
* @see {@link https://dasl.ing/cid.html Content IDs (DASL)}
|
|
163
|
+
*/
|
|
164
|
+
export type DaslCid = Cid<1, RAW_DATA_CODEC | CBOR_DATA_CODEC, SHA256_HASH_CODE>;
|
|
165
|
+
/**
|
|
166
|
+
* Type guard to check if a CID is DASL compliant.
|
|
167
|
+
*
|
|
168
|
+
* @param cid - The CID to check
|
|
169
|
+
* @returns `true` if the CID is DASL compliant (v1, raw/dag-cbor, sha256)
|
|
80
170
|
*/
|
|
81
|
-
export type DaslCid = Cid<1, RAW_MULTICODEC | DAG_CBOR_MULTICODEC, SHA256_MULTIHASH>;
|
|
82
171
|
export declare function isDaslCid(cid: Cid): cid is DaslCid;
|
|
83
172
|
/**
|
|
84
|
-
* Represents the
|
|
85
|
-
*
|
|
173
|
+
* Represents the CID of AT Protocol DAG-CBOR data (like repository MST nodes).
|
|
174
|
+
*
|
|
175
|
+
* CBOR CIDs are version 1 CIDs using DAG-CBOR multicodec with SHA-256 multihash.
|
|
176
|
+
*
|
|
177
|
+
* @see {@link https://atproto.com/specs/data-model#link-and-cid-formats AT Protocol Data Model - Link and CID Formats}
|
|
178
|
+
*/
|
|
179
|
+
export type CborCid = Cid<1, CBOR_DATA_CODEC, SHA256_HASH_CODE>;
|
|
180
|
+
/**
|
|
181
|
+
* Type guard to check if a CID is a DAG-CBOR CID.
|
|
182
|
+
*
|
|
183
|
+
* @param cid - The CID to check
|
|
184
|
+
* @returns `true` if the CID is a DAG-CBOR CID (v1, dag-cbor, sha256)
|
|
86
185
|
*/
|
|
87
|
-
export type CborCid = Cid<1, DAG_CBOR_MULTICODEC, SHA256_MULTIHASH>;
|
|
88
186
|
export declare function isCborCid(cid: Cid): cid is CborCid;
|
|
187
|
+
/**
|
|
188
|
+
* Options for checking CID flavor constraints.
|
|
189
|
+
*/
|
|
89
190
|
export type CheckCidOptions = {
|
|
191
|
+
/**
|
|
192
|
+
* The CID flavor to check for.
|
|
193
|
+
* - `'raw'` - Raw binary CID ({@link RawCid})
|
|
194
|
+
* - `'cbor'` - DAG-CBOR CID ({@link CborCid})
|
|
195
|
+
* - `'dasl'` - DASL compliant CID ({@link DaslCid})
|
|
196
|
+
*/
|
|
90
197
|
flavor?: 'raw' | 'cbor' | 'dasl';
|
|
91
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* Infers the CID type based on check options.
|
|
201
|
+
*
|
|
202
|
+
* @typeParam TOptions - The options used for checking
|
|
203
|
+
*/
|
|
92
204
|
export type InferCheckedCid<TOptions> = TOptions extends {
|
|
93
205
|
flavor: 'raw';
|
|
94
206
|
} ? RawCid : TOptions extends {
|
|
@@ -133,9 +245,43 @@ export declare function decodeCid(cidBytes: Uint8Array, options?: CheckCidOption
|
|
|
133
245
|
*/
|
|
134
246
|
export declare function parseCid<TOptions extends CheckCidOptions>(input: string, options: TOptions): InferCheckedCid<TOptions>;
|
|
135
247
|
export declare function parseCid(input: string, options?: CheckCidOptions): Cid;
|
|
248
|
+
/**
|
|
249
|
+
* Validates that a string is a valid CID representation.
|
|
250
|
+
*
|
|
251
|
+
* Unlike {@link parseCid}, this function returns a boolean instead of throwing.
|
|
252
|
+
* It also verifies that the string is the canonical representation of the CID.
|
|
253
|
+
*
|
|
254
|
+
* @param input - The string to validate
|
|
255
|
+
* @param options - Optional flavor constraints
|
|
256
|
+
* @returns `true` if the string is a valid CID
|
|
257
|
+
*/
|
|
136
258
|
export declare function validateCidString(input: string, options?: CheckCidOptions): boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Safely parses a CID string, returning `null` on failure instead of throwing.
|
|
261
|
+
*
|
|
262
|
+
* @param input - The string to parse
|
|
263
|
+
* @param options - Optional flavor constraints
|
|
264
|
+
* @returns The parsed CID, or `null` if parsing fails
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* import { parseCidSafe } from '@atproto/lex-data'
|
|
269
|
+
*
|
|
270
|
+
* const cid = parseCidSafe('bafyreib...')
|
|
271
|
+
* if (cid) {
|
|
272
|
+
* console.log(cid.toString())
|
|
273
|
+
* }
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
137
276
|
export declare function parseCidSafe<TOptions extends CheckCidOptions>(input: string, options: TOptions): InferCheckedCid<TOptions> | null;
|
|
138
277
|
export declare function parseCidSafe(input: string, options?: CheckCidOptions): Cid | null;
|
|
278
|
+
/**
|
|
279
|
+
* Ensures that a string is a valid CID representation.
|
|
280
|
+
*
|
|
281
|
+
* @param input - The string to validate
|
|
282
|
+
* @param options - Optional flavor constraints
|
|
283
|
+
* @throws If the string is not a valid CID
|
|
284
|
+
*/
|
|
139
285
|
export declare function ensureValidCidString(input: string, options?: CheckCidOptions): void;
|
|
140
286
|
/**
|
|
141
287
|
* Verifies whether the multihash of a given {@link cid} matches the hash of the provided {@link bytes}.
|
|
@@ -144,8 +290,46 @@ export declare function ensureValidCidString(input: string, options?: CheckCidOp
|
|
|
144
290
|
* @returns true if the CID matches the bytes, false otherwise.
|
|
145
291
|
*/
|
|
146
292
|
export declare function isCidForBytes(cid: Cid, bytes: Uint8Array): Promise<boolean>;
|
|
147
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Creates a CID from a multicodec, multihash code, and digest.
|
|
295
|
+
*
|
|
296
|
+
* @param code - The multicodec content type code
|
|
297
|
+
* @param multihashCode - The multihash algorithm code
|
|
298
|
+
* @param digest - The raw hash digest bytes
|
|
299
|
+
* @returns A new CIDv1 instance
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* import { createCid, RAW_DATA_CODEC, SHA256_HASH_CODE } from '@atproto/lex-data'
|
|
304
|
+
*
|
|
305
|
+
* const cid = createCid(RAW_DATA_CODEC, SHA256_HASH_CODE, hashDigest)
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
export declare function createCid<TCodec extends number, THashCode extends number>(code: TCodec, multihashCode: THashCode, digest: Uint8Array): Cid<1, TCodec, THashCode>;
|
|
309
|
+
/**
|
|
310
|
+
* Creates a DAG-CBOR CID for the given CBOR bytes.
|
|
311
|
+
*
|
|
312
|
+
* Computes the SHA-256 hash of the bytes and creates a CIDv1 with DAG-CBOR multicodec.
|
|
313
|
+
*
|
|
314
|
+
* @param bytes - The CBOR-encoded bytes to hash
|
|
315
|
+
* @returns A promise that resolves to the CborCid
|
|
316
|
+
*/
|
|
148
317
|
export declare function cidForCbor(bytes: Uint8Array): Promise<CborCid>;
|
|
318
|
+
/**
|
|
319
|
+
* Creates a raw CID for the given binary bytes.
|
|
320
|
+
*
|
|
321
|
+
* Computes the SHA-256 hash of the bytes and creates a CIDv1 with raw multicodec.
|
|
322
|
+
*
|
|
323
|
+
* @param bytes - The raw binary bytes to hash
|
|
324
|
+
* @returns A promise that resolves to the RawCid
|
|
325
|
+
*/
|
|
149
326
|
export declare function cidForRawBytes(bytes: Uint8Array): Promise<RawCid>;
|
|
327
|
+
/**
|
|
328
|
+
* Creates a raw CID from an existing SHA-256 hash digest.
|
|
329
|
+
*
|
|
330
|
+
* @param digest - The SHA-256 hash digest (must be 32 bytes)
|
|
331
|
+
* @returns A RawCid with the given digest
|
|
332
|
+
* @throws If the digest length is not 32 bytes
|
|
333
|
+
*/
|
|
150
334
|
export declare function cidForRawHash(digest: Uint8Array): RawCid;
|
|
151
335
|
//# sourceMappingURL=cid.d.ts.map
|
package/dist/cid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../src/cid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAMtC,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../src/cid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAMtC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,MAAO,CAAA;AACnC,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAA;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,KAAO,CAAA;AAClC,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,gBAAgB,IAAc,CAAA;AAC3C,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,gBAAgB,IAAc,CAAA;AAC3C,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,WAAW,SAAS,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM;IAC1D;;OAEG;IACH,IAAI,EAAE,SAAS,CAAA;IAEf;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAGnE;AAED,OAAO,QAAQ,kBAAkB,CAAC;IAChC;;;;;;;;;;;;;;;;;;OAkBG;IACH,UAAU,GAAG;KAAG;CACjB;AAqBD,OAAO,EAAE,kBAAkB,CAAC,GAAG,EAAE,CAAA;AAEjC;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,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