@wix/cli 1.1.112 → 1.1.113

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.
Files changed (133) hide show
  1. package/build/{DevCommand-TSNJSL7I.js → DevCommand-5NIZHHC2.js} +11 -13
  2. package/build/{DevCommand-TSNJSL7I.js.map → DevCommand-5NIZHHC2.js.map} +1 -1
  3. package/build/{DevCommand-JLB5XKLH.js → DevCommand-ALUHGAKA.js} +8 -10
  4. package/build/{DevCommand-JLB5XKLH.js.map → DevCommand-ALUHGAKA.js.map} +1 -1
  5. package/build/{DevCommand-VO5AVD3V.js → DevCommand-VRJX6BIL.js} +8 -9
  6. package/build/{DevCommand-VO5AVD3V.js.map → DevCommand-VRJX6BIL.js.map} +1 -1
  7. package/build/{EnvPullCommand-6QSMUXF5.js → EnvPullCommand-3MUFE7OO.js} +6 -7
  8. package/build/{EnvRemoveCommand-UL5R6YZN.js → EnvRemoveCommand-Z7IW2NBU.js} +5 -6
  9. package/build/{EnvRemoveCommand-UL5R6YZN.js.map → EnvRemoveCommand-Z7IW2NBU.js.map} +1 -1
  10. package/build/{EnvSetCommand-RTF4FOQD.js → EnvSetCommand-KEXD4HBP.js} +5 -6
  11. package/build/{EnvSetCommand-RTF4FOQD.js.map → EnvSetCommand-KEXD4HBP.js.map} +1 -1
  12. package/build/{GenerateCommand-TKTIPFQO.js → GenerateCommand-O4MYCKA5.js} +37 -17
  13. package/build/{GenerateCommand-TKTIPFQO.js.map → GenerateCommand-O4MYCKA5.js.map} +1 -1
  14. package/build/{InstallCommand-GLLQ7K2K.js → InstallCommand-AEQ7A2JQ.js} +7 -8
  15. package/build/{InstallCommand-GLLQ7K2K.js.map → InstallCommand-AEQ7A2JQ.js.map} +1 -1
  16. package/build/{LoginCommand-6CN7XWMZ.js → LoginCommand-7XCJYN2T.js} +4 -6
  17. package/build/{LoginCommand-6CN7XWMZ.js.map → LoginCommand-7XCJYN2T.js.map} +1 -1
  18. package/build/{LogoutCommand-RSV37N5O.js → LogoutCommand-7OSTEKYS.js} +2 -3
  19. package/build/{LogoutCommand-RSV37N5O.js.map → LogoutCommand-7OSTEKYS.js.map} +1 -1
  20. package/build/{PreviewCommand-VIJD3C3I.js → PreviewCommand-7TZKFZ3T.js} +7 -8
  21. package/build/{PreviewCommand-AZGVBDAS.js → PreviewCommand-A7B7HRBK.js} +10 -11
  22. package/build/{PreviewCommand-AZGVBDAS.js.map → PreviewCommand-A7B7HRBK.js.map} +1 -1
  23. package/build/{PreviewCommand-GL5VNPGU.js → PreviewCommand-WNCU6VVQ.js} +12 -13
  24. package/build/{PreviewCommand-GL5VNPGU.js.map → PreviewCommand-WNCU6VVQ.js.map} +1 -1
  25. package/build/{PublishCommand-D4SYLRXJ.js → PublishCommand-Y3EBOR64.js} +10 -11
  26. package/build/{PublishCommand-D4SYLRXJ.js.map → PublishCommand-Y3EBOR64.js.map} +1 -1
  27. package/build/{ReleaseCommand-4KDASXKO.js → ReleaseCommand-NSRK63PO.js} +7 -8
  28. package/build/{ReleaseCommand-4KDASXKO.js.map → ReleaseCommand-NSRK63PO.js.map} +1 -1
  29. package/build/{UninstallCommand-KECOJSUV.js → UninstallCommand-BYKH2OD5.js} +7 -8
  30. package/build/{UninstallCommand-KECOJSUV.js.map → UninstallCommand-BYKH2OD5.js.map} +1 -1
  31. package/build/{chunk-NYXCCTTI.js → chunk-2HIHYEDM.js} +3779 -748
  32. package/build/chunk-2HIHYEDM.js.map +1 -0
  33. package/build/{chunk-25KH37IH.js → chunk-4JAPOHJE.js} +4 -4
  34. package/build/{chunk-4XNY62ZC.js → chunk-6CF3ST26.js} +4 -4
  35. package/build/{chunk-GXTO7QW5.js → chunk-6YCIIOBO.js} +6 -6
  36. package/build/{chunk-WFO5QVKA.js → chunk-CLEB562H.js} +4 -6
  37. package/build/{chunk-WFO5QVKA.js.map → chunk-CLEB562H.js.map} +1 -1
  38. package/build/{chunk-YUPQBUES.js → chunk-DLN4ZC34.js} +6 -6
  39. package/build/{chunk-ID6AIUU4.js → chunk-G5ARP7YT.js} +2 -2
  40. package/build/{chunk-LTBO3EJC.js → chunk-HVWGXMF3.js} +3 -3
  41. package/build/{chunk-CLQIKXVP.js → chunk-IKRGTML5.js} +4 -4
  42. package/build/{chunk-NTCPUROY.js → chunk-KYCF6FOC.js} +2 -2
  43. package/build/{chunk-FUH2VNEY.js → chunk-LUMPVLDL.js} +14 -7
  44. package/build/chunk-LUMPVLDL.js.map +1 -0
  45. package/build/{chunk-AYZVCVQB.js → chunk-OMWR5T2O.js} +2 -2
  46. package/build/{chunk-DFWZKEFR.js → chunk-PXSKF3ZH.js} +5 -5
  47. package/build/{chunk-XBFTRZBP.js → chunk-PXYULYM4.js} +2 -2
  48. package/build/{chunk-7DLJ7HFW.js → chunk-QEOFWN5Q.js} +4 -6
  49. package/build/{chunk-7DLJ7HFW.js.map → chunk-QEOFWN5Q.js.map} +1 -1
  50. package/build/{chunk-EY2N4IBS.js → chunk-R5MKZGVK.js} +2 -2
  51. package/build/{chunk-SCWWGMKA.js → chunk-TJ27FIWY.js} +3 -1
  52. package/build/chunk-TJ27FIWY.js.map +1 -0
  53. package/build/{chunk-G34RNRMR.js → chunk-TRPFWRJM.js} +2 -2
  54. package/build/{chunk-YVUPBWGO.js → chunk-TWBAYQ6U.js} +6 -8
  55. package/build/{chunk-YVUPBWGO.js.map → chunk-TWBAYQ6U.js.map} +1 -1
  56. package/build/{chunk-RXJAFOGS.js → chunk-UHAOJQIZ.js} +6 -6
  57. package/build/chunk-WGXHQDL4.js +72 -0
  58. package/build/chunk-WGXHQDL4.js.map +1 -0
  59. package/build/{chunk-EMZ62X3W.js → chunk-WL33QM7L.js} +5 -7
  60. package/build/{chunk-EMZ62X3W.js.map → chunk-WL33QM7L.js.map} +1 -1
  61. package/build/{chunk-7XAFII6R.js → chunk-X3ZNA2FH.js} +3 -3
  62. package/build/{chunk-UBUQGH7L.js → chunk-YG4SDLJ3.js} +4 -4
  63. package/build/{chunk-GUPRA5FO.js → chunk-Z4ASNHNJ.js} +3 -2
  64. package/build/chunk-Z4ASNHNJ.js.map +1 -0
  65. package/build/{chunk-Z5WMOVRW.js → chunk-ZAXDMNEH.js} +2 -2
  66. package/build/{dev-MO6VFA7B.js → dev-TGYUMH2A.js} +15 -17
  67. package/build/{dev-MO6VFA7B.js.map → dev-TGYUMH2A.js.map} +1 -1
  68. package/build/{env-pull-B2I4RXV6.js → env-pull-AZFHDCAT.js} +7 -8
  69. package/build/{env-pull-B2I4RXV6.js.map → env-pull-AZFHDCAT.js.map} +1 -1
  70. package/build/index.js +16 -18
  71. package/build/index.js.map +1 -1
  72. package/build/{install-Y5DLUJCQ.js → install-3WCRDI4P.js} +6 -7
  73. package/build/{install-Y5DLUJCQ.js.map → install-3WCRDI4P.js.map} +1 -1
  74. package/build/{preview-X6ZTDHFQ.js → preview-W4V2ONOV.js} +8 -9
  75. package/build/{preview-X6ZTDHFQ.js.map → preview-W4V2ONOV.js.map} +1 -1
  76. package/build/{publish-QVY6BJEC.js → publish-ZOEOS5T6.js} +9 -11
  77. package/build/{publish-QVY6BJEC.js.map → publish-ZOEOS5T6.js.map} +1 -1
  78. package/build/{render-command-G3DEB3PP.js → render-command-GCDMLMWE.js} +14 -7
  79. package/build/render-command-GCDMLMWE.js.map +1 -0
  80. package/build/{render-command-2QKA5JIR.js → render-command-JGRUUMNE.js} +14 -7
  81. package/build/render-command-JGRUUMNE.js.map +1 -0
  82. package/build/{render-command-GHZYICWV.js → render-command-MSDRFAEH.js} +14 -7
  83. package/build/render-command-MSDRFAEH.js.map +1 -0
  84. package/build/{render-command-TWCU7ENF.js → render-command-RLQKUKVH.js} +5 -5
  85. package/build/{render-command-BLZRVWQF.js → render-command-TSTBAITN.js} +14 -4
  86. package/build/render-command-TSTBAITN.js.map +1 -0
  87. package/build/{src-JPU5VCHG.js → src-4EKWIVB6.js} +3 -3
  88. package/build/{src-ZDQRZIWA.js → src-7UHYYCVW.js} +2 -3
  89. package/build/{src-5QOEHXIM.js → src-GSOEZHCG.js} +8 -8
  90. package/build/{src-76RF63HM.js → src-LEWDR7MP.js} +19 -19
  91. package/build/{src-45IC5WTW.js → src-UTNR5MXA.js} +11 -11
  92. package/build/{sync-types-F4Q7EYBW.js → sync-types-7AJ7PNPQ.js} +5 -6
  93. package/build/{uninstall-CIJYDWKC.js → uninstall-TBLNEAEU.js} +6 -7
  94. package/build/{uninstall-CIJYDWKC.js.map → uninstall-TBLNEAEU.js.map} +1 -1
  95. package/package.json +3 -2
  96. package/build/chunk-2VWXGVIP.js +0 -3078
  97. package/build/chunk-2VWXGVIP.js.map +0 -1
  98. package/build/chunk-FUH2VNEY.js.map +0 -1
  99. package/build/chunk-GUPRA5FO.js.map +0 -1
  100. package/build/chunk-NYXCCTTI.js.map +0 -1
  101. package/build/chunk-OYD76TVD.js +0 -34
  102. package/build/chunk-OYD76TVD.js.map +0 -1
  103. package/build/chunk-SCWWGMKA.js.map +0 -1
  104. package/build/render-command-2QKA5JIR.js.map +0 -1
  105. package/build/render-command-BLZRVWQF.js.map +0 -1
  106. package/build/render-command-G3DEB3PP.js.map +0 -1
  107. package/build/render-command-GHZYICWV.js.map +0 -1
  108. /package/build/{EnvPullCommand-6QSMUXF5.js.map → EnvPullCommand-3MUFE7OO.js.map} +0 -0
  109. /package/build/{PreviewCommand-VIJD3C3I.js.map → PreviewCommand-7TZKFZ3T.js.map} +0 -0
  110. /package/build/{chunk-25KH37IH.js.map → chunk-4JAPOHJE.js.map} +0 -0
  111. /package/build/{chunk-4XNY62ZC.js.map → chunk-6CF3ST26.js.map} +0 -0
  112. /package/build/{chunk-GXTO7QW5.js.map → chunk-6YCIIOBO.js.map} +0 -0
  113. /package/build/{chunk-YUPQBUES.js.map → chunk-DLN4ZC34.js.map} +0 -0
  114. /package/build/{chunk-ID6AIUU4.js.map → chunk-G5ARP7YT.js.map} +0 -0
  115. /package/build/{chunk-LTBO3EJC.js.map → chunk-HVWGXMF3.js.map} +0 -0
  116. /package/build/{chunk-CLQIKXVP.js.map → chunk-IKRGTML5.js.map} +0 -0
  117. /package/build/{chunk-NTCPUROY.js.map → chunk-KYCF6FOC.js.map} +0 -0
  118. /package/build/{chunk-AYZVCVQB.js.map → chunk-OMWR5T2O.js.map} +0 -0
  119. /package/build/{chunk-DFWZKEFR.js.map → chunk-PXSKF3ZH.js.map} +0 -0
  120. /package/build/{chunk-XBFTRZBP.js.map → chunk-PXYULYM4.js.map} +0 -0
  121. /package/build/{chunk-EY2N4IBS.js.map → chunk-R5MKZGVK.js.map} +0 -0
  122. /package/build/{chunk-G34RNRMR.js.map → chunk-TRPFWRJM.js.map} +0 -0
  123. /package/build/{chunk-RXJAFOGS.js.map → chunk-UHAOJQIZ.js.map} +0 -0
  124. /package/build/{chunk-7XAFII6R.js.map → chunk-X3ZNA2FH.js.map} +0 -0
  125. /package/build/{chunk-UBUQGH7L.js.map → chunk-YG4SDLJ3.js.map} +0 -0
  126. /package/build/{chunk-Z5WMOVRW.js.map → chunk-ZAXDMNEH.js.map} +0 -0
  127. /package/build/{render-command-TWCU7ENF.js.map → render-command-RLQKUKVH.js.map} +0 -0
  128. /package/build/{src-JPU5VCHG.js.map → src-4EKWIVB6.js.map} +0 -0
  129. /package/build/{src-ZDQRZIWA.js.map → src-7UHYYCVW.js.map} +0 -0
  130. /package/build/{src-5QOEHXIM.js.map → src-GSOEZHCG.js.map} +0 -0
  131. /package/build/{src-76RF63HM.js.map → src-LEWDR7MP.js.map} +0 -0
  132. /package/build/{src-45IC5WTW.js.map → src-UTNR5MXA.js.map} +0 -0
  133. /package/build/{sync-types-F4Q7EYBW.js.map → sync-types-7AJ7PNPQ.js.map} +0 -0
@@ -1,3078 +0,0 @@
1
- import { createRequire as _createRequire } from 'node:module';
2
- const require = _createRequire(import.meta.url);
3
- import {
4
- BiProvider,
5
- ErrorReporterProvider,
6
- ErrorViewer,
7
- useBiLogger,
8
- useErrorReporter
9
- } from "./chunk-NYXCCTTI.js";
10
- import {
11
- require_index_node,
12
- wixCliLoginEnd,
13
- wixCliLoginStart
14
- } from "./chunk-WZOSCHKD.js";
15
- import {
16
- I18nProvider,
17
- Trans
18
- } from "./chunk-FGRHAF2I.js";
19
- import {
20
- Box_default,
21
- Key,
22
- Link,
23
- Spinner,
24
- Text,
25
- render,
26
- useAsync,
27
- useAsyncCallback,
28
- useExit,
29
- use_input_default
30
- } from "./chunk-CCTJS4D5.js";
31
- import {
32
- require_react
33
- } from "./chunk-NRAQAV6T.js";
34
- import {
35
- getDataDirPath
36
- } from "./chunk-62BYZXT7.js";
37
- import {
38
- getTestOverrides
39
- } from "./chunk-WYHHEOWO.js";
40
- import {
41
- pathExists,
42
- readJson,
43
- writeJson
44
- } from "./chunk-MW2UYD4J.js";
45
- import {
46
- z
47
- } from "./chunk-ZXYGJZOO.js";
48
- import {
49
- CliError,
50
- CliErrorCode,
51
- require_lib
52
- } from "./chunk-QPDXBXSZ.js";
53
- import {
54
- __commonJS,
55
- __toESM,
56
- init_esm_shims
57
- } from "./chunk-4EFJZ3GQ.js";
58
-
59
- // ../../node_modules/p-retry/node_modules/retry/lib/retry_operation.js
60
- var require_retry_operation = __commonJS({
61
- "../../node_modules/p-retry/node_modules/retry/lib/retry_operation.js"(exports, module) {
62
- "use strict";
63
- init_esm_shims();
64
- function RetryOperation(timeouts, options) {
65
- if (typeof options === "boolean") {
66
- options = { forever: options };
67
- }
68
- this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
69
- this._timeouts = timeouts;
70
- this._options = options || {};
71
- this._maxRetryTime = options && options.maxRetryTime || Infinity;
72
- this._fn = null;
73
- this._errors = [];
74
- this._attempts = 1;
75
- this._operationTimeout = null;
76
- this._operationTimeoutCb = null;
77
- this._timeout = null;
78
- this._operationStart = null;
79
- this._timer = null;
80
- if (this._options.forever) {
81
- this._cachedTimeouts = this._timeouts.slice(0);
82
- }
83
- }
84
- module.exports = RetryOperation;
85
- RetryOperation.prototype.reset = function() {
86
- this._attempts = 1;
87
- this._timeouts = this._originalTimeouts.slice(0);
88
- };
89
- RetryOperation.prototype.stop = function() {
90
- if (this._timeout) {
91
- clearTimeout(this._timeout);
92
- }
93
- if (this._timer) {
94
- clearTimeout(this._timer);
95
- }
96
- this._timeouts = [];
97
- this._cachedTimeouts = null;
98
- };
99
- RetryOperation.prototype.retry = function(err) {
100
- if (this._timeout) {
101
- clearTimeout(this._timeout);
102
- }
103
- if (!err) {
104
- return false;
105
- }
106
- var currentTime = (/* @__PURE__ */ new Date()).getTime();
107
- if (err && currentTime - this._operationStart >= this._maxRetryTime) {
108
- this._errors.push(err);
109
- this._errors.unshift(new Error("RetryOperation timeout occurred"));
110
- return false;
111
- }
112
- this._errors.push(err);
113
- var timeout = this._timeouts.shift();
114
- if (timeout === void 0) {
115
- if (this._cachedTimeouts) {
116
- this._errors.splice(0, this._errors.length - 1);
117
- timeout = this._cachedTimeouts.slice(-1);
118
- } else {
119
- return false;
120
- }
121
- }
122
- var self = this;
123
- this._timer = setTimeout(function() {
124
- self._attempts++;
125
- if (self._operationTimeoutCb) {
126
- self._timeout = setTimeout(function() {
127
- self._operationTimeoutCb(self._attempts);
128
- }, self._operationTimeout);
129
- if (self._options.unref) {
130
- self._timeout.unref();
131
- }
132
- }
133
- self._fn(self._attempts);
134
- }, timeout);
135
- if (this._options.unref) {
136
- this._timer.unref();
137
- }
138
- return true;
139
- };
140
- RetryOperation.prototype.attempt = function(fn, timeoutOps) {
141
- this._fn = fn;
142
- if (timeoutOps) {
143
- if (timeoutOps.timeout) {
144
- this._operationTimeout = timeoutOps.timeout;
145
- }
146
- if (timeoutOps.cb) {
147
- this._operationTimeoutCb = timeoutOps.cb;
148
- }
149
- }
150
- var self = this;
151
- if (this._operationTimeoutCb) {
152
- this._timeout = setTimeout(function() {
153
- self._operationTimeoutCb();
154
- }, self._operationTimeout);
155
- }
156
- this._operationStart = (/* @__PURE__ */ new Date()).getTime();
157
- this._fn(this._attempts);
158
- };
159
- RetryOperation.prototype.try = function(fn) {
160
- console.log("Using RetryOperation.try() is deprecated");
161
- this.attempt(fn);
162
- };
163
- RetryOperation.prototype.start = function(fn) {
164
- console.log("Using RetryOperation.start() is deprecated");
165
- this.attempt(fn);
166
- };
167
- RetryOperation.prototype.start = RetryOperation.prototype.try;
168
- RetryOperation.prototype.errors = function() {
169
- return this._errors;
170
- };
171
- RetryOperation.prototype.attempts = function() {
172
- return this._attempts;
173
- };
174
- RetryOperation.prototype.mainError = function() {
175
- if (this._errors.length === 0) {
176
- return null;
177
- }
178
- var counts = {};
179
- var mainError = null;
180
- var mainErrorCount = 0;
181
- for (var i = 0; i < this._errors.length; i++) {
182
- var error = this._errors[i];
183
- var message = error.message;
184
- var count = (counts[message] || 0) + 1;
185
- counts[message] = count;
186
- if (count >= mainErrorCount) {
187
- mainError = error;
188
- mainErrorCount = count;
189
- }
190
- }
191
- return mainError;
192
- };
193
- }
194
- });
195
-
196
- // ../../node_modules/p-retry/node_modules/retry/lib/retry.js
197
- var require_retry = __commonJS({
198
- "../../node_modules/p-retry/node_modules/retry/lib/retry.js"(exports) {
199
- "use strict";
200
- init_esm_shims();
201
- var RetryOperation = require_retry_operation();
202
- exports.operation = function(options) {
203
- var timeouts = exports.timeouts(options);
204
- return new RetryOperation(timeouts, {
205
- forever: options && (options.forever || options.retries === Infinity),
206
- unref: options && options.unref,
207
- maxRetryTime: options && options.maxRetryTime
208
- });
209
- };
210
- exports.timeouts = function(options) {
211
- if (options instanceof Array) {
212
- return [].concat(options);
213
- }
214
- var opts = {
215
- retries: 10,
216
- factor: 2,
217
- minTimeout: 1 * 1e3,
218
- maxTimeout: Infinity,
219
- randomize: false
220
- };
221
- for (var key in options) {
222
- opts[key] = options[key];
223
- }
224
- if (opts.minTimeout > opts.maxTimeout) {
225
- throw new Error("minTimeout is greater than maxTimeout");
226
- }
227
- var timeouts = [];
228
- for (var i = 0; i < opts.retries; i++) {
229
- timeouts.push(this.createTimeout(i, opts));
230
- }
231
- if (options && options.forever && !timeouts.length) {
232
- timeouts.push(this.createTimeout(i, opts));
233
- }
234
- timeouts.sort(function(a, b) {
235
- return a - b;
236
- });
237
- return timeouts;
238
- };
239
- exports.createTimeout = function(attempt, opts) {
240
- var random = opts.randomize ? Math.random() + 1 : 1;
241
- var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
242
- timeout = Math.min(timeout, opts.maxTimeout);
243
- return timeout;
244
- };
245
- exports.wrap = function(obj, options, methods) {
246
- if (options instanceof Array) {
247
- methods = options;
248
- options = null;
249
- }
250
- if (!methods) {
251
- methods = [];
252
- for (var key in obj) {
253
- if (typeof obj[key] === "function") {
254
- methods.push(key);
255
- }
256
- }
257
- }
258
- for (var i = 0; i < methods.length; i++) {
259
- var method = methods[i];
260
- var original = obj[method];
261
- obj[method] = function retryWrapper(original2) {
262
- var op = exports.operation(options);
263
- var args = Array.prototype.slice.call(arguments, 1);
264
- var callback = args.pop();
265
- args.push(function(err) {
266
- if (op.retry(err)) {
267
- return;
268
- }
269
- if (err) {
270
- arguments[0] = op.mainError();
271
- }
272
- callback.apply(this, arguments);
273
- });
274
- op.attempt(function() {
275
- original2.apply(obj, args);
276
- });
277
- }.bind(obj, original);
278
- obj[method].options = options;
279
- }
280
- };
281
- }
282
- });
283
-
284
- // ../../node_modules/p-retry/node_modules/retry/index.js
285
- var require_retry2 = __commonJS({
286
- "../../node_modules/p-retry/node_modules/retry/index.js"(exports, module) {
287
- "use strict";
288
- init_esm_shims();
289
- module.exports = require_retry();
290
- }
291
- });
292
-
293
- // ../cli-auth/src/index.ts
294
- init_esm_shims();
295
-
296
- // ../cli-auth/src/auth-strategies/index.ts
297
- init_esm_shims();
298
-
299
- // ../cli-auth/src/auth-strategies/api-key-auth-strategy.ts
300
- init_esm_shims();
301
- var import_variant3 = __toESM(require_lib(), 1);
302
-
303
- // ../cli-auth/src/client.ts
304
- init_esm_shims();
305
-
306
- // ../../node_modules/p-retry/index.js
307
- init_esm_shims();
308
- var import_retry = __toESM(require_retry2(), 1);
309
-
310
- // ../../node_modules/is-network-error/index.js
311
- init_esm_shims();
312
- var objectToString = Object.prototype.toString;
313
- var isError = (value) => objectToString.call(value) === "[object Error]";
314
- var errorMessages = /* @__PURE__ */ new Set([
315
- "network error",
316
- // Chrome
317
- "Failed to fetch",
318
- // Chrome
319
- "NetworkError when attempting to fetch resource.",
320
- // Firefox
321
- "The Internet connection appears to be offline.",
322
- // Safari 16
323
- "Load failed",
324
- // Safari 17+
325
- "Network request failed",
326
- // `cross-fetch`
327
- "fetch failed",
328
- // Undici (Node.js)
329
- "terminated"
330
- // Undici (Node.js)
331
- ]);
332
- function isNetworkError(error) {
333
- const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
334
- if (!isValid) {
335
- return false;
336
- }
337
- if (error.message === "Load failed") {
338
- return error.stack === void 0;
339
- }
340
- return errorMessages.has(error.message);
341
- }
342
-
343
- // ../../node_modules/p-retry/index.js
344
- var AbortError = class extends Error {
345
- constructor(message) {
346
- super();
347
- if (message instanceof Error) {
348
- this.originalError = message;
349
- ({ message } = message);
350
- } else {
351
- this.originalError = new Error(message);
352
- this.originalError.stack = this.stack;
353
- }
354
- this.name = "AbortError";
355
- this.message = message;
356
- }
357
- };
358
- var decorateErrorWithCounts = (error, attemptNumber, options) => {
359
- const retriesLeft = options.retries - (attemptNumber - 1);
360
- error.attemptNumber = attemptNumber;
361
- error.retriesLeft = retriesLeft;
362
- return error;
363
- };
364
- async function pRetry(input, options) {
365
- return new Promise((resolve2, reject) => {
366
- options = { ...options };
367
- options.onFailedAttempt ??= () => {
368
- };
369
- options.shouldRetry ??= () => true;
370
- options.retries ??= 10;
371
- const operation = import_retry.default.operation(options);
372
- const abortHandler = () => {
373
- operation.stop();
374
- reject(options.signal?.reason);
375
- };
376
- if (options.signal && !options.signal.aborted) {
377
- options.signal.addEventListener("abort", abortHandler, { once: true });
378
- }
379
- const cleanUp = () => {
380
- options.signal?.removeEventListener("abort", abortHandler);
381
- operation.stop();
382
- };
383
- operation.attempt(async (attemptNumber) => {
384
- try {
385
- const result = await input(attemptNumber);
386
- cleanUp();
387
- resolve2(result);
388
- } catch (error) {
389
- try {
390
- if (!(error instanceof Error)) {
391
- throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
392
- }
393
- if (error instanceof AbortError) {
394
- throw error.originalError;
395
- }
396
- if (error instanceof TypeError && !isNetworkError(error)) {
397
- throw error;
398
- }
399
- decorateErrorWithCounts(error, attemptNumber, options);
400
- if (!await options.shouldRetry(error)) {
401
- operation.stop();
402
- reject(error);
403
- }
404
- await options.onFailedAttempt(error);
405
- if (!operation.retry(error)) {
406
- throw operation.mainError();
407
- }
408
- } catch (finalError) {
409
- decorateErrorWithCounts(finalError, attemptNumber, options);
410
- cleanUp();
411
- reject(finalError);
412
- }
413
- }
414
- });
415
- });
416
- }
417
-
418
- // ../../node_modules/@wix/ambassador-identity-account-v2-account/build/es/http.impl.js
419
- init_esm_shims();
420
-
421
- // ../../node_modules/@wix/metro-runtime/dist/esm/index.js
422
- init_esm_shims();
423
-
424
- // ../../node_modules/@wix/metro-runtime/dist/esm/serialization/index.js
425
- init_esm_shims();
426
-
427
- // ../../node_modules/@wix/metro-runtime/dist/esm/serialization/utils.js
428
- init_esm_shims();
429
- function parseLeanSchemaRef(renderedSchemaName = "") {
430
- const [typeOrName, schemaName] = getSchemaNameAndType(renderedSchemaName);
431
- if (schemaName) {
432
- return {
433
- schemaName,
434
- schemaType: typeOrName
435
- };
436
- }
437
- return {
438
- schemaName: typeOrName
439
- };
440
- }
441
- var getSchemaNameAndType = (leanSchema) => leanSchema.split("#");
442
-
443
- // ../../node_modules/@wix/metro-runtime/dist/esm/url-resolver.js
444
- init_esm_shims();
445
-
446
- // ../../node_modules/@wix/metro-runtime/dist/esm/utils.js
447
- init_esm_shims();
448
- function findByPath(obj, path2, defaultValue, suffix) {
449
- let result = obj;
450
- for (const field of path2.split(".")) {
451
- if (!result) {
452
- return defaultValue;
453
- }
454
- result = result[field];
455
- }
456
- return `${result}${suffix}`;
457
- }
458
-
459
- // ../../node_modules/@wix/metro-runtime/dist/esm/url-resolver.js
460
- var USER_DOMAIN = "_";
461
- var DOMAINS = ["wix.com", "editorx.com"];
462
- var WIX_API_DOMAINS = ["42.wixprod.net", "uw2-edt-1.wixprod.net"];
463
- var DEV_WIX_CODE_DOMAIN = "dev.wix-code.com";
464
- var REGEX_CAPTURE_PROTO_FIELD = /{(.*)}/;
465
- var REGEX_CAPTURE_DOMAINS = new RegExp(`\\.(${DOMAINS.join("|")})$`);
466
- var REGEX_CAPTURE_API_DOMAINS = new RegExp(`\\.(${WIX_API_DOMAINS.join("|")})$`);
467
- var REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN = new RegExp(`.*\\.${DEV_WIX_CODE_DOMAIN}$`);
468
- function resolveUrl(opts) {
469
- const domain = resolveDomain(opts.host);
470
- const mappings = resolveMappingsByDomain(domain, opts.domainToMappings);
471
- const path2 = injectDataIntoProtoPath(opts.protoPath, opts.data || {});
472
- return resolvePath(path2, mappings);
473
- }
474
- function injectDataIntoProtoPath(protoPath, data) {
475
- return protoPath.split("/").map((path2) => maybeProtoPathToData(path2, data)).join("/");
476
- }
477
- function maybeProtoPathToData(protoPath, data) {
478
- const protoRegExpMatch = protoPath.match(REGEX_CAPTURE_PROTO_FIELD) || [];
479
- const field = protoRegExpMatch[1];
480
- if (field) {
481
- const suffix = protoPath.replace(protoRegExpMatch[0], "");
482
- return findByPath(data, field, protoPath, suffix);
483
- }
484
- return protoPath;
485
- }
486
- function resolveDomain(host) {
487
- const resolvedHost = fixHostExceptions(host);
488
- 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");
489
- }
490
- function fixHostExceptions(host) {
491
- return host.replace("create.editorx.com", "editor.editorx.com");
492
- }
493
- function resolveMappingsByDomain(domain, domainToMappings) {
494
- const mappings = domainToMappings[domain] || domainToMappings[USER_DOMAIN];
495
- if (!mappings) {
496
- if (isBaseDomain(domain)) {
497
- return domainToMappings[wwwBaseDomain];
498
- }
499
- }
500
- const rootDomainMappings = resolveRootDomain(domain, domainToMappings);
501
- return mappings ?? rootDomainMappings;
502
- }
503
- function resolveRootDomain(domain, domainToMappings) {
504
- return Object.entries(domainToMappings).find(([entryDomain]) => {
505
- const [_, ...rooDomainSegments] = domain.split(".");
506
- return rooDomainSegments.join(".") === entryDomain;
507
- })?.[1];
508
- }
509
- function resolvePath(protoPath, mappings) {
510
- const mapping = mappings?.find((m) => protoPath.startsWith(m.destPath));
511
- if (!mapping) {
512
- return protoPath;
513
- }
514
- return mapping.srcPath + protoPath.slice(mapping.destPath.length);
515
- }
516
- function isBaseDomain(domain) {
517
- return !!domain.match(/\._base_domain_$/);
518
- }
519
- var wwwBaseDomain = "www._base_domain_";
520
-
521
- // ../../node_modules/@wix/metro-runtime/dist/esm/flatten-params.js
522
- init_esm_shims();
523
-
524
- // ../../node_modules/js-base64/base64.mjs
525
- init_esm_shims();
526
- var _hasBuffer = typeof Buffer === "function";
527
- var _TD = typeof TextDecoder === "function" ? new TextDecoder() : void 0;
528
- var _TE = typeof TextEncoder === "function" ? new TextEncoder() : void 0;
529
- var b64ch = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
530
- var b64chs = Array.prototype.slice.call(b64ch);
531
- var b64tab = ((a) => {
532
- let tab = {};
533
- a.forEach((c, i) => tab[c] = i);
534
- return tab;
535
- })(b64chs);
536
- var _fromCC = String.fromCharCode.bind(String);
537
- var _U8Afrom = typeof Uint8Array.from === "function" ? Uint8Array.from.bind(Uint8Array) : (it) => new Uint8Array(Array.prototype.slice.call(it, 0));
538
- var _mkUriSafe = (src) => src.replace(/=/g, "").replace(/[+\/]/g, (m0) => m0 == "+" ? "-" : "_");
539
- var btoaPolyfill = (bin) => {
540
- let u32, c0, c1, c2, asc = "";
541
- const pad = bin.length % 3;
542
- for (let i = 0; i < bin.length; ) {
543
- if ((c0 = bin.charCodeAt(i++)) > 255 || (c1 = bin.charCodeAt(i++)) > 255 || (c2 = bin.charCodeAt(i++)) > 255)
544
- throw new TypeError("invalid character found");
545
- u32 = c0 << 16 | c1 << 8 | c2;
546
- asc += b64chs[u32 >> 18 & 63] + b64chs[u32 >> 12 & 63] + b64chs[u32 >> 6 & 63] + b64chs[u32 & 63];
547
- }
548
- return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
549
- };
550
- var _btoa = typeof btoa === "function" ? (bin) => btoa(bin) : _hasBuffer ? (bin) => Buffer.from(bin, "binary").toString("base64") : btoaPolyfill;
551
- var _fromUint8Array = _hasBuffer ? (u8a) => Buffer.from(u8a).toString("base64") : (u8a) => {
552
- const maxargs = 4096;
553
- let strs = [];
554
- for (let i = 0, l = u8a.length; i < l; i += maxargs) {
555
- strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
556
- }
557
- return _btoa(strs.join(""));
558
- };
559
- var cb_utob = (c) => {
560
- if (c.length < 2) {
561
- var cc = c.charCodeAt(0);
562
- return cc < 128 ? c : cc < 2048 ? _fromCC(192 | cc >>> 6) + _fromCC(128 | cc & 63) : _fromCC(224 | cc >>> 12 & 15) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
563
- } else {
564
- var cc = 65536 + (c.charCodeAt(0) - 55296) * 1024 + (c.charCodeAt(1) - 56320);
565
- return _fromCC(240 | cc >>> 18 & 7) + _fromCC(128 | cc >>> 12 & 63) + _fromCC(128 | cc >>> 6 & 63) + _fromCC(128 | cc & 63);
566
- }
567
- };
568
- var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
569
- var utob = (u) => u.replace(re_utob, cb_utob);
570
- var _encode = _hasBuffer ? (s) => Buffer.from(s, "utf8").toString("base64") : _TE ? (s) => _fromUint8Array(_TE.encode(s)) : (s) => _btoa(utob(s));
571
- var encode = (src, urlsafe = false) => urlsafe ? _mkUriSafe(_encode(src)) : _encode(src);
572
-
573
- // ../../node_modules/@wix/metro-runtime/dist/esm/flatten-params.js
574
- function flattenParams(data, path2 = "") {
575
- const params = {};
576
- Object.entries(data).forEach(([key, value]) => {
577
- const isObject = value !== null && typeof value === "object" && !Array.isArray(value);
578
- const fieldPath = resolvePath2(path2, key);
579
- if (isObject) {
580
- const serializedObject = flattenParams(value, fieldPath);
581
- Object.assign(params, serializedObject);
582
- } else {
583
- params[fieldPath] = value;
584
- }
585
- });
586
- return params;
587
- }
588
- function resolvePath2(path2, key) {
589
- return `${path2}${path2 ? "." : ""}${key}`;
590
- }
591
- function toURLSearchParams(params, isComplexRequest) {
592
- const flatten = flattenParams(params);
593
- const isPayloadNonSerializableAsUrlSearchParams = Object.entries(flatten).some(([key, value]) => key.includes(".") || Array.isArray(value) && value.some((v) => typeof v === "object"));
594
- const shouldSerializeToRParam = isComplexRequest && isPayloadNonSerializableAsUrlSearchParams;
595
- if (shouldSerializeToRParam) {
596
- return new URLSearchParams({ ".r": encode(JSON.stringify(params), true) });
597
- } else {
598
- return Object.entries(flatten).reduce((urlSearchParams, [key, value]) => {
599
- const keyParams = Array.isArray(value) ? value : [value];
600
- keyParams.forEach((param) => {
601
- if (param === void 0 || param === null || Array.isArray(value) && typeof param === "object") {
602
- return;
603
- }
604
- urlSearchParams.append(key, param);
605
- });
606
- return urlSearchParams;
607
- }, new URLSearchParams());
608
- }
609
- }
610
-
611
- // ../../node_modules/@wix/metro-runtime/dist/esm/ambassador-index.js
612
- init_esm_shims();
613
-
614
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/domain.js
615
- init_esm_shims();
616
- var ConverterType;
617
- (function(ConverterType2) {
618
- ConverterType2[ConverterType2["TO_JSON"] = 0] = "TO_JSON";
619
- ConverterType2[ConverterType2["FROM_JSON"] = 1] = "FROM_JSON";
620
- })(ConverterType || (ConverterType = {}));
621
-
622
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/serializer.js
623
- init_esm_shims();
624
- function schemaSerializer(rootSchema, depSchemas = {}, converterSets) {
625
- return function serialize(json = {}, converterType) {
626
- return typeof json === "string" ? json : transformSchema(rootSchema, json);
627
- function transformSchema(schema, payload4) {
628
- const result = {};
629
- if ([null, void 0].includes(payload4)) {
630
- return payload4;
631
- }
632
- Object.entries(payload4).forEach(([key, val]) => {
633
- const renderedSchemaName = schema[key];
634
- const { schemaName, schemaType } = parseLeanSchemaRef(renderedSchemaName);
635
- const isMap = schemaType === "Map";
636
- const isRepeatable = getConverter(schemaName)?.checkRepetable?.(val) ?? Array.isArray(val);
637
- let parsedValue;
638
- if (isRepeatable) {
639
- parsedValue = val.map((v) => applyField(v, schemaName));
640
- } else if (isMap) {
641
- parsedValue = applyFieldOnMap(val, schemaName);
642
- } else {
643
- parsedValue = applyField(val, schemaName);
644
- }
645
- result[key] = parsedValue;
646
- });
647
- return result;
648
- }
649
- function applyField(val, schemaOrSerializer) {
650
- if (!schemaOrSerializer) {
651
- return val;
652
- }
653
- const maybeSchema = depSchemas[schemaOrSerializer];
654
- const maybeConverter = getConverter(schemaOrSerializer);
655
- if (maybeConverter) {
656
- return getConverter(schemaOrSerializer).transform(val);
657
- } else if (maybeSchema) {
658
- return transformSchema(maybeSchema, val);
659
- }
660
- throw new Error(`${schemaOrSerializer} is neither schema nor serializable type`);
661
- }
662
- function getConverter(name) {
663
- return converterSets[name]?.[converterType];
664
- }
665
- function applyFieldOnMap(val, sanitizedSchemaOrSerializer) {
666
- return Object.entries(val).reduce((acc, [propertyName, value]) => {
667
- acc[propertyName] = applyField(value, sanitizedSchemaOrSerializer);
668
- return acc;
669
- }, {});
670
- }
671
- };
672
- }
673
-
674
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/protobuf-converters/converters.js
675
- init_esm_shims();
676
-
677
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/protobuf-converters/timestamp.js
678
- init_esm_shims();
679
- var timestamp = {
680
- types: ["google.protobuf.Timestamp"],
681
- [ConverterType.TO_JSON]: {
682
- transform: (val) => {
683
- if (typeof val === "string" || !val) {
684
- return val;
685
- }
686
- return val.toISOString();
687
- }
688
- },
689
- [ConverterType.FROM_JSON]: {
690
- transform: (val) => val ? new Date(val) : val
691
- }
692
- };
693
-
694
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/protobuf-converters/field-mask.js
695
- init_esm_shims();
696
- var fieldMask = {
697
- types: ["google.protobuf.FieldMask"],
698
- [ConverterType.TO_JSON]: {
699
- transform: (val) => val.join(","),
700
- /**
701
- * This one handles cases where we have a repeated google.protobuf.FieldMask type,
702
- * so it will look like: [['foo', 'bar'], ['qux']].
703
- *
704
- * The problem is that the serializer detects it as an array with actual fields (strings),
705
- * while in practice it is an array of multiple google.protobuf.FieldMask.
706
- *
707
- * We should determine if the items are actual fields (so each item is a string),
708
- * or arrays of google.protobuf.FieldMask (so each item is array that has items with fields).
709
- *
710
- * Another approach could be marking on the schama itseld each field if it's a repeatable or not,
711
- * it's not a good appraoch, but as long as google.protobuf.FieldMask is our only issue, it's
712
- * not _that_ bad solution.
713
- */
714
- checkRepetable: (val) => {
715
- return val.some((v) => Array.isArray(v));
716
- }
717
- },
718
- [ConverterType.FROM_JSON]: {
719
- transform: (val) => {
720
- if (typeof val === "object") {
721
- return val.paths;
722
- }
723
- return val.split(",");
724
- }
725
- }
726
- };
727
-
728
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/protobuf-converters/bytes.js
729
- init_esm_shims();
730
- var bytes = {
731
- types: ["google.protobuf.BytesValue", "BYTES"],
732
- [ConverterType.TO_JSON]: {
733
- transform: (val) => {
734
- const chars = val.reduce((res, c) => res + String.fromCharCode(c), "");
735
- return btoa(chars);
736
- }
737
- },
738
- [ConverterType.FROM_JSON]: {
739
- transform: (val) => {
740
- return Uint8Array.from(atob(val), (c) => c.charCodeAt(0));
741
- }
742
- }
743
- };
744
-
745
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/protobuf-converters/duration.js
746
- init_esm_shims();
747
- var duration = {
748
- types: ["google.protobuf.Duration"],
749
- [ConverterType.TO_JSON]: {
750
- transform: ({ seconds: seconds2 = "0", nanos = 0 }) => {
751
- let nanosPortion = "";
752
- if (nanos !== 0) {
753
- nanosPortion = `.${nanos.toString().padStart(9, "0")}`;
754
- }
755
- return `${seconds2}${nanosPortion}s`;
756
- }
757
- },
758
- [ConverterType.FROM_JSON]: {
759
- transform: (val) => {
760
- const [seconds2, nanos] = val.substring(0, val.length - 1).split(".");
761
- return {
762
- seconds: seconds2,
763
- nanos: nanosForString(nanos)
764
- };
765
- }
766
- }
767
- };
768
- function nanosForString(nanos) {
769
- let res = 0;
770
- if (nanos !== void 0) {
771
- const precision = 3 - nanos.length / 3;
772
- res = parseInt(nanos, 10) * Math.pow(1e3, precision);
773
- }
774
- return res;
775
- }
776
-
777
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/protobuf-converters/float.js
778
- init_esm_shims();
779
- var float = {
780
- types: [
781
- "FLOAT",
782
- "DOUBLE",
783
- "google.protobuf.FloatValue",
784
- "google.protobuf.DoubleValue"
785
- ],
786
- [ConverterType.TO_JSON]: {
787
- transform: (val) => {
788
- return isFinite(val) ? val : val.toString();
789
- }
790
- },
791
- [ConverterType.FROM_JSON]: {
792
- transform: (val) => {
793
- if (val === "NaN") {
794
- return NaN;
795
- }
796
- if (val === "Infinity") {
797
- return Infinity;
798
- }
799
- if (val === "-Infinity") {
800
- return -Infinity;
801
- }
802
- return val;
803
- }
804
- }
805
- };
806
-
807
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/protobuf-converters/converters.js
808
- var protobufConverters = [
809
- timestamp,
810
- fieldMask,
811
- bytes,
812
- duration,
813
- float
814
- ];
815
-
816
- // ../../node_modules/@wix/metro-runtime/dist/esm/serializer/utils.js
817
- init_esm_shims();
818
- function typeToConverterSet(converterSets) {
819
- return converterSets.reduce((result, converterSet) => {
820
- const types = converterSet.types.reduce((typeResult, type) => {
821
- return {
822
- ...typeResult,
823
- [type]: converterSet
824
- };
825
- }, {});
826
- return {
827
- ...result,
828
- ...types
829
- };
830
- }, {});
831
- }
832
-
833
- // ../../node_modules/@wix/metro-runtime/dist/esm/ambassador-index.js
834
- var ambassadorConverters = typeToConverterSet([...protobufConverters]);
835
- function serializer(rootSchema, depSchemas = {}) {
836
- const transform = schemaSerializer(rootSchema, depSchemas, ambassadorConverters);
837
- return {
838
- fromJSON(jsonOrString) {
839
- const jsonOrText = safeJsonParse(jsonOrString) || jsonOrString;
840
- return transform(jsonOrText, ConverterType.FROM_JSON);
841
- },
842
- toJSON(json) {
843
- return transform(json, ConverterType.TO_JSON);
844
- }
845
- };
846
- }
847
- function safeJsonParse(someString) {
848
- try {
849
- return JSON.parse(someString);
850
- } catch (error) {
851
- }
852
- }
853
-
854
- // ../../node_modules/@wix/ambassador-identity-account-v2-account/build/es/http.impl.js
855
- var _account = {
856
- dateCreated: "google.protobuf.Timestamp",
857
- dateUpdated: "google.protobuf.Timestamp"
858
- };
859
- var _accountResponse = { account: "_account" };
860
- var _getMyAccountRequest = {};
861
- function resolveComWixpressAccountApiAccountServiceUrl(opts) {
862
- var domainToMappings = {
863
- "api._api_base_domain_": [
864
- {
865
- srcPath: "/account-server",
866
- destPath: ""
867
- }
868
- ],
869
- "www._base_domain_": [
870
- {
871
- srcPath: "/_api/account-server",
872
- destPath: ""
873
- }
874
- ],
875
- "manage._base_domain_": [
876
- {
877
- srcPath: "/_api/account-server",
878
- destPath: ""
879
- },
880
- {
881
- srcPath: "/account-server",
882
- destPath: ""
883
- }
884
- ],
885
- "premium._base_domain_": [
886
- {
887
- srcPath: "/_api/account-server",
888
- destPath: ""
889
- }
890
- ],
891
- "editor._base_domain_": [
892
- {
893
- srcPath: "/_api/account-server",
894
- destPath: ""
895
- }
896
- ],
897
- "blocks._base_domain_": [
898
- {
899
- srcPath: "/_api/account-server",
900
- destPath: ""
901
- }
902
- ],
903
- "create.editorx": [
904
- {
905
- srcPath: "/_api/account-server",
906
- destPath: ""
907
- }
908
- ],
909
- "bo._base_domain_": [
910
- {
911
- srcPath: "/account-server",
912
- destPath: ""
913
- }
914
- ],
915
- "wixbo.ai": [
916
- {
917
- srcPath: "/account-server",
918
- destPath: ""
919
- }
920
- ],
921
- "wix-bo.com": [
922
- {
923
- srcPath: "/account-server",
924
- destPath: ""
925
- }
926
- ],
927
- "www.wixapis.com": [
928
- {
929
- srcPath: "/accounts",
930
- destPath: ""
931
- },
932
- {
933
- srcPath: "/accounts/v1/accounts",
934
- destPath: "/v1/accounts"
935
- },
936
- {
937
- srcPath: "/accounts/v1/account",
938
- destPath: "/v1/account"
939
- }
940
- ],
941
- "users._base_domain_": [
942
- {
943
- srcPath: "/_api/account-server",
944
- destPath: ""
945
- }
946
- ],
947
- "*.dev.wix-code.com": [
948
- {
949
- srcPath: "/_api/account-server",
950
- destPath: ""
951
- }
952
- ],
953
- "twins._base_domain_": [
954
- {
955
- srcPath: "/_api/account-server",
956
- destPath: ""
957
- }
958
- ]
959
- };
960
- return resolveUrl(Object.assign(opts, { domainToMappings }));
961
- }
962
- function getMyAccount(payload4) {
963
- var _a = serializer(_getMyAccountRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
964
- var fromRes = serializer(_accountResponse, { _account }).fromJSON;
965
- function __getMyAccount(_a2) {
966
- var host = _a2.host;
967
- var serializedData = toReq(payload4);
968
- var metadata = {
969
- entityFqdn: "wix.identity.account.v2.account",
970
- method: "GET",
971
- methodFqn: "com.wixpress.account.api.AccountService.getMyAccount",
972
- url: resolveComWixpressAccountApiAccountServiceUrl({
973
- protoPath: "/v1/accounts/my_account",
974
- data: serializedData,
975
- host
976
- }),
977
- params: toURLSearchParams(serializedData),
978
- transformResponse: fromRes
979
- };
980
- return metadata;
981
- }
982
- __getMyAccount.fromReq = fromReq;
983
- __getMyAccount.__isAmbassador = true;
984
- return __getMyAccount;
985
- }
986
-
987
- // ../../node_modules/@wix/ambassador-identity-oauth-v1-refresh-token/build/es/http.impl.js
988
- init_esm_shims();
989
- var _deviceCodeRequest = {};
990
- var _deviceCodeResponse = {};
991
- var _rawHttpRequest = { body: "BYTES" };
992
- var _rawHttpResponse = { body: "BYTES" };
993
- var _revokeRefreshTokenRequest = {};
994
- var _revokeRefreshTokenResponse = {};
995
- function resolveWixIdentityOauth2V1Oauth2NgUrl(opts) {
996
- var domainToMappings = {
997
- "manage._base_domain_": [
998
- {
999
- srcPath: "/oauth2",
1000
- destPath: "/v1/oauth"
1001
- }
1002
- ],
1003
- "www.wixapis.com": [
1004
- {
1005
- srcPath: "/oauth2",
1006
- destPath: "/v1/oauth"
1007
- },
1008
- {
1009
- srcPath: "/oauth2/token_info",
1010
- destPath: "/v1/token_info"
1011
- }
1012
- ],
1013
- "users._base_domain_": [
1014
- {
1015
- srcPath: "/v1/oauth/device/verify",
1016
- destPath: "/v1/oauth/device/verify"
1017
- },
1018
- {
1019
- srcPath: "/v1/oauth/manage/user-code",
1020
- destPath: "/v1/oauth/manage/user-code"
1021
- },
1022
- {
1023
- srcPath: "/v2/oauth/device/verify",
1024
- destPath: "/v2/oauth/device/verify"
1025
- },
1026
- {
1027
- srcPath: "/v1/oauth/authorize",
1028
- destPath: "/v1/oauth/authorize"
1029
- },
1030
- {
1031
- srcPath: "/v1/oauth/user-info",
1032
- destPath: "/v1/oauth/user-info"
1033
- },
1034
- {
1035
- srcPath: "/iam/wix-idp/v1/oauth/token",
1036
- destPath: "/v1/oauth/token"
1037
- },
1038
- {
1039
- srcPath: "/iam/wix-idp/v1/oauth/user-info",
1040
- destPath: "/v1/oauth/user-info"
1041
- }
1042
- ],
1043
- _: [
1044
- {
1045
- srcPath: "/_api/oauth2",
1046
- destPath: "/v1/oauth"
1047
- }
1048
- ],
1049
- "platform.rise.ai": [
1050
- {
1051
- srcPath: "/oauth2",
1052
- destPath: "/v1/oauth"
1053
- }
1054
- ],
1055
- "api._api_base_domain_": [
1056
- {
1057
- srcPath: "/oauth2-ng",
1058
- destPath: ""
1059
- }
1060
- ],
1061
- "apps._base_domain_": [
1062
- {
1063
- srcPath: "/oauth2/callback",
1064
- destPath: "/oauth2/callback"
1065
- }
1066
- ],
1067
- "editor._base_domain_": [
1068
- {
1069
- srcPath: "/oauth2/callback",
1070
- destPath: "/oauth2/callback"
1071
- }
1072
- ],
1073
- "blocks._base_domain_": [
1074
- {
1075
- srcPath: "/oauth2/callback",
1076
- destPath: "/oauth2/callback"
1077
- }
1078
- ],
1079
- "create.editorx": [
1080
- {
1081
- srcPath: "/oauth2/callback",
1082
- destPath: "/oauth2/callback"
1083
- }
1084
- ]
1085
- };
1086
- return resolveUrl(Object.assign(opts, { domainToMappings }));
1087
- }
1088
- function token(payload4) {
1089
- var _a = serializer(_rawHttpRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
1090
- var fromRes = serializer(_rawHttpResponse, {}).fromJSON;
1091
- function __token(_a2) {
1092
- var host = _a2.host;
1093
- var serializedData = toReq(payload4);
1094
- var metadata = {
1095
- entityFqdn: "wix.identity.oauth.v1.refresh_token",
1096
- method: "POST",
1097
- methodFqn: "wix.identity.oauth2.v1.Oauth2Ng.Token",
1098
- url: resolveWixIdentityOauth2V1Oauth2NgUrl({
1099
- protoPath: "/v1/oauth/token",
1100
- data: serializedData,
1101
- host
1102
- }),
1103
- data: serializedData,
1104
- transformResponse: fromRes
1105
- };
1106
- return metadata;
1107
- }
1108
- __token.fromReq = fromReq;
1109
- __token.__isAmbassador = true;
1110
- return __token;
1111
- }
1112
- function deviceCode(payload4) {
1113
- var _a = serializer(_deviceCodeRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
1114
- var fromRes = serializer(_deviceCodeResponse, {}).fromJSON;
1115
- function __deviceCode(_a2) {
1116
- var host = _a2.host;
1117
- var serializedData = toReq(payload4);
1118
- var metadata = {
1119
- entityFqdn: "wix.identity.oauth.v1.refresh_token",
1120
- method: "GET",
1121
- methodFqn: "wix.identity.oauth2.v1.Oauth2Ng.DeviceCode",
1122
- url: resolveWixIdentityOauth2V1Oauth2NgUrl({
1123
- protoPath: "/v1/oauth/device/code",
1124
- data: serializedData,
1125
- host
1126
- }),
1127
- params: toURLSearchParams(serializedData),
1128
- transformResponse: fromRes
1129
- };
1130
- return metadata;
1131
- }
1132
- __deviceCode.fromReq = fromReq;
1133
- __deviceCode.__isAmbassador = true;
1134
- return __deviceCode;
1135
- }
1136
- function revokeRefreshToken(payload4) {
1137
- var _a = serializer(_revokeRefreshTokenRequest, {}), toReq = _a.toJSON, fromReq = _a.fromJSON;
1138
- var fromRes = serializer(_revokeRefreshTokenResponse, {}).fromJSON;
1139
- function __revokeRefreshToken(_a2) {
1140
- var host = _a2.host;
1141
- var serializedData = toReq(payload4);
1142
- var metadata = {
1143
- entityFqdn: "wix.identity.oauth.v1.refresh_token",
1144
- method: "POST",
1145
- methodFqn: "wix.identity.oauth2.v1.Oauth2Ng.RevokeRefreshToken",
1146
- url: resolveWixIdentityOauth2V1Oauth2NgUrl({
1147
- protoPath: "/v1/oauth/revoke",
1148
- data: serializedData,
1149
- host
1150
- }),
1151
- data: serializedData,
1152
- transformResponse: fromRes
1153
- };
1154
- return metadata;
1155
- }
1156
- __revokeRefreshToken.fromReq = fromReq;
1157
- __revokeRefreshToken.__isAmbassador = true;
1158
- return __revokeRefreshToken;
1159
- }
1160
-
1161
- // ../cli-http-client/src/create-http-client.ts
1162
- init_esm_shims();
1163
- var import_http_client2 = __toESM(require_index_node(), 1);
1164
-
1165
- // ../cli-http-client/src/is-http-error.ts
1166
- init_esm_shims();
1167
- var import_http_client = __toESM(require_index_node(), 1);
1168
- function isHttpError(error) {
1169
- return import_http_client.HttpClient.isHttpError(error);
1170
- }
1171
- var validationErrorSchema = z.object({
1172
- details: z.object({
1173
- validationError: z.object({
1174
- fieldViolations: z.array(
1175
- z.object({
1176
- description: z.string(),
1177
- field: z.string()
1178
- })
1179
- ).nonempty()
1180
- })
1181
- })
1182
- });
1183
- function isHttpValidationError(error) {
1184
- if (error.response?.data?.details?.validationError) {
1185
- const result = validationErrorSchema.safeParse(error.response.data);
1186
- if (result.success) {
1187
- return true;
1188
- }
1189
- throw new CliError({
1190
- cause: error,
1191
- code: CliErrorCode.FailedToParseHttpErrorResponse(),
1192
- info: {
1193
- zodError: result.error
1194
- }
1195
- });
1196
- }
1197
- return false;
1198
- }
1199
- var applicationErrorSchema = z.object({
1200
- details: z.object({
1201
- applicationError: z.object({
1202
- code: z.string()
1203
- })
1204
- })
1205
- });
1206
- function isHttpApplicationError(error) {
1207
- if (error.response?.data?.details?.applicationError) {
1208
- const result = applicationErrorSchema.safeParse(error.response.data);
1209
- if (result.success) {
1210
- return true;
1211
- }
1212
- throw new CliError({
1213
- cause: error,
1214
- code: CliErrorCode.FailedToParseHttpErrorResponse(),
1215
- info: {
1216
- zodError: result.error
1217
- }
1218
- });
1219
- }
1220
- return false;
1221
- }
1222
-
1223
- // ../cli-http-client/src/create-http-client.ts
1224
- var baseUrls = {
1225
- backoffice: "https://manage.wix.com",
1226
- editor: "https://editor.wix.com",
1227
- code: "https://code.wix.com",
1228
- general: "https://www.wix.com",
1229
- api: "https://www.wixapis.com",
1230
- standalone: void 0
1231
- };
1232
- function interceptRequest(client2, fn) {
1233
- return (...args) => fn.apply(client2, args).catch((error) => {
1234
- if (isHttpError(error) && !client2.isCancel(error) && !error.response) {
1235
- throw new CliError({
1236
- code: CliErrorCode.NetworkError(),
1237
- cause: error,
1238
- info: { code: error.code }
1239
- });
1240
- }
1241
- throw error;
1242
- });
1243
- }
1244
- function createHttpClient({
1245
- getAppToken,
1246
- createHeaders,
1247
- type
1248
- }) {
1249
- const client2 = (0, import_http_client2.createHttpClient)({
1250
- baseURL: baseUrls[type],
1251
- ...type !== "standalone" ? {
1252
- getAppToken
1253
- } : {},
1254
- createHeaders: () => ({
1255
- ...createHeaders?.(),
1256
- // See https://wix.slack.com/archives/C0JLGMT28/p1667219337530909
1257
- "X-XSRF-TOKEN": "nocheck",
1258
- Cookie: "XSRF-TOKEN=nocheck",
1259
- "User-Agent": "wix-cli"
1260
- })
1261
- });
1262
- return {
1263
- ...client2,
1264
- request: interceptRequest(client2, client2.request),
1265
- get: interceptRequest(client2, client2.get),
1266
- delete: interceptRequest(client2, client2.delete),
1267
- head: interceptRequest(client2, client2.head),
1268
- options: interceptRequest(client2, client2.options),
1269
- post: interceptRequest(client2, client2.post),
1270
- put: interceptRequest(client2, client2.put),
1271
- patch: interceptRequest(client2, client2.patch)
1272
- };
1273
- }
1274
-
1275
- // ../cli-auth/src/client.ts
1276
- var import_variant = __toESM(require_lib(), 1);
1277
-
1278
- // ../cli-auth/src/schemas.ts
1279
- init_esm_shims();
1280
- var deviceCodeSchema = z.object({
1281
- deviceCode: z.string(),
1282
- verificationUri: z.string().url(),
1283
- userCode: z.string(),
1284
- expiresIn: z.number()
1285
- });
1286
- var tokenSchema = z.object({
1287
- access_token: z.string(),
1288
- refresh_token: z.string(),
1289
- expires_in: z.number()
1290
- }).transform((token2) => ({
1291
- accessToken: token2.access_token,
1292
- refreshToken: token2.refresh_token,
1293
- expiresIn: token2.expires_in
1294
- }));
1295
- var userInfoSchema = z.object({
1296
- userId: z.string().uuid(),
1297
- email: z.string().email()
1298
- });
1299
- var getMyAccountSchema = z.object({
1300
- account: z.object({
1301
- slug: z.string(),
1302
- accountId: z.string().uuid(),
1303
- accountOwner: z.string().uuid()
1304
- })
1305
- });
1306
- var siteAuthSchema = z.object({
1307
- accessToken: z.string(),
1308
- refreshToken: z.string(),
1309
- expiresIn: z.number(),
1310
- issuedAt: z.number()
1311
- });
1312
- var accountAuthSchema = siteAuthSchema.extend({
1313
- userInfo: userInfoSchema
1314
- });
1315
- var apiKeyAuthSchema = z.object({
1316
- token: z.string(),
1317
- accountId: z.string().uuid(),
1318
- userInfo: z.object({
1319
- userId: z.string().uuid(),
1320
- email: z.string()
1321
- })
1322
- });
1323
-
1324
- // ../cli-auth/src/client.ts
1325
- var {
1326
- InvalidResponseData,
1327
- FailedToGetAuthToken,
1328
- FailedToGetDeviceCode,
1329
- FailedToRenewAuthToken,
1330
- FailedToRenewAuthTokenSiteNotFound,
1331
- FailedToRevokeRefreshToken
1332
- } = CliErrorCode;
1333
- var clientId = "6f95cec8-3e98-48b9-b4e5-1fb92fcd9973";
1334
- var getCurrentTimestamp = () => Math.floor(Date.now() / 1e3);
1335
- var DeviceCodeNotYetVerifiedError = class extends Error {
1336
- };
1337
- var RenewTokenData = (0, import_variant.variant)({
1338
- TokenRenewed: (0, import_variant.payload)(),
1339
- RefreshTokenRevoked: (0, import_variant.fields)()
1340
- });
1341
- var AuthClient = class {
1342
- constructor(httpClient) {
1343
- this.httpClient = httpClient;
1344
- const { minRetryTimeout } = getTestOverrides();
1345
- this.retryOptions = {
1346
- retries: 3,
1347
- minTimeout: minRetryTimeout,
1348
- maxTimeout: 3 * 1e3
1349
- };
1350
- }
1351
- retryOptions;
1352
- async requestDeviceCode(req = {}) {
1353
- try {
1354
- const { data } = await pRetry(
1355
- () => this.httpClient.request(deviceCode({ ...req, clientId })),
1356
- this.retryOptions
1357
- );
1358
- return deviceCodeSchema.parse(data);
1359
- } catch (error) {
1360
- throw new CliError({
1361
- code: FailedToGetDeviceCode(),
1362
- cause: error
1363
- });
1364
- }
1365
- }
1366
- async createToken(req) {
1367
- try {
1368
- const payload4 = {
1369
- clientId,
1370
- grantType: "urn:ietf:params:oauth:grant-type:device_code",
1371
- scope: "offline_access",
1372
- ...req
1373
- };
1374
- const tokenData = await pRetry(async () => {
1375
- const { data, requestId } = await this.httpClient.request(
1376
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1377
- token(payload4)
1378
- );
1379
- const result = tokenSchema.safeParse(data);
1380
- if (result.success) {
1381
- return result.data;
1382
- }
1383
- throw new CliError({
1384
- code: InvalidResponseData(),
1385
- cause: result.error,
1386
- info: { requestId, data }
1387
- });
1388
- }, this.retryOptions);
1389
- return {
1390
- ...tokenData,
1391
- issuedAt: getCurrentTimestamp()
1392
- };
1393
- } catch (error) {
1394
- if (isHttpError(error) && (error.response?.data?.message === "Device code is not yet verified" || // https://github.com/wix-private/wix-cli/pull/655#discussion_r1145992702
1395
- error.response?.data?.error === "authorization_pending")) {
1396
- throw new DeviceCodeNotYetVerifiedError(
1397
- "Device code is not yet verified."
1398
- );
1399
- }
1400
- throw new CliError({
1401
- code: FailedToGetAuthToken(),
1402
- cause: error
1403
- });
1404
- }
1405
- }
1406
- async renewToken(req) {
1407
- try {
1408
- const payload4 = {
1409
- clientId,
1410
- grantType: "refresh_token",
1411
- ...req
1412
- };
1413
- const { data } = await pRetry(
1414
- () => this.httpClient.request(
1415
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1416
- token(payload4)
1417
- ),
1418
- this.retryOptions
1419
- );
1420
- const tokenData = tokenSchema.parse(data);
1421
- return RenewTokenData.TokenRenewed({
1422
- ...tokenData,
1423
- issuedAt: getCurrentTimestamp()
1424
- });
1425
- } catch (error) {
1426
- if (isHttpError(error)) {
1427
- if (error.response?.status === 400 && error.response.data?.error === "invalid_grant") {
1428
- return RenewTokenData.RefreshTokenRevoked({ cause: error });
1429
- }
1430
- if (req.siteId && error.response?.status === 404 && isHttpApplicationError(error) && error.response.data.details.applicationError.code === "SITE_NOT_FOUND") {
1431
- throw new CliError({
1432
- code: FailedToRenewAuthTokenSiteNotFound({ siteId: req.siteId }),
1433
- cause: error
1434
- });
1435
- }
1436
- }
1437
- throw new CliError({
1438
- code: FailedToRenewAuthToken(),
1439
- cause: error
1440
- });
1441
- }
1442
- }
1443
- async revokeRefreshToken(req, { email }) {
1444
- try {
1445
- const { data } = await this.httpClient.request(revokeRefreshToken(req));
1446
- return data;
1447
- } catch (error) {
1448
- throw new CliError({
1449
- code: FailedToRevokeRefreshToken({
1450
- email
1451
- }),
1452
- info: {
1453
- email
1454
- },
1455
- cause: error
1456
- });
1457
- }
1458
- }
1459
- async userInfo({ accessToken }) {
1460
- try {
1461
- const httpClient = createHttpClient({
1462
- type: "backoffice",
1463
- getAppToken: async () => accessToken
1464
- });
1465
- const { data: userInfoData } = await httpClient.get(
1466
- "/_serverless/wix-cli-userinfo/userinfo"
1467
- );
1468
- return userInfoSchema.parse(userInfoData);
1469
- } catch (error) {
1470
- throw new CliError({
1471
- code: CliErrorCode.FailedToGetUserInfo(),
1472
- cause: error
1473
- });
1474
- }
1475
- }
1476
- async getMyAccount({ token: token2 }) {
1477
- try {
1478
- const httpClient = createHttpClient({
1479
- type: "backoffice",
1480
- getAppToken: async () => token2
1481
- });
1482
- const { data } = await httpClient.request(getMyAccount({}));
1483
- return getMyAccountSchema.parse(data).account;
1484
- } catch (error) {
1485
- if (isHttpError(error) && error.response?.status === 428 && isHttpApplicationError(error) && error.response.data.details.applicationError.code === "48876") {
1486
- throw new CliError({
1487
- code: CliErrorCode.InvalidApiKey(),
1488
- cause: error
1489
- });
1490
- }
1491
- throw new CliError({
1492
- code: CliErrorCode.FailedToGetMyAccount(),
1493
- cause: error
1494
- });
1495
- }
1496
- }
1497
- };
1498
- var client = new AuthClient(createHttpClient({ type: "backoffice" }));
1499
-
1500
- // ../cli-auth/src/auth-data.ts
1501
- init_esm_shims();
1502
- import { unlink, rm } from "node:fs/promises";
1503
- import { resolve } from "node:path";
1504
- var import_variant2 = __toESM(require_lib(), 1);
1505
- function getLegacyAuthDataFilePath() {
1506
- return resolve(getDataDirPath(), "auth.json");
1507
- }
1508
- function getAuthDataFolder() {
1509
- return resolve(getDataDirPath(), "auth");
1510
- }
1511
- function getApiKeyAuthDataFilePath() {
1512
- return resolve(getAuthDataFolder(), "api-key.json");
1513
- }
1514
- function getAccountAuthDataFilePath() {
1515
- return resolve(getAuthDataFolder(), "account.json");
1516
- }
1517
- function getSiteAuthDataFilePath(siteId) {
1518
- return resolve(getAuthDataFolder(), `${siteId}.json`);
1519
- }
1520
- var ApiKeyAuthData = (0, import_variant2.variant)({
1521
- Authenticated: (0, import_variant2.payload)(),
1522
- Unauthenticated: {}
1523
- });
1524
- async function readApiKeyAuthData() {
1525
- const apiKeyAuthDataFilePath = getApiKeyAuthDataFilePath();
1526
- if (!await pathExists(apiKeyAuthDataFilePath)) {
1527
- return ApiKeyAuthData.Unauthenticated();
1528
- }
1529
- const apiKeyFileContents = await readJson(apiKeyAuthDataFilePath);
1530
- const savedApiKeyAuthData = apiKeyAuthSchema.parse(apiKeyFileContents);
1531
- return ApiKeyAuthData.Authenticated(savedApiKeyAuthData);
1532
- }
1533
- async function saveApiKeyAuthData(authData) {
1534
- try {
1535
- const targetFilePath = getApiKeyAuthDataFilePath();
1536
- await writeJson(targetFilePath, authData);
1537
- } catch (error) {
1538
- throw new CliError({
1539
- code: CliErrorCode.FailedToSaveApiKeyAuthData(),
1540
- cause: error
1541
- });
1542
- }
1543
- }
1544
- var AccountAuthData = (0, import_variant2.variant)({
1545
- Authenticated: (0, import_variant2.fields)(),
1546
- Unauthenticated: {},
1547
- Expired: (0, import_variant2.fields)()
1548
- });
1549
- async function readAccountAuthData() {
1550
- const accountAuthDataFilePath = getAccountAuthDataFilePath();
1551
- if (!await pathExists(accountAuthDataFilePath)) {
1552
- return AccountAuthData.Unauthenticated();
1553
- }
1554
- const authFileContents = await readJson(accountAuthDataFilePath);
1555
- const savedAccountAuthData = accountAuthSchema.parse(authFileContents);
1556
- if (!isValidToken(savedAccountAuthData)) {
1557
- return AccountAuthData.Expired(savedAccountAuthData);
1558
- }
1559
- return AccountAuthData.Authenticated(savedAccountAuthData);
1560
- }
1561
- var SiteAuthData = (0, import_variant2.variant)({
1562
- Authenticated: (0, import_variant2.fields)(),
1563
- Unauthenticated: {},
1564
- Expired: (0, import_variant2.fields)()
1565
- });
1566
- async function readSiteAuthData(siteId) {
1567
- const siteAuthDataFilePath = getSiteAuthDataFilePath(siteId);
1568
- if (!await pathExists(siteAuthDataFilePath)) {
1569
- return SiteAuthData.Unauthenticated();
1570
- }
1571
- const authFileContents = await readJson(siteAuthDataFilePath);
1572
- const savedSiteAuthData = siteAuthSchema.parse(authFileContents);
1573
- if (!isValidToken(savedSiteAuthData)) {
1574
- return SiteAuthData.Expired(savedSiteAuthData);
1575
- }
1576
- return SiteAuthData.Authenticated(savedSiteAuthData);
1577
- }
1578
- async function saveAuthData(authData, siteId) {
1579
- try {
1580
- const targetFilePath = siteId ? getSiteAuthDataFilePath(siteId) : getAccountAuthDataFilePath();
1581
- await writeJson(targetFilePath, authData);
1582
- } catch (error) {
1583
- throw new CliError({
1584
- code: CliErrorCode.FailedToSaveAuthData(),
1585
- cause: error
1586
- });
1587
- }
1588
- }
1589
- async function deleteAuthData() {
1590
- try {
1591
- await rm(getAuthDataFolder(), { recursive: true, force: true });
1592
- } catch (error) {
1593
- throw new CliError({
1594
- code: CliErrorCode.FailedToDeleteAuthData(),
1595
- cause: error
1596
- });
1597
- }
1598
- if (await hasLegacyAuthData()) {
1599
- await deleteLegacyAuthData();
1600
- }
1601
- }
1602
- async function deleteLegacyAuthData() {
1603
- try {
1604
- await unlink(getLegacyAuthDataFilePath());
1605
- } catch (error) {
1606
- throw new CliError({
1607
- code: CliErrorCode.FailedToDeleteLegacyAuthData(),
1608
- cause: error
1609
- });
1610
- }
1611
- }
1612
- async function hasLegacyAuthData() {
1613
- return pathExists(getLegacyAuthDataFilePath());
1614
- }
1615
- function isValidToken(authData) {
1616
- const currentTimestamp = Math.floor(Date.now() / 1e3);
1617
- const tokenOffset = 10 * 60;
1618
- const tokenLifetime = authData.expiresIn - tokenOffset;
1619
- const tokenGenerationTimestamp = authData.issuedAt;
1620
- return tokenGenerationTimestamp + tokenLifetime > currentTimestamp;
1621
- }
1622
- async function getUserInfo() {
1623
- const apiKeyAuthData = await readApiKeyAuthData();
1624
- if ((0, import_variant2.isType)(apiKeyAuthData, ApiKeyAuthData.Authenticated)) {
1625
- return apiKeyAuthData.payload.userInfo;
1626
- }
1627
- const accountAuthData = await readAccountAuthData();
1628
- return (0, import_variant2.match)(accountAuthData, {
1629
- Authenticated: ({ userInfo }) => userInfo,
1630
- Expired: ({ userInfo }) => userInfo,
1631
- Unauthenticated: () => null
1632
- });
1633
- }
1634
-
1635
- // ../cli-auth/src/auth-strategies/api-key-auth-strategy.ts
1636
- function createApiKeyAuthState({
1637
- authData: { token: token2, accountId, userInfo },
1638
- siteId
1639
- }) {
1640
- return {
1641
- getAccessToken: async () => token2,
1642
- getRefreshToken: () => {
1643
- throw new Error("API key auth does not support refresh tokens");
1644
- },
1645
- getRequestHeaders: () => {
1646
- if (siteId) {
1647
- return { "wix-site-id": siteId };
1648
- }
1649
- return { "wix-account-id": accountId };
1650
- },
1651
- userInfo
1652
- };
1653
- }
1654
- var apiKeyAuthStrategy = {
1655
- async isLoggedIn({ siteId } = {}) {
1656
- const apiKeyAuth = await readApiKeyAuthData();
1657
- return (0, import_variant3.match)(apiKeyAuth, {
1658
- Authenticated: ({ payload: payload4 }) => {
1659
- return createApiKeyAuthState({ authData: payload4, siteId });
1660
- },
1661
- Unauthenticated: () => null
1662
- });
1663
- },
1664
- async login({ token: token2 }) {
1665
- const { accountId, accountOwner, slug } = await client.getMyAccount({
1666
- token: token2
1667
- });
1668
- const authData = {
1669
- token: token2,
1670
- accountId,
1671
- userInfo: {
1672
- userId: accountOwner,
1673
- // TODO: this should be the email of the account owner, not the slug
1674
- // https://jira.wixpress.com/browse/FEDINF-12201
1675
- email: slug
1676
- }
1677
- };
1678
- await deleteAuthData();
1679
- await saveApiKeyAuthData(authData);
1680
- return createApiKeyAuthState({ authData });
1681
- }
1682
- };
1683
-
1684
- // ../cli-auth/src/auth-strategies/account-auth-strategy.ts
1685
- init_esm_shims();
1686
-
1687
- // ../../node_modules/p-limit/index.js
1688
- init_esm_shims();
1689
-
1690
- // ../../node_modules/p-limit/node_modules/yocto-queue/index.js
1691
- init_esm_shims();
1692
- var Node = class {
1693
- value;
1694
- next;
1695
- constructor(value) {
1696
- this.value = value;
1697
- }
1698
- };
1699
- var Queue = class {
1700
- #head;
1701
- #tail;
1702
- #size;
1703
- constructor() {
1704
- this.clear();
1705
- }
1706
- enqueue(value) {
1707
- const node = new Node(value);
1708
- if (this.#head) {
1709
- this.#tail.next = node;
1710
- this.#tail = node;
1711
- } else {
1712
- this.#head = node;
1713
- this.#tail = node;
1714
- }
1715
- this.#size++;
1716
- }
1717
- dequeue() {
1718
- const current = this.#head;
1719
- if (!current) {
1720
- return;
1721
- }
1722
- this.#head = this.#head.next;
1723
- this.#size--;
1724
- return current.value;
1725
- }
1726
- peek() {
1727
- if (!this.#head) {
1728
- return;
1729
- }
1730
- return this.#head.value;
1731
- }
1732
- clear() {
1733
- this.#head = void 0;
1734
- this.#tail = void 0;
1735
- this.#size = 0;
1736
- }
1737
- get size() {
1738
- return this.#size;
1739
- }
1740
- *[Symbol.iterator]() {
1741
- let current = this.#head;
1742
- while (current) {
1743
- yield current.value;
1744
- current = current.next;
1745
- }
1746
- }
1747
- };
1748
-
1749
- // ../../node_modules/p-limit/index.js
1750
- function pLimit(concurrency) {
1751
- validateConcurrency(concurrency);
1752
- const queue = new Queue();
1753
- let activeCount = 0;
1754
- const resumeNext = () => {
1755
- if (activeCount < concurrency && queue.size > 0) {
1756
- queue.dequeue()();
1757
- activeCount++;
1758
- }
1759
- };
1760
- const next = () => {
1761
- activeCount--;
1762
- resumeNext();
1763
- };
1764
- const run = async (function_, resolve2, arguments_) => {
1765
- const result = (async () => function_(...arguments_))();
1766
- resolve2(result);
1767
- try {
1768
- await result;
1769
- } catch {
1770
- }
1771
- next();
1772
- };
1773
- const enqueue = (function_, resolve2, arguments_) => {
1774
- new Promise((internalResolve) => {
1775
- queue.enqueue(internalResolve);
1776
- }).then(
1777
- run.bind(void 0, function_, resolve2, arguments_)
1778
- );
1779
- (async () => {
1780
- await Promise.resolve();
1781
- if (activeCount < concurrency) {
1782
- resumeNext();
1783
- }
1784
- })();
1785
- };
1786
- const generator = (function_, ...arguments_) => new Promise((resolve2) => {
1787
- enqueue(function_, resolve2, arguments_);
1788
- });
1789
- Object.defineProperties(generator, {
1790
- activeCount: {
1791
- get: () => activeCount
1792
- },
1793
- pendingCount: {
1794
- get: () => queue.size
1795
- },
1796
- clearQueue: {
1797
- value() {
1798
- queue.clear();
1799
- }
1800
- },
1801
- concurrency: {
1802
- get: () => concurrency,
1803
- set(newConcurrency) {
1804
- validateConcurrency(newConcurrency);
1805
- concurrency = newConcurrency;
1806
- queueMicrotask(() => {
1807
- while (activeCount < concurrency && queue.size > 0) {
1808
- resumeNext();
1809
- }
1810
- });
1811
- }
1812
- }
1813
- });
1814
- return generator;
1815
- }
1816
- function validateConcurrency(concurrency) {
1817
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
1818
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
1819
- }
1820
- }
1821
-
1822
- // ../cli-auth/src/auth-strategies/account-auth-strategy.ts
1823
- var import_variant4 = __toESM(require_lib(), 1);
1824
-
1825
- // ../../node_modules/p-wait-for/index.js
1826
- init_esm_shims();
1827
-
1828
- // ../../node_modules/p-timeout/index.js
1829
- init_esm_shims();
1830
- var TimeoutError = class extends Error {
1831
- constructor(message) {
1832
- super(message);
1833
- this.name = "TimeoutError";
1834
- }
1835
- };
1836
- var AbortError2 = class extends Error {
1837
- constructor(message) {
1838
- super();
1839
- this.name = "AbortError";
1840
- this.message = message;
1841
- }
1842
- };
1843
- var getDOMException = (errorMessage) => globalThis.DOMException === void 0 ? new AbortError2(errorMessage) : new DOMException(errorMessage);
1844
- var getAbortedReason = (signal) => {
1845
- const reason = signal.reason === void 0 ? getDOMException("This operation was aborted.") : signal.reason;
1846
- return reason instanceof Error ? reason : getDOMException(reason);
1847
- };
1848
- function pTimeout(promise, options) {
1849
- const {
1850
- milliseconds,
1851
- fallback,
1852
- message,
1853
- customTimers = { setTimeout, clearTimeout }
1854
- } = options;
1855
- let timer;
1856
- let abortHandler;
1857
- const wrappedPromise = new Promise((resolve2, reject) => {
1858
- if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
1859
- throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
1860
- }
1861
- if (options.signal) {
1862
- const { signal } = options;
1863
- if (signal.aborted) {
1864
- reject(getAbortedReason(signal));
1865
- }
1866
- abortHandler = () => {
1867
- reject(getAbortedReason(signal));
1868
- };
1869
- signal.addEventListener("abort", abortHandler, { once: true });
1870
- }
1871
- if (milliseconds === Number.POSITIVE_INFINITY) {
1872
- promise.then(resolve2, reject);
1873
- return;
1874
- }
1875
- const timeoutError = new TimeoutError();
1876
- timer = customTimers.setTimeout.call(void 0, () => {
1877
- if (fallback) {
1878
- try {
1879
- resolve2(fallback());
1880
- } catch (error) {
1881
- reject(error);
1882
- }
1883
- return;
1884
- }
1885
- if (typeof promise.cancel === "function") {
1886
- promise.cancel();
1887
- }
1888
- if (message === false) {
1889
- resolve2();
1890
- } else if (message instanceof Error) {
1891
- reject(message);
1892
- } else {
1893
- timeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;
1894
- reject(timeoutError);
1895
- }
1896
- }, milliseconds);
1897
- (async () => {
1898
- try {
1899
- resolve2(await promise);
1900
- } catch (error) {
1901
- reject(error);
1902
- }
1903
- })();
1904
- });
1905
- const cancelablePromise = wrappedPromise.finally(() => {
1906
- cancelablePromise.clear();
1907
- if (abortHandler && options.signal) {
1908
- options.signal.removeEventListener("abort", abortHandler);
1909
- }
1910
- });
1911
- cancelablePromise.clear = () => {
1912
- customTimers.clearTimeout.call(void 0, timer);
1913
- timer = void 0;
1914
- };
1915
- return cancelablePromise;
1916
- }
1917
-
1918
- // ../../node_modules/p-wait-for/index.js
1919
- var resolveValue = Symbol("resolveValue");
1920
- async function pWaitFor(condition, options = {}) {
1921
- const {
1922
- interval = 20,
1923
- timeout = Number.POSITIVE_INFINITY,
1924
- before = true
1925
- } = options;
1926
- let retryTimeout;
1927
- let abort = false;
1928
- const promise = new Promise((resolve2, reject) => {
1929
- const check = async () => {
1930
- try {
1931
- const value = await condition();
1932
- if (typeof value === "object" && value[resolveValue]) {
1933
- resolve2(value[resolveValue]);
1934
- } else if (typeof value !== "boolean") {
1935
- throw new TypeError("Expected condition to return a boolean");
1936
- } else if (value === true) {
1937
- resolve2();
1938
- } else if (!abort) {
1939
- retryTimeout = setTimeout(check, interval);
1940
- }
1941
- } catch (error) {
1942
- reject(error);
1943
- }
1944
- };
1945
- if (before) {
1946
- check();
1947
- } else {
1948
- retryTimeout = setTimeout(check, interval);
1949
- }
1950
- });
1951
- if (timeout === Number.POSITIVE_INFINITY) {
1952
- return promise;
1953
- }
1954
- try {
1955
- return await pTimeout(promise, typeof timeout === "number" ? { milliseconds: timeout } : timeout);
1956
- } finally {
1957
- abort = true;
1958
- clearTimeout(retryTimeout);
1959
- }
1960
- }
1961
- pWaitFor.resolveWith = (value) => ({ [resolveValue]: value });
1962
-
1963
- // ../cli-auth/src/auth-strategies/account-auth-strategy.ts
1964
- var seconds = (n) => 1e3 * n;
1965
- async function waitForLogin({ deviceCode: deviceCode2, expiresIn }, { signal }) {
1966
- try {
1967
- const authData = await pWaitFor(
1968
- async () => {
1969
- try {
1970
- const tokenData = await client.createToken({
1971
- deviceCode: deviceCode2
1972
- });
1973
- return pWaitFor.resolveWith(tokenData);
1974
- } catch (error) {
1975
- if (error instanceof DeviceCodeNotYetVerifiedError) {
1976
- return false;
1977
- }
1978
- throw error;
1979
- }
1980
- },
1981
- {
1982
- interval: getTestOverrides().waitForLoginInterval ?? seconds(3),
1983
- timeout: { milliseconds: seconds(expiresIn), signal }
1984
- }
1985
- );
1986
- const userInfo = await client.userInfo({
1987
- accessToken: authData.accessToken
1988
- });
1989
- const result = { ...authData, userInfo };
1990
- await deleteAuthData();
1991
- await saveAuthData(result);
1992
- return result;
1993
- } catch (error) {
1994
- if (error instanceof TimeoutError) {
1995
- throw new CliError({
1996
- code: CliErrorCode.DeviceCodeTimedOut(),
1997
- cause: error
1998
- });
1999
- }
2000
- throw error;
2001
- }
2002
- }
2003
- async function renewAccountAuth({ refreshToken, userInfo }) {
2004
- const renewTokenResult = await client.renewToken({ refreshToken });
2005
- if ((0, import_variant4.isType)(renewTokenResult, RenewTokenData.TokenRenewed)) {
2006
- await saveAuthData({ ...renewTokenResult.payload, userInfo });
2007
- }
2008
- return renewTokenResult;
2009
- }
2010
- async function getNonExpiredAccountAuth() {
2011
- const accountAuthStatus = await readAccountAuthData();
2012
- return (0, import_variant4.match)(accountAuthStatus, {
2013
- Authenticated: (accountAuth) => accountAuth,
2014
- Unauthenticated: () => null,
2015
- Expired: async (accountAuth) => {
2016
- const renewTokenResult = await renewAccountAuth(accountAuth);
2017
- return (0, import_variant4.match)(renewTokenResult, {
2018
- TokenRenewed: ({ payload: newTokenData }) => ({
2019
- ...newTokenData,
2020
- userInfo: accountAuth.userInfo
2021
- }),
2022
- RefreshTokenRevoked: (0, import_variant4.constant)(null)
2023
- });
2024
- }
2025
- });
2026
- }
2027
- function createAccountAuthState({
2028
- userInfo,
2029
- ...initialTokenData
2030
- }) {
2031
- const limiter = pLimit(1);
2032
- let tokenData = { ...initialTokenData };
2033
- return {
2034
- getAccessToken: () => {
2035
- return limiter(async () => {
2036
- if (isValidToken(tokenData)) {
2037
- return tokenData.accessToken;
2038
- }
2039
- const renewTokenResult = await renewAccountAuth({
2040
- ...tokenData,
2041
- userInfo
2042
- });
2043
- return (0, import_variant4.match)(renewTokenResult, {
2044
- TokenRenewed: ({ payload: newTokenData }) => {
2045
- tokenData = newTokenData;
2046
- return tokenData.accessToken;
2047
- },
2048
- RefreshTokenRevoked: ({ cause }) => {
2049
- throw new CliError({
2050
- code: CliErrorCode.FailedToRenewAuthTokenRefreshTokenRevoked(),
2051
- cause
2052
- });
2053
- }
2054
- });
2055
- });
2056
- },
2057
- getRefreshToken: () => tokenData.refreshToken,
2058
- userInfo
2059
- };
2060
- }
2061
- var accountAuthStrategy = {
2062
- async isLoggedIn() {
2063
- const apiKeyAuth = await apiKeyAuthStrategy.isLoggedIn();
2064
- if (apiKeyAuth) {
2065
- return apiKeyAuth;
2066
- }
2067
- const accountAuth = await getNonExpiredAccountAuth();
2068
- if (accountAuth) {
2069
- return createAccountAuthState(accountAuth);
2070
- }
2071
- return null;
2072
- },
2073
- async login({ deviceCode: deviceCode2, signal }) {
2074
- const accountAuth = await waitForLogin(deviceCode2, { signal });
2075
- return createAccountAuthState(accountAuth);
2076
- }
2077
- };
2078
-
2079
- // ../cli-auth/src/auth-strategies/site-auth-strategy.ts
2080
- init_esm_shims();
2081
- var import_variant5 = __toESM(require_lib(), 1);
2082
- async function renewSiteAuth({
2083
- accountRefreshToken,
2084
- siteId
2085
- }) {
2086
- const renewTokenResult = await client.renewToken({
2087
- refreshToken: accountRefreshToken,
2088
- siteId
2089
- });
2090
- if ((0, import_variant5.isType)(renewTokenResult, RenewTokenData.TokenRenewed)) {
2091
- await saveAuthData(renewTokenResult.payload, siteId);
2092
- }
2093
- return renewTokenResult;
2094
- }
2095
- var AuthenticationResult = (0, import_variant5.variant)({
2096
- Ok: (0, import_variant5.payload)(),
2097
- RefreshTokenRevoked: (0, import_variant5.fields)()
2098
- });
2099
- async function ensureAuthenticatedToSite({
2100
- siteId,
2101
- accountRefreshToken
2102
- }) {
2103
- const siteAuthStatus = await readSiteAuthData(siteId);
2104
- return (0, import_variant5.matcher)(siteAuthStatus).with({ Authenticated: (data) => AuthenticationResult.Ok(data) }).when(["Unauthenticated", "Expired"], async () => {
2105
- const renewTokenResult = await renewSiteAuth({
2106
- accountRefreshToken,
2107
- siteId
2108
- });
2109
- return (0, import_variant5.match)(renewTokenResult, {
2110
- TokenRenewed: ({ payload: payload4 }) => AuthenticationResult.Ok(payload4),
2111
- RefreshTokenRevoked: ({ cause }) => {
2112
- return AuthenticationResult.RefreshTokenRevoked({ cause });
2113
- }
2114
- });
2115
- }).complete();
2116
- }
2117
- function createSiteAuthState({
2118
- siteAuth: initialTokenData,
2119
- accountRefreshToken,
2120
- siteId,
2121
- userInfo
2122
- }) {
2123
- const limiter = pLimit(1);
2124
- let tokenData = { ...initialTokenData };
2125
- return {
2126
- getAccessToken: () => {
2127
- return limiter(async () => {
2128
- if (isValidToken(tokenData)) {
2129
- return tokenData.accessToken;
2130
- }
2131
- const renewTokenResult = await renewSiteAuth({
2132
- accountRefreshToken,
2133
- siteId
2134
- });
2135
- return (0, import_variant5.match)(renewTokenResult, {
2136
- TokenRenewed: ({ payload: newTokenData }) => {
2137
- tokenData = newTokenData;
2138
- return tokenData.accessToken;
2139
- },
2140
- RefreshTokenRevoked: ({ cause }) => {
2141
- throw new CliError({
2142
- code: CliErrorCode.FailedToRenewAuthTokenRefreshTokenRevoked(),
2143
- cause
2144
- });
2145
- }
2146
- });
2147
- });
2148
- },
2149
- getRefreshToken: () => tokenData.refreshToken,
2150
- userInfo
2151
- };
2152
- }
2153
- var createSiteAuthStrategy = (siteId) => ({
2154
- async isLoggedIn() {
2155
- const apiKeyAuth = await apiKeyAuthStrategy.isLoggedIn({ siteId });
2156
- if (apiKeyAuth) {
2157
- return apiKeyAuth;
2158
- }
2159
- const accountAuth = await accountAuthStrategy.isLoggedIn();
2160
- if (accountAuth) {
2161
- const accountRefreshToken = accountAuth.getRefreshToken();
2162
- const siteAuthResult = await ensureAuthenticatedToSite({
2163
- siteId,
2164
- accountRefreshToken
2165
- });
2166
- if ((0, import_variant5.isType)(siteAuthResult, AuthenticationResult.Ok)) {
2167
- return createSiteAuthState({
2168
- siteId,
2169
- siteAuth: siteAuthResult.payload,
2170
- accountRefreshToken,
2171
- userInfo: accountAuth.userInfo
2172
- });
2173
- }
2174
- }
2175
- return null;
2176
- },
2177
- async login({ deviceCode: deviceCode2, signal }) {
2178
- const accountAuth = await accountAuthStrategy.login({ deviceCode: deviceCode2, signal });
2179
- const accountRefreshToken = accountAuth.getRefreshToken();
2180
- const siteAuthResult = await ensureAuthenticatedToSite({
2181
- siteId,
2182
- accountRefreshToken
2183
- });
2184
- return (0, import_variant5.match)(siteAuthResult, {
2185
- Ok: ({ payload: siteAuth }) => {
2186
- return createSiteAuthState({
2187
- siteId,
2188
- siteAuth,
2189
- accountRefreshToken,
2190
- userInfo: accountAuth.userInfo
2191
- });
2192
- },
2193
- RefreshTokenRevoked: ({ cause }) => {
2194
- throw new CliError({
2195
- code: CliErrorCode.FailedToRenewAuthTokenRefreshTokenRevoked(),
2196
- cause
2197
- });
2198
- }
2199
- });
2200
- }
2201
- });
2202
-
2203
- // ../cli-auth/src/logout.ts
2204
- init_esm_shims();
2205
- var import_variant6 = __toESM(require_lib(), 1);
2206
- async function logout() {
2207
- const authData = await readAccountAuthData();
2208
- if (!(0, import_variant6.isType)(authData, AccountAuthData.Unauthenticated)) {
2209
- await client.revokeRefreshToken(
2210
- { token: authData.refreshToken },
2211
- authData.userInfo
2212
- );
2213
- }
2214
- await deleteAuthData();
2215
- return null;
2216
- }
2217
-
2218
- // ../cli-auth/src/useAuth.ts
2219
- init_esm_shims();
2220
- var import_react2 = __toESM(require_react(), 1);
2221
-
2222
- // ../cli-auth/src/context.ts
2223
- init_esm_shims();
2224
- var import_react = __toESM(require_react(), 1);
2225
- var AuthContext = (0, import_react.createContext)(null);
2226
-
2227
- // ../cli-auth/src/useAuth.ts
2228
- function useAuth() {
2229
- const context = (0, import_react2.useContext)(AuthContext);
2230
- if (!context) {
2231
- throw new Error("useAuth() cannot be used without an <AuthProvider>");
2232
- }
2233
- return context;
2234
- }
2235
-
2236
- // ../cli-auth/src/components/ApiKeyLogin.tsx
2237
- init_esm_shims();
2238
- var import_react3 = __toESM(require_react(), 1);
2239
- var import_variant7 = __toESM(require_lib(), 1);
2240
- var ApiKeyLogin = ({ token: token2, onLogin, onError }) => {
2241
- const biLogger = useBiLogger();
2242
- const { status } = useAsync(
2243
- async () => {
2244
- void biLogger.report(wixCliLoginStart({}));
2245
- return apiKeyAuthStrategy.login({ token: token2 });
2246
- },
2247
- [],
2248
- {
2249
- onSuccess: (authData) => {
2250
- void biLogger.report(
2251
- wixCliLoginEnd({
2252
- isSuccess: true
2253
- })
2254
- );
2255
- onLogin(authData);
2256
- },
2257
- onError: (error) => {
2258
- void biLogger.report(
2259
- wixCliLoginEnd({
2260
- isSuccess: false,
2261
- ...error instanceof Error ? {
2262
- errorType: error.name
2263
- } : {
2264
- errorType: "unknown",
2265
- errorMessage: JSON.stringify(error)
2266
- }
2267
- })
2268
- );
2269
- onError(error);
2270
- }
2271
- }
2272
- );
2273
- return (0, import_variant7.match)(status, {
2274
- Error: () => null,
2275
- Loading: () => /* @__PURE__ */ import_react3.default.createElement(Spinner, null),
2276
- Success: () => null
2277
- });
2278
- };
2279
-
2280
- // ../cli-auth/src/components/Login.tsx
2281
- init_esm_shims();
2282
- var import_react6 = __toESM(require_react(), 1);
2283
- var import_variant8 = __toESM(require_lib(), 1);
2284
-
2285
- // ../cli-auth/src/messages.json
2286
- var messages_default = {
2287
- "login.instructions_title": "Authorize the CLI to access your Wix account:",
2288
- "login.instructions_details": "1. Copy this code to the clipboard: <0>{code}</0>\n2. Choose an option:",
2289
- "login.have_wix_account": "Already have an account? Press <0/> to <1>log in</1> and then paste the code",
2290
- "login.new_to_wix": "New to Wix? Press <0/> to <1>sign up</1> and then paste the code",
2291
- "login.legacy_auth_notice": "We implemented a new and more secure login method. You'll need to re-login to continue using the CLI.",
2292
- "login.error_opening_browser": "Failed to open browser, please try opening <0/> manually."
2293
- };
2294
-
2295
- // ../cli-auth/src/components/LoginInstructions.tsx
2296
- init_esm_shims();
2297
- var import_react5 = __toESM(require_react(), 1);
2298
-
2299
- // ../user-browser/src/index.ts
2300
- init_esm_shims();
2301
-
2302
- // ../../node_modules/open/index.js
2303
- init_esm_shims();
2304
- import process5 from "node:process";
2305
- import { Buffer as Buffer2 } from "node:buffer";
2306
- import path from "node:path";
2307
- import { fileURLToPath } from "node:url";
2308
- import childProcess from "node:child_process";
2309
- import fs4, { constants as fsConstants } from "node:fs/promises";
2310
-
2311
- // ../../node_modules/is-wsl/index.js
2312
- init_esm_shims();
2313
- import process from "node:process";
2314
- import os from "node:os";
2315
- import fs3 from "node:fs";
2316
-
2317
- // ../../node_modules/is-inside-container/index.js
2318
- init_esm_shims();
2319
- import fs2 from "node:fs";
2320
-
2321
- // ../../node_modules/is-docker/index.js
2322
- init_esm_shims();
2323
- import fs from "node:fs";
2324
- var isDockerCached;
2325
- function hasDockerEnv() {
2326
- try {
2327
- fs.statSync("/.dockerenv");
2328
- return true;
2329
- } catch {
2330
- return false;
2331
- }
2332
- }
2333
- function hasDockerCGroup() {
2334
- try {
2335
- return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
2336
- } catch {
2337
- return false;
2338
- }
2339
- }
2340
- function isDocker() {
2341
- if (isDockerCached === void 0) {
2342
- isDockerCached = hasDockerEnv() || hasDockerCGroup();
2343
- }
2344
- return isDockerCached;
2345
- }
2346
-
2347
- // ../../node_modules/is-inside-container/index.js
2348
- var cachedResult;
2349
- var hasContainerEnv = () => {
2350
- try {
2351
- fs2.statSync("/run/.containerenv");
2352
- return true;
2353
- } catch {
2354
- return false;
2355
- }
2356
- };
2357
- function isInsideContainer() {
2358
- if (cachedResult === void 0) {
2359
- cachedResult = hasContainerEnv() || isDocker();
2360
- }
2361
- return cachedResult;
2362
- }
2363
-
2364
- // ../../node_modules/is-wsl/index.js
2365
- var isWsl = () => {
2366
- if (process.platform !== "linux") {
2367
- return false;
2368
- }
2369
- if (os.release().toLowerCase().includes("microsoft")) {
2370
- if (isInsideContainer()) {
2371
- return false;
2372
- }
2373
- return true;
2374
- }
2375
- try {
2376
- return fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
2377
- } catch {
2378
- return false;
2379
- }
2380
- };
2381
- var is_wsl_default = process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
2382
-
2383
- // ../../node_modules/define-lazy-prop/index.js
2384
- init_esm_shims();
2385
- function defineLazyProperty(object, propertyName, valueGetter) {
2386
- const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
2387
- Object.defineProperty(object, propertyName, {
2388
- configurable: true,
2389
- enumerable: true,
2390
- get() {
2391
- const result = valueGetter();
2392
- define(result);
2393
- return result;
2394
- },
2395
- set(value) {
2396
- define(value);
2397
- }
2398
- });
2399
- return object;
2400
- }
2401
-
2402
- // ../../node_modules/default-browser/index.js
2403
- init_esm_shims();
2404
- import { promisify as promisify4 } from "node:util";
2405
- import process4 from "node:process";
2406
- import { execFile as execFile4 } from "node:child_process";
2407
-
2408
- // ../../node_modules/default-browser-id/index.js
2409
- init_esm_shims();
2410
- import { promisify } from "node:util";
2411
- import process2 from "node:process";
2412
- import { execFile } from "node:child_process";
2413
- var execFileAsync = promisify(execFile);
2414
- async function defaultBrowserId() {
2415
- if (process2.platform !== "darwin") {
2416
- throw new Error("macOS only");
2417
- }
2418
- const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
2419
- const match9 = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
2420
- return match9?.groups.id ?? "com.apple.Safari";
2421
- }
2422
-
2423
- // ../../node_modules/bundle-name/index.js
2424
- init_esm_shims();
2425
-
2426
- // ../../node_modules/run-applescript/index.js
2427
- init_esm_shims();
2428
- import process3 from "node:process";
2429
- import { promisify as promisify2 } from "node:util";
2430
- import { execFile as execFile2, execFileSync } from "node:child_process";
2431
- var execFileAsync2 = promisify2(execFile2);
2432
- async function runAppleScript(script, { humanReadableOutput = true } = {}) {
2433
- if (process3.platform !== "darwin") {
2434
- throw new Error("macOS only");
2435
- }
2436
- const outputArguments = humanReadableOutput ? [] : ["-ss"];
2437
- const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments]);
2438
- return stdout.trim();
2439
- }
2440
-
2441
- // ../../node_modules/bundle-name/index.js
2442
- async function bundleName(bundleId) {
2443
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
2444
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
2445
- }
2446
-
2447
- // ../../node_modules/default-browser/windows.js
2448
- init_esm_shims();
2449
- import { promisify as promisify3 } from "node:util";
2450
- import { execFile as execFile3 } from "node:child_process";
2451
- var execFileAsync3 = promisify3(execFile3);
2452
- var windowsBrowserProgIds = {
2453
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
2454
- MSEdgeDHTML: { name: "Edge", id: "com.microsoft.edge" },
2455
- // On macOS, it's "com.microsoft.edgemac"
2456
- MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
2457
- // Newer Edge/Win10 releases
2458
- "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" },
2459
- FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
2460
- ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
2461
- BraveHTML: { name: "Brave", id: "com.brave.Browser" },
2462
- BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
2463
- BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" }
2464
- };
2465
- var UnknownBrowserError = class extends Error {
2466
- };
2467
- async function defaultBrowser(_execFileAsync = execFileAsync3) {
2468
- const { stdout } = await _execFileAsync("reg", [
2469
- "QUERY",
2470
- " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
2471
- "/v",
2472
- "ProgId"
2473
- ]);
2474
- const match9 = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
2475
- if (!match9) {
2476
- throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
2477
- }
2478
- const { id } = match9.groups;
2479
- const browser = windowsBrowserProgIds[id];
2480
- if (!browser) {
2481
- throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
2482
- }
2483
- return browser;
2484
- }
2485
-
2486
- // ../../node_modules/default-browser/index.js
2487
- var execFileAsync4 = promisify4(execFile4);
2488
- var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
2489
- async function defaultBrowser2() {
2490
- if (process4.platform === "darwin") {
2491
- const id = await defaultBrowserId();
2492
- const name = await bundleName(id);
2493
- return { name, id };
2494
- }
2495
- if (process4.platform === "linux") {
2496
- const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
2497
- const id = stdout.trim();
2498
- const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
2499
- return { name, id };
2500
- }
2501
- if (process4.platform === "win32") {
2502
- return defaultBrowser();
2503
- }
2504
- throw new Error("Only macOS, Linux, and Windows are supported");
2505
- }
2506
-
2507
- // ../../node_modules/open/index.js
2508
- var __dirname = path.dirname(fileURLToPath(import.meta.url));
2509
- var localXdgOpenPath = path.join(__dirname, "xdg-open");
2510
- var { platform, arch } = process5;
2511
- var getWslDrivesMountPoint = /* @__PURE__ */ (() => {
2512
- const defaultMountPoint = "/mnt/";
2513
- let mountPoint;
2514
- return async function() {
2515
- if (mountPoint) {
2516
- return mountPoint;
2517
- }
2518
- const configFilePath = "/etc/wsl.conf";
2519
- let isConfigFileExists = false;
2520
- try {
2521
- await fs4.access(configFilePath, fsConstants.F_OK);
2522
- isConfigFileExists = true;
2523
- } catch {
2524
- }
2525
- if (!isConfigFileExists) {
2526
- return defaultMountPoint;
2527
- }
2528
- const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
2529
- const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
2530
- if (!configMountPoint) {
2531
- return defaultMountPoint;
2532
- }
2533
- mountPoint = configMountPoint.groups.mountPoint.trim();
2534
- mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
2535
- return mountPoint;
2536
- };
2537
- })();
2538
- var pTryEach = async (array, mapper) => {
2539
- let latestError;
2540
- for (const item of array) {
2541
- try {
2542
- return await mapper(item);
2543
- } catch (error) {
2544
- latestError = error;
2545
- }
2546
- }
2547
- throw latestError;
2548
- };
2549
- var baseOpen = async (options) => {
2550
- options = {
2551
- wait: false,
2552
- background: false,
2553
- newInstance: false,
2554
- allowNonzeroExitCode: false,
2555
- ...options
2556
- };
2557
- if (Array.isArray(options.app)) {
2558
- return pTryEach(options.app, (singleApp) => baseOpen({
2559
- ...options,
2560
- app: singleApp
2561
- }));
2562
- }
2563
- let { name: app, arguments: appArguments = [] } = options.app ?? {};
2564
- appArguments = [...appArguments];
2565
- if (Array.isArray(app)) {
2566
- return pTryEach(app, (appName) => baseOpen({
2567
- ...options,
2568
- app: {
2569
- name: appName,
2570
- arguments: appArguments
2571
- }
2572
- }));
2573
- }
2574
- if (app === "browser" || app === "browserPrivate") {
2575
- const ids = {
2576
- "com.google.chrome": "chrome",
2577
- "google-chrome.desktop": "chrome",
2578
- "org.mozilla.firefox": "firefox",
2579
- "firefox.desktop": "firefox",
2580
- "com.microsoft.msedge": "edge",
2581
- "com.microsoft.edge": "edge",
2582
- "microsoft-edge.desktop": "edge"
2583
- };
2584
- const flags = {
2585
- chrome: "--incognito",
2586
- firefox: "--private-window",
2587
- edge: "--inPrivate"
2588
- };
2589
- const browser = await defaultBrowser2();
2590
- if (browser.id in ids) {
2591
- const browserName = ids[browser.id];
2592
- if (app === "browserPrivate") {
2593
- appArguments.push(flags[browserName]);
2594
- }
2595
- return baseOpen({
2596
- ...options,
2597
- app: {
2598
- name: apps[browserName],
2599
- arguments: appArguments
2600
- }
2601
- });
2602
- }
2603
- throw new Error(`${browser.name} is not supported as a default browser`);
2604
- }
2605
- let command;
2606
- const cliArguments = [];
2607
- const childProcessOptions = {};
2608
- if (platform === "darwin") {
2609
- command = "open";
2610
- if (options.wait) {
2611
- cliArguments.push("--wait-apps");
2612
- }
2613
- if (options.background) {
2614
- cliArguments.push("--background");
2615
- }
2616
- if (options.newInstance) {
2617
- cliArguments.push("--new");
2618
- }
2619
- if (app) {
2620
- cliArguments.push("-a", app);
2621
- }
2622
- } else if (platform === "win32" || is_wsl_default && !isInsideContainer() && !app) {
2623
- const mountPoint = await getWslDrivesMountPoint();
2624
- command = is_wsl_default ? `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process5.env.SYSTEMROOT || process5.env.windir || "C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
2625
- cliArguments.push(
2626
- "-NoProfile",
2627
- "-NonInteractive",
2628
- "-ExecutionPolicy",
2629
- "Bypass",
2630
- "-EncodedCommand"
2631
- );
2632
- if (!is_wsl_default) {
2633
- childProcessOptions.windowsVerbatimArguments = true;
2634
- }
2635
- const encodedArguments = ["Start"];
2636
- if (options.wait) {
2637
- encodedArguments.push("-Wait");
2638
- }
2639
- if (app) {
2640
- encodedArguments.push(`"\`"${app}\`""`);
2641
- if (options.target) {
2642
- appArguments.push(options.target);
2643
- }
2644
- } else if (options.target) {
2645
- encodedArguments.push(`"${options.target}"`);
2646
- }
2647
- if (appArguments.length > 0) {
2648
- appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
2649
- encodedArguments.push("-ArgumentList", appArguments.join(","));
2650
- }
2651
- options.target = Buffer2.from(encodedArguments.join(" "), "utf16le").toString("base64");
2652
- } else {
2653
- if (app) {
2654
- command = app;
2655
- } else {
2656
- const isBundled = !__dirname || __dirname === "/";
2657
- let exeLocalXdgOpen = false;
2658
- try {
2659
- await fs4.access(localXdgOpenPath, fsConstants.X_OK);
2660
- exeLocalXdgOpen = true;
2661
- } catch {
2662
- }
2663
- const useSystemXdgOpen = process5.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
2664
- command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
2665
- }
2666
- if (appArguments.length > 0) {
2667
- cliArguments.push(...appArguments);
2668
- }
2669
- if (!options.wait) {
2670
- childProcessOptions.stdio = "ignore";
2671
- childProcessOptions.detached = true;
2672
- }
2673
- }
2674
- if (platform === "darwin" && appArguments.length > 0) {
2675
- cliArguments.push("--args", ...appArguments);
2676
- }
2677
- if (options.target) {
2678
- cliArguments.push(options.target);
2679
- }
2680
- const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
2681
- if (options.wait) {
2682
- return new Promise((resolve2, reject) => {
2683
- subprocess.once("error", reject);
2684
- subprocess.once("close", (exitCode) => {
2685
- if (!options.allowNonzeroExitCode && exitCode > 0) {
2686
- reject(new Error(`Exited with code ${exitCode}`));
2687
- return;
2688
- }
2689
- resolve2(subprocess);
2690
- });
2691
- });
2692
- }
2693
- subprocess.unref();
2694
- return subprocess;
2695
- };
2696
- var open = (target, options) => {
2697
- if (typeof target !== "string") {
2698
- throw new TypeError("Expected a `target`");
2699
- }
2700
- return baseOpen({
2701
- ...options,
2702
- target
2703
- });
2704
- };
2705
- function detectArchBinary(binary) {
2706
- if (typeof binary === "string" || Array.isArray(binary)) {
2707
- return binary;
2708
- }
2709
- const { [arch]: archBinary } = binary;
2710
- if (!archBinary) {
2711
- throw new Error(`${arch} is not supported`);
2712
- }
2713
- return archBinary;
2714
- }
2715
- function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
2716
- if (wsl && is_wsl_default) {
2717
- return detectArchBinary(wsl);
2718
- }
2719
- if (!platformBinary) {
2720
- throw new Error(`${platform} is not supported`);
2721
- }
2722
- return detectArchBinary(platformBinary);
2723
- }
2724
- var apps = {};
2725
- defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
2726
- darwin: "google chrome",
2727
- win32: "chrome",
2728
- linux: ["google-chrome", "google-chrome-stable", "chromium"]
2729
- }, {
2730
- wsl: {
2731
- ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
2732
- x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
2733
- }
2734
- }));
2735
- defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
2736
- darwin: "firefox",
2737
- win32: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
2738
- linux: "firefox"
2739
- }, {
2740
- wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
2741
- }));
2742
- defineLazyProperty(apps, "edge", () => detectPlatformBinary({
2743
- darwin: "microsoft edge",
2744
- win32: "msedge",
2745
- linux: ["microsoft-edge", "microsoft-edge-dev"]
2746
- }, {
2747
- wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
2748
- }));
2749
- defineLazyProperty(apps, "browser", () => "browser");
2750
- defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
2751
- var open_default = open;
2752
-
2753
- // ../user-browser/src/open-testkit.ts
2754
- init_esm_shims();
2755
- var import_http_client3 = __toESM(require_index_node(), 1);
2756
- async function open2(testEndpoint, url) {
2757
- await (0, import_http_client3.createHttpClient)().post(testEndpoint, void 0, {
2758
- params: {
2759
- url
2760
- }
2761
- }).catch((error) => {
2762
- if (import_http_client3.HttpClient.isHttpError(error) && error.response?.data?.message) {
2763
- throw new Error(error.response.data.message);
2764
- }
2765
- throw error;
2766
- });
2767
- }
2768
-
2769
- // ../user-browser/src/index.ts
2770
- async function openBrowser(url) {
2771
- const { userBrowserTestEndpoint: testEndpoint } = getTestOverrides();
2772
- try {
2773
- if (testEndpoint) {
2774
- await open2(testEndpoint, url);
2775
- } else {
2776
- await open_default(url, {
2777
- background: true
2778
- });
2779
- }
2780
- } catch (error) {
2781
- throw new CliError({
2782
- code: CliErrorCode.FailedToOpenBrowser(),
2783
- info: { url },
2784
- cause: error
2785
- });
2786
- }
2787
- }
2788
-
2789
- // ../cli-auth/src/useColoredVerificationUri.ts
2790
- init_esm_shims();
2791
- var import_react4 = __toESM(require_react(), 1);
2792
- function useColoredVerificationUri(verificationUri) {
2793
- return (0, import_react4.useMemo)(() => {
2794
- const coloredUri = new URL(verificationUri);
2795
- coloredUri.searchParams.set("color", "developer");
2796
- coloredUri.searchParams.set("studio", "true");
2797
- const signupUri = new URL("https://users.wix.com/login/signup/password");
2798
- signupUri.searchParams.set("redirectTo", coloredUri.href);
2799
- return {
2800
- coloredVerificationUri: coloredUri.toString(),
2801
- signupUri: signupUri.toString()
2802
- };
2803
- }, [verificationUri]);
2804
- }
2805
-
2806
- // ../cli-auth/src/components/LoginInstructions.tsx
2807
- var LoginInstructions = ({ userCode, verificationUri }) => {
2808
- const { coloredVerificationUri, signupUri } = useColoredVerificationUri(verificationUri);
2809
- const { reportError } = useErrorReporter();
2810
- const [openBrowserError, setOpenBrowserError] = (0, import_react5.useState)(null);
2811
- use_input_default((input, key) => {
2812
- if (key.return) {
2813
- openBrowser(coloredVerificationUri).catch((error) => {
2814
- reportError(error);
2815
- setOpenBrowserError(error);
2816
- });
2817
- }
2818
- if (input === " ") {
2819
- openBrowser(signupUri).catch((error) => {
2820
- reportError(error);
2821
- setOpenBrowserError(error);
2822
- });
2823
- }
2824
- });
2825
- return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(Trans, { i18nKey: "login.instructions_title" }), /* @__PURE__ */ import_react5.default.createElement(Box_default, { flexDirection: "column", marginTop: 1, marginBottom: 1, marginLeft: 2 }, /* @__PURE__ */ import_react5.default.createElement(Box_default, { marginBottom: 1 }, /* @__PURE__ */ import_react5.default.createElement(
2826
- Trans,
2827
- {
2828
- i18nKey: "login.instructions_details",
2829
- components: [/* @__PURE__ */ import_react5.default.createElement(Text, { skin: "info" })],
2830
- values: { code: userCode }
2831
- }
2832
- )), /* @__PURE__ */ import_react5.default.createElement(Box_default, { marginBottom: 1 }, /* @__PURE__ */ import_react5.default.createElement(
2833
- Trans,
2834
- {
2835
- i18nKey: "login.have_wix_account",
2836
- components: [
2837
- /* @__PURE__ */ import_react5.default.createElement(Key, { value: "enter" }),
2838
- /* @__PURE__ */ import_react5.default.createElement(Link, { url: coloredVerificationUri })
2839
- ]
2840
- }
2841
- )), /* @__PURE__ */ import_react5.default.createElement(
2842
- Trans,
2843
- {
2844
- i18nKey: "login.new_to_wix",
2845
- components: [/* @__PURE__ */ import_react5.default.createElement(Key, { value: "space" }), /* @__PURE__ */ import_react5.default.createElement(Link, { url: signupUri })]
2846
- }
2847
- )), openBrowserError != null && /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(Box_default, { flexDirection: "column", marginBottom: 1 }, /* @__PURE__ */ import_react5.default.createElement(ErrorViewer, { error: openBrowserError })), /* @__PURE__ */ import_react5.default.createElement(
2848
- Trans,
2849
- {
2850
- i18nKey: "login.error_opening_browser",
2851
- components: [/* @__PURE__ */ import_react5.default.createElement(Link, { url: coloredVerificationUri })]
2852
- }
2853
- )));
2854
- };
2855
-
2856
- // ../cli-auth/src/components/Login.tsx
2857
- var Login = ({ loginFn, onLogin, onError }) => {
2858
- const biLogger = useBiLogger();
2859
- function handleError(error) {
2860
- void biLogger.report(
2861
- wixCliLoginEnd({
2862
- isSuccess: false,
2863
- ...error instanceof Error ? {
2864
- errorType: error.name
2865
- } : {
2866
- errorType: "unknown",
2867
- errorMessage: JSON.stringify(error)
2868
- }
2869
- })
2870
- );
2871
- onError(error);
2872
- }
2873
- const loginAction = useAsyncCallback(
2874
- async ({ signal }, deviceCodeResponse) => {
2875
- try {
2876
- const authData = await loginFn({
2877
- deviceCode: deviceCodeResponse,
2878
- signal
2879
- });
2880
- void biLogger.report(
2881
- wixCliLoginEnd({
2882
- isSuccess: true
2883
- })
2884
- );
2885
- onLogin(authData);
2886
- } catch (error) {
2887
- handleError(error);
2888
- }
2889
- }
2890
- );
2891
- const { status } = useAsync(
2892
- async () => {
2893
- void biLogger.report(wixCliLoginStart({}));
2894
- return client.requestDeviceCode();
2895
- },
2896
- [],
2897
- {
2898
- onSuccess: (deviceCodeResponse) => {
2899
- void loginAction.execute(deviceCodeResponse);
2900
- },
2901
- onError: handleError
2902
- }
2903
- );
2904
- return (0, import_variant8.match)(status, {
2905
- Error: () => null,
2906
- Loading: () => /* @__PURE__ */ import_react6.default.createElement(Spinner, null),
2907
- Success: ({ result: { userCode, verificationUri } }) => /* @__PURE__ */ import_react6.default.createElement(
2908
- LoginInstructions,
2909
- {
2910
- userCode,
2911
- verificationUri
2912
- }
2913
- )
2914
- });
2915
- };
2916
- function LoginWithI18n(props) {
2917
- return /* @__PURE__ */ import_react6.default.createElement(I18nProvider, { messages: messages_default }, /* @__PURE__ */ import_react6.default.createElement(Login, { loginFn: accountAuthStrategy.login, ...props }));
2918
- }
2919
-
2920
- // ../cli-auth/src/providers/AccountAuthProvider.tsx
2921
- init_esm_shims();
2922
- var import_react9 = __toESM(require_react(), 1);
2923
-
2924
- // ../cli-auth/src/components/EnsureLoggedIn.tsx
2925
- init_esm_shims();
2926
- var import_react8 = __toESM(require_react(), 1);
2927
- var import_variant10 = __toESM(require_lib(), 1);
2928
-
2929
- // ../cli-auth/src/components/WarnLegacyAuthData.tsx
2930
- init_esm_shims();
2931
- var import_react7 = __toESM(require_react(), 1);
2932
- var import_variant9 = __toESM(require_lib(), 1);
2933
- var WarnLegacyAuthData = ({ children }) => {
2934
- const { status } = useAsync(hasLegacyAuthData, [], { onError: () => {
2935
- } });
2936
- return (0, import_variant9.match)(status, {
2937
- Error: () => null,
2938
- Loading: () => null,
2939
- Success: ({ result }) => /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, result && /* @__PURE__ */ import_react7.default.createElement(Box_default, { marginBottom: 1 }, /* @__PURE__ */ import_react7.default.createElement(Trans, { i18nKey: "login.legacy_auth_notice" })), children)
2940
- });
2941
- };
2942
-
2943
- // ../cli-auth/src/components/EnsureLoggedIn.tsx
2944
- var EnsureLoggedIn = ({
2945
- authStrategy: { login, isLoggedIn },
2946
- onLogin,
2947
- onError,
2948
- children
2949
- }) => {
2950
- const { status, merge: updateAccountAuth } = useAsync(isLoggedIn, [], {
2951
- onSuccess: (result) => {
2952
- if (result) {
2953
- onLogin(result);
2954
- }
2955
- },
2956
- onError
2957
- });
2958
- return (0, import_variant10.match)(status, {
2959
- Loading: () => /* @__PURE__ */ import_react8.default.createElement(Spinner, null),
2960
- Error: () => null,
2961
- Success: ({ result: accountAuth }) => {
2962
- if (accountAuth == null) {
2963
- return /* @__PURE__ */ import_react8.default.createElement(I18nProvider, { messages: messages_default }, /* @__PURE__ */ import_react8.default.createElement(WarnLegacyAuthData, null, /* @__PURE__ */ import_react8.default.createElement(
2964
- Login,
2965
- {
2966
- loginFn: login,
2967
- onLogin: (data) => {
2968
- updateAccountAuth({ result: data });
2969
- onLogin(data);
2970
- },
2971
- onError
2972
- }
2973
- )));
2974
- }
2975
- return children(accountAuth);
2976
- }
2977
- });
2978
- };
2979
-
2980
- // ../cli-auth/src/providers/AccountAuthProvider.tsx
2981
- var AccountAuthProvider = ({
2982
- children,
2983
- onError,
2984
- onLogin
2985
- }) => {
2986
- const exit = useExit();
2987
- return /* @__PURE__ */ import_react9.default.createElement(
2988
- EnsureLoggedIn,
2989
- {
2990
- authStrategy: accountAuthStrategy,
2991
- onLogin: ({ userInfo }) => onLogin?.(userInfo),
2992
- onError: onError ?? exit
2993
- },
2994
- ({ getAccessToken, getRequestHeaders, userInfo }) => /* @__PURE__ */ import_react9.default.createElement(
2995
- AuthContext.Provider,
2996
- {
2997
- value: { getAccessToken, getRequestHeaders, userInfo }
2998
- },
2999
- children
3000
- )
3001
- );
3002
- };
3003
-
3004
- // ../cli-auth/src/providers/SiteAuthProvider.tsx
3005
- init_esm_shims();
3006
- var import_react10 = __toESM(require_react(), 1);
3007
- var SiteAuthProvider = ({
3008
- children,
3009
- siteId,
3010
- onError,
3011
- onLogin
3012
- }) => {
3013
- const exit = useExit();
3014
- const authStrategy = (0, import_react10.useMemo)(() => createSiteAuthStrategy(siteId), [siteId]);
3015
- return /* @__PURE__ */ import_react10.default.createElement(
3016
- EnsureLoggedIn,
3017
- {
3018
- authStrategy,
3019
- onLogin: ({ userInfo }) => onLogin?.(userInfo),
3020
- onError: onError ?? exit
3021
- },
3022
- ({ getAccessToken, getRequestHeaders, userInfo }) => /* @__PURE__ */ import_react10.default.createElement(
3023
- AuthContext.Provider,
3024
- {
3025
- value: { getAccessToken, getRequestHeaders, userInfo }
3026
- },
3027
- children
3028
- )
3029
- );
3030
- };
3031
-
3032
- // ../cli-auth/src/authenticate.tsx
3033
- init_esm_shims();
3034
- var import_react11 = __toESM(require_react(), 1);
3035
- var Wrapper = ({ onReady }) => {
3036
- const exit = useExit();
3037
- const auth = useAuth();
3038
- (0, import_react11.useEffect)(() => {
3039
- onReady(auth);
3040
- exit();
3041
- }, [exit, auth, onReady]);
3042
- return null;
3043
- };
3044
- function authenticateWithSiteId(siteId, biLogger, errorReporter) {
3045
- return new Promise((resolve2, reject) => {
3046
- render(
3047
- /* @__PURE__ */ import_react11.default.createElement(ErrorReporterProvider, { value: errorReporter }, /* @__PURE__ */ import_react11.default.createElement(BiProvider, { value: biLogger }, /* @__PURE__ */ import_react11.default.createElement(SiteAuthProvider, { siteId }, /* @__PURE__ */ import_react11.default.createElement(Wrapper, { onReady: resolve2 }))))
3048
- ).catch((error) => reject(error));
3049
- });
3050
- }
3051
-
3052
- // ../cli-auth/src/index.ts
3053
- var { isLoggedIn: isLoggedInToAccount } = accountAuthStrategy;
3054
-
3055
- export {
3056
- pRetry,
3057
- resolveUrl,
3058
- toURLSearchParams,
3059
- serializer,
3060
- isHttpError,
3061
- isHttpValidationError,
3062
- isHttpApplicationError,
3063
- createHttpClient,
3064
- getUserInfo,
3065
- pLimit,
3066
- pTimeout,
3067
- pWaitFor,
3068
- logout,
3069
- useAuth,
3070
- ApiKeyLogin,
3071
- openBrowser,
3072
- LoginWithI18n,
3073
- AccountAuthProvider,
3074
- SiteAuthProvider,
3075
- authenticateWithSiteId,
3076
- isLoggedInToAccount
3077
- };
3078
- //# sourceMappingURL=chunk-2VWXGVIP.js.map