@wix/sdk 1.12.13 → 1.12.14

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.
@@ -207,6 +207,9 @@ export function AppStrategy(opts) {
207
207
  }
208
208
  return getTokenInfo(tokenToCheck, authServerBaseUrl);
209
209
  },
210
+ getActiveToken() {
211
+ return 'accessToken' in opts ? opts.accessToken : refreshToken;
212
+ },
210
213
  };
211
214
  }
212
215
  async function getTokenInfo(token, authServerBaseUrl) {
@@ -2,4 +2,4 @@ import { BuildRESTFunction, PublicMetadata, RESTFunctionDescriptor } from '@wix/
2
2
  export type RESTModuleOptions = {
3
3
  HTTPHost?: string;
4
4
  };
5
- export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, options?: RESTModuleOptions): BuildRESTFunction<T>;
5
+ export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions): BuildRESTFunction<T>;
@@ -1,7 +1,7 @@
1
1
  import { biHeaderGenerator } from './bi/biHeaderGenerator.js';
2
2
  import { DEFAULT_API_URL } from './common.js';
3
3
  import { runWithoutContext } from '@wix/sdk-runtime/context';
4
- export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, options) {
4
+ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options) {
5
5
  return runWithoutContext(() => origFunc({
6
6
  request: async (factory) => {
7
7
  const requestOptions = factory({
@@ -59,6 +59,7 @@ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPI
59
59
  },
60
60
  fetchWithAuth: boundFetch,
61
61
  wixAPIFetch,
62
+ getActiveToken,
62
63
  }));
63
64
  }
64
65
  const errorBuilder = (code, description, details, data) => {
@@ -60,7 +60,7 @@ export function createClient(config) {
60
60
  finalUrl.host = apiBaseUrl;
61
61
  finalUrl.protocol = 'https';
62
62
  return boundFetch(finalUrl.toString(), fetchOptions);
63
- }, { HTTPHost: apiBaseUrl });
63
+ }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl });
64
64
  }
65
65
  else if (isObject(modules)) {
66
66
  return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
@@ -233,6 +233,9 @@ function AppStrategy(opts) {
233
233
  }
234
234
  return getTokenInfo(tokenToCheck, authServerBaseUrl);
235
235
  },
236
+ getActiveToken() {
237
+ return 'accessToken' in opts ? opts.accessToken : refreshToken;
238
+ },
236
239
  };
237
240
  }
238
241
  exports.AppStrategy = AppStrategy;
@@ -2,4 +2,4 @@ import { BuildRESTFunction, PublicMetadata, RESTFunctionDescriptor } from '@wix/
2
2
  export type RESTModuleOptions = {
3
3
  HTTPHost?: string;
4
4
  };
5
- export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, options?: RESTModuleOptions): BuildRESTFunction<T>;
5
+ export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions): BuildRESTFunction<T>;
@@ -4,7 +4,7 @@ exports.buildRESTDescriptor = void 0;
4
4
  const biHeaderGenerator_js_1 = require("./bi/biHeaderGenerator.js");
5
5
  const common_js_1 = require("./common.js");
6
6
  const context_1 = require("@wix/sdk-runtime/context");
7
- function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, options) {
7
+ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options) {
8
8
  return (0, context_1.runWithoutContext)(() => origFunc({
9
9
  request: async (factory) => {
10
10
  const requestOptions = factory({
@@ -62,6 +62,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch,
62
62
  },
63
63
  fetchWithAuth: boundFetch,
64
64
  wixAPIFetch,
65
+ getActiveToken,
65
66
  }));
66
67
  }
67
68
  exports.buildRESTDescriptor = buildRESTDescriptor;
@@ -63,7 +63,7 @@ function createClient(config) {
63
63
  finalUrl.host = apiBaseUrl;
64
64
  finalUrl.protocol = 'https';
65
65
  return boundFetch(finalUrl.toString(), fetchOptions);
66
- }, { HTTPHost: apiBaseUrl });
66
+ }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl });
67
67
  }
68
68
  else if ((0, helpers_js_1.isObject)(modules)) {
69
69
  return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.12.13",
3
+ "version": "1.12.14",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -68,8 +68,8 @@
68
68
  "@wix/image-kit": "^1.83.0",
69
69
  "@wix/redirects": "^1.0.41",
70
70
  "@wix/sdk-context": "^0.0.1",
71
- "@wix/sdk-runtime": "0.3.18",
72
- "@wix/sdk-types": "^1.10.0",
71
+ "@wix/sdk-runtime": "0.3.19",
72
+ "@wix/sdk-types": "^1.12.0",
73
73
  "jose": "^5.2.1",
74
74
  "querystring": "^0.2.1",
75
75
  "type-fest": "^4.9.0"
@@ -85,7 +85,7 @@
85
85
  "@wix/events": "^1.0.179",
86
86
  "@wix/metro": "^1.0.73",
87
87
  "@wix/metro-runtime": "^1.1677.0",
88
- "@wix/sdk-runtime": "0.3.18",
88
+ "@wix/sdk-runtime": "0.3.19",
89
89
  "eslint": "^8.56.0",
90
90
  "eslint-config-sdk": "0.0.0",
91
91
  "graphql": "^16.8.0",
@@ -119,5 +119,5 @@
119
119
  "wallaby": {
120
120
  "autoDetect": true
121
121
  },
122
- "falconPackageHash": "b1f56afb5f401e2aa11769c9e887f152fbce4bee17f7d7c651c43a30"
122
+ "falconPackageHash": "b3311f3e856f7fda5bd9d3d658ebffaf428cb466a862d8223dfd6842"
123
123
  }