@wix/sdk 1.12.7 → 1.12.8
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.
|
@@ -40,6 +40,7 @@ import { parsePublicKeyIfEncoded } from '../helpers.js';
|
|
|
40
40
|
*/
|
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
42
42
|
export function AppStrategy(opts) {
|
|
43
|
+
const authServerBaseUrl = opts.authServerBaseUrl ?? 'https://www.wixapis.com';
|
|
43
44
|
let refreshToken = 'refreshToken' in opts ? opts.refreshToken : undefined;
|
|
44
45
|
return {
|
|
45
46
|
getInstallUrl({ redirectUrl, token, state }) {
|
|
@@ -68,7 +69,8 @@ export function AppStrategy(opts) {
|
|
|
68
69
|
if (!code || !instanceId) {
|
|
69
70
|
throw new Error('Invalid OAuth callback URL. Make sure you pass the url including the code and instanceId query params.');
|
|
70
71
|
}
|
|
71
|
-
const
|
|
72
|
+
const tokenUrl = new URL('/oauth/access', authServerBaseUrl);
|
|
73
|
+
const tokensRes = await fetch(tokenUrl.href, {
|
|
72
74
|
method: 'POST',
|
|
73
75
|
headers: {
|
|
74
76
|
'Content-Type': 'application/json',
|
|
@@ -96,7 +98,8 @@ export function AppStrategy(opts) {
|
|
|
96
98
|
if (!opts.appSecret) {
|
|
97
99
|
throw new Error('App secret is required for retrieveing app-level access tokens. Make sure to pass it to the AppStrategy');
|
|
98
100
|
}
|
|
99
|
-
const
|
|
101
|
+
const tokenUrl = new URL('/oauth/access', authServerBaseUrl);
|
|
102
|
+
const tokensRes = await fetch(tokenUrl.href, {
|
|
100
103
|
method: 'POST',
|
|
101
104
|
headers: {
|
|
102
105
|
'Content-Type': 'application/json',
|
|
@@ -123,7 +126,8 @@ export function AppStrategy(opts) {
|
|
|
123
126
|
if (!opts.appSecret) {
|
|
124
127
|
throw new Error('App secret is required for retrieveing app-level access tokens. Make sure to pass it to the AppStrategy');
|
|
125
128
|
}
|
|
126
|
-
const
|
|
129
|
+
const tokenUrl = new URL('/oauth2/token', authServerBaseUrl);
|
|
130
|
+
const tokensRes = await fetch(tokenUrl.href, {
|
|
127
131
|
method: 'POST',
|
|
128
132
|
headers: {
|
|
129
133
|
'Content-Type': 'application/json',
|
|
@@ -158,7 +162,7 @@ export function AppStrategy(opts) {
|
|
|
158
162
|
},
|
|
159
163
|
async elevated() {
|
|
160
164
|
if ('accessToken' in opts && opts.accessToken) {
|
|
161
|
-
const tokenInfo = await getTokenInfo(opts.accessToken);
|
|
165
|
+
const tokenInfo = await getTokenInfo(opts.accessToken, authServerBaseUrl);
|
|
162
166
|
if (tokenInfo.clientId !== opts.appId) {
|
|
163
167
|
throw new Error(`Invalid access token. The token is not issued for the app with ID "${opts.appId}"`);
|
|
164
168
|
}
|
|
@@ -170,6 +174,7 @@ export function AppStrategy(opts) {
|
|
|
170
174
|
appSecret: opts.appSecret,
|
|
171
175
|
publicKey: opts.publicKey,
|
|
172
176
|
instanceId: tokenInfo.instanceId,
|
|
177
|
+
authServerBaseUrl: opts.authServerBaseUrl,
|
|
173
178
|
});
|
|
174
179
|
}
|
|
175
180
|
else {
|
|
@@ -200,12 +205,13 @@ export function AppStrategy(opts) {
|
|
|
200
205
|
if (!tokenToCheck) {
|
|
201
206
|
throw new Error('Missing token to get info for. Either pass the token as an argument or provide it when initializing the AppStrategy');
|
|
202
207
|
}
|
|
203
|
-
return getTokenInfo(tokenToCheck);
|
|
208
|
+
return getTokenInfo(tokenToCheck, authServerBaseUrl);
|
|
204
209
|
},
|
|
205
210
|
};
|
|
206
211
|
}
|
|
207
|
-
async function getTokenInfo(token) {
|
|
208
|
-
const
|
|
212
|
+
async function getTokenInfo(token, authServerBaseUrl) {
|
|
213
|
+
const tokenInfoUrl = new URL('/oauth2/token-info', authServerBaseUrl);
|
|
214
|
+
const tokenInfoRes = await fetch(tokenInfoUrl.href, {
|
|
209
215
|
method: 'POST',
|
|
210
216
|
headers: {
|
|
211
217
|
'Content-Type': 'application/json',
|
|
@@ -66,6 +66,7 @@ const helpers_js_1 = require("../helpers.js");
|
|
|
66
66
|
*/
|
|
67
67
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
68
68
|
function AppStrategy(opts) {
|
|
69
|
+
const authServerBaseUrl = opts.authServerBaseUrl ?? 'https://www.wixapis.com';
|
|
69
70
|
let refreshToken = 'refreshToken' in opts ? opts.refreshToken : undefined;
|
|
70
71
|
return {
|
|
71
72
|
getInstallUrl({ redirectUrl, token, state }) {
|
|
@@ -94,7 +95,8 @@ function AppStrategy(opts) {
|
|
|
94
95
|
if (!code || !instanceId) {
|
|
95
96
|
throw new Error('Invalid OAuth callback URL. Make sure you pass the url including the code and instanceId query params.');
|
|
96
97
|
}
|
|
97
|
-
const
|
|
98
|
+
const tokenUrl = new URL('/oauth/access', authServerBaseUrl);
|
|
99
|
+
const tokensRes = await fetch(tokenUrl.href, {
|
|
98
100
|
method: 'POST',
|
|
99
101
|
headers: {
|
|
100
102
|
'Content-Type': 'application/json',
|
|
@@ -122,7 +124,8 @@ function AppStrategy(opts) {
|
|
|
122
124
|
if (!opts.appSecret) {
|
|
123
125
|
throw new Error('App secret is required for retrieveing app-level access tokens. Make sure to pass it to the AppStrategy');
|
|
124
126
|
}
|
|
125
|
-
const
|
|
127
|
+
const tokenUrl = new URL('/oauth/access', authServerBaseUrl);
|
|
128
|
+
const tokensRes = await fetch(tokenUrl.href, {
|
|
126
129
|
method: 'POST',
|
|
127
130
|
headers: {
|
|
128
131
|
'Content-Type': 'application/json',
|
|
@@ -149,7 +152,8 @@ function AppStrategy(opts) {
|
|
|
149
152
|
if (!opts.appSecret) {
|
|
150
153
|
throw new Error('App secret is required for retrieveing app-level access tokens. Make sure to pass it to the AppStrategy');
|
|
151
154
|
}
|
|
152
|
-
const
|
|
155
|
+
const tokenUrl = new URL('/oauth2/token', authServerBaseUrl);
|
|
156
|
+
const tokensRes = await fetch(tokenUrl.href, {
|
|
153
157
|
method: 'POST',
|
|
154
158
|
headers: {
|
|
155
159
|
'Content-Type': 'application/json',
|
|
@@ -184,7 +188,7 @@ function AppStrategy(opts) {
|
|
|
184
188
|
},
|
|
185
189
|
async elevated() {
|
|
186
190
|
if ('accessToken' in opts && opts.accessToken) {
|
|
187
|
-
const tokenInfo = await getTokenInfo(opts.accessToken);
|
|
191
|
+
const tokenInfo = await getTokenInfo(opts.accessToken, authServerBaseUrl);
|
|
188
192
|
if (tokenInfo.clientId !== opts.appId) {
|
|
189
193
|
throw new Error(`Invalid access token. The token is not issued for the app with ID "${opts.appId}"`);
|
|
190
194
|
}
|
|
@@ -196,6 +200,7 @@ function AppStrategy(opts) {
|
|
|
196
200
|
appSecret: opts.appSecret,
|
|
197
201
|
publicKey: opts.publicKey,
|
|
198
202
|
instanceId: tokenInfo.instanceId,
|
|
203
|
+
authServerBaseUrl: opts.authServerBaseUrl,
|
|
199
204
|
});
|
|
200
205
|
}
|
|
201
206
|
else {
|
|
@@ -226,13 +231,14 @@ function AppStrategy(opts) {
|
|
|
226
231
|
if (!tokenToCheck) {
|
|
227
232
|
throw new Error('Missing token to get info for. Either pass the token as an argument or provide it when initializing the AppStrategy');
|
|
228
233
|
}
|
|
229
|
-
return getTokenInfo(tokenToCheck);
|
|
234
|
+
return getTokenInfo(tokenToCheck, authServerBaseUrl);
|
|
230
235
|
},
|
|
231
236
|
};
|
|
232
237
|
}
|
|
233
238
|
exports.AppStrategy = AppStrategy;
|
|
234
|
-
async function getTokenInfo(token) {
|
|
235
|
-
const
|
|
239
|
+
async function getTokenInfo(token, authServerBaseUrl) {
|
|
240
|
+
const tokenInfoUrl = new URL('/oauth2/token-info', authServerBaseUrl);
|
|
241
|
+
const tokenInfoRes = await fetch(tokenInfoUrl.href, {
|
|
236
242
|
method: 'POST',
|
|
237
243
|
headers: {
|
|
238
244
|
'Content-Type': 'application/json',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/sdk",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.8",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@babel/runtime": "^7.23.2",
|
|
67
67
|
"@wix/identity": "^1.0.78",
|
|
68
|
-
"@wix/image-kit": "^1.
|
|
68
|
+
"@wix/image-kit": "^1.74.0",
|
|
69
69
|
"@wix/redirects": "^1.0.41",
|
|
70
70
|
"@wix/sdk-context": "^0.0.1",
|
|
71
|
-
"@wix/sdk-runtime": "0.3.
|
|
71
|
+
"@wix/sdk-runtime": "0.3.12",
|
|
72
72
|
"@wix/sdk-types": "^1.9.2",
|
|
73
73
|
"crypto-js": "^4.2.0",
|
|
74
74
|
"jose": "^5.2.1",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@wix/events": "^1.0.179",
|
|
89
89
|
"@wix/metro": "^1.0.73",
|
|
90
90
|
"@wix/metro-runtime": "^1.1677.0",
|
|
91
|
-
"@wix/sdk-runtime": "0.3.
|
|
91
|
+
"@wix/sdk-runtime": "0.3.12",
|
|
92
92
|
"eslint": "^8.56.0",
|
|
93
93
|
"eslint-config-sdk": "0.0.0",
|
|
94
94
|
"graphql": "^16.8.0",
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
"wallaby": {
|
|
123
123
|
"autoDetect": true
|
|
124
124
|
},
|
|
125
|
-
"falconPackageHash": "
|
|
125
|
+
"falconPackageHash": "4a3ca02dc12093515b122a61d87d631718a0d7de19fe8ad5a6ef4ab4"
|
|
126
126
|
}
|