@wix/sdk 1.5.9 → 1.6.1
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/auth/api-key/package.json +3 -0
- package/auth/oauth2/package.json +3 -0
- package/auth/wix-app-oauth/package.json +3 -0
- package/build/ambassador-modules.d.ts +31 -0
- package/build/ambassador-modules.js +89 -0
- package/build/auth/ApiKeyAuthStrategy.d.ts +16 -0
- package/build/auth/ApiKeyAuthStrategy.js +22 -0
- package/build/auth/WixAppOAuthStrategy.d.ts +54 -0
- package/build/auth/WixAppOAuthStrategy.js +106 -0
- package/build/auth/oauth2/OAuthStrategy.d.ts +12 -0
- package/build/auth/oauth2/OAuthStrategy.js +357 -0
- package/build/auth/oauth2/constants.d.ts +5 -0
- package/build/auth/oauth2/constants.js +5 -0
- package/build/auth/oauth2/pkce-challenge.d.ts +5 -0
- package/build/auth/oauth2/pkce-challenge.js +33 -0
- package/build/auth/oauth2/types.d.ts +121 -0
- package/build/auth/oauth2/types.js +16 -0
- package/build/bi/biHeaderGenerator.d.ts +12 -0
- package/build/bi/biHeaderGenerator.js +17 -0
- package/build/common.d.ts +7 -0
- package/build/common.js +4 -0
- package/build/fetch-error.d.ts +9 -0
- package/build/fetch-error.js +31 -0
- package/build/helpers.d.ts +4 -0
- package/build/helpers.js +11 -0
- package/build/host-modules.d.ts +3 -0
- package/build/host-modules.js +5 -0
- package/build/iframeUtils.d.ts +4 -0
- package/build/iframeUtils.js +43 -0
- package/build/index.d.ts +8 -388
- package/build/index.js +9 -1115
- package/build/rest-modules.d.ts +7 -0
- package/build/rest-modules.js +82 -0
- package/build/tokenHelpers.d.ts +4 -0
- package/build/tokenHelpers.js +11 -0
- package/build/wixClient.d.ts +70 -0
- package/build/wixClient.js +86 -0
- package/build/wixMedia.d.ts +46 -0
- package/build/wixMedia.js +156 -0
- package/cjs/build/ambassador-modules.d.ts +31 -0
- package/cjs/build/ambassador-modules.js +95 -0
- package/cjs/build/auth/ApiKeyAuthStrategy.d.ts +16 -0
- package/cjs/build/auth/ApiKeyAuthStrategy.js +26 -0
- package/cjs/build/auth/WixAppOAuthStrategy.d.ts +54 -0
- package/cjs/build/auth/WixAppOAuthStrategy.js +110 -0
- package/cjs/build/auth/oauth2/OAuthStrategy.d.ts +12 -0
- package/cjs/build/auth/oauth2/OAuthStrategy.js +361 -0
- package/cjs/build/auth/oauth2/constants.d.ts +5 -0
- package/cjs/build/auth/oauth2/constants.js +8 -0
- package/cjs/build/auth/oauth2/pkce-challenge.d.ts +5 -0
- package/cjs/build/auth/oauth2/pkce-challenge.js +41 -0
- package/cjs/build/auth/oauth2/types.d.ts +121 -0
- package/cjs/build/auth/oauth2/types.js +19 -0
- package/cjs/build/bi/biHeaderGenerator.d.ts +12 -0
- package/cjs/build/bi/biHeaderGenerator.js +21 -0
- package/cjs/build/common.d.ts +7 -0
- package/cjs/build/common.js +7 -0
- package/cjs/build/fetch-error.d.ts +9 -0
- package/cjs/build/fetch-error.js +35 -0
- package/cjs/build/helpers.d.ts +4 -0
- package/cjs/build/helpers.js +16 -0
- package/cjs/build/host-modules.d.ts +3 -0
- package/cjs/build/host-modules.js +10 -0
- package/cjs/build/iframeUtils.d.ts +4 -0
- package/cjs/build/iframeUtils.js +50 -0
- package/cjs/build/index.d.ts +9 -0
- package/cjs/build/index.js +28 -0
- package/cjs/build/rest-modules.d.ts +7 -0
- package/cjs/build/rest-modules.js +87 -0
- package/cjs/build/tokenHelpers.d.ts +4 -0
- package/cjs/build/tokenHelpers.js +17 -0
- package/cjs/build/wixClient.d.ts +70 -0
- package/cjs/build/wixClient.js +90 -0
- package/cjs/build/wixMedia.d.ts +46 -0
- package/cjs/build/wixMedia.js +160 -0
- package/cjs/package.json +3 -0
- package/client/package.json +3 -0
- package/package.json +45 -22
- package/build/browser/index.mjs +0 -1075
- package/build/index.d.mts +0 -389
- package/build/index.mjs +0 -1066
package/build/index.d.mts
DELETED
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy, BoundAuthenticationStrategy } 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
|
-
declare const API_URL = "www.wixapis.com";
|
|
11
|
-
|
|
12
|
-
declare const getDefaultDomain: (method: string, url: string) => "www.wixapis.com" | "readonly.wixapis.com";
|
|
13
|
-
|
|
14
|
-
type RequestContext = {
|
|
15
|
-
isSSR: boolean;
|
|
16
|
-
host: string;
|
|
17
|
-
protocol?: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Ambassador request options types are copied mostly from AxiosRequestConfig.
|
|
21
|
-
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
|
|
22
|
-
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
|
|
23
|
-
*/
|
|
24
|
-
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
25
|
-
type ResponseTransformer = (data: any, headers?: any) => any;
|
|
26
|
-
type AmbassadorRequestOptions<T = any> = {
|
|
27
|
-
_?: T;
|
|
28
|
-
url?: string;
|
|
29
|
-
method?: Method;
|
|
30
|
-
params?: any;
|
|
31
|
-
data?: any;
|
|
32
|
-
transformResponse?: ResponseTransformer | ResponseTransformer[];
|
|
33
|
-
};
|
|
34
|
-
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
|
|
35
|
-
__isAmbassador: boolean;
|
|
36
|
-
};
|
|
37
|
-
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
|
|
38
|
-
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Represents a location in a Source.
|
|
42
|
-
*/
|
|
43
|
-
interface SourceLocation {
|
|
44
|
-
readonly line: number;
|
|
45
|
-
readonly column: number;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* See: https://spec.graphql.org/draft/#sec-Errors
|
|
50
|
-
*/
|
|
51
|
-
interface GraphQLFormattedError {
|
|
52
|
-
/**
|
|
53
|
-
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
|
54
|
-
* from occurrence to occurrence of the problem, except for purposes of
|
|
55
|
-
* localization.
|
|
56
|
-
*/
|
|
57
|
-
readonly message: string;
|
|
58
|
-
/**
|
|
59
|
-
* If an error can be associated to a particular point in the requested
|
|
60
|
-
* GraphQL document, it should contain a list of locations.
|
|
61
|
-
*/
|
|
62
|
-
readonly locations?: ReadonlyArray<SourceLocation>;
|
|
63
|
-
/**
|
|
64
|
-
* If an error can be associated to a particular field in the GraphQL result,
|
|
65
|
-
* it _must_ contain an entry with the key `path` that details the path of
|
|
66
|
-
* the response field which experienced the error. This allows clients to
|
|
67
|
-
* identify whether a null result is intentional or caused by a runtime error.
|
|
68
|
-
*/
|
|
69
|
-
readonly path?: ReadonlyArray<string | number>;
|
|
70
|
-
/**
|
|
71
|
-
* Reserved for implementors to extend the protocol however they see fit,
|
|
72
|
-
* and hence there are no additional restrictions on its contents.
|
|
73
|
-
*/
|
|
74
|
-
readonly extensions?: {
|
|
75
|
-
[key: string]: unknown;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
type Headers = Record<string, string>;
|
|
80
|
-
/**
|
|
81
|
-
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
|
|
82
|
-
* and returns an object with the same structure, but with all descriptors replaced with their API.
|
|
83
|
-
* Any non-descriptor properties are removed from the returned object, including descriptors that
|
|
84
|
-
* do not match the given host (as they will not work with the given host).
|
|
85
|
-
*/
|
|
86
|
-
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined> = BuildRESTDescriptors<T> & BuildAmbassadorDescriptors<T> & (H extends Host<any> ? BuildHostDescriptors<T> : {});
|
|
87
|
-
type BuildRESTDescriptors<T extends Descriptors> = T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : ConditionalExcept<{
|
|
88
|
-
[Key in keyof T]: T[Key] extends Descriptors ? BuildRESTDescriptors<T[Key]> : never;
|
|
89
|
-
}, EmptyObject>;
|
|
90
|
-
type BuildAmbassadorDescriptors<T extends Descriptors> = T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : ConditionalExcept<{
|
|
91
|
-
[Key in keyof T]: T[Key] extends Descriptors ? BuildAmbassadorDescriptors<T[Key]> : never;
|
|
92
|
-
}, EmptyObject>;
|
|
93
|
-
type BuildHostDescriptors<T extends Descriptors> = T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
|
|
94
|
-
[Key in keyof T]: T[Key] extends Descriptors ? BuildHostDescriptors<T[Key]> : never;
|
|
95
|
-
}, EmptyObject>;
|
|
96
|
-
/**
|
|
97
|
-
* Descriptors are objects that describe the API of a module, and the module
|
|
98
|
-
* can either be a REST module or a host module.
|
|
99
|
-
* This type is recursive, so it can describe nested modules.
|
|
100
|
-
*/
|
|
101
|
-
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | {
|
|
102
|
-
[key: string]: Descriptors | PublicMetadata | any;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* This type is used in `createClient` to ensure that the given host matches the host of the given descriptors.
|
|
106
|
-
* If the host does not match, the descriptor is replaced with a host module that will throw an error when used.
|
|
107
|
-
*/
|
|
108
|
-
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 : {
|
|
109
|
-
[Key in keyof T]: T[Key] extends Descriptors ? AssertHostMatches<T[Key], H> : T[Key];
|
|
110
|
-
};
|
|
111
|
-
type TypedQueryInput<Result = {
|
|
112
|
-
[key: string]: any;
|
|
113
|
-
}, Variables = {
|
|
114
|
-
[key: string]: any;
|
|
115
|
-
}> = {
|
|
116
|
-
/**
|
|
117
|
-
* Type to support `@graphql-typed-document-node/core`
|
|
118
|
-
* @internal
|
|
119
|
-
*/
|
|
120
|
-
__apiType?: (variables: Variables) => Result;
|
|
121
|
-
/**
|
|
122
|
-
* Type to support `TypedQueryDocumentNode` from `graphql`
|
|
123
|
-
* @internal
|
|
124
|
-
*/
|
|
125
|
-
__ensureTypesOfVariablesAndResultMatching?: (variables: Variables) => Result;
|
|
126
|
-
};
|
|
127
|
-
type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = Descriptors> = {
|
|
128
|
-
setHeaders(headers: Headers): void;
|
|
129
|
-
auth: Omit<Z, 'getAuthHeaders'> & BoundAuthenticationStrategy;
|
|
130
|
-
fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
|
|
131
|
-
use<R extends Descriptors = EmptyObject>(modules: H extends Host<any> ? AssertHostMatches<R, H> : R): BuildDescriptors<R, H>;
|
|
132
|
-
graphql<Result, Variables>(query: string | ((string | String) & TypedQueryInput<Result, Variables>), variables?: Variables): Promise<{
|
|
133
|
-
data: Result;
|
|
134
|
-
errors?: GraphQLFormattedError[];
|
|
135
|
-
}>;
|
|
136
|
-
} & BuildDescriptors<T, H>;
|
|
137
|
-
declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = EmptyObject>(config: {
|
|
138
|
-
modules?: H extends Host<any> ? AssertHostMatches<T, H> : T;
|
|
139
|
-
auth?: Z;
|
|
140
|
-
headers?: Headers;
|
|
141
|
-
host?: H;
|
|
142
|
-
}): WixClient<H, Z, T>;
|
|
143
|
-
|
|
144
|
-
declare function getScaledToFillImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
145
|
-
declare function getScaledToFitImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
146
|
-
declare function getCroppedImageUrl(wixMediaIdentifier: string, cropX: number, cropY: number, cropWidth: number, cropHeight: number, targetWidth: number, targetHeight: number, options?: ImageTransformOptions): string;
|
|
147
|
-
declare function getImageUrl(val: string): {
|
|
148
|
-
id: string;
|
|
149
|
-
url: string;
|
|
150
|
-
height: number;
|
|
151
|
-
width: number;
|
|
152
|
-
altText?: string;
|
|
153
|
-
filename?: string;
|
|
154
|
-
};
|
|
155
|
-
declare function getVideoUrl(val: string, resolution?: VideoResolution): {
|
|
156
|
-
id: string;
|
|
157
|
-
url: string;
|
|
158
|
-
thumbnail: string;
|
|
159
|
-
filename?: string;
|
|
160
|
-
};
|
|
161
|
-
declare function getAudioUrl(val: string): {
|
|
162
|
-
id: string;
|
|
163
|
-
url: string;
|
|
164
|
-
duration: number;
|
|
165
|
-
filename?: string;
|
|
166
|
-
};
|
|
167
|
-
declare function getDocumentUrl(val: string): {
|
|
168
|
-
id: string;
|
|
169
|
-
url: string;
|
|
170
|
-
filename?: string;
|
|
171
|
-
};
|
|
172
|
-
declare function decodeText(s: string): string;
|
|
173
|
-
declare enum VideoResolution {
|
|
174
|
-
MOBILE = "360p",
|
|
175
|
-
LOW = "480p",
|
|
176
|
-
MID = "720p",
|
|
177
|
-
HIGH = "1080p"
|
|
178
|
-
}
|
|
179
|
-
declare const media: {
|
|
180
|
-
getCroppedImageUrl: typeof getCroppedImageUrl;
|
|
181
|
-
getScaledToFillImageUrl: typeof getScaledToFillImageUrl;
|
|
182
|
-
getScaledToFitImageUrl: typeof getScaledToFitImageUrl;
|
|
183
|
-
getImageUrl: typeof getImageUrl;
|
|
184
|
-
getVideoUrl: typeof getVideoUrl;
|
|
185
|
-
getAudioUrl: typeof getAudioUrl;
|
|
186
|
-
getDocumentUrl: typeof getDocumentUrl;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
interface Tokens {
|
|
190
|
-
accessToken: AccessToken;
|
|
191
|
-
refreshToken: RefreshToken;
|
|
192
|
-
}
|
|
193
|
-
interface Token {
|
|
194
|
-
value: string;
|
|
195
|
-
}
|
|
196
|
-
interface AccessToken extends Token {
|
|
197
|
-
expiresAt: number;
|
|
198
|
-
}
|
|
199
|
-
interface RefreshToken extends Token {
|
|
200
|
-
role: TokenRole;
|
|
201
|
-
}
|
|
202
|
-
interface OauthData extends OauthPKCE {
|
|
203
|
-
originalUri: string;
|
|
204
|
-
redirectUri: string;
|
|
205
|
-
}
|
|
206
|
-
interface OauthPKCE {
|
|
207
|
-
codeVerifier: string;
|
|
208
|
-
codeChallenge: string;
|
|
209
|
-
state: string;
|
|
210
|
-
}
|
|
211
|
-
interface RegisterParams extends LoginParams {
|
|
212
|
-
profile?: authentication.IdentityProfile;
|
|
213
|
-
}
|
|
214
|
-
interface LoginParams {
|
|
215
|
-
email: string;
|
|
216
|
-
password: string;
|
|
217
|
-
captchaTokens?: {
|
|
218
|
-
invisibleRecaptchaToken?: string;
|
|
219
|
-
recaptchaToken?: string;
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
interface IOAuthStrategy extends AuthenticationStrategy {
|
|
223
|
-
generateVisitorTokens(tokens?: {
|
|
224
|
-
refreshToken?: RefreshToken;
|
|
225
|
-
accessToken?: AccessToken;
|
|
226
|
-
}): Promise<Tokens>;
|
|
227
|
-
renewToken: (refreshToken: RefreshToken) => Promise<Tokens>;
|
|
228
|
-
setTokens: (tokens: Tokens) => void;
|
|
229
|
-
getTokens: () => Tokens;
|
|
230
|
-
generateOAuthData: (redirectUri: string, originalUri?: string) => OauthData;
|
|
231
|
-
getAuthUrl: (oauthData: OauthData, opts?: {
|
|
232
|
-
prompt?: 'login' | 'none';
|
|
233
|
-
responseMode?: 'fragment' | 'web_message' | 'query';
|
|
234
|
-
}) => Promise<{
|
|
235
|
-
authUrl: string;
|
|
236
|
-
}>;
|
|
237
|
-
getMemberTokens: (code: string, state: string, oauthData: OauthData) => Promise<Tokens>;
|
|
238
|
-
logout: (originalUrl: string) => Promise<{
|
|
239
|
-
logoutUrl: string;
|
|
240
|
-
}>;
|
|
241
|
-
parseFromUrl: (url?: string, responseMode?: 'query' | 'fragment') => {
|
|
242
|
-
code: string;
|
|
243
|
-
state: string;
|
|
244
|
-
error?: string;
|
|
245
|
-
errorDescription?: string;
|
|
246
|
-
};
|
|
247
|
-
register: (params: RegisterParams) => Promise<StateMachine>;
|
|
248
|
-
login: (params: LoginParams) => Promise<StateMachine>;
|
|
249
|
-
processVerification<T extends ProcessableState>(nextInputs: CalculateNextState<T>, state?: StateMachine): Promise<StateMachine>;
|
|
250
|
-
getMemberTokensForDirectLogin: (sessionToken: string) => Promise<Tokens>;
|
|
251
|
-
sendPasswordResetEmail: (email: string, redirectUri: string) => Promise<void>;
|
|
252
|
-
captchaInvisibleSiteKey: string;
|
|
253
|
-
captchaVisibleSiteKey: string;
|
|
254
|
-
loggedIn: () => boolean;
|
|
255
|
-
}
|
|
256
|
-
declare enum LoginState {
|
|
257
|
-
SUCCESS = "SUCCESS",
|
|
258
|
-
INITIAL = "INITIAL",
|
|
259
|
-
FAILURE = "FAILURE",
|
|
260
|
-
EMAIL_VERIFICATION_REQUIRED = "EMAIL_VERIFICATION_REQUIRED",
|
|
261
|
-
OWNER_APPROVAL_REQUIRED = "OWNER_APPROVAL_REQUIRED",
|
|
262
|
-
USER_CAPTCHA_REQUIRED = "USER_CAPTCHA_REQUIRED",
|
|
263
|
-
SILENT_CAPTCHA_REQUIRED = "SILENT_CAPTCHA_REQUIRED"
|
|
264
|
-
}
|
|
265
|
-
interface LoginResults<LK extends LoginState> {
|
|
266
|
-
loginState: LK;
|
|
267
|
-
}
|
|
268
|
-
interface SuccessState extends LoginResults<LoginState.SUCCESS> {
|
|
269
|
-
data: {
|
|
270
|
-
sessionToken: string;
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
interface InitialState extends LoginResults<LoginState.INITIAL> {
|
|
274
|
-
}
|
|
275
|
-
interface ErrorState extends LoginResults<LoginState.FAILURE> {
|
|
276
|
-
errorCode?: 'invalidEmail' | 'invalidPassword' | 'resetPassword' | 'missingCaptchaToken' | 'emailAlreadyExists' | 'invalidCaptchaToken';
|
|
277
|
-
error: string;
|
|
278
|
-
}
|
|
279
|
-
interface EmailVerificationRequiredState extends LoginResults<LoginState.EMAIL_VERIFICATION_REQUIRED> {
|
|
280
|
-
data: {
|
|
281
|
-
stateToken: string;
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
interface OwnerApprovalRequiredState extends LoginResults<LoginState.OWNER_APPROVAL_REQUIRED> {
|
|
285
|
-
}
|
|
286
|
-
interface SilentCaptchaRequiredState extends LoginResults<LoginState.SILENT_CAPTCHA_REQUIRED> {
|
|
287
|
-
data: {
|
|
288
|
-
stateToken: string;
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
interface UserCaptchaRequiredState extends LoginResults<LoginState.USER_CAPTCHA_REQUIRED> {
|
|
292
|
-
data: {
|
|
293
|
-
stateToken: string;
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
declare enum TokenRole {
|
|
297
|
-
NONE = "none",
|
|
298
|
-
VISITOR = "visitor",
|
|
299
|
-
MEMBER = "member"
|
|
300
|
-
}
|
|
301
|
-
type StateMachine = InitialState | SuccessState | ErrorState | EmailVerificationRequiredState | OwnerApprovalRequiredState | SilentCaptchaRequiredState | UserCaptchaRequiredState;
|
|
302
|
-
type VerificationCode = {
|
|
303
|
-
verificationCode: string;
|
|
304
|
-
};
|
|
305
|
-
type CalculateNextState<T> = T extends EmailVerificationRequiredState ? VerificationCode : never;
|
|
306
|
-
type ProcessableState = EmailVerificationRequiredState;
|
|
307
|
-
|
|
308
|
-
declare function OAuthStrategy(config: {
|
|
309
|
-
clientId: string;
|
|
310
|
-
tokens?: Tokens;
|
|
311
|
-
}): IOAuthStrategy;
|
|
312
|
-
interface TokenResponse {
|
|
313
|
-
access_token: string;
|
|
314
|
-
expires_in: number;
|
|
315
|
-
refresh_token: string | null;
|
|
316
|
-
token_type: string;
|
|
317
|
-
scope?: string | null;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
interface IApiKeyStrategy extends AuthenticationStrategy {
|
|
321
|
-
setSiteId(siteId?: string): void;
|
|
322
|
-
setAccountId(accountId?: string): void;
|
|
323
|
-
}
|
|
324
|
-
type Context = {
|
|
325
|
-
siteId: string;
|
|
326
|
-
accountId?: string;
|
|
327
|
-
} | {
|
|
328
|
-
siteId?: string;
|
|
329
|
-
accountId: string;
|
|
330
|
-
};
|
|
331
|
-
declare function ApiKeyStrategy({ siteId, accountId, apiKey, }: {
|
|
332
|
-
apiKey: string;
|
|
333
|
-
} & Context): IApiKeyStrategy;
|
|
334
|
-
|
|
335
|
-
type WixAppOAuthStrategy = AuthenticationStrategy & {
|
|
336
|
-
getInstallUrl({ redirectUrl }: {
|
|
337
|
-
redirectUrl: string;
|
|
338
|
-
}): string;
|
|
339
|
-
handleOAuthCallback(url: string, opts?: {
|
|
340
|
-
state: string;
|
|
341
|
-
}): Promise<{
|
|
342
|
-
instanceId: string;
|
|
343
|
-
accessToken: string;
|
|
344
|
-
refreshToken: string;
|
|
345
|
-
}>;
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
|
-
* Creates an authentication strategy for Wix Apps OAuth installation process.
|
|
349
|
-
* Use this authentication strategy when making requests to Wix APIs from your Wix App backend.
|
|
350
|
-
* @param opts Options for initializing the authentication strategy
|
|
351
|
-
* @param opts.appId The Wix App ID
|
|
352
|
-
* @param opts.appSecret The Wix App Secret
|
|
353
|
-
* @param opts.refreshToken An optional refresh token previously retrieved from Wix OAuth API
|
|
354
|
-
* @returns An authentication strategy that can be used with WixClient
|
|
355
|
-
* @example
|
|
356
|
-
* ```ts
|
|
357
|
-
* import { WixAppOAuthStrategy, createClient } from '@wix/sdk';
|
|
358
|
-
* import { products } from '@wix/stores';
|
|
359
|
-
*
|
|
360
|
-
* const client = createClient({
|
|
361
|
-
* auth: WixAppOAuthStrategy({
|
|
362
|
-
* appId: 'appId',
|
|
363
|
-
* appSecret: 'appSecret',
|
|
364
|
-
* }),
|
|
365
|
-
* modules: { products },
|
|
366
|
-
* });
|
|
367
|
-
*
|
|
368
|
-
* const installUrl = client.auth.getInstallUrl({ redirectUrl: 'https://example.com' });
|
|
369
|
-
* // Redirect the user to the installUrl
|
|
370
|
-
*
|
|
371
|
-
* ...
|
|
372
|
-
*
|
|
373
|
-
* // in the callback handler of your http server
|
|
374
|
-
* // req.url is the url of the callback request
|
|
375
|
-
* const { instanceId, refreshToken } = await client.auth.handleOAuthCallback(req.url);
|
|
376
|
-
*
|
|
377
|
-
* // store the instanceId and refreshToken in your database
|
|
378
|
-
* // use the authorized client
|
|
379
|
-
* const products = await client.products.queryProducts().find();
|
|
380
|
-
*
|
|
381
|
-
* ```
|
|
382
|
-
*/
|
|
383
|
-
declare function WixAppOAuthStrategy(opts: {
|
|
384
|
-
appId: string;
|
|
385
|
-
appSecret: string;
|
|
386
|
-
refreshToken?: string;
|
|
387
|
-
}): WixAppOAuthStrategy;
|
|
388
|
-
|
|
389
|
-
export { API_URL, type AccessToken, ApiKeyStrategy, type AssertHostMatches, type BuildDescriptors, type CalculateNextState, type Descriptors, type IApiKeyStrategy, type IOAuthStrategy, type LoginParams, LoginState, OAuthStrategy, type OauthData, type OauthPKCE, type ProcessableState, type RefreshToken, type RegisterParams, type StateMachine, type Token, type TokenResponse, TokenRole, type Tokens, VideoResolution, WixAppOAuthStrategy, type WixClient, createClient, decodeText, getDefaultDomain, media };
|