@wix/sdk 1.2.6 → 1.2.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.
@@ -349,7 +349,6 @@ var RESET_PASSWORD = "-19973";
349
349
 
350
350
  // src/auth/oauth2/OAuthStrategy.ts
351
351
  var moduleWithTokens = { redirects, authentication, recovery, verification };
352
- var WIX_RECAPTCHA_ID = "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v";
353
352
  function OAuthStrategy(config) {
354
353
  const _tokens = config.tokens || {
355
354
  accessToken: { value: "", expiresAt: 0 },
@@ -464,15 +463,16 @@ function OAuthStrategy(config) {
464
463
  const getAuthUrl = async (oauthData, opts = {
465
464
  prompt: "login"
466
465
  }) => {
467
- var _a;
466
+ var _a, _b;
468
467
  return getAuthorizationUrlWithOptions(
469
468
  oauthData,
470
- "fragment",
471
- (_a = opts.prompt) != null ? _a : "login"
469
+ (_a = opts.responseMode) != null ? _a : "fragment",
470
+ (_b = opts.prompt) != null ? _b : "login"
472
471
  );
473
472
  };
474
- const parseFromUrl = () => {
475
- const params = new URLSearchParams(window.location.hash.substring(1));
473
+ const parseFromUrl = (url, responseMode = "fragment") => {
474
+ const parsedUrl = new URL(url != null ? url : window.location.href);
475
+ const params = responseMode === "query" ? parsedUrl.searchParams : new URLSearchParams(parsedUrl.hash.substring(1));
476
476
  const code = params.get("code");
477
477
  const state = params.get("state");
478
478
  const error = params.get("error");
@@ -677,18 +677,6 @@ function OAuthStrategy(config) {
677
677
  redirect: { url: redirectUri, clientId: config.clientId }
678
678
  });
679
679
  };
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
680
  const loggedIn = () => {
693
681
  return _tokens.refreshToken.role === "member" /* MEMBER */;
694
682
  };
@@ -718,8 +706,8 @@ function OAuthStrategy(config) {
718
706
  getMemberTokensForDirectLogin,
719
707
  sendResetPasswordMail: sendPasswordResetEmail,
720
708
  sendPasswordResetEmail,
721
- getRecaptchaScriptUrl,
722
- getRecaptchaToken
709
+ captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
710
+ captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
723
711
  };
724
712
  }
725
713
  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
- getRecaptchaScriptUrl: () => string;
154
- getRecaptchaToken: () => Promise<string>;
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
- getRecaptchaScriptUrl: () => string;
154
- getRecaptchaToken: () => Promise<string>;
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
@@ -390,7 +390,6 @@ var RESET_PASSWORD = "-19973";
390
390
 
391
391
  // src/auth/oauth2/OAuthStrategy.ts
392
392
  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
393
  function OAuthStrategy(config) {
395
394
  const _tokens = config.tokens || {
396
395
  accessToken: { value: "", expiresAt: 0 },
@@ -505,12 +504,13 @@ function OAuthStrategy(config) {
505
504
  }) => {
506
505
  return getAuthorizationUrlWithOptions(
507
506
  oauthData,
508
- "fragment",
507
+ opts.responseMode ?? "fragment",
509
508
  opts.prompt ?? "login"
510
509
  );
511
510
  };
512
- const parseFromUrl = () => {
513
- const params = new URLSearchParams(window.location.hash.substring(1));
511
+ const parseFromUrl = (url, responseMode = "fragment") => {
512
+ const parsedUrl = new URL(url ?? window.location.href);
513
+ const params = responseMode === "query" ? parsedUrl.searchParams : new URLSearchParams(parsedUrl.hash.substring(1));
514
514
  const code = params.get("code");
515
515
  const state = params.get("state");
516
516
  const error = params.get("error");
@@ -711,18 +711,6 @@ function OAuthStrategy(config) {
711
711
  redirect: { url: redirectUri, clientId: config.clientId }
712
712
  });
713
713
  };
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
714
  const loggedIn = () => {
727
715
  return _tokens.refreshToken.role === "member" /* MEMBER */;
728
716
  };
@@ -752,8 +740,8 @@ function OAuthStrategy(config) {
752
740
  getMemberTokensForDirectLogin,
753
741
  sendResetPasswordMail: sendPasswordResetEmail,
754
742
  sendPasswordResetEmail,
755
- getRecaptchaScriptUrl,
756
- getRecaptchaToken
743
+ captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
744
+ captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
757
745
  };
758
746
  }
759
747
  var fetchTokens = async (payload) => {
package/build/index.mjs CHANGED
@@ -347,7 +347,6 @@ var RESET_PASSWORD = "-19973";
347
347
 
348
348
  // src/auth/oauth2/OAuthStrategy.ts
349
349
  var moduleWithTokens = { redirects, authentication, recovery, verification };
350
- var WIX_RECAPTCHA_ID = "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v";
351
350
  function OAuthStrategy(config) {
352
351
  const _tokens = config.tokens || {
353
352
  accessToken: { value: "", expiresAt: 0 },
@@ -462,12 +461,13 @@ function OAuthStrategy(config) {
462
461
  }) => {
463
462
  return getAuthorizationUrlWithOptions(
464
463
  oauthData,
465
- "fragment",
464
+ opts.responseMode ?? "fragment",
466
465
  opts.prompt ?? "login"
467
466
  );
468
467
  };
469
- const parseFromUrl = () => {
470
- const params = new URLSearchParams(window.location.hash.substring(1));
468
+ const parseFromUrl = (url, responseMode = "fragment") => {
469
+ const parsedUrl = new URL(url ?? window.location.href);
470
+ const params = responseMode === "query" ? parsedUrl.searchParams : new URLSearchParams(parsedUrl.hash.substring(1));
471
471
  const code = params.get("code");
472
472
  const state = params.get("state");
473
473
  const error = params.get("error");
@@ -668,18 +668,6 @@ function OAuthStrategy(config) {
668
668
  redirect: { url: redirectUri, clientId: config.clientId }
669
669
  });
670
670
  };
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
671
  const loggedIn = () => {
684
672
  return _tokens.refreshToken.role === "member" /* MEMBER */;
685
673
  };
@@ -709,8 +697,8 @@ function OAuthStrategy(config) {
709
697
  getMemberTokensForDirectLogin,
710
698
  sendResetPasswordMail: sendPasswordResetEmail,
711
699
  sendPasswordResetEmail,
712
- getRecaptchaScriptUrl,
713
- getRecaptchaToken
700
+ captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
701
+ captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
714
702
  };
715
703
  }
716
704
  var fetchTokens = async (payload) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
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
- "@types/grecaptcha": "^3.0.4",
35
- "@wix/identity": "^1.0.44",
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.6",
37
+ "@wix/sdk-types": "1.2.7",
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.70",
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.283",
49
- "@wix/events": "^1.0.108",
50
- "@wix/motion": "^1.0.26",
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": "7048af349d562f1a266e24414afdf85663bf1eb9bb3c2360c81e0b3d"
82
+ "falconPackageHash": "0180e73db01d9fbc1b95a4afb3f5d9e3a6e79c043617f083429ad6da"
84
83
  }