@wix/sdk 1.1.21 → 1.2.6
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 +783 -0
- package/build/index.d.mts +248 -0
- package/build/index.d.ts +248 -0
- package/build/index.js +819 -0
- package/build/index.mjs +774 -0
- package/package.json +38 -24
- package/dist/cjs/__tests__/fixtures/constants.js +0 -9
- package/dist/cjs/__tests__/fixtures/constants.js.map +0 -1
- package/dist/cjs/auth/OAuthStrategy.js +0 -90
- package/dist/cjs/auth/OAuthStrategy.js.map +0 -1
- package/dist/cjs/auth/strategy.js +0 -2
- package/dist/cjs/auth/strategy.js.map +0 -1
- package/dist/cjs/external-types.d.js +0 -2
- package/dist/cjs/external-types.d.js.map +0 -1
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/test-types.d.js +0 -2
- package/dist/cjs/test-types.d.js.map +0 -1
- package/dist/cjs/wixClient.js +0 -111
- package/dist/cjs/wixClient.js.map +0 -1
- package/dist/cjs/wixMedia.js +0 -69
- package/dist/cjs/wixMedia.js.map +0 -1
- package/dist/esm/__tests__/fixtures/constants.js +0 -3
- package/dist/esm/__tests__/fixtures/constants.js.map +0 -1
- package/dist/esm/auth/OAuthStrategy.js +0 -86
- package/dist/esm/auth/OAuthStrategy.js.map +0 -1
- package/dist/esm/auth/strategy.js +0 -2
- package/dist/esm/auth/strategy.js.map +0 -1
- package/dist/esm/external-types.d.js +0 -2
- package/dist/esm/external-types.d.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/test-types.d.js +0 -2
- package/dist/esm/test-types.d.js.map +0 -1
- package/dist/esm/wixClient.js +0 -108
- package/dist/esm/wixClient.js.map +0 -1
- package/dist/esm/wixMedia.js +0 -63
- package/dist/esm/wixMedia.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/__tests__/fixtures/constants.d.ts +0 -3
- package/dist/types/__tests__/fixtures/constants.d.ts.map +0 -1
- package/dist/types/auth/OAuthStrategy.d.ts +0 -18
- package/dist/types/auth/OAuthStrategy.d.ts.map +0 -1
- package/dist/types/auth/strategy.d.ts +0 -6
- package/dist/types/auth/strategy.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/wixClient.d.ts +0 -18
- package/dist/types/wixClient.d.ts.map +0 -1
- package/dist/types/wixMedia.d.ts +0 -26
- package/dist/types/wixMedia.d.ts.map +0 -1
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy } from '@wix/sdk-types';
|
|
2
|
+
export * from '@wix/sdk-types';
|
|
3
|
+
import { ConditionalExcept, EmptyObject } from 'type-fest';
|
|
4
|
+
import { ImageTransformOptions } from '@wix/image-kit';
|
|
5
|
+
import { authentication } from '@wix/identity';
|
|
6
|
+
|
|
7
|
+
type PublicMetadata = {
|
|
8
|
+
PACKAGE_NAME?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type Headers = {
|
|
12
|
+
Authorization: string;
|
|
13
|
+
} & Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
16
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
17
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
18
|
+
* do not match the given host (as they will not work with the given host).
|
|
19
|
+
*/
|
|
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;
|
|
26
|
+
}, EmptyObject>;
|
|
27
|
+
/**
|
|
28
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
29
|
+
* can either be a REST module or a host module.
|
|
30
|
+
* This type is recursive, so it can describe nested modules.
|
|
31
|
+
*/
|
|
32
|
+
type Descriptors = RESTFunctionDescriptor | HostModule<any, any> | {
|
|
33
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* This type is used in `createClient` to ensure that the given host matches the host of the given descriptors.
|
|
37
|
+
* If the host does not match, the descriptor is replaced with a host module that will throw an error when used.
|
|
38
|
+
*/
|
|
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];
|
|
41
|
+
};
|
|
42
|
+
type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = Descriptors> = {
|
|
43
|
+
setHeaders(headers: Headers): void;
|
|
44
|
+
auth: Z;
|
|
45
|
+
fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
|
|
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;
|
|
50
|
+
auth?: Z;
|
|
51
|
+
headers?: Headers;
|
|
52
|
+
host?: H;
|
|
53
|
+
}): WixClient<H, Z, T>;
|
|
54
|
+
|
|
55
|
+
declare function getScaledToFillImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
56
|
+
declare function getScaledToFitImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
57
|
+
declare function getCroppedImageUrl(wixMediaIdentifier: string, cropX: number, cropY: number, cropWidth: number, cropHeight: number, targetWidth: number, targetHeight: number, options?: ImageTransformOptions): string;
|
|
58
|
+
declare function getImageUrl(val: string): {
|
|
59
|
+
id: string;
|
|
60
|
+
url: string;
|
|
61
|
+
height: number;
|
|
62
|
+
width: number;
|
|
63
|
+
} | {
|
|
64
|
+
altText: string;
|
|
65
|
+
filename: string;
|
|
66
|
+
id: string;
|
|
67
|
+
url: string;
|
|
68
|
+
height: number;
|
|
69
|
+
width: number;
|
|
70
|
+
};
|
|
71
|
+
declare function decodeText(s: string): string;
|
|
72
|
+
declare const media: {
|
|
73
|
+
getCroppedImageUrl: typeof getCroppedImageUrl;
|
|
74
|
+
getScaledToFillImageUrl: typeof getScaledToFillImageUrl;
|
|
75
|
+
getScaledToFitImageUrl: typeof getScaledToFitImageUrl;
|
|
76
|
+
getImageUrl: typeof getImageUrl;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
interface Tokens {
|
|
80
|
+
accessToken: AccessToken;
|
|
81
|
+
refreshToken: RefreshToken;
|
|
82
|
+
}
|
|
83
|
+
interface Token {
|
|
84
|
+
value: string;
|
|
85
|
+
}
|
|
86
|
+
interface AccessToken extends Token {
|
|
87
|
+
expiresAt: number;
|
|
88
|
+
}
|
|
89
|
+
interface RefreshToken extends Token {
|
|
90
|
+
role: TokenRole;
|
|
91
|
+
}
|
|
92
|
+
interface OauthData extends OauthPKCE {
|
|
93
|
+
originalUri: string;
|
|
94
|
+
redirectUri: string;
|
|
95
|
+
}
|
|
96
|
+
interface OauthPKCE {
|
|
97
|
+
codeVerifier: string;
|
|
98
|
+
codeChallenge: string;
|
|
99
|
+
state: string;
|
|
100
|
+
}
|
|
101
|
+
interface RegisterParams extends LoginParams {
|
|
102
|
+
profile?: authentication.IdentityProfile;
|
|
103
|
+
}
|
|
104
|
+
interface LoginParams {
|
|
105
|
+
email: string;
|
|
106
|
+
password: string;
|
|
107
|
+
captchaTokens?: {
|
|
108
|
+
invisibleRecaptchaToken?: string;
|
|
109
|
+
recaptchaToken?: string;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
interface IOAuthStrategy extends AuthenticationStrategy {
|
|
113
|
+
generateVisitorTokens(tokens?: {
|
|
114
|
+
refreshToken?: RefreshToken;
|
|
115
|
+
accessToken?: AccessToken;
|
|
116
|
+
}): Promise<Tokens>;
|
|
117
|
+
renewToken: (refreshToken: RefreshToken) => Promise<Tokens>;
|
|
118
|
+
setTokens: (tokens: Tokens) => void;
|
|
119
|
+
getTokens: () => Tokens;
|
|
120
|
+
generateOAuthData: (redirectUri: string, originalUri?: string) => OauthData;
|
|
121
|
+
getAuthUrl: (oauthData: OauthData, opts?: {
|
|
122
|
+
prompt?: 'login' | 'none';
|
|
123
|
+
}) => Promise<{
|
|
124
|
+
authUrl: string;
|
|
125
|
+
}>;
|
|
126
|
+
getMemberTokens: (code: string, state: string, oauthData: OauthData) => Promise<Tokens>;
|
|
127
|
+
logout: (originalUrl: string) => Promise<{
|
|
128
|
+
logoutUrl: string;
|
|
129
|
+
}>;
|
|
130
|
+
parseFromUrl: () => {
|
|
131
|
+
code: string;
|
|
132
|
+
state: string;
|
|
133
|
+
error?: string;
|
|
134
|
+
errorDescription?: string;
|
|
135
|
+
};
|
|
136
|
+
register: (params: RegisterParams) => Promise<StateMachine>;
|
|
137
|
+
login: (params: LoginParams) => Promise<StateMachine>;
|
|
138
|
+
processVerification<T extends ProcessableState>(nextInputs: CalculateNextState<T>): Promise<StateMachine>;
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated use processVerification instead
|
|
141
|
+
*/
|
|
142
|
+
proceed<T extends ProcessableState>(nextInputs: DeprecatedCalculateNextState<T>): Promise<StateMachine>;
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated use getMemberTokensForDirectLogin instead
|
|
145
|
+
*/
|
|
146
|
+
complete: (sessionToken: string) => Promise<Tokens>;
|
|
147
|
+
getMemberTokensForDirectLogin: (sessionToken: string) => Promise<Tokens>;
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated use sendPasswordResetEmail instead
|
|
150
|
+
*/
|
|
151
|
+
sendResetPasswordMail: (email: string, redirectUri: string) => Promise<void>;
|
|
152
|
+
sendPasswordResetEmail: (email: string, redirectUri: string) => Promise<void>;
|
|
153
|
+
getRecaptchaScriptUrl: () => string;
|
|
154
|
+
getRecaptchaToken: () => Promise<string>;
|
|
155
|
+
loggedIn: () => boolean;
|
|
156
|
+
}
|
|
157
|
+
declare enum LoginState {
|
|
158
|
+
SUCCESS = "SUCCESS",
|
|
159
|
+
INITIAL = "INITIAL",
|
|
160
|
+
FAILURE = "FAILURE",
|
|
161
|
+
EMAIL_VERIFICATION_REQUIRED = "EMAIL_VERIFICATION_REQUIRED",
|
|
162
|
+
OWNER_APPROVAL_REQUIRED = "OWNER_APPROVAL_REQUIRED",
|
|
163
|
+
USER_CAPTCHA_REQUIRED = "USER_CAPTCHA_REQUIRED",
|
|
164
|
+
SILENT_CAPTCHA_REQUIRED = "SILENT_CAPTCHA_REQUIRED"
|
|
165
|
+
}
|
|
166
|
+
interface LoginResults<SK extends string, LK extends LoginState> {
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated use loginState instead
|
|
169
|
+
*/
|
|
170
|
+
stateKind: SK;
|
|
171
|
+
loginState: LK;
|
|
172
|
+
}
|
|
173
|
+
interface SuccessState extends LoginResults<'success', LoginState.SUCCESS> {
|
|
174
|
+
data: {
|
|
175
|
+
sessionToken: string;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
interface InitialState extends LoginResults<'initial', LoginState.INITIAL> {
|
|
179
|
+
}
|
|
180
|
+
interface ErrorState extends LoginResults<'failure', LoginState.FAILURE> {
|
|
181
|
+
errorCode?: 'invalidEmail' | 'invalidPassword' | 'resetPassword' | 'missingCaptchaToken' | 'emailAlreadyExists' | 'invalidCaptchaToken';
|
|
182
|
+
error: string;
|
|
183
|
+
}
|
|
184
|
+
interface EmailVerificationRequiredState extends LoginResults<'emailVerificationRequired', LoginState.EMAIL_VERIFICATION_REQUIRED> {
|
|
185
|
+
data: {
|
|
186
|
+
stateToken: string;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
interface OwnerApprovalRequiredState extends LoginResults<'ownerApprovalRequired', LoginState.OWNER_APPROVAL_REQUIRED> {
|
|
190
|
+
}
|
|
191
|
+
interface SilentCaptchaRequiredState extends LoginResults<'silentCaptchaRequired', LoginState.SILENT_CAPTCHA_REQUIRED> {
|
|
192
|
+
data: {
|
|
193
|
+
stateToken: string;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
interface UserCaptchaRequiredState extends LoginResults<'userCaptchaRequired', LoginState.USER_CAPTCHA_REQUIRED> {
|
|
197
|
+
data: {
|
|
198
|
+
stateToken: string;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
declare enum TokenRole {
|
|
202
|
+
NONE = "none",
|
|
203
|
+
VISITOR = "visitor",
|
|
204
|
+
MEMBER = "member"
|
|
205
|
+
}
|
|
206
|
+
type StateMachine = InitialState | SuccessState | ErrorState | EmailVerificationRequiredState | OwnerApprovalRequiredState | SilentCaptchaRequiredState | UserCaptchaRequiredState;
|
|
207
|
+
type DeprecatedCode = {
|
|
208
|
+
/**
|
|
209
|
+
* @deprecated use verificationCode instead
|
|
210
|
+
*/
|
|
211
|
+
code: string;
|
|
212
|
+
};
|
|
213
|
+
type VerificationCode = {
|
|
214
|
+
verificationCode: string;
|
|
215
|
+
};
|
|
216
|
+
type DeprecatedCalculateNextState<T> = T extends EmailVerificationRequiredState ? DeprecatedCode : never;
|
|
217
|
+
type CalculateNextState<T> = T extends EmailVerificationRequiredState ? VerificationCode : never;
|
|
218
|
+
type ProcessableState = EmailVerificationRequiredState;
|
|
219
|
+
|
|
220
|
+
declare function OAuthStrategy(config: {
|
|
221
|
+
clientId: string;
|
|
222
|
+
tokens?: Tokens;
|
|
223
|
+
}): IOAuthStrategy;
|
|
224
|
+
interface TokenResponse {
|
|
225
|
+
access_token: string;
|
|
226
|
+
expires_in: number;
|
|
227
|
+
refresh_token: string | null;
|
|
228
|
+
token_type: string;
|
|
229
|
+
scope?: string | null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface IApiKeyStrategy extends AuthenticationStrategy {
|
|
233
|
+
setSiteId(siteId?: string): void;
|
|
234
|
+
setAccountId(accountId?: string): void;
|
|
235
|
+
}
|
|
236
|
+
type Context = {
|
|
237
|
+
siteId: string;
|
|
238
|
+
accountId?: string;
|
|
239
|
+
} | {
|
|
240
|
+
siteId?: string;
|
|
241
|
+
accountId: string;
|
|
242
|
+
apiKey: string;
|
|
243
|
+
};
|
|
244
|
+
declare function ApiKeyStrategy({ siteId, accountId, apiKey, }: {
|
|
245
|
+
apiKey: string;
|
|
246
|
+
} & Context): IApiKeyStrategy;
|
|
247
|
+
|
|
248
|
+
export { AccessToken, ApiKeyStrategy, AssertHostMatches, BuildDescriptors, CalculateNextState, DeprecatedCalculateNextState, Descriptors, IApiKeyStrategy, IOAuthStrategy, LoginParams, LoginState, OAuthStrategy, OauthData, OauthPKCE, ProcessableState, RefreshToken, RegisterParams, StateMachine, Token, TokenResponse, TokenRole, Tokens, WixClient, createClient, decodeText, media };
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy } from '@wix/sdk-types';
|
|
2
|
+
export * from '@wix/sdk-types';
|
|
3
|
+
import { ConditionalExcept, EmptyObject } from 'type-fest';
|
|
4
|
+
import { ImageTransformOptions } from '@wix/image-kit';
|
|
5
|
+
import { authentication } from '@wix/identity';
|
|
6
|
+
|
|
7
|
+
type PublicMetadata = {
|
|
8
|
+
PACKAGE_NAME?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type Headers = {
|
|
12
|
+
Authorization: string;
|
|
13
|
+
} & Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
16
|
+
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
17
|
+
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
18
|
+
* do not match the given host (as they will not work with the given host).
|
|
19
|
+
*/
|
|
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;
|
|
26
|
+
}, EmptyObject>;
|
|
27
|
+
/**
|
|
28
|
+
* Descriptors are objects that describe the API of a module, and the module
|
|
29
|
+
* can either be a REST module or a host module.
|
|
30
|
+
* This type is recursive, so it can describe nested modules.
|
|
31
|
+
*/
|
|
32
|
+
type Descriptors = RESTFunctionDescriptor | HostModule<any, any> | {
|
|
33
|
+
[key: string]: Descriptors | PublicMetadata | any;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* This type is used in `createClient` to ensure that the given host matches the host of the given descriptors.
|
|
37
|
+
* If the host does not match, the descriptor is replaced with a host module that will throw an error when used.
|
|
38
|
+
*/
|
|
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];
|
|
41
|
+
};
|
|
42
|
+
type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = Descriptors> = {
|
|
43
|
+
setHeaders(headers: Headers): void;
|
|
44
|
+
auth: Z;
|
|
45
|
+
fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
|
|
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;
|
|
50
|
+
auth?: Z;
|
|
51
|
+
headers?: Headers;
|
|
52
|
+
host?: H;
|
|
53
|
+
}): WixClient<H, Z, T>;
|
|
54
|
+
|
|
55
|
+
declare function getScaledToFillImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
56
|
+
declare function getScaledToFitImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
57
|
+
declare function getCroppedImageUrl(wixMediaIdentifier: string, cropX: number, cropY: number, cropWidth: number, cropHeight: number, targetWidth: number, targetHeight: number, options?: ImageTransformOptions): string;
|
|
58
|
+
declare function getImageUrl(val: string): {
|
|
59
|
+
id: string;
|
|
60
|
+
url: string;
|
|
61
|
+
height: number;
|
|
62
|
+
width: number;
|
|
63
|
+
} | {
|
|
64
|
+
altText: string;
|
|
65
|
+
filename: string;
|
|
66
|
+
id: string;
|
|
67
|
+
url: string;
|
|
68
|
+
height: number;
|
|
69
|
+
width: number;
|
|
70
|
+
};
|
|
71
|
+
declare function decodeText(s: string): string;
|
|
72
|
+
declare const media: {
|
|
73
|
+
getCroppedImageUrl: typeof getCroppedImageUrl;
|
|
74
|
+
getScaledToFillImageUrl: typeof getScaledToFillImageUrl;
|
|
75
|
+
getScaledToFitImageUrl: typeof getScaledToFitImageUrl;
|
|
76
|
+
getImageUrl: typeof getImageUrl;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
interface Tokens {
|
|
80
|
+
accessToken: AccessToken;
|
|
81
|
+
refreshToken: RefreshToken;
|
|
82
|
+
}
|
|
83
|
+
interface Token {
|
|
84
|
+
value: string;
|
|
85
|
+
}
|
|
86
|
+
interface AccessToken extends Token {
|
|
87
|
+
expiresAt: number;
|
|
88
|
+
}
|
|
89
|
+
interface RefreshToken extends Token {
|
|
90
|
+
role: TokenRole;
|
|
91
|
+
}
|
|
92
|
+
interface OauthData extends OauthPKCE {
|
|
93
|
+
originalUri: string;
|
|
94
|
+
redirectUri: string;
|
|
95
|
+
}
|
|
96
|
+
interface OauthPKCE {
|
|
97
|
+
codeVerifier: string;
|
|
98
|
+
codeChallenge: string;
|
|
99
|
+
state: string;
|
|
100
|
+
}
|
|
101
|
+
interface RegisterParams extends LoginParams {
|
|
102
|
+
profile?: authentication.IdentityProfile;
|
|
103
|
+
}
|
|
104
|
+
interface LoginParams {
|
|
105
|
+
email: string;
|
|
106
|
+
password: string;
|
|
107
|
+
captchaTokens?: {
|
|
108
|
+
invisibleRecaptchaToken?: string;
|
|
109
|
+
recaptchaToken?: string;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
interface IOAuthStrategy extends AuthenticationStrategy {
|
|
113
|
+
generateVisitorTokens(tokens?: {
|
|
114
|
+
refreshToken?: RefreshToken;
|
|
115
|
+
accessToken?: AccessToken;
|
|
116
|
+
}): Promise<Tokens>;
|
|
117
|
+
renewToken: (refreshToken: RefreshToken) => Promise<Tokens>;
|
|
118
|
+
setTokens: (tokens: Tokens) => void;
|
|
119
|
+
getTokens: () => Tokens;
|
|
120
|
+
generateOAuthData: (redirectUri: string, originalUri?: string) => OauthData;
|
|
121
|
+
getAuthUrl: (oauthData: OauthData, opts?: {
|
|
122
|
+
prompt?: 'login' | 'none';
|
|
123
|
+
}) => Promise<{
|
|
124
|
+
authUrl: string;
|
|
125
|
+
}>;
|
|
126
|
+
getMemberTokens: (code: string, state: string, oauthData: OauthData) => Promise<Tokens>;
|
|
127
|
+
logout: (originalUrl: string) => Promise<{
|
|
128
|
+
logoutUrl: string;
|
|
129
|
+
}>;
|
|
130
|
+
parseFromUrl: () => {
|
|
131
|
+
code: string;
|
|
132
|
+
state: string;
|
|
133
|
+
error?: string;
|
|
134
|
+
errorDescription?: string;
|
|
135
|
+
};
|
|
136
|
+
register: (params: RegisterParams) => Promise<StateMachine>;
|
|
137
|
+
login: (params: LoginParams) => Promise<StateMachine>;
|
|
138
|
+
processVerification<T extends ProcessableState>(nextInputs: CalculateNextState<T>): Promise<StateMachine>;
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated use processVerification instead
|
|
141
|
+
*/
|
|
142
|
+
proceed<T extends ProcessableState>(nextInputs: DeprecatedCalculateNextState<T>): Promise<StateMachine>;
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated use getMemberTokensForDirectLogin instead
|
|
145
|
+
*/
|
|
146
|
+
complete: (sessionToken: string) => Promise<Tokens>;
|
|
147
|
+
getMemberTokensForDirectLogin: (sessionToken: string) => Promise<Tokens>;
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated use sendPasswordResetEmail instead
|
|
150
|
+
*/
|
|
151
|
+
sendResetPasswordMail: (email: string, redirectUri: string) => Promise<void>;
|
|
152
|
+
sendPasswordResetEmail: (email: string, redirectUri: string) => Promise<void>;
|
|
153
|
+
getRecaptchaScriptUrl: () => string;
|
|
154
|
+
getRecaptchaToken: () => Promise<string>;
|
|
155
|
+
loggedIn: () => boolean;
|
|
156
|
+
}
|
|
157
|
+
declare enum LoginState {
|
|
158
|
+
SUCCESS = "SUCCESS",
|
|
159
|
+
INITIAL = "INITIAL",
|
|
160
|
+
FAILURE = "FAILURE",
|
|
161
|
+
EMAIL_VERIFICATION_REQUIRED = "EMAIL_VERIFICATION_REQUIRED",
|
|
162
|
+
OWNER_APPROVAL_REQUIRED = "OWNER_APPROVAL_REQUIRED",
|
|
163
|
+
USER_CAPTCHA_REQUIRED = "USER_CAPTCHA_REQUIRED",
|
|
164
|
+
SILENT_CAPTCHA_REQUIRED = "SILENT_CAPTCHA_REQUIRED"
|
|
165
|
+
}
|
|
166
|
+
interface LoginResults<SK extends string, LK extends LoginState> {
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated use loginState instead
|
|
169
|
+
*/
|
|
170
|
+
stateKind: SK;
|
|
171
|
+
loginState: LK;
|
|
172
|
+
}
|
|
173
|
+
interface SuccessState extends LoginResults<'success', LoginState.SUCCESS> {
|
|
174
|
+
data: {
|
|
175
|
+
sessionToken: string;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
interface InitialState extends LoginResults<'initial', LoginState.INITIAL> {
|
|
179
|
+
}
|
|
180
|
+
interface ErrorState extends LoginResults<'failure', LoginState.FAILURE> {
|
|
181
|
+
errorCode?: 'invalidEmail' | 'invalidPassword' | 'resetPassword' | 'missingCaptchaToken' | 'emailAlreadyExists' | 'invalidCaptchaToken';
|
|
182
|
+
error: string;
|
|
183
|
+
}
|
|
184
|
+
interface EmailVerificationRequiredState extends LoginResults<'emailVerificationRequired', LoginState.EMAIL_VERIFICATION_REQUIRED> {
|
|
185
|
+
data: {
|
|
186
|
+
stateToken: string;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
interface OwnerApprovalRequiredState extends LoginResults<'ownerApprovalRequired', LoginState.OWNER_APPROVAL_REQUIRED> {
|
|
190
|
+
}
|
|
191
|
+
interface SilentCaptchaRequiredState extends LoginResults<'silentCaptchaRequired', LoginState.SILENT_CAPTCHA_REQUIRED> {
|
|
192
|
+
data: {
|
|
193
|
+
stateToken: string;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
interface UserCaptchaRequiredState extends LoginResults<'userCaptchaRequired', LoginState.USER_CAPTCHA_REQUIRED> {
|
|
197
|
+
data: {
|
|
198
|
+
stateToken: string;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
declare enum TokenRole {
|
|
202
|
+
NONE = "none",
|
|
203
|
+
VISITOR = "visitor",
|
|
204
|
+
MEMBER = "member"
|
|
205
|
+
}
|
|
206
|
+
type StateMachine = InitialState | SuccessState | ErrorState | EmailVerificationRequiredState | OwnerApprovalRequiredState | SilentCaptchaRequiredState | UserCaptchaRequiredState;
|
|
207
|
+
type DeprecatedCode = {
|
|
208
|
+
/**
|
|
209
|
+
* @deprecated use verificationCode instead
|
|
210
|
+
*/
|
|
211
|
+
code: string;
|
|
212
|
+
};
|
|
213
|
+
type VerificationCode = {
|
|
214
|
+
verificationCode: string;
|
|
215
|
+
};
|
|
216
|
+
type DeprecatedCalculateNextState<T> = T extends EmailVerificationRequiredState ? DeprecatedCode : never;
|
|
217
|
+
type CalculateNextState<T> = T extends EmailVerificationRequiredState ? VerificationCode : never;
|
|
218
|
+
type ProcessableState = EmailVerificationRequiredState;
|
|
219
|
+
|
|
220
|
+
declare function OAuthStrategy(config: {
|
|
221
|
+
clientId: string;
|
|
222
|
+
tokens?: Tokens;
|
|
223
|
+
}): IOAuthStrategy;
|
|
224
|
+
interface TokenResponse {
|
|
225
|
+
access_token: string;
|
|
226
|
+
expires_in: number;
|
|
227
|
+
refresh_token: string | null;
|
|
228
|
+
token_type: string;
|
|
229
|
+
scope?: string | null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface IApiKeyStrategy extends AuthenticationStrategy {
|
|
233
|
+
setSiteId(siteId?: string): void;
|
|
234
|
+
setAccountId(accountId?: string): void;
|
|
235
|
+
}
|
|
236
|
+
type Context = {
|
|
237
|
+
siteId: string;
|
|
238
|
+
accountId?: string;
|
|
239
|
+
} | {
|
|
240
|
+
siteId?: string;
|
|
241
|
+
accountId: string;
|
|
242
|
+
apiKey: string;
|
|
243
|
+
};
|
|
244
|
+
declare function ApiKeyStrategy({ siteId, accountId, apiKey, }: {
|
|
245
|
+
apiKey: string;
|
|
246
|
+
} & Context): IApiKeyStrategy;
|
|
247
|
+
|
|
248
|
+
export { AccessToken, ApiKeyStrategy, AssertHostMatches, BuildDescriptors, CalculateNextState, DeprecatedCalculateNextState, Descriptors, IApiKeyStrategy, IOAuthStrategy, LoginParams, LoginState, OAuthStrategy, OauthData, OauthPKCE, ProcessableState, RefreshToken, RegisterParams, StateMachine, Token, TokenResponse, TokenRole, Tokens, WixClient, createClient, decodeText, media };
|