@dyne/interfacer-client 0.2.9 → 0.3.1

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/dist/index.cjs CHANGED
@@ -281,6 +281,7 @@ __export(index_exports, {
281
281
  clearInstanceVariablesCache: () => clearInstanceVariablesCache,
282
282
  createConfig: () => createConfig,
283
283
  createMemoryStorage: () => createMemoryStorage,
284
+ deriveEndpointsFromProxy: () => deriveEndpointsFromProxy,
284
285
  derivedProductFilterTags: () => derivedProductFilterTags,
285
286
  extractUserTagValues: () => extractUserTagValues,
286
287
  formatImageSrc: () => formatImageSrc,
@@ -1265,7 +1266,9 @@ var GraphQLClient = class {
1265
1266
  console.warn("[interfacer-client] GraphQL signing failed:", err);
1266
1267
  }
1267
1268
  }
1268
- const res = await fetch(this.config.zenflowsUrl, {
1269
+ const url = this.config.zenflowsUrl;
1270
+ if (!url) throw new Error("zenflowsUrl not configured. Provide zenflowsUrl or proxyUrl in config.");
1271
+ const res = await fetch(url, {
1269
1272
  method: "POST",
1270
1273
  headers,
1271
1274
  body
@@ -2293,8 +2296,39 @@ var InterfacerClient = class {
2293
2296
  init_hashing();
2294
2297
 
2295
2298
  // src/config/config.ts
2299
+ function deriveEndpointsFromProxy(proxyUrl) {
2300
+ const base = proxyUrl.replace(/\/$/, "");
2301
+ return {
2302
+ zenflowsUrl: `${base}/zenflows/api`,
2303
+ zenflowsFileUrl: `${base}/zenflows/api/file`,
2304
+ dppUrl: `${base}/interfacer-dpp`,
2305
+ inbox: {
2306
+ send: `${base}/inbox/send`,
2307
+ read: `${base}/inbox/read`,
2308
+ countUnread: `${base}/inbox/count-unread`,
2309
+ setRead: `${base}/inbox/set-read`
2310
+ },
2311
+ walletUrl: `${base}/wallet/token`,
2312
+ social: {
2313
+ personBase: `${base}/inbox/person`,
2314
+ economicResourceBase: `${base}/inbox/economicresource`
2315
+ },
2316
+ oshUrl: `${base}/osh`
2317
+ };
2318
+ }
2296
2319
  function createConfig(config) {
2297
- return config;
2320
+ if (!config.proxyUrl) return config;
2321
+ const derived = deriveEndpointsFromProxy(config.proxyUrl);
2322
+ return {
2323
+ ...config,
2324
+ zenflowsUrl: config.zenflowsUrl ?? derived.zenflowsUrl,
2325
+ zenflowsFileUrl: config.zenflowsFileUrl ?? derived.zenflowsFileUrl,
2326
+ dppUrl: config.dppUrl ?? derived.dppUrl,
2327
+ inbox: config.inbox ?? derived.inbox,
2328
+ walletUrl: config.walletUrl ?? derived.walletUrl,
2329
+ social: config.social ?? derived.social,
2330
+ oshUrl: config.oshUrl ?? derived.oshUrl
2331
+ };
2298
2332
  }
2299
2333
 
2300
2334
  // src/index.ts
@@ -2328,6 +2362,7 @@ init_sign();
2328
2362
  clearInstanceVariablesCache,
2329
2363
  createConfig,
2330
2364
  createMemoryStorage,
2365
+ deriveEndpointsFromProxy,
2331
2366
  derivedProductFilterTags,
2332
2367
  extractUserTagValues,
2333
2368
  formatImageSrc,