@ardrive/turbo-sdk 1.42.0-alpha.13 → 1.42.0-alpha.15

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.
Files changed (38) hide show
  1. package/lib/cjs/cli/commands/arns.js +8 -3
  2. package/lib/cjs/common/folderIndex.js +394 -0
  3. package/lib/cjs/common/index.js +1 -0
  4. package/lib/cjs/common/turbo.js +11 -4
  5. package/lib/cjs/common/upload.js +288 -17
  6. package/lib/cjs/node/folderIndex.js +132 -0
  7. package/lib/cjs/node/index.js +1 -0
  8. package/lib/cjs/node/upload.js +7 -0
  9. package/lib/cjs/utils/folderIndex.js +88 -0
  10. package/lib/esm/cli/commands/arns.js +8 -3
  11. package/lib/esm/common/folderIndex.js +389 -0
  12. package/lib/esm/common/index.js +1 -0
  13. package/lib/esm/common/turbo.js +11 -4
  14. package/lib/esm/common/upload.js +289 -18
  15. package/lib/esm/node/folderIndex.js +129 -0
  16. package/lib/esm/node/index.js +1 -0
  17. package/lib/esm/node/upload.js +7 -0
  18. package/lib/esm/utils/folderIndex.js +81 -0
  19. package/lib/types/cli/commands/arns.d.ts.map +1 -1
  20. package/lib/types/common/folderIndex.d.ts +54 -0
  21. package/lib/types/common/folderIndex.d.ts.map +1 -0
  22. package/lib/types/common/index.d.ts +1 -0
  23. package/lib/types/common/index.d.ts.map +1 -1
  24. package/lib/types/common/turbo.d.ts +11 -4
  25. package/lib/types/common/turbo.d.ts.map +1 -1
  26. package/lib/types/common/upload.d.ts +41 -0
  27. package/lib/types/common/upload.d.ts.map +1 -1
  28. package/lib/types/node/folderIndex.d.ts +28 -0
  29. package/lib/types/node/folderIndex.d.ts.map +1 -0
  30. package/lib/types/node/index.d.ts +1 -0
  31. package/lib/types/node/index.d.ts.map +1 -1
  32. package/lib/types/node/upload.d.ts +1 -0
  33. package/lib/types/node/upload.d.ts.map +1 -1
  34. package/lib/types/types.d.ts +163 -0
  35. package/lib/types/types.d.ts.map +1 -1
  36. package/lib/types/utils/folderIndex.d.ts +47 -0
  37. package/lib/types/utils/folderIndex.d.ts.map +1 -0
  38. package/package.json +1 -1
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Internals shared by the folder index layers and by `uploadFolder`. Not part
18
+ * of the package's public surface.
19
+ */
20
+ /** Tag carrying the sha-256 of a file's own bytes, as lowercase hex. */
21
+ export declare const contentHashTagName = "File-SHA256";
22
+ /** True for a lowercase hex sha-256 digest of a file's bytes. */
23
+ export declare function isValidContentHash(hash: string | undefined): hash is string;
24
+ /**
25
+ * A folder index key is `<sha-256 of the bytes>.<sha-256 of the tags>`.
26
+ *
27
+ * Both halves matter. Keying on the bytes alone would reuse an item whose tags
28
+ * are not the ones the caller asked for: an empty `a.css` and an empty `b.js`
29
+ * hash identically, and reusing one for the other would serve JavaScript as
30
+ * `text/css`. Keying on the tags as well means a reused data item is always
31
+ * exactly the data item this call would otherwise have created.
32
+ *
33
+ * The bytes half is kept in the clear so a layer that queries a gateway can
34
+ * recover it and filter on the `File-SHA256` tag.
35
+ */
36
+ export declare function isValidFolderIndexKey(key: string | undefined): key is string;
37
+ /** The bytes half of a folder index key. */
38
+ export declare function contentHashFromFolderIndexKey(key: string): string;
39
+ /** The folder index key for a file with these bytes and these final tags. */
40
+ export declare function folderIndexKey({ contentHash, tags, }: {
41
+ contentHash: string;
42
+ tags: {
43
+ name: string;
44
+ value: string;
45
+ }[];
46
+ }): Promise<string>;
47
+ //# sourceMappingURL=folderIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folderIndex.d.ts","sourceRoot":"","sources":["../../../src/utils/folderIndex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AAEH,wEAAwE;AACxE,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAKhD,iEAAiE;AACjE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,IAAI,MAAM,CAE3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,MAAM,CAE5E;AAED,4CAA4C;AAC5C,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjE;AAmCD,6EAA6E;AAC7E,wBAAsB,cAAc,CAAC,EACnC,WAAW,EACX,IAAI,GACL,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzC,GAAG,OAAO,CAAC,MAAM,CAAC,CAElB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.42.0-alpha.13",
3
+ "version": "1.42.0-alpha.15",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",