@wix/sdk 1.2.6 → 1.2.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.
- package/build/browser/index.mjs +12 -21
- package/build/index.d.mts +4 -4
- package/build/index.d.ts +4 -4
- package/build/index.js +10 -19
- package/build/index.mjs +10 -19
- package/package.json +9 -10
package/build/browser/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// src/common.ts
|
|
2
2
|
var PUBLIC_METADATA_KEY = "__metadata";
|
|
3
3
|
var API_URL = "www.wixapis.com";
|
|
4
|
+
var READ_ONLY_API_URL = "readonly.wixapis.com";
|
|
5
|
+
var FORCE_WRITE_API_URLS = ["/ecom/v1/carts/current"];
|
|
4
6
|
|
|
5
7
|
// src/helpers.ts
|
|
6
8
|
var getDefaultContentHeader = (options) => {
|
|
@@ -40,7 +42,8 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch) {
|
|
|
40
42
|
request: async (factory) => {
|
|
41
43
|
var _a;
|
|
42
44
|
const requestOptions = factory({ host: API_URL });
|
|
43
|
-
|
|
45
|
+
const domain = requestOptions.method === "GET" && !FORCE_WRITE_API_URLS.some((url2) => requestOptions.url === url2) ? READ_ONLY_API_URL : API_URL;
|
|
46
|
+
let url = `https://${domain}${requestOptions.url}`;
|
|
44
47
|
if (requestOptions.params && requestOptions.params.toString()) {
|
|
45
48
|
url += `?${requestOptions.params.toString()}`;
|
|
46
49
|
}
|
|
@@ -349,7 +352,6 @@ var RESET_PASSWORD = "-19973";
|
|
|
349
352
|
|
|
350
353
|
// src/auth/oauth2/OAuthStrategy.ts
|
|
351
354
|
var moduleWithTokens = { redirects, authentication, recovery, verification };
|
|
352
|
-
var WIX_RECAPTCHA_ID = "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v";
|
|
353
355
|
function OAuthStrategy(config) {
|
|
354
356
|
const _tokens = config.tokens || {
|
|
355
357
|
accessToken: { value: "", expiresAt: 0 },
|
|
@@ -464,15 +466,16 @@ function OAuthStrategy(config) {
|
|
|
464
466
|
const getAuthUrl = async (oauthData, opts = {
|
|
465
467
|
prompt: "login"
|
|
466
468
|
}) => {
|
|
467
|
-
var _a;
|
|
469
|
+
var _a, _b;
|
|
468
470
|
return getAuthorizationUrlWithOptions(
|
|
469
471
|
oauthData,
|
|
470
|
-
"fragment",
|
|
471
|
-
(
|
|
472
|
+
(_a = opts.responseMode) != null ? _a : "fragment",
|
|
473
|
+
(_b = opts.prompt) != null ? _b : "login"
|
|
472
474
|
);
|
|
473
475
|
};
|
|
474
|
-
const parseFromUrl = () => {
|
|
475
|
-
const
|
|
476
|
+
const parseFromUrl = (url, responseMode = "fragment") => {
|
|
477
|
+
const parsedUrl = new URL(url != null ? url : window.location.href);
|
|
478
|
+
const params = responseMode === "query" ? parsedUrl.searchParams : new URLSearchParams(parsedUrl.hash.substring(1));
|
|
476
479
|
const code = params.get("code");
|
|
477
480
|
const state = params.get("state");
|
|
478
481
|
const error = params.get("error");
|
|
@@ -677,18 +680,6 @@ function OAuthStrategy(config) {
|
|
|
677
680
|
redirect: { url: redirectUri, clientId: config.clientId }
|
|
678
681
|
});
|
|
679
682
|
};
|
|
680
|
-
const getRecaptchaScriptUrl = () => {
|
|
681
|
-
return `https://www.google.com/recaptcha/enterprise.js?render=${WIX_RECAPTCHA_ID}`;
|
|
682
|
-
};
|
|
683
|
-
const getRecaptchaToken = async () => {
|
|
684
|
-
return new Promise((resolve) => {
|
|
685
|
-
grecaptcha.enterprise.ready(() => {
|
|
686
|
-
grecaptcha.enterprise.execute(WIX_RECAPTCHA_ID, { action: "submit" }).then((token) => {
|
|
687
|
-
resolve(token);
|
|
688
|
-
});
|
|
689
|
-
});
|
|
690
|
-
});
|
|
691
|
-
};
|
|
692
683
|
const loggedIn = () => {
|
|
693
684
|
return _tokens.refreshToken.role === "member" /* MEMBER */;
|
|
694
685
|
};
|
|
@@ -718,8 +709,8 @@ function OAuthStrategy(config) {
|
|
|
718
709
|
getMemberTokensForDirectLogin,
|
|
719
710
|
sendResetPasswordMail: sendPasswordResetEmail,
|
|
720
711
|
sendPasswordResetEmail,
|
|
721
|
-
|
|
722
|
-
|
|
712
|
+
captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
|
|
713
|
+
captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
|
|
723
714
|
};
|
|
724
715
|
}
|
|
725
716
|
var fetchTokens = async (payload) => {
|
package/build/index.d.mts
CHANGED
|
@@ -120,6 +120,7 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
120
120
|
generateOAuthData: (redirectUri: string, originalUri?: string) => OauthData;
|
|
121
121
|
getAuthUrl: (oauthData: OauthData, opts?: {
|
|
122
122
|
prompt?: 'login' | 'none';
|
|
123
|
+
responseMode?: 'fragment' | 'web_message' | 'query';
|
|
123
124
|
}) => Promise<{
|
|
124
125
|
authUrl: string;
|
|
125
126
|
}>;
|
|
@@ -127,7 +128,7 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
127
128
|
logout: (originalUrl: string) => Promise<{
|
|
128
129
|
logoutUrl: string;
|
|
129
130
|
}>;
|
|
130
|
-
parseFromUrl: () => {
|
|
131
|
+
parseFromUrl: (url?: string, responseMode?: 'query' | 'fragment') => {
|
|
131
132
|
code: string;
|
|
132
133
|
state: string;
|
|
133
134
|
error?: string;
|
|
@@ -150,8 +151,8 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
150
151
|
*/
|
|
151
152
|
sendResetPasswordMail: (email: string, redirectUri: string) => Promise<void>;
|
|
152
153
|
sendPasswordResetEmail: (email: string, redirectUri: string) => Promise<void>;
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
captchaInvisibleSiteKey: string;
|
|
155
|
+
captchaVisibleSiteKey: string;
|
|
155
156
|
loggedIn: () => boolean;
|
|
156
157
|
}
|
|
157
158
|
declare enum LoginState {
|
|
@@ -239,7 +240,6 @@ type Context = {
|
|
|
239
240
|
} | {
|
|
240
241
|
siteId?: string;
|
|
241
242
|
accountId: string;
|
|
242
|
-
apiKey: string;
|
|
243
243
|
};
|
|
244
244
|
declare function ApiKeyStrategy({ siteId, accountId, apiKey, }: {
|
|
245
245
|
apiKey: string;
|
package/build/index.d.ts
CHANGED
|
@@ -120,6 +120,7 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
120
120
|
generateOAuthData: (redirectUri: string, originalUri?: string) => OauthData;
|
|
121
121
|
getAuthUrl: (oauthData: OauthData, opts?: {
|
|
122
122
|
prompt?: 'login' | 'none';
|
|
123
|
+
responseMode?: 'fragment' | 'web_message' | 'query';
|
|
123
124
|
}) => Promise<{
|
|
124
125
|
authUrl: string;
|
|
125
126
|
}>;
|
|
@@ -127,7 +128,7 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
127
128
|
logout: (originalUrl: string) => Promise<{
|
|
128
129
|
logoutUrl: string;
|
|
129
130
|
}>;
|
|
130
|
-
parseFromUrl: () => {
|
|
131
|
+
parseFromUrl: (url?: string, responseMode?: 'query' | 'fragment') => {
|
|
131
132
|
code: string;
|
|
132
133
|
state: string;
|
|
133
134
|
error?: string;
|
|
@@ -150,8 +151,8 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
150
151
|
*/
|
|
151
152
|
sendResetPasswordMail: (email: string, redirectUri: string) => Promise<void>;
|
|
152
153
|
sendPasswordResetEmail: (email: string, redirectUri: string) => Promise<void>;
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
captchaInvisibleSiteKey: string;
|
|
155
|
+
captchaVisibleSiteKey: string;
|
|
155
156
|
loggedIn: () => boolean;
|
|
156
157
|
}
|
|
157
158
|
declare enum LoginState {
|
|
@@ -239,7 +240,6 @@ type Context = {
|
|
|
239
240
|
} | {
|
|
240
241
|
siteId?: string;
|
|
241
242
|
accountId: string;
|
|
242
|
-
apiKey: string;
|
|
243
243
|
};
|
|
244
244
|
declare function ApiKeyStrategy({ siteId, accountId, apiKey, }: {
|
|
245
245
|
apiKey: string;
|
package/build/index.js
CHANGED
|
@@ -44,6 +44,8 @@ module.exports = __toCommonJS(src_exports);
|
|
|
44
44
|
// src/common.ts
|
|
45
45
|
var PUBLIC_METADATA_KEY = "__metadata";
|
|
46
46
|
var API_URL = "www.wixapis.com";
|
|
47
|
+
var READ_ONLY_API_URL = "readonly.wixapis.com";
|
|
48
|
+
var FORCE_WRITE_API_URLS = ["/ecom/v1/carts/current"];
|
|
47
49
|
|
|
48
50
|
// src/helpers.ts
|
|
49
51
|
var getDefaultContentHeader = (options) => {
|
|
@@ -81,7 +83,8 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch) {
|
|
|
81
83
|
return origFunc({
|
|
82
84
|
request: async (factory) => {
|
|
83
85
|
const requestOptions = factory({ host: API_URL });
|
|
84
|
-
|
|
86
|
+
const domain = requestOptions.method === "GET" && !FORCE_WRITE_API_URLS.some((url2) => requestOptions.url === url2) ? READ_ONLY_API_URL : API_URL;
|
|
87
|
+
let url = `https://${domain}${requestOptions.url}`;
|
|
85
88
|
if (requestOptions.params && requestOptions.params.toString()) {
|
|
86
89
|
url += `?${requestOptions.params.toString()}`;
|
|
87
90
|
}
|
|
@@ -390,7 +393,6 @@ var RESET_PASSWORD = "-19973";
|
|
|
390
393
|
|
|
391
394
|
// src/auth/oauth2/OAuthStrategy.ts
|
|
392
395
|
var moduleWithTokens = { redirects: import_redirects.redirects, authentication: import_identity.authentication, recovery: import_identity.recovery, verification: import_identity.verification };
|
|
393
|
-
var WIX_RECAPTCHA_ID = "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v";
|
|
394
396
|
function OAuthStrategy(config) {
|
|
395
397
|
const _tokens = config.tokens || {
|
|
396
398
|
accessToken: { value: "", expiresAt: 0 },
|
|
@@ -505,12 +507,13 @@ function OAuthStrategy(config) {
|
|
|
505
507
|
}) => {
|
|
506
508
|
return getAuthorizationUrlWithOptions(
|
|
507
509
|
oauthData,
|
|
508
|
-
"fragment",
|
|
510
|
+
opts.responseMode ?? "fragment",
|
|
509
511
|
opts.prompt ?? "login"
|
|
510
512
|
);
|
|
511
513
|
};
|
|
512
|
-
const parseFromUrl = () => {
|
|
513
|
-
const
|
|
514
|
+
const parseFromUrl = (url, responseMode = "fragment") => {
|
|
515
|
+
const parsedUrl = new URL(url ?? window.location.href);
|
|
516
|
+
const params = responseMode === "query" ? parsedUrl.searchParams : new URLSearchParams(parsedUrl.hash.substring(1));
|
|
514
517
|
const code = params.get("code");
|
|
515
518
|
const state = params.get("state");
|
|
516
519
|
const error = params.get("error");
|
|
@@ -711,18 +714,6 @@ function OAuthStrategy(config) {
|
|
|
711
714
|
redirect: { url: redirectUri, clientId: config.clientId }
|
|
712
715
|
});
|
|
713
716
|
};
|
|
714
|
-
const getRecaptchaScriptUrl = () => {
|
|
715
|
-
return `https://www.google.com/recaptcha/enterprise.js?render=${WIX_RECAPTCHA_ID}`;
|
|
716
|
-
};
|
|
717
|
-
const getRecaptchaToken = async () => {
|
|
718
|
-
return new Promise((resolve) => {
|
|
719
|
-
grecaptcha.enterprise.ready(() => {
|
|
720
|
-
grecaptcha.enterprise.execute(WIX_RECAPTCHA_ID, { action: "submit" }).then((token) => {
|
|
721
|
-
resolve(token);
|
|
722
|
-
});
|
|
723
|
-
});
|
|
724
|
-
});
|
|
725
|
-
};
|
|
726
717
|
const loggedIn = () => {
|
|
727
718
|
return _tokens.refreshToken.role === "member" /* MEMBER */;
|
|
728
719
|
};
|
|
@@ -752,8 +743,8 @@ function OAuthStrategy(config) {
|
|
|
752
743
|
getMemberTokensForDirectLogin,
|
|
753
744
|
sendResetPasswordMail: sendPasswordResetEmail,
|
|
754
745
|
sendPasswordResetEmail,
|
|
755
|
-
|
|
756
|
-
|
|
746
|
+
captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
|
|
747
|
+
captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
|
|
757
748
|
};
|
|
758
749
|
}
|
|
759
750
|
var fetchTokens = async (payload) => {
|
package/build/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// src/common.ts
|
|
2
2
|
var PUBLIC_METADATA_KEY = "__metadata";
|
|
3
3
|
var API_URL = "www.wixapis.com";
|
|
4
|
+
var READ_ONLY_API_URL = "readonly.wixapis.com";
|
|
5
|
+
var FORCE_WRITE_API_URLS = ["/ecom/v1/carts/current"];
|
|
4
6
|
|
|
5
7
|
// src/helpers.ts
|
|
6
8
|
var getDefaultContentHeader = (options) => {
|
|
@@ -38,7 +40,8 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch) {
|
|
|
38
40
|
return origFunc({
|
|
39
41
|
request: async (factory) => {
|
|
40
42
|
const requestOptions = factory({ host: API_URL });
|
|
41
|
-
|
|
43
|
+
const domain = requestOptions.method === "GET" && !FORCE_WRITE_API_URLS.some((url2) => requestOptions.url === url2) ? READ_ONLY_API_URL : API_URL;
|
|
44
|
+
let url = `https://${domain}${requestOptions.url}`;
|
|
42
45
|
if (requestOptions.params && requestOptions.params.toString()) {
|
|
43
46
|
url += `?${requestOptions.params.toString()}`;
|
|
44
47
|
}
|
|
@@ -347,7 +350,6 @@ var RESET_PASSWORD = "-19973";
|
|
|
347
350
|
|
|
348
351
|
// src/auth/oauth2/OAuthStrategy.ts
|
|
349
352
|
var moduleWithTokens = { redirects, authentication, recovery, verification };
|
|
350
|
-
var WIX_RECAPTCHA_ID = "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v";
|
|
351
353
|
function OAuthStrategy(config) {
|
|
352
354
|
const _tokens = config.tokens || {
|
|
353
355
|
accessToken: { value: "", expiresAt: 0 },
|
|
@@ -462,12 +464,13 @@ function OAuthStrategy(config) {
|
|
|
462
464
|
}) => {
|
|
463
465
|
return getAuthorizationUrlWithOptions(
|
|
464
466
|
oauthData,
|
|
465
|
-
"fragment",
|
|
467
|
+
opts.responseMode ?? "fragment",
|
|
466
468
|
opts.prompt ?? "login"
|
|
467
469
|
);
|
|
468
470
|
};
|
|
469
|
-
const parseFromUrl = () => {
|
|
470
|
-
const
|
|
471
|
+
const parseFromUrl = (url, responseMode = "fragment") => {
|
|
472
|
+
const parsedUrl = new URL(url ?? window.location.href);
|
|
473
|
+
const params = responseMode === "query" ? parsedUrl.searchParams : new URLSearchParams(parsedUrl.hash.substring(1));
|
|
471
474
|
const code = params.get("code");
|
|
472
475
|
const state = params.get("state");
|
|
473
476
|
const error = params.get("error");
|
|
@@ -668,18 +671,6 @@ function OAuthStrategy(config) {
|
|
|
668
671
|
redirect: { url: redirectUri, clientId: config.clientId }
|
|
669
672
|
});
|
|
670
673
|
};
|
|
671
|
-
const getRecaptchaScriptUrl = () => {
|
|
672
|
-
return `https://www.google.com/recaptcha/enterprise.js?render=${WIX_RECAPTCHA_ID}`;
|
|
673
|
-
};
|
|
674
|
-
const getRecaptchaToken = async () => {
|
|
675
|
-
return new Promise((resolve) => {
|
|
676
|
-
grecaptcha.enterprise.ready(() => {
|
|
677
|
-
grecaptcha.enterprise.execute(WIX_RECAPTCHA_ID, { action: "submit" }).then((token) => {
|
|
678
|
-
resolve(token);
|
|
679
|
-
});
|
|
680
|
-
});
|
|
681
|
-
});
|
|
682
|
-
};
|
|
683
674
|
const loggedIn = () => {
|
|
684
675
|
return _tokens.refreshToken.role === "member" /* MEMBER */;
|
|
685
676
|
};
|
|
@@ -709,8 +700,8 @@ function OAuthStrategy(config) {
|
|
|
709
700
|
getMemberTokensForDirectLogin,
|
|
710
701
|
sendResetPasswordMail: sendPasswordResetEmail,
|
|
711
702
|
sendPasswordResetEmail,
|
|
712
|
-
|
|
713
|
-
|
|
703
|
+
captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
|
|
704
|
+
captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
|
|
714
705
|
};
|
|
715
706
|
}
|
|
716
707
|
var fetchTokens = async (payload) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
@@ -31,23 +31,22 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.22.6",
|
|
34
|
-
"@
|
|
35
|
-
"@wix/
|
|
36
|
-
"@wix/image-kit": "^1.34.0",
|
|
34
|
+
"@wix/identity": "^1.0.47",
|
|
35
|
+
"@wix/image-kit": "^1.35.0",
|
|
37
36
|
"@wix/redirects": "^1.0.22",
|
|
38
|
-
"@wix/sdk-types": "1.2.
|
|
37
|
+
"@wix/sdk-types": "1.2.8",
|
|
39
38
|
"pkce-challenge": "^3.1.0",
|
|
40
39
|
"querystring": "^0.2.1",
|
|
41
40
|
"type-fest": "^3.13.1"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"@swc/core": "^1.3.
|
|
43
|
+
"@swc/core": "^1.3.72",
|
|
45
44
|
"@swc/jest": "^0.2.27",
|
|
46
45
|
"@types/jest": "^27.5.2",
|
|
47
46
|
"@types/node": "^16.18.39",
|
|
48
|
-
"@wix/ecom": "^1.0.
|
|
49
|
-
"@wix/events": "^1.0.
|
|
50
|
-
"@wix/motion": "^1.0.
|
|
47
|
+
"@wix/ecom": "^1.0.302",
|
|
48
|
+
"@wix/events": "^1.0.110",
|
|
49
|
+
"@wix/motion": "^1.0.27",
|
|
51
50
|
"eslint": "^7.32.0",
|
|
52
51
|
"eslint-config-sdk": "0.0.0",
|
|
53
52
|
"is-ci": "^3.0.1",
|
|
@@ -80,5 +79,5 @@
|
|
|
80
79
|
"wallaby": {
|
|
81
80
|
"autoDetect": true
|
|
82
81
|
},
|
|
83
|
-
"falconPackageHash": "
|
|
82
|
+
"falconPackageHash": "07eb178e34d03b5584413811900bdedde21e79d9438809689ff22469"
|
|
84
83
|
}
|