@wix/astro 1.0.1 → 1.0.2

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.
@@ -1,3557 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
- // ../../node_modules/@wix/sdk-context/build/index.mjs
8
- var wixContext = {};
9
-
10
- // ../../node_modules/@wix/sdk-types/build/index.mjs
11
- function EventDefinition(type, isDomainEvent = false, transformations = (x) => x) {
12
- return () => ({
13
- __type: "event-definition",
14
- type,
15
- isDomainEvent,
16
- transformations
17
- });
18
- }
19
- var SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
20
-
21
- // ../../node_modules/@wix/sdk/build/ambassador-modules.js
22
- var parseMethod = (method) => {
23
- switch (method) {
24
- case "get":
25
- case "GET":
26
- return "GET";
27
- case "post":
28
- case "POST":
29
- return "POST";
30
- case "put":
31
- case "PUT":
32
- return "PUT";
33
- case "delete":
34
- case "DELETE":
35
- return "DELETE";
36
- case "patch":
37
- case "PATCH":
38
- return "PATCH";
39
- case "head":
40
- case "HEAD":
41
- return "HEAD";
42
- case "options":
43
- case "OPTIONS":
44
- return "OPTIONS";
45
- default:
46
- throw new Error(`Unknown method: ${method}`);
47
- }
48
- };
49
- var toHTTPModule = (factory) => (httpClient) => async (payload) => {
50
- let requestOptions;
51
- const HTTPFactory = (context) => {
52
- requestOptions = factory(payload)(context);
53
- if (requestOptions.url === void 0) {
54
- throw new Error("Url was not successfully created for this request, please reach out to support channels for assistance.");
55
- }
56
- const { method, url, params } = requestOptions;
57
- return {
58
- ...requestOptions,
59
- method: parseMethod(method),
60
- url,
61
- data: requestOptions.data,
62
- params
63
- };
64
- };
65
- try {
66
- const response = await httpClient.request(HTTPFactory);
67
- if (requestOptions === void 0) {
68
- throw new Error("Request options were not created for this request, please reach out to support channels for assistance.");
69
- }
70
- const transformations = Array.isArray(requestOptions.transformResponse) ? requestOptions.transformResponse : [requestOptions.transformResponse];
71
- let data = response.data;
72
- transformations.forEach((transform) => {
73
- if (transform) {
74
- data = transform(response.data, response.headers);
75
- }
76
- });
77
- return data;
78
- } catch (e) {
79
- if (typeof e === "object" && e !== null && "response" in e && typeof e.response === "object" && e.response !== null && "data" in e.response) {
80
- throw e.response.data;
81
- }
82
- throw e;
83
- }
84
- };
85
- var isAmbassadorModule = (module) => {
86
- if (module.__isAmbassador) {
87
- return true;
88
- }
89
- const fn = module();
90
- return Boolean(fn.__isAmbassador);
91
- };
92
-
93
- // ../../node_modules/@wix/sdk/build/common.js
94
- var PUBLIC_METADATA_KEY = "__metadata";
95
- var DEFAULT_API_URL = "www.wixapis.com";
96
-
97
- // ../../node_modules/@wix/sdk/build/fetch-error.js
98
- var FetchErrorResponse = class extends Error {
99
- message;
100
- response;
101
- constructor(message, response) {
102
- super(message);
103
- this.message = message;
104
- this.response = response;
105
- }
106
- async details() {
107
- const dataError = await this.response.json();
108
- return errorBuilder(this.response.status, dataError?.message, dataError?.details, {
109
- requestId: this.response.headers.get("X-Wix-Request-Id"),
110
- details: dataError
111
- });
112
- }
113
- };
114
- var errorBuilder = (code, description, details, data) => {
115
- return {
116
- details: {
117
- ...!details?.validationError && {
118
- applicationError: {
119
- description,
120
- code,
121
- data
122
- }
123
- },
124
- ...details
125
- },
126
- message: description,
127
- requestId: data?.requestId
128
- };
129
- };
130
-
131
- // ../../node_modules/@wix/sdk/build/helpers.js
132
- var getDefaultContentHeader = (options) => {
133
- if (options?.method && ["post", "put", "patch"].includes(options.method.toLocaleLowerCase()) && options.body) {
134
- return { "Content-Type": "application/json" };
135
- }
136
- return {};
137
- };
138
- var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
139
-
140
- // ../../node_modules/@wix/sdk/build/host-modules.js
141
- var isHostModule = (val) => val.__type === "host";
142
- function buildHostModule(val, host) {
143
- return val.create(host);
144
- }
145
-
146
- // ../../node_modules/@wix/sdk/build/bi/biHeaderGenerator.js
147
- var WixBIHeaderName = "x-wix-bi-gateway";
148
- function biHeaderGenerator(apiMetadata, publicMetadata, environment) {
149
- return {
150
- [WixBIHeaderName]: objectToKeyValue({
151
- environment: `js-sdk${environment ? `-${environment}` : ``}`,
152
- "package-name": apiMetadata.packageName ?? publicMetadata?.PACKAGE_NAME,
153
- "method-fqn": apiMetadata.methodFqn,
154
- entity: apiMetadata.entityFqdn
155
- })
156
- };
157
- }
158
- function objectToKeyValue(input) {
159
- return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key, value]) => `${key}=${value}`).join(",");
160
- }
161
-
162
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js
163
- function runWithoutContext(fn) {
164
- const globalContext = globalThis.__wix_context__;
165
- const moduleContext = {
166
- client: wixContext.client,
167
- elevatedClient: wixContext.elevatedClient
168
- };
169
- let closureContext;
170
- globalThis.__wix_context__ = void 0;
171
- wixContext.client = void 0;
172
- wixContext.elevatedClient = void 0;
173
- if (typeof $wixContext !== "undefined") {
174
- closureContext = {
175
- client: $wixContext?.client,
176
- elevatedClient: $wixContext?.elevatedClient
177
- };
178
- delete $wixContext.client;
179
- delete $wixContext.elevatedClient;
180
- }
181
- try {
182
- return fn();
183
- } finally {
184
- globalThis.__wix_context__ = globalContext;
185
- wixContext.client = moduleContext.client;
186
- wixContext.elevatedClient = moduleContext.elevatedClient;
187
- if (typeof $wixContext !== "undefined") {
188
- $wixContext.client = closureContext.client;
189
- $wixContext.elevatedClient = closureContext.elevatedClient;
190
- }
191
- }
192
- }
193
-
194
- // ../../node_modules/@wix/sdk/build/rest-modules.js
195
- function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName) {
196
- return runWithoutContext(() => origFunc({
197
- request: async (factory) => {
198
- const requestOptions = factory({
199
- host: options?.HTTPHost || DEFAULT_API_URL
200
- });
201
- let request = requestOptions;
202
- if (request.method === "GET" && request.fallback?.length && request.params.toString().length > 4e3) {
203
- request = requestOptions.fallback[0];
204
- }
205
- const domain = options?.HTTPHost ?? DEFAULT_API_URL;
206
- let url = `https://${domain}${request.url}`;
207
- if (request.params && request.params.toString()) {
208
- url += `?${request.params.toString()}`;
209
- }
210
- try {
211
- const biHeader = biHeaderGenerator(requestOptions, publicMetadata, hostName);
212
- const res = await boundFetch(url, {
213
- method: request.method,
214
- ...request.data && {
215
- body: JSON.stringify(request.data)
216
- },
217
- headers: {
218
- ...biHeader
219
- }
220
- });
221
- if (res.status !== 200) {
222
- let dataError = null;
223
- try {
224
- dataError = await res.json();
225
- } catch (e) {
226
- }
227
- throw errorBuilder2(res.status, dataError?.message, dataError?.details, {
228
- requestId: res.headers.get("X-Wix-Request-Id"),
229
- details: dataError
230
- });
231
- }
232
- const data = await res.json();
233
- return {
234
- data,
235
- headers: res.headers,
236
- status: res.status,
237
- statusText: res.statusText
238
- };
239
- } catch (e) {
240
- if (e.message?.includes("fetch is not defined")) {
241
- console.error("Node.js v18+ is required");
242
- }
243
- throw e;
244
- }
245
- },
246
- fetchWithAuth: boundFetch,
247
- wixAPIFetch,
248
- getActiveToken
249
- }));
250
- }
251
- var errorBuilder2 = (code, description, details, data) => {
252
- return {
253
- response: {
254
- data: {
255
- details: {
256
- ...!details?.validationError && {
257
- applicationError: {
258
- description,
259
- code,
260
- data
261
- }
262
- },
263
- ...details
264
- },
265
- message: description
266
- },
267
- status: code
268
- },
269
- responseId: data?.requestId
270
- };
271
- };
272
-
273
- // ../../node_modules/@wix/sdk/build/nanoevents.js
274
- function createNanoEvents() {
275
- return {
276
- emit(event, ...args) {
277
- for (let i = 0, callbacks = this.events[event] || [], length = callbacks.length; i < length; i++) {
278
- callbacks[i](...args);
279
- }
280
- },
281
- events: {},
282
- on(event, cb) {
283
- (this.events[event] ||= []).push(cb);
284
- return () => {
285
- this.events[event] = this.events[event]?.filter((i) => cb !== i);
286
- };
287
- }
288
- };
289
- }
290
-
291
- // ../../node_modules/@wix/sdk/build/event-handlers-modules.js
292
- var isEventHandlerModule = (val) => val.__type === "event-definition";
293
- function runHandler(eventDefinition, handler, payload, baseEventMetadata) {
294
- let envelope;
295
- if (eventDefinition.isDomainEvent) {
296
- const domainEventPayload = payload;
297
- const { deletedEvent, actionEvent, createdEvent, updatedEvent, ...domainEventMetadata } = domainEventPayload;
298
- const metadata = {
299
- ...baseEventMetadata,
300
- ...domainEventMetadata
301
- };
302
- if (deletedEvent) {
303
- if (deletedEvent?.deletedEntity) {
304
- envelope = {
305
- entity: deletedEvent?.deletedEntity,
306
- metadata
307
- };
308
- } else {
309
- envelope = { metadata };
310
- }
311
- } else if (actionEvent) {
312
- envelope = {
313
- data: actionEvent.body,
314
- metadata
315
- };
316
- } else {
317
- envelope = {
318
- entity: createdEvent?.entity ?? updatedEvent?.currentEntity,
319
- metadata
320
- };
321
- }
322
- } else {
323
- envelope = {
324
- data: payload,
325
- metadata: baseEventMetadata
326
- };
327
- }
328
- const transformFromRESTFn = eventDefinition.transformations ?? ((x) => x);
329
- return handler(transformFromRESTFn(envelope));
330
- }
331
- function eventHandlersModules(authStrategy) {
332
- const eventHandlers = /* @__PURE__ */ new Map();
333
- const webhooksEmitter = createNanoEvents();
334
- const client = {
335
- ...webhooksEmitter,
336
- getRegisteredEvents: () => eventHandlers,
337
- async process(jwt, opts = {
338
- expectedEvents: []
339
- }) {
340
- const { eventType, identity, instanceId, payload } = await this.parseJWT(jwt);
341
- const allExpectedEvents = [
342
- ...opts.expectedEvents,
343
- ...Array.from(eventHandlers.keys()).map((type) => ({ type }))
344
- ];
345
- if (allExpectedEvents.length > 0 && !allExpectedEvents.some(({ type }) => type === eventType)) {
346
- throw new Error(`Unexpected event type: ${eventType}. Expected one of: ${allExpectedEvents.map((x) => x.type).join(", ")}`);
347
- }
348
- const handlers = eventHandlers.get(eventType) ?? [];
349
- await Promise.all(handlers.map(({ eventDefinition, handler }) => runHandler(eventDefinition, handler, payload, {
350
- instanceId,
351
- identity
352
- })));
353
- return {
354
- instanceId,
355
- eventType,
356
- payload,
357
- identity
358
- };
359
- },
360
- async processRequest(request, opts) {
361
- const body = await request.text();
362
- return this.process(body, opts);
363
- },
364
- async parseJWT(jwt) {
365
- if (!authStrategy.decodeJWT) {
366
- throw new Error("decodeJWT is not supported by the authentication strategy");
367
- }
368
- const { decoded, valid } = await authStrategy.decodeJWT(jwt);
369
- if (!valid) {
370
- throw new Error("JWT is not valid");
371
- }
372
- if (typeof decoded.data !== "string") {
373
- throw new Error(`Unexpected type of JWT data: expected string, got ${typeof decoded.data}`);
374
- }
375
- const parsedDecoded = JSON.parse(decoded.data);
376
- const eventType = parsedDecoded.eventType;
377
- const instanceId = parsedDecoded.instanceId;
378
- const identity = parsedDecoded.identity ? JSON.parse(parsedDecoded.identity) : void 0;
379
- const payload = JSON.parse(parsedDecoded.data);
380
- return {
381
- instanceId,
382
- eventType,
383
- payload,
384
- identity
385
- };
386
- },
387
- async parseRequest(request) {
388
- const jwt = await request.text();
389
- return this.parseJWT(jwt);
390
- },
391
- async executeHandlers(event) {
392
- const allExpectedEvents = Array.from(eventHandlers.keys()).map((type) => ({ type }));
393
- if (allExpectedEvents.length > 0 && !allExpectedEvents.some(({ type }) => type === event.eventType)) {
394
- throw new Error(`Unexpected event type: ${event.eventType}. Expected one of: ${allExpectedEvents.map((x) => x.type).join(", ")}`);
395
- }
396
- const handlers = eventHandlers.get(event.eventType) ?? [];
397
- await Promise.all(handlers.map(({ eventDefinition, handler }) => runHandler(eventDefinition, handler, event.payload, {
398
- instanceId: event.instanceId,
399
- identity: event.identity
400
- })));
401
- },
402
- apps: {
403
- AppInstalled: EventDefinition("AppInstalled")(),
404
- AppRemoved: EventDefinition("AppRemoved")()
405
- }
406
- };
407
- return {
408
- initModule(eventDefinition) {
409
- return (handler) => {
410
- const handlers = eventHandlers.get(eventDefinition.type) ?? [];
411
- handlers.push({ eventDefinition, handler });
412
- eventHandlers.set(eventDefinition.type, handlers);
413
- webhooksEmitter.emit("registered", eventDefinition);
414
- };
415
- },
416
- client
417
- };
418
- }
419
-
420
- // ../../node_modules/@wix/sdk/build/service-plugin-modules.js
421
- var isServicePluginModule = (val) => val.__type === "service-plugin-definition";
422
- function servicePluginsModules(authStrategy) {
423
- const servicePluginsImplementations = /* @__PURE__ */ new Map();
424
- const servicePluginsEmitter = createNanoEvents();
425
- const client = {
426
- ...servicePluginsEmitter,
427
- getRegisteredServicePlugins: () => servicePluginsImplementations,
428
- async parseJWT(jwt) {
429
- if (!authStrategy.decodeJWT) {
430
- throw new Error("decodeJWT is not supported by the authentication strategy");
431
- }
432
- const { decoded, valid } = await authStrategy.decodeJWT(jwt, true);
433
- if (!valid) {
434
- throw new Error("JWT is not valid");
435
- }
436
- if (typeof decoded.data !== "object" || decoded.data === null || !("metadata" in decoded.data) || typeof decoded.data.metadata !== "object" || decoded.data.metadata === null || !("appExtensionType" in decoded.data.metadata) || typeof decoded.data.metadata.appExtensionType !== "string") {
437
- throw new Error("Unexpected JWT data: expected object with metadata.appExtensionType string");
438
- }
439
- return decoded.data;
440
- },
441
- async process(request) {
442
- const servicePluginRequest = await this.parseJWT(request.body);
443
- return this.executeHandler(servicePluginRequest, request.url);
444
- },
445
- async parseRequest(request) {
446
- const body = await request.text();
447
- return this.parseJWT(body);
448
- },
449
- async processRequest(request) {
450
- const url = request.url;
451
- const body = await request.text();
452
- try {
453
- const implMethodResult = await this.process({ url, body });
454
- return Response.json(implMethodResult);
455
- } catch (err) {
456
- if (err.errorType === "SPI" && err.applicationCode && err.httpCode) {
457
- return Response.json({ applicationError: { code: err.applicationCode, data: err.data } }, { status: err.httpCode });
458
- }
459
- throw err;
460
- }
461
- },
462
- async executeHandler(servicePluginRequest, url) {
463
- const componentType = servicePluginRequest.metadata.appExtensionType.toLowerCase();
464
- const implementations = servicePluginsImplementations.get(componentType) ?? [];
465
- if (implementations.length === 0) {
466
- throw new Error(`No service plugin implementations found for component type ${componentType}`);
467
- } else if (implementations.length > 1) {
468
- throw new Error(`Multiple service plugin implementations found for component type ${componentType}. This is currently not supported`);
469
- }
470
- const { implementation: impl, servicePluginDefinition } = implementations[0];
471
- const method = servicePluginDefinition.methods.find((m) => url.endsWith(m.primaryHttpMappingPath));
472
- if (!method) {
473
- throw new Error("Unexpect request: request url did not match any method: " + url);
474
- }
475
- const implMethod = impl[method.name];
476
- if (!implMethod) {
477
- throw new Error(`Got request for service plugin method ${method.name} but no implementation was provided. Available methods: ${Object.keys(impl).join(", ")}`);
478
- }
479
- return method.transformations.toREST(await implMethod(method.transformations.fromREST(servicePluginRequest)));
480
- }
481
- };
482
- return {
483
- initModule(servicePluginDefinition) {
484
- return (implementation) => {
485
- const implementations = servicePluginsImplementations.get(servicePluginDefinition.componentType.toLowerCase()) ?? [];
486
- implementations.push({ servicePluginDefinition, implementation });
487
- servicePluginsImplementations.set(servicePluginDefinition.componentType.toLowerCase(), implementations);
488
- servicePluginsEmitter.emit("registered", servicePluginDefinition);
489
- };
490
- },
491
- client
492
- };
493
- }
494
-
495
- // ../../node_modules/@wix/sdk/build/wixClient.js
496
- var X_WIX_CONSISTENT_HEADER = "X-Wix-Consistent";
497
- function createClient(config) {
498
- const _headers = config.headers || { Authorization: "" };
499
- const authStrategy = config.auth || {
500
- getAuthHeaders: (_) => Promise.resolve({ headers: {} })
501
- };
502
- const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(void 0, config.host);
503
- authStrategy.getAuthHeaders = boundGetAuthHeaders;
504
- const fetchWithAuth = async (urlOrRequest, requestInit) => {
505
- const authHeaders = await boundGetAuthHeaders();
506
- const headers = {
507
- ...requestInit?.headers ?? {},
508
- ...authHeaders.headers,
509
- ..._headers[X_WIX_CONSISTENT_HEADER] ? { [X_WIX_CONSISTENT_HEADER]: _headers[X_WIX_CONSISTENT_HEADER] } : {}
510
- };
511
- if (typeof urlOrRequest === "string" || urlOrRequest instanceof URL) {
512
- const response = await fetch(urlOrRequest, {
513
- ...requestInit,
514
- headers
515
- });
516
- const consistentHeader = findConsistentHeader(response);
517
- if (consistentHeader) {
518
- _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;
519
- }
520
- return response;
521
- } else {
522
- for (const [k, v] of Object.entries(headers)) {
523
- if (typeof v === "string") {
524
- urlOrRequest.headers.set(k, v);
525
- }
526
- }
527
- const response = await fetch(urlOrRequest, requestInit);
528
- const consistentHeader = findConsistentHeader(response);
529
- if (consistentHeader) {
530
- _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;
531
- }
532
- return response;
533
- }
534
- };
535
- const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(authStrategy);
536
- const { client: eventHandlersClient, initModule: initEventHandlerModule } = eventHandlersModules(authStrategy);
537
- const boundFetch = async (url, options) => {
538
- const authHeaders = await boundGetAuthHeaders();
539
- const defaultContentTypeHeader = getDefaultContentHeader(options);
540
- const response = await fetch(url, {
541
- ...options,
542
- headers: {
543
- ...defaultContentTypeHeader,
544
- ..._headers,
545
- ...authHeaders?.headers,
546
- ...options?.headers,
547
- ...config.host?.essentials?.passThroughHeaders
548
- }
549
- });
550
- const consistentHeader = findConsistentHeader(response);
551
- if (consistentHeader) {
552
- _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;
553
- }
554
- return response;
555
- };
556
- const use = (modules, metadata) => {
557
- if (isEventHandlerModule(modules)) {
558
- return initEventHandlerModule(modules);
559
- } else if (isServicePluginModule(modules)) {
560
- return initServicePluginModule(modules);
561
- } else if (isHostModule(modules) && config.host) {
562
- return buildHostModule(modules, config.host);
563
- } else if (typeof modules === "function") {
564
- if ("__type" in modules && modules.__type === SERVICE_PLUGIN_ERROR_TYPE) {
565
- return modules;
566
- }
567
- const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
568
- return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, (relativeUrl, fetchOptions) => {
569
- const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
570
- finalUrl.host = apiBaseUrl;
571
- finalUrl.protocol = "https";
572
- return boundFetch(finalUrl.toString(), fetchOptions);
573
- }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name);
574
- } else if (isObject(modules)) {
575
- return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
576
- return [key, use(value, modules[PUBLIC_METADATA_KEY])];
577
- }));
578
- } else {
579
- return modules;
580
- }
581
- };
582
- const setHeaders = (headers) => {
583
- for (const k in headers) {
584
- _headers[k] = headers[k];
585
- }
586
- };
587
- const wrappedModules = config.modules ? use(config.modules) : {};
588
- return {
589
- ...wrappedModules,
590
- auth: authStrategy,
591
- setHeaders,
592
- use,
593
- enableContext(contextType, opts = { elevated: false }) {
594
- if (contextType === "global") {
595
- if (globalThis.__wix_context__ != null) {
596
- if (opts.elevated) {
597
- globalThis.__wix_context__.elevatedClient = this;
598
- } else {
599
- globalThis.__wix_context__.client = this;
600
- }
601
- } else {
602
- if (opts.elevated) {
603
- globalThis.__wix_context__ = { elevatedClient: this };
604
- } else {
605
- globalThis.__wix_context__ = { client: this };
606
- }
607
- }
608
- } else {
609
- if (opts.elevated) {
610
- wixContext.elevatedClient = this;
611
- } else {
612
- wixContext.client = this;
613
- }
614
- }
615
- },
616
- /**
617
- * @param relativeUrl The URL to fetch relative to the API base URL
618
- * @param options The fetch options
619
- * @returns The fetch Response object
620
- * @deprecated Use `fetchWithAuth` instead
621
- */
622
- fetch: (relativeUrl, options) => {
623
- const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
624
- const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
625
- finalUrl.host = apiBaseUrl;
626
- finalUrl.protocol = "https";
627
- return boundFetch(finalUrl.toString(), options);
628
- },
629
- fetchWithAuth,
630
- async graphql(query, variables, opts = {
631
- apiVersion: "alpha"
632
- }) {
633
- const apiBaseUrl = config?.host?.apiBaseUrl ?? DEFAULT_API_URL;
634
- const res = await boundFetch(`https://${apiBaseUrl}/graphql/${opts.apiVersion}`, {
635
- method: "POST",
636
- headers: {
637
- "Content-Type": "application/json"
638
- },
639
- body: JSON.stringify({ query, variables })
640
- });
641
- if (res.status !== 200) {
642
- throw new FetchErrorResponse(`GraphQL request failed with status ${res.status}`, res);
643
- }
644
- const { data, errors } = await res.json();
645
- return { data: data ?? {}, errors };
646
- },
647
- webhooks: eventHandlersClient,
648
- servicePlugins: servicePluginsClient
649
- };
650
- }
651
- function findConsistentHeader(response) {
652
- return response.headers?.get(X_WIX_CONSISTENT_HEADER) ?? response.headers?.get(X_WIX_CONSISTENT_HEADER.toLowerCase());
653
- }
654
-
655
- // ../../node_modules/@wix/auto_sdk_redirects_redirects/build/es/index.js
656
- var es_exports = {};
657
- __export(es_exports, {
658
- AttachPagesResponseStatus: () => AttachPagesResponseStatus,
659
- CallbackType: () => CallbackType,
660
- LocationType: () => LocationType,
661
- MembersAccountSection: () => MembersAccountSection,
662
- Prompt: () => Prompt,
663
- Status: () => Status,
664
- WebhookIdentityType: () => WebhookIdentityType,
665
- createRedirectSession: () => createRedirectSession4,
666
- onRedirectSessionCreated: () => onRedirectSessionCreated2
667
- });
668
-
669
- // ../../node_modules/@wix/sdk-runtime/build/constants.js
670
- var SDKRequestToRESTRequestRenameMap = {
671
- _id: "id",
672
- _createdDate: "createdDate",
673
- _updatedDate: "updatedDate"
674
- };
675
- var RESTResponseToSDKResponseRenameMap = {
676
- id: "_id",
677
- createdDate: "_createdDate",
678
- updatedDate: "_updatedDate"
679
- };
680
-
681
- // ../../node_modules/@wix/sdk-runtime/build/rename-all-nested-keys.js
682
- function renameAllNestedKeys(payload, renameMap, ignorePaths) {
683
- const isIgnored = (path) => ignorePaths.includes(path);
684
- const traverse = (obj, path) => {
685
- if (Array.isArray(obj)) {
686
- obj.forEach((item) => {
687
- traverse(item, path);
688
- });
689
- } else if (typeof obj === "object" && obj !== null) {
690
- const objAsRecord = obj;
691
- Object.keys(objAsRecord).forEach((key) => {
692
- const newPath = path === "" ? key : `${path}.${key}`;
693
- if (isIgnored(newPath)) {
694
- return;
695
- }
696
- if (key in renameMap && !(renameMap[key] in objAsRecord)) {
697
- objAsRecord[renameMap[key]] = objAsRecord[key];
698
- delete objAsRecord[key];
699
- }
700
- traverse(objAsRecord[key], newPath);
701
- });
702
- }
703
- };
704
- traverse(payload, "");
705
- return payload;
706
- }
707
- function renameKeysFromSDKRequestToRESTRequest(payload, ignorePaths = []) {
708
- return renameAllNestedKeys(payload, SDKRequestToRESTRequestRenameMap, ignorePaths);
709
- }
710
- function renameKeysFromRESTResponseToSDKResponse(payload, ignorePaths = []) {
711
- return renameAllNestedKeys(payload, RESTResponseToSDKResponseRenameMap, ignorePaths);
712
- }
713
-
714
- // ../../node_modules/@wix/sdk-runtime/build/transformations/timestamp.js
715
- function transformSDKTimestampToRESTTimestamp(val) {
716
- return val?.toISOString();
717
- }
718
- function transformRESTTimestampToSDKTimestamp(val) {
719
- return val ? new Date(val) : void 0;
720
- }
721
-
722
- // ../../node_modules/@wix/sdk-runtime/build/transformations/transform-paths.js
723
- function transformPath(obj, { path, isRepeated, isMap }, transformFn) {
724
- const pathParts = path.split(".");
725
- if (pathParts.length === 1 && path in obj) {
726
- obj[path] = isRepeated ? obj[path].map(transformFn) : isMap ? Object.fromEntries(Object.entries(obj[path]).map(([key, value]) => [key, transformFn(value)])) : transformFn(obj[path]);
727
- return obj;
728
- }
729
- const [first, ...rest] = pathParts;
730
- if (first.endsWith("{}")) {
731
- const cleanPath = first.slice(0, -2);
732
- obj[cleanPath] = Object.fromEntries(Object.entries(obj[cleanPath]).map(([key, value]) => [
733
- key,
734
- transformPath(value, { path: rest.join("."), isRepeated, isMap }, transformFn)
735
- ]));
736
- } else if (Array.isArray(obj[first])) {
737
- obj[first] = obj[first].map((item) => transformPath(item, { path: rest.join("."), isRepeated, isMap }, transformFn));
738
- } else if (first in obj && typeof obj[first] === "object" && obj[first] !== null) {
739
- obj[first] = transformPath(obj[first], { path: rest.join("."), isRepeated, isMap }, transformFn);
740
- } else if (first === "*") {
741
- Object.keys(obj).reduce((acc, curr) => {
742
- acc[curr] = transformPath(obj[curr], { path: rest.join("."), isRepeated, isMap }, transformFn);
743
- return acc;
744
- }, obj);
745
- }
746
- return obj;
747
- }
748
- function transformPaths(obj, transformations) {
749
- return transformations.reduce((acc, { paths, transformFn }) => paths.reduce((transformerAcc, path) => transformPath(transformerAcc, path, transformFn), acc), obj);
750
- }
751
-
752
- // ../../node_modules/@wix/sdk-runtime/build/utils.js
753
- function removeUndefinedKeys(obj) {
754
- return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
755
- }
756
- function constantCase(input) {
757
- return split(input).map((part) => part.toLocaleUpperCase()).join("_");
758
- }
759
- var SPLIT_LOWER_UPPER_RE = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
760
- var SPLIT_UPPER_UPPER_RE = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
761
- var SPLIT_REPLACE_VALUE = "$1\0$2";
762
- var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
763
- function split(value) {
764
- let result = value.trim();
765
- result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
766
- result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
767
- let start5 = 0;
768
- let end = result.length;
769
- while (result.charAt(start5) === "\0") {
770
- start5++;
771
- }
772
- if (start5 === end) {
773
- return [];
774
- }
775
- while (result.charAt(end - 1) === "\0") {
776
- end--;
777
- }
778
- return result.slice(start5, end).split(/\0/g);
779
- }
780
-
781
- // ../../node_modules/@wix/sdk-runtime/build/transform-error.js
782
- var isValidationError = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
783
- var isApplicationError = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
784
- var isClientError = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
785
- function transformError(httpClientError, pathsToArguments = {
786
- explicitPathsToArguments: {},
787
- spreadPathsToArguments: {},
788
- singleArgumentUnchanged: false
789
- }, argumentNames = []) {
790
- if (typeof httpClientError !== "object" || httpClientError === null) {
791
- throw httpClientError;
792
- }
793
- if (isValidationError(httpClientError)) {
794
- return buildValidationError(httpClientError.response.data, pathsToArguments, argumentNames, httpClientError.requestId);
795
- }
796
- if (isApplicationError(httpClientError)) {
797
- return buildApplicationError(httpClientError);
798
- }
799
- if (isClientError(httpClientError)) {
800
- const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
801
- const message = httpClientError.response?.data?.message ?? statusText;
802
- const details = {
803
- applicationError: {
804
- description: statusText,
805
- code: constantCase(statusText),
806
- data: {}
807
- },
808
- requestId: httpClientError.requestId
809
- };
810
- return buildError({
811
- message: JSON.stringify({
812
- message,
813
- details
814
- }, null, 2),
815
- extraProperties: { details }
816
- });
817
- }
818
- return buildSystemError(httpClientError);
819
- }
820
- var buildValidationError = (validationErrorResponse, pathsToArguments, argumentNames, requestId) => {
821
- const { fieldViolations } = validationErrorResponse.details.validationError;
822
- const transformedFieldViolations = violationsWithRenamedFields(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => a.field < b.field ? -1 : 1);
823
- const message = `INVALID_ARGUMENT: ${transformedFieldViolations?.map(({ field, description }) => `"${field}" ${description}`)?.join(", ")}`;
824
- const details = {
825
- validationError: { fieldViolations: transformedFieldViolations },
826
- requestId
827
- };
828
- return buildError({
829
- message: JSON.stringify({ message, details }, null, 2),
830
- extraProperties: { details }
831
- });
832
- };
833
- var buildError = ({ message, extraProperties = {} }) => {
834
- const error = new Error(message);
835
- for (const [key, value] of Object.entries(extraProperties)) {
836
- if (value !== void 0) {
837
- error[key] = value;
838
- }
839
- }
840
- return error;
841
- };
842
- var buildApplicationError = (httpClientError) => {
843
- const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
844
- const message = httpClientError.response?.data?.message ?? statusText;
845
- const description = httpClientError.response?.data?.details?.applicationError?.description ?? statusText;
846
- const code = httpClientError.response?.data?.details?.applicationError?.code ?? constantCase(statusText);
847
- const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};
848
- const combinedMessage = message === description ? message : `${message}: ${description}`;
849
- const details = {
850
- applicationError: {
851
- description,
852
- code,
853
- data
854
- },
855
- requestId: httpClientError.requestId
856
- };
857
- return buildError({
858
- message: JSON.stringify({ message: combinedMessage, details }, null, 2),
859
- extraProperties: { details }
860
- });
861
- };
862
- var buildSystemError = (httpClientError) => {
863
- const message = httpClientError.requestId ? `System error occurred, request-id: ${httpClientError.requestId}` : `System error occurred: ${JSON.stringify(httpClientError)}`;
864
- return buildError({
865
- message,
866
- extraProperties: {
867
- requestId: httpClientError.requestId,
868
- code: constantCase(httpClientError.response?.statusText ?? "UNKNOWN"),
869
- ...!httpClientError.response && {
870
- runtimeError: httpClientError
871
- }
872
- }
873
- });
874
- };
875
- var violationsWithRenamedFields = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged }, fieldViolations, argumentNames) => {
876
- const allPathsToArguments = {
877
- ...spreadPathsToArguments,
878
- ...explicitPathsToArguments
879
- };
880
- const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);
881
- return fieldViolations?.filter((fieldViolation) => {
882
- const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length && anotherViolation.field.startsWith(fieldViolation.field) && allPathsToArgumentsKeys.includes(anotherViolation.field));
883
- return !containedInAMoreSpecificViolationField;
884
- }).map((fieldViolation) => {
885
- const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];
886
- if (exactMatchArgumentExpression) {
887
- return {
888
- ...fieldViolation,
889
- field: withRenamedArgument(exactMatchArgumentExpression, argumentNames)
890
- };
891
- }
892
- const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path) => fieldViolation.field.startsWith(path));
893
- if (longestPartialPathMatch) {
894
- const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
895
- if (partialMatchArgumentExpression) {
896
- return {
897
- ...fieldViolation,
898
- field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument(partialMatchArgumentExpression, argumentNames))
899
- };
900
- }
901
- }
902
- if (singleArgumentUnchanged) {
903
- return {
904
- ...fieldViolation,
905
- field: `${argumentNames[0]}.${fieldViolation.field}`
906
- };
907
- }
908
- return fieldViolation;
909
- });
910
- };
911
- var withRenamedArgument = (fieldValue, argumentNames) => {
912
- const argIndex = getArgumentIndex(fieldValue);
913
- if (argIndex !== null && typeof argIndex !== "undefined") {
914
- return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);
915
- }
916
- return fieldValue;
917
- };
918
- var getArgumentIndex = (s) => {
919
- const match = s.match(/\$\[(?<argIndex>\d+)\]/);
920
- return match && match.groups && Number(match.groups.argIndex);
921
- };
922
-
923
- // ../../node_modules/@wix/sdk-runtime/build/context.js
924
- function resolveContext() {
925
- const oldContext = typeof $wixContext !== "undefined" && $wixContext.initWixModules ? $wixContext.initWixModules : typeof globalThis.__wix_context__ !== "undefined" && globalThis.__wix_context__.initWixModules ? globalThis.__wix_context__.initWixModules : void 0;
926
- if (oldContext) {
927
- return {
928
- // @ts-expect-error
929
- initWixModules(modules, elevated) {
930
- return runWithoutContext2(() => oldContext(modules, elevated));
931
- },
932
- fetchWithAuth() {
933
- throw new Error("fetchWithAuth is not available in this context");
934
- },
935
- graphql() {
936
- throw new Error("graphql is not available in this context");
937
- }
938
- };
939
- }
940
- const contextualClient = typeof $wixContext !== "undefined" ? $wixContext.client : typeof wixContext.client !== "undefined" ? wixContext.client : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.client : void 0;
941
- const elevatedClient = typeof $wixContext !== "undefined" ? $wixContext.elevatedClient : typeof wixContext.elevatedClient !== "undefined" ? wixContext.elevatedClient : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.elevatedClient : void 0;
942
- if (!contextualClient && !elevatedClient) {
943
- return;
944
- }
945
- return {
946
- initWixModules(wixModules, elevated) {
947
- if (elevated) {
948
- if (!elevatedClient) {
949
- throw new Error("An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules");
950
- }
951
- return runWithoutContext2(() => elevatedClient.use(wixModules));
952
- }
953
- if (!contextualClient) {
954
- throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
955
- }
956
- return runWithoutContext2(() => contextualClient.use(wixModules));
957
- },
958
- fetchWithAuth: (urlOrRequest, requestInit) => {
959
- if (!contextualClient) {
960
- throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
961
- }
962
- return contextualClient.fetchWithAuth(urlOrRequest, requestInit);
963
- },
964
- async graphql(query, variables, opts) {
965
- if (!contextualClient) {
966
- throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
967
- }
968
- return contextualClient.graphql(query, variables, opts);
969
- }
970
- };
971
- }
972
- function runWithoutContext2(fn) {
973
- const globalContext = globalThis.__wix_context__;
974
- const moduleContext = {
975
- client: wixContext.client,
976
- elevatedClient: wixContext.elevatedClient
977
- };
978
- let closureContext;
979
- globalThis.__wix_context__ = void 0;
980
- wixContext.client = void 0;
981
- wixContext.elevatedClient = void 0;
982
- if (typeof $wixContext !== "undefined") {
983
- closureContext = {
984
- client: $wixContext?.client,
985
- elevatedClient: $wixContext?.elevatedClient
986
- };
987
- delete $wixContext.client;
988
- delete $wixContext.elevatedClient;
989
- }
990
- try {
991
- return fn();
992
- } finally {
993
- globalThis.__wix_context__ = globalContext;
994
- wixContext.client = moduleContext.client;
995
- wixContext.elevatedClient = moduleContext.elevatedClient;
996
- if (typeof $wixContext !== "undefined") {
997
- $wixContext.client = closureContext.client;
998
- $wixContext.elevatedClient = closureContext.elevatedClient;
999
- }
1000
- }
1001
- }
1002
-
1003
- // ../../node_modules/@wix/sdk-runtime/build/context-v2.js
1004
- function contextualizeRESTModuleV2(restModule, elevated) {
1005
- return (...args) => {
1006
- const context = resolveContext();
1007
- if (!context) {
1008
- return restModule.apply(void 0, args);
1009
- }
1010
- return context.initWixModules(restModule, elevated).apply(void 0, args);
1011
- };
1012
- }
1013
- function contextualizeEventDefinitionModuleV2(eventDefinition) {
1014
- const contextualMethod = (...args) => {
1015
- const context = resolveContext();
1016
- if (!context) {
1017
- return () => {
1018
- };
1019
- }
1020
- return context.initWixModules(eventDefinition).apply(void 0, args);
1021
- };
1022
- contextualMethod.__type = eventDefinition.__type;
1023
- contextualMethod.type = eventDefinition.type;
1024
- contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;
1025
- contextualMethod.transformations = eventDefinition.transformations;
1026
- return contextualMethod;
1027
- }
1028
-
1029
- // ../../node_modules/@wix/sdk-runtime/build/rest-modules.js
1030
- function createRESTModule(descriptor, elevated = false) {
1031
- return contextualizeRESTModuleV2(descriptor, elevated);
1032
- }
1033
- function toURLSearchParams(params, isComplexRequest) {
1034
- const flatten = flattenParams(params);
1035
- const isPayloadNonSerializableAsUrlSearchParams = Object.entries(flatten).some(([key, value]) => key.includes(".") || Array.isArray(value) && value.some((v) => typeof v === "object"));
1036
- const shouldSerializeToRParam = isComplexRequest && isPayloadNonSerializableAsUrlSearchParams;
1037
- if (shouldSerializeToRParam) {
1038
- return new URLSearchParams({ ".r": base64Encode(JSON.stringify(params)) });
1039
- } else {
1040
- return Object.entries(flatten).reduce((urlSearchParams, [key, value]) => {
1041
- const keyParams = Array.isArray(value) ? value : [value];
1042
- keyParams.forEach((param) => {
1043
- if (param === void 0 || param === null || Array.isArray(value) && typeof param === "object") {
1044
- return;
1045
- }
1046
- urlSearchParams.append(key, param);
1047
- });
1048
- return urlSearchParams;
1049
- }, new URLSearchParams());
1050
- }
1051
- }
1052
- function resolveUrl(opts) {
1053
- const domain = resolveDomain(opts.host);
1054
- const mappings = resolveMappingsByDomain(domain, opts.domainToMappings);
1055
- const path = injectDataIntoProtoPath(opts.protoPath, opts.data || {});
1056
- return resolvePathFromMappings(path, mappings);
1057
- }
1058
- function flattenParams(data, path = "") {
1059
- const params = {};
1060
- Object.entries(data).forEach(([key, value]) => {
1061
- const isObject2 = value !== null && typeof value === "object" && !Array.isArray(value);
1062
- const fieldPath = resolvePath(path, key);
1063
- if (isObject2) {
1064
- const serializedObject = flattenParams(value, fieldPath);
1065
- Object.assign(params, serializedObject);
1066
- } else {
1067
- params[fieldPath] = value;
1068
- }
1069
- });
1070
- return params;
1071
- }
1072
- function resolvePath(path, key) {
1073
- return `${path}${path ? "." : ""}${key}`;
1074
- }
1075
- var base64Encode = (value) => {
1076
- const base64 = typeof btoa !== "undefined" ? btoa(value) : Buffer.from(value, "utf-8").toString("base64");
1077
- return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
1078
- };
1079
- var DOMAINS = ["wix.com", "editorx.com"];
1080
- var USER_DOMAIN = "_";
1081
- var REGEX_CAPTURE_DOMAINS = new RegExp(`\\.(${DOMAINS.join("|")})$`);
1082
- var WIX_API_DOMAINS = ["42.wixprod.net", "uw2-edt-1.wixprod.net"];
1083
- var DEV_WIX_CODE_DOMAIN = "dev.wix-code.com";
1084
- var REGEX_CAPTURE_PROTO_FIELD = /{(.*)}/;
1085
- var REGEX_CAPTURE_API_DOMAINS = new RegExp(`\\.(${WIX_API_DOMAINS.join("|")})$`);
1086
- var REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN = new RegExp(`.*\\.${DEV_WIX_CODE_DOMAIN}$`);
1087
- function resolveDomain(host) {
1088
- const resolvedHost = fixHostExceptions(host);
1089
- return resolvedHost.replace(REGEX_CAPTURE_DOMAINS, "._base_domain_").replace(REGEX_CAPTURE_API_DOMAINS, "._api_base_domain_").replace(REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN, "*.dev.wix-code.com");
1090
- }
1091
- function fixHostExceptions(host) {
1092
- return host.replace("create.editorx.com", "editor.editorx.com");
1093
- }
1094
- function resolveMappingsByDomain(domain, domainToMappings) {
1095
- const mappings = domainToMappings[domain] || domainToMappings[USER_DOMAIN];
1096
- if (!mappings) {
1097
- if (isBaseDomain(domain)) {
1098
- return domainToMappings[wwwBaseDomain];
1099
- }
1100
- }
1101
- return mappings;
1102
- }
1103
- function isBaseDomain(domain) {
1104
- return !!domain.match(/\._base_domain_$/);
1105
- }
1106
- var wwwBaseDomain = "www._base_domain_";
1107
- function injectDataIntoProtoPath(protoPath, data) {
1108
- return protoPath.split("/").map((path) => maybeProtoPathToData(path, data)).join("/");
1109
- }
1110
- function maybeProtoPathToData(protoPath, data) {
1111
- const protoRegExpMatch = protoPath.match(REGEX_CAPTURE_PROTO_FIELD) || [];
1112
- const field = protoRegExpMatch[1];
1113
- if (field) {
1114
- const suffix = protoPath.replace(protoRegExpMatch[0], "");
1115
- return findByPath(data, field, protoPath, suffix);
1116
- }
1117
- return protoPath;
1118
- }
1119
- function findByPath(obj, path, defaultValue, suffix) {
1120
- let result = obj;
1121
- for (const field of path.split(".")) {
1122
- if (!result) {
1123
- return defaultValue;
1124
- }
1125
- result = result[field];
1126
- }
1127
- return `${result}${suffix}`;
1128
- }
1129
- function resolvePathFromMappings(protoPath, mappings) {
1130
- const mapping = mappings?.find((m) => protoPath.startsWith(m.destPath));
1131
- if (!mapping) {
1132
- return protoPath;
1133
- }
1134
- return mapping.srcPath + protoPath.slice(mapping.destPath.length);
1135
- }
1136
-
1137
- // ../../node_modules/@wix/auto_sdk_redirects_redirects/build/es/src/headless-v1-redirect-session-redirects.http.js
1138
- function resolveWixHeadlessV1RedirectSessionServiceUrl(opts) {
1139
- const domainToMappings = {
1140
- "www._base_domain_": [
1141
- {
1142
- srcPath: "/_api/redirects-api",
1143
- destPath: ""
1144
- }
1145
- ],
1146
- "www.wixapis.com": [
1147
- {
1148
- srcPath: "/_api/redirects-api",
1149
- destPath: ""
1150
- },
1151
- {
1152
- srcPath: "/redirect-session",
1153
- destPath: ""
1154
- }
1155
- ]
1156
- };
1157
- return resolveUrl(Object.assign(opts, { domainToMappings }));
1158
- }
1159
- var PACKAGE_NAME = "@wix/auto_sdk_redirects_redirects";
1160
- function createRedirectSession(payload) {
1161
- function __createRedirectSession({ host }) {
1162
- const metadata = {
1163
- entityFqdn: "wix.headless.v1.redirect_session",
1164
- method: "POST",
1165
- methodFqn: "wix.headless.v1.RedirectSessionService.CreateRedirectSession",
1166
- packageName: PACKAGE_NAME,
1167
- url: resolveWixHeadlessV1RedirectSessionServiceUrl({
1168
- protoPath: "/v1/redirect-session",
1169
- data: payload,
1170
- host
1171
- }),
1172
- data: payload
1173
- };
1174
- return metadata;
1175
- }
1176
- return __createRedirectSession;
1177
- }
1178
-
1179
- // ../../node_modules/@wix/auto_sdk_redirects_redirects/build/es/src/headless-v1-redirect-session-redirects.universal.js
1180
- var LocationType;
1181
- (function(LocationType2) {
1182
- LocationType2["UNDEFINED"] = "UNDEFINED";
1183
- LocationType2["OWNER_BUSINESS"] = "OWNER_BUSINESS";
1184
- LocationType2["OWNER_CUSTOM"] = "OWNER_CUSTOM";
1185
- LocationType2["CUSTOM"] = "CUSTOM";
1186
- })(LocationType || (LocationType = {}));
1187
- var Prompt;
1188
- (function(Prompt2) {
1189
- Prompt2["login"] = "login";
1190
- Prompt2["none"] = "none";
1191
- })(Prompt || (Prompt = {}));
1192
- var MembersAccountSection;
1193
- (function(MembersAccountSection2) {
1194
- MembersAccountSection2["ACCOUNT_INFO"] = "ACCOUNT_INFO";
1195
- MembersAccountSection2["BOOKINGS"] = "BOOKINGS";
1196
- MembersAccountSection2["ORDERS"] = "ORDERS";
1197
- MembersAccountSection2["SUBSCRIPTIONS"] = "SUBSCRIPTIONS";
1198
- MembersAccountSection2["EVENTS"] = "EVENTS";
1199
- })(MembersAccountSection || (MembersAccountSection = {}));
1200
- var AttachPagesResponseStatus;
1201
- (function(AttachPagesResponseStatus2) {
1202
- AttachPagesResponseStatus2["UNKNOWN"] = "UNKNOWN";
1203
- AttachPagesResponseStatus2["SUCCESS"] = "SUCCESS";
1204
- AttachPagesResponseStatus2["NO_ACTION"] = "NO_ACTION";
1205
- AttachPagesResponseStatus2["ERROR"] = "ERROR";
1206
- })(AttachPagesResponseStatus || (AttachPagesResponseStatus = {}));
1207
- var CallbackType;
1208
- (function(CallbackType2) {
1209
- CallbackType2["UNKNOWN"] = "UNKNOWN";
1210
- CallbackType2["LOGOUT"] = "LOGOUT";
1211
- CallbackType2["CHECKOUT"] = "CHECKOUT";
1212
- CallbackType2["AUTHORIZE"] = "AUTHORIZE";
1213
- })(CallbackType || (CallbackType = {}));
1214
- var Status;
1215
- (function(Status5) {
1216
- Status5["UNKNOWN"] = "UNKNOWN";
1217
- Status5["SUCCESS"] = "SUCCESS";
1218
- Status5["ERROR"] = "ERROR";
1219
- })(Status || (Status = {}));
1220
- var WebhookIdentityType;
1221
- (function(WebhookIdentityType2) {
1222
- WebhookIdentityType2["UNKNOWN"] = "UNKNOWN";
1223
- WebhookIdentityType2["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
1224
- WebhookIdentityType2["MEMBER"] = "MEMBER";
1225
- WebhookIdentityType2["WIX_USER"] = "WIX_USER";
1226
- WebhookIdentityType2["APP"] = "APP";
1227
- })(WebhookIdentityType || (WebhookIdentityType = {}));
1228
- async function createRedirectSession2(options) {
1229
- const { httpClient, sideEffects } = arguments[1];
1230
- const payload = renameKeysFromSDKRequestToRESTRequest({
1231
- bookingsCheckout: options?.bookingsCheckout,
1232
- ecomCheckout: options?.ecomCheckout,
1233
- eventsCheckout: options?.eventsCheckout,
1234
- paidPlansCheckout: options?.paidPlansCheckout,
1235
- login: options?.login,
1236
- logout: options?.logout,
1237
- auth: options?.auth,
1238
- storesProduct: options?.storesProduct,
1239
- bookingsBook: options?.bookingsBook,
1240
- callbacks: options?.callbacks,
1241
- preferences: options?.preferences
1242
- });
1243
- const reqOpts = createRedirectSession(payload);
1244
- sideEffects?.onSiteCall?.();
1245
- try {
1246
- const result = await httpClient.request(reqOpts);
1247
- sideEffects?.onSuccess?.(result);
1248
- return renameKeysFromRESTResponseToSDKResponse(result.data);
1249
- } catch (err) {
1250
- const transformedError = transformError(err, {
1251
- spreadPathsToArguments: {},
1252
- explicitPathsToArguments: {
1253
- bookingsCheckout: "$[0].bookingsCheckout",
1254
- ecomCheckout: "$[0].ecomCheckout",
1255
- eventsCheckout: "$[0].eventsCheckout",
1256
- paidPlansCheckout: "$[0].paidPlansCheckout",
1257
- login: "$[0].login",
1258
- logout: "$[0].logout",
1259
- auth: "$[0].auth",
1260
- storesProduct: "$[0].storesProduct",
1261
- bookingsBook: "$[0].bookingsBook",
1262
- callbacks: "$[0].callbacks",
1263
- preferences: "$[0].preferences"
1264
- },
1265
- singleArgumentUnchanged: false
1266
- }, ["options"]);
1267
- sideEffects?.onError?.(err);
1268
- throw transformedError;
1269
- }
1270
- }
1271
-
1272
- // ../../node_modules/@wix/auto_sdk_redirects_redirects/build/es/src/headless-v1-redirect-session-redirects.public.js
1273
- function createRedirectSession3(httpClient) {
1274
- return (options) => createRedirectSession2(
1275
- options,
1276
- // @ts-ignore
1277
- { httpClient }
1278
- );
1279
- }
1280
- var onRedirectSessionCreated = EventDefinition("wix.headless.v1.redirect_session_created", true, (event) => renameKeysFromRESTResponseToSDKResponse(transformPaths(event, [
1281
- {
1282
- transformFn: transformRESTTimestampToSDKTimestamp,
1283
- paths: [{ path: "metadata.eventTime" }]
1284
- }
1285
- ])))();
1286
-
1287
- // ../../node_modules/@wix/sdk-runtime/build/event-definition-modules.js
1288
- function createEventModule(eventDefinition) {
1289
- return contextualizeEventDefinitionModuleV2(eventDefinition);
1290
- }
1291
-
1292
- // ../../node_modules/@wix/auto_sdk_redirects_redirects/build/es/src/headless-v1-redirect-session-redirects.context.js
1293
- var createRedirectSession4 = /* @__PURE__ */ createRESTModule(createRedirectSession3);
1294
- var onRedirectSessionCreated2 = createEventModule(onRedirectSessionCreated);
1295
-
1296
- // ../../node_modules/@wix/sdk/build/tokenHelpers.js
1297
- function getCurrentDate() {
1298
- return Math.floor(Date.now() / 1e3);
1299
- }
1300
- function isTokenExpired(token4) {
1301
- const currentDate = getCurrentDate();
1302
- return token4.expiresAt < currentDate;
1303
- }
1304
- function createAccessToken(accessToken, expiresIn) {
1305
- const now = getCurrentDate();
1306
- return { value: accessToken, expiresAt: Number(expiresIn) + now };
1307
- }
1308
-
1309
- // ../../node_modules/@wix/auto_sdk_identity_authentication/build/es/index.js
1310
- var es_exports2 = {};
1311
- __export(es_exports2, {
1312
- AddressTag: () => AddressTag,
1313
- EmailTag: () => EmailTag,
1314
- FactorStatus: () => FactorStatus,
1315
- FactorType: () => FactorType,
1316
- MfaReason: () => MfaReason,
1317
- PhoneTag: () => PhoneTag,
1318
- PrivacyStatus: () => PrivacyStatus,
1319
- Reason: () => Reason,
1320
- StateType: () => StateType,
1321
- Status: () => Status2,
1322
- StatusName: () => StatusName,
1323
- TenantType: () => TenantType,
1324
- changePassword: () => changePassword4,
1325
- loginCallback: () => loginCallback4,
1326
- loginV2: () => loginV24,
1327
- logout: () => logout4,
1328
- registerV2: () => registerV24,
1329
- signOn: () => signOn4,
1330
- verify: () => verify4
1331
- });
1332
-
1333
- // ../../node_modules/@wix/sdk-runtime/build/transformations/float.js
1334
- function transformSDKFloatToRESTFloat(val) {
1335
- return isFinite(val) ? val : val.toString();
1336
- }
1337
- function transformRESTFloatToSDKFloat(val) {
1338
- if (val === "NaN") {
1339
- return NaN;
1340
- }
1341
- if (val === "Infinity") {
1342
- return Infinity;
1343
- }
1344
- if (val === "-Infinity") {
1345
- return -Infinity;
1346
- }
1347
- return val;
1348
- }
1349
-
1350
- // ../../node_modules/@wix/sdk-runtime/build/transformations/bytes.js
1351
- function transformRESTBytesToSDKBytes(val) {
1352
- return Uint8Array.from(atob(val), (c) => c.charCodeAt(0));
1353
- }
1354
-
1355
- // ../../node_modules/@wix/auto_sdk_identity_authentication/build/es/src/iam-authentication-v1-authentication-authentication.http.js
1356
- function resolveWixIamAuthenticationV1AuthenticationServiceUrl(opts) {
1357
- const domainToMappings = {
1358
- _: [
1359
- {
1360
- srcPath: "/_api/iam/authentication",
1361
- destPath: ""
1362
- }
1363
- ],
1364
- "users._base_domain_": [
1365
- {
1366
- srcPath: "/iam/wix/google",
1367
- destPath: "/v1/sso/callback/root/0e6a50f5-b523-4e29-990d-f37fa2ffdd69"
1368
- },
1369
- {
1370
- srcPath: "/authentication",
1371
- destPath: ""
1372
- }
1373
- ],
1374
- "www.wixapis.com": [
1375
- {
1376
- srcPath: "/_api/iam/authentication",
1377
- destPath: ""
1378
- },
1379
- {
1380
- srcPath: "/iam/authentication",
1381
- destPath: ""
1382
- }
1383
- ],
1384
- "bo._base_domain_": [
1385
- {
1386
- srcPath: "/_api/iam/authentication",
1387
- destPath: ""
1388
- }
1389
- ],
1390
- "wixbo.ai": [
1391
- {
1392
- srcPath: "/_api/iam/authentication",
1393
- destPath: ""
1394
- }
1395
- ],
1396
- "wix-bo.com": [
1397
- {
1398
- srcPath: "/_api/iam/authentication",
1399
- destPath: ""
1400
- }
1401
- ],
1402
- "dev._base_domain_": [
1403
- {
1404
- srcPath: "/_api/iam/authentication",
1405
- destPath: ""
1406
- }
1407
- ],
1408
- "manage._base_domain_": [
1409
- {
1410
- srcPath: "/_api/authentication",
1411
- destPath: ""
1412
- }
1413
- ],
1414
- "www._base_domain_": [
1415
- {
1416
- srcPath: "/_api/iam/authentication",
1417
- destPath: ""
1418
- }
1419
- ]
1420
- };
1421
- return resolveUrl(Object.assign(opts, { domainToMappings }));
1422
- }
1423
- var PACKAGE_NAME2 = "@wix/auto_sdk_identity_authentication";
1424
- function registerV2(payload) {
1425
- function __registerV2({ host }) {
1426
- const serializedData = transformPaths(payload, [
1427
- {
1428
- transformFn: transformSDKFloatToRESTFloat,
1429
- paths: [{ path: "profile.customFields.value.numValue" }]
1430
- },
1431
- {
1432
- transformFn: transformSDKTimestampToRESTTimestamp,
1433
- paths: [{ path: "profile.customFields.value.dateValue" }]
1434
- }
1435
- ]);
1436
- const metadata = {
1437
- entityFqdn: "wix.iam.authentication.v1.authentication",
1438
- method: "POST",
1439
- methodFqn: "wix.iam.authentication.v1.AuthenticationService.RegisterV2",
1440
- packageName: PACKAGE_NAME2,
1441
- url: resolveWixIamAuthenticationV1AuthenticationServiceUrl({
1442
- protoPath: "/v2/register",
1443
- data: serializedData,
1444
- host
1445
- }),
1446
- data: serializedData,
1447
- transformResponse: (payload2) => transformPaths(payload2, [
1448
- {
1449
- transformFn: transformRESTTimestampToSDKTimestamp,
1450
- paths: [
1451
- { path: "identity.createdDate" },
1452
- { path: "identity.updatedDate" },
1453
- { path: "identity.identityProfile.customFields.value.dateValue" },
1454
- { path: "additionalData.*.dateValue" }
1455
- ]
1456
- },
1457
- {
1458
- transformFn: transformRESTFloatToSDKFloat,
1459
- paths: [
1460
- { path: "identity.identityProfile.customFields.value.numValue" },
1461
- { path: "additionalData.*.numValue" }
1462
- ]
1463
- }
1464
- ])
1465
- };
1466
- return metadata;
1467
- }
1468
- return __registerV2;
1469
- }
1470
- function loginV2(payload) {
1471
- function __loginV2({ host }) {
1472
- const metadata = {
1473
- entityFqdn: "wix.iam.authentication.v1.authentication",
1474
- method: "POST",
1475
- methodFqn: "wix.iam.authentication.v1.AuthenticationService.LoginV2",
1476
- packageName: PACKAGE_NAME2,
1477
- url: resolveWixIamAuthenticationV1AuthenticationServiceUrl({
1478
- protoPath: "/v2/login",
1479
- data: payload,
1480
- host
1481
- }),
1482
- data: payload,
1483
- transformResponse: (payload2) => transformPaths(payload2, [
1484
- {
1485
- transformFn: transformRESTTimestampToSDKTimestamp,
1486
- paths: [
1487
- { path: "identity.createdDate" },
1488
- { path: "identity.updatedDate" },
1489
- { path: "identity.identityProfile.customFields.value.dateValue" },
1490
- { path: "additionalData.*.dateValue" }
1491
- ]
1492
- },
1493
- {
1494
- transformFn: transformRESTFloatToSDKFloat,
1495
- paths: [
1496
- { path: "identity.identityProfile.customFields.value.numValue" },
1497
- { path: "additionalData.*.numValue" }
1498
- ]
1499
- }
1500
- ])
1501
- };
1502
- return metadata;
1503
- }
1504
- return __loginV2;
1505
- }
1506
- function changePassword(payload) {
1507
- function __changePassword({ host }) {
1508
- const metadata = {
1509
- entityFqdn: "wix.iam.authentication.v1.authentication",
1510
- method: "POST",
1511
- methodFqn: "wix.iam.authentication.v1.AuthenticationService.ChangePassword",
1512
- packageName: PACKAGE_NAME2,
1513
- url: resolveWixIamAuthenticationV1AuthenticationServiceUrl({
1514
- protoPath: "/v2/change-password",
1515
- data: payload,
1516
- host
1517
- }),
1518
- data: payload
1519
- };
1520
- return metadata;
1521
- }
1522
- return __changePassword;
1523
- }
1524
- function loginCallback(payload) {
1525
- function __loginCallback({ host }) {
1526
- const metadata = {
1527
- entityFqdn: "wix.iam.authentication.v1.authentication",
1528
- method: "GET",
1529
- methodFqn: "wix.iam.authentication.v1.AuthenticationService.LoginCallback",
1530
- packageName: PACKAGE_NAME2,
1531
- url: resolveWixIamAuthenticationV1AuthenticationServiceUrl({
1532
- protoPath: "/v1/callback",
1533
- data: payload,
1534
- host
1535
- }),
1536
- params: toURLSearchParams(payload),
1537
- transformResponse: (payload2) => transformPaths(payload2, [
1538
- {
1539
- transformFn: transformRESTBytesToSDKBytes,
1540
- paths: [{ path: "body" }]
1541
- }
1542
- ])
1543
- };
1544
- return metadata;
1545
- }
1546
- return __loginCallback;
1547
- }
1548
- function signOn(payload) {
1549
- function __signOn({ host }) {
1550
- const serializedData = transformPaths(payload, [
1551
- {
1552
- transformFn: transformSDKFloatToRESTFloat,
1553
- paths: [{ path: "profile.customFields.value.numValue" }]
1554
- },
1555
- {
1556
- transformFn: transformSDKTimestampToRESTTimestamp,
1557
- paths: [{ path: "profile.customFields.value.dateValue" }]
1558
- }
1559
- ]);
1560
- const metadata = {
1561
- entityFqdn: "wix.iam.authentication.v1.authentication",
1562
- method: "POST",
1563
- methodFqn: "wix.iam.authentication.v1.AuthenticationService.SignOn",
1564
- packageName: PACKAGE_NAME2,
1565
- url: resolveWixIamAuthenticationV1AuthenticationServiceUrl({
1566
- protoPath: "/v2/sign-on",
1567
- data: serializedData,
1568
- host
1569
- }),
1570
- data: serializedData,
1571
- transformResponse: (payload2) => transformPaths(payload2, [
1572
- {
1573
- transformFn: transformRESTTimestampToSDKTimestamp,
1574
- paths: [
1575
- { path: "identity.createdDate" },
1576
- { path: "identity.updatedDate" },
1577
- { path: "identity.identityProfile.customFields.value.dateValue" }
1578
- ]
1579
- },
1580
- {
1581
- transformFn: transformRESTFloatToSDKFloat,
1582
- paths: [
1583
- { path: "identity.identityProfile.customFields.value.numValue" }
1584
- ]
1585
- }
1586
- ])
1587
- };
1588
- return metadata;
1589
- }
1590
- return __signOn;
1591
- }
1592
- function logout(payload) {
1593
- function __logout({ host }) {
1594
- const metadata = {
1595
- entityFqdn: "wix.iam.authentication.v1.authentication",
1596
- method: "GET",
1597
- methodFqn: "wix.iam.authentication.v1.AuthenticationService.Logout",
1598
- packageName: PACKAGE_NAME2,
1599
- url: resolveWixIamAuthenticationV1AuthenticationServiceUrl({
1600
- protoPath: "/v1/logout",
1601
- data: payload,
1602
- host
1603
- }),
1604
- params: toURLSearchParams(payload),
1605
- transformResponse: (payload2) => transformPaths(payload2, [
1606
- {
1607
- transformFn: transformRESTBytesToSDKBytes,
1608
- paths: [{ path: "body" }]
1609
- }
1610
- ])
1611
- };
1612
- return metadata;
1613
- }
1614
- return __logout;
1615
- }
1616
- function verify(payload) {
1617
- function __verify({ host }) {
1618
- const metadata = {
1619
- entityFqdn: "wix.iam.authentication.v1.authentication",
1620
- method: "POST",
1621
- methodFqn: "wix.iam.authentication.v1.AuthenticationService.Verify",
1622
- packageName: PACKAGE_NAME2,
1623
- url: resolveWixIamAuthenticationV1AuthenticationServiceUrl({
1624
- protoPath: "/v2/{factorType}/verify",
1625
- data: payload,
1626
- host
1627
- }),
1628
- data: payload,
1629
- transformResponse: (payload2) => transformPaths(payload2, [
1630
- {
1631
- transformFn: transformRESTTimestampToSDKTimestamp,
1632
- paths: [
1633
- { path: "identity.createdDate" },
1634
- { path: "identity.updatedDate" },
1635
- { path: "identity.identityProfile.customFields.value.dateValue" },
1636
- { path: "additionalData.*.dateValue" }
1637
- ]
1638
- },
1639
- {
1640
- transformFn: transformRESTFloatToSDKFloat,
1641
- paths: [
1642
- { path: "identity.identityProfile.customFields.value.numValue" },
1643
- { path: "additionalData.*.numValue" }
1644
- ]
1645
- }
1646
- ])
1647
- };
1648
- return metadata;
1649
- }
1650
- return __verify;
1651
- }
1652
-
1653
- // ../../node_modules/@wix/sdk-runtime/build/transformations/address.js
1654
- function transformSDKAddressToRESTAddress(payload) {
1655
- return payload && removeUndefinedKeys({
1656
- city: payload.city,
1657
- subdivision: payload.subdivision,
1658
- country: payload.country,
1659
- postalCode: payload.postalCode,
1660
- formattedAddress: payload.formatted,
1661
- geocode: payload.location,
1662
- addressLine: payload.addressLine1,
1663
- addressLine2: payload.addressLine2,
1664
- streetAddress: payload.streetAddress && {
1665
- name: payload.streetAddress.name,
1666
- number: payload.streetAddress.number,
1667
- apt: payload.streetAddress.apt
1668
- }
1669
- });
1670
- }
1671
- function transformRESTAddressToSDKAddress(payload) {
1672
- return payload && removeUndefinedKeys({
1673
- formatted: payload.formattedAddress,
1674
- location: payload.geocode,
1675
- addressLine1: payload.addressLine,
1676
- addressLine2: payload.addressLine2,
1677
- streetAddress: payload.streetAddress && {
1678
- name: payload.streetAddress.name,
1679
- number: payload.streetAddress.number,
1680
- apt: payload.streetAddress.apt
1681
- },
1682
- city: payload.city,
1683
- subdivision: payload.subdivision,
1684
- country: payload.country,
1685
- postalCode: payload.postalCode,
1686
- countryFullname: payload.countryFullname,
1687
- subdivisionFullname: payload.subdivisionFullname
1688
- });
1689
- }
1690
-
1691
- // ../../node_modules/@wix/auto_sdk_identity_authentication/build/es/src/iam-authentication-v1-authentication-authentication.universal.js
1692
- var PrivacyStatus;
1693
- (function(PrivacyStatus4) {
1694
- PrivacyStatus4["UNDEFINED"] = "UNDEFINED";
1695
- PrivacyStatus4["PUBLIC"] = "PUBLIC";
1696
- PrivacyStatus4["PRIVATE"] = "PRIVATE";
1697
- })(PrivacyStatus || (PrivacyStatus = {}));
1698
- var EmailTag;
1699
- (function(EmailTag4) {
1700
- EmailTag4["UNTAGGED"] = "UNTAGGED";
1701
- EmailTag4["MAIN"] = "MAIN";
1702
- EmailTag4["HOME"] = "HOME";
1703
- EmailTag4["WORK"] = "WORK";
1704
- })(EmailTag || (EmailTag = {}));
1705
- var PhoneTag;
1706
- (function(PhoneTag4) {
1707
- PhoneTag4["UNTAGGED"] = "UNTAGGED";
1708
- PhoneTag4["MAIN"] = "MAIN";
1709
- PhoneTag4["HOME"] = "HOME";
1710
- PhoneTag4["MOBILE"] = "MOBILE";
1711
- PhoneTag4["WORK"] = "WORK";
1712
- PhoneTag4["FAX"] = "FAX";
1713
- })(PhoneTag || (PhoneTag = {}));
1714
- var AddressTag;
1715
- (function(AddressTag4) {
1716
- AddressTag4["UNTAGGED"] = "UNTAGGED";
1717
- AddressTag4["HOME"] = "HOME";
1718
- AddressTag4["WORK"] = "WORK";
1719
- AddressTag4["BILLING"] = "BILLING";
1720
- AddressTag4["SHIPPING"] = "SHIPPING";
1721
- })(AddressTag || (AddressTag = {}));
1722
- var StateType;
1723
- (function(StateType4) {
1724
- StateType4["UNKNOWN_STATE"] = "UNKNOWN_STATE";
1725
- StateType4["SUCCESS"] = "SUCCESS";
1726
- StateType4["REQUIRE_OWNER_APPROVAL"] = "REQUIRE_OWNER_APPROVAL";
1727
- StateType4["REQUIRE_EMAIL_VERIFICATION"] = "REQUIRE_EMAIL_VERIFICATION";
1728
- StateType4["STATUS_CHECK"] = "STATUS_CHECK";
1729
- })(StateType || (StateType = {}));
1730
- var StatusName;
1731
- (function(StatusName4) {
1732
- StatusName4["UNKNOWN_STATUS"] = "UNKNOWN_STATUS";
1733
- StatusName4["PENDING"] = "PENDING";
1734
- StatusName4["ACTIVE"] = "ACTIVE";
1735
- StatusName4["DELETED"] = "DELETED";
1736
- StatusName4["BLOCKED"] = "BLOCKED";
1737
- StatusName4["OFFLINE"] = "OFFLINE";
1738
- })(StatusName || (StatusName = {}));
1739
- var Reason;
1740
- (function(Reason4) {
1741
- Reason4["UNKNOWN_REASON"] = "UNKNOWN_REASON";
1742
- Reason4["PENDING_ADMIN_APPROVAL_REQUIRED"] = "PENDING_ADMIN_APPROVAL_REQUIRED";
1743
- Reason4["PENDING_EMAIL_VERIFICATION_REQUIRED"] = "PENDING_EMAIL_VERIFICATION_REQUIRED";
1744
- })(Reason || (Reason = {}));
1745
- var FactorType;
1746
- (function(FactorType4) {
1747
- FactorType4["UNKNOWN_FACTOR_TYPE"] = "UNKNOWN_FACTOR_TYPE";
1748
- FactorType4["PASSWORD"] = "PASSWORD";
1749
- FactorType4["SMS"] = "SMS";
1750
- FactorType4["CALL"] = "CALL";
1751
- FactorType4["EMAIL"] = "EMAIL";
1752
- FactorType4["TOTP"] = "TOTP";
1753
- FactorType4["PUSH"] = "PUSH";
1754
- })(FactorType || (FactorType = {}));
1755
- var Status2;
1756
- (function(Status5) {
1757
- Status5["INACTIVE"] = "INACTIVE";
1758
- Status5["ACTIVE"] = "ACTIVE";
1759
- Status5["REQUIRE_REENROLL"] = "REQUIRE_REENROLL";
1760
- })(Status2 || (Status2 = {}));
1761
- var FactorStatus;
1762
- (function(FactorStatus4) {
1763
- FactorStatus4["UNKNOWN_FACTOR_STATUS"] = "UNKNOWN_FACTOR_STATUS";
1764
- FactorStatus4["ENABLED"] = "ENABLED";
1765
- FactorStatus4["REQUIRE_ACTIVATION"] = "REQUIRE_ACTIVATION";
1766
- FactorStatus4["REQUIRE_REENROLL"] = "REQUIRE_REENROLL";
1767
- FactorStatus4["ENABLED_BY_RULE"] = "ENABLED_BY_RULE";
1768
- FactorStatus4["DISABLED_BY_RULE"] = "DISABLED_BY_RULE";
1769
- })(FactorStatus || (FactorStatus = {}));
1770
- var MfaReason;
1771
- (function(MfaReason4) {
1772
- MfaReason4["UNKNOWN_MFA_REASON"] = "UNKNOWN_MFA_REASON";
1773
- MfaReason4["USER_SETTINGS"] = "USER_SETTINGS";
1774
- MfaReason4["HIGH_RISK_LOGIN"] = "HIGH_RISK_LOGIN";
1775
- })(MfaReason || (MfaReason = {}));
1776
- var TenantType;
1777
- (function(TenantType3) {
1778
- TenantType3["UNKNOWN_TENANT_TYPE"] = "UNKNOWN_TENANT_TYPE";
1779
- TenantType3["ACCOUNT"] = "ACCOUNT";
1780
- TenantType3["SITE"] = "SITE";
1781
- TenantType3["ROOT"] = "ROOT";
1782
- })(TenantType || (TenantType = {}));
1783
- async function registerV22(loginId, options) {
1784
- const { httpClient, sideEffects } = arguments[2];
1785
- const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({
1786
- loginId,
1787
- password: options?.password,
1788
- profile: options?.profile,
1789
- captchaTokens: options?.captchaTokens,
1790
- clientMetaData: options?.clientMetaData
1791
- }), [
1792
- {
1793
- transformFn: transformSDKAddressToRESTAddress,
1794
- paths: [{ path: "profile.addresses.address" }]
1795
- }
1796
- ]);
1797
- const reqOpts = registerV2(payload);
1798
- sideEffects?.onSiteCall?.();
1799
- try {
1800
- const result = await httpClient.request(reqOpts);
1801
- sideEffects?.onSuccess?.(result);
1802
- return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
1803
- {
1804
- transformFn: transformRESTAddressToSDKAddress,
1805
- paths: [{ path: "identity.identityProfile.addresses.address" }]
1806
- }
1807
- ]));
1808
- } catch (err) {
1809
- const transformedError = transformError(err, {
1810
- spreadPathsToArguments: {},
1811
- explicitPathsToArguments: {
1812
- loginId: "$[0]",
1813
- password: "$[1].password",
1814
- profile: "$[1].profile",
1815
- captchaTokens: "$[1].captchaTokens",
1816
- clientMetaData: "$[1].clientMetaData"
1817
- },
1818
- singleArgumentUnchanged: false
1819
- }, ["loginId", "options"]);
1820
- sideEffects?.onError?.(err);
1821
- throw transformedError;
1822
- }
1823
- }
1824
- async function loginV22(loginId, options) {
1825
- const { httpClient, sideEffects } = arguments[2];
1826
- const payload = renameKeysFromSDKRequestToRESTRequest({
1827
- loginId,
1828
- password: options?.password,
1829
- captchaTokens: options?.captchaTokens,
1830
- clientMetaData: options?.clientMetaData
1831
- });
1832
- const reqOpts = loginV2(payload);
1833
- sideEffects?.onSiteCall?.();
1834
- try {
1835
- const result = await httpClient.request(reqOpts);
1836
- sideEffects?.onSuccess?.(result);
1837
- return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
1838
- {
1839
- transformFn: transformRESTAddressToSDKAddress,
1840
- paths: [{ path: "identity.identityProfile.addresses.address" }]
1841
- }
1842
- ]));
1843
- } catch (err) {
1844
- const transformedError = transformError(err, {
1845
- spreadPathsToArguments: {},
1846
- explicitPathsToArguments: {
1847
- loginId: "$[0]",
1848
- password: "$[1].password",
1849
- captchaTokens: "$[1].captchaTokens",
1850
- clientMetaData: "$[1].clientMetaData"
1851
- },
1852
- singleArgumentUnchanged: false
1853
- }, ["loginId", "options"]);
1854
- sideEffects?.onError?.(err);
1855
- throw transformedError;
1856
- }
1857
- }
1858
- async function changePassword2(newPassword) {
1859
- const { httpClient, sideEffects } = arguments[1];
1860
- const payload = renameKeysFromSDKRequestToRESTRequest({
1861
- newPassword
1862
- });
1863
- const reqOpts = changePassword(payload);
1864
- sideEffects?.onSiteCall?.();
1865
- try {
1866
- const result = await httpClient.request(reqOpts);
1867
- sideEffects?.onSuccess?.(result);
1868
- } catch (err) {
1869
- const transformedError = transformError(err, {
1870
- spreadPathsToArguments: {},
1871
- explicitPathsToArguments: { newPassword: "$[0]" },
1872
- singleArgumentUnchanged: false
1873
- }, ["newPassword"]);
1874
- sideEffects?.onError?.(err);
1875
- throw transformedError;
1876
- }
1877
- }
1878
- async function loginCallback2(options) {
1879
- const { httpClient, sideEffects } = arguments[1];
1880
- const payload = renameKeysFromSDKRequestToRESTRequest({
1881
- state: options?.state,
1882
- sessionToken: options?.sessionToken
1883
- });
1884
- const reqOpts = loginCallback(payload);
1885
- sideEffects?.onSiteCall?.();
1886
- try {
1887
- const result = await httpClient.request(reqOpts);
1888
- sideEffects?.onSuccess?.(result);
1889
- return renameKeysFromRESTResponseToSDKResponse(result.data);
1890
- } catch (err) {
1891
- const transformedError = transformError(err, {
1892
- spreadPathsToArguments: {},
1893
- explicitPathsToArguments: {
1894
- state: "$[0].state",
1895
- sessionToken: "$[0].sessionToken"
1896
- },
1897
- singleArgumentUnchanged: false
1898
- }, ["options"]);
1899
- sideEffects?.onError?.(err);
1900
- throw transformedError;
1901
- }
1902
- }
1903
- async function signOn2(loginId, options) {
1904
- const { httpClient, sideEffects } = arguments[2];
1905
- const payload = transformPaths(renameKeysFromSDKRequestToRESTRequest({
1906
- loginId,
1907
- profile: options?.profile,
1908
- verifyEmail: options?.verifyEmail,
1909
- mergeExistingContact: options?.mergeExistingContact
1910
- }), [
1911
- {
1912
- transformFn: transformSDKAddressToRESTAddress,
1913
- paths: [{ path: "profile.addresses.address" }]
1914
- }
1915
- ]);
1916
- const reqOpts = signOn(payload);
1917
- sideEffects?.onSiteCall?.();
1918
- try {
1919
- const result = await httpClient.request(reqOpts);
1920
- sideEffects?.onSuccess?.(result);
1921
- return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
1922
- {
1923
- transformFn: transformRESTAddressToSDKAddress,
1924
- paths: [{ path: "identity.identityProfile.addresses.address" }]
1925
- }
1926
- ]));
1927
- } catch (err) {
1928
- const transformedError = transformError(err, {
1929
- spreadPathsToArguments: {},
1930
- explicitPathsToArguments: {
1931
- loginId: "$[0]",
1932
- profile: "$[1].profile",
1933
- verifyEmail: "$[1].verifyEmail",
1934
- mergeExistingContact: "$[1].mergeExistingContact"
1935
- },
1936
- singleArgumentUnchanged: false
1937
- }, ["loginId", "options"]);
1938
- sideEffects?.onError?.(err);
1939
- throw transformedError;
1940
- }
1941
- }
1942
- async function logout2(options) {
1943
- const { httpClient, sideEffects } = arguments[1];
1944
- const payload = renameKeysFromSDKRequestToRESTRequest({
1945
- postLogoutRedirectUri: options?.postLogoutRedirectUri,
1946
- clientId: options?.clientId
1947
- });
1948
- const reqOpts = logout(payload);
1949
- sideEffects?.onSiteCall?.();
1950
- try {
1951
- const result = await httpClient.request(reqOpts);
1952
- sideEffects?.onSuccess?.(result);
1953
- return renameKeysFromRESTResponseToSDKResponse(result.data);
1954
- } catch (err) {
1955
- const transformedError = transformError(err, {
1956
- spreadPathsToArguments: {},
1957
- explicitPathsToArguments: {
1958
- postLogoutRedirectUri: "$[0].postLogoutRedirectUri",
1959
- clientId: "$[0].clientId"
1960
- },
1961
- singleArgumentUnchanged: false
1962
- }, ["options"]);
1963
- sideEffects?.onError?.(err);
1964
- throw transformedError;
1965
- }
1966
- }
1967
- async function verify2(factorType, options) {
1968
- const { httpClient, sideEffects } = arguments[2];
1969
- const payload = renameKeysFromSDKRequestToRESTRequest({
1970
- factorType,
1971
- stateToken: options?.stateToken,
1972
- rememberThisDevice: options?.rememberThisDevice,
1973
- smsData: options?.smsData,
1974
- callData: options?.callData,
1975
- emailData: options?.emailData,
1976
- totpData: options?.totpData,
1977
- pushData: options?.pushData
1978
- });
1979
- const reqOpts = verify(payload);
1980
- sideEffects?.onSiteCall?.();
1981
- try {
1982
- const result = await httpClient.request(reqOpts);
1983
- sideEffects?.onSuccess?.(result);
1984
- return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
1985
- {
1986
- transformFn: transformRESTAddressToSDKAddress,
1987
- paths: [{ path: "identity.identityProfile.addresses.address" }]
1988
- }
1989
- ]));
1990
- } catch (err) {
1991
- const transformedError = transformError(err, {
1992
- spreadPathsToArguments: {},
1993
- explicitPathsToArguments: {
1994
- factorType: "$[0]",
1995
- stateToken: "$[1].stateToken",
1996
- rememberThisDevice: "$[1].rememberThisDevice",
1997
- smsData: "$[1].smsData",
1998
- callData: "$[1].callData",
1999
- emailData: "$[1].emailData",
2000
- totpData: "$[1].totpData",
2001
- pushData: "$[1].pushData"
2002
- },
2003
- singleArgumentUnchanged: false
2004
- }, ["factorType", "options"]);
2005
- sideEffects?.onError?.(err);
2006
- throw transformedError;
2007
- }
2008
- }
2009
-
2010
- // ../../node_modules/@wix/auto_sdk_identity_authentication/build/es/src/iam-authentication-v1-authentication-authentication.public.js
2011
- function registerV23(httpClient) {
2012
- return (loginId, options) => registerV22(
2013
- loginId,
2014
- options,
2015
- // @ts-ignore
2016
- { httpClient }
2017
- );
2018
- }
2019
- function loginV23(httpClient) {
2020
- return (loginId, options) => loginV22(
2021
- loginId,
2022
- options,
2023
- // @ts-ignore
2024
- { httpClient }
2025
- );
2026
- }
2027
- function changePassword3(httpClient) {
2028
- return (newPassword) => changePassword2(
2029
- newPassword,
2030
- // @ts-ignore
2031
- { httpClient }
2032
- );
2033
- }
2034
- function loginCallback3(httpClient) {
2035
- return (options) => loginCallback2(
2036
- options,
2037
- // @ts-ignore
2038
- { httpClient }
2039
- );
2040
- }
2041
- function signOn3(httpClient) {
2042
- return (loginId, options) => signOn2(
2043
- loginId,
2044
- options,
2045
- // @ts-ignore
2046
- { httpClient }
2047
- );
2048
- }
2049
- function logout3(httpClient) {
2050
- return (options) => logout2(
2051
- options,
2052
- // @ts-ignore
2053
- { httpClient }
2054
- );
2055
- }
2056
- function verify3(httpClient) {
2057
- return (factorType, options) => verify2(
2058
- factorType,
2059
- options,
2060
- // @ts-ignore
2061
- { httpClient }
2062
- );
2063
- }
2064
-
2065
- // ../../node_modules/@wix/auto_sdk_identity_authentication/build/es/src/iam-authentication-v1-authentication-authentication.context.js
2066
- var registerV24 = /* @__PURE__ */ createRESTModule(registerV23);
2067
- var loginV24 = /* @__PURE__ */ createRESTModule(loginV23);
2068
- var changePassword4 = /* @__PURE__ */ createRESTModule(changePassword3);
2069
- var loginCallback4 = /* @__PURE__ */ createRESTModule(loginCallback3);
2070
- var signOn4 = /* @__PURE__ */ createRESTModule(signOn3);
2071
- var logout4 = /* @__PURE__ */ createRESTModule(logout3);
2072
- var verify4 = /* @__PURE__ */ createRESTModule(verify3);
2073
-
2074
- // ../../node_modules/@wix/auto_sdk_identity_recovery/build/es/index.js
2075
- var es_exports3 = {};
2076
- __export(es_exports3, {
2077
- AddressTag: () => AddressTag2,
2078
- EmailTag: () => EmailTag2,
2079
- FactorStatus: () => FactorStatus2,
2080
- FactorType: () => FactorType2,
2081
- MfaReason: () => MfaReason2,
2082
- PhoneTag: () => PhoneTag2,
2083
- PrivacyStatus: () => PrivacyStatus2,
2084
- Reason: () => Reason2,
2085
- StateType: () => StateType2,
2086
- Status: () => Status3,
2087
- StatusName: () => StatusName2,
2088
- TenantType: () => TenantType2,
2089
- recover: () => recover4,
2090
- sendActivationEmail: () => sendActivationEmail4,
2091
- sendRecoveryEmail: () => sendRecoveryEmail4
2092
- });
2093
-
2094
- // ../../node_modules/@wix/auto_sdk_identity_recovery/build/es/src/iam-recovery-v1-recovery-recovery.http.js
2095
- function resolveWixIamRecoveryV1RecoveryServiceUrl(opts) {
2096
- const domainToMappings = {
2097
- _: [
2098
- {
2099
- srcPath: "/_iam/recovery",
2100
- destPath: ""
2101
- },
2102
- {
2103
- srcPath: "/_api/iam/recovery",
2104
- destPath: ""
2105
- }
2106
- ],
2107
- "www.wixapis.com": [
2108
- {
2109
- srcPath: "/_api/iam/recovery",
2110
- destPath: ""
2111
- }
2112
- ]
2113
- };
2114
- return resolveUrl(Object.assign(opts, { domainToMappings }));
2115
- }
2116
- var PACKAGE_NAME3 = "@wix/auto_sdk_identity_recovery";
2117
- function sendRecoveryEmail(payload) {
2118
- function __sendRecoveryEmail({ host }) {
2119
- const metadata = {
2120
- entityFqdn: "wix.iam.recovery.v1.recovery",
2121
- method: "POST",
2122
- methodFqn: "wix.iam.recovery.v1.RecoveryService.SendRecoveryEmail",
2123
- packageName: PACKAGE_NAME3,
2124
- url: resolveWixIamRecoveryV1RecoveryServiceUrl({
2125
- protoPath: "/v1/send-email",
2126
- data: payload,
2127
- host
2128
- }),
2129
- data: payload
2130
- };
2131
- return metadata;
2132
- }
2133
- return __sendRecoveryEmail;
2134
- }
2135
- function sendActivationEmail(payload) {
2136
- function __sendActivationEmail({ host }) {
2137
- const metadata = {
2138
- entityFqdn: "wix.iam.recovery.v1.recovery",
2139
- method: "POST",
2140
- methodFqn: "wix.iam.recovery.v1.RecoveryService.SendActivationEmail",
2141
- packageName: PACKAGE_NAME3,
2142
- url: resolveWixIamRecoveryV1RecoveryServiceUrl({
2143
- protoPath: "/v1/activation-email",
2144
- data: payload,
2145
- host
2146
- }),
2147
- data: payload
2148
- };
2149
- return metadata;
2150
- }
2151
- return __sendActivationEmail;
2152
- }
2153
- function recover(payload) {
2154
- function __recover({ host }) {
2155
- const metadata = {
2156
- entityFqdn: "wix.iam.recovery.v1.recovery",
2157
- method: "POST",
2158
- methodFqn: "wix.iam.recovery.v1.RecoveryService.Recover",
2159
- packageName: PACKAGE_NAME3,
2160
- url: resolveWixIamRecoveryV1RecoveryServiceUrl({
2161
- protoPath: "/v1/recover",
2162
- data: payload,
2163
- host
2164
- }),
2165
- data: payload,
2166
- transformResponse: (payload2) => transformPaths(payload2, [
2167
- {
2168
- transformFn: transformRESTTimestampToSDKTimestamp,
2169
- paths: [
2170
- { path: "identity.createdDate" },
2171
- { path: "identity.updatedDate" },
2172
- { path: "identity.identityProfile.customFields.value.dateValue" },
2173
- { path: "additionalData.*.dateValue" }
2174
- ]
2175
- },
2176
- {
2177
- transformFn: transformRESTFloatToSDKFloat,
2178
- paths: [
2179
- { path: "identity.identityProfile.customFields.value.numValue" },
2180
- { path: "additionalData.*.numValue" }
2181
- ]
2182
- }
2183
- ])
2184
- };
2185
- return metadata;
2186
- }
2187
- return __recover;
2188
- }
2189
-
2190
- // ../../node_modules/@wix/auto_sdk_identity_recovery/build/es/src/iam-recovery-v1-recovery-recovery.universal.js
2191
- var TenantType2;
2192
- (function(TenantType3) {
2193
- TenantType3["UNKNOWN_TENANT_TYPE"] = "UNKNOWN_TENANT_TYPE";
2194
- TenantType3["ACCOUNT"] = "ACCOUNT";
2195
- TenantType3["SITE"] = "SITE";
2196
- TenantType3["ROOT"] = "ROOT";
2197
- })(TenantType2 || (TenantType2 = {}));
2198
- var StateType2;
2199
- (function(StateType4) {
2200
- StateType4["UNKNOWN_STATE"] = "UNKNOWN_STATE";
2201
- StateType4["SUCCESS"] = "SUCCESS";
2202
- StateType4["REQUIRE_OWNER_APPROVAL"] = "REQUIRE_OWNER_APPROVAL";
2203
- StateType4["REQUIRE_EMAIL_VERIFICATION"] = "REQUIRE_EMAIL_VERIFICATION";
2204
- StateType4["STATUS_CHECK"] = "STATUS_CHECK";
2205
- })(StateType2 || (StateType2 = {}));
2206
- var PrivacyStatus2;
2207
- (function(PrivacyStatus4) {
2208
- PrivacyStatus4["UNDEFINED"] = "UNDEFINED";
2209
- PrivacyStatus4["PUBLIC"] = "PUBLIC";
2210
- PrivacyStatus4["PRIVATE"] = "PRIVATE";
2211
- })(PrivacyStatus2 || (PrivacyStatus2 = {}));
2212
- var EmailTag2;
2213
- (function(EmailTag4) {
2214
- EmailTag4["UNTAGGED"] = "UNTAGGED";
2215
- EmailTag4["MAIN"] = "MAIN";
2216
- EmailTag4["HOME"] = "HOME";
2217
- EmailTag4["WORK"] = "WORK";
2218
- })(EmailTag2 || (EmailTag2 = {}));
2219
- var PhoneTag2;
2220
- (function(PhoneTag4) {
2221
- PhoneTag4["UNTAGGED"] = "UNTAGGED";
2222
- PhoneTag4["MAIN"] = "MAIN";
2223
- PhoneTag4["HOME"] = "HOME";
2224
- PhoneTag4["MOBILE"] = "MOBILE";
2225
- PhoneTag4["WORK"] = "WORK";
2226
- PhoneTag4["FAX"] = "FAX";
2227
- })(PhoneTag2 || (PhoneTag2 = {}));
2228
- var AddressTag2;
2229
- (function(AddressTag4) {
2230
- AddressTag4["UNTAGGED"] = "UNTAGGED";
2231
- AddressTag4["HOME"] = "HOME";
2232
- AddressTag4["WORK"] = "WORK";
2233
- AddressTag4["BILLING"] = "BILLING";
2234
- AddressTag4["SHIPPING"] = "SHIPPING";
2235
- })(AddressTag2 || (AddressTag2 = {}));
2236
- var StatusName2;
2237
- (function(StatusName4) {
2238
- StatusName4["UNKNOWN_STATUS"] = "UNKNOWN_STATUS";
2239
- StatusName4["PENDING"] = "PENDING";
2240
- StatusName4["ACTIVE"] = "ACTIVE";
2241
- StatusName4["DELETED"] = "DELETED";
2242
- StatusName4["BLOCKED"] = "BLOCKED";
2243
- StatusName4["OFFLINE"] = "OFFLINE";
2244
- })(StatusName2 || (StatusName2 = {}));
2245
- var Reason2;
2246
- (function(Reason4) {
2247
- Reason4["UNKNOWN_REASON"] = "UNKNOWN_REASON";
2248
- Reason4["PENDING_ADMIN_APPROVAL_REQUIRED"] = "PENDING_ADMIN_APPROVAL_REQUIRED";
2249
- Reason4["PENDING_EMAIL_VERIFICATION_REQUIRED"] = "PENDING_EMAIL_VERIFICATION_REQUIRED";
2250
- })(Reason2 || (Reason2 = {}));
2251
- var FactorType2;
2252
- (function(FactorType4) {
2253
- FactorType4["UNKNOWN_FACTOR_TYPE"] = "UNKNOWN_FACTOR_TYPE";
2254
- FactorType4["PASSWORD"] = "PASSWORD";
2255
- FactorType4["SMS"] = "SMS";
2256
- FactorType4["CALL"] = "CALL";
2257
- FactorType4["EMAIL"] = "EMAIL";
2258
- FactorType4["TOTP"] = "TOTP";
2259
- FactorType4["PUSH"] = "PUSH";
2260
- })(FactorType2 || (FactorType2 = {}));
2261
- var Status3;
2262
- (function(Status5) {
2263
- Status5["INACTIVE"] = "INACTIVE";
2264
- Status5["ACTIVE"] = "ACTIVE";
2265
- Status5["REQUIRE_REENROLL"] = "REQUIRE_REENROLL";
2266
- })(Status3 || (Status3 = {}));
2267
- var FactorStatus2;
2268
- (function(FactorStatus4) {
2269
- FactorStatus4["UNKNOWN_FACTOR_STATUS"] = "UNKNOWN_FACTOR_STATUS";
2270
- FactorStatus4["ENABLED"] = "ENABLED";
2271
- FactorStatus4["REQUIRE_ACTIVATION"] = "REQUIRE_ACTIVATION";
2272
- FactorStatus4["REQUIRE_REENROLL"] = "REQUIRE_REENROLL";
2273
- FactorStatus4["ENABLED_BY_RULE"] = "ENABLED_BY_RULE";
2274
- FactorStatus4["DISABLED_BY_RULE"] = "DISABLED_BY_RULE";
2275
- })(FactorStatus2 || (FactorStatus2 = {}));
2276
- var MfaReason2;
2277
- (function(MfaReason4) {
2278
- MfaReason4["UNKNOWN_MFA_REASON"] = "UNKNOWN_MFA_REASON";
2279
- MfaReason4["USER_SETTINGS"] = "USER_SETTINGS";
2280
- MfaReason4["HIGH_RISK_LOGIN"] = "HIGH_RISK_LOGIN";
2281
- })(MfaReason2 || (MfaReason2 = {}));
2282
- async function sendRecoveryEmail2(email, options) {
2283
- const { httpClient, sideEffects } = arguments[2];
2284
- const payload = renameKeysFromSDKRequestToRESTRequest({
2285
- email,
2286
- language: options?.language,
2287
- redirect: options?.redirect
2288
- });
2289
- const reqOpts = sendRecoveryEmail(payload);
2290
- sideEffects?.onSiteCall?.();
2291
- try {
2292
- const result = await httpClient.request(reqOpts);
2293
- sideEffects?.onSuccess?.(result);
2294
- } catch (err) {
2295
- const transformedError = transformError(err, {
2296
- spreadPathsToArguments: {},
2297
- explicitPathsToArguments: {
2298
- email: "$[0]",
2299
- language: "$[1].language",
2300
- redirect: "$[1].redirect"
2301
- },
2302
- singleArgumentUnchanged: false
2303
- }, ["email", "options"]);
2304
- sideEffects?.onError?.(err);
2305
- throw transformedError;
2306
- }
2307
- }
2308
- async function sendActivationEmail2(identityId, options) {
2309
- const { httpClient, sideEffects } = arguments[2];
2310
- const payload = renameKeysFromSDKRequestToRESTRequest({
2311
- identityId,
2312
- emailOptions: options?.emailOptions
2313
- });
2314
- const reqOpts = sendActivationEmail(payload);
2315
- sideEffects?.onSiteCall?.();
2316
- try {
2317
- const result = await httpClient.request(reqOpts);
2318
- sideEffects?.onSuccess?.(result);
2319
- } catch (err) {
2320
- const transformedError = transformError(err, {
2321
- spreadPathsToArguments: {},
2322
- explicitPathsToArguments: {
2323
- identityId: "$[0]",
2324
- emailOptions: "$[1].emailOptions"
2325
- },
2326
- singleArgumentUnchanged: false
2327
- }, ["identityId", "options"]);
2328
- sideEffects?.onError?.(err);
2329
- throw transformedError;
2330
- }
2331
- }
2332
- async function recover2(recoveryToken, options) {
2333
- const { httpClient, sideEffects } = arguments[2];
2334
- const payload = renameKeysFromSDKRequestToRESTRequest({
2335
- recoveryToken,
2336
- password: options?.password
2337
- });
2338
- const reqOpts = recover(payload);
2339
- sideEffects?.onSiteCall?.();
2340
- try {
2341
- const result = await httpClient.request(reqOpts);
2342
- sideEffects?.onSuccess?.(result);
2343
- return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
2344
- {
2345
- transformFn: transformRESTAddressToSDKAddress,
2346
- paths: [{ path: "identity.identityProfile.addresses.address" }]
2347
- }
2348
- ]));
2349
- } catch (err) {
2350
- const transformedError = transformError(err, {
2351
- spreadPathsToArguments: {},
2352
- explicitPathsToArguments: {
2353
- recoveryToken: "$[0]",
2354
- password: "$[1].password"
2355
- },
2356
- singleArgumentUnchanged: false
2357
- }, ["recoveryToken", "options"]);
2358
- sideEffects?.onError?.(err);
2359
- throw transformedError;
2360
- }
2361
- }
2362
-
2363
- // ../../node_modules/@wix/auto_sdk_identity_recovery/build/es/src/iam-recovery-v1-recovery-recovery.public.js
2364
- function sendRecoveryEmail3(httpClient) {
2365
- return (email, options) => sendRecoveryEmail2(
2366
- email,
2367
- options,
2368
- // @ts-ignore
2369
- { httpClient }
2370
- );
2371
- }
2372
- function sendActivationEmail3(httpClient) {
2373
- return (identityId, options) => sendActivationEmail2(
2374
- identityId,
2375
- options,
2376
- // @ts-ignore
2377
- { httpClient }
2378
- );
2379
- }
2380
- function recover3(httpClient) {
2381
- return (recoveryToken, options) => recover2(
2382
- recoveryToken,
2383
- options,
2384
- // @ts-ignore
2385
- { httpClient }
2386
- );
2387
- }
2388
-
2389
- // ../../node_modules/@wix/auto_sdk_identity_recovery/build/es/src/iam-recovery-v1-recovery-recovery.context.js
2390
- var sendRecoveryEmail4 = /* @__PURE__ */ createRESTModule(sendRecoveryEmail3);
2391
- var sendActivationEmail4 = /* @__PURE__ */ createRESTModule(sendActivationEmail3);
2392
- var recover4 = /* @__PURE__ */ createRESTModule(recover3);
2393
-
2394
- // ../../node_modules/@wix/auto_sdk_identity_verification/build/es/index.js
2395
- var es_exports4 = {};
2396
- __export(es_exports4, {
2397
- AddressTag: () => AddressTag3,
2398
- EmailTag: () => EmailTag3,
2399
- FactorStatus: () => FactorStatus3,
2400
- FactorType: () => FactorType3,
2401
- MfaReason: () => MfaReason3,
2402
- PhoneTag: () => PhoneTag3,
2403
- PrivacyStatus: () => PrivacyStatus3,
2404
- Reason: () => Reason3,
2405
- StateType: () => StateType3,
2406
- Status: () => Status4,
2407
- StatusName: () => StatusName3,
2408
- Target: () => Target,
2409
- resendDuringAuthentication: () => resendDuringAuthentication4,
2410
- start: () => start4,
2411
- verifyDuringAuthentication: () => verifyDuringAuthentication4
2412
- });
2413
-
2414
- // ../../node_modules/@wix/auto_sdk_identity_verification/build/es/src/iam-verification-v1-start-response-verification.http.js
2415
- function resolveWixIamVerificationV1VerificationServiceUrl(opts) {
2416
- const domainToMappings = {
2417
- "www.wixapis.com": [
2418
- {
2419
- srcPath: "/_api/iam/verification",
2420
- destPath: ""
2421
- }
2422
- ],
2423
- _: [
2424
- {
2425
- srcPath: "/_api/iam/verification",
2426
- destPath: ""
2427
- }
2428
- ],
2429
- "www._base_domain_": [
2430
- {
2431
- srcPath: "/_api/iam/verification",
2432
- destPath: ""
2433
- }
2434
- ]
2435
- };
2436
- return resolveUrl(Object.assign(opts, { domainToMappings }));
2437
- }
2438
- var PACKAGE_NAME4 = "@wix/auto_sdk_identity_verification";
2439
- function start(payload) {
2440
- function __start({ host }) {
2441
- const metadata = {
2442
- entityFqdn: "wix.iam.verification.v1.start_response",
2443
- method: "POST",
2444
- methodFqn: "wix.iam.verification.v1.VerificationService.Start",
2445
- packageName: PACKAGE_NAME4,
2446
- url: resolveWixIamVerificationV1VerificationServiceUrl({
2447
- protoPath: "/v1/Start",
2448
- data: payload,
2449
- host
2450
- }),
2451
- data: payload
2452
- };
2453
- return metadata;
2454
- }
2455
- return __start;
2456
- }
2457
- function verifyDuringAuthentication(payload) {
2458
- function __verifyDuringAuthentication({ host }) {
2459
- const metadata = {
2460
- entityFqdn: "wix.iam.verification.v1.start_response",
2461
- method: "POST",
2462
- methodFqn: "wix.iam.verification.v1.VerificationService.VerifyDuringAuthentication",
2463
- packageName: PACKAGE_NAME4,
2464
- url: resolveWixIamVerificationV1VerificationServiceUrl({
2465
- protoPath: "/v1/auth/verify",
2466
- data: payload,
2467
- host
2468
- }),
2469
- data: payload,
2470
- transformResponse: (payload2) => transformPaths(payload2, [
2471
- {
2472
- transformFn: transformRESTTimestampToSDKTimestamp,
2473
- paths: [
2474
- { path: "identity.createdDate" },
2475
- { path: "identity.updatedDate" },
2476
- { path: "identity.identityProfile.customFields.value.dateValue" },
2477
- { path: "additionalData.*.dateValue" }
2478
- ]
2479
- },
2480
- {
2481
- transformFn: transformRESTFloatToSDKFloat,
2482
- paths: [
2483
- { path: "identity.identityProfile.customFields.value.numValue" },
2484
- { path: "additionalData.*.numValue" }
2485
- ]
2486
- }
2487
- ])
2488
- };
2489
- return metadata;
2490
- }
2491
- return __verifyDuringAuthentication;
2492
- }
2493
- function resendDuringAuthentication(payload) {
2494
- function __resendDuringAuthentication({ host }) {
2495
- const metadata = {
2496
- entityFqdn: "wix.iam.verification.v1.start_response",
2497
- method: "POST",
2498
- methodFqn: "wix.iam.verification.v1.VerificationService.ResendDuringAuthentication",
2499
- packageName: PACKAGE_NAME4,
2500
- url: resolveWixIamVerificationV1VerificationServiceUrl({
2501
- protoPath: "/v1/auth/resend",
2502
- data: payload,
2503
- host
2504
- }),
2505
- data: payload,
2506
- transformResponse: (payload2) => transformPaths(payload2, [
2507
- {
2508
- transformFn: transformRESTTimestampToSDKTimestamp,
2509
- paths: [
2510
- { path: "identity.createdDate" },
2511
- { path: "identity.updatedDate" },
2512
- { path: "identity.identityProfile.customFields.value.dateValue" },
2513
- { path: "additionalData.*.dateValue" }
2514
- ]
2515
- },
2516
- {
2517
- transformFn: transformRESTFloatToSDKFloat,
2518
- paths: [
2519
- { path: "identity.identityProfile.customFields.value.numValue" },
2520
- { path: "additionalData.*.numValue" }
2521
- ]
2522
- }
2523
- ])
2524
- };
2525
- return metadata;
2526
- }
2527
- return __resendDuringAuthentication;
2528
- }
2529
-
2530
- // ../../node_modules/@wix/auto_sdk_identity_verification/build/es/src/iam-verification-v1-start-response-verification.universal.js
2531
- var Target;
2532
- (function(Target2) {
2533
- Target2["UNKNOWN_TARGET"] = "UNKNOWN_TARGET";
2534
- Target2["EMAIL"] = "EMAIL";
2535
- })(Target || (Target = {}));
2536
- var StateType3;
2537
- (function(StateType4) {
2538
- StateType4["UNKNOWN_STATE"] = "UNKNOWN_STATE";
2539
- StateType4["SUCCESS"] = "SUCCESS";
2540
- StateType4["REQUIRE_OWNER_APPROVAL"] = "REQUIRE_OWNER_APPROVAL";
2541
- StateType4["REQUIRE_EMAIL_VERIFICATION"] = "REQUIRE_EMAIL_VERIFICATION";
2542
- StateType4["STATUS_CHECK"] = "STATUS_CHECK";
2543
- })(StateType3 || (StateType3 = {}));
2544
- var PrivacyStatus3;
2545
- (function(PrivacyStatus4) {
2546
- PrivacyStatus4["UNDEFINED"] = "UNDEFINED";
2547
- PrivacyStatus4["PUBLIC"] = "PUBLIC";
2548
- PrivacyStatus4["PRIVATE"] = "PRIVATE";
2549
- })(PrivacyStatus3 || (PrivacyStatus3 = {}));
2550
- var EmailTag3;
2551
- (function(EmailTag4) {
2552
- EmailTag4["UNTAGGED"] = "UNTAGGED";
2553
- EmailTag4["MAIN"] = "MAIN";
2554
- EmailTag4["HOME"] = "HOME";
2555
- EmailTag4["WORK"] = "WORK";
2556
- })(EmailTag3 || (EmailTag3 = {}));
2557
- var PhoneTag3;
2558
- (function(PhoneTag4) {
2559
- PhoneTag4["UNTAGGED"] = "UNTAGGED";
2560
- PhoneTag4["MAIN"] = "MAIN";
2561
- PhoneTag4["HOME"] = "HOME";
2562
- PhoneTag4["MOBILE"] = "MOBILE";
2563
- PhoneTag4["WORK"] = "WORK";
2564
- PhoneTag4["FAX"] = "FAX";
2565
- })(PhoneTag3 || (PhoneTag3 = {}));
2566
- var AddressTag3;
2567
- (function(AddressTag4) {
2568
- AddressTag4["UNTAGGED"] = "UNTAGGED";
2569
- AddressTag4["HOME"] = "HOME";
2570
- AddressTag4["WORK"] = "WORK";
2571
- AddressTag4["BILLING"] = "BILLING";
2572
- AddressTag4["SHIPPING"] = "SHIPPING";
2573
- })(AddressTag3 || (AddressTag3 = {}));
2574
- var StatusName3;
2575
- (function(StatusName4) {
2576
- StatusName4["UNKNOWN_STATUS"] = "UNKNOWN_STATUS";
2577
- StatusName4["PENDING"] = "PENDING";
2578
- StatusName4["ACTIVE"] = "ACTIVE";
2579
- StatusName4["DELETED"] = "DELETED";
2580
- StatusName4["BLOCKED"] = "BLOCKED";
2581
- StatusName4["OFFLINE"] = "OFFLINE";
2582
- })(StatusName3 || (StatusName3 = {}));
2583
- var Reason3;
2584
- (function(Reason4) {
2585
- Reason4["UNKNOWN_REASON"] = "UNKNOWN_REASON";
2586
- Reason4["PENDING_ADMIN_APPROVAL_REQUIRED"] = "PENDING_ADMIN_APPROVAL_REQUIRED";
2587
- Reason4["PENDING_EMAIL_VERIFICATION_REQUIRED"] = "PENDING_EMAIL_VERIFICATION_REQUIRED";
2588
- })(Reason3 || (Reason3 = {}));
2589
- var FactorType3;
2590
- (function(FactorType4) {
2591
- FactorType4["UNKNOWN_FACTOR_TYPE"] = "UNKNOWN_FACTOR_TYPE";
2592
- FactorType4["PASSWORD"] = "PASSWORD";
2593
- FactorType4["SMS"] = "SMS";
2594
- FactorType4["CALL"] = "CALL";
2595
- FactorType4["EMAIL"] = "EMAIL";
2596
- FactorType4["TOTP"] = "TOTP";
2597
- FactorType4["PUSH"] = "PUSH";
2598
- })(FactorType3 || (FactorType3 = {}));
2599
- var Status4;
2600
- (function(Status5) {
2601
- Status5["INACTIVE"] = "INACTIVE";
2602
- Status5["ACTIVE"] = "ACTIVE";
2603
- Status5["REQUIRE_REENROLL"] = "REQUIRE_REENROLL";
2604
- })(Status4 || (Status4 = {}));
2605
- var FactorStatus3;
2606
- (function(FactorStatus4) {
2607
- FactorStatus4["UNKNOWN_FACTOR_STATUS"] = "UNKNOWN_FACTOR_STATUS";
2608
- FactorStatus4["ENABLED"] = "ENABLED";
2609
- FactorStatus4["REQUIRE_ACTIVATION"] = "REQUIRE_ACTIVATION";
2610
- FactorStatus4["REQUIRE_REENROLL"] = "REQUIRE_REENROLL";
2611
- FactorStatus4["ENABLED_BY_RULE"] = "ENABLED_BY_RULE";
2612
- FactorStatus4["DISABLED_BY_RULE"] = "DISABLED_BY_RULE";
2613
- })(FactorStatus3 || (FactorStatus3 = {}));
2614
- var MfaReason3;
2615
- (function(MfaReason4) {
2616
- MfaReason4["UNKNOWN_MFA_REASON"] = "UNKNOWN_MFA_REASON";
2617
- MfaReason4["USER_SETTINGS"] = "USER_SETTINGS";
2618
- MfaReason4["HIGH_RISK_LOGIN"] = "HIGH_RISK_LOGIN";
2619
- })(MfaReason3 || (MfaReason3 = {}));
2620
- async function start2(options) {
2621
- const { httpClient, sideEffects } = arguments[1];
2622
- const payload = renameKeysFromSDKRequestToRESTRequest({
2623
- identityId: options?.identityId,
2624
- target: options?.target
2625
- });
2626
- const reqOpts = start(payload);
2627
- sideEffects?.onSiteCall?.();
2628
- try {
2629
- const result = await httpClient.request(reqOpts);
2630
- sideEffects?.onSuccess?.(result);
2631
- return renameKeysFromRESTResponseToSDKResponse(result.data);
2632
- } catch (err) {
2633
- const transformedError = transformError(err, {
2634
- spreadPathsToArguments: {},
2635
- explicitPathsToArguments: {
2636
- identityId: "$[0].identityId",
2637
- target: "$[0].target"
2638
- },
2639
- singleArgumentUnchanged: false
2640
- }, ["options"]);
2641
- sideEffects?.onError?.(err);
2642
- throw transformedError;
2643
- }
2644
- }
2645
- async function verifyDuringAuthentication2(code, options) {
2646
- const { httpClient, sideEffects } = arguments[2];
2647
- const payload = renameKeysFromSDKRequestToRESTRequest({
2648
- code,
2649
- stateToken: options?.stateToken
2650
- });
2651
- const reqOpts = verifyDuringAuthentication(payload);
2652
- sideEffects?.onSiteCall?.();
2653
- try {
2654
- const result = await httpClient.request(reqOpts);
2655
- sideEffects?.onSuccess?.(result);
2656
- return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
2657
- {
2658
- transformFn: transformRESTAddressToSDKAddress,
2659
- paths: [{ path: "identity.identityProfile.addresses.address" }]
2660
- }
2661
- ]));
2662
- } catch (err) {
2663
- const transformedError = transformError(err, {
2664
- spreadPathsToArguments: {},
2665
- explicitPathsToArguments: {
2666
- code: "$[0]",
2667
- stateToken: "$[1].stateToken"
2668
- },
2669
- singleArgumentUnchanged: false
2670
- }, ["code", "options"]);
2671
- sideEffects?.onError?.(err);
2672
- throw transformedError;
2673
- }
2674
- }
2675
- async function resendDuringAuthentication2(stateToken) {
2676
- const { httpClient, sideEffects } = arguments[1];
2677
- const payload = renameKeysFromSDKRequestToRESTRequest({
2678
- stateToken
2679
- });
2680
- const reqOpts = resendDuringAuthentication(payload);
2681
- sideEffects?.onSiteCall?.();
2682
- try {
2683
- const result = await httpClient.request(reqOpts);
2684
- sideEffects?.onSuccess?.(result);
2685
- return renameKeysFromRESTResponseToSDKResponse(transformPaths(result.data, [
2686
- {
2687
- transformFn: transformRESTAddressToSDKAddress,
2688
- paths: [{ path: "identity.identityProfile.addresses.address" }]
2689
- }
2690
- ]));
2691
- } catch (err) {
2692
- const transformedError = transformError(err, {
2693
- spreadPathsToArguments: {},
2694
- explicitPathsToArguments: { stateToken: "$[0]" },
2695
- singleArgumentUnchanged: false
2696
- }, ["stateToken"]);
2697
- sideEffects?.onError?.(err);
2698
- throw transformedError;
2699
- }
2700
- }
2701
-
2702
- // ../../node_modules/@wix/auto_sdk_identity_verification/build/es/src/iam-verification-v1-start-response-verification.public.js
2703
- function start3(httpClient) {
2704
- return (options) => start2(
2705
- options,
2706
- // @ts-ignore
2707
- { httpClient }
2708
- );
2709
- }
2710
- function verifyDuringAuthentication3(httpClient) {
2711
- return (code, options) => verifyDuringAuthentication2(
2712
- code,
2713
- options,
2714
- // @ts-ignore
2715
- { httpClient }
2716
- );
2717
- }
2718
- function resendDuringAuthentication3(httpClient) {
2719
- return (stateToken) => resendDuringAuthentication2(
2720
- stateToken,
2721
- // @ts-ignore
2722
- { httpClient }
2723
- );
2724
- }
2725
-
2726
- // ../../node_modules/@wix/auto_sdk_identity_verification/build/es/src/iam-verification-v1-start-response-verification.context.js
2727
- var start4 = /* @__PURE__ */ createRESTModule(start3);
2728
- var verifyDuringAuthentication4 = /* @__PURE__ */ createRESTModule(verifyDuringAuthentication3);
2729
- var resendDuringAuthentication4 = /* @__PURE__ */ createRESTModule(resendDuringAuthentication3);
2730
-
2731
- // ../../node_modules/@wix/auto_sdk_identity_oauth/build/es/src/identity-oauth-v1-refresh-token-oauth.universal.js
2732
- var SubjectType;
2733
- (function(SubjectType2) {
2734
- SubjectType2["UNKNOWN"] = "UNKNOWN";
2735
- SubjectType2["USER"] = "USER";
2736
- SubjectType2["VISITOR"] = "VISITOR";
2737
- SubjectType2["MEMBER"] = "MEMBER";
2738
- SubjectType2["APP"] = "APP";
2739
- })(SubjectType || (SubjectType = {}));
2740
-
2741
- // ../../node_modules/@wix/sdk/build/auth/oauth2/types.js
2742
- var LoginState;
2743
- (function(LoginState2) {
2744
- LoginState2["SUCCESS"] = "SUCCESS";
2745
- LoginState2["INITIAL"] = "INITIAL";
2746
- LoginState2["FAILURE"] = "FAILURE";
2747
- LoginState2["EMAIL_VERIFICATION_REQUIRED"] = "EMAIL_VERIFICATION_REQUIRED";
2748
- LoginState2["OWNER_APPROVAL_REQUIRED"] = "OWNER_APPROVAL_REQUIRED";
2749
- LoginState2["USER_CAPTCHA_REQUIRED"] = "USER_CAPTCHA_REQUIRED";
2750
- LoginState2["SILENT_CAPTCHA_REQUIRED"] = "SILENT_CAPTCHA_REQUIRED";
2751
- })(LoginState || (LoginState = {}));
2752
- var TokenRole;
2753
- (function(TokenRole2) {
2754
- TokenRole2["NONE"] = "none";
2755
- TokenRole2["VISITOR"] = "visitor";
2756
- TokenRole2["MEMBER"] = "member";
2757
- })(TokenRole || (TokenRole = {}));
2758
-
2759
- // ../../node_modules/@wix/sdk/build/iframeUtils.js
2760
- function addListener(eventTarget, name, fn) {
2761
- if (eventTarget.addEventListener) {
2762
- eventTarget.addEventListener(name, fn);
2763
- } else {
2764
- eventTarget.attachEvent("on" + name, fn);
2765
- }
2766
- }
2767
- function removeListener(eventTarget, name, fn) {
2768
- if (eventTarget.removeEventListener) {
2769
- eventTarget.removeEventListener(name, fn);
2770
- } else {
2771
- eventTarget.detachEvent("on" + name, fn);
2772
- }
2773
- }
2774
- function loadFrame(src) {
2775
- const iframe = document.createElement("iframe");
2776
- iframe.style.display = "none";
2777
- iframe.src = src;
2778
- return document.body.appendChild(iframe);
2779
- }
2780
- function addPostMessageListener(state) {
2781
- let responseHandler;
2782
- let timeoutId;
2783
- const msgReceivedOrTimeout = new Promise((resolve, reject) => {
2784
- responseHandler = (e) => {
2785
- if (!e.data || e.data.state !== state) {
2786
- return;
2787
- }
2788
- resolve(e.data);
2789
- };
2790
- addListener(window, "message", responseHandler);
2791
- timeoutId = setTimeout(() => {
2792
- reject(new Error("OAuth flow timed out"));
2793
- }, 12e4);
2794
- });
2795
- return msgReceivedOrTimeout.finally(() => {
2796
- clearTimeout(timeoutId);
2797
- removeListener(window, "message", responseHandler);
2798
- });
2799
- }
2800
-
2801
- // ../../node_modules/@wix/sdk/build/auth/oauth2/constants.js
2802
- var MISSING_CAPTCHA = "-19971";
2803
- var INVALID_CAPTCHA = "-19970";
2804
- var EMAIL_EXISTS = "-19995";
2805
- var INVALID_PASSWORD = "-19976";
2806
- var RESET_PASSWORD = "-19973";
2807
-
2808
- // ../../node_modules/@wix/sdk/build/auth/oauth2/sha256.js
2809
- var SHIFT = [24, 16, 8, 0];
2810
- var EXTRA = [-2147483648, 8388608, 32768, 128];
2811
- var K = [
2812
- 1116352408,
2813
- 1899447441,
2814
- 3049323471,
2815
- 3921009573,
2816
- 961987163,
2817
- 1508970993,
2818
- 2453635748,
2819
- 2870763221,
2820
- 3624381080,
2821
- 310598401,
2822
- 607225278,
2823
- 1426881987,
2824
- 1925078388,
2825
- 2162078206,
2826
- 2614888103,
2827
- 3248222580,
2828
- 3835390401,
2829
- 4022224774,
2830
- 264347078,
2831
- 604807628,
2832
- 770255983,
2833
- 1249150122,
2834
- 1555081692,
2835
- 1996064986,
2836
- 2554220882,
2837
- 2821834349,
2838
- 2952996808,
2839
- 3210313671,
2840
- 3336571891,
2841
- 3584528711,
2842
- 113926993,
2843
- 338241895,
2844
- 666307205,
2845
- 773529912,
2846
- 1294757372,
2847
- 1396182291,
2848
- 1695183700,
2849
- 1986661051,
2850
- 2177026350,
2851
- 2456956037,
2852
- 2730485921,
2853
- 2820302411,
2854
- 3259730800,
2855
- 3345764771,
2856
- 3516065817,
2857
- 3600352804,
2858
- 4094571909,
2859
- 275423344,
2860
- 430227734,
2861
- 506948616,
2862
- 659060556,
2863
- 883997877,
2864
- 958139571,
2865
- 1322822218,
2866
- 1537002063,
2867
- 1747873779,
2868
- 1955562222,
2869
- 2024104815,
2870
- 2227730452,
2871
- 2361852424,
2872
- 2428436474,
2873
- 2756734187,
2874
- 3204031479,
2875
- 3329325298
2876
- ];
2877
- var SHA256 = class {
2878
- blocks;
2879
- h0;
2880
- h1;
2881
- h2;
2882
- h3;
2883
- h4;
2884
- h5;
2885
- h6;
2886
- h7;
2887
- block;
2888
- start;
2889
- bytes;
2890
- hBytes;
2891
- finalized;
2892
- hashed;
2893
- first;
2894
- lastByteIndex;
2895
- chromeBugWorkAround;
2896
- constructor() {
2897
- this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
2898
- this.h0 = 1779033703;
2899
- this.h1 = 3144134277;
2900
- this.h2 = 1013904242;
2901
- this.h3 = 2773480762;
2902
- this.h4 = 1359893119;
2903
- this.h5 = 2600822924;
2904
- this.h6 = 528734635;
2905
- this.h7 = 1541459225;
2906
- this.block = this.start = this.bytes = this.hBytes = 0;
2907
- this.finalized = this.hashed = false;
2908
- this.first = true;
2909
- }
2910
- update(message) {
2911
- const blocks = this.blocks;
2912
- const length = message.length;
2913
- let code, index = 0, i;
2914
- while (index < length) {
2915
- if (this.hashed) {
2916
- this.hashed = false;
2917
- blocks[0] = this.block;
2918
- this.block = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
2919
- }
2920
- for (i = this.start; index < length && i < 64; ++index) {
2921
- code = message.charCodeAt(index);
2922
- if (code < 128) {
2923
- blocks[i >>> 2] |= code << SHIFT[i++ & 3];
2924
- } else if (code < 2048) {
2925
- blocks[i >>> 2] |= (192 | code >>> 6) << SHIFT[i++ & 3];
2926
- blocks[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
2927
- } else if (code < 55296 || code >= 57344) {
2928
- blocks[i >>> 2] |= (224 | code >>> 12) << SHIFT[i++ & 3];
2929
- blocks[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
2930
- blocks[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
2931
- } else {
2932
- code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023);
2933
- blocks[i >>> 2] |= (240 | code >>> 18) << SHIFT[i++ & 3];
2934
- blocks[i >>> 2] |= (128 | code >>> 12 & 63) << SHIFT[i++ & 3];
2935
- blocks[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3];
2936
- blocks[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3];
2937
- }
2938
- }
2939
- this.lastByteIndex = i;
2940
- this.bytes += i - this.start;
2941
- if (i >= 64) {
2942
- this.block = blocks[16];
2943
- this.start = i - 64;
2944
- this.hash();
2945
- this.hashed = true;
2946
- } else {
2947
- this.start = i;
2948
- }
2949
- }
2950
- if (this.bytes > 4294967295) {
2951
- this.hBytes += this.bytes / 4294967296 << 0;
2952
- this.bytes = this.bytes % 4294967296;
2953
- }
2954
- return this;
2955
- }
2956
- hash() {
2957
- const blocks = this.blocks;
2958
- let a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, h = this.h7, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
2959
- for (j = 16; j < 64; ++j) {
2960
- t1 = blocks[j - 15];
2961
- s0 = (t1 >>> 7 | t1 << 25) ^ (t1 >>> 18 | t1 << 14) ^ t1 >>> 3;
2962
- t1 = blocks[j - 2];
2963
- s1 = (t1 >>> 17 | t1 << 15) ^ (t1 >>> 19 | t1 << 13) ^ t1 >>> 10;
2964
- blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0;
2965
- }
2966
- bc = b & c;
2967
- for (j = 0; j < 64; j += 4) {
2968
- if (this.first) {
2969
- ab = 704751109;
2970
- t1 = blocks[0] - 210244248;
2971
- h = t1 - 1521486534 << 0;
2972
- d = t1 + 143694565 << 0;
2973
- this.first = false;
2974
- } else {
2975
- s0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10);
2976
- s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7);
2977
- ab = a & b;
2978
- maj = ab ^ a & c ^ bc;
2979
- ch = e & f ^ ~e & g;
2980
- t1 = h + s1 + ch + K[j] + blocks[j];
2981
- t2 = s0 + maj;
2982
- h = d + t1 << 0;
2983
- d = t1 + t2 << 0;
2984
- }
2985
- s0 = (d >>> 2 | d << 30) ^ (d >>> 13 | d << 19) ^ (d >>> 22 | d << 10);
2986
- s1 = (h >>> 6 | h << 26) ^ (h >>> 11 | h << 21) ^ (h >>> 25 | h << 7);
2987
- da = d & a;
2988
- maj = da ^ d & b ^ ab;
2989
- ch = h & e ^ ~h & f;
2990
- t1 = g + s1 + ch + K[j + 1] + blocks[j + 1];
2991
- t2 = s0 + maj;
2992
- g = c + t1 << 0;
2993
- c = t1 + t2 << 0;
2994
- s0 = (c >>> 2 | c << 30) ^ (c >>> 13 | c << 19) ^ (c >>> 22 | c << 10);
2995
- s1 = (g >>> 6 | g << 26) ^ (g >>> 11 | g << 21) ^ (g >>> 25 | g << 7);
2996
- cd = c & d;
2997
- maj = cd ^ c & a ^ da;
2998
- ch = g & h ^ ~g & e;
2999
- t1 = f + s1 + ch + K[j + 2] + blocks[j + 2];
3000
- t2 = s0 + maj;
3001
- f = b + t1 << 0;
3002
- b = t1 + t2 << 0;
3003
- s0 = (b >>> 2 | b << 30) ^ (b >>> 13 | b << 19) ^ (b >>> 22 | b << 10);
3004
- s1 = (f >>> 6 | f << 26) ^ (f >>> 11 | f << 21) ^ (f >>> 25 | f << 7);
3005
- bc = b & c;
3006
- maj = bc ^ b & d ^ cd;
3007
- ch = f & g ^ ~f & h;
3008
- t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];
3009
- t2 = s0 + maj;
3010
- e = a + t1 << 0;
3011
- a = t1 + t2 << 0;
3012
- this.chromeBugWorkAround = true;
3013
- }
3014
- this.h0 = this.h0 + a << 0;
3015
- this.h1 = this.h1 + b << 0;
3016
- this.h2 = this.h2 + c << 0;
3017
- this.h3 = this.h3 + d << 0;
3018
- this.h4 = this.h4 + e << 0;
3019
- this.h5 = this.h5 + f << 0;
3020
- this.h6 = this.h6 + g << 0;
3021
- this.h7 = this.h7 + h << 0;
3022
- }
3023
- finalize() {
3024
- if (this.finalized) {
3025
- return;
3026
- }
3027
- this.finalized = true;
3028
- const blocks = this.blocks, i = this.lastByteIndex;
3029
- blocks[16] = this.block;
3030
- blocks[i >>> 2] |= EXTRA[i & 3];
3031
- this.block = blocks[16];
3032
- if (i >= 56) {
3033
- if (!this.hashed) {
3034
- this.hash();
3035
- }
3036
- blocks[0] = this.block;
3037
- blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
3038
- }
3039
- blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
3040
- blocks[15] = this.bytes << 3;
3041
- this.hash();
3042
- }
3043
- arrayBuffer() {
3044
- this.finalize();
3045
- const buffer = new ArrayBuffer(32);
3046
- const dataView = new DataView(buffer);
3047
- dataView.setUint32(0, this.h0);
3048
- dataView.setUint32(4, this.h1);
3049
- dataView.setUint32(8, this.h2);
3050
- dataView.setUint32(12, this.h3);
3051
- dataView.setUint32(16, this.h4);
3052
- dataView.setUint32(20, this.h5);
3053
- dataView.setUint32(24, this.h6);
3054
- dataView.setUint32(28, this.h7);
3055
- return buffer;
3056
- }
3057
- };
3058
- function sha256(message) {
3059
- return new SHA256().update(message).arrayBuffer();
3060
- }
3061
-
3062
- // ../../node_modules/@wix/sdk/build/auth/oauth2/pkce-challenge.js
3063
- function pkceChallenge(length) {
3064
- if (!length) {
3065
- length = 43;
3066
- }
3067
- if (length < 43 || length > 128) {
3068
- throw new Error(`Expected a length between 43 and 128. Received ${length}.`);
3069
- }
3070
- const verifier = generateVerifier(length);
3071
- const challenge = generateChallenge(verifier);
3072
- return {
3073
- code_verifier: verifier,
3074
- code_challenge: challenge
3075
- };
3076
- }
3077
- function generateVerifier(length) {
3078
- return random(length);
3079
- }
3080
- function generateChallenge(code_verifier) {
3081
- return base64urlencode(sha256(code_verifier));
3082
- }
3083
- function random(size) {
3084
- const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
3085
- let result = "";
3086
- const randomUints = crypto.getRandomValues(new Uint8Array(size));
3087
- for (let i = 0; i < size; i++) {
3088
- const randomIndex = randomUints[i] % mask.length;
3089
- result += mask[randomIndex];
3090
- }
3091
- return result;
3092
- }
3093
- function base64urlencode(str) {
3094
- const base64 = typeof Buffer === "undefined" ? btoa(ab2str(str)) : Buffer.from(str).toString("base64");
3095
- return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
3096
- }
3097
- function ab2str(buf) {
3098
- return String.fromCharCode.apply(null, Array.from(new Uint8Array(buf)));
3099
- }
3100
-
3101
- // ../../node_modules/@wix/sdk/build/auth/oauth2/OAuthStrategy.js
3102
- var moduleWithTokens = { redirects: es_exports, authentication: es_exports2, recovery: es_exports3, verification: es_exports4 };
3103
- function OAuthStrategy(config) {
3104
- const _tokens = config.tokens || {
3105
- accessToken: { value: "", expiresAt: 0 },
3106
- refreshToken: { value: "", role: TokenRole.NONE }
3107
- };
3108
- const setTokens = (tokens) => {
3109
- _tokens.accessToken = tokens.accessToken;
3110
- _tokens.refreshToken = tokens.refreshToken;
3111
- };
3112
- let _state = {
3113
- loginState: LoginState.INITIAL
3114
- };
3115
- const getAuthHeaders = async () => {
3116
- if (!_tokens.accessToken?.value || isTokenExpired(_tokens.accessToken)) {
3117
- const tokens = await generateVisitorTokens({
3118
- refreshToken: _tokens.refreshToken
3119
- });
3120
- setTokens(tokens);
3121
- }
3122
- return Promise.resolve({
3123
- headers: { Authorization: _tokens.accessToken.value }
3124
- });
3125
- };
3126
- const wixClientWithTokens = createClient({
3127
- modules: moduleWithTokens,
3128
- auth: { getAuthHeaders }
3129
- });
3130
- const generateVisitorTokens = async (tokens) => {
3131
- if (tokens?.accessToken?.value && tokens?.refreshToken?.value && !isTokenExpired(tokens.accessToken)) {
3132
- return tokens;
3133
- }
3134
- if (tokens?.refreshToken?.value) {
3135
- try {
3136
- const newTokens = await renewToken(tokens.refreshToken);
3137
- return newTokens;
3138
- } catch (e) {
3139
- }
3140
- }
3141
- const tokensResponse = await fetchTokens({
3142
- clientId: config.clientId,
3143
- grantType: "anonymous"
3144
- });
3145
- return {
3146
- accessToken: createAccessToken(tokensResponse.access_token, tokensResponse.expires_in),
3147
- refreshToken: {
3148
- value: tokensResponse.refresh_token,
3149
- role: TokenRole.VISITOR
3150
- }
3151
- };
3152
- };
3153
- const renewToken = async (refreshToken) => {
3154
- const tokensResponse = await fetchTokens({
3155
- refreshToken: refreshToken.value,
3156
- grantType: "refresh_token"
3157
- });
3158
- const accessToken = createAccessToken(tokensResponse.access_token, tokensResponse.expires_in);
3159
- return {
3160
- accessToken,
3161
- refreshToken
3162
- };
3163
- };
3164
- const generatePKCE = () => {
3165
- const pkceState = pkceChallenge();
3166
- return {
3167
- codeChallenge: pkceState.code_challenge,
3168
- codeVerifier: pkceState.code_verifier,
3169
- state: pkceChallenge().code_challenge
3170
- };
3171
- };
3172
- const generateOAuthData = (redirectUri, originalUri) => {
3173
- const state = { redirectUri };
3174
- const pkceState = generatePKCE();
3175
- return {
3176
- ...state,
3177
- originalUri: originalUri ?? "",
3178
- codeChallenge: pkceState.codeChallenge,
3179
- codeVerifier: pkceState.codeVerifier,
3180
- state: pkceChallenge().code_challenge
3181
- };
3182
- };
3183
- const getAuthorizationUrlWithOptions = async (oauthData, responseMode, prompt, sessionToken) => {
3184
- const { redirectSession } = await wixClientWithTokens.redirects.createRedirectSession({
3185
- auth: {
3186
- authRequest: {
3187
- redirectUri: oauthData.redirectUri,
3188
- ...oauthData.redirectUri && {
3189
- redirectUri: oauthData.redirectUri
3190
- },
3191
- clientId: config.clientId,
3192
- codeChallenge: oauthData.codeChallenge,
3193
- codeChallengeMethod: "S256",
3194
- responseMode,
3195
- responseType: "code",
3196
- scope: "offline_access",
3197
- state: oauthData.state,
3198
- ...sessionToken && { sessionToken }
3199
- },
3200
- prompt: es_exports.Prompt[prompt]
3201
- }
3202
- });
3203
- return {
3204
- authUrl: redirectSession.fullUrl,
3205
- authorizationEndpoint: redirectSession.urlDetails.endpoint,
3206
- sessionToken: redirectSession.sessionToken
3207
- };
3208
- };
3209
- const getAuthUrl = async (oauthData = generateOAuthData("unused://"), opts = {
3210
- prompt: "login"
3211
- }) => {
3212
- return getAuthorizationUrlWithOptions(oauthData, opts.responseMode ?? "fragment", opts.prompt ?? "login", opts.sessionToken);
3213
- };
3214
- const parseFromUrl = (url, responseMode = "fragment") => {
3215
- const parsedUrl = new URL(url ?? window.location.href);
3216
- const params = responseMode === "query" ? parsedUrl.searchParams : new URLSearchParams(parsedUrl.hash.substring(1));
3217
- const code = params.get("code");
3218
- const state = params.get("state");
3219
- const error = params.get("error");
3220
- const errorDescription = params.get("error_description");
3221
- return { code, state, ...error && { error, errorDescription } };
3222
- };
3223
- const getMemberTokens = async (code, state, oauthData) => {
3224
- if (!code || !state) {
3225
- throw new Error("Missing code or _state");
3226
- } else if (state !== oauthData.state) {
3227
- throw new Error("Invalid _state");
3228
- }
3229
- const tokensResponse = await fetchTokens({
3230
- clientId: config.clientId,
3231
- grantType: "authorization_code",
3232
- ...oauthData.redirectUri && { redirectUri: oauthData.redirectUri },
3233
- code,
3234
- codeVerifier: oauthData.codeVerifier
3235
- });
3236
- return {
3237
- accessToken: createAccessToken(tokensResponse.access_token, tokensResponse.expires_in),
3238
- refreshToken: {
3239
- value: tokensResponse.refresh_token,
3240
- role: TokenRole.MEMBER
3241
- }
3242
- };
3243
- };
3244
- const logout5 = async (originalUrl) => {
3245
- const { redirectSession } = await wixClientWithTokens.redirects.createRedirectSession({
3246
- logout: { clientId: config.clientId },
3247
- callbacks: {
3248
- postFlowUrl: originalUrl
3249
- }
3250
- });
3251
- _tokens.accessToken = { value: "", expiresAt: 0 };
3252
- _tokens.refreshToken = { value: "", role: TokenRole.NONE };
3253
- return { logoutUrl: redirectSession.fullUrl };
3254
- };
3255
- const handleState = (response) => {
3256
- if (response.state === es_exports2.StateType.SUCCESS) {
3257
- return {
3258
- loginState: LoginState.SUCCESS,
3259
- data: { sessionToken: response.sessionToken }
3260
- };
3261
- } else if (response.state === es_exports2.StateType.REQUIRE_OWNER_APPROVAL) {
3262
- return {
3263
- loginState: LoginState.OWNER_APPROVAL_REQUIRED
3264
- };
3265
- } else if (response.state === es_exports2.StateType.REQUIRE_EMAIL_VERIFICATION) {
3266
- _state = {
3267
- loginState: LoginState.EMAIL_VERIFICATION_REQUIRED,
3268
- data: { stateToken: response.stateToken }
3269
- };
3270
- return _state;
3271
- }
3272
- return {
3273
- loginState: LoginState.FAILURE,
3274
- error: "Unknown _state"
3275
- };
3276
- };
3277
- const register = async (params) => {
3278
- try {
3279
- const res = await wixClientWithTokens.authentication.registerV2({
3280
- email: params.email
3281
- }, {
3282
- password: params.password,
3283
- profile: params.profile,
3284
- ...params.captchaTokens && {
3285
- captchaTokens: [
3286
- {
3287
- Recaptcha: params.captchaTokens?.recaptchaToken,
3288
- InvisibleRecaptcha: params.captchaTokens?.invisibleRecaptchaToken
3289
- }
3290
- ]
3291
- }
3292
- });
3293
- return handleState(res);
3294
- } catch (e) {
3295
- const emailValidation = e.details.validationError?.fieldViolations?.find((v) => v.data.type === "EMAIL");
3296
- if (emailValidation) {
3297
- return {
3298
- loginState: LoginState.FAILURE,
3299
- error: emailValidation.description,
3300
- errorCode: "invalidEmail"
3301
- };
3302
- }
3303
- if (e.details.applicationError?.code === MISSING_CAPTCHA) {
3304
- return {
3305
- loginState: LoginState.FAILURE,
3306
- error: e.message,
3307
- errorCode: "missingCaptchaToken"
3308
- };
3309
- }
3310
- if (e.details.applicationError?.code === EMAIL_EXISTS) {
3311
- return {
3312
- loginState: LoginState.FAILURE,
3313
- error: e.message,
3314
- errorCode: "emailAlreadyExists"
3315
- };
3316
- }
3317
- if (e.details.applicationError?.code === INVALID_CAPTCHA) {
3318
- return {
3319
- loginState: LoginState.FAILURE,
3320
- error: e.message,
3321
- errorCode: "invalidCaptchaToken"
3322
- };
3323
- }
3324
- return {
3325
- loginState: LoginState.FAILURE,
3326
- error: e.message
3327
- };
3328
- }
3329
- };
3330
- const login = async (params) => {
3331
- try {
3332
- const res = await wixClientWithTokens.authentication.loginV2({
3333
- email: params.email
3334
- }, {
3335
- password: params.password,
3336
- ...params.captchaTokens && {
3337
- captchaTokens: [
3338
- {
3339
- Recaptcha: params.captchaTokens?.recaptchaToken,
3340
- InvisibleRecaptcha: params.captchaTokens?.invisibleRecaptchaToken
3341
- }
3342
- ]
3343
- }
3344
- });
3345
- return handleState(res);
3346
- } catch (e) {
3347
- return {
3348
- loginState: LoginState.FAILURE,
3349
- error: e.message,
3350
- errorCode: e.details.applicationError?.code === MISSING_CAPTCHA ? "missingCaptchaToken" : e.details.applicationError?.code === INVALID_CAPTCHA ? "invalidCaptchaToken" : e.details.applicationError.code === INVALID_PASSWORD ? "invalidPassword" : e.details.applicationError.code === RESET_PASSWORD ? "resetPassword" : "invalidEmail"
3351
- };
3352
- }
3353
- };
3354
- const processVerification = async (nextInputs, state) => {
3355
- const stateToUse = state ?? _state;
3356
- if (stateToUse.loginState === LoginState.EMAIL_VERIFICATION_REQUIRED) {
3357
- const code = nextInputs.verificationCode ?? nextInputs.code;
3358
- const res = await wixClientWithTokens.verification.verifyDuringAuthentication(code, { stateToken: stateToUse.data.stateToken });
3359
- return handleState(res);
3360
- }
3361
- return {
3362
- loginState: LoginState.FAILURE,
3363
- error: "Unknown _state"
3364
- };
3365
- };
3366
- const getMemberTokensForDirectLogin = async (sessionToken) => {
3367
- const oauthPKCE = generatePKCE();
3368
- const { authUrl } = await getAuthorizationUrlWithOptions(oauthPKCE, "web_message", "none", sessionToken);
3369
- const iframePromise = addPostMessageListener(oauthPKCE.state);
3370
- const iframeEl = loadFrame(authUrl);
3371
- return iframePromise.then((res) => {
3372
- return getMemberTokens(res.code, res.state, oauthPKCE);
3373
- }).finally(() => {
3374
- if (document.body.contains(iframeEl)) {
3375
- iframeEl.parentElement?.removeChild(iframeEl);
3376
- }
3377
- });
3378
- };
3379
- const sendPasswordResetEmail = async (email, redirectUri) => {
3380
- await wixClientWithTokens.recovery.sendRecoveryEmail(email, {
3381
- redirect: { url: redirectUri, clientId: config.clientId }
3382
- });
3383
- };
3384
- const loggedIn = () => {
3385
- return _tokens.refreshToken.role === TokenRole.MEMBER;
3386
- };
3387
- const getMemberTokensForExternalLogin = async (memberId, apiKey) => {
3388
- const tokensResponse = await fetchTokens({
3389
- grant_type: "authorized_client",
3390
- scope: "offline_access",
3391
- member_id: memberId
3392
- }, {
3393
- Authorization: _tokens.accessToken.value + "," + apiKey
3394
- });
3395
- return {
3396
- accessToken: createAccessToken(tokensResponse.access_token, tokensResponse.expires_in),
3397
- refreshToken: {
3398
- value: tokensResponse.refresh_token,
3399
- role: TokenRole.MEMBER
3400
- }
3401
- };
3402
- };
3403
- return {
3404
- generateVisitorTokens,
3405
- renewToken,
3406
- parseFromUrl,
3407
- getAuthUrl,
3408
- getMemberTokens,
3409
- generateOAuthData,
3410
- getAuthHeaders,
3411
- setTokens,
3412
- getTokens: () => _tokens,
3413
- loggedIn,
3414
- logout: logout5,
3415
- register,
3416
- processVerification,
3417
- login,
3418
- getMemberTokensForDirectLogin,
3419
- getMemberTokensForExternalLogin,
3420
- sendPasswordResetEmail,
3421
- captchaInvisibleSiteKey: "6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v",
3422
- captchaVisibleSiteKey: "6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy"
3423
- };
3424
- }
3425
- var fetchTokens = async (payload, headers = {}) => {
3426
- const res = await fetch(`https://${DEFAULT_API_URL}/oauth2/token`, {
3427
- method: "POST",
3428
- body: JSON.stringify(payload),
3429
- headers: {
3430
- ...biHeaderGenerator({
3431
- entityFqdn: "wix.identity.oauth.v1.refresh_token",
3432
- methodFqn: "wix.identity.oauth2.v1.Oauth2Ng.Token",
3433
- packageName: "@wix/sdk"
3434
- }),
3435
- "Content-Type": "application/json",
3436
- ...headers
3437
- }
3438
- });
3439
- if (res.status !== 200) {
3440
- let responseJson;
3441
- try {
3442
- responseJson = await res.json();
3443
- } catch {
3444
- }
3445
- throw new Error(`Failed to fetch tokens from OAuth API: ${res.statusText}. request id: ${res.headers.get("x-request-id")}. ${responseJson ? `Response: ${JSON.stringify(responseJson)}` : ""}`);
3446
- }
3447
- const json = await res.json();
3448
- return json;
3449
- };
3450
-
3451
- // src/middleware/auth.ts
3452
- import { WIX_CLIENT_ID as WIX_CLIENT_ID2 } from "astro:env/client";
3453
- import { z } from "astro/zod";
3454
-
3455
- // src/utils/authStrategyAsyncLocalStorage.ts
3456
- import { AsyncLocalStorage } from "node:async_hooks";
3457
- var authStrategyAsyncLocalStorage = new AsyncLocalStorage();
3458
-
3459
- // src/utils/sessionCookieJson.ts
3460
- import { WIX_CLIENT_ID } from "astro:env/client";
3461
- function sessionCookieJson(tokens) {
3462
- return {
3463
- clientId: WIX_CLIENT_ID,
3464
- tokens
3465
- };
3466
- }
3467
-
3468
- // src/middleware/auth.ts
3469
- var sessionClient = createClient({
3470
- auth: {
3471
- async getAuthHeaders() {
3472
- const auth = authStrategyAsyncLocalStorage.getStore()?.auth;
3473
- if (!auth) {
3474
- throw new Error(
3475
- "No authentication strategy found in the current context"
3476
- );
3477
- }
3478
- return auth.getAuthHeaders();
3479
- }
3480
- }
3481
- });
3482
- sessionClient.enableContext("global");
3483
- function checkIsDynamicPageRequest(context) {
3484
- try {
3485
- return context.clientAddress != null;
3486
- } catch {
3487
- return false;
3488
- }
3489
- }
3490
- function getSessionTokensFromCookie(context) {
3491
- if (!checkIsDynamicPageRequest(context)) {
3492
- return;
3493
- }
3494
- const rawCookie = context.cookies.get("wixSession")?.json();
3495
- if (rawCookie) {
3496
- const tokensParseResult = z.object({
3497
- clientId: z.string(),
3498
- tokens: z.object({
3499
- accessToken: z.object({
3500
- expiresAt: z.number(),
3501
- value: z.string()
3502
- }),
3503
- refreshToken: z.object({
3504
- role: z.nativeEnum(TokenRole),
3505
- value: z.string()
3506
- })
3507
- })
3508
- }).safeParse(rawCookie);
3509
- if (tokensParseResult.success && tokensParseResult.data.clientId === WIX_CLIENT_ID2) {
3510
- return tokensParseResult.data;
3511
- }
3512
- }
3513
- }
3514
- function saveSessionTokensToCookie(context, tokens) {
3515
- context.cookies.set("wixSession", sessionCookieJson(tokens), {
3516
- path: "/",
3517
- secure: true
3518
- });
3519
- }
3520
- var onRequest = async (context, next) => {
3521
- if (!WIX_CLIENT_ID2) {
3522
- return next();
3523
- }
3524
- const sessionTokensFromCookie = getSessionTokensFromCookie(context);
3525
- const auth = OAuthStrategy({
3526
- clientId: WIX_CLIENT_ID2
3527
- });
3528
- if (sessionTokensFromCookie) {
3529
- auth.setTokens(sessionTokensFromCookie.tokens);
3530
- } else {
3531
- auth.setTokens(await auth.generateVisitorTokens());
3532
- }
3533
- const response = await authStrategyAsyncLocalStorage.run(
3534
- {
3535
- auth
3536
- },
3537
- () => next()
3538
- );
3539
- if (checkIsDynamicPageRequest(context) && sessionTokensFromCookie?.tokens.accessToken.expiresAt !== auth.getTokens().accessToken.expiresAt) {
3540
- saveSessionTokensToCookie(context, auth.getTokens());
3541
- }
3542
- return response;
3543
- };
3544
- export {
3545
- onRequest
3546
- };
3547
- /*! Bundled license information:
3548
-
3549
- @wix/sdk/build/auth/oauth2/sha256.js:
3550
- (**
3551
- * [js-sha256]{@link https://github.com/emn178/js-sha256}
3552
- * @version 0.11.0
3553
- * @author Chen, Yi-Cyuan [emn178@gmail.com]
3554
- * @copyright Chen, Yi-Cyuan 2014-2024
3555
- * @license MIT
3556
- *)
3557
- */