@cloudflare/workers-auth 0.1.0 → 0.2.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/{chunk-PAWJFY3S.mjs → chunk-O6YSETKJ.mjs} +0 -2
- package/dist/index.d.mts +170 -42
- package/dist/index.mjs +305 -1288
- package/dist/metafile-esm.json +1 -1
- package/dist/test-helpers/index.mjs +1 -3
- package/package.json +2 -2
- package/dist/chunk-PAWJFY3S.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/test-helpers/index.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { __name } from './chunk-
|
|
2
|
-
import {
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { getEnvironmentVariableFactory, getCloudflareApiEnvironmentFromEnv, UserError, getGlobalWranglerConfigPath, parseTOML, readFileSync, getCloudflareComplianceRegion } from '@cloudflare/workers-utils';
|
|
1
|
+
import { __name } from './chunk-O6YSETKJ.mjs';
|
|
2
|
+
import { getEnvironmentVariableFactory, getCloudflareApiEnvironmentFromEnv, UserError, 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';
|
|
@@ -10,909 +8,101 @@ import url from 'node:url';
|
|
|
10
8
|
import { webcrypto } 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
70
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
71
|
+
const apiToken = getCloudflareAPITokenFromEnv();
|
|
72
|
+
if (apiToken) {
|
|
73
|
+
return { apiToken };
|
|
443
74
|
}
|
|
444
|
-
return
|
|
445
|
-
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
446
|
-
endPtr
|
|
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
|
-
});
|
|
462
|
-
}
|
|
463
|
-
do {
|
|
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];
|
|
103
|
+
return credentials;
|
|
669
104
|
}
|
|
670
|
-
__name(
|
|
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 + " ]";
|
|
826
|
-
}
|
|
827
|
-
__name(stringifyArray, "stringifyArray");
|
|
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
|
-
});
|
|
906
|
-
}
|
|
907
|
-
__name(writeAuthConfigFile, "writeAuthConfigFile");
|
|
908
|
-
function readAuthConfigFile() {
|
|
909
|
-
return parseTOML(readFileSync(getAuthConfigFilePath()));
|
|
910
|
-
}
|
|
911
|
-
__name(readAuthConfigFile, "readAuthConfigFile");
|
|
912
|
-
var getClientIdFromEnv = getEnvironmentVariableFactory({
|
|
913
|
-
variableName: "WRANGLER_CLIENT_ID",
|
|
914
|
-
defaultValue: /* @__PURE__ */ __name(() => getCloudflareApiEnvironmentFromEnv() === "staging" ? "4b2ea6cc-9421-4761-874b-ce550e0e3def" : "54d11594-84e4-41aa-b438-e81b8fa78ee7", "defaultValue")
|
|
915
|
-
});
|
|
105
|
+
__name(requireApiToken, "requireApiToken");
|
|
916
106
|
var getAuthDomainFromEnv = getEnvironmentVariableFactory({
|
|
917
107
|
variableName: "WRANGLER_AUTH_DOMAIN",
|
|
918
108
|
defaultValue: /* @__PURE__ */ __name(() => getCloudflareApiEnvironmentFromEnv() === "staging" ? "dash.staging.cloudflare.com" : "dash.cloudflare.com", "defaultValue")
|
|
@@ -1052,11 +242,17 @@ var ErrorOAuth2 = class extends UserError {
|
|
|
1052
242
|
static {
|
|
1053
243
|
__name(this, "ErrorOAuth2");
|
|
1054
244
|
}
|
|
245
|
+
/** The OAuth `error` code returned by the provider (e.g. `invalid_scope`). */
|
|
246
|
+
code;
|
|
247
|
+
/** The OAuth `error_description` returned by the provider, if any. */
|
|
248
|
+
description;
|
|
249
|
+
/** The OAuth `error_uri` returned by the provider, if any. */
|
|
250
|
+
uri;
|
|
1055
251
|
toString() {
|
|
1056
252
|
return "ErrorOAuth2";
|
|
1057
253
|
}
|
|
1058
254
|
};
|
|
1059
|
-
var ErrorUnknown = class extends
|
|
255
|
+
var ErrorUnknown = class extends ErrorOAuth2 {
|
|
1060
256
|
static {
|
|
1061
257
|
__name(this, "ErrorUnknown");
|
|
1062
258
|
}
|
|
@@ -1192,61 +388,93 @@ var ErrorUnsupportedGrantType = class extends ErrorAccessTokenResponse {
|
|
|
1192
388
|
return "ErrorUnsupportedGrantType";
|
|
1193
389
|
}
|
|
1194
390
|
};
|
|
1195
|
-
function
|
|
391
|
+
function formatOAuthErrorMessage(code, description, uri) {
|
|
392
|
+
let message = `OAuth error: ${code}`;
|
|
393
|
+
if (description) {
|
|
394
|
+
message += `
|
|
395
|
+
${description}`;
|
|
396
|
+
}
|
|
397
|
+
if (uri) {
|
|
398
|
+
message += `
|
|
399
|
+
See: ${uri}`;
|
|
400
|
+
}
|
|
401
|
+
return message;
|
|
402
|
+
}
|
|
403
|
+
__name(formatOAuthErrorMessage, "formatOAuthErrorMessage");
|
|
404
|
+
function toErrorClass(rawError, description, uri) {
|
|
405
|
+
const message = formatOAuthErrorMessage(rawError, description, uri);
|
|
406
|
+
let error;
|
|
1196
407
|
switch (rawError) {
|
|
1197
408
|
case "invalid_request":
|
|
1198
|
-
|
|
409
|
+
error = new ErrorInvalidRequest(message, {
|
|
1199
410
|
telemetryMessage: "user oauth invalid request"
|
|
1200
411
|
});
|
|
412
|
+
break;
|
|
1201
413
|
case "invalid_grant":
|
|
1202
|
-
|
|
414
|
+
error = new ErrorInvalidGrant(message, {
|
|
1203
415
|
telemetryMessage: "user oauth invalid grant"
|
|
1204
416
|
});
|
|
417
|
+
break;
|
|
1205
418
|
case "unauthorized_client":
|
|
1206
|
-
|
|
419
|
+
error = new ErrorUnauthorizedClient(message, {
|
|
1207
420
|
telemetryMessage: "user oauth unauthorized client"
|
|
1208
421
|
});
|
|
422
|
+
break;
|
|
1209
423
|
case "access_denied":
|
|
1210
|
-
|
|
424
|
+
error = new ErrorAccessDenied(message, {
|
|
1211
425
|
telemetryMessage: "user oauth access denied"
|
|
1212
426
|
});
|
|
427
|
+
break;
|
|
1213
428
|
case "unsupported_response_type":
|
|
1214
|
-
|
|
429
|
+
error = new ErrorUnsupportedResponseType(message, {
|
|
1215
430
|
telemetryMessage: "user oauth unsupported response type"
|
|
1216
431
|
});
|
|
432
|
+
break;
|
|
1217
433
|
case "invalid_scope":
|
|
1218
|
-
|
|
434
|
+
error = new ErrorInvalidScope(message, {
|
|
1219
435
|
telemetryMessage: "user oauth invalid scope"
|
|
1220
436
|
});
|
|
437
|
+
break;
|
|
1221
438
|
case "server_error":
|
|
1222
|
-
|
|
439
|
+
error = new ErrorServerError(message, {
|
|
1223
440
|
telemetryMessage: "user oauth server error"
|
|
1224
441
|
});
|
|
442
|
+
break;
|
|
1225
443
|
case "temporarily_unavailable":
|
|
1226
|
-
|
|
444
|
+
error = new ErrorTemporarilyUnavailable(message, {
|
|
1227
445
|
telemetryMessage: "user oauth temporarily unavailable"
|
|
1228
446
|
});
|
|
447
|
+
break;
|
|
1229
448
|
case "invalid_client":
|
|
1230
|
-
|
|
449
|
+
error = new ErrorInvalidClient(message, {
|
|
1231
450
|
telemetryMessage: "user oauth invalid client"
|
|
1232
451
|
});
|
|
452
|
+
break;
|
|
1233
453
|
case "unsupported_grant_type":
|
|
1234
|
-
|
|
454
|
+
error = new ErrorUnsupportedGrantType(message, {
|
|
1235
455
|
telemetryMessage: "user oauth unsupported grant type"
|
|
1236
456
|
});
|
|
457
|
+
break;
|
|
1237
458
|
case "invalid_json":
|
|
1238
|
-
|
|
459
|
+
error = new ErrorInvalidJson(message, {
|
|
1239
460
|
telemetryMessage: "user oauth invalid json"
|
|
1240
461
|
});
|
|
462
|
+
break;
|
|
1241
463
|
case "invalid_token":
|
|
1242
|
-
|
|
464
|
+
error = new ErrorInvalidToken(message, {
|
|
1243
465
|
telemetryMessage: "user oauth invalid token"
|
|
1244
466
|
});
|
|
467
|
+
break;
|
|
1245
468
|
default:
|
|
1246
|
-
|
|
469
|
+
error = new ErrorUnknown(message, {
|
|
1247
470
|
telemetryMessage: "user oauth unknown error"
|
|
1248
471
|
});
|
|
472
|
+
break;
|
|
1249
473
|
}
|
|
474
|
+
error.code = rawError;
|
|
475
|
+
error.description = description;
|
|
476
|
+
error.uri = uri;
|
|
477
|
+
return error;
|
|
1250
478
|
}
|
|
1251
479
|
__name(toErrorClass, "toErrorClass");
|
|
1252
480
|
|
|
@@ -1291,18 +519,6 @@ function dedent(templ) {
|
|
|
1291
519
|
}
|
|
1292
520
|
__name(dedent, "dedent");
|
|
1293
521
|
var esm_default = dedent;
|
|
1294
|
-
|
|
1295
|
-
// src/generate-auth-url.ts
|
|
1296
|
-
var OAUTH_CALLBACK_URL = "http://localhost:8976/oauth/callback";
|
|
1297
|
-
var generateAuthUrl = /* @__PURE__ */ __name(({
|
|
1298
|
-
authUrl,
|
|
1299
|
-
clientId,
|
|
1300
|
-
scopes,
|
|
1301
|
-
stateQueryParam,
|
|
1302
|
-
codeChallenge
|
|
1303
|
-
}) => {
|
|
1304
|
-
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`;
|
|
1305
|
-
}, "generateAuthUrl");
|
|
1306
522
|
var RECOMMENDED_CODE_VERIFIER_LENGTH = 96;
|
|
1307
523
|
var RECOMMENDED_STATE_LENGTH = 32;
|
|
1308
524
|
var PKCE_CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
|
|
@@ -1335,51 +551,13 @@ async function generatePKCECodes() {
|
|
|
1335
551
|
}
|
|
1336
552
|
__name(generatePKCECodes, "generatePKCECodes");
|
|
1337
553
|
|
|
1338
|
-
// src/state.ts
|
|
1339
|
-
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
1340
|
-
function readStoredAuthState(options) {
|
|
1341
|
-
const { configOverride, warningLogger } = options ?? {};
|
|
1342
|
-
let parsed;
|
|
1343
|
-
try {
|
|
1344
|
-
parsed = configOverride ?? readAuthConfigFile();
|
|
1345
|
-
} catch {
|
|
1346
|
-
return {};
|
|
1347
|
-
}
|
|
1348
|
-
const { oauth_token, refresh_token, expiration_time, scopes, api_token } = parsed;
|
|
1349
|
-
if (oauth_token) {
|
|
1350
|
-
return {
|
|
1351
|
-
accessToken: {
|
|
1352
|
-
value: oauth_token,
|
|
1353
|
-
// If there is no `expiration_time` field then set it to an old date, to cause it to expire immediately.
|
|
1354
|
-
expiry: expiration_time ?? "2000-01-01:00:00:00+00:00"
|
|
1355
|
-
},
|
|
1356
|
-
refreshToken: { value: refresh_token ?? "" },
|
|
1357
|
-
scopes
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
if (api_token) {
|
|
1361
|
-
if (!hasWarnedAboutDeprecatedV1ApiToken && warningLogger) {
|
|
1362
|
-
hasWarnedAboutDeprecatedV1ApiToken = true;
|
|
1363
|
-
warningLogger.warn(
|
|
1364
|
-
`It looks like you have used Wrangler v1's \`config\` command to login with an API token
|
|
1365
|
-
from ${configOverride === void 0 ? getAuthConfigFilePath() : "in-memory config"}.
|
|
1366
|
-
This is no longer supported in the current version of Wrangler.
|
|
1367
|
-
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\` environment variable.`
|
|
1368
|
-
);
|
|
1369
|
-
}
|
|
1370
|
-
return { deprecatedApiToken: api_token };
|
|
1371
|
-
}
|
|
1372
|
-
return {};
|
|
1373
|
-
}
|
|
1374
|
-
__name(readStoredAuthState, "readStoredAuthState");
|
|
1375
|
-
|
|
1376
554
|
// src/token-exchange.ts
|
|
1377
555
|
function isReturningFromAuthServer(query, state, logger) {
|
|
1378
556
|
if (query.error) {
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
throw toErrorClass(
|
|
557
|
+
const error = Array.isArray(query.error) ? query.error[0] : query.error;
|
|
558
|
+
const description = Array.isArray(query.error_description) ? query.error_description[0] : query.error_description;
|
|
559
|
+
const uri = Array.isArray(query.error_uri) ? query.error_uri[0] : query.error_uri;
|
|
560
|
+
throw toErrorClass(error, description, uri);
|
|
1383
561
|
}
|
|
1384
562
|
const code = query.code;
|
|
1385
563
|
if (!code) {
|
|
@@ -1400,7 +578,7 @@ function isReturningFromAuthServer(query, state, logger) {
|
|
|
1400
578
|
return true;
|
|
1401
579
|
}
|
|
1402
580
|
__name(isReturningFromAuthServer, "isReturningFromAuthServer");
|
|
1403
|
-
async function getAuthURL(scopes, clientId, state, generators) {
|
|
581
|
+
async function getAuthURL(scopes, clientId, redirectUri, state, generators) {
|
|
1404
582
|
const { codeChallenge, codeVerifier } = await generatePKCECodes();
|
|
1405
583
|
const stateQueryParam = generators.generateRandomState(
|
|
1406
584
|
RECOMMENDED_STATE_LENGTH
|
|
@@ -1415,13 +593,15 @@ async function getAuthURL(scopes, clientId, state, generators) {
|
|
|
1415
593
|
clientId,
|
|
1416
594
|
scopes,
|
|
1417
595
|
stateQueryParam,
|
|
1418
|
-
codeChallenge
|
|
596
|
+
codeChallenge,
|
|
597
|
+
redirectUri
|
|
1419
598
|
});
|
|
1420
599
|
}
|
|
1421
600
|
__name(getAuthURL, "getAuthURL");
|
|
1422
|
-
async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI) {
|
|
601
|
+
async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI, clientId, storage) {
|
|
1423
602
|
const storedRefreshToken = readStoredAuthState({
|
|
1424
|
-
warningLogger: logger
|
|
603
|
+
warningLogger: logger,
|
|
604
|
+
storage
|
|
1425
605
|
}).refreshToken;
|
|
1426
606
|
if (!storedRefreshToken) {
|
|
1427
607
|
logger.warn("No refresh token is present.");
|
|
@@ -1429,7 +609,7 @@ async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI)
|
|
|
1429
609
|
const params = new URLSearchParams({
|
|
1430
610
|
grant_type: "refresh_token",
|
|
1431
611
|
refresh_token: storedRefreshToken?.value ?? "",
|
|
1432
|
-
client_id:
|
|
612
|
+
client_id: clientId
|
|
1433
613
|
});
|
|
1434
614
|
const response = await fetchAuthToken(params, logger, isNonInteractiveOrCI);
|
|
1435
615
|
if (response.status >= 400) {
|
|
@@ -1478,7 +658,7 @@ async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI)
|
|
|
1478
658
|
}
|
|
1479
659
|
}
|
|
1480
660
|
__name(exchangeRefreshTokenForAccessToken, "exchangeRefreshTokenForAccessToken");
|
|
1481
|
-
async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrCI) {
|
|
661
|
+
async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrCI, clientId, redirectUri) {
|
|
1482
662
|
const { authorizationCode, codeVerifier = "" } = state;
|
|
1483
663
|
if (!codeVerifier) {
|
|
1484
664
|
logger.warn("No code verifier is being sent.");
|
|
@@ -1488,8 +668,8 @@ async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrC
|
|
|
1488
668
|
const params = new URLSearchParams({
|
|
1489
669
|
grant_type: `authorization_code`,
|
|
1490
670
|
code: authorizationCode ?? "",
|
|
1491
|
-
redirect_uri:
|
|
1492
|
-
client_id:
|
|
671
|
+
redirect_uri: redirectUri,
|
|
672
|
+
client_id: clientId,
|
|
1493
673
|
code_verifier: codeVerifier
|
|
1494
674
|
});
|
|
1495
675
|
const response = await fetchAuthToken(params, logger, isNonInteractiveOrCI);
|
|
@@ -1502,7 +682,7 @@ async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrC
|
|
|
1502
682
|
}
|
|
1503
683
|
const json = await getJSONFromResponse(response, logger);
|
|
1504
684
|
if ("error" in json) {
|
|
1505
|
-
throw
|
|
685
|
+
throw toErrorClass(json.error);
|
|
1506
686
|
}
|
|
1507
687
|
const { access_token, expires_in, refresh_token, scope } = json;
|
|
1508
688
|
state.hasAuthCodeBeenExchangedForAccessToken = true;
|
|
@@ -1546,7 +726,7 @@ async function fetchAuthToken(body, logger, isNonInteractiveOrCI) {
|
|
|
1546
726
|
headers
|
|
1547
727
|
});
|
|
1548
728
|
if (!response.ok) {
|
|
1549
|
-
logger.
|
|
729
|
+
logger.debug(
|
|
1550
730
|
"Failed to fetch auth token:",
|
|
1551
731
|
response.status,
|
|
1552
732
|
response.statusText
|
|
@@ -1554,7 +734,7 @@ async function fetchAuthToken(body, logger, isNonInteractiveOrCI) {
|
|
|
1554
734
|
}
|
|
1555
735
|
return response;
|
|
1556
736
|
} catch (e) {
|
|
1557
|
-
logger.
|
|
737
|
+
logger.debug("Failed to fetch auth token:", e);
|
|
1558
738
|
throw e;
|
|
1559
739
|
}
|
|
1560
740
|
}
|
|
@@ -1570,7 +750,9 @@ async function getJSONFromResponse(response, logger) {
|
|
|
1570
750
|
);
|
|
1571
751
|
if (text.match(/challenge-platform/)) {
|
|
1572
752
|
logger.error(
|
|
1573
|
-
`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
|
+
)}`
|
|
1574
756
|
);
|
|
1575
757
|
}
|
|
1576
758
|
}
|
|
@@ -1588,9 +770,11 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1588
770
|
const urlToOpen = await getAuthURL(
|
|
1589
771
|
options.scopes,
|
|
1590
772
|
options.clientId,
|
|
773
|
+
options.redirectUri,
|
|
1591
774
|
state,
|
|
1592
775
|
generators
|
|
1593
776
|
);
|
|
777
|
+
const callbackPath = new URL(options.redirectUri).pathname;
|
|
1594
778
|
let server;
|
|
1595
779
|
let loginTimeoutHandle;
|
|
1596
780
|
const timerPromise = new Promise((_, reject) => {
|
|
@@ -1609,6 +793,9 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1609
793
|
server = http.createServer(async (req, res) => {
|
|
1610
794
|
function finish(token, error) {
|
|
1611
795
|
clearTimeout(loginTimeoutHandle);
|
|
796
|
+
if (!res.writableEnded) {
|
|
797
|
+
res.end();
|
|
798
|
+
}
|
|
1612
799
|
server.close((closeErr) => {
|
|
1613
800
|
if (error || closeErr) {
|
|
1614
801
|
reject(error || closeErr);
|
|
@@ -1619,13 +806,50 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1619
806
|
});
|
|
1620
807
|
}
|
|
1621
808
|
__name(finish, "finish");
|
|
809
|
+
function renderErrorPage(detail) {
|
|
810
|
+
const escape = /* @__PURE__ */ __name((s) => s.replace(
|
|
811
|
+
/[&<>"']/g,
|
|
812
|
+
(c) => ({
|
|
813
|
+
"&": "&",
|
|
814
|
+
"<": "<",
|
|
815
|
+
">": ">",
|
|
816
|
+
'"': """,
|
|
817
|
+
"'": "'"
|
|
818
|
+
})[c]
|
|
819
|
+
), "escape");
|
|
820
|
+
const codeRow = detail.code ? `<p>Code: <code>${escape(detail.code)}</code></p>` : "";
|
|
821
|
+
const descriptionRow = detail.description ? `<p class="detail">${escape(detail.description)}</p>` : "";
|
|
822
|
+
const body = `<!doctype html>
|
|
823
|
+
<html lang="en">
|
|
824
|
+
<head>
|
|
825
|
+
<meta charset="utf-8" />
|
|
826
|
+
<title>Wrangler login failed</title>
|
|
827
|
+
<style>
|
|
828
|
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; max-width: 720px; margin: 4rem auto; padding: 0 1rem; color: #1f2933; line-height: 1.5; }
|
|
829
|
+
h1 { color: #c12d3f; }
|
|
830
|
+
code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
|
|
831
|
+
p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
|
|
832
|
+
</style>
|
|
833
|
+
</head>
|
|
834
|
+
<body>
|
|
835
|
+
<h1>Wrangler login failed</h1>
|
|
836
|
+
<p>The Cloudflare OAuth provider returned an error.</p>
|
|
837
|
+
${codeRow}
|
|
838
|
+
${descriptionRow}
|
|
839
|
+
<p>You can close this tab and return to your terminal for more details.</p>
|
|
840
|
+
</body>
|
|
841
|
+
</html>`;
|
|
842
|
+
res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
|
|
843
|
+
res.end(body);
|
|
844
|
+
}
|
|
845
|
+
__name(renderErrorPage, "renderErrorPage");
|
|
1622
846
|
assert2(req.url, "This request doesn't have a URL");
|
|
1623
847
|
const { pathname, query } = url.parse(req.url, true);
|
|
1624
848
|
if (req.method !== "GET") {
|
|
1625
849
|
return res.end("OK");
|
|
1626
850
|
}
|
|
1627
851
|
switch (pathname) {
|
|
1628
|
-
case
|
|
852
|
+
case callbackPath: {
|
|
1629
853
|
let hasAuthCode = false;
|
|
1630
854
|
try {
|
|
1631
855
|
hasAuthCode = isReturningFromAuthServer(query, state, ctx.logger);
|
|
@@ -1643,46 +867,64 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1643
867
|
);
|
|
1644
868
|
});
|
|
1645
869
|
return;
|
|
1646
|
-
} else {
|
|
1647
|
-
finish(null, err);
|
|
1648
|
-
return;
|
|
1649
870
|
}
|
|
871
|
+
const oauthErr = err;
|
|
872
|
+
renderErrorPage({
|
|
873
|
+
code: oauthErr.code,
|
|
874
|
+
description: oauthErr.description ?? oauthErr.message
|
|
875
|
+
});
|
|
876
|
+
finish(null, oauthErr);
|
|
877
|
+
return;
|
|
1650
878
|
}
|
|
1651
879
|
if (!hasAuthCode) {
|
|
880
|
+
const noCodeMessage = "The Cloudflare OAuth provider did not return an authorisation code.";
|
|
881
|
+
renderErrorPage({ description: noCodeMessage });
|
|
1652
882
|
finish(
|
|
1653
883
|
null,
|
|
1654
|
-
new ErrorNoAuthCode(
|
|
884
|
+
new ErrorNoAuthCode(noCodeMessage, {
|
|
1655
885
|
telemetryMessage: "user oauth missing auth code"
|
|
1656
886
|
})
|
|
1657
887
|
);
|
|
1658
888
|
return;
|
|
1659
|
-
} else {
|
|
1660
|
-
try {
|
|
1661
|
-
const exchange = await exchangeAuthCodeForAccessToken(
|
|
1662
|
-
state,
|
|
1663
|
-
ctx.logger,
|
|
1664
|
-
ctx.isNonInteractiveOrCI
|
|
1665
|
-
);
|
|
1666
|
-
res.writeHead(307, {
|
|
1667
|
-
Location: options.granted.url
|
|
1668
|
-
});
|
|
1669
|
-
res.end(() => {
|
|
1670
|
-
finish(exchange);
|
|
1671
|
-
});
|
|
1672
|
-
} catch (err) {
|
|
1673
|
-
finish(null, err);
|
|
1674
|
-
}
|
|
1675
|
-
return;
|
|
1676
889
|
}
|
|
890
|
+
try {
|
|
891
|
+
const exchange = await exchangeAuthCodeForAccessToken(
|
|
892
|
+
state,
|
|
893
|
+
ctx.logger,
|
|
894
|
+
ctx.isNonInteractiveOrCI,
|
|
895
|
+
options.clientId,
|
|
896
|
+
options.redirectUri
|
|
897
|
+
);
|
|
898
|
+
res.writeHead(307, {
|
|
899
|
+
Location: options.granted.url
|
|
900
|
+
});
|
|
901
|
+
res.end(() => {
|
|
902
|
+
finish(exchange);
|
|
903
|
+
});
|
|
904
|
+
} catch (err) {
|
|
905
|
+
const exchangeErr = err;
|
|
906
|
+
const isOAuthError = exchangeErr instanceof ErrorOAuth2;
|
|
907
|
+
renderErrorPage({
|
|
908
|
+
code: isOAuthError ? exchangeErr.code : void 0,
|
|
909
|
+
description: (isOAuthError ? exchangeErr.description : void 0) ?? exchangeErr.message ?? "Failed to exchange the authorisation code for an access token."
|
|
910
|
+
});
|
|
911
|
+
finish(null, exchangeErr);
|
|
912
|
+
}
|
|
913
|
+
return;
|
|
1677
914
|
}
|
|
1678
915
|
}
|
|
1679
916
|
});
|
|
1680
|
-
|
|
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) {
|
|
1681
922
|
ctx.logger.log(
|
|
1682
923
|
`Temporary login server listening on ${options.callbackHost}:${options.callbackPort}`
|
|
1683
924
|
);
|
|
1684
925
|
ctx.logger.log(
|
|
1685
|
-
|
|
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.`
|
|
1686
928
|
);
|
|
1687
929
|
}
|
|
1688
930
|
server.once("error", (err) => {
|
|
@@ -1709,6 +951,18 @@ async function getOauthToken(options, state, ctx, generators) {
|
|
|
1709
951
|
return Promise.race([timerPromise, loginPromise]);
|
|
1710
952
|
}
|
|
1711
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");
|
|
1712
966
|
function generateRandomState(lengthOfState) {
|
|
1713
967
|
const output = new Uint32Array(lengthOfState);
|
|
1714
968
|
webcrypto.getRandomValues(output);
|
|
@@ -1723,6 +977,12 @@ function createOAuthFlow(ctx) {
|
|
|
1723
977
|
generateAuthUrl: ctx.generateAuthUrl ?? generateAuthUrl,
|
|
1724
978
|
generateRandomState: ctx.generateRandomState ?? generateRandomState
|
|
1725
979
|
};
|
|
980
|
+
const storage = ctx.storage;
|
|
981
|
+
const getClientId = /* @__PURE__ */ __name(() => typeof ctx.clientId === "function" ? ctx.clientId() : ctx.clientId, "getClientId");
|
|
982
|
+
const consent = ctx.consent;
|
|
983
|
+
const redirectUrl = new URL(ctx.redirectUri);
|
|
984
|
+
const defaultCallbackHost = redirectUrl.hostname;
|
|
985
|
+
const defaultCallbackPort = Number(redirectUrl.port);
|
|
1726
986
|
async function login(props) {
|
|
1727
987
|
if (ctx.hasEnvCredentials()) {
|
|
1728
988
|
ctx.logger.error(
|
|
@@ -1750,22 +1010,18 @@ function createOAuthFlow(ctx) {
|
|
|
1750
1010
|
{
|
|
1751
1011
|
browser: props.browser ?? true,
|
|
1752
1012
|
scopes: props.scopes,
|
|
1753
|
-
clientId:
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
url: "https://welcome.developers.workers.dev/wrangler-oauth-consent-granted"
|
|
1760
|
-
},
|
|
1761
|
-
callbackHost: props.callbackHost ?? "localhost",
|
|
1762
|
-
callbackPort: props.callbackPort ?? 8976
|
|
1013
|
+
clientId: getClientId(),
|
|
1014
|
+
redirectUri: ctx.redirectUri,
|
|
1015
|
+
denied: consent.denied,
|
|
1016
|
+
granted: consent.granted,
|
|
1017
|
+
callbackHost: props.callbackHost ?? defaultCallbackHost,
|
|
1018
|
+
callbackPort: props.callbackPort ?? defaultCallbackPort
|
|
1763
1019
|
},
|
|
1764
1020
|
oauthFlowState,
|
|
1765
1021
|
ctx,
|
|
1766
1022
|
generators
|
|
1767
1023
|
);
|
|
1768
|
-
|
|
1024
|
+
storage.write({
|
|
1769
1025
|
oauth_token: oauth.token?.value ?? "",
|
|
1770
1026
|
expiration_time: oauth.token?.expiry,
|
|
1771
1027
|
refresh_token: oauth.refreshToken?.value,
|
|
@@ -1780,7 +1036,10 @@ function createOAuthFlow(ctx) {
|
|
|
1780
1036
|
if (ctx.hasEnvCredentials()) {
|
|
1781
1037
|
return false;
|
|
1782
1038
|
}
|
|
1783
|
-
const { accessToken } = readStoredAuthState({
|
|
1039
|
+
const { accessToken } = readStoredAuthState({
|
|
1040
|
+
warningLogger: ctx.logger,
|
|
1041
|
+
storage
|
|
1042
|
+
});
|
|
1784
1043
|
return Boolean(accessToken && /* @__PURE__ */ new Date() >= new Date(accessToken.expiry));
|
|
1785
1044
|
}
|
|
1786
1045
|
__name(isRefreshNeeded, "isRefreshNeeded");
|
|
@@ -1795,9 +1054,11 @@ function createOAuthFlow(ctx) {
|
|
|
1795
1054
|
scopes
|
|
1796
1055
|
} = await exchangeRefreshTokenForAccessToken(
|
|
1797
1056
|
ctx.logger,
|
|
1798
|
-
ctx.isNonInteractiveOrCI
|
|
1057
|
+
ctx.isNonInteractiveOrCI,
|
|
1058
|
+
getClientId(),
|
|
1059
|
+
storage
|
|
1799
1060
|
);
|
|
1800
|
-
|
|
1061
|
+
storage.write({
|
|
1801
1062
|
oauth_token,
|
|
1802
1063
|
expiration_time,
|
|
1803
1064
|
refresh_token,
|
|
@@ -1814,20 +1075,40 @@ function createOAuthFlow(ctx) {
|
|
|
1814
1075
|
__name(refreshToken, "refreshToken");
|
|
1815
1076
|
async function loginOrRefreshIfRequired(props) {
|
|
1816
1077
|
if (ctx.hasEnvCredentials()) {
|
|
1817
|
-
return true;
|
|
1078
|
+
return { loggedIn: true };
|
|
1818
1079
|
}
|
|
1819
|
-
const stored = readStoredAuthState({
|
|
1080
|
+
const stored = readStoredAuthState({
|
|
1081
|
+
warningLogger: ctx.logger,
|
|
1082
|
+
storage
|
|
1083
|
+
});
|
|
1820
1084
|
if (!stored.accessToken && !stored.deprecatedApiToken) {
|
|
1821
|
-
|
|
1085
|
+
if (ctx.isNonInteractiveOrCI()) {
|
|
1086
|
+
return {
|
|
1087
|
+
loggedIn: false,
|
|
1088
|
+
reason: "no-credentials-non-interactive"
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
if (await login(props)) {
|
|
1092
|
+
return { loggedIn: true };
|
|
1093
|
+
}
|
|
1094
|
+
return { loggedIn: false, reason: "no-credentials-login-failed" };
|
|
1822
1095
|
} else if (isRefreshNeeded()) {
|
|
1823
1096
|
const didRefresh = await refreshToken();
|
|
1824
1097
|
if (didRefresh) {
|
|
1825
|
-
return true;
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1098
|
+
return { loggedIn: true };
|
|
1099
|
+
}
|
|
1100
|
+
if (ctx.isNonInteractiveOrCI()) {
|
|
1101
|
+
return {
|
|
1102
|
+
loggedIn: false,
|
|
1103
|
+
reason: "token-expired-non-interactive"
|
|
1104
|
+
};
|
|
1828
1105
|
}
|
|
1106
|
+
if (await login(props)) {
|
|
1107
|
+
return { loggedIn: true };
|
|
1108
|
+
}
|
|
1109
|
+
return { loggedIn: false, reason: "token-expired-login-failed" };
|
|
1829
1110
|
} else {
|
|
1830
|
-
return true;
|
|
1111
|
+
return { loggedIn: true };
|
|
1831
1112
|
}
|
|
1832
1113
|
}
|
|
1833
1114
|
__name(loginOrRefreshIfRequired, "loginOrRefreshIfRequired");
|
|
@@ -1839,13 +1120,14 @@ function createOAuthFlow(ctx) {
|
|
|
1839
1120
|
return;
|
|
1840
1121
|
}
|
|
1841
1122
|
const storedRefreshToken = readStoredAuthState({
|
|
1842
|
-
warningLogger: ctx.logger
|
|
1123
|
+
warningLogger: ctx.logger,
|
|
1124
|
+
storage
|
|
1843
1125
|
}).refreshToken;
|
|
1844
1126
|
if (!storedRefreshToken) {
|
|
1845
1127
|
ctx.logger.log("Not logged in, exiting...");
|
|
1846
1128
|
return;
|
|
1847
1129
|
}
|
|
1848
|
-
const body = `client_id=${encodeURIComponent(
|
|
1130
|
+
const body = `client_id=${encodeURIComponent(getClientId())}&token_type_hint=refresh_token&token=${encodeURIComponent(storedRefreshToken.value || "")}`;
|
|
1849
1131
|
const response = await fetch(getRevokeUrlFromEnv(), {
|
|
1850
1132
|
method: "POST",
|
|
1851
1133
|
body,
|
|
@@ -1854,13 +1136,13 @@ function createOAuthFlow(ctx) {
|
|
|
1854
1136
|
}
|
|
1855
1137
|
});
|
|
1856
1138
|
await response.text();
|
|
1857
|
-
|
|
1139
|
+
storage.clear();
|
|
1858
1140
|
ctx.logger.log(`Successfully logged out.`);
|
|
1859
1141
|
ctx.purgeOnLoginOrLogout?.();
|
|
1860
1142
|
}
|
|
1861
1143
|
__name(logout, "logout");
|
|
1862
1144
|
async function getOAuthTokenFromLocalState() {
|
|
1863
|
-
let stored = readStoredAuthState({ warningLogger: ctx.logger });
|
|
1145
|
+
let stored = readStoredAuthState({ warningLogger: ctx.logger, storage });
|
|
1864
1146
|
if (!stored.accessToken) {
|
|
1865
1147
|
return void 0;
|
|
1866
1148
|
}
|
|
@@ -1870,7 +1152,7 @@ function createOAuthFlow(ctx) {
|
|
|
1870
1152
|
if (!didRefresh) {
|
|
1871
1153
|
return void 0;
|
|
1872
1154
|
}
|
|
1873
|
-
stored = readStoredAuthState({ warningLogger: ctx.logger });
|
|
1155
|
+
stored = readStoredAuthState({ warningLogger: ctx.logger, storage });
|
|
1874
1156
|
}
|
|
1875
1157
|
return stored.accessToken?.value;
|
|
1876
1158
|
}
|
|
@@ -1885,270 +1167,5 @@ function createOAuthFlow(ctx) {
|
|
|
1885
1167
|
};
|
|
1886
1168
|
}
|
|
1887
1169
|
__name(createOAuthFlow, "createOAuthFlow");
|
|
1888
|
-
/*! Bundled license information:
|
|
1889
|
-
|
|
1890
|
-
smol-toml/dist/error.js:
|
|
1891
|
-
(*!
|
|
1892
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
1893
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1894
|
-
*
|
|
1895
|
-
* Redistribution and use in source and binary forms, with or without
|
|
1896
|
-
* modification, are permitted provided that the following conditions are met:
|
|
1897
|
-
*
|
|
1898
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
1899
|
-
* list of conditions and the following disclaimer.
|
|
1900
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
1901
|
-
* this list of conditions and the following disclaimer in the
|
|
1902
|
-
* documentation and/or other materials provided with the distribution.
|
|
1903
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
1904
|
-
* may be used to endorse or promote products derived from this software without
|
|
1905
|
-
* specific prior written permission.
|
|
1906
|
-
*
|
|
1907
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
1908
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
1909
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
1910
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
1911
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
1912
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
1913
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
1914
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
1915
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
1916
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1917
|
-
*)
|
|
1918
|
-
|
|
1919
|
-
smol-toml/dist/util.js:
|
|
1920
|
-
(*!
|
|
1921
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
1922
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1923
|
-
*
|
|
1924
|
-
* Redistribution and use in source and binary forms, with or without
|
|
1925
|
-
* modification, are permitted provided that the following conditions are met:
|
|
1926
|
-
*
|
|
1927
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
1928
|
-
* list of conditions and the following disclaimer.
|
|
1929
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
1930
|
-
* this list of conditions and the following disclaimer in the
|
|
1931
|
-
* documentation and/or other materials provided with the distribution.
|
|
1932
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
1933
|
-
* may be used to endorse or promote products derived from this software without
|
|
1934
|
-
* specific prior written permission.
|
|
1935
|
-
*
|
|
1936
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
1937
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
1938
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
1939
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
1940
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
1941
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
1942
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
1943
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
1944
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
1945
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1946
|
-
*)
|
|
1947
|
-
|
|
1948
|
-
smol-toml/dist/date.js:
|
|
1949
|
-
(*!
|
|
1950
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
1951
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1952
|
-
*
|
|
1953
|
-
* Redistribution and use in source and binary forms, with or without
|
|
1954
|
-
* modification, are permitted provided that the following conditions are met:
|
|
1955
|
-
*
|
|
1956
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
1957
|
-
* list of conditions and the following disclaimer.
|
|
1958
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
1959
|
-
* this list of conditions and the following disclaimer in the
|
|
1960
|
-
* documentation and/or other materials provided with the distribution.
|
|
1961
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
1962
|
-
* may be used to endorse or promote products derived from this software without
|
|
1963
|
-
* specific prior written permission.
|
|
1964
|
-
*
|
|
1965
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
1966
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
1967
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
1968
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
1969
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
1970
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
1971
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
1972
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
1973
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
1974
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1975
|
-
*)
|
|
1976
|
-
|
|
1977
|
-
smol-toml/dist/primitive.js:
|
|
1978
|
-
(*!
|
|
1979
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
1980
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1981
|
-
*
|
|
1982
|
-
* Redistribution and use in source and binary forms, with or without
|
|
1983
|
-
* modification, are permitted provided that the following conditions are met:
|
|
1984
|
-
*
|
|
1985
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
1986
|
-
* list of conditions and the following disclaimer.
|
|
1987
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
1988
|
-
* this list of conditions and the following disclaimer in the
|
|
1989
|
-
* documentation and/or other materials provided with the distribution.
|
|
1990
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
1991
|
-
* may be used to endorse or promote products derived from this software without
|
|
1992
|
-
* specific prior written permission.
|
|
1993
|
-
*
|
|
1994
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
1995
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
1996
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
1997
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
1998
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
1999
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2000
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2001
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2002
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2003
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2004
|
-
*)
|
|
2005
|
-
|
|
2006
|
-
smol-toml/dist/extract.js:
|
|
2007
|
-
(*!
|
|
2008
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2009
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2010
|
-
*
|
|
2011
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2012
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2013
|
-
*
|
|
2014
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2015
|
-
* list of conditions and the following disclaimer.
|
|
2016
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2017
|
-
* this list of conditions and the following disclaimer in the
|
|
2018
|
-
* documentation and/or other materials provided with the distribution.
|
|
2019
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2020
|
-
* may be used to endorse or promote products derived from this software without
|
|
2021
|
-
* specific prior written permission.
|
|
2022
|
-
*
|
|
2023
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2024
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2025
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2026
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2027
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2028
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2029
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2030
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2031
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2032
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2033
|
-
*)
|
|
2034
|
-
|
|
2035
|
-
smol-toml/dist/struct.js:
|
|
2036
|
-
(*!
|
|
2037
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2038
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2039
|
-
*
|
|
2040
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2041
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2042
|
-
*
|
|
2043
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2044
|
-
* list of conditions and the following disclaimer.
|
|
2045
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2046
|
-
* this list of conditions and the following disclaimer in the
|
|
2047
|
-
* documentation and/or other materials provided with the distribution.
|
|
2048
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2049
|
-
* may be used to endorse or promote products derived from this software without
|
|
2050
|
-
* specific prior written permission.
|
|
2051
|
-
*
|
|
2052
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2053
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2054
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2055
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2056
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2057
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2058
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2059
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2060
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2061
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2062
|
-
*)
|
|
2063
|
-
|
|
2064
|
-
smol-toml/dist/parse.js:
|
|
2065
|
-
(*!
|
|
2066
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2067
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2068
|
-
*
|
|
2069
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2070
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2071
|
-
*
|
|
2072
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2073
|
-
* list of conditions and the following disclaimer.
|
|
2074
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2075
|
-
* this list of conditions and the following disclaimer in the
|
|
2076
|
-
* documentation and/or other materials provided with the distribution.
|
|
2077
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2078
|
-
* may be used to endorse or promote products derived from this software without
|
|
2079
|
-
* specific prior written permission.
|
|
2080
|
-
*
|
|
2081
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2082
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2083
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2084
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2085
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2086
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2087
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2088
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2089
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2090
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2091
|
-
*)
|
|
2092
|
-
|
|
2093
|
-
smol-toml/dist/stringify.js:
|
|
2094
|
-
(*!
|
|
2095
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2096
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2097
|
-
*
|
|
2098
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2099
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2100
|
-
*
|
|
2101
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2102
|
-
* list of conditions and the following disclaimer.
|
|
2103
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2104
|
-
* this list of conditions and the following disclaimer in the
|
|
2105
|
-
* documentation and/or other materials provided with the distribution.
|
|
2106
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2107
|
-
* may be used to endorse or promote products derived from this software without
|
|
2108
|
-
* specific prior written permission.
|
|
2109
|
-
*
|
|
2110
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2111
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2112
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2113
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2114
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2115
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2116
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2117
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2118
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2119
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2120
|
-
*)
|
|
2121
|
-
|
|
2122
|
-
smol-toml/dist/index.js:
|
|
2123
|
-
(*!
|
|
2124
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
2125
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
2126
|
-
*
|
|
2127
|
-
* Redistribution and use in source and binary forms, with or without
|
|
2128
|
-
* modification, are permitted provided that the following conditions are met:
|
|
2129
|
-
*
|
|
2130
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
2131
|
-
* list of conditions and the following disclaimer.
|
|
2132
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
2133
|
-
* this list of conditions and the following disclaimer in the
|
|
2134
|
-
* documentation and/or other materials provided with the distribution.
|
|
2135
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
2136
|
-
* may be used to endorse or promote products derived from this software without
|
|
2137
|
-
* specific prior written permission.
|
|
2138
|
-
*
|
|
2139
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
2140
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
2141
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
2142
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
2143
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
2144
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
2145
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
2146
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
2147
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
2148
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
2149
|
-
*)
|
|
2150
|
-
*/
|
|
2151
1170
|
|
|
2152
|
-
export { ErrorAccessDenied, ErrorAccessTokenResponse, ErrorAuthenticationGrant, ErrorInvalidClient, ErrorInvalidGrant, ErrorInvalidJson, ErrorInvalidRequest, ErrorInvalidReturnedStateParam, ErrorInvalidScope, ErrorInvalidToken, ErrorNoAuthCode, ErrorOAuth2, ErrorServerError, ErrorTemporarilyUnavailable, ErrorUnauthorizedClient, ErrorUnknown, ErrorUnsupportedGrantType, ErrorUnsupportedResponseType,
|
|
2153
|
-
//# sourceMappingURL=index.mjs.map
|
|
2154
|
-
//# sourceMappingURL=index.mjs.map
|
|
1171
|
+
export { ErrorAccessDenied, ErrorAccessTokenResponse, ErrorAuthenticationGrant, ErrorInvalidClient, ErrorInvalidGrant, ErrorInvalidJson, ErrorInvalidRequest, ErrorInvalidReturnedStateParam, ErrorInvalidScope, ErrorInvalidToken, ErrorNoAuthCode, ErrorOAuth2, ErrorServerError, ErrorTemporarilyUnavailable, ErrorUnauthorizedClient, ErrorUnknown, ErrorUnsupportedGrantType, ErrorUnsupportedResponseType, PKCE_CHARSET, RECOMMENDED_CODE_VERIFIER_LENGTH, RECOMMENDED_STATE_LENGTH, base64urlEncode, clearAccessCaches, createOAuthFlow, domainUsesAccess, generateAuthUrl, generatePKCECodes, generateRandomState, getAPIToken, getAccessClientIdFromEnv, getAccessClientSecretFromEnv, getAccessHeaders, getAuthDomainFromEnv, getAuthFromEnv, getAuthUrlFromEnv, getCfAuthorizationTokenFromEnv, getCloudflareAPITokenFromEnv, getCloudflareAccessHeaders, getCloudflareGlobalAuthEmailFromEnv, getCloudflareGlobalAuthKeyFromEnv, getRevokeUrlFromEnv, getTokenUrlFromEnv, readStoredAuthState, requireApiToken, toErrorClass };
|