@cloudflare/workers-auth 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +200 -227
- package/dist/index.mjs +474 -1293
- package/dist/metafile-esm.json +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,920 +1,108 @@
|
|
|
1
1
|
import { __name } from './chunk-O6YSETKJ.mjs';
|
|
2
|
-
import {
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { getEnvironmentVariableFactory, getCloudflareApiEnvironmentFromEnv, UserError, getGlobalWranglerConfigPath, parseTOML, readFileSync, getCloudflareComplianceRegion } from '@cloudflare/workers-utils';
|
|
2
|
+
import { getEnvironmentVariableFactory, getCloudflareApiEnvironmentFromEnv, UserError, getCloudflareApiBaseUrl, COMPLIANCE_REGION_CONFIG_PUBLIC, FatalError, getCloudflareComplianceRegion } from '@cloudflare/workers-utils';
|
|
5
3
|
import { spawnSync } from 'node:child_process';
|
|
6
4
|
import { fetch } from 'undici';
|
|
7
5
|
import assert2 from 'node:assert';
|
|
8
6
|
import http from 'node:http';
|
|
9
7
|
import url from 'node:url';
|
|
10
|
-
import { webcrypto } from 'node:crypto';
|
|
8
|
+
import { webcrypto, createHash } from 'node:crypto';
|
|
11
9
|
import { TextEncoder } from 'node:util';
|
|
12
10
|
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
23
|
-
for (let i = line - 1; i <= line + 1; i++) {
|
|
24
|
-
let l = lines[i - 1];
|
|
25
|
-
if (!l)
|
|
26
|
-
continue;
|
|
27
|
-
codeblock += i.toString().padEnd(numberLen, " ");
|
|
28
|
-
codeblock += ": ";
|
|
29
|
-
codeblock += l;
|
|
30
|
-
codeblock += "\n";
|
|
31
|
-
if (i === line) {
|
|
32
|
-
codeblock += " ".repeat(numberLen + column + 2);
|
|
33
|
-
codeblock += "^\n";
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return codeblock;
|
|
37
|
-
}
|
|
38
|
-
__name(makeCodeBlock, "makeCodeBlock");
|
|
39
|
-
var TomlError = class extends Error {
|
|
40
|
-
static {
|
|
41
|
-
__name(this, "TomlError");
|
|
42
|
-
}
|
|
43
|
-
line;
|
|
44
|
-
column;
|
|
45
|
-
codeblock;
|
|
46
|
-
constructor(message, options) {
|
|
47
|
-
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
48
|
-
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
49
|
-
super(`Invalid TOML document: ${message}
|
|
50
|
-
|
|
51
|
-
${codeblock}`, options);
|
|
52
|
-
this.line = line;
|
|
53
|
-
this.column = column;
|
|
54
|
-
this.codeblock = codeblock;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/util.js
|
|
59
|
-
function isEscaped(str, ptr) {
|
|
60
|
-
let i = 0;
|
|
61
|
-
while (str[ptr - ++i] === "\\")
|
|
62
|
-
;
|
|
63
|
-
return --i && i % 2;
|
|
64
|
-
}
|
|
65
|
-
__name(isEscaped, "isEscaped");
|
|
66
|
-
function indexOfNewline(str, start = 0, end = str.length) {
|
|
67
|
-
let idx = str.indexOf("\n", start);
|
|
68
|
-
if (str[idx - 1] === "\r")
|
|
69
|
-
idx--;
|
|
70
|
-
return idx <= end ? idx : -1;
|
|
71
|
-
}
|
|
72
|
-
__name(indexOfNewline, "indexOfNewline");
|
|
73
|
-
function skipComment(str, ptr) {
|
|
74
|
-
for (let i = ptr; i < str.length; i++) {
|
|
75
|
-
let c = str[i];
|
|
76
|
-
if (c === "\n")
|
|
77
|
-
return i;
|
|
78
|
-
if (c === "\r" && str[i + 1] === "\n")
|
|
79
|
-
return i + 1;
|
|
80
|
-
if (c < " " && c !== " " || c === "\x7F") {
|
|
81
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
82
|
-
toml: str,
|
|
83
|
-
ptr
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return str.length;
|
|
88
|
-
}
|
|
89
|
-
__name(skipComment, "skipComment");
|
|
90
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
91
|
-
let c;
|
|
92
|
-
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
|
|
93
|
-
ptr++;
|
|
94
|
-
return banComments || c !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
|
|
95
|
-
}
|
|
96
|
-
__name(skipVoid, "skipVoid");
|
|
97
|
-
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
98
|
-
if (!end) {
|
|
99
|
-
ptr = indexOfNewline(str, ptr);
|
|
100
|
-
return ptr < 0 ? str.length : ptr;
|
|
101
|
-
}
|
|
102
|
-
for (let i = ptr; i < str.length; i++) {
|
|
103
|
-
let c = str[i];
|
|
104
|
-
if (c === "#") {
|
|
105
|
-
i = indexOfNewline(str, i);
|
|
106
|
-
} else if (c === sep) {
|
|
107
|
-
return i + 1;
|
|
108
|
-
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
109
|
-
return i;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
throw new TomlError("cannot find end of structure", {
|
|
113
|
-
toml: str,
|
|
114
|
-
ptr
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
__name(skipUntil, "skipUntil");
|
|
118
|
-
function getStringEnd(str, seek) {
|
|
119
|
-
let first = str[seek];
|
|
120
|
-
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
|
|
121
|
-
seek += target.length - 1;
|
|
122
|
-
do
|
|
123
|
-
seek = str.indexOf(target, ++seek);
|
|
124
|
-
while (seek > -1 && first !== "'" && isEscaped(str, seek));
|
|
125
|
-
if (seek > -1) {
|
|
126
|
-
seek += target.length;
|
|
127
|
-
if (target.length > 1) {
|
|
128
|
-
if (str[seek] === first)
|
|
129
|
-
seek++;
|
|
130
|
-
if (str[seek] === first)
|
|
131
|
-
seek++;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return seek;
|
|
135
|
-
}
|
|
136
|
-
__name(getStringEnd, "getStringEnd");
|
|
137
|
-
|
|
138
|
-
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/date.js
|
|
139
|
-
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
140
|
-
var TomlDate = class _TomlDate extends Date {
|
|
141
|
-
static {
|
|
142
|
-
__name(this, "TomlDate");
|
|
143
|
-
}
|
|
144
|
-
#hasDate = false;
|
|
145
|
-
#hasTime = false;
|
|
146
|
-
#offset = null;
|
|
147
|
-
constructor(date) {
|
|
148
|
-
let hasDate = true;
|
|
149
|
-
let hasTime = true;
|
|
150
|
-
let offset = "Z";
|
|
151
|
-
if (typeof date === "string") {
|
|
152
|
-
let match = date.match(DATE_TIME_RE);
|
|
153
|
-
if (match) {
|
|
154
|
-
if (!match[1]) {
|
|
155
|
-
hasDate = false;
|
|
156
|
-
date = `0000-01-01T${date}`;
|
|
157
|
-
}
|
|
158
|
-
hasTime = !!match[2];
|
|
159
|
-
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
|
|
160
|
-
if (match[2] && +match[2] > 23) {
|
|
161
|
-
date = "";
|
|
162
|
-
} else {
|
|
163
|
-
offset = match[3] || null;
|
|
164
|
-
date = date.toUpperCase();
|
|
165
|
-
if (!offset && hasTime)
|
|
166
|
-
date += "Z";
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
date = "";
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
super(date);
|
|
173
|
-
if (!isNaN(this.getTime())) {
|
|
174
|
-
this.#hasDate = hasDate;
|
|
175
|
-
this.#hasTime = hasTime;
|
|
176
|
-
this.#offset = offset;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
isDateTime() {
|
|
180
|
-
return this.#hasDate && this.#hasTime;
|
|
181
|
-
}
|
|
182
|
-
isLocal() {
|
|
183
|
-
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
184
|
-
}
|
|
185
|
-
isDate() {
|
|
186
|
-
return this.#hasDate && !this.#hasTime;
|
|
187
|
-
}
|
|
188
|
-
isTime() {
|
|
189
|
-
return this.#hasTime && !this.#hasDate;
|
|
190
|
-
}
|
|
191
|
-
isValid() {
|
|
192
|
-
return this.#hasDate || this.#hasTime;
|
|
193
|
-
}
|
|
194
|
-
toISOString() {
|
|
195
|
-
let iso = super.toISOString();
|
|
196
|
-
if (this.isDate())
|
|
197
|
-
return iso.slice(0, 10);
|
|
198
|
-
if (this.isTime())
|
|
199
|
-
return iso.slice(11, 23);
|
|
200
|
-
if (this.#offset === null)
|
|
201
|
-
return iso.slice(0, -1);
|
|
202
|
-
if (this.#offset === "Z")
|
|
203
|
-
return iso;
|
|
204
|
-
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
205
|
-
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
206
|
-
let offsetDate = new Date(this.getTime() - offset * 6e4);
|
|
207
|
-
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
208
|
-
}
|
|
209
|
-
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
210
|
-
let date = new _TomlDate(jsDate);
|
|
211
|
-
date.#offset = offset;
|
|
212
|
-
return date;
|
|
213
|
-
}
|
|
214
|
-
static wrapAsLocalDateTime(jsDate) {
|
|
215
|
-
let date = new _TomlDate(jsDate);
|
|
216
|
-
date.#offset = null;
|
|
217
|
-
return date;
|
|
218
|
-
}
|
|
219
|
-
static wrapAsLocalDate(jsDate) {
|
|
220
|
-
let date = new _TomlDate(jsDate);
|
|
221
|
-
date.#hasTime = false;
|
|
222
|
-
date.#offset = null;
|
|
223
|
-
return date;
|
|
224
|
-
}
|
|
225
|
-
static wrapAsLocalTime(jsDate) {
|
|
226
|
-
let date = new _TomlDate(jsDate);
|
|
227
|
-
date.#hasDate = false;
|
|
228
|
-
date.#offset = null;
|
|
229
|
-
return date;
|
|
11
|
+
// src/state.ts
|
|
12
|
+
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
13
|
+
function readStoredAuthState(options) {
|
|
14
|
+
const { configOverride, warningLogger, storage } = options;
|
|
15
|
+
let parsed;
|
|
16
|
+
try {
|
|
17
|
+
parsed = configOverride ?? storage.read();
|
|
18
|
+
} catch {
|
|
19
|
+
return {};
|
|
230
20
|
}
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
f: "\f",
|
|
243
|
-
r: "\r",
|
|
244
|
-
'"': '"',
|
|
245
|
-
"\\": "\\"
|
|
246
|
-
};
|
|
247
|
-
function parseString(str, ptr = 0, endPtr = str.length) {
|
|
248
|
-
let isLiteral = str[ptr] === "'";
|
|
249
|
-
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
250
|
-
if (isMultiline) {
|
|
251
|
-
endPtr -= 2;
|
|
252
|
-
if (str[ptr += 2] === "\r")
|
|
253
|
-
ptr++;
|
|
254
|
-
if (str[ptr] === "\n")
|
|
255
|
-
ptr++;
|
|
256
|
-
}
|
|
257
|
-
let tmp = 0;
|
|
258
|
-
let isEscape;
|
|
259
|
-
let parsed = "";
|
|
260
|
-
let sliceStart = ptr;
|
|
261
|
-
while (ptr < endPtr - 1) {
|
|
262
|
-
let c = str[ptr++];
|
|
263
|
-
if (c === "\n" || c === "\r" && str[ptr] === "\n") {
|
|
264
|
-
if (!isMultiline) {
|
|
265
|
-
throw new TomlError("newlines are not allowed in strings", {
|
|
266
|
-
toml: str,
|
|
267
|
-
ptr: ptr - 1
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
} else if (c < " " && c !== " " || c === "\x7F") {
|
|
271
|
-
throw new TomlError("control characters are not allowed in strings", {
|
|
272
|
-
toml: str,
|
|
273
|
-
ptr: ptr - 1
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
if (isEscape) {
|
|
277
|
-
isEscape = false;
|
|
278
|
-
if (c === "u" || c === "U") {
|
|
279
|
-
let code = str.slice(ptr, ptr += c === "u" ? 4 : 8);
|
|
280
|
-
if (!ESCAPE_REGEX.test(code)) {
|
|
281
|
-
throw new TomlError("invalid unicode escape", {
|
|
282
|
-
toml: str,
|
|
283
|
-
ptr: tmp
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
try {
|
|
287
|
-
parsed += String.fromCodePoint(parseInt(code, 16));
|
|
288
|
-
} catch {
|
|
289
|
-
throw new TomlError("invalid unicode escape", {
|
|
290
|
-
toml: str,
|
|
291
|
-
ptr: tmp
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
} else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
|
|
295
|
-
ptr = skipVoid(str, ptr - 1, true);
|
|
296
|
-
if (str[ptr] !== "\n" && str[ptr] !== "\r") {
|
|
297
|
-
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
298
|
-
toml: str,
|
|
299
|
-
ptr: tmp
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
ptr = skipVoid(str, ptr);
|
|
303
|
-
} else if (c in ESC_MAP) {
|
|
304
|
-
parsed += ESC_MAP[c];
|
|
305
|
-
} else {
|
|
306
|
-
throw new TomlError("unrecognized escape sequence", {
|
|
307
|
-
toml: str,
|
|
308
|
-
ptr: tmp
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
sliceStart = ptr;
|
|
312
|
-
} else if (!isLiteral && c === "\\") {
|
|
313
|
-
tmp = ptr - 1;
|
|
314
|
-
isEscape = true;
|
|
315
|
-
parsed += str.slice(sliceStart, tmp);
|
|
316
|
-
}
|
|
21
|
+
const { oauth_token, refresh_token, expiration_time, scopes, api_token } = parsed;
|
|
22
|
+
if (oauth_token) {
|
|
23
|
+
return {
|
|
24
|
+
accessToken: {
|
|
25
|
+
value: oauth_token,
|
|
26
|
+
// If there is no `expiration_time` field then set it to an old date, to cause it to expire immediately.
|
|
27
|
+
expiry: expiration_time ?? "2000-01-01:00:00:00+00:00"
|
|
28
|
+
},
|
|
29
|
+
refreshToken: { value: refresh_token ?? "" },
|
|
30
|
+
scopes
|
|
31
|
+
};
|
|
317
32
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return -Infinity;
|
|
328
|
-
if (value === "inf" || value === "+inf")
|
|
329
|
-
return Infinity;
|
|
330
|
-
if (value === "nan" || value === "+nan" || value === "-nan")
|
|
331
|
-
return NaN;
|
|
332
|
-
if (value === "-0")
|
|
333
|
-
return integersAsBigInt ? 0n : 0;
|
|
334
|
-
let isInt = INT_REGEX.test(value);
|
|
335
|
-
if (isInt || FLOAT_REGEX.test(value)) {
|
|
336
|
-
if (LEADING_ZERO.test(value)) {
|
|
337
|
-
throw new TomlError("leading zeroes are not allowed", {
|
|
338
|
-
toml,
|
|
339
|
-
ptr
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
value = value.replace(/_/g, "");
|
|
343
|
-
let numeric = +value;
|
|
344
|
-
if (isNaN(numeric)) {
|
|
345
|
-
throw new TomlError("invalid number", {
|
|
346
|
-
toml,
|
|
347
|
-
ptr
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
if (isInt) {
|
|
351
|
-
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
352
|
-
throw new TomlError("integer value cannot be represented losslessly", {
|
|
353
|
-
toml,
|
|
354
|
-
ptr
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
if (isInt || integersAsBigInt === true)
|
|
358
|
-
numeric = BigInt(value);
|
|
33
|
+
if (api_token) {
|
|
34
|
+
if (!hasWarnedAboutDeprecatedV1ApiToken && warningLogger) {
|
|
35
|
+
hasWarnedAboutDeprecatedV1ApiToken = true;
|
|
36
|
+
warningLogger.warn(
|
|
37
|
+
`It looks like you have used Wrangler v1's \`config\` command to login with an API token
|
|
38
|
+
from ${configOverride === void 0 ? storage.path() : "in-memory config"}.
|
|
39
|
+
This is no longer supported in the current version of Wrangler.
|
|
40
|
+
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\` environment variable.`
|
|
41
|
+
);
|
|
359
42
|
}
|
|
360
|
-
return
|
|
361
|
-
}
|
|
362
|
-
const date = new TomlDate(value);
|
|
363
|
-
if (!date.isValid()) {
|
|
364
|
-
throw new TomlError("invalid value", {
|
|
365
|
-
toml,
|
|
366
|
-
ptr
|
|
367
|
-
});
|
|
43
|
+
return { deprecatedApiToken: api_token };
|
|
368
44
|
}
|
|
369
|
-
return
|
|
45
|
+
return {};
|
|
370
46
|
}
|
|
371
|
-
__name(
|
|
47
|
+
__name(readStoredAuthState, "readStoredAuthState");
|
|
372
48
|
|
|
373
|
-
//
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
__name(sliceAndTrimEndOf, "sliceAndTrimEndOf");
|
|
394
|
-
function extractValue(str, ptr, end, depth, integersAsBigInt) {
|
|
395
|
-
if (depth === 0) {
|
|
396
|
-
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
397
|
-
toml: str,
|
|
398
|
-
ptr
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
let c = str[ptr];
|
|
402
|
-
if (c === "[" || c === "{") {
|
|
403
|
-
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
404
|
-
let newPtr = end ? skipUntil(str, endPtr2, ",", end) : endPtr2;
|
|
405
|
-
if (endPtr2 - newPtr && end === "}") {
|
|
406
|
-
let nextNewLine = indexOfNewline(str, endPtr2, newPtr);
|
|
407
|
-
if (nextNewLine > -1) {
|
|
408
|
-
throw new TomlError("newlines are not allowed in inline tables", {
|
|
409
|
-
toml: str,
|
|
410
|
-
ptr: nextNewLine
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return [value, newPtr];
|
|
415
|
-
}
|
|
416
|
-
let endPtr;
|
|
417
|
-
if (c === '"' || c === "'") {
|
|
418
|
-
endPtr = getStringEnd(str, ptr);
|
|
419
|
-
let parsed = parseString(str, ptr, endPtr);
|
|
420
|
-
if (end) {
|
|
421
|
-
endPtr = skipVoid(str, endPtr, end !== "]");
|
|
422
|
-
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
|
|
423
|
-
throw new TomlError("unexpected character encountered", {
|
|
424
|
-
toml: str,
|
|
425
|
-
ptr: endPtr
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
endPtr += +(str[endPtr] === ",");
|
|
49
|
+
// src/credentials.ts
|
|
50
|
+
var getCloudflareAPITokenFromEnv = getEnvironmentVariableFactory({
|
|
51
|
+
variableName: "CLOUDFLARE_API_TOKEN",
|
|
52
|
+
deprecatedName: "CF_API_TOKEN"
|
|
53
|
+
});
|
|
54
|
+
var getCloudflareGlobalAuthKeyFromEnv = getEnvironmentVariableFactory({
|
|
55
|
+
variableName: "CLOUDFLARE_API_KEY",
|
|
56
|
+
deprecatedName: "CF_API_KEY"
|
|
57
|
+
});
|
|
58
|
+
var getCloudflareGlobalAuthEmailFromEnv = getEnvironmentVariableFactory({
|
|
59
|
+
variableName: "CLOUDFLARE_EMAIL",
|
|
60
|
+
deprecatedName: "CF_EMAIL"
|
|
61
|
+
});
|
|
62
|
+
function getAuthFromEnv(options) {
|
|
63
|
+
const allowGlobalAuthKey = options?.allowGlobalAuthKey ?? true;
|
|
64
|
+
if (allowGlobalAuthKey) {
|
|
65
|
+
const globalApiKey = getCloudflareGlobalAuthKeyFromEnv();
|
|
66
|
+
const globalApiEmail = getCloudflareGlobalAuthEmailFromEnv();
|
|
67
|
+
if (globalApiKey && globalApiEmail) {
|
|
68
|
+
return { authKey: globalApiKey, authEmail: globalApiEmail };
|
|
429
69
|
}
|
|
430
|
-
return [parsed, endPtr];
|
|
431
|
-
}
|
|
432
|
-
endPtr = skipUntil(str, ptr, ",", end);
|
|
433
|
-
let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","), end === "]");
|
|
434
|
-
if (!slice[0]) {
|
|
435
|
-
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
436
|
-
toml: str,
|
|
437
|
-
ptr
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
if (end && slice[1] > -1) {
|
|
441
|
-
endPtr = skipVoid(str, ptr + slice[1]);
|
|
442
|
-
endPtr += +(str[endPtr] === ",");
|
|
443
70
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
];
|
|
448
|
-
}
|
|
449
|
-
__name(extractValue, "extractValue");
|
|
450
|
-
|
|
451
|
-
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/struct.js
|
|
452
|
-
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
453
|
-
function parseKey(str, ptr, end = "=") {
|
|
454
|
-
let dot = ptr - 1;
|
|
455
|
-
let parsed = [];
|
|
456
|
-
let endPtr = str.indexOf(end, ptr);
|
|
457
|
-
if (endPtr < 0) {
|
|
458
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
459
|
-
toml: str,
|
|
460
|
-
ptr
|
|
461
|
-
});
|
|
71
|
+
const apiToken = getCloudflareAPITokenFromEnv();
|
|
72
|
+
if (apiToken) {
|
|
73
|
+
return { apiToken };
|
|
462
74
|
}
|
|
463
|
-
|
|
464
|
-
let c = str[ptr = ++dot];
|
|
465
|
-
if (c !== " " && c !== " ") {
|
|
466
|
-
if (c === '"' || c === "'") {
|
|
467
|
-
if (c === str[ptr + 1] && c === str[ptr + 2]) {
|
|
468
|
-
throw new TomlError("multiline strings are not allowed in keys", {
|
|
469
|
-
toml: str,
|
|
470
|
-
ptr
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
let eos = getStringEnd(str, ptr);
|
|
474
|
-
if (eos < 0) {
|
|
475
|
-
throw new TomlError("unfinished string encountered", {
|
|
476
|
-
toml: str,
|
|
477
|
-
ptr
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
dot = str.indexOf(".", eos);
|
|
481
|
-
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
482
|
-
let newLine = indexOfNewline(strEnd);
|
|
483
|
-
if (newLine > -1) {
|
|
484
|
-
throw new TomlError("newlines are not allowed in keys", {
|
|
485
|
-
toml: str,
|
|
486
|
-
ptr: ptr + dot + newLine
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
if (strEnd.trimStart()) {
|
|
490
|
-
throw new TomlError("found extra tokens after the string part", {
|
|
491
|
-
toml: str,
|
|
492
|
-
ptr: eos
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
if (endPtr < eos) {
|
|
496
|
-
endPtr = str.indexOf(end, eos);
|
|
497
|
-
if (endPtr < 0) {
|
|
498
|
-
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
499
|
-
toml: str,
|
|
500
|
-
ptr
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
parsed.push(parseString(str, ptr, eos));
|
|
505
|
-
} else {
|
|
506
|
-
dot = str.indexOf(".", ptr);
|
|
507
|
-
let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
508
|
-
if (!KEY_PART_RE.test(part)) {
|
|
509
|
-
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
510
|
-
toml: str,
|
|
511
|
-
ptr
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
parsed.push(part.trimEnd());
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
} while (dot + 1 && dot < endPtr);
|
|
518
|
-
return [parsed, skipVoid(str, endPtr + 1, true, true)];
|
|
75
|
+
return void 0;
|
|
519
76
|
}
|
|
520
|
-
__name(
|
|
521
|
-
function
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
throw new TomlError("inline tables cannot contain comments", err);
|
|
533
|
-
} else if (c === ",") {
|
|
534
|
-
throw new TomlError("expected key-value, found comma", err);
|
|
535
|
-
} else if (c !== " " && c !== " ") {
|
|
536
|
-
let k;
|
|
537
|
-
let t = res;
|
|
538
|
-
let hasOwn = false;
|
|
539
|
-
let [key, keyEndPtr] = parseKey(str, ptr - 1);
|
|
540
|
-
for (let i = 0; i < key.length; i++) {
|
|
541
|
-
if (i)
|
|
542
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
543
|
-
k = key[i];
|
|
544
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
545
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
546
|
-
toml: str,
|
|
547
|
-
ptr
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
if (!hasOwn && k === "__proto__") {
|
|
551
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
if (hasOwn) {
|
|
555
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
556
|
-
toml: str,
|
|
557
|
-
ptr
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
|
|
561
|
-
seen.add(value);
|
|
562
|
-
t[k] = value;
|
|
563
|
-
ptr = valueEndPtr;
|
|
564
|
-
comma = str[ptr - 1] === "," ? ptr - 1 : 0;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
if (comma) {
|
|
568
|
-
throw new TomlError("trailing commas are not allowed in inline tables", {
|
|
569
|
-
toml: str,
|
|
570
|
-
ptr: comma
|
|
571
|
-
});
|
|
77
|
+
__name(getAuthFromEnv, "getAuthFromEnv");
|
|
78
|
+
function getAPIToken(options) {
|
|
79
|
+
const envAuth = getAuthFromEnv(options);
|
|
80
|
+
if (envAuth) {
|
|
81
|
+
return envAuth;
|
|
82
|
+
}
|
|
83
|
+
const stored = readStoredAuthState({
|
|
84
|
+
storage: options.storage,
|
|
85
|
+
warningLogger: options.warningLogger
|
|
86
|
+
});
|
|
87
|
+
if (stored.deprecatedApiToken) {
|
|
88
|
+
return { apiToken: stored.deprecatedApiToken };
|
|
572
89
|
}
|
|
573
|
-
if (
|
|
574
|
-
|
|
575
|
-
toml: str,
|
|
576
|
-
ptr
|
|
577
|
-
});
|
|
90
|
+
if (stored.accessToken?.value) {
|
|
91
|
+
return { apiToken: stored.accessToken.value };
|
|
578
92
|
}
|
|
579
|
-
return
|
|
93
|
+
return void 0;
|
|
580
94
|
}
|
|
581
|
-
__name(
|
|
582
|
-
function
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
if (c === ",") {
|
|
588
|
-
throw new TomlError("expected value, found comma", {
|
|
589
|
-
toml: str,
|
|
590
|
-
ptr: ptr - 1
|
|
591
|
-
});
|
|
592
|
-
} else if (c === "#")
|
|
593
|
-
ptr = skipComment(str, ptr);
|
|
594
|
-
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
|
|
595
|
-
let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
|
|
596
|
-
res.push(e[0]);
|
|
597
|
-
ptr = e[1];
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
if (!c) {
|
|
601
|
-
throw new TomlError("unfinished array encountered", {
|
|
602
|
-
toml: str,
|
|
603
|
-
ptr
|
|
95
|
+
__name(getAPIToken, "getAPIToken");
|
|
96
|
+
function requireApiToken(options) {
|
|
97
|
+
const credentials = getAPIToken(options);
|
|
98
|
+
if (!credentials) {
|
|
99
|
+
throw new UserError("No API token found.", {
|
|
100
|
+
telemetryMessage: "user auth missing api token"
|
|
604
101
|
});
|
|
605
102
|
}
|
|
606
|
-
return
|
|
607
|
-
}
|
|
608
|
-
__name(parseArray, "parseArray");
|
|
609
|
-
|
|
610
|
-
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/parse.js
|
|
611
|
-
function peekTable(key, table, meta, type) {
|
|
612
|
-
let t = table;
|
|
613
|
-
let m = meta;
|
|
614
|
-
let k;
|
|
615
|
-
let hasOwn = false;
|
|
616
|
-
let state;
|
|
617
|
-
for (let i = 0; i < key.length; i++) {
|
|
618
|
-
if (i) {
|
|
619
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
620
|
-
m = (state = m[k]).c;
|
|
621
|
-
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
622
|
-
return null;
|
|
623
|
-
}
|
|
624
|
-
if (state.t === 2) {
|
|
625
|
-
let l = t.length - 1;
|
|
626
|
-
t = t[l];
|
|
627
|
-
m = m[l].c;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
k = key[i];
|
|
631
|
-
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
|
|
632
|
-
return null;
|
|
633
|
-
}
|
|
634
|
-
if (!hasOwn) {
|
|
635
|
-
if (k === "__proto__") {
|
|
636
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
637
|
-
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
638
|
-
}
|
|
639
|
-
m[k] = {
|
|
640
|
-
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
641
|
-
d: false,
|
|
642
|
-
i: 0,
|
|
643
|
-
c: {}
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
state = m[k];
|
|
648
|
-
if (state.t !== type && !(type === 1 && state.t === 3)) {
|
|
649
|
-
return null;
|
|
650
|
-
}
|
|
651
|
-
if (type === 2) {
|
|
652
|
-
if (!state.d) {
|
|
653
|
-
state.d = true;
|
|
654
|
-
t[k] = [];
|
|
655
|
-
}
|
|
656
|
-
t[k].push(t = {});
|
|
657
|
-
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
|
|
658
|
-
}
|
|
659
|
-
if (state.d) {
|
|
660
|
-
return null;
|
|
661
|
-
}
|
|
662
|
-
state.d = true;
|
|
663
|
-
if (type === 1) {
|
|
664
|
-
t = hasOwn ? t[k] : t[k] = {};
|
|
665
|
-
} else if (type === 0 && hasOwn) {
|
|
666
|
-
return null;
|
|
667
|
-
}
|
|
668
|
-
return [k, t, state.c];
|
|
669
|
-
}
|
|
670
|
-
__name(peekTable, "peekTable");
|
|
671
|
-
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
672
|
-
let res = {};
|
|
673
|
-
let meta = {};
|
|
674
|
-
let tbl = res;
|
|
675
|
-
let m = meta;
|
|
676
|
-
for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
|
|
677
|
-
if (toml[ptr] === "[") {
|
|
678
|
-
let isTableArray = toml[++ptr] === "[";
|
|
679
|
-
let k = parseKey(toml, ptr += +isTableArray, "]");
|
|
680
|
-
if (isTableArray) {
|
|
681
|
-
if (toml[k[1] - 1] !== "]") {
|
|
682
|
-
throw new TomlError("expected end of table declaration", {
|
|
683
|
-
toml,
|
|
684
|
-
ptr: k[1] - 1
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
k[1]++;
|
|
688
|
-
}
|
|
689
|
-
let p = peekTable(
|
|
690
|
-
k[0],
|
|
691
|
-
res,
|
|
692
|
-
meta,
|
|
693
|
-
isTableArray ? 2 : 1
|
|
694
|
-
/* Type.EXPLICIT */
|
|
695
|
-
);
|
|
696
|
-
if (!p) {
|
|
697
|
-
throw new TomlError("trying to redefine an already defined table or value", {
|
|
698
|
-
toml,
|
|
699
|
-
ptr
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
m = p[2];
|
|
703
|
-
tbl = p[1];
|
|
704
|
-
ptr = k[1];
|
|
705
|
-
} else {
|
|
706
|
-
let k = parseKey(toml, ptr);
|
|
707
|
-
let p = peekTable(
|
|
708
|
-
k[0],
|
|
709
|
-
tbl,
|
|
710
|
-
m,
|
|
711
|
-
0
|
|
712
|
-
/* Type.DOTTED */
|
|
713
|
-
);
|
|
714
|
-
if (!p) {
|
|
715
|
-
throw new TomlError("trying to redefine an already defined table or value", {
|
|
716
|
-
toml,
|
|
717
|
-
ptr
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
|
|
721
|
-
p[1][p[0]] = v[0];
|
|
722
|
-
ptr = v[1];
|
|
723
|
-
}
|
|
724
|
-
ptr = skipVoid(toml, ptr, true);
|
|
725
|
-
if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
|
|
726
|
-
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
727
|
-
toml,
|
|
728
|
-
ptr
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
ptr = skipVoid(toml, ptr);
|
|
732
|
-
}
|
|
733
|
-
return res;
|
|
734
|
-
}
|
|
735
|
-
__name(parse, "parse");
|
|
736
|
-
|
|
737
|
-
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/stringify.js
|
|
738
|
-
var BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
739
|
-
function extendedTypeOf(obj) {
|
|
740
|
-
let type = typeof obj;
|
|
741
|
-
if (type === "object") {
|
|
742
|
-
if (Array.isArray(obj))
|
|
743
|
-
return "array";
|
|
744
|
-
if (obj instanceof Date)
|
|
745
|
-
return "date";
|
|
746
|
-
}
|
|
747
|
-
return type;
|
|
748
|
-
}
|
|
749
|
-
__name(extendedTypeOf, "extendedTypeOf");
|
|
750
|
-
function isArrayOfTables(obj) {
|
|
751
|
-
for (let i = 0; i < obj.length; i++) {
|
|
752
|
-
if (extendedTypeOf(obj[i]) !== "object")
|
|
753
|
-
return false;
|
|
754
|
-
}
|
|
755
|
-
return obj.length != 0;
|
|
756
|
-
}
|
|
757
|
-
__name(isArrayOfTables, "isArrayOfTables");
|
|
758
|
-
function formatString(s) {
|
|
759
|
-
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
760
|
-
}
|
|
761
|
-
__name(formatString, "formatString");
|
|
762
|
-
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
763
|
-
if (depth === 0) {
|
|
764
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
765
|
-
}
|
|
766
|
-
if (type === "number") {
|
|
767
|
-
if (isNaN(val))
|
|
768
|
-
return "nan";
|
|
769
|
-
if (val === Infinity)
|
|
770
|
-
return "inf";
|
|
771
|
-
if (val === -Infinity)
|
|
772
|
-
return "-inf";
|
|
773
|
-
if (numberAsFloat && Number.isInteger(val))
|
|
774
|
-
return val.toFixed(1);
|
|
775
|
-
return val.toString();
|
|
776
|
-
}
|
|
777
|
-
if (type === "bigint" || type === "boolean") {
|
|
778
|
-
return val.toString();
|
|
779
|
-
}
|
|
780
|
-
if (type === "string") {
|
|
781
|
-
return formatString(val);
|
|
782
|
-
}
|
|
783
|
-
if (type === "date") {
|
|
784
|
-
if (isNaN(val.getTime())) {
|
|
785
|
-
throw new TypeError("cannot serialize invalid date");
|
|
786
|
-
}
|
|
787
|
-
return val.toISOString();
|
|
788
|
-
}
|
|
789
|
-
if (type === "object") {
|
|
790
|
-
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
791
|
-
}
|
|
792
|
-
if (type === "array") {
|
|
793
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
__name(stringifyValue, "stringifyValue");
|
|
797
|
-
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
798
|
-
let keys = Object.keys(obj);
|
|
799
|
-
if (keys.length === 0)
|
|
800
|
-
return "{}";
|
|
801
|
-
let res = "{ ";
|
|
802
|
-
for (let i = 0; i < keys.length; i++) {
|
|
803
|
-
let k = keys[i];
|
|
804
|
-
if (i)
|
|
805
|
-
res += ", ";
|
|
806
|
-
res += BARE_KEY.test(k) ? k : formatString(k);
|
|
807
|
-
res += " = ";
|
|
808
|
-
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
|
|
809
|
-
}
|
|
810
|
-
return res + " }";
|
|
811
|
-
}
|
|
812
|
-
__name(stringifyInlineTable, "stringifyInlineTable");
|
|
813
|
-
function stringifyArray(array, depth, numberAsFloat) {
|
|
814
|
-
if (array.length === 0)
|
|
815
|
-
return "[]";
|
|
816
|
-
let res = "[ ";
|
|
817
|
-
for (let i = 0; i < array.length; i++) {
|
|
818
|
-
if (i)
|
|
819
|
-
res += ", ";
|
|
820
|
-
if (array[i] === null || array[i] === void 0) {
|
|
821
|
-
throw new TypeError("arrays cannot contain null or undefined values");
|
|
822
|
-
}
|
|
823
|
-
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
|
|
824
|
-
}
|
|
825
|
-
return res + " ]";
|
|
103
|
+
return credentials;
|
|
826
104
|
}
|
|
827
|
-
__name(
|
|
828
|
-
function stringifyArrayTable(array, key, depth, numberAsFloat) {
|
|
829
|
-
if (depth === 0) {
|
|
830
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
831
|
-
}
|
|
832
|
-
let res = "";
|
|
833
|
-
for (let i = 0; i < array.length; i++) {
|
|
834
|
-
res += `${res && "\n"}[[${key}]]
|
|
835
|
-
`;
|
|
836
|
-
res += stringifyTable(0, array[i], key, depth, numberAsFloat);
|
|
837
|
-
}
|
|
838
|
-
return res;
|
|
839
|
-
}
|
|
840
|
-
__name(stringifyArrayTable, "stringifyArrayTable");
|
|
841
|
-
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
842
|
-
if (depth === 0) {
|
|
843
|
-
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
844
|
-
}
|
|
845
|
-
let preamble = "";
|
|
846
|
-
let tables = "";
|
|
847
|
-
let keys = Object.keys(obj);
|
|
848
|
-
for (let i = 0; i < keys.length; i++) {
|
|
849
|
-
let k = keys[i];
|
|
850
|
-
if (obj[k] !== null && obj[k] !== void 0) {
|
|
851
|
-
let type = extendedTypeOf(obj[k]);
|
|
852
|
-
if (type === "symbol" || type === "function") {
|
|
853
|
-
throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
854
|
-
}
|
|
855
|
-
let key = BARE_KEY.test(k) ? k : formatString(k);
|
|
856
|
-
if (type === "array" && isArrayOfTables(obj[k])) {
|
|
857
|
-
tables += (tables && "\n") + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
858
|
-
} else if (type === "object") {
|
|
859
|
-
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
860
|
-
tables += (tables && "\n") + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
861
|
-
} else {
|
|
862
|
-
preamble += key;
|
|
863
|
-
preamble += " = ";
|
|
864
|
-
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
|
|
865
|
-
preamble += "\n";
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
if (tableKey && (preamble || !tables))
|
|
870
|
-
preamble = preamble ? `[${tableKey}]
|
|
871
|
-
${preamble}` : `[${tableKey}]`;
|
|
872
|
-
return preamble && tables ? `${preamble}
|
|
873
|
-
${tables}` : preamble || tables;
|
|
874
|
-
}
|
|
875
|
-
__name(stringifyTable, "stringifyTable");
|
|
876
|
-
function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
|
|
877
|
-
if (extendedTypeOf(obj) !== "object") {
|
|
878
|
-
throw new TypeError("stringify can only be called with an object");
|
|
879
|
-
}
|
|
880
|
-
let str = stringifyTable(0, obj, "", maxDepth, numbersAsFloat);
|
|
881
|
-
if (str[str.length - 1] !== "\n")
|
|
882
|
-
return str + "\n";
|
|
883
|
-
return str;
|
|
884
|
-
}
|
|
885
|
-
__name(stringify, "stringify");
|
|
886
|
-
|
|
887
|
-
// ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/index.js
|
|
888
|
-
var dist_default = { parse, stringify, TomlDate, TomlError };
|
|
889
|
-
|
|
890
|
-
// src/auth-config-file.ts
|
|
891
|
-
var USER_AUTH_CONFIG_PATH = "config";
|
|
892
|
-
function getAuthConfigFilePath() {
|
|
893
|
-
const environment = getCloudflareApiEnvironmentFromEnv();
|
|
894
|
-
const filePath = `${USER_AUTH_CONFIG_PATH}/${environment === "production" ? "default.toml" : `${environment}.toml`}`;
|
|
895
|
-
return path.join(getGlobalWranglerConfigPath(), filePath);
|
|
896
|
-
}
|
|
897
|
-
__name(getAuthConfigFilePath, "getAuthConfigFilePath");
|
|
898
|
-
function writeAuthConfigFile(config) {
|
|
899
|
-
const configPath = getAuthConfigFilePath();
|
|
900
|
-
mkdirSync(path.dirname(configPath), {
|
|
901
|
-
recursive: true
|
|
902
|
-
});
|
|
903
|
-
writeFileSync(configPath, dist_default.stringify(config), {
|
|
904
|
-
encoding: "utf-8",
|
|
905
|
-
mode: 384
|
|
906
|
-
});
|
|
907
|
-
chmodSync(configPath, 384);
|
|
908
|
-
}
|
|
909
|
-
__name(writeAuthConfigFile, "writeAuthConfigFile");
|
|
910
|
-
function readAuthConfigFile() {
|
|
911
|
-
return parseTOML(readFileSync(getAuthConfigFilePath()));
|
|
912
|
-
}
|
|
913
|
-
__name(readAuthConfigFile, "readAuthConfigFile");
|
|
914
|
-
var getClientIdFromEnv = getEnvironmentVariableFactory({
|
|
915
|
-
variableName: "WRANGLER_CLIENT_ID",
|
|
916
|
-
defaultValue: /* @__PURE__ */ __name(() => getCloudflareApiEnvironmentFromEnv() === "staging" ? "4b2ea6cc-9421-4761-874b-ce550e0e3def" : "54d11594-84e4-41aa-b438-e81b8fa78ee7", "defaultValue")
|
|
917
|
-
});
|
|
105
|
+
__name(requireApiToken, "requireApiToken");
|
|
918
106
|
var getAuthDomainFromEnv = getEnvironmentVariableFactory({
|
|
919
107
|
variableName: "WRANGLER_AUTH_DOMAIN",
|
|
920
108
|
defaultValue: /* @__PURE__ */ __name(() => getCloudflareApiEnvironmentFromEnv() === "staging" ? "dash.staging.cloudflare.com" : "dash.cloudflare.com", "defaultValue")
|
|
@@ -1050,6 +238,48 @@ async function getCloudflareAccessHeaders(options) {
|
|
|
1050
238
|
return getAccessHeaders(getAuthDomainFromEnv(), options);
|
|
1051
239
|
}
|
|
1052
240
|
__name(getCloudflareAccessHeaders, "getCloudflareAccessHeaders");
|
|
241
|
+
|
|
242
|
+
// ../../node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent/esm/index.js
|
|
243
|
+
function dedent(templ) {
|
|
244
|
+
var values = [];
|
|
245
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
246
|
+
values[_i - 1] = arguments[_i];
|
|
247
|
+
}
|
|
248
|
+
var strings = Array.from(typeof templ === "string" ? [templ] : templ);
|
|
249
|
+
strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
250
|
+
var indentLengths = strings.reduce(function(arr, str) {
|
|
251
|
+
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
|
|
252
|
+
if (matches) {
|
|
253
|
+
return arr.concat(matches.map(function(match) {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
return arr;
|
|
259
|
+
}, []);
|
|
260
|
+
if (indentLengths.length) {
|
|
261
|
+
var pattern_1 = new RegExp("\n[ ]{" + Math.min.apply(Math, indentLengths) + "}", "g");
|
|
262
|
+
strings = strings.map(function(str) {
|
|
263
|
+
return str.replace(pattern_1, "\n");
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
strings[0] = strings[0].replace(/^\r?\n/, "");
|
|
267
|
+
var string = strings[0];
|
|
268
|
+
values.forEach(function(value, i) {
|
|
269
|
+
var endentations = string.match(/(?:^|\n)( *)$/);
|
|
270
|
+
var endentation = endentations ? endentations[1] : "";
|
|
271
|
+
var indentedValue = value;
|
|
272
|
+
if (typeof value === "string" && value.includes("\n")) {
|
|
273
|
+
indentedValue = String(value).split("\n").map(function(str, i2) {
|
|
274
|
+
return i2 === 0 ? str : "" + endentation + str;
|
|
275
|
+
}).join("\n");
|
|
276
|
+
}
|
|
277
|
+
string += indentedValue + strings[i + 1];
|
|
278
|
+
});
|
|
279
|
+
return string;
|
|
280
|
+
}
|
|
281
|
+
__name(dedent, "dedent");
|
|
282
|
+
var esm_default = dedent;
|
|
1053
283
|
var ErrorOAuth2 = class extends UserError {
|
|
1054
284
|
static {
|
|
1055
285
|
__name(this, "ErrorOAuth2");
|
|
@@ -1289,60 +519,6 @@ function toErrorClass(rawError, description, uri) {
|
|
|
1289
519
|
return error;
|
|
1290
520
|
}
|
|
1291
521
|
__name(toErrorClass, "toErrorClass");
|
|
1292
|
-
|
|
1293
|
-
// ../../node_modules/.pnpm/ts-dedent@2.2.0/node_modules/ts-dedent/esm/index.js
|
|
1294
|
-
function dedent(templ) {
|
|
1295
|
-
var values = [];
|
|
1296
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1297
|
-
values[_i - 1] = arguments[_i];
|
|
1298
|
-
}
|
|
1299
|
-
var strings = Array.from(typeof templ === "string" ? [templ] : templ);
|
|
1300
|
-
strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
1301
|
-
var indentLengths = strings.reduce(function(arr, str) {
|
|
1302
|
-
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
|
|
1303
|
-
if (matches) {
|
|
1304
|
-
return arr.concat(matches.map(function(match) {
|
|
1305
|
-
var _a, _b;
|
|
1306
|
-
return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
1307
|
-
}));
|
|
1308
|
-
}
|
|
1309
|
-
return arr;
|
|
1310
|
-
}, []);
|
|
1311
|
-
if (indentLengths.length) {
|
|
1312
|
-
var pattern_1 = new RegExp("\n[ ]{" + Math.min.apply(Math, indentLengths) + "}", "g");
|
|
1313
|
-
strings = strings.map(function(str) {
|
|
1314
|
-
return str.replace(pattern_1, "\n");
|
|
1315
|
-
});
|
|
1316
|
-
}
|
|
1317
|
-
strings[0] = strings[0].replace(/^\r?\n/, "");
|
|
1318
|
-
var string = strings[0];
|
|
1319
|
-
values.forEach(function(value, i) {
|
|
1320
|
-
var endentations = string.match(/(?:^|\n)( *)$/);
|
|
1321
|
-
var endentation = endentations ? endentations[1] : "";
|
|
1322
|
-
var indentedValue = value;
|
|
1323
|
-
if (typeof value === "string" && value.includes("\n")) {
|
|
1324
|
-
indentedValue = String(value).split("\n").map(function(str, i2) {
|
|
1325
|
-
return i2 === 0 ? str : "" + endentation + str;
|
|
1326
|
-
}).join("\n");
|
|
1327
|
-
}
|
|
1328
|
-
string += indentedValue + strings[i + 1];
|
|
1329
|
-
});
|
|
1330
|
-
return string;
|
|
1331
|
-
}
|
|
1332
|
-
__name(dedent, "dedent");
|
|
1333
|
-
var esm_default = dedent;
|
|
1334
|
-
|
|
1335
|
-
// src/generate-auth-url.ts
|
|
1336
|
-
var OAUTH_CALLBACK_URL = "http://localhost:8976/oauth/callback";
|
|
1337
|
-
var generateAuthUrl = /* @__PURE__ */ __name(({
|
|
1338
|
-
authUrl,
|
|
1339
|
-
clientId,
|
|
1340
|
-
scopes,
|
|
1341
|
-
stateQueryParam,
|
|
1342
|
-
codeChallenge
|
|
1343
|
-
}) => {
|
|
1344
|
-
return authUrl + `?response_type=code&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(OAUTH_CALLBACK_URL)}&scope=${encodeURIComponent([...scopes, "offline_access"].join(" "))}&state=${stateQueryParam}&code_challenge=${encodeURIComponent(codeChallenge)}&code_challenge_method=S256`;
|
|
1345
|
-
}, "generateAuthUrl");
|
|
1346
522
|
var RECOMMENDED_CODE_VERIFIER_LENGTH = 96;
|
|
1347
523
|
var RECOMMENDED_STATE_LENGTH = 32;
|
|
1348
524
|
var PKCE_CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
|
|
@@ -1375,44 +551,6 @@ async function generatePKCECodes() {
|
|
|
1375
551
|
}
|
|
1376
552
|
__name(generatePKCECodes, "generatePKCECodes");
|
|
1377
553
|
|
|
1378
|
-
// src/state.ts
|
|
1379
|
-
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
1380
|
-
function readStoredAuthState(options) {
|
|
1381
|
-
const { configOverride, warningLogger } = options ?? {};
|
|
1382
|
-
let parsed;
|
|
1383
|
-
try {
|
|
1384
|
-
parsed = configOverride ?? readAuthConfigFile();
|
|
1385
|
-
} catch {
|
|
1386
|
-
return {};
|
|
1387
|
-
}
|
|
1388
|
-
const { oauth_token, refresh_token, expiration_time, scopes, api_token } = parsed;
|
|
1389
|
-
if (oauth_token) {
|
|
1390
|
-
return {
|
|
1391
|
-
accessToken: {
|
|
1392
|
-
value: oauth_token,
|
|
1393
|
-
// If there is no `expiration_time` field then set it to an old date, to cause it to expire immediately.
|
|
1394
|
-
expiry: expiration_time ?? "2000-01-01:00:00:00+00:00"
|
|
1395
|
-
},
|
|
1396
|
-
refreshToken: { value: refresh_token ?? "" },
|
|
1397
|
-
scopes
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
if (api_token) {
|
|
1401
|
-
if (!hasWarnedAboutDeprecatedV1ApiToken && warningLogger) {
|
|
1402
|
-
hasWarnedAboutDeprecatedV1ApiToken = true;
|
|
1403
|
-
warningLogger.warn(
|
|
1404
|
-
`It looks like you have used Wrangler v1's \`config\` command to login with an API token
|
|
1405
|
-
from ${configOverride === void 0 ? getAuthConfigFilePath() : "in-memory config"}.
|
|
1406
|
-
This is no longer supported in the current version of Wrangler.
|
|
1407
|
-
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\` environment variable.`
|
|
1408
|
-
);
|
|
1409
|
-
}
|
|
1410
|
-
return { deprecatedApiToken: api_token };
|
|
1411
|
-
}
|
|
1412
|
-
return {};
|
|
1413
|
-
}
|
|
1414
|
-
__name(readStoredAuthState, "readStoredAuthState");
|
|
1415
|
-
|
|
1416
554
|
// src/token-exchange.ts
|
|
1417
555
|
function isReturningFromAuthServer(query, state, logger) {
|
|
1418
556
|
if (query.error) {
|
|
@@ -1440,7 +578,7 @@ function isReturningFromAuthServer(query, state, logger) {
|
|
|
1440
578
|
return true;
|
|
1441
579
|
}
|
|
1442
580
|
__name(isReturningFromAuthServer, "isReturningFromAuthServer");
|
|
1443
|
-
async function getAuthURL(scopes, clientId, state, generators) {
|
|
581
|
+
async function getAuthURL(scopes, clientId, redirectUri, state, generators) {
|
|
1444
582
|
const { codeChallenge, codeVerifier } = await generatePKCECodes();
|
|
1445
583
|
const stateQueryParam = generators.generateRandomState(
|
|
1446
584
|
RECOMMENDED_STATE_LENGTH
|
|
@@ -1455,13 +593,15 @@ async function getAuthURL(scopes, clientId, state, generators) {
|
|
|
1455
593
|
clientId,
|
|
1456
594
|
scopes,
|
|
1457
595
|
stateQueryParam,
|
|
1458
|
-
codeChallenge
|
|
596
|
+
codeChallenge,
|
|
597
|
+
redirectUri
|
|
1459
598
|
});
|
|
1460
599
|
}
|
|
1461
600
|
__name(getAuthURL, "getAuthURL");
|
|
1462
|
-
async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI) {
|
|
601
|
+
async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI, clientId, storage) {
|
|
1463
602
|
const storedRefreshToken = readStoredAuthState({
|
|
1464
|
-
warningLogger: logger
|
|
603
|
+
warningLogger: logger,
|
|
604
|
+
storage
|
|
1465
605
|
}).refreshToken;
|
|
1466
606
|
if (!storedRefreshToken) {
|
|
1467
607
|
logger.warn("No refresh token is present.");
|
|
@@ -1469,7 +609,7 @@ async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI)
|
|
|
1469
609
|
const params = new URLSearchParams({
|
|
1470
610
|
grant_type: "refresh_token",
|
|
1471
611
|
refresh_token: storedRefreshToken?.value ?? "",
|
|
1472
|
-
client_id:
|
|
612
|
+
client_id: clientId
|
|
1473
613
|
});
|
|
1474
614
|
const response = await fetchAuthToken(params, logger, isNonInteractiveOrCI);
|
|
1475
615
|
if (response.status >= 400) {
|
|
@@ -1518,7 +658,7 @@ async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI)
|
|
|
1518
658
|
}
|
|
1519
659
|
}
|
|
1520
660
|
__name(exchangeRefreshTokenForAccessToken, "exchangeRefreshTokenForAccessToken");
|
|
1521
|
-
async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrCI) {
|
|
661
|
+
async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrCI, clientId, redirectUri) {
|
|
1522
662
|
const { authorizationCode, codeVerifier = "" } = state;
|
|
1523
663
|
if (!codeVerifier) {
|
|
1524
664
|
logger.warn("No code verifier is being sent.");
|
|
@@ -1528,8 +668,8 @@ async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrC
|
|
|
1528
668
|
const params = new URLSearchParams({
|
|
1529
669
|
grant_type: `authorization_code`,
|
|
1530
670
|
code: authorizationCode ?? "",
|
|
1531
|
-
redirect_uri:
|
|
1532
|
-
client_id:
|
|
671
|
+
redirect_uri: redirectUri,
|
|
672
|
+
client_id: clientId,
|
|
1533
673
|
code_verifier: codeVerifier
|
|
1534
674
|
});
|
|
1535
675
|
const response = await fetchAuthToken(params, logger, isNonInteractiveOrCI);
|
|
@@ -1586,7 +726,7 @@ async function fetchAuthToken(body, logger, isNonInteractiveOrCI) {
|
|
|
1586
726
|
headers
|
|
1587
727
|
});
|
|
1588
728
|
if (!response.ok) {
|
|
1589
|
-
logger.
|
|
729
|
+
logger.debug(
|
|
1590
730
|
"Failed to fetch auth token:",
|
|
1591
731
|
response.status,
|
|
1592
732
|
response.statusText
|
|
@@ -1594,7 +734,7 @@ async function fetchAuthToken(body, logger, isNonInteractiveOrCI) {
|
|
|
1594
734
|
}
|
|
1595
735
|
return response;
|
|
1596
736
|
} catch (e) {
|
|
1597
|
-
logger.
|
|
737
|
+
logger.debug("Failed to fetch auth token:", e);
|
|
1598
738
|
throw e;
|
|
1599
739
|
}
|
|
1600
740
|
}
|
|
@@ -1610,7 +750,9 @@ async function getJSONFromResponse(response, logger) {
|
|
|
1610
750
|
);
|
|
1611
751
|
if (text.match(/challenge-platform/)) {
|
|
1612
752
|
logger.error(
|
|
1613
|
-
`It looks like you might have hit a bot challenge page. This may be transient but if not, please contact Cloudflare to find out what can be done. When you contact Cloudflare, please provide your Ray ID: ${response.headers.get(
|
|
753
|
+
`It looks like you might have hit a bot challenge page. This may be transient but if not, please contact Cloudflare to find out what can be done. When you contact Cloudflare, please provide your Ray ID: ${response.headers.get(
|
|
754
|
+
"cf-ray"
|
|
755
|
+
)}`
|
|
1614
756
|
);
|
|
1615
757
|
}
|
|
1616
758
|
}
|
|
@@ -1628,9 +770,11 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1628
770
|
const urlToOpen = await getAuthURL(
|
|
1629
771
|
options.scopes,
|
|
1630
772
|
options.clientId,
|
|
773
|
+
options.redirectUri,
|
|
1631
774
|
state,
|
|
1632
775
|
generators
|
|
1633
776
|
);
|
|
777
|
+
const callbackPath = new URL(options.redirectUri).pathname;
|
|
1634
778
|
let server;
|
|
1635
779
|
let loginTimeoutHandle;
|
|
1636
780
|
const timerPromise = new Promise((_, reject) => {
|
|
@@ -1705,7 +849,7 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1705
849
|
return res.end("OK");
|
|
1706
850
|
}
|
|
1707
851
|
switch (pathname) {
|
|
1708
|
-
case
|
|
852
|
+
case callbackPath: {
|
|
1709
853
|
let hasAuthCode = false;
|
|
1710
854
|
try {
|
|
1711
855
|
hasAuthCode = isReturningFromAuthServer(query, state, ctx.logger);
|
|
@@ -1747,7 +891,9 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1747
891
|
const exchange = await exchangeAuthCodeForAccessToken(
|
|
1748
892
|
state,
|
|
1749
893
|
ctx.logger,
|
|
1750
|
-
ctx.isNonInteractiveOrCI
|
|
894
|
+
ctx.isNonInteractiveOrCI,
|
|
895
|
+
options.clientId,
|
|
896
|
+
options.redirectUri
|
|
1751
897
|
);
|
|
1752
898
|
res.writeHead(307, {
|
|
1753
899
|
Location: options.granted.url
|
|
@@ -1768,12 +914,17 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1768
914
|
}
|
|
1769
915
|
}
|
|
1770
916
|
});
|
|
1771
|
-
|
|
917
|
+
const redirect = new URL(options.redirectUri);
|
|
918
|
+
const redirectPort = Number(
|
|
919
|
+
redirect.port || (redirect.protocol === "https:" ? 443 : 80)
|
|
920
|
+
);
|
|
921
|
+
if (redirect.hostname !== options.callbackHost || redirectPort !== options.callbackPort) {
|
|
1772
922
|
ctx.logger.log(
|
|
1773
923
|
`Temporary login server listening on ${options.callbackHost}:${options.callbackPort}`
|
|
1774
924
|
);
|
|
1775
925
|
ctx.logger.log(
|
|
1776
|
-
|
|
926
|
+
`Note that the OAuth login page will always redirect to \`${options.redirectUri}\`.
|
|
927
|
+
If you have changed the callback host or port because you are running in a container, then ensure that you have port forwarding set up correctly.`
|
|
1777
928
|
);
|
|
1778
929
|
}
|
|
1779
930
|
server.once("error", (err) => {
|
|
@@ -1800,12 +951,212 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1800
951
|
return Promise.race([timerPromise, loginPromise]);
|
|
1801
952
|
}
|
|
1802
953
|
__name(getOauthToken, "getOauthToken");
|
|
954
|
+
|
|
955
|
+
// src/generate-auth-url.ts
|
|
956
|
+
var generateAuthUrl = /* @__PURE__ */ __name(({
|
|
957
|
+
authUrl,
|
|
958
|
+
clientId,
|
|
959
|
+
scopes,
|
|
960
|
+
stateQueryParam,
|
|
961
|
+
codeChallenge,
|
|
962
|
+
redirectUri
|
|
963
|
+
}) => {
|
|
964
|
+
return authUrl + `?response_type=code&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent([...scopes, "offline_access"].join(" "))}&state=${stateQueryParam}&code_challenge=${encodeURIComponent(codeChallenge)}&code_challenge_method=S256`;
|
|
965
|
+
}, "generateAuthUrl");
|
|
1803
966
|
function generateRandomState(lengthOfState) {
|
|
1804
967
|
const output = new Uint32Array(lengthOfState);
|
|
1805
968
|
webcrypto.getRandomValues(output);
|
|
1806
969
|
return Array.from(output).map((num) => PKCE_CHARSET[num % PKCE_CHARSET.length]).join("");
|
|
1807
970
|
}
|
|
1808
971
|
__name(generateRandomState, "generateRandomState");
|
|
972
|
+
var POW_MAX_ITERATIONS = 64e6;
|
|
973
|
+
function solvePow(seed, k, g) {
|
|
974
|
+
const checkpoints = new Array(k + 1);
|
|
975
|
+
let h = createHash("sha256").update(seed).digest();
|
|
976
|
+
checkpoints[0] = h;
|
|
977
|
+
for (let j = 0; j < k; j++) {
|
|
978
|
+
for (let i = 0; i < g; i++) {
|
|
979
|
+
h = createHash("sha256").update(h).digest();
|
|
980
|
+
}
|
|
981
|
+
checkpoints[j + 1] = h;
|
|
982
|
+
}
|
|
983
|
+
return checkpoints;
|
|
984
|
+
}
|
|
985
|
+
__name(solvePow, "solvePow");
|
|
986
|
+
function encodeCheckpoints(checkpoints) {
|
|
987
|
+
return Buffer.concat(checkpoints).toString("base64");
|
|
988
|
+
}
|
|
989
|
+
__name(encodeCheckpoints, "encodeCheckpoints");
|
|
990
|
+
function solveChallenge(challenge) {
|
|
991
|
+
const checkpoints = solvePow(
|
|
992
|
+
Buffer.from(challenge.seed, "base64url"),
|
|
993
|
+
challenge.k,
|
|
994
|
+
challenge.g
|
|
995
|
+
);
|
|
996
|
+
return {
|
|
997
|
+
challengeToken: challenge.challengeToken,
|
|
998
|
+
solution: { checkpoints: encodeCheckpoints(checkpoints) }
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
__name(solveChallenge, "solveChallenge");
|
|
1002
|
+
|
|
1003
|
+
// src/temporary.ts
|
|
1004
|
+
var TEMPORARY_TERMS_URLS = {
|
|
1005
|
+
termsOfService: "https://www.cloudflare.com/terms/",
|
|
1006
|
+
privacyPolicy: "https://www.cloudflare.com/privacypolicy/"
|
|
1007
|
+
};
|
|
1008
|
+
var TEMPORARY_TERMS_PROMPT = `You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) in order to continue. By typing "yes", you agree to these terms. Type "yes" to continue.`;
|
|
1009
|
+
var TEMPORARY_TERMS_NOTICE = `Continuing means you accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}).`;
|
|
1010
|
+
var TEMPORARY_TERMS_ERROR = `You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) to use --temporary.`;
|
|
1011
|
+
function getTemporaryPreviewUrl() {
|
|
1012
|
+
return `${getCloudflareApiBaseUrl(COMPLIANCE_REGION_CONFIG_PUBLIC)}/provisioning/previews`;
|
|
1013
|
+
}
|
|
1014
|
+
__name(getTemporaryPreviewUrl, "getTemporaryPreviewUrl");
|
|
1015
|
+
function getTemporaryPreviewChallengeUrl() {
|
|
1016
|
+
return `${getTemporaryPreviewUrl()}/challenge`;
|
|
1017
|
+
}
|
|
1018
|
+
__name(getTemporaryPreviewChallengeUrl, "getTemporaryPreviewChallengeUrl");
|
|
1019
|
+
function isFutureTimestamp(timestamp) {
|
|
1020
|
+
const parsed = Date.parse(timestamp);
|
|
1021
|
+
return !Number.isNaN(parsed) && parsed > Date.now();
|
|
1022
|
+
}
|
|
1023
|
+
__name(isFutureTimestamp, "isFutureTimestamp");
|
|
1024
|
+
function getCachedTemporaryPreviewAccount(storage) {
|
|
1025
|
+
let temporaryPreviewAccount;
|
|
1026
|
+
try {
|
|
1027
|
+
temporaryPreviewAccount = storage.read();
|
|
1028
|
+
} catch {
|
|
1029
|
+
return void 0;
|
|
1030
|
+
}
|
|
1031
|
+
if (!temporaryPreviewAccount) {
|
|
1032
|
+
return void 0;
|
|
1033
|
+
}
|
|
1034
|
+
if (!temporaryPreviewAccount.account?.id || !temporaryPreviewAccount.account?.apiToken || !temporaryPreviewAccount.account?.name || !temporaryPreviewAccount.claim?.url || !isFutureTimestamp(temporaryPreviewAccount.account?.expiresAt ?? "") || !isFutureTimestamp(temporaryPreviewAccount.claim?.expiresAt ?? "")) {
|
|
1035
|
+
return void 0;
|
|
1036
|
+
}
|
|
1037
|
+
return temporaryPreviewAccount;
|
|
1038
|
+
}
|
|
1039
|
+
__name(getCachedTemporaryPreviewAccount, "getCachedTemporaryPreviewAccount");
|
|
1040
|
+
async function requestPowSolution(logger) {
|
|
1041
|
+
const response = await fetch(getTemporaryPreviewChallengeUrl(), {
|
|
1042
|
+
method: "POST",
|
|
1043
|
+
headers: { "Content-Type": "application/json" },
|
|
1044
|
+
body: "{}"
|
|
1045
|
+
});
|
|
1046
|
+
if (!response.ok) {
|
|
1047
|
+
throw new FatalError(
|
|
1048
|
+
`Failed to request a proof-of-work challenge (${response.status} ${response.statusText}).`,
|
|
1049
|
+
{ telemetryMessage: "deploy temporary account challenge failed" }
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
let body;
|
|
1053
|
+
try {
|
|
1054
|
+
body = await response.json();
|
|
1055
|
+
} catch {
|
|
1056
|
+
throw new FatalError(
|
|
1057
|
+
`Failed to request a proof-of-work challenge. Received an invalid response (${response.status} ${response.statusText}).`,
|
|
1058
|
+
{
|
|
1059
|
+
telemetryMessage: "deploy temporary account challenge invalid response"
|
|
1060
|
+
}
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
const { challengeToken, seed, k, g } = body.result ?? {};
|
|
1064
|
+
if (challengeToken === void 0 || seed === void 0 || k === void 0 || g === void 0) {
|
|
1065
|
+
throw new FatalError(
|
|
1066
|
+
"Failed to request a proof-of-work challenge because the response was missing required fields.",
|
|
1067
|
+
{ telemetryMessage: "deploy temporary account challenge incomplete" }
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
if (!Number.isInteger(k) || !Number.isInteger(g) || k <= 0 || g <= 0 || k * g > POW_MAX_ITERATIONS || Buffer.from(seed, "base64url").length !== 32) {
|
|
1071
|
+
throw new FatalError(
|
|
1072
|
+
"The proof-of-work challenge is not supported by this version of Wrangler.",
|
|
1073
|
+
{
|
|
1074
|
+
telemetryMessage: "deploy temporary account challenge difficulty unsupported"
|
|
1075
|
+
}
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
logger.log("Solving proof-of-work challenge\u2026");
|
|
1079
|
+
return solveChallenge({ challengeToken, seed, k, g });
|
|
1080
|
+
}
|
|
1081
|
+
__name(requestPowSolution, "requestPowSolution");
|
|
1082
|
+
async function createTemporaryPreviewAccount(logger) {
|
|
1083
|
+
const pow = await requestPowSolution(logger);
|
|
1084
|
+
const response = await fetch(getTemporaryPreviewUrl(), {
|
|
1085
|
+
method: "POST",
|
|
1086
|
+
headers: { "Content-Type": "application/json" },
|
|
1087
|
+
body: JSON.stringify({
|
|
1088
|
+
termsOfService: TEMPORARY_TERMS_URLS.termsOfService,
|
|
1089
|
+
privacyPolicy: TEMPORARY_TERMS_URLS.privacyPolicy,
|
|
1090
|
+
acceptTermsOfService: "yes",
|
|
1091
|
+
challengeToken: pow.challengeToken,
|
|
1092
|
+
solution: pow.solution
|
|
1093
|
+
})
|
|
1094
|
+
});
|
|
1095
|
+
if (!response.ok) {
|
|
1096
|
+
throw new FatalError(
|
|
1097
|
+
`Failed to create a temporary preview account (${response.status} ${response.statusText}).`,
|
|
1098
|
+
{ telemetryMessage: "deploy temporary account create failed" }
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
let responseBody;
|
|
1102
|
+
try {
|
|
1103
|
+
responseBody = await response.json();
|
|
1104
|
+
} catch {
|
|
1105
|
+
throw new FatalError(
|
|
1106
|
+
`Failed to create a temporary preview account. Received an invalid response (${response.status} ${response.statusText}).`,
|
|
1107
|
+
{ telemetryMessage: "deploy temporary account invalid response" }
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
const previewAccount = responseBody.result;
|
|
1111
|
+
const accountId = previewAccount?.account?.id;
|
|
1112
|
+
const accountName = previewAccount?.account?.name;
|
|
1113
|
+
const apiToken = previewAccount?.account?.apiToken;
|
|
1114
|
+
const accountExpiresAt = previewAccount?.account?.expiresAt;
|
|
1115
|
+
const claimUrl = previewAccount?.claim?.url;
|
|
1116
|
+
const claimExpiresAt = previewAccount?.claim?.expiresAt;
|
|
1117
|
+
if (accountId === void 0 || accountName === void 0 || apiToken === void 0 || accountExpiresAt === void 0 || claimUrl === void 0 || claimExpiresAt === void 0) {
|
|
1118
|
+
throw new FatalError(
|
|
1119
|
+
"Failed to create a temporary preview account because the response was missing required fields.",
|
|
1120
|
+
{ telemetryMessage: "deploy temporary account response incomplete" }
|
|
1121
|
+
);
|
|
1122
|
+
}
|
|
1123
|
+
return {
|
|
1124
|
+
account: {
|
|
1125
|
+
id: accountId,
|
|
1126
|
+
name: accountName,
|
|
1127
|
+
apiToken,
|
|
1128
|
+
expiresAt: accountExpiresAt
|
|
1129
|
+
},
|
|
1130
|
+
claim: {
|
|
1131
|
+
url: claimUrl,
|
|
1132
|
+
expiresAt: claimExpiresAt
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
__name(createTemporaryPreviewAccount, "createTemporaryPreviewAccount");
|
|
1137
|
+
async function getOrCreateTemporaryPreviewAccount(options) {
|
|
1138
|
+
const cachedPreviewAccount = getCachedTemporaryPreviewAccount(
|
|
1139
|
+
options.storage
|
|
1140
|
+
);
|
|
1141
|
+
if (cachedPreviewAccount) {
|
|
1142
|
+
return { account: cachedPreviewAccount, cached: true };
|
|
1143
|
+
}
|
|
1144
|
+
const termsAccepted = await options.prompt(
|
|
1145
|
+
TEMPORARY_TERMS_PROMPT,
|
|
1146
|
+
TEMPORARY_TERMS_NOTICE
|
|
1147
|
+
);
|
|
1148
|
+
if (!termsAccepted) {
|
|
1149
|
+
throw new UserError(TEMPORARY_TERMS_ERROR, {
|
|
1150
|
+
telemetryMessage: "user temporary terms not accepted"
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
const temporaryPreviewAccount = await createTemporaryPreviewAccount(
|
|
1154
|
+
options.logger
|
|
1155
|
+
);
|
|
1156
|
+
options.storage.write(temporaryPreviewAccount);
|
|
1157
|
+
return { account: temporaryPreviewAccount, cached: false };
|
|
1158
|
+
}
|
|
1159
|
+
__name(getOrCreateTemporaryPreviewAccount, "getOrCreateTemporaryPreviewAccount");
|
|
1809
1160
|
|
|
1810
1161
|
// src/flow.ts
|
|
1811
1162
|
function createOAuthFlow(ctx) {
|
|
@@ -1814,6 +1165,14 @@ function createOAuthFlow(ctx) {
|
|
|
1814
1165
|
generateAuthUrl: ctx.generateAuthUrl ?? generateAuthUrl,
|
|
1815
1166
|
generateRandomState: ctx.generateRandomState ?? generateRandomState
|
|
1816
1167
|
};
|
|
1168
|
+
const storage = ctx.storage;
|
|
1169
|
+
const getClientId = /* @__PURE__ */ __name(() => typeof ctx.clientId === "function" ? ctx.clientId() : ctx.clientId, "getClientId");
|
|
1170
|
+
const consent = ctx.consent;
|
|
1171
|
+
let temporaryAllowed = false;
|
|
1172
|
+
let activeTemporaryAccount;
|
|
1173
|
+
const redirectUrl = new URL(ctx.redirectUri);
|
|
1174
|
+
const defaultCallbackHost = redirectUrl.hostname;
|
|
1175
|
+
const defaultCallbackPort = Number(redirectUrl.port);
|
|
1817
1176
|
async function login(props) {
|
|
1818
1177
|
if (ctx.hasEnvCredentials()) {
|
|
1819
1178
|
ctx.logger.error(
|
|
@@ -1841,28 +1200,25 @@ function createOAuthFlow(ctx) {
|
|
|
1841
1200
|
{
|
|
1842
1201
|
browser: props.browser ?? true,
|
|
1843
1202
|
scopes: props.scopes,
|
|
1844
|
-
clientId:
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
url: "https://welcome.developers.workers.dev/wrangler-oauth-consent-granted"
|
|
1851
|
-
},
|
|
1852
|
-
callbackHost: props.callbackHost ?? "localhost",
|
|
1853
|
-
callbackPort: props.callbackPort ?? 8976
|
|
1203
|
+
clientId: getClientId(),
|
|
1204
|
+
redirectUri: ctx.redirectUri,
|
|
1205
|
+
denied: consent.denied,
|
|
1206
|
+
granted: consent.granted,
|
|
1207
|
+
callbackHost: props.callbackHost ?? defaultCallbackHost,
|
|
1208
|
+
callbackPort: props.callbackPort ?? defaultCallbackPort
|
|
1854
1209
|
},
|
|
1855
1210
|
oauthFlowState,
|
|
1856
1211
|
ctx,
|
|
1857
1212
|
generators
|
|
1858
1213
|
);
|
|
1859
|
-
|
|
1214
|
+
storage.write({
|
|
1860
1215
|
oauth_token: oauth.token?.value ?? "",
|
|
1861
1216
|
expiration_time: oauth.token?.expiry,
|
|
1862
1217
|
refresh_token: oauth.refreshToken?.value,
|
|
1863
1218
|
scopes: oauth.scopes
|
|
1864
1219
|
});
|
|
1865
1220
|
ctx.logger.log(`Successfully logged in.`);
|
|
1221
|
+
clearTemporaryAccount();
|
|
1866
1222
|
ctx.purgeOnLoginOrLogout?.();
|
|
1867
1223
|
return true;
|
|
1868
1224
|
}
|
|
@@ -1871,7 +1227,10 @@ function createOAuthFlow(ctx) {
|
|
|
1871
1227
|
if (ctx.hasEnvCredentials()) {
|
|
1872
1228
|
return false;
|
|
1873
1229
|
}
|
|
1874
|
-
const { accessToken } = readStoredAuthState({
|
|
1230
|
+
const { accessToken } = readStoredAuthState({
|
|
1231
|
+
warningLogger: ctx.logger,
|
|
1232
|
+
storage
|
|
1233
|
+
});
|
|
1875
1234
|
return Boolean(accessToken && /* @__PURE__ */ new Date() >= new Date(accessToken.expiry));
|
|
1876
1235
|
}
|
|
1877
1236
|
__name(isRefreshNeeded, "isRefreshNeeded");
|
|
@@ -1886,9 +1245,11 @@ function createOAuthFlow(ctx) {
|
|
|
1886
1245
|
scopes
|
|
1887
1246
|
} = await exchangeRefreshTokenForAccessToken(
|
|
1888
1247
|
ctx.logger,
|
|
1889
|
-
ctx.isNonInteractiveOrCI
|
|
1248
|
+
ctx.isNonInteractiveOrCI,
|
|
1249
|
+
getClientId(),
|
|
1250
|
+
storage
|
|
1890
1251
|
);
|
|
1891
|
-
|
|
1252
|
+
storage.write({
|
|
1892
1253
|
oauth_token,
|
|
1893
1254
|
expiration_time,
|
|
1894
1255
|
refresh_token,
|
|
@@ -1905,24 +1266,45 @@ function createOAuthFlow(ctx) {
|
|
|
1905
1266
|
__name(refreshToken, "refreshToken");
|
|
1906
1267
|
async function loginOrRefreshIfRequired(props) {
|
|
1907
1268
|
if (ctx.hasEnvCredentials()) {
|
|
1908
|
-
return true;
|
|
1269
|
+
return { loggedIn: true };
|
|
1909
1270
|
}
|
|
1910
|
-
const stored = readStoredAuthState({
|
|
1271
|
+
const stored = readStoredAuthState({
|
|
1272
|
+
warningLogger: ctx.logger,
|
|
1273
|
+
storage
|
|
1274
|
+
});
|
|
1911
1275
|
if (!stored.accessToken && !stored.deprecatedApiToken) {
|
|
1912
|
-
|
|
1276
|
+
if (ctx.isNonInteractiveOrCI()) {
|
|
1277
|
+
return {
|
|
1278
|
+
loggedIn: false,
|
|
1279
|
+
reason: "no-credentials-non-interactive"
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
if (await login(props)) {
|
|
1283
|
+
return { loggedIn: true };
|
|
1284
|
+
}
|
|
1285
|
+
return { loggedIn: false, reason: "no-credentials-login-failed" };
|
|
1913
1286
|
} else if (isRefreshNeeded()) {
|
|
1914
1287
|
const didRefresh = await refreshToken();
|
|
1915
1288
|
if (didRefresh) {
|
|
1916
|
-
return true;
|
|
1917
|
-
} else {
|
|
1918
|
-
return !ctx.isNonInteractiveOrCI() && await login(props);
|
|
1289
|
+
return { loggedIn: true };
|
|
1919
1290
|
}
|
|
1291
|
+
if (ctx.isNonInteractiveOrCI()) {
|
|
1292
|
+
return {
|
|
1293
|
+
loggedIn: false,
|
|
1294
|
+
reason: "token-expired-non-interactive"
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
if (await login(props)) {
|
|
1298
|
+
return { loggedIn: true };
|
|
1299
|
+
}
|
|
1300
|
+
return { loggedIn: false, reason: "token-expired-login-failed" };
|
|
1920
1301
|
} else {
|
|
1921
|
-
return true;
|
|
1302
|
+
return { loggedIn: true };
|
|
1922
1303
|
}
|
|
1923
1304
|
}
|
|
1924
1305
|
__name(loginOrRefreshIfRequired, "loginOrRefreshIfRequired");
|
|
1925
1306
|
async function logout() {
|
|
1307
|
+
const clearedTemporary = clearTemporaryAccount();
|
|
1926
1308
|
if (ctx.hasEnvCredentials()) {
|
|
1927
1309
|
ctx.logger.log(
|
|
1928
1310
|
"You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log out."
|
|
@@ -1930,13 +1312,16 @@ function createOAuthFlow(ctx) {
|
|
|
1930
1312
|
return;
|
|
1931
1313
|
}
|
|
1932
1314
|
const storedRefreshToken = readStoredAuthState({
|
|
1933
|
-
warningLogger: ctx.logger
|
|
1315
|
+
warningLogger: ctx.logger,
|
|
1316
|
+
storage
|
|
1934
1317
|
}).refreshToken;
|
|
1935
1318
|
if (!storedRefreshToken) {
|
|
1936
|
-
ctx.logger.log(
|
|
1319
|
+
ctx.logger.log(
|
|
1320
|
+
clearedTemporary ? "Cleared temporary preview account." : "Not logged in, exiting..."
|
|
1321
|
+
);
|
|
1937
1322
|
return;
|
|
1938
1323
|
}
|
|
1939
|
-
const body = `client_id=${encodeURIComponent(
|
|
1324
|
+
const body = `client_id=${encodeURIComponent(getClientId())}&token_type_hint=refresh_token&token=${encodeURIComponent(storedRefreshToken.value || "")}`;
|
|
1940
1325
|
const response = await fetch(getRevokeUrlFromEnv(), {
|
|
1941
1326
|
method: "POST",
|
|
1942
1327
|
body,
|
|
@@ -1945,13 +1330,13 @@ function createOAuthFlow(ctx) {
|
|
|
1945
1330
|
}
|
|
1946
1331
|
});
|
|
1947
1332
|
await response.text();
|
|
1948
|
-
|
|
1333
|
+
storage.clear();
|
|
1949
1334
|
ctx.logger.log(`Successfully logged out.`);
|
|
1950
1335
|
ctx.purgeOnLoginOrLogout?.();
|
|
1951
1336
|
}
|
|
1952
1337
|
__name(logout, "logout");
|
|
1953
1338
|
async function getOAuthTokenFromLocalState() {
|
|
1954
|
-
let stored = readStoredAuthState({ warningLogger: ctx.logger });
|
|
1339
|
+
let stored = readStoredAuthState({ warningLogger: ctx.logger, storage });
|
|
1955
1340
|
if (!stored.accessToken) {
|
|
1956
1341
|
return void 0;
|
|
1957
1342
|
}
|
|
@@ -1961,283 +1346,79 @@ function createOAuthFlow(ctx) {
|
|
|
1961
1346
|
if (!didRefresh) {
|
|
1962
1347
|
return void 0;
|
|
1963
1348
|
}
|
|
1964
|
-
stored = readStoredAuthState({ warningLogger: ctx.logger });
|
|
1349
|
+
stored = readStoredAuthState({ warningLogger: ctx.logger, storage });
|
|
1965
1350
|
}
|
|
1966
1351
|
return stored.accessToken?.value;
|
|
1967
1352
|
}
|
|
1968
1353
|
__name(getOAuthTokenFromLocalState, "getOAuthTokenFromLocalState");
|
|
1354
|
+
function getAPITokenInternal() {
|
|
1355
|
+
if (activeTemporaryAccount) {
|
|
1356
|
+
return { apiToken: activeTemporaryAccount.account.apiToken };
|
|
1357
|
+
}
|
|
1358
|
+
return getAPIToken({
|
|
1359
|
+
storage,
|
|
1360
|
+
warningLogger: ctx.logger,
|
|
1361
|
+
allowGlobalAuthKey: ctx.allowGlobalAuthKey
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
__name(getAPITokenInternal, "getAPITokenInternal");
|
|
1365
|
+
function requireApiTokenInternal() {
|
|
1366
|
+
if (activeTemporaryAccount) {
|
|
1367
|
+
return { apiToken: activeTemporaryAccount.account.apiToken };
|
|
1368
|
+
}
|
|
1369
|
+
return requireApiToken({
|
|
1370
|
+
storage,
|
|
1371
|
+
warningLogger: ctx.logger,
|
|
1372
|
+
allowGlobalAuthKey: ctx.allowGlobalAuthKey
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
__name(requireApiTokenInternal, "requireApiTokenInternal");
|
|
1376
|
+
function setTemporaryAllowed(allowed) {
|
|
1377
|
+
temporaryAllowed = allowed && ctx.temporary !== void 0;
|
|
1378
|
+
activeTemporaryAccount = void 0;
|
|
1379
|
+
}
|
|
1380
|
+
__name(setTemporaryAllowed, "setTemporaryAllowed");
|
|
1381
|
+
function isTemporaryAllowed() {
|
|
1382
|
+
return temporaryAllowed;
|
|
1383
|
+
}
|
|
1384
|
+
__name(isTemporaryAllowed, "isTemporaryAllowed");
|
|
1385
|
+
function getActiveTemporaryAccount() {
|
|
1386
|
+
return activeTemporaryAccount;
|
|
1387
|
+
}
|
|
1388
|
+
__name(getActiveTemporaryAccount, "getActiveTemporaryAccount");
|
|
1389
|
+
async function activateTemporaryAccount() {
|
|
1390
|
+
if (!ctx.temporary) {
|
|
1391
|
+
throw new UserError(
|
|
1392
|
+
"Temporary preview accounts are not supported by this CLI.",
|
|
1393
|
+
{ telemetryMessage: "user temporary account unsupported" }
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
const result = await getOrCreateTemporaryPreviewAccount({
|
|
1397
|
+
...ctx.temporary,
|
|
1398
|
+
logger: ctx.logger
|
|
1399
|
+
});
|
|
1400
|
+
activeTemporaryAccount = result.account;
|
|
1401
|
+
return result;
|
|
1402
|
+
}
|
|
1403
|
+
__name(activateTemporaryAccount, "activateTemporaryAccount");
|
|
1404
|
+
function clearTemporaryAccount() {
|
|
1405
|
+
activeTemporaryAccount = void 0;
|
|
1406
|
+
return ctx.temporary?.storage.clear() ?? false;
|
|
1407
|
+
}
|
|
1408
|
+
__name(clearTemporaryAccount, "clearTemporaryAccount");
|
|
1969
1409
|
return {
|
|
1970
1410
|
login,
|
|
1971
1411
|
logout,
|
|
1972
1412
|
loginOrRefreshIfRequired,
|
|
1973
1413
|
getOAuthTokenFromLocalState,
|
|
1974
|
-
|
|
1975
|
-
|
|
1414
|
+
getAPIToken: getAPITokenInternal,
|
|
1415
|
+
requireApiToken: requireApiTokenInternal,
|
|
1416
|
+
setTemporaryAllowed,
|
|
1417
|
+
isTemporaryAllowed,
|
|
1418
|
+
getActiveTemporaryAccount,
|
|
1419
|
+
activateTemporaryAccount
|
|
1976
1420
|
};
|
|
1977
1421
|
}
|
|
1978
1422
|
__name(createOAuthFlow, "createOAuthFlow");
|
|
1979
|
-
/*! Bundled license information:
|
|
1980
|
-
|
|
1981
|
-
smol-toml/dist/error.js:
|
|
1982
|
-
(*!
|
|
1983
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
1984
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1985
|
-
*
|
|
1986
|
-
* Redistribution and use in source and binary forms, with or without
|
|
1987
|
-
* modification, are permitted provided that the following conditions are met:
|
|
1988
|
-
*
|
|
1989
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
1990
|
-
* list of conditions and the following disclaimer.
|
|
1991
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
1992
|
-
* this list of conditions and the following disclaimer in the
|
|
1993
|
-
* documentation and/or other materials provided with the distribution.
|
|
1994
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
1995
|
-
* may be used to endorse or promote products derived from this software without
|
|
1996
|
-
* specific prior written permission.
|
|
1997
|
-
*
|
|
1998
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
1999
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2000
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2001
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2002
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2003
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2004
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2005
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2006
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2007
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2008
|
-
*)
|
|
2009
|
-
|
|
2010
|
-
smol-toml/dist/util.js:
|
|
2011
|
-
(*!
|
|
2012
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2013
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2014
|
-
*
|
|
2015
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2016
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2017
|
-
*
|
|
2018
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2019
|
-
* list of conditions and the following disclaimer.
|
|
2020
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2021
|
-
* this list of conditions and the following disclaimer in the
|
|
2022
|
-
* documentation and/or other materials provided with the distribution.
|
|
2023
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2024
|
-
* may be used to endorse or promote products derived from this software without
|
|
2025
|
-
* specific prior written permission.
|
|
2026
|
-
*
|
|
2027
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2028
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2029
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2030
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2031
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2032
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2033
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2034
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2035
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2036
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2037
|
-
*)
|
|
2038
|
-
|
|
2039
|
-
smol-toml/dist/date.js:
|
|
2040
|
-
(*!
|
|
2041
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2042
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2043
|
-
*
|
|
2044
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2045
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2046
|
-
*
|
|
2047
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2048
|
-
* list of conditions and the following disclaimer.
|
|
2049
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2050
|
-
* this list of conditions and the following disclaimer in the
|
|
2051
|
-
* documentation and/or other materials provided with the distribution.
|
|
2052
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2053
|
-
* may be used to endorse or promote products derived from this software without
|
|
2054
|
-
* specific prior written permission.
|
|
2055
|
-
*
|
|
2056
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2057
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2058
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2059
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2060
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2061
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2062
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2063
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2064
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2065
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2066
|
-
*)
|
|
2067
|
-
|
|
2068
|
-
smol-toml/dist/primitive.js:
|
|
2069
|
-
(*!
|
|
2070
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2071
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2072
|
-
*
|
|
2073
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2074
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2075
|
-
*
|
|
2076
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2077
|
-
* list of conditions and the following disclaimer.
|
|
2078
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2079
|
-
* this list of conditions and the following disclaimer in the
|
|
2080
|
-
* documentation and/or other materials provided with the distribution.
|
|
2081
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2082
|
-
* may be used to endorse or promote products derived from this software without
|
|
2083
|
-
* specific prior written permission.
|
|
2084
|
-
*
|
|
2085
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2086
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2087
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2088
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2089
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2090
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2091
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2092
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2093
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2094
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2095
|
-
*)
|
|
2096
|
-
|
|
2097
|
-
smol-toml/dist/extract.js:
|
|
2098
|
-
(*!
|
|
2099
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2100
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2101
|
-
*
|
|
2102
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2103
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2104
|
-
*
|
|
2105
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2106
|
-
* list of conditions and the following disclaimer.
|
|
2107
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2108
|
-
* this list of conditions and the following disclaimer in the
|
|
2109
|
-
* documentation and/or other materials provided with the distribution.
|
|
2110
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2111
|
-
* may be used to endorse or promote products derived from this software without
|
|
2112
|
-
* specific prior written permission.
|
|
2113
|
-
*
|
|
2114
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2115
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2116
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2117
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2118
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2119
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2120
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2121
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2122
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2123
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2124
|
-
*)
|
|
2125
|
-
|
|
2126
|
-
smol-toml/dist/struct.js:
|
|
2127
|
-
(*!
|
|
2128
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2129
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2130
|
-
*
|
|
2131
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2132
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2133
|
-
*
|
|
2134
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2135
|
-
* list of conditions and the following disclaimer.
|
|
2136
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2137
|
-
* this list of conditions and the following disclaimer in the
|
|
2138
|
-
* documentation and/or other materials provided with the distribution.
|
|
2139
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2140
|
-
* may be used to endorse or promote products derived from this software without
|
|
2141
|
-
* specific prior written permission.
|
|
2142
|
-
*
|
|
2143
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2144
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2145
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2146
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2147
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2148
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2149
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2150
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2151
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2152
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2153
|
-
*)
|
|
2154
|
-
|
|
2155
|
-
smol-toml/dist/parse.js:
|
|
2156
|
-
(*!
|
|
2157
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2158
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2159
|
-
*
|
|
2160
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2161
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2162
|
-
*
|
|
2163
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2164
|
-
* list of conditions and the following disclaimer.
|
|
2165
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2166
|
-
* this list of conditions and the following disclaimer in the
|
|
2167
|
-
* documentation and/or other materials provided with the distribution.
|
|
2168
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2169
|
-
* may be used to endorse or promote products derived from this software without
|
|
2170
|
-
* specific prior written permission.
|
|
2171
|
-
*
|
|
2172
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2173
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2174
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2175
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2176
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2177
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2178
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2179
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2180
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2181
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2182
|
-
*)
|
|
2183
|
-
|
|
2184
|
-
smol-toml/dist/stringify.js:
|
|
2185
|
-
(*!
|
|
2186
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2187
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2188
|
-
*
|
|
2189
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2190
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2191
|
-
*
|
|
2192
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2193
|
-
* list of conditions and the following disclaimer.
|
|
2194
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2195
|
-
* this list of conditions and the following disclaimer in the
|
|
2196
|
-
* documentation and/or other materials provided with the distribution.
|
|
2197
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2198
|
-
* may be used to endorse or promote products derived from this software without
|
|
2199
|
-
* specific prior written permission.
|
|
2200
|
-
*
|
|
2201
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2202
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2203
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2204
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2205
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2206
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2207
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2208
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2209
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2210
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2211
|
-
*)
|
|
2212
|
-
|
|
2213
|
-
smol-toml/dist/index.js:
|
|
2214
|
-
(*!
|
|
2215
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2216
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2217
|
-
*
|
|
2218
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2219
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2220
|
-
*
|
|
2221
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2222
|
-
* list of conditions and the following disclaimer.
|
|
2223
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2224
|
-
* this list of conditions and the following disclaimer in the
|
|
2225
|
-
* documentation and/or other materials provided with the distribution.
|
|
2226
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2227
|
-
* may be used to endorse or promote products derived from this software without
|
|
2228
|
-
* specific prior written permission.
|
|
2229
|
-
*
|
|
2230
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2231
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2232
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2233
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2234
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2235
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2236
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2237
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2238
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2239
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2240
|
-
*)
|
|
2241
|
-
*/
|
|
2242
1423
|
|
|
2243
|
-
export {
|
|
1424
|
+
export { PKCE_CHARSET, TEMPORARY_TERMS_NOTICE, TEMPORARY_TERMS_PROMPT, clearAccessCaches, createOAuthFlow, domainUsesAccess, generateAuthUrl, generateRandomState, getAccessHeaders, getAuthFromEnv, getAuthUrlFromEnv, getCloudflareAPITokenFromEnv, getCloudflareGlobalAuthEmailFromEnv, getCloudflareGlobalAuthKeyFromEnv, readStoredAuthState };
|