@wix/sdk 1.21.3 → 1.21.5

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.
@@ -2,4 +2,6 @@ import { BuildRESTFunction, PublicMetadata, RESTFunctionDescriptor, WixClientErr
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, errorHandler: WixClientErrorHandler | undefined, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions, hostName?: string | undefined, useCDN?: boolean): BuildRESTFunction<T>;
5
+ export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, errorHandler: WixClientErrorHandler | undefined, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, getAuthHeaders?: () => Promise<{
6
+ headers: Record<string, string>;
7
+ }>, options?: RESTModuleOptions, hostName?: string | undefined, useCDN?: boolean): BuildRESTFunction<T>;
@@ -2,7 +2,7 @@ import { biHeaderGenerator } from './bi/biHeaderGenerator.js';
2
2
  import { DEFAULT_API_URL, DEFAULT_EDGE_API_URL } from './common.js';
3
3
  import { runWithoutContext } from '@wix/sdk-runtime/context';
4
4
  import { transformError } from '@wix/sdk-runtime/transform-error';
5
- export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
5
+ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, getAuthHeaders, options, hostName, useCDN) {
6
6
  return runWithoutContext(() => origFunc({
7
7
  request: async (factory) => {
8
8
  const requestOptions = factory({
@@ -82,6 +82,7 @@ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorH
82
82
  fetchWithAuth: boundFetch,
83
83
  wixAPIFetch,
84
84
  getActiveToken,
85
+ getAuthHeaders,
85
86
  }));
86
87
  }
87
88
  class SDKError extends Error {
@@ -137,7 +137,9 @@ export function createClient(config) {
137
137
  finalUrl.host = apiBaseUrl;
138
138
  finalUrl.protocol = 'https';
139
139
  return boundFetch(finalUrl.toString(), fetchOptions);
140
- }, getAuthStrategy().getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
140
+ }, getAuthStrategy().getActiveToken,
141
+ // async wrapper normalizes the sync/async union from AuthenticationStrategy.getAuthHeaders
142
+ async () => boundGetAuthHeaders(), { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
141
143
  }
142
144
  else if (isObject(modules)) {
143
145
  return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
@@ -2,4 +2,6 @@ import { BuildRESTFunction, PublicMetadata, RESTFunctionDescriptor, WixClientErr
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, errorHandler: WixClientErrorHandler | undefined, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions, hostName?: string | undefined, useCDN?: boolean): BuildRESTFunction<T>;
5
+ export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, errorHandler: WixClientErrorHandler | undefined, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, getAuthHeaders?: () => Promise<{
6
+ headers: Record<string, string>;
7
+ }>, options?: RESTModuleOptions, hostName?: string | undefined, useCDN?: boolean): BuildRESTFunction<T>;
@@ -5,7 +5,7 @@ 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
7
  const transform_error_1 = require("@wix/sdk-runtime/transform-error");
8
- function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
8
+ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, getAuthHeaders, options, hostName, useCDN) {
9
9
  return (0, context_1.runWithoutContext)(() => origFunc({
10
10
  request: async (factory) => {
11
11
  const requestOptions = factory({
@@ -85,6 +85,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
85
85
  fetchWithAuth: boundFetch,
86
86
  wixAPIFetch,
87
87
  getActiveToken,
88
+ getAuthHeaders,
88
89
  }));
89
90
  }
90
91
  class SDKError extends Error {
@@ -141,7 +141,9 @@ function createClient(config) {
141
141
  finalUrl.host = apiBaseUrl;
142
142
  finalUrl.protocol = 'https';
143
143
  return boundFetch(finalUrl.toString(), fetchOptions);
144
- }, getAuthStrategy().getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
144
+ }, getAuthStrategy().getActiveToken,
145
+ // async wrapper normalizes the sync/async union from AuthenticationStrategy.getAuthHeaders
146
+ async () => boundGetAuthHeaders(), { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
145
147
  }
146
148
  else if ((0, helpers_js_1.isObject)(modules)) {
147
149
  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.21.3",
3
+ "version": "1.21.5",
4
4
  "author": {
5
5
  "name": "Ronny Ringel",
6
6
  "email": "ronnyr@wix.com"
@@ -10,8 +10,8 @@
10
10
  "@wix/image-kit": "^1.114.0",
11
11
  "@wix/redirects": "^1.0.70",
12
12
  "@wix/sdk-context": "0.0.1",
13
- "@wix/sdk-runtime": "1.0.7",
14
- "@wix/sdk-types": "1.17.3",
13
+ "@wix/sdk-runtime": "1.0.10",
14
+ "@wix/sdk-types": "1.17.6",
15
15
  "jose": "^5.10.0",
16
16
  "type-fest": "^4.41.0"
17
17
  },
@@ -22,8 +22,8 @@
22
22
  "@wix/ecom": "^1.0.886",
23
23
  "@wix/events": "^1.0.382",
24
24
  "@wix/metro": "^1.0.93",
25
- "@wix/metro-runtime": "^1.1891.0",
26
- "@wix/sdk-runtime": "1.0.7",
25
+ "@wix/metro-runtime": "1.1891.0",
26
+ "@wix/sdk-runtime": "1.0.10",
27
27
  "eslint": "^8.57.1",
28
28
  "eslint-config-sdk": "1.0.0",
29
29
  "graphql": "^16.8.0",
@@ -126,5 +126,5 @@
126
126
  "yoshiFlowLibrary": {
127
127
  "buildEsmWithBabel": true
128
128
  },
129
- "falconPackageHash": "85c30d8bf85fa6b345737b139ab7ebaf274735a08a7bcac2a23b5ebf"
129
+ "falconPackageHash": "fe44d3ebe66b6cec8a2d67821e548bc019ffedd9c22b31260308794b"
130
130
  }