@wix/sdk 1.15.5 → 1.15.7
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/AppStrategy.d.ts +0 -10
- package/build/auth/AppStrategy.js +1 -15
- package/build/context.d.ts +1 -0
- package/build/context.js +1 -0
- package/build/enable-context.d.ts +3 -0
- package/build/enable-context.js +14 -0
- package/build/get-token-info.d.ts +10 -0
- package/build/get-token-info.js +15 -0
- package/build/web-method-modules.js +1 -1
- package/cjs/build/auth/AppStrategy.d.ts +0 -10
- package/cjs/build/auth/AppStrategy.js +3 -18
- package/cjs/build/context.d.ts +1 -0
- package/cjs/build/context.js +3 -1
- package/cjs/build/enable-context.d.ts +3 -0
- package/cjs/build/enable-context.js +17 -0
- package/cjs/build/get-token-info.d.ts +10 -0
- package/cjs/build/get-token-info.js +18 -0
- package/cjs/build/web-method-modules.js +2 -2
- package/package.json +15 -15
|
@@ -80,13 +80,3 @@ export declare function AppStrategy(opts: {
|
|
|
80
80
|
} | {
|
|
81
81
|
accessToken?: string;
|
|
82
82
|
})): AppStrategy;
|
|
83
|
-
export declare function getTokenInfo(token: string): Promise<{
|
|
84
|
-
active: boolean;
|
|
85
|
-
subjectType: 'APP' | 'USER' | 'MEMBER' | 'VISITOR' | 'UNKNOWN';
|
|
86
|
-
subjectId: string;
|
|
87
|
-
exp: number;
|
|
88
|
-
iat: number;
|
|
89
|
-
clientId?: string;
|
|
90
|
-
siteId: string;
|
|
91
|
-
instanceId?: string;
|
|
92
|
-
}>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parsePublicKeyIfEncoded } from '../helpers.js';
|
|
2
|
+
import { getTokenInfo } from '../get-token-info.js';
|
|
2
3
|
/**
|
|
3
4
|
* Creates an authentication strategy for Wix Apps OAuth installation process.
|
|
4
5
|
* Use this authentication strategy when making requests to Wix APIs from your Wix App backend.
|
|
@@ -238,18 +239,3 @@ export function AppStrategy(opts) {
|
|
|
238
239
|
},
|
|
239
240
|
};
|
|
240
241
|
}
|
|
241
|
-
export async function getTokenInfo(token) {
|
|
242
|
-
const tokenInfoRes = await fetch('https://www.wixapis.com/oauth2/token-info', {
|
|
243
|
-
method: 'POST',
|
|
244
|
-
headers: {
|
|
245
|
-
'Content-Type': 'application/json',
|
|
246
|
-
},
|
|
247
|
-
body: JSON.stringify({
|
|
248
|
-
token,
|
|
249
|
-
}),
|
|
250
|
-
});
|
|
251
|
-
if (tokenInfoRes.status !== 200) {
|
|
252
|
-
throw new Error(`Failed to get token info. Unexpected status code from Wix OAuth API: ${tokenInfoRes.status}`);
|
|
253
|
-
}
|
|
254
|
-
return (await tokenInfoRes.json());
|
|
255
|
-
}
|
package/build/context.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare function elevate<T extends RESTFunctionDescriptor>(restModule: T)
|
|
|
3
3
|
export declare const fetchWithAuth: typeof fetch & ((restModuleOpts: import("@wix/sdk-types").HttpClient) => typeof fetch);
|
|
4
4
|
export { graphql } from './graphql.js';
|
|
5
5
|
export { setGlobalWixContext } from './wix-context.js';
|
|
6
|
+
export { enableContext } from './enable-context.js';
|
package/build/context.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { wixContext } from '@wix/sdk-context';
|
|
2
|
+
export function enableContext(wixClient, contextType) {
|
|
3
|
+
if (contextType === 'global') {
|
|
4
|
+
if (globalThis.__wix_context__ != null) {
|
|
5
|
+
globalThis.__wix_context__.client = wixClient;
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
globalThis.__wix_context__ = { client: wixClient };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
wixContext.client = wixClient;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function getTokenInfo(token: string): Promise<{
|
|
2
|
+
active: boolean;
|
|
3
|
+
subjectType: 'APP' | 'USER' | 'MEMBER' | 'VISITOR' | 'UNKNOWN';
|
|
4
|
+
subjectId: string;
|
|
5
|
+
exp: number;
|
|
6
|
+
iat: number;
|
|
7
|
+
clientId?: string;
|
|
8
|
+
siteId: string;
|
|
9
|
+
instanceId?: string;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export async function getTokenInfo(token) {
|
|
2
|
+
const tokenInfoRes = await fetch('https://www.wixapis.com/oauth2/token-info', {
|
|
3
|
+
method: 'POST',
|
|
4
|
+
headers: {
|
|
5
|
+
'Content-Type': 'application/json',
|
|
6
|
+
},
|
|
7
|
+
body: JSON.stringify({
|
|
8
|
+
token,
|
|
9
|
+
}),
|
|
10
|
+
});
|
|
11
|
+
if (tokenInfoRes.status !== 200) {
|
|
12
|
+
throw new Error(`Failed to get token info. Unexpected status code from Wix OAuth API: ${tokenInfoRes.status}`);
|
|
13
|
+
}
|
|
14
|
+
return (await tokenInfoRes.json());
|
|
15
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { serializeError } from 'serialize-error';
|
|
2
|
-
import { getTokenInfo } from './
|
|
2
|
+
import { getTokenInfo } from './get-token-info.js';
|
|
3
3
|
export const isWebMethodModules = (val) => val.__type === 'web-method-module';
|
|
4
4
|
var Permissions;
|
|
5
5
|
(function (Permissions) {
|
|
@@ -80,13 +80,3 @@ export declare function AppStrategy(opts: {
|
|
|
80
80
|
} | {
|
|
81
81
|
accessToken?: string;
|
|
82
82
|
})): AppStrategy;
|
|
83
|
-
export declare function getTokenInfo(token: string): Promise<{
|
|
84
|
-
active: boolean;
|
|
85
|
-
subjectType: 'APP' | 'USER' | 'MEMBER' | 'VISITOR' | 'UNKNOWN';
|
|
86
|
-
subjectId: string;
|
|
87
|
-
exp: number;
|
|
88
|
-
iat: number;
|
|
89
|
-
clientId?: string;
|
|
90
|
-
siteId: string;
|
|
91
|
-
instanceId?: string;
|
|
92
|
-
}>;
|
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.AppStrategy = AppStrategy;
|
|
37
|
-
exports.getTokenInfo = getTokenInfo;
|
|
38
37
|
const helpers_js_1 = require("../helpers.js");
|
|
38
|
+
const get_token_info_js_1 = require("../get-token-info.js");
|
|
39
39
|
/**
|
|
40
40
|
* Creates an authentication strategy for Wix Apps OAuth installation process.
|
|
41
41
|
* Use this authentication strategy when making requests to Wix APIs from your Wix App backend.
|
|
@@ -226,7 +226,7 @@ function AppStrategy(opts) {
|
|
|
226
226
|
},
|
|
227
227
|
async elevated() {
|
|
228
228
|
if ('accessToken' in opts && opts.accessToken) {
|
|
229
|
-
const tokenInfo = await getTokenInfo(opts.accessToken);
|
|
229
|
+
const tokenInfo = await (0, get_token_info_js_1.getTokenInfo)(opts.accessToken);
|
|
230
230
|
if (tokenInfo.clientId !== opts.appId) {
|
|
231
231
|
throw new Error(`Invalid access token. The token is not issued for the app with ID "${opts.appId}"`);
|
|
232
232
|
}
|
|
@@ -268,25 +268,10 @@ function AppStrategy(opts) {
|
|
|
268
268
|
if (!tokenToCheck) {
|
|
269
269
|
throw new Error('Missing token to get info for. Either pass the token as an argument or provide it when initializing the AppStrategy');
|
|
270
270
|
}
|
|
271
|
-
return getTokenInfo(tokenToCheck);
|
|
271
|
+
return (0, get_token_info_js_1.getTokenInfo)(tokenToCheck);
|
|
272
272
|
},
|
|
273
273
|
getActiveToken() {
|
|
274
274
|
return 'accessToken' in opts ? opts.accessToken : refreshToken;
|
|
275
275
|
},
|
|
276
276
|
};
|
|
277
277
|
}
|
|
278
|
-
async function getTokenInfo(token) {
|
|
279
|
-
const tokenInfoRes = await fetch('https://www.wixapis.com/oauth2/token-info', {
|
|
280
|
-
method: 'POST',
|
|
281
|
-
headers: {
|
|
282
|
-
'Content-Type': 'application/json',
|
|
283
|
-
},
|
|
284
|
-
body: JSON.stringify({
|
|
285
|
-
token,
|
|
286
|
-
}),
|
|
287
|
-
});
|
|
288
|
-
if (tokenInfoRes.status !== 200) {
|
|
289
|
-
throw new Error(`Failed to get token info. Unexpected status code from Wix OAuth API: ${tokenInfoRes.status}`);
|
|
290
|
-
}
|
|
291
|
-
return (await tokenInfoRes.json());
|
|
292
|
-
}
|
package/cjs/build/context.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare function elevate<T extends RESTFunctionDescriptor>(restModule: T)
|
|
|
3
3
|
export declare const fetchWithAuth: typeof fetch & ((restModuleOpts: import("@wix/sdk-types").HttpClient) => typeof fetch);
|
|
4
4
|
export { graphql } from './graphql.js';
|
|
5
5
|
export { setGlobalWixContext } from './wix-context.js';
|
|
6
|
+
export { enableContext } from './enable-context.js';
|
package/cjs/build/context.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setGlobalWixContext = exports.graphql = exports.fetchWithAuth = void 0;
|
|
3
|
+
exports.enableContext = exports.setGlobalWixContext = exports.graphql = exports.fetchWithAuth = void 0;
|
|
4
4
|
exports.elevate = elevate;
|
|
5
5
|
const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
|
|
6
6
|
function elevate(restModule) {
|
|
@@ -13,3 +13,5 @@ var graphql_js_1 = require("./graphql.js");
|
|
|
13
13
|
Object.defineProperty(exports, "graphql", { enumerable: true, get: function () { return graphql_js_1.graphql; } });
|
|
14
14
|
var wix_context_js_1 = require("./wix-context.js");
|
|
15
15
|
Object.defineProperty(exports, "setGlobalWixContext", { enumerable: true, get: function () { return wix_context_js_1.setGlobalWixContext; } });
|
|
16
|
+
var enable_context_js_1 = require("./enable-context.js");
|
|
17
|
+
Object.defineProperty(exports, "enableContext", { enumerable: true, get: function () { return enable_context_js_1.enableContext; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enableContext = enableContext;
|
|
4
|
+
const sdk_context_1 = require("@wix/sdk-context");
|
|
5
|
+
function enableContext(wixClient, contextType) {
|
|
6
|
+
if (contextType === 'global') {
|
|
7
|
+
if (globalThis.__wix_context__ != null) {
|
|
8
|
+
globalThis.__wix_context__.client = wixClient;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
globalThis.__wix_context__ = { client: wixClient };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
sdk_context_1.wixContext.client = wixClient;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function getTokenInfo(token: string): Promise<{
|
|
2
|
+
active: boolean;
|
|
3
|
+
subjectType: 'APP' | 'USER' | 'MEMBER' | 'VISITOR' | 'UNKNOWN';
|
|
4
|
+
subjectId: string;
|
|
5
|
+
exp: number;
|
|
6
|
+
iat: number;
|
|
7
|
+
clientId?: string;
|
|
8
|
+
siteId: string;
|
|
9
|
+
instanceId?: string;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTokenInfo = getTokenInfo;
|
|
4
|
+
async function getTokenInfo(token) {
|
|
5
|
+
const tokenInfoRes = await fetch('https://www.wixapis.com/oauth2/token-info', {
|
|
6
|
+
method: 'POST',
|
|
7
|
+
headers: {
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
},
|
|
10
|
+
body: JSON.stringify({
|
|
11
|
+
token,
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
if (tokenInfoRes.status !== 200) {
|
|
15
|
+
throw new Error(`Failed to get token info. Unexpected status code from Wix OAuth API: ${tokenInfoRes.status}`);
|
|
16
|
+
}
|
|
17
|
+
return (await tokenInfoRes.json());
|
|
18
|
+
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isWebMethodModules = void 0;
|
|
4
4
|
exports.webMethodModules = webMethodModules;
|
|
5
5
|
const serialize_error_1 = require("serialize-error");
|
|
6
|
-
const
|
|
6
|
+
const get_token_info_js_1 = require("./get-token-info.js");
|
|
7
7
|
const isWebMethodModules = (val) => val.__type === 'web-method-module';
|
|
8
8
|
exports.isWebMethodModules = isWebMethodModules;
|
|
9
9
|
var Permissions;
|
|
@@ -17,7 +17,7 @@ async function checkPermission(request, permission) {
|
|
|
17
17
|
if (!accessToken) {
|
|
18
18
|
throw new Error('Request is missing authentication data');
|
|
19
19
|
}
|
|
20
|
-
const { subjectType } = await (0,
|
|
20
|
+
const { subjectType } = await (0, get_token_info_js_1.getTokenInfo)(accessToken);
|
|
21
21
|
switch (permission) {
|
|
22
22
|
case Permissions.Anyone: {
|
|
23
23
|
if (subjectType !== 'VISITOR' &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/sdk",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.7",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
@@ -67,34 +67,34 @@
|
|
|
67
67
|
"*.{js,ts}": "yarn lint"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@wix/identity": "^1.0.
|
|
71
|
-
"@wix/image-kit": "^1.
|
|
72
|
-
"@wix/redirects": "^1.0.
|
|
70
|
+
"@wix/identity": "^1.0.98",
|
|
71
|
+
"@wix/image-kit": "^1.98.0",
|
|
72
|
+
"@wix/redirects": "^1.0.67",
|
|
73
73
|
"@wix/sdk-context": "^0.0.1",
|
|
74
|
-
"@wix/sdk-runtime": "0.3.
|
|
75
|
-
"@wix/sdk-types": "^1.12.
|
|
74
|
+
"@wix/sdk-runtime": "0.3.27",
|
|
75
|
+
"@wix/sdk-types": "^1.12.7",
|
|
76
76
|
"jose": "^5.9.6",
|
|
77
77
|
"serialize-error": "^8.1.0",
|
|
78
|
-
"type-fest": "^4.30.
|
|
78
|
+
"type-fest": "^4.30.2"
|
|
79
79
|
},
|
|
80
80
|
"optionalDependencies": {
|
|
81
81
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@types/is-ci": "^3.0.4",
|
|
85
|
-
"@types/node": "^20.17.
|
|
85
|
+
"@types/node": "^20.17.10",
|
|
86
86
|
"@vitest/ui": "^1.6.0",
|
|
87
|
-
"@wix/ecom": "^1.0.
|
|
88
|
-
"@wix/events": "^1.0.
|
|
89
|
-
"@wix/metro": "^1.0.
|
|
90
|
-
"@wix/metro-runtime": "^1.
|
|
91
|
-
"@wix/sdk-runtime": "0.3.
|
|
87
|
+
"@wix/ecom": "^1.0.868",
|
|
88
|
+
"@wix/events": "^1.0.362",
|
|
89
|
+
"@wix/metro": "^1.0.93",
|
|
90
|
+
"@wix/metro-runtime": "^1.1879.0",
|
|
91
|
+
"@wix/sdk-runtime": "0.3.27",
|
|
92
92
|
"eslint": "^8.57.1",
|
|
93
93
|
"eslint-config-sdk": "0.0.0",
|
|
94
94
|
"graphql": "^16.8.0",
|
|
95
95
|
"is-ci": "^3.0.1",
|
|
96
96
|
"jsdom": "^22.1.0",
|
|
97
|
-
"msw": "^2.
|
|
97
|
+
"msw": "^2.7.0",
|
|
98
98
|
"typescript": "^5.7.2",
|
|
99
99
|
"vitest": "^1.6.0",
|
|
100
100
|
"vitest-teamcity-reporter": "^0.3.1"
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
"wallaby": {
|
|
123
123
|
"autoDetect": true
|
|
124
124
|
},
|
|
125
|
-
"falconPackageHash": "
|
|
125
|
+
"falconPackageHash": "1dff796e2f80d78d9e5087ee2a1ef6e462efd17cc6327c4c41c57736"
|
|
126
126
|
}
|