@bigbinary/neeto-playwright-commons 6.1.5 → 7.0.1-beta1
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/README.md +6 -13
- package/configs/eslint/common.js +1 -1
- package/configs/eslint/host.js +11 -7
- package/index.d.ts +25 -6
- package/index.js +342 -3229
- package/package.json +24 -26
- package/scripts/neeto-chat-widget/setup.sh +5 -1
package/index.js
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs$1, { existsSync, globSync } from 'node:fs';
|
|
2
|
+
import { isPresent, isNotPresent, hyphenate, humanize, noop, keysToSnakeCase, keysToCamelCase, truncate, isNotEmpty, _findBy, randomPick, findBy } from '@bigbinary/neeto-cist';
|
|
2
3
|
import { spawn, execSync } from 'child_process';
|
|
3
4
|
import * as fs from 'fs';
|
|
4
|
-
import { readFileSync, writeFileSync,
|
|
5
|
+
import { readFileSync, writeFileSync, rmSync } from 'fs';
|
|
5
6
|
import { faker } from '@faker-js/faker/locale/en';
|
|
6
7
|
import { expect, test, chromium, defineConfig, devices } from '@playwright/test';
|
|
7
8
|
import { isEmpty, pluck, curry, isNotNil, not, mergeDeepLeft, uniq, mergeDeepRight, uniqBy, sortBy } from 'ramda';
|
|
8
9
|
import dayjs from 'dayjs';
|
|
9
|
-
import {
|
|
10
|
-
import { setTimeout
|
|
10
|
+
import { createInstance } from 'i18next';
|
|
11
|
+
import { setTimeout } from 'node:timers/promises';
|
|
11
12
|
import { Redis } from 'ioredis';
|
|
12
13
|
import { TOTP } from 'otpauth';
|
|
13
14
|
import os from 'os';
|
|
14
15
|
import * as path from 'path';
|
|
15
16
|
import path__default from 'path';
|
|
16
17
|
import { stringify } from 'picoquery';
|
|
17
|
-
import { randomFillSync, createPrivateKey, randomBytes, createHmac } from 'node:crypto';
|
|
18
|
+
import { randomFillSync, randomUUID, createPrivateKey, randomBytes, createHmac } from 'node:crypto';
|
|
18
19
|
import { simpleParser } from 'mailparser';
|
|
19
|
-
import { parse
|
|
20
|
+
import { parse } from 'node-html-parser';
|
|
20
21
|
import { Jimp } from 'jimp';
|
|
21
22
|
import jsQRModule from 'jsqr';
|
|
22
23
|
import { execFileSync } from 'node:child_process';
|
|
23
|
-
import fs$1, { globSync } from 'node:fs';
|
|
24
24
|
import path$1 from 'node:path';
|
|
25
25
|
import { load } from 'js-yaml';
|
|
26
26
|
import timezone from 'dayjs/plugin/timezone.js';
|
|
27
27
|
import utc from 'dayjs/plugin/utc.js';
|
|
28
|
-
import
|
|
28
|
+
import { createAppAuth } from '@octokit/auth-app';
|
|
29
|
+
import { Octokit } from '@octokit/core';
|
|
29
30
|
import { countries } from 'countries-list';
|
|
30
31
|
import { parsePhoneNumberWithError } from 'libphonenumber-js';
|
|
31
32
|
import { lock } from 'proper-lockfile';
|
|
32
33
|
import * as net from 'net';
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
process.env.TEST_ENV ??= "development";
|
|
36
|
+
for (const suffix of [process.env.TEST_ENV, "local"]) {
|
|
37
|
+
const path = `./e2e/config/.env.${suffix}`;
|
|
38
|
+
if (existsSync(path))
|
|
39
|
+
process.loadEnvFile(path);
|
|
40
|
+
}
|
|
34
41
|
|
|
35
42
|
const BASE_URL = "/api/v1";
|
|
36
43
|
const NEETO_AUTH_BASE_URL = (subdomain = "app") => `https://${subdomain}.neetoauth.net`;
|
|
@@ -425,19 +432,11 @@ const isStagingOrganizationExpired = (subdomainName) => {
|
|
|
425
432
|
return now.diff(createdAt, "day") >= getStagingOrganizationTtlInDays();
|
|
426
433
|
};
|
|
427
434
|
|
|
428
|
-
const
|
|
429
|
-
const last = names[names.length - 1];
|
|
430
|
-
const rest = names.slice(0, -1);
|
|
431
|
-
if (rest.length === 0)
|
|
432
|
-
return last;
|
|
433
|
-
if (rest.length === 1)
|
|
434
|
-
return `${rest[0]} and ${last}`;
|
|
435
|
-
return `${rest.join(", ")}, and ${last}`;
|
|
436
|
-
};
|
|
435
|
+
const envListFormat = new Intl.ListFormat("en", { type: "conjunction" });
|
|
437
436
|
const missingEnvMessage = (names) => {
|
|
438
437
|
const noun = names.length === 1 ? "ENV variable" : "ENV variables";
|
|
439
438
|
const verb = names.length === 1 ? "is" : "are";
|
|
440
|
-
return `${noun} ${
|
|
439
|
+
return `${noun} ${envListFormat.format(names)} ${verb} not set`;
|
|
441
440
|
};
|
|
442
441
|
/**
|
|
443
442
|
* Reads the named environment variables. Aborts the running test when any
|
|
@@ -508,6 +507,7 @@ const ZAPIER_WEB_TEXTS = {
|
|
|
508
507
|
reconnect: "Reconnect this authentication",
|
|
509
508
|
retestStep: "Retest step",
|
|
510
509
|
editThisZap: "Edit this Zap",
|
|
510
|
+
publishThisZap: "Publish this Zap",
|
|
511
511
|
staging: "Staging",
|
|
512
512
|
create: "Create",
|
|
513
513
|
account: "Account",
|
|
@@ -1170,7 +1170,6 @@ const ZAPIER_SELECTORS = {
|
|
|
1170
1170
|
zapierSubLink: "zapier-sub-link",
|
|
1171
1171
|
navbar: "top-nav-test-id",
|
|
1172
1172
|
authTitle: "auth-title",
|
|
1173
|
-
publishButton: "publish-button-wrapper",
|
|
1174
1173
|
panelFooter: "#details-panel-footer",
|
|
1175
1174
|
zapToggle: "zap-toggle",
|
|
1176
1175
|
stepBlock: `step-node-${process.env.ZAP_ID}`,
|
|
@@ -1329,6 +1328,22 @@ const KEYBOARD_SHORTCUTS_SELECTORS = {
|
|
|
1329
1328
|
hotKeyItem: "hotkey-item",
|
|
1330
1329
|
};
|
|
1331
1330
|
|
|
1331
|
+
let storedI18n;
|
|
1332
|
+
const initI18n = async ({ plugins, options, }) => {
|
|
1333
|
+
if (!storedI18n?.isInitialized) {
|
|
1334
|
+
const instance = createInstance();
|
|
1335
|
+
plugins.forEach(plugin => instance.use(plugin));
|
|
1336
|
+
await instance.init(options);
|
|
1337
|
+
storedI18n = instance;
|
|
1338
|
+
}
|
|
1339
|
+
return storedI18n;
|
|
1340
|
+
};
|
|
1341
|
+
const getI18nInstance = () => {
|
|
1342
|
+
if (!storedI18n)
|
|
1343
|
+
throw new Error("No i18n instance initialized");
|
|
1344
|
+
return storedI18n;
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1332
1347
|
class IntegrationBase {
|
|
1333
1348
|
page;
|
|
1334
1349
|
neetoPlaywrightUtilities;
|
|
@@ -1444,12 +1459,12 @@ const restoreCookies = async (redis, provider, context) => {
|
|
|
1444
1459
|
}
|
|
1445
1460
|
catch {
|
|
1446
1461
|
log(`Cache entry for "${provider}" is corrupt — falling back to login`);
|
|
1447
|
-
await redis.del(cookieKey(provider)).catch(noop
|
|
1462
|
+
await redis.del(cookieKey(provider)).catch(noop);
|
|
1448
1463
|
return false;
|
|
1449
1464
|
}
|
|
1450
1465
|
};
|
|
1451
1466
|
const acquireLock = (redis, provider) => redis.set(lockKey(provider), "1", "EX", LOCK_TTL_SECONDS, "NX");
|
|
1452
|
-
const releaseLock = (redis, provider) => redis.del(lockKey(provider)).catch(noop
|
|
1467
|
+
const releaseLock = (redis, provider) => redis.del(lockKey(provider)).catch(noop);
|
|
1453
1468
|
const startLockRefresh = (redis, provider) => {
|
|
1454
1469
|
const interval = setInterval(() => {
|
|
1455
1470
|
redis
|
|
@@ -1458,7 +1473,7 @@ const startLockRefresh = (redis, provider) => {
|
|
|
1458
1473
|
if (success)
|
|
1459
1474
|
log(`Refreshed lock TTL for "${provider}"`);
|
|
1460
1475
|
})
|
|
1461
|
-
.catch(noop
|
|
1476
|
+
.catch(noop);
|
|
1462
1477
|
}, LOCK_REFRESH_INTERVAL_MS);
|
|
1463
1478
|
return () => clearInterval(interval);
|
|
1464
1479
|
};
|
|
@@ -1466,12 +1481,12 @@ const pollForCookies = async (redis, provider, context) => {
|
|
|
1466
1481
|
log(`"${provider}" lock held by another shard — waiting for cached cookies`);
|
|
1467
1482
|
const controller = new AbortController();
|
|
1468
1483
|
const { signal } = controller;
|
|
1469
|
-
const timeout = setTimeout
|
|
1484
|
+
const timeout = setTimeout(POLL_TIMEOUT_MS, undefined, { signal }).then(() => {
|
|
1470
1485
|
failTest(`[cookieCache] Timed out waiting for "${provider}" cookies from another shard`);
|
|
1471
1486
|
});
|
|
1472
1487
|
const poll = async () => {
|
|
1473
1488
|
while (true) {
|
|
1474
|
-
await setTimeout
|
|
1489
|
+
await setTimeout(POLL_INTERVAL_MS, undefined, { signal });
|
|
1475
1490
|
if (await restoreCookies(redis, provider, context))
|
|
1476
1491
|
return true;
|
|
1477
1492
|
signal.throwIfAborted();
|
|
@@ -1542,6 +1557,29 @@ const initializeTotp = ({ issuer, secret, }) => {
|
|
|
1542
1557
|
secret,
|
|
1543
1558
|
});
|
|
1544
1559
|
};
|
|
1560
|
+
const fillTotpWhenReady = async ({ codeInput, totp, submitButton, successLocators = [], hideCodeInput = true, }) => {
|
|
1561
|
+
const generateToken = () => totp.generate({ timestamp: Date.now() + 5_000 });
|
|
1562
|
+
const locatorsToHide = hideCodeInput
|
|
1563
|
+
? [codeInput, ...successLocators]
|
|
1564
|
+
: successLocators;
|
|
1565
|
+
let previousToken;
|
|
1566
|
+
await expect(async () => {
|
|
1567
|
+
if (!hideCodeInput || !(await codeInput.isHidden())) {
|
|
1568
|
+
let token = generateToken();
|
|
1569
|
+
if (token === previousToken) {
|
|
1570
|
+
await setTimeout(totp.remaining({ timestamp: Date.now() + 5_000 }) + 500);
|
|
1571
|
+
token = generateToken();
|
|
1572
|
+
}
|
|
1573
|
+
if (!hideCodeInput || !(await codeInput.isHidden())) {
|
|
1574
|
+
previousToken = token;
|
|
1575
|
+
await codeInput.fill(token);
|
|
1576
|
+
expect(totp.validate({ token })).not.toBeNull();
|
|
1577
|
+
await submitButton?.click();
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
await Promise.all(locatorsToHide.map(locator => expect(locator).toBeHidden({ timeout: 20_000 })));
|
|
1581
|
+
}).toPass({ timeout: 2 * 60_000, intervals: [5_000] });
|
|
1582
|
+
};
|
|
1545
1583
|
|
|
1546
1584
|
class GooglePage extends IntegrationBase {
|
|
1547
1585
|
totp;
|
|
@@ -1635,31 +1673,14 @@ class GooglePage extends IntegrationBase {
|
|
|
1635
1673
|
}, ["google.com"]);
|
|
1636
1674
|
};
|
|
1637
1675
|
enterTotpCode = async () => {
|
|
1638
|
-
let previousToken = null;
|
|
1639
1676
|
const codeInput = this.page.getByLabel(GOOGLE_LOGIN_TEXTS.enterCode);
|
|
1640
1677
|
await expect(codeInput).toBeVisible({ timeout: 20_000 });
|
|
1641
|
-
await
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
await this.page.waitForTimeout(remainingTime + 500);
|
|
1648
|
-
totpToken = this.totp.generate({ timestamp: Date.now() });
|
|
1649
|
-
}
|
|
1650
|
-
previousToken = totpToken;
|
|
1651
|
-
if (await codeInput.isHidden())
|
|
1652
|
-
return;
|
|
1653
|
-
await codeInput.fill(totpToken);
|
|
1654
|
-
expect(this.totp.validate({ token: totpToken })).not.toBeNull();
|
|
1655
|
-
await this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext).click();
|
|
1656
|
-
await Promise.all([
|
|
1657
|
-
expect(codeInput).toBeHidden({ timeout: 20_000 }),
|
|
1658
|
-
expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)).toBeHidden({
|
|
1659
|
-
timeout: 20_000,
|
|
1660
|
-
}),
|
|
1661
|
-
]);
|
|
1662
|
-
}).toPass({ timeout: 2 * 60 * 1000 });
|
|
1678
|
+
await fillTotpWhenReady({
|
|
1679
|
+
codeInput,
|
|
1680
|
+
totp: this.totp,
|
|
1681
|
+
submitButton: this.page.locator(GOOGLE_LOGIN_SELECTORS.totpNext),
|
|
1682
|
+
successLocators: [this.page.getByText(GOOGLE_LOGIN_TEXTS.wrongCode)],
|
|
1683
|
+
});
|
|
1663
1684
|
};
|
|
1664
1685
|
logoutFromGoogle = async () => {
|
|
1665
1686
|
if (IS_DEV_ENV)
|
|
@@ -1946,32 +1967,19 @@ class OrganizationPage {
|
|
|
1946
1967
|
}).toPass({ timeout: loginTimeout });
|
|
1947
1968
|
};
|
|
1948
1969
|
enterTotpCode = async () => {
|
|
1949
|
-
let previousToken = null;
|
|
1950
1970
|
const totp = initializeTotp({
|
|
1951
1971
|
issuer: "Neeto",
|
|
1952
1972
|
secret: process.env.PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY,
|
|
1953
1973
|
});
|
|
1954
1974
|
const codeInput = this.page.getByTestId(LOGIN_SELECTORS.authenticatorAppOtpInput);
|
|
1955
1975
|
await expect(codeInput).toBeVisible({ timeout: 20_000 });
|
|
1956
|
-
await
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
totpToken = totp.generate({ timestamp: Date.now() });
|
|
1964
|
-
}
|
|
1965
|
-
previousToken = totpToken;
|
|
1966
|
-
if (await codeInput.isHidden())
|
|
1967
|
-
return;
|
|
1968
|
-
await codeInput.fill(totpToken);
|
|
1969
|
-
expect(totp.validate({ token: totpToken })).not.toBeNull();
|
|
1970
|
-
await Promise.all([
|
|
1971
|
-
expect(codeInput).toBeHidden({ timeout: 10_000 }),
|
|
1972
|
-
expect(this.page.getByTestId(LOGIN_SELECTORS.enterOtpInputError)).toBeHidden({ timeout: 10_000 }),
|
|
1973
|
-
]);
|
|
1974
|
-
}).toPass({ timeout: LOGIN_TIMEOUT });
|
|
1976
|
+
await fillTotpWhenReady({
|
|
1977
|
+
codeInput,
|
|
1978
|
+
totp,
|
|
1979
|
+
successLocators: [
|
|
1980
|
+
this.page.getByTestId(LOGIN_SELECTORS.enterOtpInputError),
|
|
1981
|
+
],
|
|
1982
|
+
});
|
|
1975
1983
|
};
|
|
1976
1984
|
loginStrategies = {
|
|
1977
1985
|
[LOGIN_STRATEGIES.oliver]: () => this.loginAsOliver(),
|
|
@@ -2285,7 +2293,7 @@ class CustomCommands {
|
|
|
2285
2293
|
return await callback();
|
|
2286
2294
|
}
|
|
2287
2295
|
const timeToWaitInSecs = iteration > 3 ? 10 : Math.pow(2, iteration);
|
|
2288
|
-
await setTimeout
|
|
2296
|
+
await setTimeout(timeToWaitInSecs * 1000);
|
|
2289
2297
|
return await this.recursiveMethod(callback, condition, timeout, startTime, iteration + 1);
|
|
2290
2298
|
};
|
|
2291
2299
|
executeRecursively = async ({ callback, condition, timeout = 5000, }) => {
|
|
@@ -2307,16 +2315,11 @@ class CustomCommands {
|
|
|
2307
2315
|
await expect(filteredToastLocator).toContainText(isEmpty(message) ? TOAST_DEFAULT_MESSAGE : message, { timeout });
|
|
2308
2316
|
if (!closeAfterVerification)
|
|
2309
2317
|
return;
|
|
2310
|
-
const
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
}, buttonHandle);
|
|
2316
|
-
await expect(toastCloseButton).toBeHidden({
|
|
2317
|
-
timeout: toastCloseTimeout,
|
|
2318
|
-
});
|
|
2319
|
-
}
|
|
2318
|
+
const toastCloseBtn = filteredToastLocator.getByTestId(COMMON_SELECTORS.toastCloseButton);
|
|
2319
|
+
await toastCloseBtn.dispatchEvent("click", {}, {
|
|
2320
|
+
timeout: toastCloseTimeout,
|
|
2321
|
+
});
|
|
2322
|
+
await expect(toastCloseBtn).toBeHidden({ timeout: toastCloseTimeout });
|
|
2320
2323
|
};
|
|
2321
2324
|
waitForPageLoad = async ({ visibilityTimeout = 35_000, customPageContext = this.page, waitForOption = "serial", } = {}) => {
|
|
2322
2325
|
await customPageContext.waitForLoadState();
|
|
@@ -2801,7 +2804,7 @@ const saveStorageState = async (page, credentials = {}) => {
|
|
|
2801
2804
|
};
|
|
2802
2805
|
const removeCredentialFile = () => {
|
|
2803
2806
|
try {
|
|
2804
|
-
fs.
|
|
2807
|
+
fs.rmSync(STORAGE_STATE, { force: true });
|
|
2805
2808
|
}
|
|
2806
2809
|
catch (error) {
|
|
2807
2810
|
console.log(error);
|
|
@@ -3019,6 +3022,9 @@ class MailpitApi {
|
|
|
3019
3022
|
};
|
|
3020
3023
|
}
|
|
3021
3024
|
|
|
3025
|
+
const latestRailsEmail = (emails) => emails.reduce((latest, current) => !latest || new Date(current.receivedAt) > new Date(latest.receivedAt)
|
|
3026
|
+
? current
|
|
3027
|
+
: latest, null);
|
|
3022
3028
|
class RailsEmailApiClient {
|
|
3023
3029
|
port = process.env.RAILS_SERVER_PORT;
|
|
3024
3030
|
subdomain = process.env.SUBDOMAIN ?? "spinkart";
|
|
@@ -3068,12 +3074,7 @@ class RailsEmailApiClient {
|
|
|
3068
3074
|
const data = await this.fetchJson(`${this.emailsEndpoint}${query}`);
|
|
3069
3075
|
return data?.map(this.convertRawEmail) ?? [];
|
|
3070
3076
|
};
|
|
3071
|
-
getLatestEmail = async (searchParams) =>
|
|
3072
|
-
const emails = await this.listEmails(searchParams);
|
|
3073
|
-
return emails.reduce((latest, curr) => !latest || new Date(curr.receivedAt) > new Date(latest.receivedAt)
|
|
3074
|
-
? curr
|
|
3075
|
-
: latest, null);
|
|
3076
|
-
};
|
|
3077
|
+
getLatestEmail = async (searchParams) => latestRailsEmail(await this.listEmails(searchParams));
|
|
3077
3078
|
clearEmails = () => this.fetchJson(this.emailsEndpoint, {
|
|
3078
3079
|
method: "DELETE",
|
|
3079
3080
|
});
|
|
@@ -3321,8 +3322,6 @@ class RailsEmailUtils {
|
|
|
3321
3322
|
this.railsEmailClient = new RailsEmailApiClient();
|
|
3322
3323
|
}
|
|
3323
3324
|
convertRailsEmailToFormattedList = (railsEmail) => {
|
|
3324
|
-
if (!railsEmail)
|
|
3325
|
-
return null;
|
|
3326
3325
|
const LINK_REGEX = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])/g;
|
|
3327
3326
|
const CODE_REGEX = /(?<![#/])\b\d{4,}\b/g;
|
|
3328
3327
|
const htmlBody = railsEmail.htmlBody || "";
|
|
@@ -3354,7 +3353,7 @@ class RailsEmailUtils {
|
|
|
3354
3353
|
links: extractMatches(textBody, LINK_REGEX),
|
|
3355
3354
|
codes: extractMatches(textBody, CODE_REGEX),
|
|
3356
3355
|
},
|
|
3357
|
-
id:
|
|
3356
|
+
id: randomUUID(),
|
|
3358
3357
|
from: parseEmailAddress(railsEmail.from),
|
|
3359
3358
|
to: parseEmailAddress(railsEmail.to),
|
|
3360
3359
|
cc: parseEmailAddress(railsEmail.cc),
|
|
@@ -3385,36 +3384,28 @@ class RailsEmailUtils {
|
|
|
3385
3384
|
...messageSearchCriteria,
|
|
3386
3385
|
receivedAfter: receivedAfter.toISOString(),
|
|
3387
3386
|
});
|
|
3388
|
-
return emails
|
|
3389
|
-
.map(email => this.convertRailsEmailToFormattedList(email))
|
|
3390
|
-
.filter((email) => email !== null);
|
|
3387
|
+
return emails.map(this.convertRailsEmailToFormattedList);
|
|
3391
3388
|
};
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
...messageSearchCriteria,
|
|
3397
|
-
receivedAfter: receivedAfter.toISOString(),
|
|
3398
|
-
});
|
|
3399
|
-
if (!railsEmail)
|
|
3400
|
-
return null;
|
|
3401
|
-
return this.convertRailsEmailToFormattedList(railsEmail);
|
|
3402
|
-
},
|
|
3389
|
+
waitForLatestEmail = async (searchParams, expectedEmailCount, timeout) => {
|
|
3390
|
+
let emails = [];
|
|
3391
|
+
const latestEmail = (await this.neetoPlaywrightUtilities.executeRecursively({
|
|
3392
|
+
callback: () => latestRailsEmail(emails),
|
|
3403
3393
|
condition: async () => {
|
|
3404
|
-
|
|
3405
|
-
...messageSearchCriteria,
|
|
3406
|
-
receivedAfter: receivedAfter.toISOString(),
|
|
3407
|
-
});
|
|
3394
|
+
emails = await this.railsEmailClient.listEmails(searchParams);
|
|
3408
3395
|
return emails.length >= expectedEmailCount;
|
|
3409
3396
|
},
|
|
3410
3397
|
timeout,
|
|
3411
3398
|
}));
|
|
3399
|
+
return latestEmail || null;
|
|
3400
|
+
};
|
|
3401
|
+
findMessage = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = new Date(new Date().valueOf() - 60 * 60 * 1000), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
|
|
3402
|
+
const email = await this.waitForLatestEmail({ ...messageSearchCriteria, receivedAfter: receivedAfter.toISOString() }, expectedEmailCount, timeout);
|
|
3412
3403
|
if (!email) {
|
|
3413
3404
|
if (shouldThrowErrorOnTimeout && expectedEmailCount > 0)
|
|
3414
3405
|
failTest("Timed out waiting for matching message");
|
|
3415
3406
|
return {};
|
|
3416
3407
|
}
|
|
3417
|
-
return email;
|
|
3408
|
+
return this.convertRailsEmailToFormattedList(email);
|
|
3418
3409
|
};
|
|
3419
3410
|
getLatestMessageId = async (subject, { timeout = 10_000, receivedAfter = new Date(new Date().valueOf() - 60 * 1000), } = {}) => {
|
|
3420
3411
|
const email = await this.findMessage({ subject }, { timeout, receivedAfter }, false);
|
|
@@ -3423,70 +3414,34 @@ class RailsEmailUtils {
|
|
|
3423
3414
|
return email.messageId.replace(/^<|>$/g, "");
|
|
3424
3415
|
};
|
|
3425
3416
|
findOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 10_000, receivedAfter = new Date(), expectedEmailCount = 1, }) => {
|
|
3426
|
-
const
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
const formattedEmail = this.convertRailsEmailToFormattedList(railsEmail);
|
|
3436
|
-
if (!formattedEmail)
|
|
3437
|
-
return null;
|
|
3438
|
-
return formattedEmail.html.codes?.[0] || formattedEmail.text.codes?.[0];
|
|
3439
|
-
},
|
|
3440
|
-
condition: async () => {
|
|
3441
|
-
const emails = await this.railsEmailClient.listEmails({
|
|
3442
|
-
to: email,
|
|
3443
|
-
subject: subjectSubstring,
|
|
3444
|
-
receivedAfter: receivedAfter.toISOString(),
|
|
3445
|
-
});
|
|
3446
|
-
return emails.length >= expectedEmailCount;
|
|
3447
|
-
},
|
|
3448
|
-
timeout,
|
|
3449
|
-
});
|
|
3450
|
-
return otp || undefined;
|
|
3417
|
+
const railsEmail = await this.waitForLatestEmail({
|
|
3418
|
+
to: email,
|
|
3419
|
+
subject: subjectSubstring,
|
|
3420
|
+
receivedAfter: receivedAfter.toISOString(),
|
|
3421
|
+
}, expectedEmailCount, timeout);
|
|
3422
|
+
if (!railsEmail)
|
|
3423
|
+
return undefined;
|
|
3424
|
+
const { html, text } = this.convertRailsEmailToFormattedList(railsEmail);
|
|
3425
|
+
return html.codes?.[0] || text.codes?.[0];
|
|
3451
3426
|
};
|
|
3452
3427
|
getEmailAttachment = async ({ name, type }, messageSearchCriteria = {}, { receivedAfter = new Date(new Date().valueOf() - 60 * 60 * 1000), expectedEmailCount = 1, timeout = 10_000, } = {}, shouldThrowErrorOnTimeout = true) => {
|
|
3453
|
-
const
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
return null;
|
|
3461
|
-
const attachment = railsEmail.attachments?.find(att => {
|
|
3462
|
-
const matchesName = name ? att.name?.includes(name) : true;
|
|
3463
|
-
const matchesType = type ? att.type?.startsWith(type) : true;
|
|
3464
|
-
return matchesName && matchesType;
|
|
3465
|
-
});
|
|
3466
|
-
if (!attachment)
|
|
3467
|
-
return null;
|
|
3468
|
-
return {
|
|
3469
|
-
filename: attachment.name,
|
|
3470
|
-
type: attachment.type,
|
|
3471
|
-
content: Buffer.from(attachment.content, "base64"),
|
|
3472
|
-
contentType: attachment.type,
|
|
3473
|
-
};
|
|
3474
|
-
},
|
|
3475
|
-
condition: async () => {
|
|
3476
|
-
const emails = await this.railsEmailClient.listEmails({
|
|
3477
|
-
...messageSearchCriteria,
|
|
3478
|
-
receivedAfter: receivedAfter.toISOString(),
|
|
3479
|
-
});
|
|
3480
|
-
return emails.length >= expectedEmailCount;
|
|
3481
|
-
},
|
|
3482
|
-
timeout,
|
|
3483
|
-
}));
|
|
3484
|
-
if (!attachmentDetails) {
|
|
3428
|
+
const railsEmail = await this.waitForLatestEmail({ ...messageSearchCriteria, receivedAfter: receivedAfter.toISOString() }, expectedEmailCount, timeout);
|
|
3429
|
+
const attachment = railsEmail?.attachments?.find(att => {
|
|
3430
|
+
const matchesName = name ? att.name?.includes(name) : true;
|
|
3431
|
+
const matchesType = type ? att.type?.startsWith(type) : true;
|
|
3432
|
+
return matchesName && matchesType;
|
|
3433
|
+
});
|
|
3434
|
+
if (!attachment) {
|
|
3485
3435
|
if (shouldThrowErrorOnTimeout)
|
|
3486
3436
|
failTest("Timed out waiting for matching message or attachment not found");
|
|
3487
3437
|
return undefined;
|
|
3488
3438
|
}
|
|
3489
|
-
return
|
|
3439
|
+
return {
|
|
3440
|
+
filename: attachment.name,
|
|
3441
|
+
type: attachment.type,
|
|
3442
|
+
content: Buffer.from(attachment.content, "base64"),
|
|
3443
|
+
contentType: attachment.type,
|
|
3444
|
+
};
|
|
3490
3445
|
};
|
|
3491
3446
|
}
|
|
3492
3447
|
|
|
@@ -3524,7 +3479,7 @@ class MailerUtils {
|
|
|
3524
3479
|
const wrappedHtml = /<html[\s>]/i.test(emailBody)
|
|
3525
3480
|
? emailBody.replace(/\sxmlns="[^"]+"/g, "")
|
|
3526
3481
|
: basicHTMLContent(emailBody);
|
|
3527
|
-
const root = parse
|
|
3482
|
+
const root = parse(wrappedHtml, { comment: false });
|
|
3528
3483
|
const textBody = root.querySelector("body")?.text.trim() || "";
|
|
3529
3484
|
const text = { body: textBody, ...contentRecognitions };
|
|
3530
3485
|
return { html, text };
|
|
@@ -3962,6 +3917,15 @@ const listFormatter = ({ value, format, lng, options, }) => {
|
|
|
3962
3917
|
const items = newValue.toString().split(",");
|
|
3963
3918
|
return formatter.format(items);
|
|
3964
3919
|
};
|
|
3920
|
+
const interpolationFormatter = {
|
|
3921
|
+
type: "formatter",
|
|
3922
|
+
format: (value, format, lng, options) => {
|
|
3923
|
+
if (LIST_FORMATS.includes(format ?? "")) {
|
|
3924
|
+
return listFormatter({ value, format, lng, options });
|
|
3925
|
+
}
|
|
3926
|
+
return lowerCaseDynamicTextFormatter(value, format);
|
|
3927
|
+
},
|
|
3928
|
+
};
|
|
3965
3929
|
|
|
3966
3930
|
const sentenceCase = (value) => value.charAt(0).toLocaleUpperCase() + value.slice(1);
|
|
3967
3931
|
const sentenceCaseProcessor = {
|
|
@@ -4207,30 +4171,24 @@ const i18nFixture = {
|
|
|
4207
4171
|
const options = {
|
|
4208
4172
|
debug: false,
|
|
4209
4173
|
fallbackLng: ENGLISH_LOCALE,
|
|
4174
|
+
returnEmptyString: true,
|
|
4210
4175
|
resources,
|
|
4211
4176
|
interpolation: {
|
|
4212
4177
|
defaultVariables: { taxonomies },
|
|
4213
4178
|
escapeValue: false,
|
|
4214
4179
|
skipOnVariables: false,
|
|
4215
4180
|
alwaysFormat: true,
|
|
4216
|
-
format: (value, format, lng, options) => {
|
|
4217
|
-
let newValue = value;
|
|
4218
|
-
if (LIST_FORMATS.includes(format ?? "")) {
|
|
4219
|
-
newValue = listFormatter({
|
|
4220
|
-
value: newValue,
|
|
4221
|
-
format,
|
|
4222
|
-
lng,
|
|
4223
|
-
options,
|
|
4224
|
-
});
|
|
4225
|
-
return newValue;
|
|
4226
|
-
}
|
|
4227
|
-
return lowerCaseDynamicTextFormatter(newValue, format);
|
|
4228
|
-
},
|
|
4229
4181
|
},
|
|
4230
4182
|
postProcess: ["removeTagsProcessor", "sentenceCaseProcessor"],
|
|
4231
4183
|
};
|
|
4232
|
-
const
|
|
4233
|
-
|
|
4184
|
+
const i18nInitialized = await initI18n({
|
|
4185
|
+
plugins: [
|
|
4186
|
+
interpolationFormatter,
|
|
4187
|
+
removeTagsProcessor,
|
|
4188
|
+
sentenceCaseProcessor,
|
|
4189
|
+
],
|
|
4190
|
+
options,
|
|
4191
|
+
});
|
|
4234
4192
|
await use(i18nInitialized);
|
|
4235
4193
|
},
|
|
4236
4194
|
{ auto: true, scope: "worker", box: true },
|
|
@@ -4370,7 +4328,7 @@ class EmbedBase {
|
|
|
4370
4328
|
}
|
|
4371
4329
|
await this.embedTestPage.close();
|
|
4372
4330
|
await this.context.close();
|
|
4373
|
-
|
|
4331
|
+
rmSync(this.filePath, { force: true });
|
|
4374
4332
|
};
|
|
4375
4333
|
clickOnPopupButton = async (popUpButtonSelectorOptions) => {
|
|
4376
4334
|
const popUpButton = this.embedTestPage.getByRole(this.embedTestPageType === "floatingPopup" ? "button" : "link", popUpButtonSelectorOptions);
|
|
@@ -5021,14 +4979,13 @@ class MicrosoftPage extends IntegrationBase {
|
|
|
5021
4979
|
name: MICROSOFT_LOGIN_TEXTS.verify,
|
|
5022
4980
|
});
|
|
5023
4981
|
await this.page.waitForLoadState("load", { timeout: 25_000 });
|
|
5024
|
-
await
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
}).toPass({ timeout: 60 * 1000, intervals: [10_000] });
|
|
4982
|
+
await fillTotpWhenReady({
|
|
4983
|
+
codeInput: this.page.getByLabel(MICROSOFT_LOGIN_TEXTS.enterCode),
|
|
4984
|
+
totp: this.totp,
|
|
4985
|
+
submitButton: verifyBtn,
|
|
4986
|
+
successLocators: [this.page.getByRole("alert"), verifyBtn],
|
|
4987
|
+
hideCodeInput: false,
|
|
4988
|
+
});
|
|
5032
4989
|
};
|
|
5033
4990
|
staySignedIn = async () => {
|
|
5034
4991
|
await this.page.waitForLoadState("load", { timeout: 25_000 });
|
|
@@ -5298,7 +5255,10 @@ class ZapierPage extends IntegrationBase {
|
|
|
5298
5255
|
.getByRole("button", { name: ZAPIER_WEB_TEXTS.editThisZap })
|
|
5299
5256
|
.click();
|
|
5300
5257
|
await this.zapierWebPage.waitForLoadState();
|
|
5301
|
-
const publishBtn = this.navbar.
|
|
5258
|
+
const publishBtn = this.navbar.getByRole("button", {
|
|
5259
|
+
name: ZAPIER_WEB_TEXTS.publishThisZap,
|
|
5260
|
+
exact: true,
|
|
5261
|
+
});
|
|
5302
5262
|
const editBtn = this.zapierWebPage.getByRole("button", {
|
|
5303
5263
|
name: ZAPIER_WEB_TEXTS.editExistingDraft,
|
|
5304
5264
|
});
|
|
@@ -5414,28 +5374,16 @@ class ZapierPage extends IntegrationBase {
|
|
|
5414
5374
|
.waitFor({ timeout: 25_000 });
|
|
5415
5375
|
};
|
|
5416
5376
|
enterTotpCode = async () => {
|
|
5417
|
-
let previousToken = null;
|
|
5418
5377
|
const codeInput = this.zapierWebPage.locator(ZAPIER_SELECTORS.authenticationCode);
|
|
5419
5378
|
await expect(codeInput).toBeVisible({ timeout: 20_000 });
|
|
5420
|
-
await
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
}
|
|
5429
|
-
previousToken = totpToken;
|
|
5430
|
-
if (await codeInput.isHidden())
|
|
5431
|
-
return;
|
|
5432
|
-
await codeInput.fill(totpToken);
|
|
5433
|
-
expect(this.totp.validate({ token: totpToken })).not.toBeNull();
|
|
5434
|
-
await this.zapierWebPage
|
|
5435
|
-
.getByRole("button", { name: ZAPIER_WEB_TEXTS.confirm, exact: true })
|
|
5436
|
-
.click();
|
|
5437
|
-
await expect(codeInput).toBeHidden({ timeout: 20_000 });
|
|
5438
|
-
}).toPass({ timeout: 2 * 60 * 1000 });
|
|
5379
|
+
await fillTotpWhenReady({
|
|
5380
|
+
codeInput,
|
|
5381
|
+
totp: this.totp,
|
|
5382
|
+
submitButton: this.zapierWebPage.getByRole("button", {
|
|
5383
|
+
name: ZAPIER_WEB_TEXTS.confirm,
|
|
5384
|
+
exact: true,
|
|
5385
|
+
}),
|
|
5386
|
+
});
|
|
5439
5387
|
};
|
|
5440
5388
|
logoutFromZapier = async () => {
|
|
5441
5389
|
await this.zapierWebPage.goto(THIRD_PARTY_ROUTES.zapier.logOut, {
|
|
@@ -6697,19 +6645,22 @@ class CustomDomainPage {
|
|
|
6697
6645
|
};
|
|
6698
6646
|
isEdgeCertificateDomain = () => !!CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX &&
|
|
6699
6647
|
this.customDomainURL.endsWith(`.${CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX}`);
|
|
6700
|
-
isCustomDomainRouted = () =>
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
}
|
|
6712
|
-
|
|
6648
|
+
isCustomDomainRouted = async () => {
|
|
6649
|
+
try {
|
|
6650
|
+
const response = await fetch(this.customDomainURL, {
|
|
6651
|
+
redirect: "manual",
|
|
6652
|
+
signal: AbortSignal.timeout(10_000),
|
|
6653
|
+
});
|
|
6654
|
+
await response.body?.cancel();
|
|
6655
|
+
// Traefik answers a plain-text 404 until the edge-certificate route is loaded.
|
|
6656
|
+
const isTraefikNotFound = response.status === 404 &&
|
|
6657
|
+
response.headers.get("content-type")?.startsWith("text/plain");
|
|
6658
|
+
return !this.isEdgeCertificateDomain() || !isTraefikNotFound;
|
|
6659
|
+
}
|
|
6660
|
+
catch {
|
|
6661
|
+
return false;
|
|
6662
|
+
}
|
|
6663
|
+
};
|
|
6713
6664
|
// A new edge-certificate route flaps between routed and 404 before it settles.
|
|
6714
6665
|
waitForTrustedSSL = () => {
|
|
6715
6666
|
const requiredRoutedResponses = this.isEdgeCertificateDomain() ? 3 : 1;
|
|
@@ -7499,24 +7450,31 @@ const cpuThrottlingUsingCDP = ({ cdpSession, rate = 1.25, }) => cdpSession.send(
|
|
|
7499
7450
|
const executeWithThrottledResources = async ({ code: emulatedCode, kind = "both", networkCondition, cpuThrottlingRate, cdpSession, }) => {
|
|
7500
7451
|
const shouldApplyNetworkThrottling = kind === "network" || kind === "both";
|
|
7501
7452
|
const shouldApplyCPUThrottling = kind === "cpu" || kind === "both";
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7453
|
+
try {
|
|
7454
|
+
if (shouldApplyNetworkThrottling) {
|
|
7455
|
+
await networkThrottlingUsingCDP({
|
|
7456
|
+
cdpSession,
|
|
7457
|
+
emulateNetworkConditionsParameters: networkCondition,
|
|
7458
|
+
});
|
|
7459
|
+
}
|
|
7460
|
+
if (shouldApplyCPUThrottling) {
|
|
7461
|
+
await cpuThrottlingUsingCDP({
|
|
7462
|
+
cdpSession,
|
|
7463
|
+
rate: cpuThrottlingRate,
|
|
7464
|
+
});
|
|
7465
|
+
}
|
|
7466
|
+
await emulatedCode();
|
|
7507
7467
|
}
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7468
|
+
finally {
|
|
7469
|
+
// allSettled so a closed CDP session can't replace the error from `code`.
|
|
7470
|
+
await Promise.allSettled([
|
|
7471
|
+
networkThrottlingUsingCDP({
|
|
7472
|
+
cdpSession,
|
|
7473
|
+
emulateNetworkConditionsParameters: networkConditions["No Throttling"],
|
|
7474
|
+
}),
|
|
7475
|
+
cpuThrottlingUsingCDP({ cdpSession, rate: 1 }),
|
|
7476
|
+
]);
|
|
7513
7477
|
}
|
|
7514
|
-
await emulatedCode();
|
|
7515
|
-
await networkThrottlingUsingCDP({
|
|
7516
|
-
cdpSession,
|
|
7517
|
-
emulateNetworkConditionsParameters: networkConditions["No Throttling"],
|
|
7518
|
-
});
|
|
7519
|
-
await cpuThrottlingUsingCDP({ cdpSession, rate: 1 });
|
|
7520
7478
|
};
|
|
7521
7479
|
|
|
7522
7480
|
const openFilterPane = async (page) => {
|
|
@@ -7578,2979 +7536,137 @@ const currencyUtils = {
|
|
|
7578
7536
|
currencyFormat,
|
|
7579
7537
|
};
|
|
7580
7538
|
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7539
|
+
const PEM_PATTERN = /(-----BEGIN [A-Z ]+-----)([\s\S]*?)(-----END [A-Z ]+-----)/;
|
|
7540
|
+
const PEM_LINE_LENGTH = 64;
|
|
7541
|
+
const GITHUB_BOT_ENV_VARS = [
|
|
7542
|
+
"GITHUB_BOT_APP_ID",
|
|
7543
|
+
"GITHUB_BOT_PRIVATE_KEY",
|
|
7544
|
+
"GITHUB_BOT_INSTALLATION_ID",
|
|
7545
|
+
];
|
|
7546
|
+
let cachedAppAuth;
|
|
7547
|
+
// Secret stores hold the key with \n escapes, with spaces, or base64-encoded.
|
|
7548
|
+
const readPrivateKey = (rawKey) => {
|
|
7549
|
+
const unescaped = rawKey.replace(/\\n/g, "\n");
|
|
7550
|
+
const decoded = unescaped.includes("-----BEGIN")
|
|
7551
|
+
? unescaped
|
|
7552
|
+
: Buffer.from(rawKey.replace(/\s/g, ""), "base64").toString("utf-8");
|
|
7553
|
+
const pem = decoded.match(PEM_PATTERN);
|
|
7554
|
+
if (!pem)
|
|
7555
|
+
failTest("ENV variable GITHUB_BOT_PRIVATE_KEY is not a PEM key or a base64 encoded PEM key");
|
|
7556
|
+
const [, begin, body, end] = pem;
|
|
7557
|
+
const lines = body.replace(/\s/g, "").match(new RegExp(`.{1,${PEM_LINE_LENGTH}}`, "g")) ??
|
|
7558
|
+
[];
|
|
7559
|
+
return [begin, ...lines, end, ""].join("\n");
|
|
7560
|
+
};
|
|
7561
|
+
// The auth client holds the token cache, so it must be reused across calls.
|
|
7562
|
+
const getAppAuth = () => {
|
|
7563
|
+
if (cachedAppAuth)
|
|
7564
|
+
return cachedAppAuth;
|
|
7565
|
+
const missing = GITHUB_BOT_ENV_VARS.filter(name => isNotPresent(process.env[name]));
|
|
7566
|
+
if (missing.length > 0)
|
|
7567
|
+
failTest(`ENV variables ${missing.join(", ")} are not set. Set all of ${GITHUB_BOT_ENV_VARS.join(", ")}, or set only GITHUB_TOKEN`);
|
|
7568
|
+
const appId = process.env.GITHUB_BOT_APP_ID;
|
|
7569
|
+
const privateKey = process.env.GITHUB_BOT_PRIVATE_KEY;
|
|
7570
|
+
const installationId = process.env.GITHUB_BOT_INSTALLATION_ID;
|
|
7571
|
+
// createAppAuth needs a PKCS#8 key, and the bundled JWT signer does not convert the PKCS#1 key that GitHub issues.
|
|
7572
|
+
const privateKeyPkcs8 = createPrivateKey(readPrivateKey(privateKey)).export({
|
|
7573
|
+
type: "pkcs8",
|
|
7574
|
+
format: "pem",
|
|
7575
|
+
});
|
|
7576
|
+
cachedAppAuth = createAppAuth({
|
|
7577
|
+
appId: appId.trim(),
|
|
7578
|
+
privateKey: privateKeyPkcs8,
|
|
7579
|
+
installationId: installationId.trim(),
|
|
7580
|
+
});
|
|
7581
|
+
return cachedAppAuth;
|
|
7582
|
+
};
|
|
7583
|
+
const getGithubToken = async ({ forceRefresh = false, } = {}) => {
|
|
7584
|
+
const isGithubBotConfigured = GITHUB_BOT_ENV_VARS.some(name => process.env[name]);
|
|
7585
|
+
const githubToken = process.env.GITHUB_TOKEN;
|
|
7586
|
+
if (!isGithubBotConfigured && githubToken)
|
|
7587
|
+
return githubToken;
|
|
7588
|
+
const { token } = await getAppAuth()({
|
|
7589
|
+
type: "installation",
|
|
7590
|
+
refresh: forceRefresh,
|
|
7591
|
+
});
|
|
7592
|
+
return token;
|
|
7612
7593
|
};
|
|
7613
7594
|
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
}
|
|
7624
|
-
|
|
7625
|
-
// pkg/dist-src/util/is-plain-object.js
|
|
7626
|
-
function isPlainObject$1(value) {
|
|
7627
|
-
if (typeof value !== "object" || value === null) return false;
|
|
7628
|
-
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
7629
|
-
const proto = Object.getPrototypeOf(value);
|
|
7630
|
-
if (proto === null) return true;
|
|
7631
|
-
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
7632
|
-
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
7633
|
-
}
|
|
7634
|
-
|
|
7635
|
-
// pkg/dist-src/util/merge-deep.js
|
|
7636
|
-
function mergeDeep(defaults, options) {
|
|
7637
|
-
const result = Object.assign({}, defaults);
|
|
7638
|
-
Object.keys(options).forEach((key) => {
|
|
7639
|
-
if (isPlainObject$1(options[key])) {
|
|
7640
|
-
if (!(key in defaults)) Object.assign(result, { [key]: options[key] });
|
|
7641
|
-
else result[key] = mergeDeep(defaults[key], options[key]);
|
|
7642
|
-
} else {
|
|
7643
|
-
Object.assign(result, { [key]: options[key] });
|
|
7644
|
-
}
|
|
7645
|
-
});
|
|
7646
|
-
return result;
|
|
7647
|
-
}
|
|
7648
|
-
|
|
7649
|
-
// pkg/dist-src/util/remove-undefined-properties.js
|
|
7650
|
-
function removeUndefinedProperties(obj) {
|
|
7651
|
-
for (const key in obj) {
|
|
7652
|
-
if (obj[key] === void 0) {
|
|
7653
|
-
delete obj[key];
|
|
7654
|
-
}
|
|
7655
|
-
}
|
|
7656
|
-
return obj;
|
|
7657
|
-
}
|
|
7658
|
-
|
|
7659
|
-
// pkg/dist-src/merge.js
|
|
7660
|
-
function merge(defaults, route, options) {
|
|
7661
|
-
if (typeof route === "string") {
|
|
7662
|
-
let [method, url] = route.split(" ");
|
|
7663
|
-
options = Object.assign(url ? { method, url } : { url: method }, options);
|
|
7664
|
-
} else {
|
|
7665
|
-
options = Object.assign({}, route);
|
|
7666
|
-
}
|
|
7667
|
-
options.headers = lowercaseKeys(options.headers);
|
|
7668
|
-
removeUndefinedProperties(options);
|
|
7669
|
-
removeUndefinedProperties(options.headers);
|
|
7670
|
-
const mergedOptions = mergeDeep(defaults || {}, options);
|
|
7671
|
-
if (options.url === "/graphql") {
|
|
7672
|
-
if (defaults && defaults.mediaType.previews?.length) {
|
|
7673
|
-
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(
|
|
7674
|
-
(preview) => !mergedOptions.mediaType.previews.includes(preview)
|
|
7675
|
-
).concat(mergedOptions.mediaType.previews);
|
|
7595
|
+
const issueStatusCache = new Map();
|
|
7596
|
+
const fetchIsIssueOpen = async (owner, repo, issueNumber) => {
|
|
7597
|
+
const requestIssue = (auth) => new Octokit({ auth }).request("GET /repos/{owner}/{repo}/issues/{issue_number}", {
|
|
7598
|
+
owner,
|
|
7599
|
+
repo,
|
|
7600
|
+
issue_number: issueNumber,
|
|
7601
|
+
headers: { "X-GitHub-Api-Version": "2022-11-28" },
|
|
7602
|
+
});
|
|
7603
|
+
try {
|
|
7604
|
+
const { data } = await requestIssue(await getGithubToken());
|
|
7605
|
+
return data.state === "open";
|
|
7676
7606
|
}
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
function addQueryParameters(url, parameters) {
|
|
7684
|
-
const separator = /\?/.test(url) ? "&" : "?";
|
|
7685
|
-
const names = Object.keys(parameters);
|
|
7686
|
-
if (names.length === 0) {
|
|
7687
|
-
return url;
|
|
7688
|
-
}
|
|
7689
|
-
return url + separator + names.map((name) => {
|
|
7690
|
-
if (name === "q") {
|
|
7691
|
-
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
|
7607
|
+
catch (error) {
|
|
7608
|
+
// 401 means the cached token was revoked — mint a fresh one and retry once.
|
|
7609
|
+
if (error.status !== 401)
|
|
7610
|
+
throw error;
|
|
7611
|
+
const { data } = await requestIssue(await getGithubToken({ forceRefresh: true }));
|
|
7612
|
+
return data.state === "open";
|
|
7692
7613
|
}
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
}
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7614
|
+
};
|
|
7615
|
+
const isIssueOpen = (issueLink) => {
|
|
7616
|
+
const [owner, repo, ...rest] = (issueLink.split(/[?#]/)[0].split("github.com/").at(-1) ?? "")
|
|
7617
|
+
.split("/")
|
|
7618
|
+
.filter(Boolean);
|
|
7619
|
+
const issueNumber = Number(rest.at(-1));
|
|
7620
|
+
if (!owner || !repo || !Number.isInteger(issueNumber))
|
|
7621
|
+
failTest(`[isGithubIssueOpen] Invalid GitHub issue link: ${issueLink}`);
|
|
7622
|
+
const cacheKey = `${owner}/${repo}#${issueNumber}`;
|
|
7623
|
+
const cachedStatus = issueStatusCache.get(cacheKey);
|
|
7624
|
+
if (cachedStatus)
|
|
7625
|
+
return cachedStatus;
|
|
7626
|
+
const status = fetchIsIssueOpen(owner, repo, issueNumber);
|
|
7627
|
+
issueStatusCache.set(cacheKey, status);
|
|
7628
|
+
status.catch(() => issueStatusCache.delete(cacheKey));
|
|
7629
|
+
return status;
|
|
7630
|
+
};
|
|
7631
|
+
const isGithubIssueOpen = async (issueLinks) => {
|
|
7632
|
+
const issueStatuses = await Promise.all(issueLinks.map(isIssueOpen));
|
|
7633
|
+
return issueStatuses.some(Boolean);
|
|
7634
|
+
};
|
|
7709
7635
|
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7636
|
+
const simulateTypingWithDelay = async ({ field, value, delay = 500, }) => {
|
|
7637
|
+
const minSliceLength = Math.max(3, Math.floor(value.length * 0.6));
|
|
7638
|
+
const maxSliceLength = Math.max(4, Math.floor(value.length * 0.8));
|
|
7639
|
+
const sliceLength = Math.floor(Math.random() * (maxSliceLength - minSliceLength + 1)) +
|
|
7640
|
+
minSliceLength;
|
|
7641
|
+
const maxBackspaceCount = Math.max(2, Math.min(4, Math.floor(sliceLength * 0.3)));
|
|
7642
|
+
const backspaceCount = Math.floor(Math.random() * (maxBackspaceCount - 1)) + 2;
|
|
7643
|
+
const textPart1 = value.slice(0, sliceLength);
|
|
7644
|
+
const textPart2 = value.slice(sliceLength - backspaceCount);
|
|
7645
|
+
await field.hover();
|
|
7646
|
+
await field.click({ delay: Math.floor(Math.random() * delay) + 700 });
|
|
7647
|
+
await field.pressSequentially(textPart1, {
|
|
7648
|
+
delay: Math.floor(Math.random() * delay) + 400,
|
|
7649
|
+
timeout: 30_000,
|
|
7650
|
+
});
|
|
7651
|
+
for (let i = 0; i < backspaceCount; i++) {
|
|
7652
|
+
await field.press("Backspace", {
|
|
7653
|
+
delay: Math.floor(Math.random() * 1000) + 300,
|
|
7654
|
+
});
|
|
7716
7655
|
}
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
}
|
|
7730
|
-
|
|
7731
|
-
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
|
7732
|
-
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
|
7733
|
-
});
|
|
7734
|
-
}
|
|
7735
|
-
function encodeValue(operator, value, key) {
|
|
7736
|
-
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
|
|
7737
|
-
if (key) {
|
|
7738
|
-
return encodeUnreserved(key) + "=" + value;
|
|
7739
|
-
} else {
|
|
7740
|
-
return value;
|
|
7741
|
-
}
|
|
7742
|
-
}
|
|
7743
|
-
function isDefined(value) {
|
|
7744
|
-
return value !== void 0 && value !== null;
|
|
7745
|
-
}
|
|
7746
|
-
function isKeyOperator(operator) {
|
|
7747
|
-
return operator === ";" || operator === "&" || operator === "?";
|
|
7748
|
-
}
|
|
7749
|
-
function getValues(context, operator, key, modifier) {
|
|
7750
|
-
var value = context[key], result = [];
|
|
7751
|
-
if (isDefined(value) && value !== "") {
|
|
7752
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean") {
|
|
7753
|
-
value = value.toString();
|
|
7754
|
-
if (modifier && modifier !== "*") {
|
|
7755
|
-
value = value.substring(0, parseInt(modifier, 10));
|
|
7756
|
-
}
|
|
7757
|
-
result.push(
|
|
7758
|
-
encodeValue(operator, value, isKeyOperator(operator) ? key : "")
|
|
7759
|
-
);
|
|
7760
|
-
} else {
|
|
7761
|
-
if (modifier === "*") {
|
|
7762
|
-
if (Array.isArray(value)) {
|
|
7763
|
-
value.filter(isDefined).forEach(function(value2) {
|
|
7764
|
-
result.push(
|
|
7765
|
-
encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
|
|
7766
|
-
);
|
|
7767
|
-
});
|
|
7768
|
-
} else {
|
|
7769
|
-
Object.keys(value).forEach(function(k) {
|
|
7770
|
-
if (isDefined(value[k])) {
|
|
7771
|
-
result.push(encodeValue(operator, value[k], k));
|
|
7772
|
-
}
|
|
7773
|
-
});
|
|
7774
|
-
}
|
|
7775
|
-
} else {
|
|
7776
|
-
const tmp = [];
|
|
7777
|
-
if (Array.isArray(value)) {
|
|
7778
|
-
value.filter(isDefined).forEach(function(value2) {
|
|
7779
|
-
tmp.push(encodeValue(operator, value2));
|
|
7780
|
-
});
|
|
7781
|
-
} else {
|
|
7782
|
-
Object.keys(value).forEach(function(k) {
|
|
7783
|
-
if (isDefined(value[k])) {
|
|
7784
|
-
tmp.push(encodeUnreserved(k));
|
|
7785
|
-
tmp.push(encodeValue(operator, value[k].toString()));
|
|
7786
|
-
}
|
|
7787
|
-
});
|
|
7788
|
-
}
|
|
7789
|
-
if (isKeyOperator(operator)) {
|
|
7790
|
-
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
|
7791
|
-
} else if (tmp.length !== 0) {
|
|
7792
|
-
result.push(tmp.join(","));
|
|
7793
|
-
}
|
|
7794
|
-
}
|
|
7795
|
-
}
|
|
7796
|
-
} else {
|
|
7797
|
-
if (operator === ";") {
|
|
7798
|
-
if (isDefined(value)) {
|
|
7799
|
-
result.push(encodeUnreserved(key));
|
|
7800
|
-
}
|
|
7801
|
-
} else if (value === "" && (operator === "&" || operator === "?")) {
|
|
7802
|
-
result.push(encodeUnreserved(key) + "=");
|
|
7803
|
-
} else if (value === "") {
|
|
7804
|
-
result.push("");
|
|
7805
|
-
}
|
|
7806
|
-
}
|
|
7807
|
-
return result;
|
|
7808
|
-
}
|
|
7809
|
-
function parseUrl(template) {
|
|
7810
|
-
return {
|
|
7811
|
-
expand: expand.bind(null, template)
|
|
7812
|
-
};
|
|
7813
|
-
}
|
|
7814
|
-
function expand(template, context) {
|
|
7815
|
-
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
|
7816
|
-
template = template.replace(
|
|
7817
|
-
/\{([^\{\}]+)\}|([^\{\}]+)/g,
|
|
7818
|
-
function(_, expression, literal) {
|
|
7819
|
-
if (expression) {
|
|
7820
|
-
let operator = "";
|
|
7821
|
-
const values = [];
|
|
7822
|
-
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
|
7823
|
-
operator = expression.charAt(0);
|
|
7824
|
-
expression = expression.substr(1);
|
|
7825
|
-
}
|
|
7826
|
-
expression.split(/,/g).forEach(function(variable) {
|
|
7827
|
-
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
|
7828
|
-
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
|
7829
|
-
});
|
|
7830
|
-
if (operator && operator !== "+") {
|
|
7831
|
-
var separator = ",";
|
|
7832
|
-
if (operator === "?") {
|
|
7833
|
-
separator = "&";
|
|
7834
|
-
} else if (operator !== "#") {
|
|
7835
|
-
separator = operator;
|
|
7836
|
-
}
|
|
7837
|
-
return (values.length !== 0 ? operator : "") + values.join(separator);
|
|
7838
|
-
} else {
|
|
7839
|
-
return values.join(",");
|
|
7840
|
-
}
|
|
7841
|
-
} else {
|
|
7842
|
-
return encodeReserved(literal);
|
|
7843
|
-
}
|
|
7844
|
-
}
|
|
7845
|
-
);
|
|
7846
|
-
if (template === "/") {
|
|
7847
|
-
return template;
|
|
7848
|
-
} else {
|
|
7849
|
-
return template.replace(/\/$/, "");
|
|
7850
|
-
}
|
|
7851
|
-
}
|
|
7852
|
-
|
|
7853
|
-
// pkg/dist-src/parse.js
|
|
7854
|
-
function parse(options) {
|
|
7855
|
-
let method = options.method.toUpperCase();
|
|
7856
|
-
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
|
7857
|
-
let headers = Object.assign({}, options.headers);
|
|
7858
|
-
let body;
|
|
7859
|
-
let parameters = omit(options, [
|
|
7860
|
-
"method",
|
|
7861
|
-
"baseUrl",
|
|
7862
|
-
"url",
|
|
7863
|
-
"headers",
|
|
7864
|
-
"request",
|
|
7865
|
-
"mediaType"
|
|
7866
|
-
]);
|
|
7867
|
-
const urlVariableNames = extractUrlVariableNames(url);
|
|
7868
|
-
url = parseUrl(url).expand(parameters);
|
|
7869
|
-
if (!/^http/.test(url)) {
|
|
7870
|
-
url = options.baseUrl + url;
|
|
7871
|
-
}
|
|
7872
|
-
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl");
|
|
7873
|
-
const remainingParameters = omit(parameters, omittedParameters);
|
|
7874
|
-
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
|
7875
|
-
if (!isBinaryRequest) {
|
|
7876
|
-
if (options.mediaType.format) {
|
|
7877
|
-
headers.accept = headers.accept.split(/,/).map(
|
|
7878
|
-
(format) => format.replace(
|
|
7879
|
-
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,
|
|
7880
|
-
`application/vnd$1$2.${options.mediaType.format}`
|
|
7881
|
-
)
|
|
7882
|
-
).join(",");
|
|
7883
|
-
}
|
|
7884
|
-
if (url.endsWith("/graphql")) {
|
|
7885
|
-
if (options.mediaType.previews?.length) {
|
|
7886
|
-
const previewsFromAcceptHeader = headers.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g) || [];
|
|
7887
|
-
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
|
|
7888
|
-
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
|
|
7889
|
-
return `application/vnd.github.${preview}-preview${format}`;
|
|
7890
|
-
}).join(",");
|
|
7891
|
-
}
|
|
7892
|
-
}
|
|
7893
|
-
}
|
|
7894
|
-
if (["GET", "HEAD"].includes(method)) {
|
|
7895
|
-
url = addQueryParameters(url, remainingParameters);
|
|
7896
|
-
} else {
|
|
7897
|
-
if ("data" in remainingParameters) {
|
|
7898
|
-
body = remainingParameters.data;
|
|
7899
|
-
} else {
|
|
7900
|
-
if (Object.keys(remainingParameters).length) {
|
|
7901
|
-
body = remainingParameters;
|
|
7902
|
-
}
|
|
7903
|
-
}
|
|
7904
|
-
}
|
|
7905
|
-
if (!headers["content-type"] && typeof body !== "undefined") {
|
|
7906
|
-
headers["content-type"] = "application/json; charset=utf-8";
|
|
7907
|
-
}
|
|
7908
|
-
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
|
7909
|
-
body = "";
|
|
7910
|
-
}
|
|
7911
|
-
return Object.assign(
|
|
7912
|
-
{ method, url, headers },
|
|
7913
|
-
typeof body !== "undefined" ? { body } : null,
|
|
7914
|
-
options.request ? { request: options.request } : null
|
|
7915
|
-
);
|
|
7916
|
-
}
|
|
7917
|
-
|
|
7918
|
-
// pkg/dist-src/endpoint-with-defaults.js
|
|
7919
|
-
function endpointWithDefaults(defaults, route, options) {
|
|
7920
|
-
return parse(merge(defaults, route, options));
|
|
7921
|
-
}
|
|
7922
|
-
|
|
7923
|
-
// pkg/dist-src/with-defaults.js
|
|
7924
|
-
function withDefaults$2(oldDefaults, newDefaults) {
|
|
7925
|
-
const DEFAULTS2 = merge(oldDefaults, newDefaults);
|
|
7926
|
-
const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2);
|
|
7927
|
-
return Object.assign(endpoint2, {
|
|
7928
|
-
DEFAULTS: DEFAULTS2,
|
|
7929
|
-
defaults: withDefaults$2.bind(null, DEFAULTS2),
|
|
7930
|
-
merge: merge.bind(null, DEFAULTS2),
|
|
7931
|
-
parse
|
|
7932
|
-
});
|
|
7933
|
-
}
|
|
7934
|
-
|
|
7935
|
-
// pkg/dist-src/index.js
|
|
7936
|
-
var endpoint = withDefaults$2(null, DEFAULTS);
|
|
7937
|
-
|
|
7938
|
-
var fastContentTypeParse = {};
|
|
7939
|
-
|
|
7940
|
-
var hasRequiredFastContentTypeParse;
|
|
7941
|
-
|
|
7942
|
-
function requireFastContentTypeParse () {
|
|
7943
|
-
if (hasRequiredFastContentTypeParse) return fastContentTypeParse;
|
|
7944
|
-
hasRequiredFastContentTypeParse = 1;
|
|
7945
|
-
|
|
7946
|
-
const NullObject = function NullObject () { };
|
|
7947
|
-
NullObject.prototype = Object.create(null);
|
|
7948
|
-
|
|
7949
|
-
/**
|
|
7950
|
-
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
|
|
7951
|
-
*
|
|
7952
|
-
* parameter = token "=" ( token / quoted-string )
|
|
7953
|
-
* token = 1*tchar
|
|
7954
|
-
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
|
|
7955
|
-
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
|
|
7956
|
-
* / DIGIT / ALPHA
|
|
7957
|
-
* ; any VCHAR, except delimiters
|
|
7958
|
-
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
|
|
7959
|
-
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
|
|
7960
|
-
* obs-text = %x80-FF
|
|
7961
|
-
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
7962
|
-
*/
|
|
7963
|
-
const paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
7964
|
-
|
|
7965
|
-
/**
|
|
7966
|
-
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6
|
|
7967
|
-
*
|
|
7968
|
-
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
7969
|
-
* obs-text = %x80-FF
|
|
7970
|
-
*/
|
|
7971
|
-
const quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
|
|
7972
|
-
|
|
7973
|
-
/**
|
|
7974
|
-
* RegExp to match type in RFC 7231 sec 3.1.1.1
|
|
7975
|
-
*
|
|
7976
|
-
* media-type = type "/" subtype
|
|
7977
|
-
* type = token
|
|
7978
|
-
* subtype = token
|
|
7979
|
-
*/
|
|
7980
|
-
const mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u;
|
|
7981
|
-
|
|
7982
|
-
// default ContentType to prevent repeated object creation
|
|
7983
|
-
const defaultContentType = { type: '', parameters: new NullObject() };
|
|
7984
|
-
Object.freeze(defaultContentType.parameters);
|
|
7985
|
-
Object.freeze(defaultContentType);
|
|
7986
|
-
|
|
7987
|
-
/**
|
|
7988
|
-
* Parse media type to object.
|
|
7989
|
-
*
|
|
7990
|
-
* @param {string|object} header
|
|
7991
|
-
* @return {Object}
|
|
7992
|
-
* @public
|
|
7993
|
-
*/
|
|
7994
|
-
|
|
7995
|
-
function parse (header) {
|
|
7996
|
-
if (typeof header !== 'string') {
|
|
7997
|
-
throw new TypeError('argument header is required and must be a string')
|
|
7998
|
-
}
|
|
7999
|
-
|
|
8000
|
-
let index = header.indexOf(';');
|
|
8001
|
-
const type = index !== -1
|
|
8002
|
-
? header.slice(0, index).trim()
|
|
8003
|
-
: header.trim();
|
|
8004
|
-
|
|
8005
|
-
if (mediaTypeRE.test(type) === false) {
|
|
8006
|
-
throw new TypeError('invalid media type')
|
|
8007
|
-
}
|
|
8008
|
-
|
|
8009
|
-
const result = {
|
|
8010
|
-
type: type.toLowerCase(),
|
|
8011
|
-
parameters: new NullObject()
|
|
8012
|
-
};
|
|
8013
|
-
|
|
8014
|
-
// parse parameters
|
|
8015
|
-
if (index === -1) {
|
|
8016
|
-
return result
|
|
8017
|
-
}
|
|
8018
|
-
|
|
8019
|
-
let key;
|
|
8020
|
-
let match;
|
|
8021
|
-
let value;
|
|
8022
|
-
|
|
8023
|
-
paramRE.lastIndex = index;
|
|
8024
|
-
|
|
8025
|
-
while ((match = paramRE.exec(header))) {
|
|
8026
|
-
if (match.index !== index) {
|
|
8027
|
-
throw new TypeError('invalid parameter format')
|
|
8028
|
-
}
|
|
8029
|
-
|
|
8030
|
-
index += match[0].length;
|
|
8031
|
-
key = match[1].toLowerCase();
|
|
8032
|
-
value = match[2];
|
|
8033
|
-
|
|
8034
|
-
if (value[0] === '"') {
|
|
8035
|
-
// remove quotes and escapes
|
|
8036
|
-
value = value
|
|
8037
|
-
.slice(1, value.length - 1);
|
|
8038
|
-
|
|
8039
|
-
quotedPairRE.test(value) && (value = value.replace(quotedPairRE, '$1'));
|
|
8040
|
-
}
|
|
8041
|
-
|
|
8042
|
-
result.parameters[key] = value;
|
|
8043
|
-
}
|
|
8044
|
-
|
|
8045
|
-
if (index !== header.length) {
|
|
8046
|
-
throw new TypeError('invalid parameter format')
|
|
8047
|
-
}
|
|
8048
|
-
|
|
8049
|
-
return result
|
|
8050
|
-
}
|
|
8051
|
-
|
|
8052
|
-
function safeParse (header) {
|
|
8053
|
-
if (typeof header !== 'string') {
|
|
8054
|
-
return defaultContentType
|
|
8055
|
-
}
|
|
8056
|
-
|
|
8057
|
-
let index = header.indexOf(';');
|
|
8058
|
-
const type = index !== -1
|
|
8059
|
-
? header.slice(0, index).trim()
|
|
8060
|
-
: header.trim();
|
|
8061
|
-
|
|
8062
|
-
if (mediaTypeRE.test(type) === false) {
|
|
8063
|
-
return defaultContentType
|
|
8064
|
-
}
|
|
8065
|
-
|
|
8066
|
-
const result = {
|
|
8067
|
-
type: type.toLowerCase(),
|
|
8068
|
-
parameters: new NullObject()
|
|
8069
|
-
};
|
|
8070
|
-
|
|
8071
|
-
// parse parameters
|
|
8072
|
-
if (index === -1) {
|
|
8073
|
-
return result
|
|
8074
|
-
}
|
|
8075
|
-
|
|
8076
|
-
let key;
|
|
8077
|
-
let match;
|
|
8078
|
-
let value;
|
|
8079
|
-
|
|
8080
|
-
paramRE.lastIndex = index;
|
|
8081
|
-
|
|
8082
|
-
while ((match = paramRE.exec(header))) {
|
|
8083
|
-
if (match.index !== index) {
|
|
8084
|
-
return defaultContentType
|
|
8085
|
-
}
|
|
8086
|
-
|
|
8087
|
-
index += match[0].length;
|
|
8088
|
-
key = match[1].toLowerCase();
|
|
8089
|
-
value = match[2];
|
|
8090
|
-
|
|
8091
|
-
if (value[0] === '"') {
|
|
8092
|
-
// remove quotes and escapes
|
|
8093
|
-
value = value
|
|
8094
|
-
.slice(1, value.length - 1);
|
|
8095
|
-
|
|
8096
|
-
quotedPairRE.test(value) && (value = value.replace(quotedPairRE, '$1'));
|
|
8097
|
-
}
|
|
8098
|
-
|
|
8099
|
-
result.parameters[key] = value;
|
|
8100
|
-
}
|
|
8101
|
-
|
|
8102
|
-
if (index !== header.length) {
|
|
8103
|
-
return defaultContentType
|
|
8104
|
-
}
|
|
8105
|
-
|
|
8106
|
-
return result
|
|
8107
|
-
}
|
|
8108
|
-
|
|
8109
|
-
fastContentTypeParse.default = { parse, safeParse };
|
|
8110
|
-
fastContentTypeParse.parse = parse;
|
|
8111
|
-
fastContentTypeParse.safeParse = safeParse;
|
|
8112
|
-
fastContentTypeParse.defaultContentType = defaultContentType;
|
|
8113
|
-
return fastContentTypeParse;
|
|
8114
|
-
}
|
|
8115
|
-
|
|
8116
|
-
var fastContentTypeParseExports = requireFastContentTypeParse();
|
|
8117
|
-
|
|
8118
|
-
const intRegex = /^-?\d+$/;
|
|
8119
|
-
const noiseValue = /^-?\d+n+$/; // Noise - strings that match the custom format before being converted to it
|
|
8120
|
-
const originalStringify = JSON.stringify;
|
|
8121
|
-
const originalParse = JSON.parse;
|
|
8122
|
-
const customFormat = /^-?\d+n$/;
|
|
8123
|
-
|
|
8124
|
-
const bigIntsStringify = /([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g;
|
|
8125
|
-
const noiseStringify =
|
|
8126
|
-
/([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g;
|
|
8127
|
-
|
|
8128
|
-
/** @typedef {(key: string, value: any, context?: { source: string }) => any} Reviver */
|
|
8129
|
-
|
|
8130
|
-
/**
|
|
8131
|
-
* Function to serialize value to a JSON string.
|
|
8132
|
-
* Converts BigInt values to a custom format (strings with digits and "n" at the end) and then converts them to proper big integers in a JSON string.
|
|
8133
|
-
* @param {*} value - The value to convert to a JSON string.
|
|
8134
|
-
* @param {(Function|Array<string>|null)} [replacer] - A function that alters the behavior of the stringification process, or an array of strings to indicate properties to exclude.
|
|
8135
|
-
* @param {(string|number)} [space] - A string or number to specify indentation or pretty-printing.
|
|
8136
|
-
* @returns {string} The JSON string representation.
|
|
8137
|
-
*/
|
|
8138
|
-
const JSONStringify = (value, replacer, space) => {
|
|
8139
|
-
if ("rawJSON" in JSON) {
|
|
8140
|
-
return originalStringify(
|
|
8141
|
-
value,
|
|
8142
|
-
(key, value) => {
|
|
8143
|
-
if (typeof value === "bigint") return JSON.rawJSON(value.toString());
|
|
8144
|
-
|
|
8145
|
-
if (Array.isArray(replacer) && replacer.includes(key)) return value;
|
|
8146
|
-
|
|
8147
|
-
return value;
|
|
8148
|
-
},
|
|
8149
|
-
space,
|
|
8150
|
-
);
|
|
8151
|
-
}
|
|
8152
|
-
|
|
8153
|
-
if (!value) return originalStringify(value, replacer, space);
|
|
8154
|
-
|
|
8155
|
-
const convertedToCustomJSON = originalStringify(
|
|
8156
|
-
value,
|
|
8157
|
-
(key, value) => {
|
|
8158
|
-
const isNoise =
|
|
8159
|
-
typeof value === "string" && Boolean(value.match(noiseValue));
|
|
8160
|
-
|
|
8161
|
-
if (isNoise) return value.toString() + "n"; // Mark noise values with additional "n" to offset the deletion of one "n" during the processing
|
|
8162
|
-
|
|
8163
|
-
if (typeof value === "bigint") return value.toString() + "n";
|
|
8164
|
-
|
|
8165
|
-
if (Array.isArray(replacer) && replacer.includes(key)) return value;
|
|
8166
|
-
|
|
8167
|
-
return value;
|
|
8168
|
-
},
|
|
8169
|
-
space,
|
|
8170
|
-
);
|
|
8171
|
-
const processedJSON = convertedToCustomJSON.replace(
|
|
8172
|
-
bigIntsStringify,
|
|
8173
|
-
"$1$2$3",
|
|
8174
|
-
); // Delete one "n" off the end of every BigInt value
|
|
8175
|
-
const denoisedJSON = processedJSON.replace(noiseStringify, "$1$2$3"); // Remove one "n" off the end of every noisy string
|
|
8176
|
-
|
|
8177
|
-
return denoisedJSON;
|
|
8178
|
-
};
|
|
8179
|
-
|
|
8180
|
-
/**
|
|
8181
|
-
* Support for JSON.parse's context.source feature detection.
|
|
8182
|
-
* @type {boolean}
|
|
8183
|
-
*/
|
|
8184
|
-
const isContextSourceSupported = () =>
|
|
8185
|
-
JSON.parse("1", (_, __, context) => !!context && context.source === "1");
|
|
8186
|
-
|
|
8187
|
-
/**
|
|
8188
|
-
* Convert marked big numbers to BigInt
|
|
8189
|
-
* @type {Reviver}
|
|
8190
|
-
*/
|
|
8191
|
-
const convertMarkedBigIntsReviver = (key, value, context, userReviver) => {
|
|
8192
|
-
const isCustomFormatBigInt =
|
|
8193
|
-
typeof value === "string" && value.match(customFormat);
|
|
8194
|
-
if (isCustomFormatBigInt) return BigInt(value.slice(0, -1));
|
|
8195
|
-
|
|
8196
|
-
const isNoiseValue = typeof value === "string" && value.match(noiseValue);
|
|
8197
|
-
if (isNoiseValue) return value.slice(0, -1);
|
|
8198
|
-
|
|
8199
|
-
return value;
|
|
8200
|
-
};
|
|
8201
|
-
|
|
8202
|
-
/**
|
|
8203
|
-
* Faster (2x) and simpler function to parse JSON.
|
|
8204
|
-
* Based on JSON.parse's context.source feature, which is not universally available now.
|
|
8205
|
-
* Does not support the legacy custom format, used in the first version of this library.
|
|
8206
|
-
*/
|
|
8207
|
-
const JSONParseV2 = (text, reviver) => {
|
|
8208
|
-
return JSON.parse(text, (key, value, context) => {
|
|
8209
|
-
const isBigNumber =
|
|
8210
|
-
typeof value === "number" &&
|
|
8211
|
-
(value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER);
|
|
8212
|
-
const isInt = context && intRegex.test(context.source);
|
|
8213
|
-
const isBigInt = isBigNumber && isInt;
|
|
8214
|
-
|
|
8215
|
-
if (isBigInt) return BigInt(context.source);
|
|
8216
|
-
|
|
8217
|
-
return value;
|
|
8218
|
-
});
|
|
8219
|
-
};
|
|
8220
|
-
|
|
8221
|
-
const MAX_INT = Number.MAX_SAFE_INTEGER.toString();
|
|
8222
|
-
const MAX_DIGITS = MAX_INT.length;
|
|
8223
|
-
const stringsOrLargeNumbers =
|
|
8224
|
-
/"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g;
|
|
8225
|
-
const noiseValueWithQuotes = /^"-?\d+n+"$/; // Noise - strings that match the custom format before being converted to it
|
|
8226
|
-
|
|
8227
|
-
/**
|
|
8228
|
-
* Function to parse JSON.
|
|
8229
|
-
* If JSON has number values greater than Number.MAX_SAFE_INTEGER, we convert those values to a custom format, then parse them to BigInt values.
|
|
8230
|
-
* Other types of values are not affected and parsed as native JSON.parse() would parse them.
|
|
8231
|
-
*/
|
|
8232
|
-
const JSONParse = (text, reviver) => {
|
|
8233
|
-
if (!text) return originalParse(text, reviver);
|
|
8234
|
-
|
|
8235
|
-
if (isContextSourceSupported()) return JSONParseV2(text); // Shortcut to a faster (2x) and simpler version
|
|
8236
|
-
|
|
8237
|
-
// Find and mark big numbers with "n"
|
|
8238
|
-
const serializedData = text.replace(
|
|
8239
|
-
stringsOrLargeNumbers,
|
|
8240
|
-
(text, digits, fractional, exponential) => {
|
|
8241
|
-
const isString = text[0] === '"';
|
|
8242
|
-
const isNoise = isString && Boolean(text.match(noiseValueWithQuotes));
|
|
8243
|
-
|
|
8244
|
-
if (isNoise) return text.substring(0, text.length - 1) + 'n"'; // Mark noise values with additional "n" to offset the deletion of one "n" during the processing
|
|
8245
|
-
|
|
8246
|
-
const isFractionalOrExponential = fractional || exponential;
|
|
8247
|
-
const isLessThanMaxSafeInt =
|
|
8248
|
-
digits &&
|
|
8249
|
-
(digits.length < MAX_DIGITS ||
|
|
8250
|
-
(digits.length === MAX_DIGITS && digits <= MAX_INT)); // With a fixed number of digits, we can correctly use lexicographical comparison to do a numeric comparison
|
|
8251
|
-
|
|
8252
|
-
if (isString || isFractionalOrExponential || isLessThanMaxSafeInt)
|
|
8253
|
-
return text;
|
|
8254
|
-
|
|
8255
|
-
return '"' + text + 'n"';
|
|
8256
|
-
},
|
|
8257
|
-
);
|
|
8258
|
-
|
|
8259
|
-
return originalParse(serializedData, (key, value, context) =>
|
|
8260
|
-
convertMarkedBigIntsReviver(key, value),
|
|
8261
|
-
);
|
|
8262
|
-
};
|
|
8263
|
-
|
|
8264
|
-
class RequestError extends Error {
|
|
8265
|
-
name;
|
|
8266
|
-
/**
|
|
8267
|
-
* http status code
|
|
8268
|
-
*/
|
|
8269
|
-
status;
|
|
8270
|
-
/**
|
|
8271
|
-
* Request options that lead to the error.
|
|
8272
|
-
*/
|
|
8273
|
-
request;
|
|
8274
|
-
/**
|
|
8275
|
-
* Response object if a response was received
|
|
8276
|
-
*/
|
|
8277
|
-
response;
|
|
8278
|
-
constructor(message, statusCode, options) {
|
|
8279
|
-
super(message, { cause: options.cause });
|
|
8280
|
-
this.name = "HttpError";
|
|
8281
|
-
this.status = Number.parseInt(statusCode);
|
|
8282
|
-
if (Number.isNaN(this.status)) {
|
|
8283
|
-
this.status = 0;
|
|
8284
|
-
}
|
|
8285
|
-
/* v8 ignore else -- @preserve -- Bug with vitest coverage where it sees an else branch that doesn't exist */
|
|
8286
|
-
if ("response" in options) {
|
|
8287
|
-
this.response = options.response;
|
|
8288
|
-
}
|
|
8289
|
-
const requestCopy = Object.assign({}, options.request);
|
|
8290
|
-
if (options.request.headers.authorization) {
|
|
8291
|
-
requestCopy.headers = Object.assign({}, options.request.headers, {
|
|
8292
|
-
authorization: options.request.headers.authorization.replace(
|
|
8293
|
-
/(?<! ) .*$/,
|
|
8294
|
-
" [REDACTED]"
|
|
8295
|
-
)
|
|
8296
|
-
});
|
|
8297
|
-
}
|
|
8298
|
-
requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
|
8299
|
-
this.request = requestCopy;
|
|
8300
|
-
}
|
|
8301
|
-
}
|
|
8302
|
-
|
|
8303
|
-
// pkg/dist-src/index.js
|
|
8304
|
-
|
|
8305
|
-
// pkg/dist-src/version.js
|
|
8306
|
-
var VERSION$6 = "10.0.8";
|
|
8307
|
-
|
|
8308
|
-
// pkg/dist-src/defaults.js
|
|
8309
|
-
var defaults_default = {
|
|
8310
|
-
headers: {
|
|
8311
|
-
"user-agent": `octokit-request.js/${VERSION$6} ${getUserAgent()}`
|
|
8312
|
-
}
|
|
8313
|
-
};
|
|
8314
|
-
|
|
8315
|
-
// pkg/dist-src/is-plain-object.js
|
|
8316
|
-
function isPlainObject(value) {
|
|
8317
|
-
if (typeof value !== "object" || value === null) return false;
|
|
8318
|
-
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
8319
|
-
const proto = Object.getPrototypeOf(value);
|
|
8320
|
-
if (proto === null) return true;
|
|
8321
|
-
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
8322
|
-
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
8323
|
-
}
|
|
8324
|
-
var noop$1 = () => "";
|
|
8325
|
-
async function fetchWrapper(requestOptions) {
|
|
8326
|
-
const fetch = requestOptions.request?.fetch || globalThis.fetch;
|
|
8327
|
-
if (!fetch) {
|
|
8328
|
-
throw new Error(
|
|
8329
|
-
"fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing"
|
|
8330
|
-
);
|
|
8331
|
-
}
|
|
8332
|
-
const log = requestOptions.request?.log || console;
|
|
8333
|
-
const parseSuccessResponseBody = requestOptions.request?.parseSuccessResponseBody !== false;
|
|
8334
|
-
const body = isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body) ? JSONStringify(requestOptions.body) : requestOptions.body;
|
|
8335
|
-
const requestHeaders = Object.fromEntries(
|
|
8336
|
-
Object.entries(requestOptions.headers).map(([name, value]) => [
|
|
8337
|
-
name,
|
|
8338
|
-
String(value)
|
|
8339
|
-
])
|
|
8340
|
-
);
|
|
8341
|
-
let fetchResponse;
|
|
8342
|
-
try {
|
|
8343
|
-
fetchResponse = await fetch(requestOptions.url, {
|
|
8344
|
-
method: requestOptions.method,
|
|
8345
|
-
body,
|
|
8346
|
-
redirect: requestOptions.request?.redirect,
|
|
8347
|
-
headers: requestHeaders,
|
|
8348
|
-
signal: requestOptions.request?.signal,
|
|
8349
|
-
// duplex must be set if request.body is ReadableStream or Async Iterables.
|
|
8350
|
-
// See https://fetch.spec.whatwg.org/#dom-requestinit-duplex.
|
|
8351
|
-
...requestOptions.body && { duplex: "half" }
|
|
8352
|
-
});
|
|
8353
|
-
} catch (error) {
|
|
8354
|
-
let message = "Unknown Error";
|
|
8355
|
-
if (error instanceof Error) {
|
|
8356
|
-
if (error.name === "AbortError") {
|
|
8357
|
-
error.status = 500;
|
|
8358
|
-
throw error;
|
|
8359
|
-
}
|
|
8360
|
-
message = error.message;
|
|
8361
|
-
if (error.name === "TypeError" && "cause" in error) {
|
|
8362
|
-
if (error.cause instanceof Error) {
|
|
8363
|
-
message = error.cause.message;
|
|
8364
|
-
} else if (typeof error.cause === "string") {
|
|
8365
|
-
message = error.cause;
|
|
8366
|
-
}
|
|
8367
|
-
}
|
|
8368
|
-
}
|
|
8369
|
-
const requestError = new RequestError(message, 500, {
|
|
8370
|
-
request: requestOptions
|
|
8371
|
-
});
|
|
8372
|
-
requestError.cause = error;
|
|
8373
|
-
throw requestError;
|
|
8374
|
-
}
|
|
8375
|
-
const status = fetchResponse.status;
|
|
8376
|
-
const url = fetchResponse.url;
|
|
8377
|
-
const responseHeaders = {};
|
|
8378
|
-
for (const [key, value] of fetchResponse.headers) {
|
|
8379
|
-
responseHeaders[key] = value;
|
|
8380
|
-
}
|
|
8381
|
-
const octokitResponse = {
|
|
8382
|
-
url,
|
|
8383
|
-
status,
|
|
8384
|
-
headers: responseHeaders,
|
|
8385
|
-
data: ""
|
|
8386
|
-
};
|
|
8387
|
-
if ("deprecation" in responseHeaders) {
|
|
8388
|
-
const matches = responseHeaders.link && responseHeaders.link.match(/<([^<>]+)>; rel="deprecation"/);
|
|
8389
|
-
const deprecationLink = matches && matches.pop();
|
|
8390
|
-
log.warn(
|
|
8391
|
-
`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${responseHeaders.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`
|
|
8392
|
-
);
|
|
8393
|
-
}
|
|
8394
|
-
if (status === 204 || status === 205) {
|
|
8395
|
-
return octokitResponse;
|
|
8396
|
-
}
|
|
8397
|
-
if (requestOptions.method === "HEAD") {
|
|
8398
|
-
if (status < 400) {
|
|
8399
|
-
return octokitResponse;
|
|
8400
|
-
}
|
|
8401
|
-
throw new RequestError(fetchResponse.statusText, status, {
|
|
8402
|
-
response: octokitResponse,
|
|
8403
|
-
request: requestOptions
|
|
8404
|
-
});
|
|
8405
|
-
}
|
|
8406
|
-
if (status === 304) {
|
|
8407
|
-
octokitResponse.data = await getResponseData(fetchResponse);
|
|
8408
|
-
throw new RequestError("Not modified", status, {
|
|
8409
|
-
response: octokitResponse,
|
|
8410
|
-
request: requestOptions
|
|
8411
|
-
});
|
|
8412
|
-
}
|
|
8413
|
-
if (status >= 400) {
|
|
8414
|
-
octokitResponse.data = await getResponseData(fetchResponse);
|
|
8415
|
-
throw new RequestError(toErrorMessage(octokitResponse.data), status, {
|
|
8416
|
-
response: octokitResponse,
|
|
8417
|
-
request: requestOptions
|
|
8418
|
-
});
|
|
8419
|
-
}
|
|
8420
|
-
octokitResponse.data = parseSuccessResponseBody ? await getResponseData(fetchResponse) : fetchResponse.body;
|
|
8421
|
-
return octokitResponse;
|
|
8422
|
-
}
|
|
8423
|
-
async function getResponseData(response) {
|
|
8424
|
-
const contentType = response.headers.get("content-type");
|
|
8425
|
-
if (!contentType) {
|
|
8426
|
-
return response.text().catch(noop$1);
|
|
8427
|
-
}
|
|
8428
|
-
const mimetype = fastContentTypeParseExports.safeParse(contentType);
|
|
8429
|
-
if (isJSONResponse(mimetype)) {
|
|
8430
|
-
let text = "";
|
|
8431
|
-
try {
|
|
8432
|
-
text = await response.text();
|
|
8433
|
-
return JSONParse(text);
|
|
8434
|
-
} catch (err) {
|
|
8435
|
-
return text;
|
|
8436
|
-
}
|
|
8437
|
-
} else if (mimetype.type.startsWith("text/") || mimetype.parameters.charset?.toLowerCase() === "utf-8") {
|
|
8438
|
-
return response.text().catch(noop$1);
|
|
8439
|
-
} else {
|
|
8440
|
-
return response.arrayBuffer().catch(
|
|
8441
|
-
/* v8 ignore next -- @preserve */
|
|
8442
|
-
() => new ArrayBuffer(0)
|
|
8443
|
-
);
|
|
8444
|
-
}
|
|
8445
|
-
}
|
|
8446
|
-
function isJSONResponse(mimetype) {
|
|
8447
|
-
return mimetype.type === "application/json" || mimetype.type === "application/scim+json";
|
|
8448
|
-
}
|
|
8449
|
-
function toErrorMessage(data) {
|
|
8450
|
-
if (typeof data === "string") {
|
|
8451
|
-
return data;
|
|
8452
|
-
}
|
|
8453
|
-
if (data instanceof ArrayBuffer) {
|
|
8454
|
-
return "Unknown error";
|
|
8455
|
-
}
|
|
8456
|
-
if ("message" in data) {
|
|
8457
|
-
const suffix = "documentation_url" in data ? ` - ${data.documentation_url}` : "";
|
|
8458
|
-
return Array.isArray(data.errors) ? `${data.message}: ${data.errors.map((v) => JSON.stringify(v)).join(", ")}${suffix}` : `${data.message}${suffix}`;
|
|
8459
|
-
}
|
|
8460
|
-
return `Unknown error: ${JSON.stringify(data)}`;
|
|
8461
|
-
}
|
|
8462
|
-
|
|
8463
|
-
// pkg/dist-src/with-defaults.js
|
|
8464
|
-
function withDefaults$1(oldEndpoint, newDefaults) {
|
|
8465
|
-
const endpoint2 = oldEndpoint.defaults(newDefaults);
|
|
8466
|
-
const newApi = function(route, parameters) {
|
|
8467
|
-
const endpointOptions = endpoint2.merge(route, parameters);
|
|
8468
|
-
if (!endpointOptions.request || !endpointOptions.request.hook) {
|
|
8469
|
-
return fetchWrapper(endpoint2.parse(endpointOptions));
|
|
8470
|
-
}
|
|
8471
|
-
const request2 = (route2, parameters2) => {
|
|
8472
|
-
return fetchWrapper(
|
|
8473
|
-
endpoint2.parse(endpoint2.merge(route2, parameters2))
|
|
8474
|
-
);
|
|
8475
|
-
};
|
|
8476
|
-
Object.assign(request2, {
|
|
8477
|
-
endpoint: endpoint2,
|
|
8478
|
-
defaults: withDefaults$1.bind(null, endpoint2)
|
|
8479
|
-
});
|
|
8480
|
-
return endpointOptions.request.hook(request2, endpointOptions);
|
|
8481
|
-
};
|
|
8482
|
-
return Object.assign(newApi, {
|
|
8483
|
-
endpoint: endpoint2,
|
|
8484
|
-
defaults: withDefaults$1.bind(null, endpoint2)
|
|
8485
|
-
});
|
|
8486
|
-
}
|
|
8487
|
-
|
|
8488
|
-
// pkg/dist-src/index.js
|
|
8489
|
-
var request = withDefaults$1(endpoint, defaults_default);
|
|
8490
|
-
/* v8 ignore next -- @preserve */
|
|
8491
|
-
/* v8 ignore else -- @preserve */
|
|
8492
|
-
|
|
8493
|
-
// pkg/dist-src/version.js
|
|
8494
|
-
function requestToOAuthBaseUrl$1(request) {
|
|
8495
|
-
const endpointDefaults = request.endpoint.DEFAULTS;
|
|
8496
|
-
return /^https:\/\/(api\.)?github\.com$/.test(endpointDefaults.baseUrl) ? "https://github.com" : endpointDefaults.baseUrl.replace("/api/v3", "");
|
|
8497
|
-
}
|
|
8498
|
-
async function oauthRequest$1(request, route, parameters) {
|
|
8499
|
-
const withOAuthParameters = {
|
|
8500
|
-
baseUrl: requestToOAuthBaseUrl$1(request),
|
|
8501
|
-
headers: {
|
|
8502
|
-
accept: "application/json"
|
|
8503
|
-
},
|
|
8504
|
-
...parameters
|
|
8505
|
-
};
|
|
8506
|
-
const response = await request(route, withOAuthParameters);
|
|
8507
|
-
if ("error" in response.data) {
|
|
8508
|
-
const error = new RequestError(
|
|
8509
|
-
`${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`,
|
|
8510
|
-
400,
|
|
8511
|
-
{
|
|
8512
|
-
request: request.endpoint.merge(
|
|
8513
|
-
route,
|
|
8514
|
-
withOAuthParameters
|
|
8515
|
-
)
|
|
8516
|
-
}
|
|
8517
|
-
);
|
|
8518
|
-
error.response = response;
|
|
8519
|
-
throw error;
|
|
8520
|
-
}
|
|
8521
|
-
return response;
|
|
8522
|
-
}
|
|
8523
|
-
async function createDeviceCode(options) {
|
|
8524
|
-
const request$1 = options.request || request;
|
|
8525
|
-
const parameters = {
|
|
8526
|
-
client_id: options.clientId
|
|
8527
|
-
};
|
|
8528
|
-
if ("scopes" in options && Array.isArray(options.scopes)) {
|
|
8529
|
-
parameters.scope = options.scopes.join(" ");
|
|
8530
|
-
}
|
|
8531
|
-
return oauthRequest$1(request$1, "POST /login/device/code", parameters);
|
|
8532
|
-
}
|
|
8533
|
-
async function exchangeDeviceCode(options) {
|
|
8534
|
-
const request$1 = options.request || request;
|
|
8535
|
-
const response = await oauthRequest$1(
|
|
8536
|
-
request$1,
|
|
8537
|
-
"POST /login/oauth/access_token",
|
|
8538
|
-
{
|
|
8539
|
-
client_id: options.clientId,
|
|
8540
|
-
device_code: options.code,
|
|
8541
|
-
grant_type: "urn:ietf:params:oauth:grant-type:device_code"
|
|
8542
|
-
}
|
|
8543
|
-
);
|
|
8544
|
-
const authentication = {
|
|
8545
|
-
clientType: options.clientType,
|
|
8546
|
-
clientId: options.clientId,
|
|
8547
|
-
token: response.data.access_token,
|
|
8548
|
-
scopes: response.data.scope.split(/\s+/).filter(Boolean)
|
|
8549
|
-
};
|
|
8550
|
-
if ("clientSecret" in options) {
|
|
8551
|
-
authentication.clientSecret = options.clientSecret;
|
|
8552
|
-
}
|
|
8553
|
-
if (options.clientType === "github-app") {
|
|
8554
|
-
if ("refresh_token" in response.data) {
|
|
8555
|
-
const apiTimeInMs = new Date(response.headers.date).getTime();
|
|
8556
|
-
authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp2(
|
|
8557
|
-
apiTimeInMs,
|
|
8558
|
-
response.data.expires_in
|
|
8559
|
-
), authentication.refreshTokenExpiresAt = toTimestamp2(
|
|
8560
|
-
apiTimeInMs,
|
|
8561
|
-
response.data.refresh_token_expires_in
|
|
8562
|
-
);
|
|
8563
|
-
}
|
|
8564
|
-
delete authentication.scopes;
|
|
8565
|
-
}
|
|
8566
|
-
return { ...response, authentication };
|
|
8567
|
-
}
|
|
8568
|
-
function toTimestamp2(apiTimeInMs, expirationInSeconds) {
|
|
8569
|
-
return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
|
|
8570
|
-
}
|
|
8571
|
-
|
|
8572
|
-
// pkg/dist-src/index.js
|
|
8573
|
-
async function getOAuthAccessToken(state, options) {
|
|
8574
|
-
const cachedAuthentication = getCachedAuthentication(state, options.auth);
|
|
8575
|
-
if (cachedAuthentication) return cachedAuthentication;
|
|
8576
|
-
const { data: verification } = await createDeviceCode({
|
|
8577
|
-
clientType: state.clientType,
|
|
8578
|
-
clientId: state.clientId,
|
|
8579
|
-
request: options.request || state.request,
|
|
8580
|
-
// @ts-expect-error the extra code to make TS happy is not worth it
|
|
8581
|
-
scopes: options.auth.scopes || state.scopes
|
|
8582
|
-
});
|
|
8583
|
-
await state.onVerification(verification);
|
|
8584
|
-
const authentication = await waitForAccessToken(
|
|
8585
|
-
options.request || state.request,
|
|
8586
|
-
state.clientId,
|
|
8587
|
-
state.clientType,
|
|
8588
|
-
verification
|
|
8589
|
-
);
|
|
8590
|
-
state.authentication = authentication;
|
|
8591
|
-
return authentication;
|
|
8592
|
-
}
|
|
8593
|
-
function getCachedAuthentication(state, auth2) {
|
|
8594
|
-
if (auth2.refresh === true) return false;
|
|
8595
|
-
if (!state.authentication) return false;
|
|
8596
|
-
if (state.clientType === "github-app") {
|
|
8597
|
-
return state.authentication;
|
|
8598
|
-
}
|
|
8599
|
-
const authentication = state.authentication;
|
|
8600
|
-
const newScope = ("scopes" in auth2 && auth2.scopes || state.scopes).join(
|
|
8601
|
-
" "
|
|
8602
|
-
);
|
|
8603
|
-
const currentScope = authentication.scopes.join(" ");
|
|
8604
|
-
return newScope === currentScope ? authentication : false;
|
|
8605
|
-
}
|
|
8606
|
-
async function wait(seconds) {
|
|
8607
|
-
await new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
|
|
8608
|
-
}
|
|
8609
|
-
async function waitForAccessToken(request, clientId, clientType, verification) {
|
|
8610
|
-
try {
|
|
8611
|
-
const options = {
|
|
8612
|
-
clientId,
|
|
8613
|
-
request,
|
|
8614
|
-
code: verification.device_code
|
|
8615
|
-
};
|
|
8616
|
-
const { authentication } = clientType === "oauth-app" ? await exchangeDeviceCode({
|
|
8617
|
-
...options,
|
|
8618
|
-
clientType: "oauth-app"
|
|
8619
|
-
}) : await exchangeDeviceCode({
|
|
8620
|
-
...options,
|
|
8621
|
-
clientType: "github-app"
|
|
8622
|
-
});
|
|
8623
|
-
return {
|
|
8624
|
-
type: "token",
|
|
8625
|
-
tokenType: "oauth",
|
|
8626
|
-
...authentication
|
|
8627
|
-
};
|
|
8628
|
-
} catch (error) {
|
|
8629
|
-
if (!error.response) throw error;
|
|
8630
|
-
const errorType = error.response.data.error;
|
|
8631
|
-
if (errorType === "authorization_pending") {
|
|
8632
|
-
await wait(verification.interval);
|
|
8633
|
-
return waitForAccessToken(request, clientId, clientType, verification);
|
|
8634
|
-
}
|
|
8635
|
-
if (errorType === "slow_down") {
|
|
8636
|
-
await wait(verification.interval + 7);
|
|
8637
|
-
return waitForAccessToken(request, clientId, clientType, verification);
|
|
8638
|
-
}
|
|
8639
|
-
throw error;
|
|
8640
|
-
}
|
|
8641
|
-
}
|
|
8642
|
-
|
|
8643
|
-
// pkg/dist-src/auth.js
|
|
8644
|
-
async function auth$4(state, authOptions) {
|
|
8645
|
-
return getOAuthAccessToken(state, {
|
|
8646
|
-
auth: authOptions
|
|
8647
|
-
});
|
|
8648
|
-
}
|
|
8649
|
-
|
|
8650
|
-
// pkg/dist-src/hook.js
|
|
8651
|
-
async function hook$4(state, request, route, parameters) {
|
|
8652
|
-
let endpoint = request.endpoint.merge(
|
|
8653
|
-
route,
|
|
8654
|
-
parameters
|
|
8655
|
-
);
|
|
8656
|
-
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
|
8657
|
-
return request(endpoint);
|
|
8658
|
-
}
|
|
8659
|
-
const { token } = await getOAuthAccessToken(state, {
|
|
8660
|
-
request,
|
|
8661
|
-
auth: { type: "oauth" }
|
|
8662
|
-
});
|
|
8663
|
-
endpoint.headers.authorization = `token ${token}`;
|
|
8664
|
-
return request(endpoint);
|
|
8665
|
-
}
|
|
8666
|
-
|
|
8667
|
-
// pkg/dist-src/version.js
|
|
8668
|
-
var VERSION$5 = "0.0.0-development";
|
|
8669
|
-
|
|
8670
|
-
// pkg/dist-src/index.js
|
|
8671
|
-
function createOAuthDeviceAuth(options) {
|
|
8672
|
-
const requestWithDefaults = options.request || request.defaults({
|
|
8673
|
-
headers: {
|
|
8674
|
-
"user-agent": `octokit-auth-oauth-device.js/${VERSION$5} ${getUserAgent()}`
|
|
8675
|
-
}
|
|
8676
|
-
});
|
|
8677
|
-
const { request: request$1 = requestWithDefaults, ...otherOptions } = options;
|
|
8678
|
-
const state = options.clientType === "github-app" ? {
|
|
8679
|
-
...otherOptions,
|
|
8680
|
-
clientType: "github-app",
|
|
8681
|
-
request: request$1
|
|
8682
|
-
} : {
|
|
8683
|
-
...otherOptions,
|
|
8684
|
-
clientType: "oauth-app",
|
|
8685
|
-
request: request$1,
|
|
8686
|
-
scopes: options.scopes || []
|
|
8687
|
-
};
|
|
8688
|
-
if (!options.clientId) {
|
|
8689
|
-
throw new Error(
|
|
8690
|
-
'[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)'
|
|
8691
|
-
);
|
|
8692
|
-
}
|
|
8693
|
-
if (!options.onVerification) {
|
|
8694
|
-
throw new Error(
|
|
8695
|
-
'[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)'
|
|
8696
|
-
);
|
|
8697
|
-
}
|
|
8698
|
-
return Object.assign(auth$4.bind(null, state), {
|
|
8699
|
-
hook: hook$4.bind(null, state)
|
|
8700
|
-
});
|
|
8701
|
-
}
|
|
8702
|
-
|
|
8703
|
-
// pkg/dist-src/version.js
|
|
8704
|
-
function requestToOAuthBaseUrl(request) {
|
|
8705
|
-
const endpointDefaults = request.endpoint.DEFAULTS;
|
|
8706
|
-
return /^https:\/\/(api\.)?github\.com$/.test(endpointDefaults.baseUrl) ? "https://github.com" : endpointDefaults.baseUrl.replace("/api/v3", "");
|
|
8707
|
-
}
|
|
8708
|
-
async function oauthRequest(request, route, parameters) {
|
|
8709
|
-
const withOAuthParameters = {
|
|
8710
|
-
baseUrl: requestToOAuthBaseUrl(request),
|
|
8711
|
-
headers: {
|
|
8712
|
-
accept: "application/json"
|
|
8713
|
-
},
|
|
8714
|
-
...parameters
|
|
8715
|
-
};
|
|
8716
|
-
const response = await request(route, withOAuthParameters);
|
|
8717
|
-
if ("error" in response.data) {
|
|
8718
|
-
const error = new RequestError(
|
|
8719
|
-
`${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`,
|
|
8720
|
-
400,
|
|
8721
|
-
{
|
|
8722
|
-
request: request.endpoint.merge(
|
|
8723
|
-
route,
|
|
8724
|
-
withOAuthParameters
|
|
8725
|
-
)
|
|
8726
|
-
}
|
|
8727
|
-
);
|
|
8728
|
-
error.response = response;
|
|
8729
|
-
throw error;
|
|
8730
|
-
}
|
|
8731
|
-
return response;
|
|
8732
|
-
}
|
|
8733
|
-
async function exchangeWebFlowCode(options) {
|
|
8734
|
-
const request$1 = options.request || request;
|
|
8735
|
-
const response = await oauthRequest(
|
|
8736
|
-
request$1,
|
|
8737
|
-
"POST /login/oauth/access_token",
|
|
8738
|
-
{
|
|
8739
|
-
client_id: options.clientId,
|
|
8740
|
-
client_secret: options.clientSecret,
|
|
8741
|
-
code: options.code,
|
|
8742
|
-
redirect_uri: options.redirectUrl
|
|
8743
|
-
}
|
|
8744
|
-
);
|
|
8745
|
-
const authentication = {
|
|
8746
|
-
clientType: options.clientType,
|
|
8747
|
-
clientId: options.clientId,
|
|
8748
|
-
clientSecret: options.clientSecret,
|
|
8749
|
-
token: response.data.access_token,
|
|
8750
|
-
scopes: response.data.scope.split(/\s+/).filter(Boolean)
|
|
8751
|
-
};
|
|
8752
|
-
if (options.clientType === "github-app") {
|
|
8753
|
-
if ("refresh_token" in response.data) {
|
|
8754
|
-
const apiTimeInMs = new Date(response.headers.date).getTime();
|
|
8755
|
-
authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp(
|
|
8756
|
-
apiTimeInMs,
|
|
8757
|
-
response.data.expires_in
|
|
8758
|
-
), authentication.refreshTokenExpiresAt = toTimestamp(
|
|
8759
|
-
apiTimeInMs,
|
|
8760
|
-
response.data.refresh_token_expires_in
|
|
8761
|
-
);
|
|
8762
|
-
}
|
|
8763
|
-
delete authentication.scopes;
|
|
8764
|
-
}
|
|
8765
|
-
return { ...response, authentication };
|
|
8766
|
-
}
|
|
8767
|
-
function toTimestamp(apiTimeInMs, expirationInSeconds) {
|
|
8768
|
-
return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
|
|
8769
|
-
}
|
|
8770
|
-
async function checkToken(options) {
|
|
8771
|
-
const request$1 = options.request || request;
|
|
8772
|
-
const response = await request$1("POST /applications/{client_id}/token", {
|
|
8773
|
-
headers: {
|
|
8774
|
-
authorization: `basic ${btoa(
|
|
8775
|
-
`${options.clientId}:${options.clientSecret}`
|
|
8776
|
-
)}`
|
|
8777
|
-
},
|
|
8778
|
-
client_id: options.clientId,
|
|
8779
|
-
access_token: options.token
|
|
8780
|
-
});
|
|
8781
|
-
const authentication = {
|
|
8782
|
-
clientType: options.clientType,
|
|
8783
|
-
clientId: options.clientId,
|
|
8784
|
-
clientSecret: options.clientSecret,
|
|
8785
|
-
token: options.token,
|
|
8786
|
-
scopes: response.data.scopes
|
|
8787
|
-
};
|
|
8788
|
-
if (response.data.expires_at)
|
|
8789
|
-
authentication.expiresAt = response.data.expires_at;
|
|
8790
|
-
if (options.clientType === "github-app") {
|
|
8791
|
-
delete authentication.scopes;
|
|
8792
|
-
}
|
|
8793
|
-
return { ...response, authentication };
|
|
8794
|
-
}
|
|
8795
|
-
async function refreshToken(options) {
|
|
8796
|
-
const request$1 = options.request || request;
|
|
8797
|
-
const response = await oauthRequest(
|
|
8798
|
-
request$1,
|
|
8799
|
-
"POST /login/oauth/access_token",
|
|
8800
|
-
{
|
|
8801
|
-
client_id: options.clientId,
|
|
8802
|
-
client_secret: options.clientSecret,
|
|
8803
|
-
grant_type: "refresh_token",
|
|
8804
|
-
refresh_token: options.refreshToken
|
|
8805
|
-
}
|
|
8806
|
-
);
|
|
8807
|
-
const apiTimeInMs = new Date(response.headers.date).getTime();
|
|
8808
|
-
const authentication = {
|
|
8809
|
-
clientType: "github-app",
|
|
8810
|
-
clientId: options.clientId,
|
|
8811
|
-
clientSecret: options.clientSecret,
|
|
8812
|
-
token: response.data.access_token,
|
|
8813
|
-
refreshToken: response.data.refresh_token,
|
|
8814
|
-
expiresAt: toTimestamp3(apiTimeInMs, response.data.expires_in),
|
|
8815
|
-
refreshTokenExpiresAt: toTimestamp3(
|
|
8816
|
-
apiTimeInMs,
|
|
8817
|
-
response.data.refresh_token_expires_in
|
|
8818
|
-
)
|
|
8819
|
-
};
|
|
8820
|
-
return { ...response, authentication };
|
|
8821
|
-
}
|
|
8822
|
-
function toTimestamp3(apiTimeInMs, expirationInSeconds) {
|
|
8823
|
-
return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
|
|
8824
|
-
}
|
|
8825
|
-
async function resetToken(options) {
|
|
8826
|
-
const request$1 = options.request || request;
|
|
8827
|
-
const auth = btoa(`${options.clientId}:${options.clientSecret}`);
|
|
8828
|
-
const response = await request$1(
|
|
8829
|
-
"PATCH /applications/{client_id}/token",
|
|
8830
|
-
{
|
|
8831
|
-
headers: {
|
|
8832
|
-
authorization: `basic ${auth}`
|
|
8833
|
-
},
|
|
8834
|
-
client_id: options.clientId,
|
|
8835
|
-
access_token: options.token
|
|
8836
|
-
}
|
|
8837
|
-
);
|
|
8838
|
-
const authentication = {
|
|
8839
|
-
clientType: options.clientType,
|
|
8840
|
-
clientId: options.clientId,
|
|
8841
|
-
clientSecret: options.clientSecret,
|
|
8842
|
-
token: response.data.token,
|
|
8843
|
-
scopes: response.data.scopes
|
|
8844
|
-
};
|
|
8845
|
-
if (response.data.expires_at)
|
|
8846
|
-
authentication.expiresAt = response.data.expires_at;
|
|
8847
|
-
if (options.clientType === "github-app") {
|
|
8848
|
-
delete authentication.scopes;
|
|
8849
|
-
}
|
|
8850
|
-
return { ...response, authentication };
|
|
8851
|
-
}
|
|
8852
|
-
async function deleteToken(options) {
|
|
8853
|
-
const request$1 = options.request || request;
|
|
8854
|
-
const auth = btoa(`${options.clientId}:${options.clientSecret}`);
|
|
8855
|
-
return request$1(
|
|
8856
|
-
"DELETE /applications/{client_id}/token",
|
|
8857
|
-
{
|
|
8858
|
-
headers: {
|
|
8859
|
-
authorization: `basic ${auth}`
|
|
8860
|
-
},
|
|
8861
|
-
client_id: options.clientId,
|
|
8862
|
-
access_token: options.token
|
|
8863
|
-
}
|
|
8864
|
-
);
|
|
8865
|
-
}
|
|
8866
|
-
async function deleteAuthorization(options) {
|
|
8867
|
-
const request$1 = options.request || request;
|
|
8868
|
-
const auth = btoa(`${options.clientId}:${options.clientSecret}`);
|
|
8869
|
-
return request$1(
|
|
8870
|
-
"DELETE /applications/{client_id}/grant",
|
|
8871
|
-
{
|
|
8872
|
-
headers: {
|
|
8873
|
-
authorization: `basic ${auth}`
|
|
8874
|
-
},
|
|
8875
|
-
client_id: options.clientId,
|
|
8876
|
-
access_token: options.token
|
|
8877
|
-
}
|
|
8878
|
-
);
|
|
8879
|
-
}
|
|
8880
|
-
|
|
8881
|
-
// pkg/dist-src/index.js
|
|
8882
|
-
|
|
8883
|
-
// pkg/dist-src/version.js
|
|
8884
|
-
var VERSION$4 = "0.0.0-development";
|
|
8885
|
-
async function getAuthentication(state) {
|
|
8886
|
-
if ("code" in state.strategyOptions) {
|
|
8887
|
-
const { authentication } = await exchangeWebFlowCode({
|
|
8888
|
-
clientId: state.clientId,
|
|
8889
|
-
clientSecret: state.clientSecret,
|
|
8890
|
-
clientType: state.clientType,
|
|
8891
|
-
onTokenCreated: state.onTokenCreated,
|
|
8892
|
-
...state.strategyOptions,
|
|
8893
|
-
request: state.request
|
|
8894
|
-
});
|
|
8895
|
-
return {
|
|
8896
|
-
type: "token",
|
|
8897
|
-
tokenType: "oauth",
|
|
8898
|
-
...authentication
|
|
8899
|
-
};
|
|
8900
|
-
}
|
|
8901
|
-
if ("onVerification" in state.strategyOptions) {
|
|
8902
|
-
const deviceAuth = createOAuthDeviceAuth({
|
|
8903
|
-
clientType: state.clientType,
|
|
8904
|
-
clientId: state.clientId,
|
|
8905
|
-
onTokenCreated: state.onTokenCreated,
|
|
8906
|
-
...state.strategyOptions,
|
|
8907
|
-
request: state.request
|
|
8908
|
-
});
|
|
8909
|
-
const authentication = await deviceAuth({
|
|
8910
|
-
type: "oauth"
|
|
8911
|
-
});
|
|
8912
|
-
return {
|
|
8913
|
-
clientSecret: state.clientSecret,
|
|
8914
|
-
...authentication
|
|
8915
|
-
};
|
|
8916
|
-
}
|
|
8917
|
-
if ("token" in state.strategyOptions) {
|
|
8918
|
-
return {
|
|
8919
|
-
type: "token",
|
|
8920
|
-
tokenType: "oauth",
|
|
8921
|
-
clientId: state.clientId,
|
|
8922
|
-
clientSecret: state.clientSecret,
|
|
8923
|
-
clientType: state.clientType,
|
|
8924
|
-
onTokenCreated: state.onTokenCreated,
|
|
8925
|
-
...state.strategyOptions
|
|
8926
|
-
};
|
|
8927
|
-
}
|
|
8928
|
-
throw new Error("[@octokit/auth-oauth-user] Invalid strategy options");
|
|
8929
|
-
}
|
|
8930
|
-
async function auth$3(state, options = {}) {
|
|
8931
|
-
if (!state.authentication) {
|
|
8932
|
-
state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state);
|
|
8933
|
-
}
|
|
8934
|
-
if (state.authentication.invalid) {
|
|
8935
|
-
throw new Error("[@octokit/auth-oauth-user] Token is invalid");
|
|
8936
|
-
}
|
|
8937
|
-
const currentAuthentication = state.authentication;
|
|
8938
|
-
if ("expiresAt" in currentAuthentication) {
|
|
8939
|
-
if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ new Date()) {
|
|
8940
|
-
const { authentication } = await refreshToken({
|
|
8941
|
-
clientId: state.clientId,
|
|
8942
|
-
clientSecret: state.clientSecret,
|
|
8943
|
-
refreshToken: currentAuthentication.refreshToken,
|
|
8944
|
-
request: state.request
|
|
8945
|
-
});
|
|
8946
|
-
state.authentication = {
|
|
8947
|
-
tokenType: "oauth",
|
|
8948
|
-
type: "token",
|
|
8949
|
-
...authentication
|
|
8950
|
-
};
|
|
8951
|
-
}
|
|
8952
|
-
}
|
|
8953
|
-
if (options.type === "refresh") {
|
|
8954
|
-
if (state.clientType === "oauth-app") {
|
|
8955
|
-
throw new Error(
|
|
8956
|
-
"[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens"
|
|
8957
|
-
);
|
|
8958
|
-
}
|
|
8959
|
-
if (!currentAuthentication.hasOwnProperty("expiresAt")) {
|
|
8960
|
-
throw new Error("[@octokit/auth-oauth-user] Refresh token missing");
|
|
8961
|
-
}
|
|
8962
|
-
await state.onTokenCreated?.(state.authentication, {
|
|
8963
|
-
type: options.type
|
|
8964
|
-
});
|
|
8965
|
-
}
|
|
8966
|
-
if (options.type === "check" || options.type === "reset") {
|
|
8967
|
-
const method = options.type === "check" ? checkToken : resetToken;
|
|
8968
|
-
try {
|
|
8969
|
-
const { authentication } = await method({
|
|
8970
|
-
// @ts-expect-error making TS happy would require unnecessary code so no
|
|
8971
|
-
clientType: state.clientType,
|
|
8972
|
-
clientId: state.clientId,
|
|
8973
|
-
clientSecret: state.clientSecret,
|
|
8974
|
-
token: state.authentication.token,
|
|
8975
|
-
request: state.request
|
|
8976
|
-
});
|
|
8977
|
-
state.authentication = {
|
|
8978
|
-
tokenType: "oauth",
|
|
8979
|
-
type: "token",
|
|
8980
|
-
// @ts-expect-error TBD
|
|
8981
|
-
...authentication
|
|
8982
|
-
};
|
|
8983
|
-
if (options.type === "reset") {
|
|
8984
|
-
await state.onTokenCreated?.(state.authentication, {
|
|
8985
|
-
type: options.type
|
|
8986
|
-
});
|
|
8987
|
-
}
|
|
8988
|
-
return state.authentication;
|
|
8989
|
-
} catch (error) {
|
|
8990
|
-
if (error.status === 404) {
|
|
8991
|
-
error.message = "[@octokit/auth-oauth-user] Token is invalid";
|
|
8992
|
-
state.authentication.invalid = true;
|
|
8993
|
-
}
|
|
8994
|
-
throw error;
|
|
8995
|
-
}
|
|
8996
|
-
}
|
|
8997
|
-
if (options.type === "delete" || options.type === "deleteAuthorization") {
|
|
8998
|
-
const method = options.type === "delete" ? deleteToken : deleteAuthorization;
|
|
8999
|
-
try {
|
|
9000
|
-
await method({
|
|
9001
|
-
// @ts-expect-error making TS happy would require unnecessary code so no
|
|
9002
|
-
clientType: state.clientType,
|
|
9003
|
-
clientId: state.clientId,
|
|
9004
|
-
clientSecret: state.clientSecret,
|
|
9005
|
-
token: state.authentication.token,
|
|
9006
|
-
request: state.request
|
|
9007
|
-
});
|
|
9008
|
-
} catch (error) {
|
|
9009
|
-
if (error.status !== 404) throw error;
|
|
9010
|
-
}
|
|
9011
|
-
state.authentication.invalid = true;
|
|
9012
|
-
return state.authentication;
|
|
9013
|
-
}
|
|
9014
|
-
return state.authentication;
|
|
9015
|
-
}
|
|
9016
|
-
|
|
9017
|
-
// pkg/dist-src/requires-basic-auth.js
|
|
9018
|
-
var ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/;
|
|
9019
|
-
function requiresBasicAuth(url) {
|
|
9020
|
-
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);
|
|
9021
|
-
}
|
|
9022
|
-
|
|
9023
|
-
// pkg/dist-src/hook.js
|
|
9024
|
-
async function hook$3(state, request, route, parameters = {}) {
|
|
9025
|
-
const endpoint = request.endpoint.merge(
|
|
9026
|
-
route,
|
|
9027
|
-
parameters
|
|
9028
|
-
);
|
|
9029
|
-
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
|
9030
|
-
return request(endpoint);
|
|
9031
|
-
}
|
|
9032
|
-
if (requiresBasicAuth(endpoint.url)) {
|
|
9033
|
-
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
|
9034
|
-
endpoint.headers.authorization = `basic ${credentials}`;
|
|
9035
|
-
return request(endpoint);
|
|
9036
|
-
}
|
|
9037
|
-
const { token } = state.clientType === "oauth-app" ? await auth$3({ ...state, request }) : await auth$3({ ...state, request });
|
|
9038
|
-
endpoint.headers.authorization = "token " + token;
|
|
9039
|
-
return request(endpoint);
|
|
9040
|
-
}
|
|
9041
|
-
|
|
9042
|
-
// pkg/dist-src/index.js
|
|
9043
|
-
function createOAuthUserAuth({
|
|
9044
|
-
clientId,
|
|
9045
|
-
clientSecret,
|
|
9046
|
-
clientType = "oauth-app",
|
|
9047
|
-
request: request$1 = request.defaults({
|
|
9048
|
-
headers: {
|
|
9049
|
-
"user-agent": `octokit-auth-oauth-app.js/${VERSION$4} ${getUserAgent()}`
|
|
9050
|
-
}
|
|
9051
|
-
}),
|
|
9052
|
-
onTokenCreated,
|
|
9053
|
-
...strategyOptions
|
|
9054
|
-
}) {
|
|
9055
|
-
const state = Object.assign({
|
|
9056
|
-
clientType,
|
|
9057
|
-
clientId,
|
|
9058
|
-
clientSecret,
|
|
9059
|
-
onTokenCreated,
|
|
9060
|
-
strategyOptions,
|
|
9061
|
-
request: request$1
|
|
9062
|
-
});
|
|
9063
|
-
return Object.assign(auth$3.bind(null, state), {
|
|
9064
|
-
// @ts-expect-error not worth the extra code needed to appease TS
|
|
9065
|
-
hook: hook$3.bind(null, state)
|
|
9066
|
-
});
|
|
9067
|
-
}
|
|
9068
|
-
createOAuthUserAuth.VERSION = VERSION$4;
|
|
9069
|
-
|
|
9070
|
-
// pkg/dist-src/index.js
|
|
9071
|
-
async function auth$2(state, authOptions) {
|
|
9072
|
-
if (authOptions.type === "oauth-app") {
|
|
9073
|
-
return {
|
|
9074
|
-
type: "oauth-app",
|
|
9075
|
-
clientId: state.clientId,
|
|
9076
|
-
clientSecret: state.clientSecret,
|
|
9077
|
-
clientType: state.clientType,
|
|
9078
|
-
headers: {
|
|
9079
|
-
authorization: `basic ${btoa(
|
|
9080
|
-
`${state.clientId}:${state.clientSecret}`
|
|
9081
|
-
)}`
|
|
9082
|
-
}
|
|
9083
|
-
};
|
|
9084
|
-
}
|
|
9085
|
-
if ("factory" in authOptions) {
|
|
9086
|
-
const { type, ...options } = {
|
|
9087
|
-
...authOptions,
|
|
9088
|
-
...state
|
|
9089
|
-
};
|
|
9090
|
-
return authOptions.factory(options);
|
|
9091
|
-
}
|
|
9092
|
-
const common = {
|
|
9093
|
-
clientId: state.clientId,
|
|
9094
|
-
clientSecret: state.clientSecret,
|
|
9095
|
-
request: state.request,
|
|
9096
|
-
...authOptions
|
|
9097
|
-
};
|
|
9098
|
-
const userAuth = state.clientType === "oauth-app" ? await createOAuthUserAuth({
|
|
9099
|
-
...common,
|
|
9100
|
-
clientType: state.clientType
|
|
9101
|
-
}) : await createOAuthUserAuth({
|
|
9102
|
-
...common,
|
|
9103
|
-
clientType: state.clientType
|
|
9104
|
-
});
|
|
9105
|
-
return userAuth();
|
|
9106
|
-
}
|
|
9107
|
-
async function hook$2(state, request2, route, parameters) {
|
|
9108
|
-
let endpoint = request2.endpoint.merge(
|
|
9109
|
-
route,
|
|
9110
|
-
parameters
|
|
9111
|
-
);
|
|
9112
|
-
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
|
9113
|
-
return request2(endpoint);
|
|
9114
|
-
}
|
|
9115
|
-
if (state.clientType === "github-app" && !requiresBasicAuth(endpoint.url)) {
|
|
9116
|
-
throw new Error(
|
|
9117
|
-
`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${endpoint.method} ${endpoint.url}" is not supported.`
|
|
9118
|
-
);
|
|
9119
|
-
}
|
|
9120
|
-
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
|
9121
|
-
endpoint.headers.authorization = `basic ${credentials}`;
|
|
9122
|
-
try {
|
|
9123
|
-
return await request2(endpoint);
|
|
9124
|
-
} catch (error) {
|
|
9125
|
-
if (error.status !== 401) throw error;
|
|
9126
|
-
error.message = `[@octokit/auth-oauth-app] "${endpoint.method} ${endpoint.url}" does not support clientId/clientSecret basic authentication.`;
|
|
9127
|
-
throw error;
|
|
9128
|
-
}
|
|
9129
|
-
}
|
|
9130
|
-
|
|
9131
|
-
// pkg/dist-src/version.js
|
|
9132
|
-
var VERSION$3 = "0.0.0-development";
|
|
9133
|
-
function createOAuthAppAuth(options) {
|
|
9134
|
-
const state = Object.assign(
|
|
9135
|
-
{
|
|
9136
|
-
request: request.defaults({
|
|
9137
|
-
headers: {
|
|
9138
|
-
"user-agent": `octokit-auth-oauth-app.js/${VERSION$3} ${getUserAgent()}`
|
|
9139
|
-
}
|
|
9140
|
-
}),
|
|
9141
|
-
clientType: "oauth-app"
|
|
9142
|
-
},
|
|
9143
|
-
options
|
|
9144
|
-
);
|
|
9145
|
-
return Object.assign(auth$2.bind(null, state), {
|
|
9146
|
-
hook: hook$2.bind(null, state)
|
|
9147
|
-
});
|
|
9148
|
-
}
|
|
9149
|
-
|
|
9150
|
-
// we don't @ts-check here because it chokes on atob and btoa which are available in all modern JS runtime environments
|
|
9151
|
-
|
|
9152
|
-
/**
|
|
9153
|
-
* @param {string} privateKey
|
|
9154
|
-
* @returns {boolean}
|
|
9155
|
-
*/
|
|
9156
|
-
function isPkcs1(privateKey) {
|
|
9157
|
-
return privateKey.includes("-----BEGIN RSA PRIVATE KEY-----");
|
|
9158
|
-
}
|
|
9159
|
-
|
|
9160
|
-
/**
|
|
9161
|
-
* @param {string} privateKey
|
|
9162
|
-
* @returns {boolean}
|
|
9163
|
-
*/
|
|
9164
|
-
function isOpenSsh(privateKey) {
|
|
9165
|
-
return privateKey.includes("-----BEGIN OPENSSH PRIVATE KEY-----");
|
|
9166
|
-
}
|
|
9167
|
-
|
|
9168
|
-
/**
|
|
9169
|
-
* @param {string} str
|
|
9170
|
-
* @returns {ArrayBuffer}
|
|
9171
|
-
*/
|
|
9172
|
-
function string2ArrayBuffer(str) {
|
|
9173
|
-
const buf = new ArrayBuffer(str.length);
|
|
9174
|
-
const bufView = new Uint8Array(buf);
|
|
9175
|
-
for (let i = 0, strLen = str.length; i < strLen; i++) {
|
|
9176
|
-
bufView[i] = str.charCodeAt(i);
|
|
9177
|
-
}
|
|
9178
|
-
return buf;
|
|
9179
|
-
}
|
|
9180
|
-
|
|
9181
|
-
/**
|
|
9182
|
-
* @param {string} pem
|
|
9183
|
-
* @returns {ArrayBuffer}
|
|
9184
|
-
*/
|
|
9185
|
-
function getDERfromPEM(pem) {
|
|
9186
|
-
const pemB64 = pem
|
|
9187
|
-
.trim()
|
|
9188
|
-
.split("\n")
|
|
9189
|
-
.slice(1, -1) // Remove the --- BEGIN / END PRIVATE KEY ---
|
|
9190
|
-
.join("");
|
|
9191
|
-
|
|
9192
|
-
const decoded = atob(pemB64);
|
|
9193
|
-
return string2ArrayBuffer(decoded);
|
|
9194
|
-
}
|
|
9195
|
-
|
|
9196
|
-
/**
|
|
9197
|
-
* @param {import('../internals').Header} header
|
|
9198
|
-
* @param {import('../internals').Payload} payload
|
|
9199
|
-
* @returns {string}
|
|
9200
|
-
*/
|
|
9201
|
-
function getEncodedMessage(header, payload) {
|
|
9202
|
-
return `${base64encodeJSON(header)}.${base64encodeJSON(payload)}`;
|
|
9203
|
-
}
|
|
9204
|
-
|
|
9205
|
-
/**
|
|
9206
|
-
* @param {ArrayBuffer} buffer
|
|
9207
|
-
* @returns {string}
|
|
9208
|
-
*/
|
|
9209
|
-
function base64encode(buffer) {
|
|
9210
|
-
var binary = "";
|
|
9211
|
-
var bytes = new Uint8Array(buffer);
|
|
9212
|
-
var len = bytes.byteLength;
|
|
9213
|
-
for (var i = 0; i < len; i++) {
|
|
9214
|
-
binary += String.fromCharCode(bytes[i]);
|
|
9215
|
-
}
|
|
9216
|
-
|
|
9217
|
-
return fromBase64(btoa(binary));
|
|
9218
|
-
}
|
|
9219
|
-
|
|
9220
|
-
/**
|
|
9221
|
-
* @param {string} base64
|
|
9222
|
-
* @returns {string}
|
|
9223
|
-
*/
|
|
9224
|
-
function fromBase64(base64) {
|
|
9225
|
-
return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
9226
|
-
}
|
|
9227
|
-
|
|
9228
|
-
/**
|
|
9229
|
-
* @param {Record<string,unknown>} obj
|
|
9230
|
-
* @returns {string}
|
|
9231
|
-
*/
|
|
9232
|
-
function base64encodeJSON(obj) {
|
|
9233
|
-
return fromBase64(btoa(JSON.stringify(obj)));
|
|
9234
|
-
}
|
|
9235
|
-
|
|
9236
|
-
const { subtle } = globalThis.crypto;
|
|
9237
|
-
|
|
9238
|
-
// no-op, unfortunately there is no way to transform from PKCS8 or OpenSSH to PKCS1 with WebCrypto
|
|
9239
|
-
function convertPrivateKey(privateKey) {
|
|
9240
|
-
return privateKey;
|
|
9241
|
-
}
|
|
9242
|
-
|
|
9243
|
-
// we don't @ts-check here because it chokes crypto which is a global API in modern JS runtime environments
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
/**
|
|
9247
|
-
* @param {import('../internals').GetTokenOptions} options
|
|
9248
|
-
* @returns {Promise<string>}
|
|
9249
|
-
*/
|
|
9250
|
-
async function getToken({ privateKey, payload }) {
|
|
9251
|
-
const convertedPrivateKey = convertPrivateKey(privateKey);
|
|
9252
|
-
|
|
9253
|
-
// WebCrypto only supports PKCS#8, unfortunately
|
|
9254
|
-
/* c8 ignore start */
|
|
9255
|
-
if (isPkcs1(convertedPrivateKey)) {
|
|
9256
|
-
throw new Error(
|
|
9257
|
-
"[universal-github-app-jwt] Private Key is in PKCS#1 format, but only PKCS#8 is supported. See https://github.com/gr2m/universal-github-app-jwt#private-key-formats"
|
|
9258
|
-
);
|
|
9259
|
-
}
|
|
9260
|
-
/* c8 ignore stop */
|
|
9261
|
-
|
|
9262
|
-
// WebCrypto does not support OpenSSH, unfortunately
|
|
9263
|
-
if (isOpenSsh(convertedPrivateKey)) {
|
|
9264
|
-
throw new Error(
|
|
9265
|
-
"[universal-github-app-jwt] Private Key is in OpenSSH format, but only PKCS#8 is supported. See https://github.com/gr2m/universal-github-app-jwt#private-key-formats"
|
|
9266
|
-
);
|
|
9267
|
-
}
|
|
9268
|
-
|
|
9269
|
-
const algorithm = {
|
|
9270
|
-
name: "RSASSA-PKCS1-v1_5",
|
|
9271
|
-
hash: { name: "SHA-256" },
|
|
9272
|
-
};
|
|
9273
|
-
|
|
9274
|
-
/** @type {import('../internals').Header} */
|
|
9275
|
-
const header = { alg: "RS256", typ: "JWT" };
|
|
9276
|
-
|
|
9277
|
-
const privateKeyDER = getDERfromPEM(convertedPrivateKey);
|
|
9278
|
-
const importedKey = await subtle.importKey(
|
|
9279
|
-
"pkcs8",
|
|
9280
|
-
privateKeyDER,
|
|
9281
|
-
algorithm,
|
|
9282
|
-
false,
|
|
9283
|
-
["sign"]
|
|
9284
|
-
);
|
|
9285
|
-
|
|
9286
|
-
const encodedMessage = getEncodedMessage(header, payload);
|
|
9287
|
-
const encodedMessageArrBuf = string2ArrayBuffer(encodedMessage);
|
|
9288
|
-
|
|
9289
|
-
const signatureArrBuf = await subtle.sign(
|
|
9290
|
-
algorithm.name,
|
|
9291
|
-
importedKey,
|
|
9292
|
-
encodedMessageArrBuf
|
|
9293
|
-
);
|
|
9294
|
-
|
|
9295
|
-
const encodedSignature = base64encode(signatureArrBuf);
|
|
9296
|
-
|
|
9297
|
-
return `${encodedMessage}.${encodedSignature}`;
|
|
9298
|
-
}
|
|
9299
|
-
|
|
9300
|
-
// @ts-check
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
/**
|
|
9304
|
-
* @param {import(".").Options} options
|
|
9305
|
-
* @returns {Promise<import(".").Result>}
|
|
9306
|
-
*/
|
|
9307
|
-
async function githubAppJwt({
|
|
9308
|
-
id,
|
|
9309
|
-
privateKey,
|
|
9310
|
-
now = Math.floor(Date.now() / 1000),
|
|
9311
|
-
}) {
|
|
9312
|
-
// Private keys are often times configured as environment variables, in which case line breaks are escaped using `\\n`.
|
|
9313
|
-
// Replace these here for convenience.
|
|
9314
|
-
const privateKeyWithNewlines = privateKey.replace(/\\n/g, '\n');
|
|
9315
|
-
|
|
9316
|
-
// When creating a JSON Web Token, it sets the "issued at time" (iat) to 30s
|
|
9317
|
-
// in the past as we have seen people running situations where the GitHub API
|
|
9318
|
-
// claimed the iat would be in future. It turned out the clocks on the
|
|
9319
|
-
// different machine were not in sync.
|
|
9320
|
-
const nowWithSafetyMargin = now - 30;
|
|
9321
|
-
const expiration = nowWithSafetyMargin + 60 * 10; // JWT expiration time (10 minute maximum)
|
|
9322
|
-
|
|
9323
|
-
const payload = {
|
|
9324
|
-
iat: nowWithSafetyMargin, // Issued at time
|
|
9325
|
-
exp: expiration,
|
|
9326
|
-
iss: id,
|
|
9327
|
-
};
|
|
9328
|
-
|
|
9329
|
-
const token = await getToken({
|
|
9330
|
-
privateKey: privateKeyWithNewlines,
|
|
9331
|
-
payload,
|
|
9332
|
-
});
|
|
9333
|
-
|
|
9334
|
-
return {
|
|
9335
|
-
appId: id,
|
|
9336
|
-
expiration,
|
|
9337
|
-
token,
|
|
9338
|
-
};
|
|
9339
|
-
}
|
|
9340
|
-
|
|
9341
|
-
/**
|
|
9342
|
-
* toad-cache
|
|
9343
|
-
*
|
|
9344
|
-
* @copyright 2024 Igor Savin <kibertoad@gmail.com>
|
|
9345
|
-
* @license MIT
|
|
9346
|
-
* @version 3.7.0
|
|
9347
|
-
*/
|
|
9348
|
-
class LruObject {
|
|
9349
|
-
constructor(max = 1000, ttlInMsecs = 0) {
|
|
9350
|
-
if (isNaN(max) || max < 0) {
|
|
9351
|
-
throw new Error('Invalid max value')
|
|
9352
|
-
}
|
|
9353
|
-
|
|
9354
|
-
if (isNaN(ttlInMsecs) || ttlInMsecs < 0) {
|
|
9355
|
-
throw new Error('Invalid ttl value')
|
|
9356
|
-
}
|
|
9357
|
-
|
|
9358
|
-
this.first = null;
|
|
9359
|
-
this.items = Object.create(null);
|
|
9360
|
-
this.last = null;
|
|
9361
|
-
this.size = 0;
|
|
9362
|
-
this.max = max;
|
|
9363
|
-
this.ttl = ttlInMsecs;
|
|
9364
|
-
}
|
|
9365
|
-
|
|
9366
|
-
bumpLru(item) {
|
|
9367
|
-
if (this.last === item) {
|
|
9368
|
-
return // Item is already the last one, no need to bump
|
|
9369
|
-
}
|
|
9370
|
-
|
|
9371
|
-
const last = this.last;
|
|
9372
|
-
const next = item.next;
|
|
9373
|
-
const prev = item.prev;
|
|
9374
|
-
|
|
9375
|
-
if (this.first === item) {
|
|
9376
|
-
this.first = next;
|
|
9377
|
-
}
|
|
9378
|
-
|
|
9379
|
-
item.next = null;
|
|
9380
|
-
item.prev = last;
|
|
9381
|
-
last.next = item;
|
|
9382
|
-
|
|
9383
|
-
if (prev !== null) {
|
|
9384
|
-
prev.next = next;
|
|
9385
|
-
}
|
|
9386
|
-
|
|
9387
|
-
if (next !== null) {
|
|
9388
|
-
next.prev = prev;
|
|
9389
|
-
}
|
|
9390
|
-
|
|
9391
|
-
this.last = item;
|
|
9392
|
-
}
|
|
9393
|
-
|
|
9394
|
-
clear() {
|
|
9395
|
-
this.items = Object.create(null);
|
|
9396
|
-
this.first = null;
|
|
9397
|
-
this.last = null;
|
|
9398
|
-
this.size = 0;
|
|
9399
|
-
}
|
|
9400
|
-
|
|
9401
|
-
delete(key) {
|
|
9402
|
-
if (Object.prototype.hasOwnProperty.call(this.items, key)) {
|
|
9403
|
-
const item = this.items[key];
|
|
9404
|
-
|
|
9405
|
-
delete this.items[key];
|
|
9406
|
-
this.size--;
|
|
9407
|
-
|
|
9408
|
-
if (item.prev !== null) {
|
|
9409
|
-
item.prev.next = item.next;
|
|
9410
|
-
}
|
|
9411
|
-
|
|
9412
|
-
if (item.next !== null) {
|
|
9413
|
-
item.next.prev = item.prev;
|
|
9414
|
-
}
|
|
9415
|
-
|
|
9416
|
-
if (this.first === item) {
|
|
9417
|
-
this.first = item.next;
|
|
9418
|
-
}
|
|
9419
|
-
|
|
9420
|
-
if (this.last === item) {
|
|
9421
|
-
this.last = item.prev;
|
|
9422
|
-
}
|
|
9423
|
-
}
|
|
9424
|
-
}
|
|
9425
|
-
|
|
9426
|
-
deleteMany(keys) {
|
|
9427
|
-
for (var i = 0; i < keys.length; i++) {
|
|
9428
|
-
this.delete(keys[i]);
|
|
9429
|
-
}
|
|
9430
|
-
}
|
|
9431
|
-
|
|
9432
|
-
evict() {
|
|
9433
|
-
if (this.size > 0) {
|
|
9434
|
-
const item = this.first;
|
|
9435
|
-
|
|
9436
|
-
delete this.items[item.key];
|
|
9437
|
-
|
|
9438
|
-
if (--this.size === 0) {
|
|
9439
|
-
this.first = null;
|
|
9440
|
-
this.last = null;
|
|
9441
|
-
} else {
|
|
9442
|
-
this.first = item.next;
|
|
9443
|
-
this.first.prev = null;
|
|
9444
|
-
}
|
|
9445
|
-
}
|
|
9446
|
-
}
|
|
9447
|
-
|
|
9448
|
-
expiresAt(key) {
|
|
9449
|
-
if (Object.prototype.hasOwnProperty.call(this.items, key)) {
|
|
9450
|
-
return this.items[key].expiry
|
|
9451
|
-
}
|
|
9452
|
-
}
|
|
9453
|
-
|
|
9454
|
-
get(key) {
|
|
9455
|
-
if (Object.prototype.hasOwnProperty.call(this.items, key)) {
|
|
9456
|
-
const item = this.items[key];
|
|
9457
|
-
|
|
9458
|
-
// Item has already expired
|
|
9459
|
-
if (this.ttl > 0 && item.expiry <= Date.now()) {
|
|
9460
|
-
this.delete(key);
|
|
9461
|
-
return
|
|
9462
|
-
}
|
|
9463
|
-
|
|
9464
|
-
// Item is still fresh
|
|
9465
|
-
this.bumpLru(item);
|
|
9466
|
-
return item.value
|
|
9467
|
-
}
|
|
9468
|
-
}
|
|
9469
|
-
|
|
9470
|
-
getMany(keys) {
|
|
9471
|
-
const result = [];
|
|
9472
|
-
|
|
9473
|
-
for (var i = 0; i < keys.length; i++) {
|
|
9474
|
-
result.push(this.get(keys[i]));
|
|
9475
|
-
}
|
|
9476
|
-
|
|
9477
|
-
return result
|
|
9478
|
-
}
|
|
9479
|
-
|
|
9480
|
-
keys() {
|
|
9481
|
-
return Object.keys(this.items)
|
|
9482
|
-
}
|
|
9483
|
-
|
|
9484
|
-
set(key, value) {
|
|
9485
|
-
// Replace existing item
|
|
9486
|
-
if (Object.prototype.hasOwnProperty.call(this.items, key)) {
|
|
9487
|
-
const item = this.items[key];
|
|
9488
|
-
item.value = value;
|
|
9489
|
-
|
|
9490
|
-
item.expiry = this.ttl > 0 ? Date.now() + this.ttl : this.ttl;
|
|
9491
|
-
|
|
9492
|
-
if (this.last !== item) {
|
|
9493
|
-
this.bumpLru(item);
|
|
9494
|
-
}
|
|
9495
|
-
|
|
9496
|
-
return
|
|
9497
|
-
}
|
|
9498
|
-
|
|
9499
|
-
// Add new item
|
|
9500
|
-
if (this.max > 0 && this.size === this.max) {
|
|
9501
|
-
this.evict();
|
|
9502
|
-
}
|
|
9503
|
-
|
|
9504
|
-
const item = {
|
|
9505
|
-
expiry: this.ttl > 0 ? Date.now() + this.ttl : this.ttl,
|
|
9506
|
-
key: key,
|
|
9507
|
-
prev: this.last,
|
|
9508
|
-
next: null,
|
|
9509
|
-
value,
|
|
9510
|
-
};
|
|
9511
|
-
this.items[key] = item;
|
|
9512
|
-
|
|
9513
|
-
if (++this.size === 1) {
|
|
9514
|
-
this.first = item;
|
|
9515
|
-
} else {
|
|
9516
|
-
this.last.next = item;
|
|
9517
|
-
}
|
|
9518
|
-
|
|
9519
|
-
this.last = item;
|
|
9520
|
-
}
|
|
9521
|
-
}
|
|
9522
|
-
|
|
9523
|
-
// pkg/dist-src/index.js
|
|
9524
|
-
async function getAppAuthentication({
|
|
9525
|
-
appId,
|
|
9526
|
-
privateKey,
|
|
9527
|
-
timeDifference,
|
|
9528
|
-
createJwt
|
|
9529
|
-
}) {
|
|
9530
|
-
try {
|
|
9531
|
-
if (createJwt) {
|
|
9532
|
-
const { jwt, expiresAt } = await createJwt(appId, timeDifference);
|
|
9533
|
-
return {
|
|
9534
|
-
type: "app",
|
|
9535
|
-
token: jwt,
|
|
9536
|
-
appId,
|
|
9537
|
-
expiresAt
|
|
9538
|
-
};
|
|
9539
|
-
}
|
|
9540
|
-
const authOptions = {
|
|
9541
|
-
id: appId,
|
|
9542
|
-
privateKey
|
|
9543
|
-
};
|
|
9544
|
-
if (timeDifference) {
|
|
9545
|
-
Object.assign(authOptions, {
|
|
9546
|
-
now: Math.floor(Date.now() / 1e3) + timeDifference
|
|
9547
|
-
});
|
|
9548
|
-
}
|
|
9549
|
-
const appAuthentication = await githubAppJwt(authOptions);
|
|
9550
|
-
return {
|
|
9551
|
-
type: "app",
|
|
9552
|
-
token: appAuthentication.token,
|
|
9553
|
-
appId: appAuthentication.appId,
|
|
9554
|
-
expiresAt: new Date(appAuthentication.expiration * 1e3).toISOString()
|
|
9555
|
-
};
|
|
9556
|
-
} catch (error) {
|
|
9557
|
-
if (privateKey === "-----BEGIN RSA PRIVATE KEY-----") {
|
|
9558
|
-
throw new Error(
|
|
9559
|
-
"The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'"
|
|
9560
|
-
);
|
|
9561
|
-
} else {
|
|
9562
|
-
throw error;
|
|
9563
|
-
}
|
|
9564
|
-
}
|
|
9565
|
-
}
|
|
9566
|
-
function getCache() {
|
|
9567
|
-
return new LruObject(
|
|
9568
|
-
// cache max. 15000 tokens, that will use less than 10mb memory
|
|
9569
|
-
15e3,
|
|
9570
|
-
// Cache for 1 minute less than GitHub expiry
|
|
9571
|
-
1e3 * 60 * 59
|
|
9572
|
-
);
|
|
9573
|
-
}
|
|
9574
|
-
async function get(cache, options) {
|
|
9575
|
-
const cacheKey = optionsToCacheKey(options);
|
|
9576
|
-
const result = await cache.get(cacheKey);
|
|
9577
|
-
if (!result) {
|
|
9578
|
-
return;
|
|
9579
|
-
}
|
|
9580
|
-
const [
|
|
9581
|
-
token,
|
|
9582
|
-
createdAt,
|
|
9583
|
-
expiresAt,
|
|
9584
|
-
repositorySelection,
|
|
9585
|
-
permissionsString,
|
|
9586
|
-
singleFileName
|
|
9587
|
-
] = result.split("|");
|
|
9588
|
-
const permissions = options.permissions || permissionsString.split(/,/).reduce((permissions2, string) => {
|
|
9589
|
-
if (/!$/.test(string)) {
|
|
9590
|
-
permissions2[string.slice(0, -1)] = "write";
|
|
9591
|
-
} else {
|
|
9592
|
-
permissions2[string] = "read";
|
|
9593
|
-
}
|
|
9594
|
-
return permissions2;
|
|
9595
|
-
}, {});
|
|
9596
|
-
return {
|
|
9597
|
-
token,
|
|
9598
|
-
createdAt,
|
|
9599
|
-
expiresAt,
|
|
9600
|
-
permissions,
|
|
9601
|
-
repositoryIds: options.repositoryIds,
|
|
9602
|
-
repositoryNames: options.repositoryNames,
|
|
9603
|
-
singleFileName,
|
|
9604
|
-
repositorySelection
|
|
9605
|
-
};
|
|
9606
|
-
}
|
|
9607
|
-
async function set(cache, options, data) {
|
|
9608
|
-
const key = optionsToCacheKey(options);
|
|
9609
|
-
const permissionsString = options.permissions ? "" : Object.keys(data.permissions).map(
|
|
9610
|
-
(name) => `${name}${data.permissions[name] === "write" ? "!" : ""}`
|
|
9611
|
-
).join(",");
|
|
9612
|
-
const value = [
|
|
9613
|
-
data.token,
|
|
9614
|
-
data.createdAt,
|
|
9615
|
-
data.expiresAt,
|
|
9616
|
-
data.repositorySelection,
|
|
9617
|
-
permissionsString,
|
|
9618
|
-
data.singleFileName
|
|
9619
|
-
].join("|");
|
|
9620
|
-
await cache.set(key, value);
|
|
9621
|
-
}
|
|
9622
|
-
function optionsToCacheKey({
|
|
9623
|
-
installationId,
|
|
9624
|
-
permissions = {},
|
|
9625
|
-
repositoryIds = [],
|
|
9626
|
-
repositoryNames = []
|
|
9627
|
-
}) {
|
|
9628
|
-
const permissionsString = Object.keys(permissions).sort().map((name) => permissions[name] === "read" ? name : `${name}!`).join(",");
|
|
9629
|
-
const repositoryIdsString = repositoryIds.sort().join(",");
|
|
9630
|
-
const repositoryNamesString = repositoryNames.join(",");
|
|
9631
|
-
return [
|
|
9632
|
-
installationId,
|
|
9633
|
-
repositoryIdsString,
|
|
9634
|
-
repositoryNamesString,
|
|
9635
|
-
permissionsString
|
|
9636
|
-
].filter(Boolean).join("|");
|
|
9637
|
-
}
|
|
9638
|
-
|
|
9639
|
-
// pkg/dist-src/to-token-authentication.js
|
|
9640
|
-
function toTokenAuthentication({
|
|
9641
|
-
installationId,
|
|
9642
|
-
token,
|
|
9643
|
-
createdAt,
|
|
9644
|
-
expiresAt,
|
|
9645
|
-
repositorySelection,
|
|
9646
|
-
permissions,
|
|
9647
|
-
repositoryIds,
|
|
9648
|
-
repositoryNames,
|
|
9649
|
-
singleFileName
|
|
9650
|
-
}) {
|
|
9651
|
-
return Object.assign(
|
|
9652
|
-
{
|
|
9653
|
-
type: "token",
|
|
9654
|
-
tokenType: "installation",
|
|
9655
|
-
token,
|
|
9656
|
-
installationId,
|
|
9657
|
-
permissions,
|
|
9658
|
-
createdAt,
|
|
9659
|
-
expiresAt,
|
|
9660
|
-
repositorySelection
|
|
9661
|
-
},
|
|
9662
|
-
repositoryIds ? { repositoryIds } : null,
|
|
9663
|
-
repositoryNames ? { repositoryNames } : null,
|
|
9664
|
-
singleFileName ? { singleFileName } : null
|
|
9665
|
-
);
|
|
9666
|
-
}
|
|
9667
|
-
|
|
9668
|
-
// pkg/dist-src/get-installation-authentication.js
|
|
9669
|
-
async function getInstallationAuthentication(state, options, customRequest) {
|
|
9670
|
-
const installationId = Number(options.installationId || state.installationId);
|
|
9671
|
-
if (!installationId) {
|
|
9672
|
-
throw new Error(
|
|
9673
|
-
"[@octokit/auth-app] installationId option is required for installation authentication."
|
|
9674
|
-
);
|
|
9675
|
-
}
|
|
9676
|
-
if (options.factory) {
|
|
9677
|
-
const { type, factory, oauthApp, ...factoryAuthOptions } = {
|
|
9678
|
-
...state,
|
|
9679
|
-
...options
|
|
9680
|
-
};
|
|
9681
|
-
return factory(factoryAuthOptions);
|
|
9682
|
-
}
|
|
9683
|
-
const request = customRequest || state.request;
|
|
9684
|
-
return getInstallationAuthenticationConcurrently(
|
|
9685
|
-
state,
|
|
9686
|
-
{ ...options, installationId },
|
|
9687
|
-
request
|
|
9688
|
-
);
|
|
9689
|
-
}
|
|
9690
|
-
var pendingPromises = /* @__PURE__ */ new Map();
|
|
9691
|
-
function getInstallationAuthenticationConcurrently(state, options, request) {
|
|
9692
|
-
const cacheKey = optionsToCacheKey(options);
|
|
9693
|
-
if (pendingPromises.has(cacheKey)) {
|
|
9694
|
-
return pendingPromises.get(cacheKey);
|
|
9695
|
-
}
|
|
9696
|
-
const promise = getInstallationAuthenticationImpl(
|
|
9697
|
-
state,
|
|
9698
|
-
options,
|
|
9699
|
-
request
|
|
9700
|
-
).finally(() => pendingPromises.delete(cacheKey));
|
|
9701
|
-
pendingPromises.set(cacheKey, promise);
|
|
9702
|
-
return promise;
|
|
9703
|
-
}
|
|
9704
|
-
async function getInstallationAuthenticationImpl(state, options, request) {
|
|
9705
|
-
if (!options.refresh) {
|
|
9706
|
-
const result = await get(state.cache, options);
|
|
9707
|
-
if (result) {
|
|
9708
|
-
const {
|
|
9709
|
-
token: token2,
|
|
9710
|
-
createdAt: createdAt2,
|
|
9711
|
-
expiresAt: expiresAt2,
|
|
9712
|
-
permissions: permissions2,
|
|
9713
|
-
repositoryIds: repositoryIds2,
|
|
9714
|
-
repositoryNames: repositoryNames2,
|
|
9715
|
-
singleFileName: singleFileName2,
|
|
9716
|
-
repositorySelection: repositorySelection2
|
|
9717
|
-
} = result;
|
|
9718
|
-
return toTokenAuthentication({
|
|
9719
|
-
installationId: options.installationId,
|
|
9720
|
-
token: token2,
|
|
9721
|
-
createdAt: createdAt2,
|
|
9722
|
-
expiresAt: expiresAt2,
|
|
9723
|
-
permissions: permissions2,
|
|
9724
|
-
repositorySelection: repositorySelection2,
|
|
9725
|
-
repositoryIds: repositoryIds2,
|
|
9726
|
-
repositoryNames: repositoryNames2,
|
|
9727
|
-
singleFileName: singleFileName2
|
|
9728
|
-
});
|
|
9729
|
-
}
|
|
9730
|
-
}
|
|
9731
|
-
const appAuthentication = await getAppAuthentication(state);
|
|
9732
|
-
const payload = {
|
|
9733
|
-
installation_id: options.installationId,
|
|
9734
|
-
mediaType: {
|
|
9735
|
-
previews: ["machine-man"]
|
|
9736
|
-
},
|
|
9737
|
-
headers: {
|
|
9738
|
-
authorization: `bearer ${appAuthentication.token}`
|
|
9739
|
-
}
|
|
9740
|
-
};
|
|
9741
|
-
if (options.repositoryIds) {
|
|
9742
|
-
Object.assign(payload, { repository_ids: options.repositoryIds });
|
|
9743
|
-
}
|
|
9744
|
-
if (options.repositoryNames) {
|
|
9745
|
-
Object.assign(payload, {
|
|
9746
|
-
repositories: options.repositoryNames
|
|
9747
|
-
});
|
|
9748
|
-
}
|
|
9749
|
-
if (options.permissions) {
|
|
9750
|
-
Object.assign(payload, { permissions: options.permissions });
|
|
9751
|
-
}
|
|
9752
|
-
const {
|
|
9753
|
-
data: {
|
|
9754
|
-
token,
|
|
9755
|
-
expires_at: expiresAt,
|
|
9756
|
-
repositories,
|
|
9757
|
-
permissions: permissionsOptional,
|
|
9758
|
-
repository_selection: repositorySelectionOptional,
|
|
9759
|
-
single_file: singleFileName
|
|
9760
|
-
}
|
|
9761
|
-
} = await request(
|
|
9762
|
-
"POST /app/installations/{installation_id}/access_tokens",
|
|
9763
|
-
payload
|
|
9764
|
-
);
|
|
9765
|
-
const permissions = permissionsOptional || {};
|
|
9766
|
-
const repositorySelection = repositorySelectionOptional || "all";
|
|
9767
|
-
const repositoryIds = repositories ? repositories.map((r) => r.id) : void 0;
|
|
9768
|
-
const repositoryNames = repositories ? repositories.map((repo) => repo.name) : void 0;
|
|
9769
|
-
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
9770
|
-
const cacheOptions = {
|
|
9771
|
-
token,
|
|
9772
|
-
createdAt,
|
|
9773
|
-
expiresAt,
|
|
9774
|
-
repositorySelection,
|
|
9775
|
-
permissions};
|
|
9776
|
-
if (singleFileName) {
|
|
9777
|
-
Object.assign(payload, { singleFileName });
|
|
9778
|
-
}
|
|
9779
|
-
await set(state.cache, options, cacheOptions);
|
|
9780
|
-
const cacheData = {
|
|
9781
|
-
installationId: options.installationId,
|
|
9782
|
-
token,
|
|
9783
|
-
createdAt,
|
|
9784
|
-
expiresAt,
|
|
9785
|
-
repositorySelection,
|
|
9786
|
-
permissions,
|
|
9787
|
-
repositoryIds,
|
|
9788
|
-
repositoryNames
|
|
9789
|
-
};
|
|
9790
|
-
if (singleFileName) {
|
|
9791
|
-
Object.assign(cacheData, { singleFileName });
|
|
9792
|
-
}
|
|
9793
|
-
return toTokenAuthentication(cacheData);
|
|
9794
|
-
}
|
|
9795
|
-
|
|
9796
|
-
// pkg/dist-src/auth.js
|
|
9797
|
-
async function auth$1(state, authOptions) {
|
|
9798
|
-
switch (authOptions.type) {
|
|
9799
|
-
case "app":
|
|
9800
|
-
return getAppAuthentication(state);
|
|
9801
|
-
case "oauth-app":
|
|
9802
|
-
return state.oauthApp({ type: "oauth-app" });
|
|
9803
|
-
case "installation":
|
|
9804
|
-
return getInstallationAuthentication(state, {
|
|
9805
|
-
...authOptions,
|
|
9806
|
-
type: "installation"
|
|
9807
|
-
});
|
|
9808
|
-
case "oauth-user":
|
|
9809
|
-
return state.oauthApp(authOptions);
|
|
9810
|
-
default:
|
|
9811
|
-
throw new Error(`Invalid auth type: ${authOptions.type}`);
|
|
9812
|
-
}
|
|
9813
|
-
}
|
|
9814
|
-
|
|
9815
|
-
// pkg/dist-src/requires-app-auth.js
|
|
9816
|
-
var PATHS = [
|
|
9817
|
-
"/app",
|
|
9818
|
-
"/app/hook/config",
|
|
9819
|
-
"/app/hook/deliveries",
|
|
9820
|
-
"/app/hook/deliveries/{delivery_id}",
|
|
9821
|
-
"/app/hook/deliveries/{delivery_id}/attempts",
|
|
9822
|
-
"/app/installations",
|
|
9823
|
-
"/app/installations/{installation_id}",
|
|
9824
|
-
"/app/installations/{installation_id}/access_tokens",
|
|
9825
|
-
"/app/installations/{installation_id}/suspended",
|
|
9826
|
-
"/app/installation-requests",
|
|
9827
|
-
"/marketplace_listing/accounts/{account_id}",
|
|
9828
|
-
"/marketplace_listing/plan",
|
|
9829
|
-
"/marketplace_listing/plans",
|
|
9830
|
-
"/marketplace_listing/plans/{plan_id}/accounts",
|
|
9831
|
-
"/marketplace_listing/stubbed/accounts/{account_id}",
|
|
9832
|
-
"/marketplace_listing/stubbed/plan",
|
|
9833
|
-
"/marketplace_listing/stubbed/plans",
|
|
9834
|
-
"/marketplace_listing/stubbed/plans/{plan_id}/accounts",
|
|
9835
|
-
"/orgs/{org}/installation",
|
|
9836
|
-
"/repos/{owner}/{repo}/installation",
|
|
9837
|
-
"/users/{username}/installation",
|
|
9838
|
-
"/enterprises/{enterprise}/installation"
|
|
9839
|
-
];
|
|
9840
|
-
function routeMatcher(paths) {
|
|
9841
|
-
const regexes = paths.map(
|
|
9842
|
-
(p) => p.split("/").map((c) => c.startsWith("{") ? "(?:.+?)" : c).join("/")
|
|
9843
|
-
);
|
|
9844
|
-
const regex = `^(?:${regexes.map((r) => `(?:${r})`).join("|")})$`;
|
|
9845
|
-
return new RegExp(regex, "i");
|
|
9846
|
-
}
|
|
9847
|
-
var REGEX = routeMatcher(PATHS);
|
|
9848
|
-
function requiresAppAuth(url) {
|
|
9849
|
-
return !!url && REGEX.test(url.split("?")[0]);
|
|
9850
|
-
}
|
|
9851
|
-
|
|
9852
|
-
// pkg/dist-src/hook.js
|
|
9853
|
-
var FIVE_SECONDS_IN_MS = 5 * 1e3;
|
|
9854
|
-
function isNotTimeSkewError(error) {
|
|
9855
|
-
return !(error.message.match(
|
|
9856
|
-
/'Expiration time' claim \('exp'\) is too far in the future/
|
|
9857
|
-
) || error.message.match(
|
|
9858
|
-
/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/
|
|
9859
|
-
) || error.message.match(
|
|
9860
|
-
/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/
|
|
9861
|
-
));
|
|
9862
|
-
}
|
|
9863
|
-
async function hook$1(state, request, route, parameters) {
|
|
9864
|
-
const endpoint = request.endpoint.merge(route, parameters);
|
|
9865
|
-
const url = endpoint.url;
|
|
9866
|
-
if (/\/login\/oauth\/access_token$/.test(url)) {
|
|
9867
|
-
return request(endpoint);
|
|
9868
|
-
}
|
|
9869
|
-
if (requiresAppAuth(url.replace(request.endpoint.DEFAULTS.baseUrl, ""))) {
|
|
9870
|
-
const { token: token2 } = await getAppAuthentication(state);
|
|
9871
|
-
endpoint.headers.authorization = `bearer ${token2}`;
|
|
9872
|
-
let response;
|
|
9873
|
-
try {
|
|
9874
|
-
response = await request(endpoint);
|
|
9875
|
-
} catch (error) {
|
|
9876
|
-
if (isNotTimeSkewError(error)) {
|
|
9877
|
-
throw error;
|
|
9878
|
-
}
|
|
9879
|
-
if (typeof error.response.headers.date === "undefined") {
|
|
9880
|
-
throw error;
|
|
9881
|
-
}
|
|
9882
|
-
const diff = Math.floor(
|
|
9883
|
-
(Date.parse(error.response.headers.date) - Date.parse((/* @__PURE__ */ new Date()).toString())) / 1e3
|
|
9884
|
-
);
|
|
9885
|
-
state.log.warn(error.message);
|
|
9886
|
-
state.log.warn(
|
|
9887
|
-
`[@octokit/auth-app] GitHub API time and system time are different by ${diff} seconds. Retrying request with the difference accounted for.`
|
|
9888
|
-
);
|
|
9889
|
-
const { token: token3 } = await getAppAuthentication({
|
|
9890
|
-
...state,
|
|
9891
|
-
timeDifference: diff
|
|
9892
|
-
});
|
|
9893
|
-
endpoint.headers.authorization = `bearer ${token3}`;
|
|
9894
|
-
return request(endpoint);
|
|
9895
|
-
}
|
|
9896
|
-
return response;
|
|
9897
|
-
}
|
|
9898
|
-
if (requiresBasicAuth(url)) {
|
|
9899
|
-
const authentication = await state.oauthApp({ type: "oauth-app" });
|
|
9900
|
-
endpoint.headers.authorization = authentication.headers.authorization;
|
|
9901
|
-
return request(endpoint);
|
|
9902
|
-
}
|
|
9903
|
-
const { token, createdAt } = await getInstallationAuthentication(
|
|
9904
|
-
state,
|
|
9905
|
-
// @ts-expect-error TBD
|
|
9906
|
-
{},
|
|
9907
|
-
request.defaults({ baseUrl: endpoint.baseUrl })
|
|
9908
|
-
);
|
|
9909
|
-
endpoint.headers.authorization = `token ${token}`;
|
|
9910
|
-
return sendRequestWithRetries(
|
|
9911
|
-
state,
|
|
9912
|
-
request,
|
|
9913
|
-
endpoint,
|
|
9914
|
-
createdAt
|
|
9915
|
-
);
|
|
9916
|
-
}
|
|
9917
|
-
async function sendRequestWithRetries(state, request, options, createdAt, retries = 0) {
|
|
9918
|
-
const timeSinceTokenCreationInMs = +/* @__PURE__ */ new Date() - +new Date(createdAt);
|
|
9919
|
-
try {
|
|
9920
|
-
return await request(options);
|
|
9921
|
-
} catch (error) {
|
|
9922
|
-
if (error.status !== 401) {
|
|
9923
|
-
throw error;
|
|
9924
|
-
}
|
|
9925
|
-
if (timeSinceTokenCreationInMs >= FIVE_SECONDS_IN_MS) {
|
|
9926
|
-
if (retries > 0) {
|
|
9927
|
-
error.message = `After ${retries} retries within ${timeSinceTokenCreationInMs / 1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`;
|
|
9928
|
-
}
|
|
9929
|
-
throw error;
|
|
9930
|
-
}
|
|
9931
|
-
++retries;
|
|
9932
|
-
const awaitTime = retries * 1e3;
|
|
9933
|
-
state.log.warn(
|
|
9934
|
-
`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${retries}, wait: ${awaitTime / 1e3}s)`
|
|
9935
|
-
);
|
|
9936
|
-
await new Promise((resolve) => setTimeout(resolve, awaitTime));
|
|
9937
|
-
return sendRequestWithRetries(state, request, options, createdAt, retries);
|
|
9938
|
-
}
|
|
9939
|
-
}
|
|
9940
|
-
|
|
9941
|
-
// pkg/dist-src/version.js
|
|
9942
|
-
var VERSION$2 = "8.2.0";
|
|
9943
|
-
function createAppAuth(options) {
|
|
9944
|
-
if (!options.appId) {
|
|
9945
|
-
throw new Error("[@octokit/auth-app] appId option is required");
|
|
9946
|
-
}
|
|
9947
|
-
if (!options.privateKey && !options.createJwt) {
|
|
9948
|
-
throw new Error("[@octokit/auth-app] privateKey option is required");
|
|
9949
|
-
} else if (options.privateKey && options.createJwt) {
|
|
9950
|
-
throw new Error(
|
|
9951
|
-
"[@octokit/auth-app] privateKey and createJwt options are mutually exclusive"
|
|
9952
|
-
);
|
|
9953
|
-
}
|
|
9954
|
-
if ("installationId" in options && !options.installationId) {
|
|
9955
|
-
throw new Error(
|
|
9956
|
-
"[@octokit/auth-app] installationId is set to a falsy value"
|
|
9957
|
-
);
|
|
9958
|
-
}
|
|
9959
|
-
const log = options.log || {};
|
|
9960
|
-
if (typeof log.warn !== "function") {
|
|
9961
|
-
log.warn = console.warn.bind(console);
|
|
9962
|
-
}
|
|
9963
|
-
const request$1 = options.request || request.defaults({
|
|
9964
|
-
headers: {
|
|
9965
|
-
"user-agent": `octokit-auth-app.js/${VERSION$2} ${getUserAgent()}`
|
|
9966
|
-
}
|
|
9967
|
-
});
|
|
9968
|
-
const state = Object.assign(
|
|
9969
|
-
{
|
|
9970
|
-
request: request$1,
|
|
9971
|
-
cache: getCache()
|
|
9972
|
-
},
|
|
9973
|
-
options,
|
|
9974
|
-
options.installationId ? { installationId: Number(options.installationId) } : {},
|
|
9975
|
-
{
|
|
9976
|
-
log,
|
|
9977
|
-
oauthApp: createOAuthAppAuth({
|
|
9978
|
-
clientType: "github-app",
|
|
9979
|
-
clientId: options.clientId || "",
|
|
9980
|
-
clientSecret: options.clientSecret || "",
|
|
9981
|
-
request: request$1
|
|
9982
|
-
})
|
|
9983
|
-
}
|
|
9984
|
-
);
|
|
9985
|
-
return Object.assign(auth$1.bind(null, state), {
|
|
9986
|
-
hook: hook$1.bind(null, state)
|
|
9987
|
-
});
|
|
9988
|
-
}
|
|
9989
|
-
|
|
9990
|
-
const PEM_PATTERN = /(-----BEGIN [A-Z ]+-----)([\s\S]*?)(-----END [A-Z ]+-----)/;
|
|
9991
|
-
const PEM_LINE_LENGTH = 64;
|
|
9992
|
-
const GITHUB_BOT_ENV_VARS = [
|
|
9993
|
-
"GITHUB_BOT_APP_ID",
|
|
9994
|
-
"GITHUB_BOT_PRIVATE_KEY",
|
|
9995
|
-
"GITHUB_BOT_INSTALLATION_ID",
|
|
9996
|
-
];
|
|
9997
|
-
let cachedAppAuth;
|
|
9998
|
-
// Secret stores hold the key with \n escapes, with spaces, or base64-encoded.
|
|
9999
|
-
const readPrivateKey = (rawKey) => {
|
|
10000
|
-
const unescaped = rawKey.replace(/\\n/g, "\n");
|
|
10001
|
-
const decoded = unescaped.includes("-----BEGIN")
|
|
10002
|
-
? unescaped
|
|
10003
|
-
: Buffer.from(rawKey.replace(/\s/g, ""), "base64").toString("utf-8");
|
|
10004
|
-
const pem = decoded.match(PEM_PATTERN);
|
|
10005
|
-
if (!pem)
|
|
10006
|
-
failTest("ENV variable GITHUB_BOT_PRIVATE_KEY is not a PEM key or a base64 encoded PEM key");
|
|
10007
|
-
const [, begin, body, end] = pem;
|
|
10008
|
-
const lines = body.replace(/\s/g, "").match(new RegExp(`.{1,${PEM_LINE_LENGTH}}`, "g")) ??
|
|
10009
|
-
[];
|
|
10010
|
-
return [begin, ...lines, end, ""].join("\n");
|
|
10011
|
-
};
|
|
10012
|
-
// The auth client holds the token cache, so it must be reused across calls.
|
|
10013
|
-
const getAppAuth = () => {
|
|
10014
|
-
if (cachedAppAuth)
|
|
10015
|
-
return cachedAppAuth;
|
|
10016
|
-
const missing = GITHUB_BOT_ENV_VARS.filter(name => isNotPresent(process.env[name]));
|
|
10017
|
-
if (missing.length > 0)
|
|
10018
|
-
failTest(`ENV variables ${missing.join(", ")} are not set. Set all of ${GITHUB_BOT_ENV_VARS.join(", ")}, or set only GITHUB_TOKEN`);
|
|
10019
|
-
const appId = process.env.GITHUB_BOT_APP_ID;
|
|
10020
|
-
const privateKey = process.env.GITHUB_BOT_PRIVATE_KEY;
|
|
10021
|
-
const installationId = process.env.GITHUB_BOT_INSTALLATION_ID;
|
|
10022
|
-
// createAppAuth needs a PKCS#8 key, and the bundled JWT signer does not convert the PKCS#1 key that GitHub issues.
|
|
10023
|
-
const privateKeyPkcs8 = createPrivateKey(readPrivateKey(privateKey)).export({
|
|
10024
|
-
type: "pkcs8",
|
|
10025
|
-
format: "pem",
|
|
10026
|
-
});
|
|
10027
|
-
cachedAppAuth = createAppAuth({
|
|
10028
|
-
appId: appId.trim(),
|
|
10029
|
-
privateKey: privateKeyPkcs8,
|
|
10030
|
-
installationId: installationId.trim(),
|
|
10031
|
-
});
|
|
10032
|
-
return cachedAppAuth;
|
|
10033
|
-
};
|
|
10034
|
-
const getGithubToken = async ({ forceRefresh = false, } = {}) => {
|
|
10035
|
-
const isGithubBotConfigured = GITHUB_BOT_ENV_VARS.some(name => process.env[name]);
|
|
10036
|
-
const githubToken = process.env.GITHUB_TOKEN;
|
|
10037
|
-
if (!isGithubBotConfigured && githubToken)
|
|
10038
|
-
return githubToken;
|
|
10039
|
-
const { token } = await getAppAuth()({
|
|
10040
|
-
type: "installation",
|
|
10041
|
-
refresh: forceRefresh,
|
|
10042
|
-
});
|
|
10043
|
-
return token;
|
|
10044
|
-
};
|
|
10045
|
-
|
|
10046
|
-
// @ts-check
|
|
10047
|
-
|
|
10048
|
-
function register(state, name, method, options) {
|
|
10049
|
-
if (typeof method !== "function") {
|
|
10050
|
-
throw new Error("method for before hook must be a function");
|
|
10051
|
-
}
|
|
10052
|
-
|
|
10053
|
-
if (!options) {
|
|
10054
|
-
options = {};
|
|
10055
|
-
}
|
|
10056
|
-
|
|
10057
|
-
if (Array.isArray(name)) {
|
|
10058
|
-
return name.reverse().reduce((callback, name) => {
|
|
10059
|
-
return register.bind(null, state, name, callback, options);
|
|
10060
|
-
}, method)();
|
|
10061
|
-
}
|
|
10062
|
-
|
|
10063
|
-
return Promise.resolve().then(() => {
|
|
10064
|
-
if (!state.registry[name]) {
|
|
10065
|
-
return method(options);
|
|
10066
|
-
}
|
|
10067
|
-
|
|
10068
|
-
return state.registry[name].reduce((method, registered) => {
|
|
10069
|
-
return registered.hook.bind(null, method, options);
|
|
10070
|
-
}, method)();
|
|
10071
|
-
});
|
|
10072
|
-
}
|
|
10073
|
-
|
|
10074
|
-
// @ts-check
|
|
10075
|
-
|
|
10076
|
-
function addHook(state, kind, name, hook) {
|
|
10077
|
-
const orig = hook;
|
|
10078
|
-
if (!state.registry[name]) {
|
|
10079
|
-
state.registry[name] = [];
|
|
10080
|
-
}
|
|
10081
|
-
|
|
10082
|
-
if (kind === "before") {
|
|
10083
|
-
hook = (method, options) => {
|
|
10084
|
-
return Promise.resolve()
|
|
10085
|
-
.then(orig.bind(null, options))
|
|
10086
|
-
.then(method.bind(null, options));
|
|
10087
|
-
};
|
|
10088
|
-
}
|
|
10089
|
-
|
|
10090
|
-
if (kind === "after") {
|
|
10091
|
-
hook = (method, options) => {
|
|
10092
|
-
let result;
|
|
10093
|
-
return Promise.resolve()
|
|
10094
|
-
.then(method.bind(null, options))
|
|
10095
|
-
.then((result_) => {
|
|
10096
|
-
result = result_;
|
|
10097
|
-
return orig(result, options);
|
|
10098
|
-
})
|
|
10099
|
-
.then(() => {
|
|
10100
|
-
return result;
|
|
10101
|
-
});
|
|
10102
|
-
};
|
|
10103
|
-
}
|
|
10104
|
-
|
|
10105
|
-
if (kind === "error") {
|
|
10106
|
-
hook = (method, options) => {
|
|
10107
|
-
return Promise.resolve()
|
|
10108
|
-
.then(method.bind(null, options))
|
|
10109
|
-
.catch((error) => {
|
|
10110
|
-
return orig(error, options);
|
|
10111
|
-
});
|
|
10112
|
-
};
|
|
10113
|
-
}
|
|
10114
|
-
|
|
10115
|
-
state.registry[name].push({
|
|
10116
|
-
hook: hook,
|
|
10117
|
-
orig: orig,
|
|
10118
|
-
});
|
|
10119
|
-
}
|
|
10120
|
-
|
|
10121
|
-
// @ts-check
|
|
10122
|
-
|
|
10123
|
-
function removeHook(state, name, method) {
|
|
10124
|
-
if (!state.registry[name]) {
|
|
10125
|
-
return;
|
|
10126
|
-
}
|
|
10127
|
-
|
|
10128
|
-
const index = state.registry[name]
|
|
10129
|
-
.map((registered) => {
|
|
10130
|
-
return registered.orig;
|
|
10131
|
-
})
|
|
10132
|
-
.indexOf(method);
|
|
10133
|
-
|
|
10134
|
-
if (index === -1) {
|
|
10135
|
-
return;
|
|
10136
|
-
}
|
|
10137
|
-
|
|
10138
|
-
state.registry[name].splice(index, 1);
|
|
10139
|
-
}
|
|
10140
|
-
|
|
10141
|
-
// @ts-check
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
// bind with array of arguments: https://stackoverflow.com/a/21792913
|
|
10145
|
-
const bind = Function.bind;
|
|
10146
|
-
const bindable = bind.bind(bind);
|
|
10147
|
-
|
|
10148
|
-
function bindApi(hook, state, name) {
|
|
10149
|
-
const removeHookRef = bindable(removeHook, null).apply(
|
|
10150
|
-
null,
|
|
10151
|
-
[state]
|
|
10152
|
-
);
|
|
10153
|
-
hook.api = { remove: removeHookRef };
|
|
10154
|
-
hook.remove = removeHookRef;
|
|
10155
|
-
["before", "error", "after", "wrap"].forEach((kind) => {
|
|
10156
|
-
const args = [state, kind];
|
|
10157
|
-
hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args);
|
|
10158
|
-
});
|
|
10159
|
-
}
|
|
10160
|
-
|
|
10161
|
-
function Collection() {
|
|
10162
|
-
const state = {
|
|
10163
|
-
registry: {},
|
|
10164
|
-
};
|
|
10165
|
-
|
|
10166
|
-
const hook = register.bind(null, state);
|
|
10167
|
-
bindApi(hook, state);
|
|
10168
|
-
|
|
10169
|
-
return hook;
|
|
10170
|
-
}
|
|
10171
|
-
|
|
10172
|
-
var Hook = { Collection };
|
|
10173
|
-
|
|
10174
|
-
// pkg/dist-src/index.js
|
|
10175
|
-
|
|
10176
|
-
// pkg/dist-src/version.js
|
|
10177
|
-
var VERSION$1 = "0.0.0-development";
|
|
10178
|
-
|
|
10179
|
-
// pkg/dist-src/error.js
|
|
10180
|
-
function _buildMessageForResponseErrors(data) {
|
|
10181
|
-
return `Request failed due to following response errors:
|
|
10182
|
-
` + data.errors.map((e) => ` - ${e.message}`).join("\n");
|
|
10183
|
-
}
|
|
10184
|
-
var GraphqlResponseError = class extends Error {
|
|
10185
|
-
constructor(request2, headers, response) {
|
|
10186
|
-
super(_buildMessageForResponseErrors(response));
|
|
10187
|
-
this.request = request2;
|
|
10188
|
-
this.headers = headers;
|
|
10189
|
-
this.response = response;
|
|
10190
|
-
this.errors = response.errors;
|
|
10191
|
-
this.data = response.data;
|
|
10192
|
-
if (Error.captureStackTrace) {
|
|
10193
|
-
Error.captureStackTrace(this, this.constructor);
|
|
10194
|
-
}
|
|
10195
|
-
}
|
|
10196
|
-
name = "GraphqlResponseError";
|
|
10197
|
-
errors;
|
|
10198
|
-
data;
|
|
10199
|
-
};
|
|
10200
|
-
|
|
10201
|
-
// pkg/dist-src/graphql.js
|
|
10202
|
-
var NON_VARIABLE_OPTIONS = [
|
|
10203
|
-
"method",
|
|
10204
|
-
"baseUrl",
|
|
10205
|
-
"url",
|
|
10206
|
-
"headers",
|
|
10207
|
-
"request",
|
|
10208
|
-
"query",
|
|
10209
|
-
"mediaType",
|
|
10210
|
-
"operationName"
|
|
10211
|
-
];
|
|
10212
|
-
var FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
|
|
10213
|
-
var GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
|
10214
|
-
function graphql(request2, query, options) {
|
|
10215
|
-
if (options) {
|
|
10216
|
-
if (typeof query === "string" && "query" in options) {
|
|
10217
|
-
return Promise.reject(
|
|
10218
|
-
new Error(`[@octokit/graphql] "query" cannot be used as variable name`)
|
|
10219
|
-
);
|
|
10220
|
-
}
|
|
10221
|
-
for (const key in options) {
|
|
10222
|
-
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) continue;
|
|
10223
|
-
return Promise.reject(
|
|
10224
|
-
new Error(
|
|
10225
|
-
`[@octokit/graphql] "${key}" cannot be used as variable name`
|
|
10226
|
-
)
|
|
10227
|
-
);
|
|
10228
|
-
}
|
|
10229
|
-
}
|
|
10230
|
-
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
|
|
10231
|
-
const requestOptions = Object.keys(
|
|
10232
|
-
parsedOptions
|
|
10233
|
-
).reduce((result, key) => {
|
|
10234
|
-
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
|
10235
|
-
result[key] = parsedOptions[key];
|
|
10236
|
-
return result;
|
|
10237
|
-
}
|
|
10238
|
-
if (!result.variables) {
|
|
10239
|
-
result.variables = {};
|
|
10240
|
-
}
|
|
10241
|
-
result.variables[key] = parsedOptions[key];
|
|
10242
|
-
return result;
|
|
10243
|
-
}, {});
|
|
10244
|
-
const baseUrl = parsedOptions.baseUrl || request2.endpoint.DEFAULTS.baseUrl;
|
|
10245
|
-
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
|
10246
|
-
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
|
10247
|
-
}
|
|
10248
|
-
return request2(requestOptions).then((response) => {
|
|
10249
|
-
if (response.data.errors) {
|
|
10250
|
-
const headers = {};
|
|
10251
|
-
for (const key of Object.keys(response.headers)) {
|
|
10252
|
-
headers[key] = response.headers[key];
|
|
10253
|
-
}
|
|
10254
|
-
throw new GraphqlResponseError(
|
|
10255
|
-
requestOptions,
|
|
10256
|
-
headers,
|
|
10257
|
-
response.data
|
|
10258
|
-
);
|
|
10259
|
-
}
|
|
10260
|
-
return response.data.data;
|
|
10261
|
-
});
|
|
10262
|
-
}
|
|
10263
|
-
|
|
10264
|
-
// pkg/dist-src/with-defaults.js
|
|
10265
|
-
function withDefaults(request2, newDefaults) {
|
|
10266
|
-
const newRequest = request2.defaults(newDefaults);
|
|
10267
|
-
const newApi = (query, options) => {
|
|
10268
|
-
return graphql(newRequest, query, options);
|
|
10269
|
-
};
|
|
10270
|
-
return Object.assign(newApi, {
|
|
10271
|
-
defaults: withDefaults.bind(null, newRequest),
|
|
10272
|
-
endpoint: newRequest.endpoint
|
|
10273
|
-
});
|
|
10274
|
-
}
|
|
10275
|
-
|
|
10276
|
-
// pkg/dist-src/index.js
|
|
10277
|
-
withDefaults(request, {
|
|
10278
|
-
headers: {
|
|
10279
|
-
"user-agent": `octokit-graphql.js/${VERSION$1} ${getUserAgent()}`
|
|
10280
|
-
},
|
|
10281
|
-
method: "POST",
|
|
10282
|
-
url: "/graphql"
|
|
10283
|
-
});
|
|
10284
|
-
function withCustomRequest(customRequest) {
|
|
10285
|
-
return withDefaults(customRequest, {
|
|
10286
|
-
method: "POST",
|
|
10287
|
-
url: "/graphql"
|
|
10288
|
-
});
|
|
10289
|
-
}
|
|
10290
|
-
|
|
10291
|
-
// pkg/dist-src/is-jwt.js
|
|
10292
|
-
var b64url = "(?:[a-zA-Z0-9_-]+)";
|
|
10293
|
-
var sep = "\\.";
|
|
10294
|
-
var jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);
|
|
10295
|
-
var isJWT = jwtRE.test.bind(jwtRE);
|
|
10296
|
-
|
|
10297
|
-
// pkg/dist-src/auth.js
|
|
10298
|
-
async function auth(token) {
|
|
10299
|
-
const isApp = isJWT(token);
|
|
10300
|
-
const isInstallation = token.startsWith("v1.") || token.startsWith("ghs_");
|
|
10301
|
-
const isUserToServer = token.startsWith("ghu_");
|
|
10302
|
-
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
|
10303
|
-
return {
|
|
10304
|
-
type: "token",
|
|
10305
|
-
token,
|
|
10306
|
-
tokenType
|
|
10307
|
-
};
|
|
10308
|
-
}
|
|
10309
|
-
|
|
10310
|
-
// pkg/dist-src/with-authorization-prefix.js
|
|
10311
|
-
function withAuthorizationPrefix(token) {
|
|
10312
|
-
if (token.split(/\./).length === 3) {
|
|
10313
|
-
return `bearer ${token}`;
|
|
10314
|
-
}
|
|
10315
|
-
return `token ${token}`;
|
|
10316
|
-
}
|
|
10317
|
-
|
|
10318
|
-
// pkg/dist-src/hook.js
|
|
10319
|
-
async function hook(token, request, route, parameters) {
|
|
10320
|
-
const endpoint = request.endpoint.merge(
|
|
10321
|
-
route,
|
|
10322
|
-
parameters
|
|
10323
|
-
);
|
|
10324
|
-
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
|
10325
|
-
return request(endpoint);
|
|
10326
|
-
}
|
|
10327
|
-
|
|
10328
|
-
// pkg/dist-src/index.js
|
|
10329
|
-
var createTokenAuth = function createTokenAuth2(token) {
|
|
10330
|
-
if (!token) {
|
|
10331
|
-
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
|
10332
|
-
}
|
|
10333
|
-
if (typeof token !== "string") {
|
|
10334
|
-
throw new Error(
|
|
10335
|
-
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
|
10336
|
-
);
|
|
10337
|
-
}
|
|
10338
|
-
token = token.replace(/^(token|bearer) +/i, "");
|
|
10339
|
-
return Object.assign(auth.bind(null, token), {
|
|
10340
|
-
hook: hook.bind(null, token)
|
|
10341
|
-
});
|
|
10342
|
-
};
|
|
10343
|
-
|
|
10344
|
-
const VERSION = "7.0.6";
|
|
10345
|
-
|
|
10346
|
-
const noop = () => {
|
|
10347
|
-
};
|
|
10348
|
-
const consoleWarn = console.warn.bind(console);
|
|
10349
|
-
const consoleError = console.error.bind(console);
|
|
10350
|
-
function createLogger(logger = {}) {
|
|
10351
|
-
if (typeof logger.debug !== "function") {
|
|
10352
|
-
logger.debug = noop;
|
|
10353
|
-
}
|
|
10354
|
-
if (typeof logger.info !== "function") {
|
|
10355
|
-
logger.info = noop;
|
|
10356
|
-
}
|
|
10357
|
-
if (typeof logger.warn !== "function") {
|
|
10358
|
-
logger.warn = consoleWarn;
|
|
10359
|
-
}
|
|
10360
|
-
if (typeof logger.error !== "function") {
|
|
10361
|
-
logger.error = consoleError;
|
|
10362
|
-
}
|
|
10363
|
-
return logger;
|
|
10364
|
-
}
|
|
10365
|
-
const userAgentTrail = `octokit-core.js/${VERSION} ${getUserAgent()}`;
|
|
10366
|
-
class Octokit {
|
|
10367
|
-
static VERSION = VERSION;
|
|
10368
|
-
static defaults(defaults) {
|
|
10369
|
-
const OctokitWithDefaults = class extends this {
|
|
10370
|
-
constructor(...args) {
|
|
10371
|
-
const options = args[0] || {};
|
|
10372
|
-
if (typeof defaults === "function") {
|
|
10373
|
-
super(defaults(options));
|
|
10374
|
-
return;
|
|
10375
|
-
}
|
|
10376
|
-
super(
|
|
10377
|
-
Object.assign(
|
|
10378
|
-
{},
|
|
10379
|
-
defaults,
|
|
10380
|
-
options,
|
|
10381
|
-
options.userAgent && defaults.userAgent ? {
|
|
10382
|
-
userAgent: `${options.userAgent} ${defaults.userAgent}`
|
|
10383
|
-
} : null
|
|
10384
|
-
)
|
|
10385
|
-
);
|
|
10386
|
-
}
|
|
10387
|
-
};
|
|
10388
|
-
return OctokitWithDefaults;
|
|
10389
|
-
}
|
|
10390
|
-
static plugins = [];
|
|
10391
|
-
/**
|
|
10392
|
-
* Attach a plugin (or many) to your Octokit instance.
|
|
10393
|
-
*
|
|
10394
|
-
* @example
|
|
10395
|
-
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
|
10396
|
-
*/
|
|
10397
|
-
static plugin(...newPlugins) {
|
|
10398
|
-
const currentPlugins = this.plugins;
|
|
10399
|
-
const NewOctokit = class extends this {
|
|
10400
|
-
static plugins = currentPlugins.concat(
|
|
10401
|
-
newPlugins.filter((plugin) => !currentPlugins.includes(plugin))
|
|
10402
|
-
);
|
|
10403
|
-
};
|
|
10404
|
-
return NewOctokit;
|
|
10405
|
-
}
|
|
10406
|
-
constructor(options = {}) {
|
|
10407
|
-
const hook = new Hook.Collection();
|
|
10408
|
-
const requestDefaults = {
|
|
10409
|
-
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
|
10410
|
-
headers: {},
|
|
10411
|
-
request: Object.assign({}, options.request, {
|
|
10412
|
-
// @ts-ignore internal usage only, no need to type
|
|
10413
|
-
hook: hook.bind(null, "request")
|
|
10414
|
-
}),
|
|
10415
|
-
mediaType: {
|
|
10416
|
-
previews: [],
|
|
10417
|
-
format: ""
|
|
10418
|
-
}
|
|
10419
|
-
};
|
|
10420
|
-
requestDefaults.headers["user-agent"] = options.userAgent ? `${options.userAgent} ${userAgentTrail}` : userAgentTrail;
|
|
10421
|
-
if (options.baseUrl) {
|
|
10422
|
-
requestDefaults.baseUrl = options.baseUrl;
|
|
10423
|
-
}
|
|
10424
|
-
if (options.previews) {
|
|
10425
|
-
requestDefaults.mediaType.previews = options.previews;
|
|
10426
|
-
}
|
|
10427
|
-
if (options.timeZone) {
|
|
10428
|
-
requestDefaults.headers["time-zone"] = options.timeZone;
|
|
10429
|
-
}
|
|
10430
|
-
this.request = request.defaults(requestDefaults);
|
|
10431
|
-
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
|
10432
|
-
this.log = createLogger(options.log);
|
|
10433
|
-
this.hook = hook;
|
|
10434
|
-
if (!options.authStrategy) {
|
|
10435
|
-
if (!options.auth) {
|
|
10436
|
-
this.auth = async () => ({
|
|
10437
|
-
type: "unauthenticated"
|
|
10438
|
-
});
|
|
10439
|
-
} else {
|
|
10440
|
-
const auth = createTokenAuth(options.auth);
|
|
10441
|
-
hook.wrap("request", auth.hook);
|
|
10442
|
-
this.auth = auth;
|
|
10443
|
-
}
|
|
10444
|
-
} else {
|
|
10445
|
-
const { authStrategy, ...otherOptions } = options;
|
|
10446
|
-
const auth = authStrategy(
|
|
10447
|
-
Object.assign(
|
|
10448
|
-
{
|
|
10449
|
-
request: this.request,
|
|
10450
|
-
log: this.log,
|
|
10451
|
-
// we pass the current octokit instance as well as its constructor options
|
|
10452
|
-
// to allow for authentication strategies that return a new octokit instance
|
|
10453
|
-
// that shares the same internal state as the current one. The original
|
|
10454
|
-
// requirement for this was the "event-octokit" authentication strategy
|
|
10455
|
-
// of https://github.com/probot/octokit-auth-probot.
|
|
10456
|
-
octokit: this,
|
|
10457
|
-
octokitOptions: otherOptions
|
|
10458
|
-
},
|
|
10459
|
-
options.auth
|
|
10460
|
-
)
|
|
10461
|
-
);
|
|
10462
|
-
hook.wrap("request", auth.hook);
|
|
10463
|
-
this.auth = auth;
|
|
10464
|
-
}
|
|
10465
|
-
const classConstructor = this.constructor;
|
|
10466
|
-
for (let i = 0; i < classConstructor.plugins.length; ++i) {
|
|
10467
|
-
Object.assign(this, classConstructor.plugins[i](this, options));
|
|
10468
|
-
}
|
|
10469
|
-
}
|
|
10470
|
-
// assigned during constructor
|
|
10471
|
-
request;
|
|
10472
|
-
graphql;
|
|
10473
|
-
log;
|
|
10474
|
-
hook;
|
|
10475
|
-
// TODO: type `octokit.auth` based on passed options.authStrategy
|
|
10476
|
-
auth;
|
|
10477
|
-
}
|
|
10478
|
-
|
|
10479
|
-
const issueStatusCache = new Map();
|
|
10480
|
-
const fetchIsIssueOpen = async (owner, repo, issueNumber) => {
|
|
10481
|
-
const requestIssue = (auth) => new Octokit({ auth }).request("GET /repos/{owner}/{repo}/issues/{issue_number}", {
|
|
10482
|
-
owner,
|
|
10483
|
-
repo,
|
|
10484
|
-
issue_number: issueNumber,
|
|
10485
|
-
headers: { "X-GitHub-Api-Version": "2022-11-28" },
|
|
10486
|
-
});
|
|
10487
|
-
try {
|
|
10488
|
-
const { data } = await requestIssue(await getGithubToken());
|
|
10489
|
-
return data.state === "open";
|
|
10490
|
-
}
|
|
10491
|
-
catch (error) {
|
|
10492
|
-
// 401 means the cached token was revoked — mint a fresh one and retry once.
|
|
10493
|
-
if (error.status !== 401)
|
|
10494
|
-
throw error;
|
|
10495
|
-
const { data } = await requestIssue(await getGithubToken({ forceRefresh: true }));
|
|
10496
|
-
return data.state === "open";
|
|
10497
|
-
}
|
|
10498
|
-
};
|
|
10499
|
-
const isIssueOpen = (issueLink) => {
|
|
10500
|
-
const [owner, repo, ...rest] = (issueLink.split(/[?#]/)[0].split("github.com/").at(-1) ?? "")
|
|
10501
|
-
.split("/")
|
|
10502
|
-
.filter(Boolean);
|
|
10503
|
-
const issueNumber = Number(rest.at(-1));
|
|
10504
|
-
if (!owner || !repo || !Number.isInteger(issueNumber))
|
|
10505
|
-
failTest(`[isGithubIssueOpen] Invalid GitHub issue link: ${issueLink}`);
|
|
10506
|
-
const cacheKey = `${owner}/${repo}#${issueNumber}`;
|
|
10507
|
-
const cachedStatus = issueStatusCache.get(cacheKey);
|
|
10508
|
-
if (cachedStatus)
|
|
10509
|
-
return cachedStatus;
|
|
10510
|
-
const status = fetchIsIssueOpen(owner, repo, issueNumber);
|
|
10511
|
-
issueStatusCache.set(cacheKey, status);
|
|
10512
|
-
status.catch(() => issueStatusCache.delete(cacheKey));
|
|
10513
|
-
return status;
|
|
10514
|
-
};
|
|
10515
|
-
const isGithubIssueOpen = async (issueLinks) => {
|
|
10516
|
-
const issueStatuses = await Promise.all(issueLinks.map(isIssueOpen));
|
|
10517
|
-
return issueStatuses.some(Boolean);
|
|
10518
|
-
};
|
|
10519
|
-
|
|
10520
|
-
const simulateTypingWithDelay = async ({ field, value, delay = 500, }) => {
|
|
10521
|
-
const minSliceLength = Math.max(3, Math.floor(value.length * 0.6));
|
|
10522
|
-
const maxSliceLength = Math.max(4, Math.floor(value.length * 0.8));
|
|
10523
|
-
const sliceLength = Math.floor(Math.random() * (maxSliceLength - minSliceLength + 1)) +
|
|
10524
|
-
minSliceLength;
|
|
10525
|
-
const maxBackspaceCount = Math.max(2, Math.min(4, Math.floor(sliceLength * 0.3)));
|
|
10526
|
-
const backspaceCount = Math.floor(Math.random() * (maxBackspaceCount - 1)) + 2;
|
|
10527
|
-
const textPart1 = value.slice(0, sliceLength);
|
|
10528
|
-
const textPart2 = value.slice(sliceLength - backspaceCount);
|
|
10529
|
-
await field.hover();
|
|
10530
|
-
await field.click({ delay: Math.floor(Math.random() * delay) + 700 });
|
|
10531
|
-
await field.pressSequentially(textPart1, {
|
|
10532
|
-
delay: Math.floor(Math.random() * delay) + 400,
|
|
10533
|
-
timeout: 30_000,
|
|
10534
|
-
});
|
|
10535
|
-
for (let i = 0; i < backspaceCount; i++) {
|
|
10536
|
-
await field.press("Backspace", {
|
|
10537
|
-
delay: Math.floor(Math.random() * 1000) + 300,
|
|
10538
|
-
});
|
|
10539
|
-
}
|
|
10540
|
-
await field.pressSequentially(textPart2, {
|
|
10541
|
-
delay: Math.floor(Math.random() * delay) + 700,
|
|
10542
|
-
timeout: 45_000,
|
|
10543
|
-
});
|
|
10544
|
-
};
|
|
10545
|
-
const simulateClickWithDelay = async ({ element, page, }) => {
|
|
10546
|
-
const locatorBoundingBox = await element.boundingBox();
|
|
10547
|
-
const clickX = locatorBoundingBox.x + locatorBoundingBox.width / 2 + 10;
|
|
10548
|
-
const clickY = locatorBoundingBox.y + locatorBoundingBox.height / 2 - 10;
|
|
10549
|
-
await element.hover();
|
|
10550
|
-
await page.mouse.click(clickX, clickY, {
|
|
10551
|
-
delay: Math.floor(Math.random() * 1000) + 1000,
|
|
10552
|
-
});
|
|
10553
|
-
};
|
|
7656
|
+
await field.pressSequentially(textPart2, {
|
|
7657
|
+
delay: Math.floor(Math.random() * delay) + 700,
|
|
7658
|
+
timeout: 45_000,
|
|
7659
|
+
});
|
|
7660
|
+
};
|
|
7661
|
+
const simulateClickWithDelay = async ({ element, page, }) => {
|
|
7662
|
+
const locatorBoundingBox = await element.boundingBox();
|
|
7663
|
+
const clickX = locatorBoundingBox.x + locatorBoundingBox.width / 2 + 10;
|
|
7664
|
+
const clickY = locatorBoundingBox.y + locatorBoundingBox.height / 2 - 10;
|
|
7665
|
+
await element.hover();
|
|
7666
|
+
await page.mouse.click(clickX, clickY, {
|
|
7667
|
+
delay: Math.floor(Math.random() * 1000) + 1000,
|
|
7668
|
+
});
|
|
7669
|
+
};
|
|
10554
7670
|
|
|
10555
7671
|
const phoneCodeToIsoMap = new Map(Object.entries(countries).flatMap(([isoCode, countryData]) => countryData?.phone?.map(phoneCode => [phoneCode, isoCode])));
|
|
10556
7672
|
const getIsoCodeFromPhoneCode = (phoneCode) => {
|
|
@@ -10704,6 +7820,18 @@ const httpCheck = async (url, timeout = 3000) => {
|
|
|
10704
7820
|
}
|
|
10705
7821
|
};
|
|
10706
7822
|
|
|
7823
|
+
// Let child projects select their own Yarn instead of inheriting the host's shim.
|
|
7824
|
+
const stripBerryBinFromEnv = () => {
|
|
7825
|
+
const { BERRY_BIN_FOLDER, ...env } = process.env;
|
|
7826
|
+
if (!BERRY_BIN_FOLDER || env.PATH === undefined)
|
|
7827
|
+
return env;
|
|
7828
|
+
return {
|
|
7829
|
+
...env,
|
|
7830
|
+
PATH: env.PATH.split(path.delimiter)
|
|
7831
|
+
.filter(dir => dir !== BERRY_BIN_FOLDER)
|
|
7832
|
+
.join(path.delimiter),
|
|
7833
|
+
};
|
|
7834
|
+
};
|
|
10707
7835
|
// The product's root is the nearest folder above the working directory that has the setup script.
|
|
10708
7836
|
const findRepoRoot = () => {
|
|
10709
7837
|
let dir = process.cwd();
|
|
@@ -10721,7 +7849,7 @@ const pollUntil = async ({ check, timeoutMs, intervalMs, }) => {
|
|
|
10721
7849
|
while (Date.now() < deadline) {
|
|
10722
7850
|
if (await check())
|
|
10723
7851
|
return true;
|
|
10724
|
-
await setTimeout
|
|
7852
|
+
await setTimeout(intervalMs);
|
|
10725
7853
|
}
|
|
10726
7854
|
return false;
|
|
10727
7855
|
};
|
|
@@ -10906,7 +8034,7 @@ class ProductServer {
|
|
|
10906
8034
|
const databaseUrl = new URL(process.env.DATABASE_URL ?? "postgresql://127.0.0.1");
|
|
10907
8035
|
databaseUrl.pathname = `/${database}`;
|
|
10908
8036
|
return {
|
|
10909
|
-
...
|
|
8037
|
+
...stripBerryBinFromEnv(),
|
|
10910
8038
|
BUNDLE_PATH: undefined,
|
|
10911
8039
|
BUNDLE_GEMFILE: undefined,
|
|
10912
8040
|
BUNDLE_APP_CONFIG: undefined,
|
|
@@ -11103,15 +8231,6 @@ class ProductServer {
|
|
|
11103
8231
|
}
|
|
11104
8232
|
|
|
11105
8233
|
const { name, paths, webpackDevFile, setupScript, baseUrl, readyUrl, maxWaitMs, } = CHAT_WIDGET;
|
|
11106
|
-
// A product on Yarn 4 puts its own yarn first on PATH for the scripts it runs, so it's dropped to let the widget use its own Yarn.
|
|
11107
|
-
const widgetEnv = (extraEnv = {}) => {
|
|
11108
|
-
const { BERRY_BIN_FOLDER, ...env } = process.env;
|
|
11109
|
-
const PATH = (env.PATH ?? "")
|
|
11110
|
-
.split(path.delimiter)
|
|
11111
|
-
.filter(dir => !BERRY_BIN_FOLDER || dir !== BERRY_BIN_FOLDER)
|
|
11112
|
-
.join(path.delimiter);
|
|
11113
|
-
return { ...env, PATH, ...extraEnv };
|
|
11114
|
-
};
|
|
11115
8234
|
// Runs neeto-chat-widget's webpack dev server, as it isn't a Rails product; workers share it like ProductServer.
|
|
11116
8235
|
class WidgetServer {
|
|
11117
8236
|
log = (msg) => console.log(`[LocalServer:${name}] ${msg}`);
|
|
@@ -11157,7 +8276,7 @@ class WidgetServer {
|
|
|
11157
8276
|
command: "bash",
|
|
11158
8277
|
args: [setupScript, paths.DIR],
|
|
11159
8278
|
logFile: paths.SETUP_LOG,
|
|
11160
|
-
env:
|
|
8279
|
+
env: { ...stripBerryBinFromEnv(), GITHUB_TOKEN: githubToken },
|
|
11161
8280
|
});
|
|
11162
8281
|
fs.writeFileSync(paths.PREPARED_MARKER, "");
|
|
11163
8282
|
}
|
|
@@ -11176,7 +8295,7 @@ class WidgetServer {
|
|
|
11176
8295
|
args: ["start"],
|
|
11177
8296
|
logFile: paths.LOG,
|
|
11178
8297
|
cwd: paths.DIR,
|
|
11179
|
-
env:
|
|
8298
|
+
env: stripBerryBinFromEnv(),
|
|
11180
8299
|
});
|
|
11181
8300
|
fs.writeFileSync(paths.STATE_FILE, JSON.stringify({ pid }));
|
|
11182
8301
|
this.log("Server ready.");
|
|
@@ -11379,13 +8498,6 @@ const parseSpecPatterns = () => {
|
|
|
11379
8498
|
};
|
|
11380
8499
|
|
|
11381
8500
|
// @ts-check
|
|
11382
|
-
const envBasePath = "./e2e/config/.env";
|
|
11383
|
-
const envLocalPath = `${envBasePath}.local`;
|
|
11384
|
-
const reporterPackageName = "@bigbinary/neeto-playwright-reporter";
|
|
11385
|
-
process.env.TEST_ENV = process.env.TEST_ENV ?? ENVIRONMENT.development;
|
|
11386
|
-
const loadEnv = (path) => dotenv.config({ path, quiet: true });
|
|
11387
|
-
loadEnv(`${envBasePath}.${process.env.TEST_ENV}`);
|
|
11388
|
-
fs.existsSync(envLocalPath) && loadEnv(envLocalPath);
|
|
11389
8501
|
const playdashStagingConfig = {
|
|
11390
8502
|
apiKey: process.env.PLAYDASH_STAGING_API_KEY,
|
|
11391
8503
|
ciBuildId: process.env.NEETO_CI_JOB_ID,
|
|
@@ -11407,6 +8519,7 @@ const playdashProductionHealthConfig = {
|
|
|
11407
8519
|
ciBuildId: process.env.NEETO_CI_JOB_ID,
|
|
11408
8520
|
tags: process.env.TAG,
|
|
11409
8521
|
};
|
|
8522
|
+
const reporterPackageName = "@bigbinary/neeto-playwright-reporter";
|
|
11410
8523
|
const railsPort = process.env.RAILS_SERVER_PORT;
|
|
11411
8524
|
const vitePort = process.env.VITE_PORT;
|
|
11412
8525
|
const isPlaywrightRun = process.env.PLAYWRIGHT_RUN === "true";
|
|
@@ -11687,4 +8800,4 @@ class InboundEmailApis {
|
|
|
11687
8800
|
};
|
|
11688
8801
|
}
|
|
11689
8802
|
|
|
11690
|
-
export { ACME_SUBDOMAIN, ACTIONS, ADMIN_PANEL_SELECTORS, ALL_RESOURCES, ANALYTICS_RESOURCES, API_ROUTES, APP_RESOURCES, AUDIT_LOGS_SELECTORS, AuditLogsPage, BASE_URL, CALENDAR_LABELS, CERTIFICATE_LIMIT_EXCEEDED_MESSAGE, CERTIFICATE_LIMIT_EXCEEDED_REGEXP, CERTIFICATE_PROVISION_FAILED_MESSAGE, CERTIFICATE_PROVISION_FAILED_REGEXP, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, CHAT_WIDGET_TEXTS, COLOR, COMMON_SELECTORS, COMMON_TEXTS, COMMUNITY_TEXTS, CREDENTIALS, CURRENT_TIME_RANGES, CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX, CUSTOM_DOMAIN_SELECTORS, CUSTOM_DOMAIN_SUFFIX, ColorPickerUtils, CustomCommands, CustomDomainApi, CustomDomainPage, DATE_FORMATS, DATE_PICKER_SELECTORS, DATE_RANGES, DATE_TEXTS, DEFAULT_TIMEZONE_ID, DEFAULT_WEBHOOKS_RESPONSE_TEXT, DESCRIPTION_EDITOR_TEXTS, EDITOR_VERIFY_TEXT_COLOR, EMBED_SELECTORS, EMOJI_LABEL, EMPTY_STORAGE_STATE, ENGAGE_TEXTS, ENVIRONMENT, EXAMPLE_URL, EXPANDED_FONT_SIZE, EXPORT_FILE_TYPES, EditorPage, EmailDeliveryUtils, EmbedBase, FILE_FORMATS, FONTS_RESOURCES, FONT_SIZE_SELECTORS, FROM_EMAIL_ENV_KEYS, GLOBAL_TRANSLATIONS_PATTERN, GOOGLE_ANALYTICS_SELECTORS, GOOGLE_CALENDAR_DATE_FORMAT, GOOGLE_LOGIN_SELECTORS, GOOGLE_LOGIN_TEXTS, GOOGLE_SHEETS_SELECTORS, GooglePage, HELP_CENTER_ROUTES, HELP_CENTER_SELECTORS, HelpAndProfilePage, INTEGRATIONS_TEXTS, INTEGRATION_SELECTORS, IPRestrictionsPage, IP_RESTRICTIONS_SELECTORS, IS_CI, IS_DEV_CI, IS_DEV_ENV, IS_PLAYWRIGHT_RUN, IS_REVIEW_ENV, IS_STAGING_ENV, IS_WEBKIT, ImageUploader, InboundEmailApis, IntegrationBase, IpRestrictionsApi, KEYBOARD_SHORTCUTS_SELECTORS, KEYBOARD_SHORTCUT_TEST_CASES, LIST_MODIFIER_SELECTORS, LIST_MODIFIER_TAGS, LOGIN_DEFAULTS, LOGIN_SELECTORS, LOGIN_STRATEGIES, LOGIN_TIMEOUT, LocalServer, MAILPIT_BASE_URL, MAILPIT_DOMAIN_NAME, MICROSOFT_LOGIN_SELECTORS, MICROSOFT_LOGIN_TEXTS, MailerUtils, MailpitApi, MicrosoftPage, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, NEETO_IMAGE_UPLOADER_SELECTORS, NEETO_ROUTES, NEETO_SEO_SELECTORS, NEETO_TEXT_MODIFIER_SELECTORS, NeetoEmailDeliveryApi, NeetoTowerApi, ONBOARDING_SELECTORS, ORGANIZATION_TEXTS, OTP_EMAIL_PATTERN, OTP_FETCH_TIMEOUT, OrganizationPage, PAST_TIME_RANGES, PHONE_NUMBER_FORMATS, PLURAL, PROFILE_LINKS, PROFILE_SECTION_SELECTORS, PROJECT_NAMES, PROJECT_TRANSLATIONS_PATH, REVIEW_APP_CUSTOM_DOMAIN_SUFFIX, ROUTES, RailsEmailApiClient, RailsEmailUtils, SIGNUP_SELECTORS, SINGULAR, SLACK_DATA_QA_SELECTORS, SLACK_DEFAULT_CHANNEL, SLACK_SELECTORS, SLACK_WEB_TEXTS, STATUS_TEXTS, STORAGE_STATE, SecurityApi, SidebarSection, SlackApi, SlackPage, SmsApi, SmsUtils, TABLE_SELECTORS, TAB_SELECTORS, TEXT_MODIFIER_ROLES, TEXT_MODIFIER_SELECTORS, TEXT_MODIFIER_TAGS, THANK_YOU_SELECTORS, THEMES_SELECTORS, THEMES_TEXTS, THIRD_PARTY_RESOURCES, THIRD_PARTY_ROUTES, TIME_RANGES, TOASTR_MESSAGES, TRAEFIK_NOT_FOUND_TEXT, TWILIO_SELECTORS, ThankYouApi, ThankYouPage, TwilioApi, USER_AGENTS, WebhookSiteApi, ZAPIER_LIMIT_EXHAUSTED_MESSAGE, ZAPIER_SELECTORS, ZAPIER_TEST_EMAIL, ZAPIER_WEB_TEXTS, ZapierPage, authenticateUser, baseURLGenerator, basicHTMLContent, clearCredentials, commands, cpuThrottlingUsingCDP, createOrganizationViaApi, createOrganizationViaRake, currencyUtils, dataQa, decodeQRCodeFromFile, definePlaywrightConfig, exampleEmail, executeWithThrottledResources, extractSubdomainFromError, failTest, filterUtils, fixedMenuSelector, generatePhoneNumber, generatePhoneNumberDetails, generateRandomBypassEmail, generateRandomFile, generateStagingData, getByDataQA, getClipboardContent, getFormattedPhoneNumber, getFullUrl, getGithubToken, getGlobalUserProps, getGlobalUserState, getImagePathAndName, getIsoCodeFromPhoneCode, getListCount, getRailsT, globalShortcuts, grantClipboardPermissions, hexToRGB, hexToRGBA, i18nFixture, imageRegex, initializeCredentials, initializeReviewAppCredentials, initializeTestData, initializeTotp, isGithubIssueOpen, isStagingOrganizationExpired, joinHyphenCase, joinString, login, loginToReviewApp, mailpitDomainName, minutesAgo, networkConditions, networkThrottlingUsingCDP, optionSelector, railsTFixture, readFileAsBrowserFile, readFileSyncIfExists, removeCredentialFile, requireEnv, reviewAppBaseURL, reviewAppOrganizationOptions, saveStorageState, serializeFileForBrowser, shouldSkipCustomDomainSetup, shouldSkipSetupAndTeardown, simulateClickWithDelay, simulateTypingWithDelay, skipTest, squish, stealth as stealthTest, tableUtils, toCamelCase, updateCredentials, waitForReviewApp, warmup, withCookieCache, writeDataToFile };
|
|
8803
|
+
export { ACME_SUBDOMAIN, ACTIONS, ADMIN_PANEL_SELECTORS, ALL_RESOURCES, ANALYTICS_RESOURCES, API_ROUTES, APP_RESOURCES, AUDIT_LOGS_SELECTORS, AuditLogsPage, BASE_URL, CALENDAR_LABELS, CERTIFICATE_LIMIT_EXCEEDED_MESSAGE, CERTIFICATE_LIMIT_EXCEEDED_REGEXP, CERTIFICATE_PROVISION_FAILED_MESSAGE, CERTIFICATE_PROVISION_FAILED_REGEXP, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, CHAT_WIDGET_TEXTS, COLOR, COMMON_SELECTORS, COMMON_TEXTS, COMMUNITY_TEXTS, CREDENTIALS, CURRENT_TIME_RANGES, CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX, CUSTOM_DOMAIN_SELECTORS, CUSTOM_DOMAIN_SUFFIX, ColorPickerUtils, CustomCommands, CustomDomainApi, CustomDomainPage, DATE_FORMATS, DATE_PICKER_SELECTORS, DATE_RANGES, DATE_TEXTS, DEFAULT_TIMEZONE_ID, DEFAULT_WEBHOOKS_RESPONSE_TEXT, DESCRIPTION_EDITOR_TEXTS, EDITOR_VERIFY_TEXT_COLOR, EMBED_SELECTORS, EMOJI_LABEL, EMPTY_STORAGE_STATE, ENGAGE_TEXTS, ENVIRONMENT, EXAMPLE_URL, EXPANDED_FONT_SIZE, EXPORT_FILE_TYPES, EditorPage, EmailDeliveryUtils, EmbedBase, FILE_FORMATS, FONTS_RESOURCES, FONT_SIZE_SELECTORS, FROM_EMAIL_ENV_KEYS, GLOBAL_TRANSLATIONS_PATTERN, GOOGLE_ANALYTICS_SELECTORS, GOOGLE_CALENDAR_DATE_FORMAT, GOOGLE_LOGIN_SELECTORS, GOOGLE_LOGIN_TEXTS, GOOGLE_SHEETS_SELECTORS, GooglePage, HELP_CENTER_ROUTES, HELP_CENTER_SELECTORS, HelpAndProfilePage, INTEGRATIONS_TEXTS, INTEGRATION_SELECTORS, IPRestrictionsPage, IP_RESTRICTIONS_SELECTORS, IS_CI, IS_DEV_CI, IS_DEV_ENV, IS_PLAYWRIGHT_RUN, IS_REVIEW_ENV, IS_STAGING_ENV, IS_WEBKIT, ImageUploader, InboundEmailApis, IntegrationBase, IpRestrictionsApi, KEYBOARD_SHORTCUTS_SELECTORS, KEYBOARD_SHORTCUT_TEST_CASES, LIST_MODIFIER_SELECTORS, LIST_MODIFIER_TAGS, LOGIN_DEFAULTS, LOGIN_SELECTORS, LOGIN_STRATEGIES, LOGIN_TIMEOUT, LocalServer, MAILPIT_BASE_URL, MAILPIT_DOMAIN_NAME, MICROSOFT_LOGIN_SELECTORS, MICROSOFT_LOGIN_TEXTS, MailerUtils, MailpitApi, MicrosoftPage, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, NEETO_IMAGE_UPLOADER_SELECTORS, NEETO_ROUTES, NEETO_SEO_SELECTORS, NEETO_TEXT_MODIFIER_SELECTORS, NeetoEmailDeliveryApi, NeetoTowerApi, ONBOARDING_SELECTORS, ORGANIZATION_TEXTS, OTP_EMAIL_PATTERN, OTP_FETCH_TIMEOUT, OrganizationPage, PAST_TIME_RANGES, PHONE_NUMBER_FORMATS, PLURAL, PROFILE_LINKS, PROFILE_SECTION_SELECTORS, PROJECT_NAMES, PROJECT_TRANSLATIONS_PATH, REVIEW_APP_CUSTOM_DOMAIN_SUFFIX, ROUTES, RailsEmailApiClient, RailsEmailUtils, SIGNUP_SELECTORS, SINGULAR, SLACK_DATA_QA_SELECTORS, SLACK_DEFAULT_CHANNEL, SLACK_SELECTORS, SLACK_WEB_TEXTS, STATUS_TEXTS, STORAGE_STATE, SecurityApi, SidebarSection, SlackApi, SlackPage, SmsApi, SmsUtils, TABLE_SELECTORS, TAB_SELECTORS, TEXT_MODIFIER_ROLES, TEXT_MODIFIER_SELECTORS, TEXT_MODIFIER_TAGS, THANK_YOU_SELECTORS, THEMES_SELECTORS, THEMES_TEXTS, THIRD_PARTY_RESOURCES, THIRD_PARTY_ROUTES, TIME_RANGES, TOASTR_MESSAGES, TRAEFIK_NOT_FOUND_TEXT, TWILIO_SELECTORS, ThankYouApi, ThankYouPage, TwilioApi, USER_AGENTS, WebhookSiteApi, ZAPIER_LIMIT_EXHAUSTED_MESSAGE, ZAPIER_SELECTORS, ZAPIER_TEST_EMAIL, ZAPIER_WEB_TEXTS, ZapierPage, authenticateUser, baseURLGenerator, basicHTMLContent, clearCredentials, commands, cpuThrottlingUsingCDP, createOrganizationViaApi, createOrganizationViaRake, currencyUtils, dataQa, decodeQRCodeFromFile, definePlaywrightConfig, exampleEmail, executeWithThrottledResources, extractSubdomainFromError, failTest, fillTotpWhenReady, filterUtils, fixedMenuSelector, generatePhoneNumber, generatePhoneNumberDetails, generateRandomBypassEmail, generateRandomFile, generateStagingData, getByDataQA, getClipboardContent, getFormattedPhoneNumber, getFullUrl, getGithubToken, getGlobalUserProps, getGlobalUserState, getI18nInstance, getImagePathAndName, getIsoCodeFromPhoneCode, getListCount, getRailsT, globalShortcuts, grantClipboardPermissions, hexToRGB, hexToRGBA, i18nFixture, imageRegex, initializeCredentials, initializeReviewAppCredentials, initializeTestData, initializeTotp, isGithubIssueOpen, isStagingOrganizationExpired, joinHyphenCase, joinString, login, loginToReviewApp, mailpitDomainName, minutesAgo, networkConditions, networkThrottlingUsingCDP, optionSelector, railsTFixture, readFileAsBrowserFile, readFileSyncIfExists, removeCredentialFile, requireEnv, reviewAppBaseURL, reviewAppOrganizationOptions, saveStorageState, serializeFileForBrowser, shouldSkipCustomDomainSetup, shouldSkipSetupAndTeardown, simulateClickWithDelay, simulateTypingWithDelay, skipTest, squish, stealth as stealthTest, tableUtils, toCamelCase, updateCredentials, waitForReviewApp, warmup, withCookieCache, writeDataToFile };
|