@fangorn-network/sdk 0.1.0-dev → 0.1.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.
Files changed (96) hide show
  1. package/lib/cli/cli.js +328 -128
  2. package/lib/cli/index.d.ts +4 -1
  3. package/lib/cli/index.js +20 -2
  4. package/lib/config.d.ts +111 -48
  5. package/lib/config.js +39 -11
  6. package/lib/contracts/app-registry/abi.d.ts +1265 -0
  7. package/lib/contracts/app-registry/abi.js +1454 -0
  8. package/lib/contracts/app-registry/index.d.ts +161 -0
  9. package/lib/contracts/app-registry/index.js +274 -0
  10. package/lib/contracts/data-registry/abi.d.ts +19 -195
  11. package/lib/contracts/data-registry/abi.js +206 -409
  12. package/lib/contracts/data-registry/index.d.ts +2 -126
  13. package/lib/contracts/data-registry/index.js +1 -174
  14. package/lib/contracts/index.d.ts +7 -4
  15. package/lib/contracts/index.js +7 -4
  16. package/lib/contracts/logs.d.ts +1 -1
  17. package/lib/contracts/logs.js +1 -1
  18. package/lib/contracts/{settlement-registry → membership-registry}/abi.d.ts +636 -301
  19. package/lib/contracts/membership-registry/abi.js +1333 -0
  20. package/lib/contracts/membership-registry/index.d.ts +79 -0
  21. package/lib/contracts/membership-registry/index.js +104 -0
  22. package/lib/contracts/types.d.ts +10 -0
  23. package/lib/contracts/types.js +12 -0
  24. package/lib/crypto/aes.d.ts +2 -2
  25. package/lib/crypto/aes.js +4 -4
  26. package/lib/crypto/encryption.d.ts +109 -8
  27. package/lib/crypto/encryption.js +114 -16
  28. package/lib/engine/car.d.ts +1 -5
  29. package/lib/engine/car.js +2 -2
  30. package/lib/engine/index.d.ts +14 -33
  31. package/lib/engine/index.js +41 -98
  32. package/lib/engine/records.d.ts +8 -19
  33. package/lib/engine/records.js +7 -81
  34. package/lib/engine/test-helpers.d.ts +3 -2
  35. package/lib/engine/test-helpers.js +5 -7
  36. package/lib/erc8004.js +10 -7
  37. package/lib/fangorn.d.ts +86 -65
  38. package/lib/fangorn.js +153 -115
  39. package/lib/feed.d.ts +8 -7
  40. package/lib/feed.js +8 -7
  41. package/lib/harness/examples/hackmd/build-markdown-graph.d.ts +1 -0
  42. package/lib/harness/examples/hackmd/build-markdown-graph.js +17 -0
  43. package/lib/harness/index.d.ts +58 -0
  44. package/lib/harness/index.js +73 -0
  45. package/lib/index.d.ts +13 -10
  46. package/lib/index.js +13 -10
  47. package/lib/node_modules/{@jridgewell → .pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell}/sourcemap-codec/dist/sourcemap-codec.js +1 -1
  48. package/lib/node_modules/{@vitest → .pnpm/@vitest_expect@4.0.18/node_modules/@vitest}/expect/dist/index.js +8 -8
  49. package/lib/node_modules/{@vitest → .pnpm/@vitest_pretty-format@4.0.18/node_modules/@vitest}/pretty-format/dist/index.js +2 -2
  50. package/lib/node_modules/{@vitest → .pnpm/@vitest_runner@4.0.18/node_modules/@vitest}/runner/dist/chunk-tasks.js +2 -2
  51. package/lib/node_modules/{@vitest → .pnpm/@vitest_runner@4.0.18/node_modules/@vitest}/runner/dist/index.js +4 -4
  52. package/lib/node_modules/{@vitest → .pnpm/@vitest_snapshot@4.0.18/node_modules/@vitest}/snapshot/dist/index.js +4 -4
  53. package/lib/node_modules/{@vitest → .pnpm/@vitest_spy@4.0.18/node_modules/@vitest}/spy/dist/index.js +1 -1
  54. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/chunk-_commonjsHelpers.js +1 -1
  55. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/chunk-pathe.M-eThtNZ.js +1 -1
  56. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/diff.js +3 -3
  57. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/display.js +2 -2
  58. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/error.js +2 -2
  59. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/helpers.js +1 -1
  60. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/serialize.js +1 -1
  61. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/source-map.js +1 -1
  62. package/lib/node_modules/{@vitest → .pnpm/@vitest_utils@4.0.18/node_modules/@vitest}/utils/dist/timers.js +1 -1
  63. package/lib/node_modules/{chai → .pnpm/chai@6.2.2/node_modules/chai}/index.js +1 -1
  64. package/lib/node_modules/{magic-string → .pnpm/magic-string@0.30.21/node_modules/magic-string}/dist/magic-string.es.js +2 -2
  65. package/lib/node_modules/{pathe → .pnpm/pathe@2.0.3/node_modules/pathe}/dist/shared/pathe.M-eThtNZ.js +1 -1
  66. package/lib/node_modules/{tinyrainbow → .pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow}/dist/index.js +1 -1
  67. package/lib/node_modules/{vitest → .pnpm/vitest@4.0.18_@types_node@24.10.1_jiti@2.6.1_terser@5.51.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest}/dist/chunks/_commonjsHelpers.D26ty3Ew.js +1 -1
  68. package/lib/node_modules/{vitest → .pnpm/vitest@4.0.18_@types_node@24.10.1_jiti@2.6.1_terser@5.51.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest}/dist/chunks/date.Bq6ZW5rf.js +1 -1
  69. package/lib/node_modules/{vitest → .pnpm/vitest@4.0.18_@types_node@24.10.1_jiti@2.6.1_terser@5.51.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest}/dist/chunks/utils.DvEY5TfP.js +2 -2
  70. package/lib/node_modules/{vitest → .pnpm/vitest@4.0.18_@types_node@24.10.1_jiti@2.6.1_terser@5.51.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest}/dist/chunks/vi.2VT5v0um.js +11 -11
  71. package/lib/providers/storage/signed-url.d.ts +10 -2
  72. package/lib/providers/storage/signed-url.js +15 -5
  73. package/lib/providers/storage/types.d.ts +1 -1
  74. package/lib/providers/storage/utils.js +3 -5
  75. package/lib/registry.d.ts +118 -0
  76. package/lib/registry.js +184 -0
  77. package/lib/test/mem-registry.d.ts +19 -14
  78. package/lib/test/mem-registry.js +37 -44
  79. package/lib/test/sdk-suite.d.ts +4 -1
  80. package/lib/test/sdk-suite.js +89 -18
  81. package/lib/test/testbed.d.ts +5227 -5218
  82. package/lib/test/testbed.js +56 -29
  83. package/lib/types/index.d.ts +11 -6
  84. package/package.json +1 -1
  85. package/lib/cli/sell.d.ts +0 -28
  86. package/lib/cli/sell.js +0 -95
  87. package/lib/cli/stage.d.ts +0 -19
  88. package/lib/cli/stage.js +0 -94
  89. package/lib/contracts/settlement-registry/abi.js +0 -962
  90. package/lib/contracts/settlement-registry/index.d.ts +0 -143
  91. package/lib/contracts/settlement-registry/index.js +0 -213
  92. package/lib/crypto/paid.d.ts +0 -104
  93. package/lib/crypto/paid.js +0 -147
  94. package/lib/test/key-server.d.ts +0 -12
  95. package/lib/test/key-server.js +0 -30
  96. /package/lib/node_modules/{@vitest → .pnpm/@vitest_runner@4.0.18/node_modules/@vitest}/runner/dist/utils.js +0 -0
@@ -0,0 +1,73 @@
1
+ import { readFileSync, readdirSync, statSync } from "fs";
2
+ import { basename, extname, join } from "path";
3
+
4
+ //#region src/harness/index.ts
5
+ /**
6
+ * Traverses a directory, parses files based on their extensions,
7
+ * and generates a strictly validated Fangorn-compliant commit graph.
8
+ */
9
+ function buildAssetGraph(dir, options = {}) {
10
+ const { processors = {} } = options;
11
+ const rawFiles = readdirSync(dir);
12
+ const getId = (f) => basename(f, extname(f));
13
+ const validIds = new Set(rawFiles.map(getId));
14
+ const vertices = [];
15
+ const edges = /* @__PURE__ */ new Set();
16
+ for (const f of rawFiles) {
17
+ const ext = extname(f).toLowerCase();
18
+ const processor = processors[ext];
19
+ const fromId = getId(f);
20
+ const fullPath = join(dir, f);
21
+ const fileFacade = {
22
+ name: f,
23
+ nameNoExt: fromId,
24
+ ext,
25
+ path: fullPath,
26
+ readText: () => readFileSync(fullPath, "utf-8"),
27
+ readBuffer: () => readFileSync(fullPath),
28
+ stat: () => statSync(fullPath)
29
+ };
30
+ try {
31
+ const { tag = "asset", payload = {}, links = [] } = processor(fileFacade);
32
+ vertices.push({
33
+ id: fromId,
34
+ tag,
35
+ payload
36
+ });
37
+ for (const toId of links) if (toId && fromId !== toId && validIds.has(toId)) edges.add(JSON.stringify({
38
+ rel: "links",
39
+ from: fromId,
40
+ to: toId
41
+ }));
42
+ } catch (err) {
43
+ console.error(`Fangorn Error processing file ${f}:`, err);
44
+ }
45
+ }
46
+ return {
47
+ vertices,
48
+ edges: Array.from(edges).map((e) => JSON.parse(e))
49
+ };
50
+ }
51
+ /**
52
+ * Utility helper to scan markdown strings for standard markdown links or wikilinks.
53
+ */
54
+ function extractMarkdownLinks(content) {
55
+ const LINK_REGEX = /\]\(([^)\s]+?\.md)(?:#[^)]*)?\)|\[\[([^\]|#]+?)(?:[|#][^\]]*)?\]\]/g;
56
+ const links = [];
57
+ const convertToId = (str) => basename(str, extname(str));
58
+ for (const match of content.matchAll(LINK_REGEX)) {
59
+ const rawTarget = match[1];
60
+ if (rawTarget) links.push(convertToId(rawTarget));
61
+ }
62
+ return links;
63
+ }
64
+ const buildMarkdownGraph = (dir) => {
65
+ return buildAssetGraph(dir, { processors: { ".md": (file) => ({
66
+ tag: "doc",
67
+ payload: { content: file.readText() },
68
+ links: extractMarkdownLinks(file.readText())
69
+ }) } });
70
+ };
71
+
72
+ //#endregion
73
+ export { buildAssetGraph, buildMarkdownGraph, extractMarkdownLinks };
package/lib/index.d.ts CHANGED
@@ -1,17 +1,20 @@
1
+ import { AppConfig, ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, SupportedNetworks, appId, nonBlank, toAppId } from "./config.js";
2
+ import { APP_REGISTRY_ABI } from "./contracts/app-registry/abi.js";
3
+ import { PublisherStatus } from "./contracts/types.js";
1
4
  import { PreparedTx } from "./contracts/write.js";
2
- import { ChainRegistry, ChainRegistryConfig, CommitUpdate, EPOCH_SECONDS, LogFilter, Registry, RepoRef, UPDATE_TYPES, UpdateEntry, WINDOW, ZERO_HEAD, dataDomain, epochOf, repoId, updateMessage } from "./contracts/data-registry/index.js";
5
+ import { AppAccess, AppAgentLog, AppRegistryClient } from "./contracts/app-registry/index.js";
3
6
  import { DATA_REGISTRY_ABI } from "./contracts/data-registry/abi.js";
4
- import { RegisterArgs, SettleArgs, SettlementPayment, SettlementRegistryClient, TERMS_TYPES, Terms, TermsJson, WHOLE_REPO, recordKey, registerNonce, settlementDomain, subjectOf, termsFromJson, termsToJson } from "./contracts/settlement-registry/index.js";
5
- import { SETTLEMENT_REGISTRY_ABI } from "./contracts/settlement-registry/abi.js";
7
+ import { repoId } from "./contracts/data-registry/index.js";
8
+ import { ClaimArgs, JoinArgs, MembershipPayment, MembershipRegistryClient, joinNonce, membershipScope, membershipTokenId } from "./contracts/membership-registry/index.js";
9
+ import { MEMBERSHIP_REGISTRY_ABI } from "./contracts/membership-registry/abi.js";
6
10
  import "./contracts/index.js";
7
- import { BaseSepoliaConfig, FangornConfig, NetworkConfig, SupportedNetworks, nonBlank } from "./config.js";
11
+ import { AccessRequest, AccessSigner, DecryptHandleParams, EncryptAndUploadParams, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, Gadget, HandleFieldInput, X25519_PUBKEY_LENGTH, accessMessageHash, buildAccessRequest, decryptHandle, encryptAndUpload, seal, sealSelf, sha256Hex, unseal, unsealSelf } from "./crypto/encryption.js";
12
+ import { ChainRegistry, ChainRegistryConfig, EPOCH_SECONDS, Exclusion, LogFilter, Registry, RepoRef, UpdateEntry, ZERO_HEAD, covers, epochOf, exclusionId, repoExcluded } from "./registry.js";
8
13
  import { FangornContext, FangornCreateOptions, StorageConfig } from "./types/index.js";
9
- import { CommitFeed } from "./feed.js";
10
- import { AgentCard, CARD_RECORD, FANGORN_REPO_EXTENSION, Fangorn, RepoChange, SubscribeOptions } from "./fangorn.js";
11
- import { SellOptions, sealRecords } from "./cli/sell.js";
12
- import { AccessSigner, GADGET_SELF_HKDF_V1, X25519_PUBKEY_LENGTH, seal, sealSelf, unseal, unsealSelf } from "./crypto/encryption.js";
13
- import { AccessRequest, Deposit, FieldHandle, GADGET_FIELD_V1, PaidScope, accessMessage, buildAccessRequest, decryptField, deriveRecordKey, encryptField, makeDeposit, newRepoKey, openField, requestKey, sealField, statement } from "./crypto/paid.js";
14
+ import { AppFeed } from "./feed.js";
15
+ import { AgentCard, FANGORN_APP_EXTENSION, Fangorn, RepoChange, SubscribeOptions } from "./fangorn.js";
16
+ import { AssetProcessor, BuildAssetGraphOptions, CommitFileGraph, Edge, FileFacade, ProcessorResult, Vertex, buildAssetGraph, buildMarkdownGraph, extractMarkdownLinks } from "./harness/index.js";
14
17
  import { PinataBackend } from "./providers/storage/pinata.js";
15
18
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend, SignedUrlSigner } from "./providers/storage/signed-url.js";
16
19
  import { MAX_UPLOAD_ATTEMPTS, deserialize, fetchRawByCid, isTransientUpload, retrieveByCid, serialize, withUploadRetry } from "./providers/storage/utils.js";
17
- export { AccessRequest, AccessSigner, AgentCard, BaseSepoliaConfig, CARD_RECORD, ChainRegistry, ChainRegistryConfig, CommitFeed, CommitUpdate, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, Deposit, EPOCH_SECONDS, FANGORN_REPO_EXTENSION, Fangorn, FangornConfig, FangornContext, FangornCreateOptions, FieldHandle, GADGET_FIELD_V1, GADGET_SELF_HKDF_V1, LogFilter, MAX_UPLOAD_ATTEMPTS, NetworkConfig, PaidScope, PinataBackend, PreparedTx, RegisterArgs, Registry, RepoChange, RepoRef, SETTLEMENT_REGISTRY_ABI, SellOptions, SettleArgs, SettlementPayment, SettlementRegistryClient, SignedUrlBackend, SignedUrlSigner, StorageConfig, SubscribeOptions, SupportedNetworks, TERMS_TYPES, Terms, TermsJson, UPDATE_TYPES, UpdateEntry, WHOLE_REPO, WINDOW, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessage, buildAccessRequest, dataDomain, decryptField, deriveRecordKey, deserialize, encryptField, epochOf, fetchRawByCid, isTransientUpload, makeDeposit, newRepoKey, nonBlank, openField, recordKey, registerNonce, repoId, requestKey, retrieveByCid, seal, sealField, sealRecords, sealSelf, serialize, settlementDomain, statement, subjectOf, termsFromJson, termsToJson, unseal, unsealSelf, updateMessage, withUploadRetry };
20
+ export { APP_REGISTRY_ABI, AccessRequest, AccessSigner, AgentCard, AppAccess, AppAgentLog, AppConfig, AppFeed, AppRegistryClient, ArbitrumSepoliaConfig, AssetProcessor, BaseSepoliaConfig, BuildAssetGraphOptions, ChainRegistry, ChainRegistryConfig, ClaimArgs, CommitFileGraph, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, DecryptHandleParams, EPOCH_SECONDS, Edge, EncryptAndUploadParams, Exclusion, FANGORN_APP_EXTENSION, Fangorn, FangornConfig, FangornContext, FangornCreateOptions, FileFacade, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, Gadget, HandleFieldInput, JoinArgs, LogFilter, MAX_UPLOAD_ATTEMPTS, MEMBERSHIP_REGISTRY_ABI, MembershipPayment, MembershipRegistryClient, PinataBackend, PreparedTx, ProcessorResult, PublisherStatus, Registry, RepoChange, RepoRef, SignedUrlBackend, SignedUrlSigner, StorageConfig, SubscribeOptions, SupportedNetworks, UpdateEntry, Vertex, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, covers, decryptHandle, deserialize, encryptAndUpload, epochOf, exclusionId, extractMarkdownLinks, fetchRawByCid, isTransientUpload, joinNonce, membershipScope, membershipTokenId, nonBlank, repoExcluded, repoId, retrieveByCid, seal, sealSelf, serialize, sha256Hex, toAppId, unseal, unsealSelf, withUploadRetry };
package/lib/index.js CHANGED
@@ -1,16 +1,19 @@
1
- import { BaseSepoliaConfig, FangornConfig, SupportedNetworks, nonBlank } from "./config.js";
1
+ import { ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, SupportedNetworks, appId, nonBlank, toAppId } from "./config.js";
2
2
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend } from "./providers/storage/signed-url.js";
3
3
  import { MAX_UPLOAD_ATTEMPTS, deserialize, fetchRawByCid, isTransientUpload, retrieveByCid, serialize, withUploadRetry } from "./providers/storage/utils.js";
4
4
  import { PinataBackend } from "./providers/storage/pinata.js";
5
+ import { APP_REGISTRY_ABI } from "./contracts/app-registry/abi.js";
6
+ import { AppRegistryClient } from "./contracts/app-registry/index.js";
7
+ import { repoId } from "./contracts/data-registry/index.js";
5
8
  import { DATA_REGISTRY_ABI } from "./contracts/data-registry/abi.js";
6
- import { ChainRegistry, EPOCH_SECONDS, UPDATE_TYPES, WINDOW, ZERO_HEAD, dataDomain, epochOf, repoId, updateMessage } from "./contracts/data-registry/index.js";
7
- import { SETTLEMENT_REGISTRY_ABI } from "./contracts/settlement-registry/abi.js";
8
- import { SettlementRegistryClient, TERMS_TYPES, WHOLE_REPO, recordKey, registerNonce, settlementDomain, subjectOf, termsFromJson, termsToJson } from "./contracts/settlement-registry/index.js";
9
+ import { MEMBERSHIP_REGISTRY_ABI } from "./contracts/membership-registry/abi.js";
10
+ import { MembershipRegistryClient, joinNonce, membershipScope, membershipTokenId } from "./contracts/membership-registry/index.js";
11
+ import { PublisherStatus } from "./contracts/types.js";
9
12
  import "./contracts/index.js";
10
- import { CommitFeed } from "./feed.js";
11
- import { CARD_RECORD, FANGORN_REPO_EXTENSION, Fangorn } from "./fangorn.js";
12
- import { GADGET_SELF_HKDF_V1, X25519_PUBKEY_LENGTH, seal, sealSelf, unseal, unsealSelf } from "./crypto/encryption.js";
13
- import { GADGET_FIELD_V1, accessMessage, buildAccessRequest, decryptField, deriveRecordKey, encryptField, makeDeposit, newRepoKey, openField, requestKey, sealField, statement } from "./crypto/paid.js";
14
- import { sealRecords } from "./cli/sell.js";
13
+ import { ChainRegistry, EPOCH_SECONDS, ZERO_HEAD, covers, epochOf, exclusionId, repoExcluded } from "./registry.js";
14
+ import { AppFeed } from "./feed.js";
15
+ import { FANGORN_APP_EXTENSION, Fangorn } from "./fangorn.js";
16
+ import { buildAssetGraph, buildMarkdownGraph, extractMarkdownLinks } from "./harness/index.js";
17
+ import { GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, X25519_PUBKEY_LENGTH, accessMessageHash, buildAccessRequest, decryptHandle, encryptAndUpload, seal, sealSelf, sha256Hex, unseal, unsealSelf } from "./crypto/encryption.js";
15
18
 
16
- export { BaseSepoliaConfig, CARD_RECORD, ChainRegistry, CommitFeed, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, EPOCH_SECONDS, FANGORN_REPO_EXTENSION, Fangorn, FangornConfig, GADGET_FIELD_V1, GADGET_SELF_HKDF_V1, MAX_UPLOAD_ATTEMPTS, PinataBackend, SETTLEMENT_REGISTRY_ABI, SettlementRegistryClient, SignedUrlBackend, SupportedNetworks, TERMS_TYPES, UPDATE_TYPES, WHOLE_REPO, WINDOW, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessage, buildAccessRequest, dataDomain, decryptField, deriveRecordKey, deserialize, encryptField, epochOf, fetchRawByCid, isTransientUpload, makeDeposit, newRepoKey, nonBlank, openField, recordKey, registerNonce, repoId, requestKey, retrieveByCid, seal, sealField, sealRecords, sealSelf, serialize, settlementDomain, statement, subjectOf, termsFromJson, termsToJson, unseal, unsealSelf, updateMessage, withUploadRetry };
19
+ export { APP_REGISTRY_ABI, AppFeed, AppRegistryClient, ArbitrumSepoliaConfig, BaseSepoliaConfig, ChainRegistry, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, EPOCH_SECONDS, FANGORN_APP_EXTENSION, Fangorn, FangornConfig, GADGET_SELF_HKDF_V1, GADGET_WORKER_USDC_V1, MAX_UPLOAD_ATTEMPTS, MEMBERSHIP_REGISTRY_ABI, MembershipRegistryClient, PinataBackend, PublisherStatus, SignedUrlBackend, SupportedNetworks, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessageHash, appId, buildAccessRequest, buildAssetGraph, buildMarkdownGraph, covers, decryptHandle, deserialize, encryptAndUpload, epochOf, exclusionId, extractMarkdownLinks, fetchRawByCid, isTransientUpload, joinNonce, membershipScope, membershipTokenId, nonBlank, repoExcluded, repoId, retrieveByCid, seal, sealSelf, serialize, sha256Hex, toAppId, unseal, unsealSelf, withUploadRetry };
@@ -1,4 +1,4 @@
1
- //#region node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
1
+ //#region node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
2
2
  var comma = ",".charCodeAt(0);
3
3
  var semicolon = ";".charCodeAt(0);
4
4
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -1,12 +1,12 @@
1
- import { C } from "../../../tinyrainbow/dist/index.js";
2
- import { stringify } from "../../utils/dist/display.js";
3
- import { assertTypes, getType, isObject, noop } from "../../utils/dist/helpers.js";
4
- import { diff, printDiffOrStringify } from "../../utils/dist/diff.js";
5
- import { isMockFunction } from "../../spy/dist/index.js";
6
- import { processError } from "../../utils/dist/error.js";
7
- import { use, utils_exports } from "../../../chai/index.js";
1
+ import { C } from "../../../../../tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js";
2
+ import { stringify } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/display.js";
3
+ import { assertTypes, getType, isObject, noop } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/helpers.js";
4
+ import { diff, printDiffOrStringify } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/diff.js";
5
+ import { isMockFunction } from "../../../../../@vitest_spy@4.0.18/node_modules/@vitest/spy/dist/index.js";
6
+ import { processError } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/error.js";
7
+ import { use, utils_exports } from "../../../../../chai@6.2.2/node_modules/chai/index.js";
8
8
 
9
- //#region node_modules/@vitest/expect/dist/index.js
9
+ //#region node_modules/.pnpm/@vitest+expect@4.0.18/node_modules/@vitest/expect/dist/index.js
10
10
  const MATCHERS_OBJECT = Symbol.for("matchers-object");
11
11
  const JEST_MATCHERS_OBJECT = Symbol.for("$$jest-matchers-object");
12
12
  const GLOBAL_EXPECT = Symbol.for("expect-global");
@@ -1,6 +1,6 @@
1
- import { C } from "../../../tinyrainbow/dist/index.js";
1
+ import { C } from "../../../../../tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js";
2
2
 
3
- //#region node_modules/@vitest/pretty-format/dist/index.js
3
+ //#region node_modules/.pnpm/@vitest+pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.js
4
4
  function _mergeNamespaces(n, m) {
5
5
  m.forEach(function(e) {
6
6
  e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
@@ -1,6 +1,6 @@
1
- import { parseSingleStack } from "../../utils/dist/source-map.js";
1
+ import { parseSingleStack } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/source-map.js";
2
2
 
3
- //#region node_modules/@vitest/runner/dist/chunk-tasks.js
3
+ //#region node_modules/.pnpm/@vitest+runner@4.0.18/node_modules/@vitest/runner/dist/chunk-tasks.js
4
4
  function createChainable(keys, fn) {
5
5
  function create(context) {
6
6
  const chain$1 = function(...args) {
@@ -1,9 +1,9 @@
1
- import { format, formatRegExp, objDisplay } from "../../utils/dist/display.js";
2
- import { assertTypes, createDefer, isNegativeNaN, isObject, objectAttr, toArray } from "../../utils/dist/helpers.js";
3
- import { getSafeTimers } from "../../utils/dist/timers.js";
1
+ import { format, formatRegExp, objDisplay } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/display.js";
2
+ import { assertTypes, createDefer, isNegativeNaN, isObject, objectAttr, toArray } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/helpers.js";
3
+ import { getSafeTimers } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/timers.js";
4
4
  import { createChainable, createTaskName, findTestFileStackTrace } from "./chunk-tasks.js";
5
5
 
6
- //#region node_modules/@vitest/runner/dist/index.js
6
+ //#region node_modules/.pnpm/@vitest+runner@4.0.18/node_modules/@vitest/runner/dist/index.js
7
7
  var PendingError = class extends Error {
8
8
  code = "VITEST_PENDING";
9
9
  taskId;
@@ -1,7 +1,7 @@
1
- import { format, plugins } from "../../pretty-format/dist/index.js";
2
- import { resolve } from "../../../pathe/dist/shared/pathe.M-eThtNZ.js";
1
+ import { format, plugins } from "../../../../../@vitest_pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.js";
2
+ import { resolve } from "../../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js";
3
3
 
4
- //#region node_modules/@vitest/snapshot/dist/index.js
4
+ //#region node_modules/.pnpm/@vitest+snapshot@4.0.18/node_modules/@vitest/snapshot/dist/index.js
5
5
  var comma = ",".charCodeAt(0);
6
6
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
7
7
  var intToChar = new Uint8Array(64);
@@ -420,7 +420,7 @@ function offsetToLineNumber(source, offset) {
420
420
  return line + 1;
421
421
  }
422
422
  async function saveInlineSnapshots(environment, snapshots) {
423
- const MagicString = (await import("../../../magic-string/dist/magic-string.es.js")).default;
423
+ const MagicString = (await import("../../../../../magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js")).default;
424
424
  const files = new Set(snapshots.map((i) => i.file));
425
425
  await Promise.all(Array.from(files).map(async (file) => {
426
426
  const snaps = snapshots.filter((i) => i.file === file);
@@ -1,4 +1,4 @@
1
- //#region node_modules/@vitest/spy/dist/index.js
1
+ //#region node_modules/.pnpm/@vitest+spy@4.0.18/node_modules/@vitest/spy/dist/index.js
2
2
  function isMockFunction(fn$1) {
3
3
  return typeof fn$1 === "function" && "_isMockFunction" in fn$1 && fn$1._isMockFunction === true;
4
4
  }
@@ -1,4 +1,4 @@
1
- //#region node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js
1
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js
2
2
  function getDefaultExportFromCjs(x) {
3
3
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4
4
  }
@@ -1,4 +1,4 @@
1
- //#region node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
1
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
2
2
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
3
3
  function normalizeWindowsPath(input = "") {
4
4
  if (!input) return input;
@@ -1,10 +1,10 @@
1
- import { C } from "../../../tinyrainbow/dist/index.js";
2
- import { format, plugins } from "../../pretty-format/dist/index.js";
1
+ import { C } from "../../../../../tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js";
2
+ import { format, plugins } from "../../../../../@vitest_pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.js";
3
3
  import { stringify } from "./display.js";
4
4
  import { deepClone, getOwnProperties, getType } from "./helpers.js";
5
5
  import { getDefaultExportFromCjs } from "./chunk-_commonjsHelpers.js";
6
6
 
7
- //#region node_modules/@vitest/utils/dist/diff.js
7
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/diff.js
8
8
  /**
9
9
  * Diff Match and Patch
10
10
  * Copyright 2018 The diff-match-patch Authors.
@@ -1,6 +1,6 @@
1
- import { format, plugins } from "../../pretty-format/dist/index.js";
1
+ import { format, plugins } from "../../../../../@vitest_pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.js";
2
2
 
3
- //#region node_modules/@vitest/utils/dist/display.js
3
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/display.js
4
4
  const ansiColors = {
5
5
  bold: ["1", "22"],
6
6
  dim: ["2", "22"],
@@ -1,9 +1,9 @@
1
- import "../../../tinyrainbow/dist/index.js";
1
+ import "../../../../../tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js";
2
2
  import { stringify } from "./display.js";
3
3
  import { printDiffOrStringify } from "./diff.js";
4
4
  import { serializeValue } from "./serialize.js";
5
5
 
6
- //#region node_modules/@vitest/utils/dist/error.js
6
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/error.js
7
7
  function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
8
8
  if (!_err || typeof _err !== "object") return { message: String(_err) };
9
9
  const err = _err;
@@ -1,4 +1,4 @@
1
- //#region node_modules/@vitest/utils/dist/helpers.js
1
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/helpers.js
2
2
  /**
3
3
  * Get original stacktrace without source map support the most performant way.
4
4
  * - Create only 1 stack frame.
@@ -1,4 +1,4 @@
1
- //#region node_modules/@vitest/utils/dist/serialize.js
1
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/serialize.js
2
2
  const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
3
3
  const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
4
4
  function isImmutable(v) {
@@ -1,6 +1,6 @@
1
1
  import { resolve } from "./chunk-pathe.M-eThtNZ.js";
2
2
 
3
- //#region node_modules/@vitest/utils/dist/source-map.js
3
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/source-map.js
4
4
  var comma = ",".charCodeAt(0);
5
5
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6
6
  var intToChar = new Uint8Array(64);
@@ -1,4 +1,4 @@
1
- //#region node_modules/@vitest/utils/dist/timers.js
1
+ //#region node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/timers.js
2
2
  const SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS");
3
3
  function getSafeTimers() {
4
4
  const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
@@ -1,4 +1,4 @@
1
- //#region node_modules/chai/index.js
1
+ //#region node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
4
4
  enumerable: true,
@@ -1,6 +1,6 @@
1
- import { encode } from "../../@jridgewell/sourcemap-codec/dist/sourcemap-codec.js";
1
+ import { encode } from "../../../../@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js";
2
2
 
3
- //#region node_modules/magic-string/dist/magic-string.es.mjs
3
+ //#region node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs
4
4
  var BitSet = class BitSet {
5
5
  constructor(arg) {
6
6
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
@@ -1,4 +1,4 @@
1
- //#region node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
1
+ //#region node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
2
2
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
3
3
  function normalizeWindowsPath(input = "") {
4
4
  if (!input) return input;
@@ -1,4 +1,4 @@
1
- //#region node_modules/tinyrainbow/dist/index.js
1
+ //#region node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js
2
2
  var d = {
3
3
  reset: [0, 0],
4
4
  bold: [
@@ -1,4 +1,4 @@
1
- //#region node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
1
+ //#region node_modules/.pnpm/vitest@4.0.18_@types+node@24.10.1_jiti@2.6.1_terser@5.51.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
2
2
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
3
3
 
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- //#region node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
1
+ //#region node_modules/.pnpm/vitest@4.0.18_@types+node@24.10.1_jiti@2.6.1_terser@5.51.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
2
2
  const RealDate = Date;
3
3
  let now = null;
4
4
  var MockDate = class MockDate extends RealDate {
@@ -1,6 +1,6 @@
1
- import { getSafeTimers } from "../../../@vitest/utils/dist/timers.js";
1
+ import { getSafeTimers } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/timers.js";
2
2
 
3
- //#region node_modules/vitest/dist/chunks/utils.DvEY5TfP.js
3
+ //#region node_modules/.pnpm/vitest@4.0.18_@types+node@24.10.1_jiti@2.6.1_terser@5.51.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/chunks/utils.DvEY5TfP.js
4
4
  const NAME_WORKER_STATE = "__vitest_worker__";
5
5
  function getWorkerState() {
6
6
  const workerState = globalThis[NAME_WORKER_STATE];
@@ -1,18 +1,18 @@
1
- import { assertTypes, createSimpleStackTrace } from "../../../@vitest/utils/dist/helpers.js";
2
- import { clearAllMocks, fn, isMockFunction, resetAllMocks, restoreAllMocks, spyOn } from "../../../@vitest/spy/dist/index.js";
3
- import { Assertion, assert as assert$1, expect, should as should$1, use, utils_exports } from "../../../chai/index.js";
4
- import { ASYMMETRIC_MATCHERS_OBJECT, GLOBAL_EXPECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, addCustomEqualityTesters, customMatchers, equals, getState, iterableEquality, setState, subsetEquality } from "../../../@vitest/expect/dist/index.js";
5
- import { delay, getSafeTimers } from "../../../@vitest/utils/dist/timers.js";
6
- import { parseSingleStack } from "../../../@vitest/utils/dist/source-map.js";
7
- import { getNames } from "../../../@vitest/runner/dist/chunk-tasks.js";
8
- import { getCurrentTest } from "../../../@vitest/runner/dist/index.js";
1
+ import { assertTypes, createSimpleStackTrace } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/helpers.js";
2
+ import { clearAllMocks, fn, isMockFunction, resetAllMocks, restoreAllMocks, spyOn } from "../../../../../@vitest_spy@4.0.18/node_modules/@vitest/spy/dist/index.js";
3
+ import { Assertion, assert as assert$1, expect, should as should$1, use, utils_exports } from "../../../../../chai@6.2.2/node_modules/chai/index.js";
4
+ import { ASYMMETRIC_MATCHERS_OBJECT, GLOBAL_EXPECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, addCustomEqualityTesters, customMatchers, equals, getState, iterableEquality, setState, subsetEquality } from "../../../../../@vitest_expect@4.0.18/node_modules/@vitest/expect/dist/index.js";
5
+ import { delay, getSafeTimers } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/timers.js";
6
+ import { parseSingleStack } from "../../../../../@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/source-map.js";
7
+ import { getNames } from "../../../../../@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/chunk-tasks.js";
8
+ import { getCurrentTest } from "../../../../../@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/index.js";
9
9
  import { getWorkerState, isChildProcess, resetModules, waitForImportsToResolve } from "./utils.DvEY5TfP.js";
10
- import "../../../@vitest/runner/dist/utils.js";
11
- import { SnapshotClient, addSerializer, stripSnapshotIndentation } from "../../../@vitest/snapshot/dist/index.js";
10
+ import "../../../../../@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/utils.js";
11
+ import { SnapshotClient, addSerializer, stripSnapshotIndentation } from "../../../../../@vitest_snapshot@4.0.18/node_modules/@vitest/snapshot/dist/index.js";
12
12
  import { commonjsGlobal } from "./_commonjsHelpers.D26ty3Ew.js";
13
13
  import { RealDate, mockDate, resetDate } from "./date.Bq6ZW5rf.js";
14
14
 
15
- //#region node_modules/vitest/dist/chunks/vi.2VT5v0um.js
15
+ //#region node_modules/.pnpm/vitest@4.0.18_@types+node@24.10.1_jiti@2.6.1_terser@5.51.2_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/chunks/vi.2VT5v0um.js
16
16
  const unsupported = [
17
17
  "matchSnapshot",
18
18
  "toMatchSnapshot",
@@ -29,13 +29,21 @@ interface SignedUrlSigner {
29
29
  * JWT-only operations (server-side metadata queries / deletes) are unavailable
30
30
  * here. Switch to a PinataBackend they're needed.
31
31
  *
32
- * Every upload is charged to the signing publisher's storage quota.
32
+ * Apps provide storage: every upload is billed to the client's app, whose
33
+ * subscription pays for it. Each request carries the app id, the signer must be
34
+ * one of that app's publishers, and the pins are filed under the app's group.
35
+ * There is no app-less upload: with no app this refuses before contacting the
36
+ * worker. The id is read per request so a later `setAppId` takes effect
37
+ * immediately.
33
38
  */
34
39
  declare class SignedUrlBackend implements MetadataStorage {
35
40
  private readonly signer;
36
41
  private readonly gateway;
42
+ /** The client's current app id, read per upload (see setAppId). */
43
+ private readonly appId;
37
44
  private readonly workerUrl;
38
- constructor(workerUrl: string | undefined, signer: SignedUrlSigner, gateway: string);
45
+ constructor(workerUrl: string | undefined, signer: SignedUrlSigner, gateway: string, /** The client's current app id, read per upload (see setAppId). */
46
+ appId: () => Hex | undefined);
39
47
  /** Run the worker challenge handshake → one-time presigned upload URL + network. */
40
48
  private requestUploadUrl;
41
49
  private workerJson;
@@ -18,7 +18,7 @@ function workerError(r) {
18
18
  *
19
19
  * Uploads go through the pinata-url-provider Worker. Prove wallet ownership by
20
20
  * signing the worker's challenge, and it hands back a short-lived, single-use
21
- * Pinata presigned upload URL that users POST the file to.
21
+ * Pinata presigned upload URL that users POST the file to.
22
22
  * Reads need no auth: every Fangorn block is public content, so it's
23
23
  * fetched straight from a public IPFS gateway by CID (privacy is cryptographic,
24
24
  * not access-controlled). Each upload runs a fresh handshake because the
@@ -27,22 +27,31 @@ function workerError(r) {
27
27
  * JWT-only operations (server-side metadata queries / deletes) are unavailable
28
28
  * here. Switch to a PinataBackend they're needed.
29
29
  *
30
- * Every upload is charged to the signing publisher's storage quota.
30
+ * Apps provide storage: every upload is billed to the client's app, whose
31
+ * subscription pays for it. Each request carries the app id, the signer must be
32
+ * one of that app's publishers, and the pins are filed under the app's group.
33
+ * There is no app-less upload: with no app this refuses before contacting the
34
+ * worker. The id is read per request so a later `setAppId` takes effect
35
+ * immediately.
31
36
  */
32
37
  var SignedUrlBackend = class {
33
38
  workerUrl;
34
- constructor(workerUrl, signer, gateway) {
39
+ constructor(workerUrl, signer, gateway, appId) {
35
40
  this.signer = signer;
36
41
  this.gateway = gateway;
42
+ this.appId = appId;
37
43
  this.workerUrl = workerUrl?.trim() ? workerUrl : DEFAULT_SIGNED_URL_WORKER;
38
44
  }
39
45
  /** Run the worker challenge handshake → one-time presigned upload URL + network. */
40
46
  async requestUploadUrl(size, uploadId) {
41
47
  const address = this.signer.address;
48
+ const appId = this.appId();
49
+ if (!appId) throw new Error("signed-url uploads are billed to an app: pass `appId` to Fangorn.create() or call setAppId(), or bring your own storage ({ pinata } or { backend })");
42
50
  const challenge = await this.workerJson({
43
51
  address,
44
52
  size,
45
- uploadId
53
+ uploadId,
54
+ appId
46
55
  });
47
56
  if (!challenge.challenge) throw new Error(`Presigned-URL worker did not issue a challenge: ${workerError(challenge)}`);
48
57
  const signature = await this.signer.signMessage(challenge.challenge);
@@ -51,7 +60,8 @@ var SignedUrlBackend = class {
51
60
  message: challenge.challenge,
52
61
  signature,
53
62
  size,
54
- uploadId
63
+ uploadId,
64
+ appId
55
65
  });
56
66
  if (!grant.ok || !grant.uploadUrl) throw new Error(`Presigned-URL worker denied an upload URL: ${workerError(grant)}`);
57
67
  return {
@@ -36,7 +36,7 @@ interface MetadataStorage {
36
36
  */
37
37
  putBlock(block: RawBlock): Promise<void>;
38
38
  /**
39
- * Store an opaque byte payload (e.g. a CAR file) and return its CID.
39
+ * Store an opaque byte payload (e.g. a CAR file) and return a URI handle.
40
40
  * The backend is NOT expected to understand the contents.
41
41
  */
42
42
  putFile(bytes: Uint8Array, name: string): Promise<string>;
@@ -1,12 +1,11 @@
1
1
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend } from "./signed-url.js";
2
2
  import { PinataBackend } from "./pinata.js";
3
3
  import { CID } from "multiformats/cid";
4
- import { base64pad } from "multiformats/bases/base64";
5
4
 
6
5
  //#region src/providers/storage/utils.ts
7
6
  const RAW_CODE = 85;
8
7
  const REVIVERS = [(_key, value) => {
9
- if (value !== null && typeof value === "object" && "__type" in value && "data" in value && value.__type === "Uint8Array") return base64pad.baseDecode(value.data);
8
+ if (value !== null && typeof value === "object" && "__type" in value && "data" in value && value.__type === "Uint8Array") return new Uint8Array(Buffer.from(value.data, "base64"));
10
9
  return value;
11
10
  }];
12
11
  function serialize(data) {
@@ -14,7 +13,7 @@ function serialize(data) {
14
13
  return JSON.stringify(data, (_key, value) => {
15
14
  if (value instanceof Uint8Array) return {
16
15
  __type: "Uint8Array",
17
- data: base64pad.baseEncode(value)
16
+ data: Buffer.from(value).toString("base64")
18
17
  };
19
18
  return value;
20
19
  });
@@ -28,8 +27,7 @@ function deserialize(text) {
28
27
  return value;
29
28
  });
30
29
  }
31
- const env = globalThis.process?.env;
32
- const MAX_UPLOAD_ATTEMPTS = Math.max(1, Number(env?.PINATA_UPLOAD_RETRIES ?? 6));
30
+ const MAX_UPLOAD_ATTEMPTS = Math.max(1, Number(process.env.PINATA_UPLOAD_RETRIES ?? 6));
33
31
  function isTransientUpload(err) {
34
32
  const e = err;
35
33
  const s = typeof e.statusCode === "number" ? e.statusCode : 0;