@wix/sdk 1.15.21 → 1.15.22
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/build/auth/SiteSessionAuth.d.ts +1 -0
- package/build/auth/SiteSessionAuth.js +1 -0
- package/build/auth/oauth2/OAuthStrategy.js +1 -0
- package/build/auth/oauth2/types.d.ts +1 -0
- package/build/common.d.ts +1 -0
- package/build/common.js +1 -0
- package/build/rest-modules.d.ts +1 -1
- package/build/rest-modules.js +3 -3
- package/build/wixClient.d.ts +1 -0
- package/build/wixClient.js +2 -1
- package/cjs/build/auth/SiteSessionAuth.d.ts +1 -0
- package/cjs/build/auth/SiteSessionAuth.js +1 -0
- package/cjs/build/auth/oauth2/OAuthStrategy.js +1 -0
- package/cjs/build/auth/oauth2/types.d.ts +1 -0
- package/cjs/build/common.d.ts +1 -0
- package/cjs/build/common.js +2 -1
- package/cjs/build/rest-modules.d.ts +1 -1
- package/cjs/build/rest-modules.js +2 -2
- package/cjs/build/wixClient.d.ts +1 -0
- package/cjs/build/wixClient.js +2 -1
- package/package.json +5 -5
|
@@ -17,6 +17,7 @@ export declare function SiteSessionAuth(config: {
|
|
|
17
17
|
getTokens: () => Tokens;
|
|
18
18
|
isSessionSynced: typeof isVisitorCookieWarmedUp;
|
|
19
19
|
syncToWixPages: typeof preWarmVisitorCookie;
|
|
20
|
+
shouldUseCDN: boolean;
|
|
20
21
|
};
|
|
21
22
|
export interface TokenResponse {
|
|
22
23
|
access_token: string;
|
package/build/common.d.ts
CHANGED
package/build/common.js
CHANGED
package/build/rest-modules.d.ts
CHANGED
|
@@ -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>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions, hostName?: string | undefined): 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, hostName?: string | undefined, useCDN?: boolean): BuildRESTFunction<T>;
|
package/build/rest-modules.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { biHeaderGenerator } from './bi/biHeaderGenerator.js';
|
|
2
|
-
import { DEFAULT_API_URL } from './common.js';
|
|
2
|
+
import { DEFAULT_API_URL, DEFAULT_EDGE_API_URL } from './common.js';
|
|
3
3
|
import { runWithoutContext } from '@wix/sdk-runtime/context';
|
|
4
|
-
export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName) {
|
|
4
|
+
export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
|
|
5
5
|
return runWithoutContext(() => origFunc({
|
|
6
6
|
request: async (factory) => {
|
|
7
7
|
const requestOptions = factory({
|
|
@@ -14,7 +14,7 @@ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPI
|
|
|
14
14
|
request = requestOptions.fallback[0];
|
|
15
15
|
}
|
|
16
16
|
const domain = options?.HTTPHost ?? DEFAULT_API_URL;
|
|
17
|
-
let url = `https://${domain}${request.url}`;
|
|
17
|
+
let url = `https://${useCDN ? DEFAULT_EDGE_API_URL : domain}${request.url}`;
|
|
18
18
|
if (request.params && request.params.toString()) {
|
|
19
19
|
url += `?${request.params.toString()}`;
|
|
20
20
|
}
|
package/build/wixClient.d.ts
CHANGED
package/build/wixClient.js
CHANGED
|
@@ -94,6 +94,7 @@ export function createClient(config) {
|
|
|
94
94
|
return modules;
|
|
95
95
|
}
|
|
96
96
|
const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
|
|
97
|
+
const shouldUseCDN = config.useCDN === undefined ? config.auth?.shouldUseCDN : config.useCDN;
|
|
97
98
|
return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules))
|
|
98
99
|
? toHTTPModule(modules)
|
|
99
100
|
: modules, metadata ?? {}, boundFetch, (relativeUrl, fetchOptions) => {
|
|
@@ -101,7 +102,7 @@ export function createClient(config) {
|
|
|
101
102
|
finalUrl.host = apiBaseUrl;
|
|
102
103
|
finalUrl.protocol = 'https';
|
|
103
104
|
return boundFetch(finalUrl.toString(), fetchOptions);
|
|
104
|
-
}, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name);
|
|
105
|
+
}, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
|
|
105
106
|
}
|
|
106
107
|
else if (isObject(modules)) {
|
|
107
108
|
return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
|
|
@@ -17,6 +17,7 @@ export declare function SiteSessionAuth(config: {
|
|
|
17
17
|
getTokens: () => Tokens;
|
|
18
18
|
isSessionSynced: typeof isVisitorCookieWarmedUp;
|
|
19
19
|
syncToWixPages: typeof preWarmVisitorCookie;
|
|
20
|
+
shouldUseCDN: boolean;
|
|
20
21
|
};
|
|
21
22
|
export interface TokenResponse {
|
|
22
23
|
access_token: string;
|
|
@@ -76,6 +76,7 @@ function SiteSessionAuth(config) {
|
|
|
76
76
|
getTokens: () => _tokens,
|
|
77
77
|
isSessionSynced: pre_warm_cookie_js_1.isVisitorCookieWarmedUp,
|
|
78
78
|
syncToWixPages: pre_warm_cookie_js_1.preWarmVisitorCookie,
|
|
79
|
+
shouldUseCDN: true,
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
const fetchTokens = async (payload, headers = {}) => {
|
|
@@ -358,6 +358,7 @@ function OAuthStrategy(config) {
|
|
|
358
358
|
isSessionSynced: pre_warm_cookie_js_1.isVisitorCookieWarmedUp,
|
|
359
359
|
syncToWixPages: pre_warm_cookie_js_1.preWarmVisitorCookie,
|
|
360
360
|
},
|
|
361
|
+
shouldUseCDN: true,
|
|
361
362
|
};
|
|
362
363
|
}
|
|
363
364
|
const fetchTokens = async (payload, headers = {}) => {
|
package/cjs/build/common.d.ts
CHANGED
package/cjs/build/common.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FORCE_WRITE_API_URLS = exports.DEFAULT_API_URL = exports.PUBLIC_METADATA_KEY = void 0;
|
|
3
|
+
exports.FORCE_WRITE_API_URLS = exports.DEFAULT_EDGE_API_URL = exports.DEFAULT_API_URL = exports.PUBLIC_METADATA_KEY = void 0;
|
|
4
4
|
exports.PUBLIC_METADATA_KEY = '__metadata';
|
|
5
5
|
exports.DEFAULT_API_URL = 'www.wixapis.com';
|
|
6
|
+
exports.DEFAULT_EDGE_API_URL = 'edge.wixapis.com';
|
|
6
7
|
exports.FORCE_WRITE_API_URLS = ['/ecom/v1/carts/current'];
|
|
@@ -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>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions, hostName?: string | undefined): 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, hostName?: string | undefined, useCDN?: boolean): BuildRESTFunction<T>;
|
|
@@ -4,7 +4,7 @@ exports.buildRESTDescriptor = buildRESTDescriptor;
|
|
|
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, getActiveToken, options, hostName) {
|
|
7
|
+
function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
|
|
8
8
|
return (0, context_1.runWithoutContext)(() => origFunc({
|
|
9
9
|
request: async (factory) => {
|
|
10
10
|
const requestOptions = factory({
|
|
@@ -17,7 +17,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch,
|
|
|
17
17
|
request = requestOptions.fallback[0];
|
|
18
18
|
}
|
|
19
19
|
const domain = options?.HTTPHost ?? common_js_1.DEFAULT_API_URL;
|
|
20
|
-
let url = `https://${domain}${request.url}`;
|
|
20
|
+
let url = `https://${useCDN ? common_js_1.DEFAULT_EDGE_API_URL : domain}${request.url}`;
|
|
21
21
|
if (request.params && request.params.toString()) {
|
|
22
22
|
url += `?${request.params.toString()}`;
|
|
23
23
|
}
|
package/cjs/build/wixClient.d.ts
CHANGED
package/cjs/build/wixClient.js
CHANGED
|
@@ -98,6 +98,7 @@ function createClient(config) {
|
|
|
98
98
|
return modules;
|
|
99
99
|
}
|
|
100
100
|
const apiBaseUrl = config.host?.apiBaseUrl ?? common_js_1.DEFAULT_API_URL;
|
|
101
|
+
const shouldUseCDN = config.useCDN === undefined ? config.auth?.shouldUseCDN : config.useCDN;
|
|
101
102
|
return (0, rest_modules_js_1.buildRESTDescriptor)((0, context_1.runWithoutContext)(() => (0, ambassador_modules_js_1.isAmbassadorModule)(modules))
|
|
102
103
|
? (0, ambassador_modules_js_1.toHTTPModule)(modules)
|
|
103
104
|
: modules, metadata ?? {}, boundFetch, (relativeUrl, fetchOptions) => {
|
|
@@ -105,7 +106,7 @@ function createClient(config) {
|
|
|
105
106
|
finalUrl.host = apiBaseUrl;
|
|
106
107
|
finalUrl.protocol = 'https';
|
|
107
108
|
return boundFetch(finalUrl.toString(), fetchOptions);
|
|
108
|
-
}, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name);
|
|
109
|
+
}, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
|
|
109
110
|
}
|
|
110
111
|
else if ((0, helpers_js_1.isObject)(modules)) {
|
|
111
112
|
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.15.
|
|
3
|
+
"version": "1.15.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"@wix/image-kit": "^1.108.0",
|
|
77
77
|
"@wix/redirects": "^1.0.70",
|
|
78
78
|
"@wix/sdk-context": "0.0.1",
|
|
79
|
-
"@wix/sdk-runtime": "0.3.
|
|
80
|
-
"@wix/sdk-types": "^1.13.
|
|
79
|
+
"@wix/sdk-runtime": "0.3.51",
|
|
80
|
+
"@wix/sdk-types": "^1.13.24",
|
|
81
81
|
"jose": "^5.10.0",
|
|
82
82
|
"type-fest": "^4.41.0"
|
|
83
83
|
},
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@wix/events": "^1.0.382",
|
|
93
93
|
"@wix/metro": "^1.0.93",
|
|
94
94
|
"@wix/metro-runtime": "^1.1891.0",
|
|
95
|
-
"@wix/sdk-runtime": "0.3.
|
|
95
|
+
"@wix/sdk-runtime": "0.3.51",
|
|
96
96
|
"eslint": "^8.57.1",
|
|
97
97
|
"eslint-config-sdk": "0.0.0",
|
|
98
98
|
"graphql": "^16.8.0",
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"wallaby": {
|
|
127
127
|
"autoDetect": true
|
|
128
128
|
},
|
|
129
|
-
"falconPackageHash": "
|
|
129
|
+
"falconPackageHash": "60cb24e5bec634e1a32cb026c97cd7e9e13bd464b260f1e7bea3ab92"
|
|
130
130
|
}
|