@wix/sdk 1.2.5 → 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.
- package/build/browser/index.mjs +15 -27
- package/build/index.d.mts +21 -17
- package/build/index.d.ts +21 -17
- package/build/index.js +14 -25
- package/build/index.mjs +13 -25
- package/package.json +10 -11
package/build/browser/index.mjs
CHANGED
|
@@ -11,6 +11,12 @@ var getDefaultContentHeader = (options) => {
|
|
|
11
11
|
};
|
|
12
12
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
13
13
|
|
|
14
|
+
// src/host-modules.ts
|
|
15
|
+
var isHostModule = (val) => isObject(val) && val.__type === "host";
|
|
16
|
+
function buildHostModule(val, host) {
|
|
17
|
+
return val.create(host);
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
// src/bi/biHeaderGenerator.ts
|
|
15
21
|
var WixBIHeaderName = "x-wix-bi-gateway";
|
|
16
22
|
function biHeaderGenerator(apiMetadata, publicMetadata) {
|
|
@@ -102,12 +108,6 @@ var errorBuilder = (code, description, details, data) => {
|
|
|
102
108
|
};
|
|
103
109
|
};
|
|
104
110
|
|
|
105
|
-
// src/host-modules.ts
|
|
106
|
-
var isHostModule = (val) => isObject(val) && val.__type === "host";
|
|
107
|
-
function buildHostModule(val, host) {
|
|
108
|
-
return val.create(host);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
111
|
// src/wixClient.ts
|
|
112
112
|
function createClient(config) {
|
|
113
113
|
const _headers = config.headers || { Authorization: "" };
|
|
@@ -128,7 +128,7 @@ function createClient(config) {
|
|
|
128
128
|
});
|
|
129
129
|
};
|
|
130
130
|
const use = (modules, metadata) => {
|
|
131
|
-
if (isHostModule(modules)) {
|
|
131
|
+
if (isHostModule(modules) && config.host) {
|
|
132
132
|
return buildHostModule(modules, config.host);
|
|
133
133
|
} else if (typeof modules === "function") {
|
|
134
134
|
return buildRESTDescriptor(
|
|
@@ -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
|
-
(
|
|
469
|
+
(_a = opts.responseMode) != null ? _a : "fragment",
|
|
470
|
+
(_b = opts.prompt) != null ? _b : "login"
|
|
472
471
|
);
|
|
473
472
|
};
|
|
474
|
-
const parseFromUrl = () => {
|
|
475
|
-
const
|
|
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
|
-
|
|
722
|
-
|
|
709
|
+
captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
|
|
710
|
+
captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
|
|
723
711
|
};
|
|
724
712
|
}
|
|
725
713
|
var fetchTokens = async (payload) => {
|
package/build/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy } from '@wix/sdk-types';
|
|
2
2
|
export * from '@wix/sdk-types';
|
|
3
3
|
import { ConditionalExcept, EmptyObject } from 'type-fest';
|
|
4
4
|
import { ImageTransformOptions } from '@wix/image-kit';
|
|
@@ -17,36 +17,40 @@ type Headers = {
|
|
|
17
17
|
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
18
18
|
* do not match the given host (as they will not work with the given host).
|
|
19
19
|
*/
|
|
20
|
-
type BuildDescriptors<T extends Descriptors
|
|
21
|
-
|
|
20
|
+
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined> = BuildRESTDescriptors<T> & (H extends Host<any> ? BuildHostDescriptors<T> : {});
|
|
21
|
+
type BuildRESTDescriptors<T extends Descriptors> = T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : ConditionalExcept<{
|
|
22
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildRESTDescriptors<T[Key]> : never;
|
|
23
|
+
}, EmptyObject>;
|
|
24
|
+
type BuildHostDescriptors<T extends Descriptors> = T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
|
|
25
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildHostDescriptors<T[Key]> : never;
|
|
22
26
|
}, EmptyObject>;
|
|
23
27
|
/**
|
|
24
28
|
* Descriptors are objects that describe the API of a module, and the module
|
|
25
29
|
* can either be a REST module or a host module.
|
|
26
30
|
* This type is recursive, so it can describe nested modules.
|
|
27
31
|
*/
|
|
28
|
-
type Descriptors
|
|
29
|
-
[key: string]: Descriptors
|
|
32
|
+
type Descriptors = RESTFunctionDescriptor | HostModule<any, any> | {
|
|
33
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
30
34
|
};
|
|
31
35
|
/**
|
|
32
36
|
* This type is used in `createClient` to ensure that the given host matches the host of the given descriptors.
|
|
33
37
|
* If the host does not match, the descriptor is replaced with a host module that will throw an error when used.
|
|
34
38
|
*/
|
|
35
|
-
type AssertHostMatches<T extends Descriptors
|
|
36
|
-
[Key in keyof T]: T[Key] extends Descriptors
|
|
39
|
+
type AssertHostMatches<T extends Descriptors, H extends Host<any>> = T extends HostModule<any, infer U> ? H extends undefined ? never : H extends U ? T : HostModule<any, H> : T extends RESTFunctionDescriptor<any> ? T : {
|
|
40
|
+
[Key in keyof T]: T[Key] extends Descriptors ? AssertHostMatches<T[Key], H> : T[Key];
|
|
37
41
|
};
|
|
38
|
-
type WixClient<
|
|
42
|
+
type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = Descriptors> = {
|
|
39
43
|
setHeaders(headers: Headers): void;
|
|
40
44
|
auth: Z;
|
|
41
45
|
fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
|
|
42
|
-
use<R extends Descriptors
|
|
43
|
-
} & BuildDescriptors<T>;
|
|
44
|
-
declare function createClient<
|
|
45
|
-
modules?: AssertHostMatches<T, H
|
|
46
|
+
use<R extends Descriptors = EmptyObject>(modules: H extends Host<any> ? AssertHostMatches<R, H> : R): BuildDescriptors<R, H>;
|
|
47
|
+
} & BuildDescriptors<T, H>;
|
|
48
|
+
declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = EmptyObject>(config: {
|
|
49
|
+
modules?: H extends Host<any> ? AssertHostMatches<T, H> : T;
|
|
46
50
|
auth?: Z;
|
|
47
51
|
headers?: Headers;
|
|
48
52
|
host?: H;
|
|
49
|
-
}): WixClient<
|
|
53
|
+
}): WixClient<H, Z, T>;
|
|
50
54
|
|
|
51
55
|
declare function getScaledToFillImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
52
56
|
declare function getScaledToFitImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
@@ -116,6 +120,7 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
116
120
|
generateOAuthData: (redirectUri: string, originalUri?: string) => OauthData;
|
|
117
121
|
getAuthUrl: (oauthData: OauthData, opts?: {
|
|
118
122
|
prompt?: 'login' | 'none';
|
|
123
|
+
responseMode?: 'fragment' | 'web_message' | 'query';
|
|
119
124
|
}) => Promise<{
|
|
120
125
|
authUrl: string;
|
|
121
126
|
}>;
|
|
@@ -123,7 +128,7 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
123
128
|
logout: (originalUrl: string) => Promise<{
|
|
124
129
|
logoutUrl: string;
|
|
125
130
|
}>;
|
|
126
|
-
parseFromUrl: () => {
|
|
131
|
+
parseFromUrl: (url?: string, responseMode?: 'query' | 'fragment') => {
|
|
127
132
|
code: string;
|
|
128
133
|
state: string;
|
|
129
134
|
error?: string;
|
|
@@ -146,8 +151,8 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
146
151
|
*/
|
|
147
152
|
sendResetPasswordMail: (email: string, redirectUri: string) => Promise<void>;
|
|
148
153
|
sendPasswordResetEmail: (email: string, redirectUri: string) => Promise<void>;
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
captchaInvisibleSiteKey: string;
|
|
155
|
+
captchaVisibleSiteKey: string;
|
|
151
156
|
loggedIn: () => boolean;
|
|
152
157
|
}
|
|
153
158
|
declare enum LoginState {
|
|
@@ -235,7 +240,6 @@ type Context = {
|
|
|
235
240
|
} | {
|
|
236
241
|
siteId?: string;
|
|
237
242
|
accountId: string;
|
|
238
|
-
apiKey: string;
|
|
239
243
|
};
|
|
240
244
|
declare function ApiKeyStrategy({ siteId, accountId, apiKey, }: {
|
|
241
245
|
apiKey: string;
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy } from '@wix/sdk-types';
|
|
2
2
|
export * from '@wix/sdk-types';
|
|
3
3
|
import { ConditionalExcept, EmptyObject } from 'type-fest';
|
|
4
4
|
import { ImageTransformOptions } from '@wix/image-kit';
|
|
@@ -17,36 +17,40 @@ type Headers = {
|
|
|
17
17
|
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
18
18
|
* do not match the given host (as they will not work with the given host).
|
|
19
19
|
*/
|
|
20
|
-
type BuildDescriptors<T extends Descriptors
|
|
21
|
-
|
|
20
|
+
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined> = BuildRESTDescriptors<T> & (H extends Host<any> ? BuildHostDescriptors<T> : {});
|
|
21
|
+
type BuildRESTDescriptors<T extends Descriptors> = T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : ConditionalExcept<{
|
|
22
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildRESTDescriptors<T[Key]> : never;
|
|
23
|
+
}, EmptyObject>;
|
|
24
|
+
type BuildHostDescriptors<T extends Descriptors> = T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
|
|
25
|
+
[Key in keyof T]: T[Key] extends Descriptors ? BuildHostDescriptors<T[Key]> : never;
|
|
22
26
|
}, EmptyObject>;
|
|
23
27
|
/**
|
|
24
28
|
* Descriptors are objects that describe the API of a module, and the module
|
|
25
29
|
* can either be a REST module or a host module.
|
|
26
30
|
* This type is recursive, so it can describe nested modules.
|
|
27
31
|
*/
|
|
28
|
-
type Descriptors
|
|
29
|
-
[key: string]: Descriptors
|
|
32
|
+
type Descriptors = RESTFunctionDescriptor | HostModule<any, any> | {
|
|
33
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
30
34
|
};
|
|
31
35
|
/**
|
|
32
36
|
* This type is used in `createClient` to ensure that the given host matches the host of the given descriptors.
|
|
33
37
|
* If the host does not match, the descriptor is replaced with a host module that will throw an error when used.
|
|
34
38
|
*/
|
|
35
|
-
type AssertHostMatches<T extends Descriptors
|
|
36
|
-
[Key in keyof T]: T[Key] extends Descriptors
|
|
39
|
+
type AssertHostMatches<T extends Descriptors, H extends Host<any>> = T extends HostModule<any, infer U> ? H extends undefined ? never : H extends U ? T : HostModule<any, H> : T extends RESTFunctionDescriptor<any> ? T : {
|
|
40
|
+
[Key in keyof T]: T[Key] extends Descriptors ? AssertHostMatches<T[Key], H> : T[Key];
|
|
37
41
|
};
|
|
38
|
-
type WixClient<
|
|
42
|
+
type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = Descriptors> = {
|
|
39
43
|
setHeaders(headers: Headers): void;
|
|
40
44
|
auth: Z;
|
|
41
45
|
fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
|
|
42
|
-
use<R extends Descriptors
|
|
43
|
-
} & BuildDescriptors<T>;
|
|
44
|
-
declare function createClient<
|
|
45
|
-
modules?: AssertHostMatches<T, H
|
|
46
|
+
use<R extends Descriptors = EmptyObject>(modules: H extends Host<any> ? AssertHostMatches<R, H> : R): BuildDescriptors<R, H>;
|
|
47
|
+
} & BuildDescriptors<T, H>;
|
|
48
|
+
declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = EmptyObject>(config: {
|
|
49
|
+
modules?: H extends Host<any> ? AssertHostMatches<T, H> : T;
|
|
46
50
|
auth?: Z;
|
|
47
51
|
headers?: Headers;
|
|
48
52
|
host?: H;
|
|
49
|
-
}): WixClient<
|
|
53
|
+
}): WixClient<H, Z, T>;
|
|
50
54
|
|
|
51
55
|
declare function getScaledToFillImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
52
56
|
declare function getScaledToFitImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
@@ -116,6 +120,7 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
116
120
|
generateOAuthData: (redirectUri: string, originalUri?: string) => OauthData;
|
|
117
121
|
getAuthUrl: (oauthData: OauthData, opts?: {
|
|
118
122
|
prompt?: 'login' | 'none';
|
|
123
|
+
responseMode?: 'fragment' | 'web_message' | 'query';
|
|
119
124
|
}) => Promise<{
|
|
120
125
|
authUrl: string;
|
|
121
126
|
}>;
|
|
@@ -123,7 +128,7 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
123
128
|
logout: (originalUrl: string) => Promise<{
|
|
124
129
|
logoutUrl: string;
|
|
125
130
|
}>;
|
|
126
|
-
parseFromUrl: () => {
|
|
131
|
+
parseFromUrl: (url?: string, responseMode?: 'query' | 'fragment') => {
|
|
127
132
|
code: string;
|
|
128
133
|
state: string;
|
|
129
134
|
error?: string;
|
|
@@ -146,8 +151,8 @@ interface IOAuthStrategy extends AuthenticationStrategy {
|
|
|
146
151
|
*/
|
|
147
152
|
sendResetPasswordMail: (email: string, redirectUri: string) => Promise<void>;
|
|
148
153
|
sendPasswordResetEmail: (email: string, redirectUri: string) => Promise<void>;
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
captchaInvisibleSiteKey: string;
|
|
155
|
+
captchaVisibleSiteKey: string;
|
|
151
156
|
loggedIn: () => boolean;
|
|
152
157
|
}
|
|
153
158
|
declare enum LoginState {
|
|
@@ -235,7 +240,6 @@ type Context = {
|
|
|
235
240
|
} | {
|
|
236
241
|
siteId?: string;
|
|
237
242
|
accountId: string;
|
|
238
|
-
apiKey: string;
|
|
239
243
|
};
|
|
240
244
|
declare function ApiKeyStrategy({ siteId, accountId, apiKey, }: {
|
|
241
245
|
apiKey: string;
|
package/build/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -53,6 +54,12 @@ var getDefaultContentHeader = (options) => {
|
|
|
53
54
|
};
|
|
54
55
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
55
56
|
|
|
57
|
+
// src/host-modules.ts
|
|
58
|
+
var isHostModule = (val) => isObject(val) && val.__type === "host";
|
|
59
|
+
function buildHostModule(val, host) {
|
|
60
|
+
return val.create(host);
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
// src/bi/biHeaderGenerator.ts
|
|
57
64
|
var WixBIHeaderName = "x-wix-bi-gateway";
|
|
58
65
|
function biHeaderGenerator(apiMetadata, publicMetadata) {
|
|
@@ -142,12 +149,6 @@ var errorBuilder = (code, description, details, data) => {
|
|
|
142
149
|
};
|
|
143
150
|
};
|
|
144
151
|
|
|
145
|
-
// src/host-modules.ts
|
|
146
|
-
var isHostModule = (val) => isObject(val) && val.__type === "host";
|
|
147
|
-
function buildHostModule(val, host) {
|
|
148
|
-
return val.create(host);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
152
|
// src/wixClient.ts
|
|
152
153
|
function createClient(config) {
|
|
153
154
|
const _headers = config.headers || { Authorization: "" };
|
|
@@ -168,7 +169,7 @@ function createClient(config) {
|
|
|
168
169
|
});
|
|
169
170
|
};
|
|
170
171
|
const use = (modules, metadata) => {
|
|
171
|
-
if (isHostModule(modules)) {
|
|
172
|
+
if (isHostModule(modules) && config.host) {
|
|
172
173
|
return buildHostModule(modules, config.host);
|
|
173
174
|
} else if (typeof modules === "function") {
|
|
174
175
|
return buildRESTDescriptor(
|
|
@@ -389,7 +390,6 @@ var RESET_PASSWORD = "-19973";
|
|
|
389
390
|
|
|
390
391
|
// src/auth/oauth2/OAuthStrategy.ts
|
|
391
392
|
var moduleWithTokens = { redirects: import_redirects.redirects, authentication: import_identity.authentication, recovery: import_identity.recovery, verification: import_identity.verification };
|
|
392
|
-
var WIX_RECAPTCHA_ID = "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v";
|
|
393
393
|
function OAuthStrategy(config) {
|
|
394
394
|
const _tokens = config.tokens || {
|
|
395
395
|
accessToken: { value: "", expiresAt: 0 },
|
|
@@ -504,12 +504,13 @@ function OAuthStrategy(config) {
|
|
|
504
504
|
}) => {
|
|
505
505
|
return getAuthorizationUrlWithOptions(
|
|
506
506
|
oauthData,
|
|
507
|
-
"fragment",
|
|
507
|
+
opts.responseMode ?? "fragment",
|
|
508
508
|
opts.prompt ?? "login"
|
|
509
509
|
);
|
|
510
510
|
};
|
|
511
|
-
const parseFromUrl = () => {
|
|
512
|
-
const
|
|
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));
|
|
513
514
|
const code = params.get("code");
|
|
514
515
|
const state = params.get("state");
|
|
515
516
|
const error = params.get("error");
|
|
@@ -710,18 +711,6 @@ function OAuthStrategy(config) {
|
|
|
710
711
|
redirect: { url: redirectUri, clientId: config.clientId }
|
|
711
712
|
});
|
|
712
713
|
};
|
|
713
|
-
const getRecaptchaScriptUrl = () => {
|
|
714
|
-
return `https://www.google.com/recaptcha/enterprise.js?render=${WIX_RECAPTCHA_ID}`;
|
|
715
|
-
};
|
|
716
|
-
const getRecaptchaToken = async () => {
|
|
717
|
-
return new Promise((resolve) => {
|
|
718
|
-
grecaptcha.enterprise.ready(() => {
|
|
719
|
-
grecaptcha.enterprise.execute(WIX_RECAPTCHA_ID, { action: "submit" }).then((token) => {
|
|
720
|
-
resolve(token);
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
});
|
|
724
|
-
};
|
|
725
714
|
const loggedIn = () => {
|
|
726
715
|
return _tokens.refreshToken.role === "member" /* MEMBER */;
|
|
727
716
|
};
|
|
@@ -751,8 +740,8 @@ function OAuthStrategy(config) {
|
|
|
751
740
|
getMemberTokensForDirectLogin,
|
|
752
741
|
sendResetPasswordMail: sendPasswordResetEmail,
|
|
753
742
|
sendPasswordResetEmail,
|
|
754
|
-
|
|
755
|
-
|
|
743
|
+
captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
|
|
744
|
+
captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
|
|
756
745
|
};
|
|
757
746
|
}
|
|
758
747
|
var fetchTokens = async (payload) => {
|
package/build/index.mjs
CHANGED
|
@@ -11,6 +11,12 @@ var getDefaultContentHeader = (options) => {
|
|
|
11
11
|
};
|
|
12
12
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
13
13
|
|
|
14
|
+
// src/host-modules.ts
|
|
15
|
+
var isHostModule = (val) => isObject(val) && val.__type === "host";
|
|
16
|
+
function buildHostModule(val, host) {
|
|
17
|
+
return val.create(host);
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
// src/bi/biHeaderGenerator.ts
|
|
15
21
|
var WixBIHeaderName = "x-wix-bi-gateway";
|
|
16
22
|
function biHeaderGenerator(apiMetadata, publicMetadata) {
|
|
@@ -100,12 +106,6 @@ var errorBuilder = (code, description, details, data) => {
|
|
|
100
106
|
};
|
|
101
107
|
};
|
|
102
108
|
|
|
103
|
-
// src/host-modules.ts
|
|
104
|
-
var isHostModule = (val) => isObject(val) && val.__type === "host";
|
|
105
|
-
function buildHostModule(val, host) {
|
|
106
|
-
return val.create(host);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
109
|
// src/wixClient.ts
|
|
110
110
|
function createClient(config) {
|
|
111
111
|
const _headers = config.headers || { Authorization: "" };
|
|
@@ -126,7 +126,7 @@ function createClient(config) {
|
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
128
|
const use = (modules, metadata) => {
|
|
129
|
-
if (isHostModule(modules)) {
|
|
129
|
+
if (isHostModule(modules) && config.host) {
|
|
130
130
|
return buildHostModule(modules, config.host);
|
|
131
131
|
} else if (typeof modules === "function") {
|
|
132
132
|
return buildRESTDescriptor(
|
|
@@ -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
|
|
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
|
-
|
|
713
|
-
|
|
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.
|
|
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
|
-
"@
|
|
35
|
-
"@wix/
|
|
36
|
-
"@wix/
|
|
37
|
-
"@wix/
|
|
38
|
-
"@wix/sdk-types": "1.2.5",
|
|
34
|
+
"@wix/identity": "^1.0.47",
|
|
35
|
+
"@wix/image-kit": "^1.35.0",
|
|
36
|
+
"@wix/redirects": "^1.0.22",
|
|
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.
|
|
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": "0180e73db01d9fbc1b95a4afb3f5d9e3a6e79c043617f083429ad6da"
|
|
84
83
|
}
|