First upload version 0.0.1
This commit is contained in:
21
node_modules/@octokit/auth-unauthenticated/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/auth-unauthenticated/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2020 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
148
node_modules/@octokit/auth-unauthenticated/README.md
generated
vendored
Normal file
148
node_modules/@octokit/auth-unauthenticated/README.md
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
# auth-unauthenticated.js
|
||||
|
||||
> strategy for explicitly unauthenticated Octokit instances
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/auth-unauthenticated)
|
||||
[](https://github.com/octokit/auth-unauthenticated.js/actions?query=workflow%3ATest)
|
||||
|
||||
`@octokit/auth-unauthenticated` is useful for cases when an Octokit constructor has a default authentication strategy, but you require an explicitly unauthenticated instance.
|
||||
|
||||
One use cases is when building a GitHub App using [`@octokit/auth-app`](https://github.com/octokit/auth-app.js) and handling webhooks using [`@octokit/webhooks`](https://github.com/octokit/webhooks.js). While all webhook events provide an installation ID in its payload, in case of the `installation.deleted` event, the app can no longer create an installation access token, because the app's access has been revoked.
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [`createUnauthenticatedAuth() options`](#createunauthenticatedauth-options)
|
||||
- [`auth()`](#auth)
|
||||
- [Authentication object](#authentication-object)
|
||||
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
|
||||
- [License](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
|
||||
Load `@octokit/auth-unauthenticated` directly from [esm.sh](https://esm.sh)
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { createUnauthenticatedAuth } from "https://esm.sh/@octokit/auth-unauthenticated";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/auth-unauthenticated</code>
|
||||
|
||||
```js
|
||||
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
> [!IMPORTANT]
|
||||
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`.
|
||||
>
|
||||
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
|
||||
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
|
||||
|
||||
```js
|
||||
const auth = createUnauthenticatedAuth({
|
||||
reason:
|
||||
"Handling an installation.deleted event (The app's access has been revoked)",
|
||||
});
|
||||
const authentication = await auth();
|
||||
// {
|
||||
// type: 'unauthenticated',
|
||||
// reason: 'Handling an installation.deleted event (The app's access has been revoked)'
|
||||
// }
|
||||
```
|
||||
|
||||
## `createUnauthenticatedAuth() options`
|
||||
|
||||
The `createUnauthenticatedAuth` method requires an `options.reason` argument which will be used when returning an error due to a lack of authentication or when logging a warning in case of a `404` error.
|
||||
|
||||
Examples
|
||||
|
||||
```js
|
||||
createUnauthenticatedAuth({
|
||||
reason:
|
||||
"Handling an installation.deleted event: The app's access has been revoked from @octokit (id: 12345)",
|
||||
});
|
||||
```
|
||||
|
||||
## `auth()`
|
||||
|
||||
The `auth()` method accepts any options, but it doesn't do anything with it. That makes it a great drop-in replacement for any other authentication strategy.
|
||||
|
||||
## Authentication object
|
||||
|
||||
<table width="100%">
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th width=150>
|
||||
name
|
||||
</th>
|
||||
<th width=70>
|
||||
type
|
||||
</th>
|
||||
<th>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th>
|
||||
<code>type</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"unauthenticated"</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## `auth.hook(request, route, options)` or `auth.hook(request, options)`
|
||||
|
||||
`auth.hook()` hooks directly into the request life cycle. If a mutating request is attempted to be sent (`DELETE`, `PATCH`, `POST`, or `PUT`), the request is failed immediately and returning an error that contains the reason passed to `createUnauthenticatedAuth({ reason })`.
|
||||
|
||||
If a request fails with a `404` or due to hitting a rate/abuse limit, the returned error is amended that it might be caused due to a lack of authentication and will include the reason passed to `createUnauthenticatedAuth({ reason })`.
|
||||
|
||||
The `request` option is an instance of [`@octokit/request`](https://github.com/octokit/request.js#readme). The `route`/`options` parameters are the same as for the [`request()` method](https://github.com/octokit/request.js#request).
|
||||
|
||||
`auth.hook()` can be called directly to send an authenticated request
|
||||
|
||||
```js
|
||||
const { data } = await auth.hook(request, "GET /");
|
||||
```
|
||||
|
||||
Or it can be passed as option to [`request()`](https://github.com/octokit/request.js#request).
|
||||
|
||||
```js
|
||||
const requestWithAuth = request.defaults({
|
||||
request: {
|
||||
hook: auth.hook,
|
||||
},
|
||||
});
|
||||
|
||||
const { data } = await requestWithAuth("GET /");
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
75
node_modules/@octokit/auth-unauthenticated/dist-node/index.js
generated
vendored
Normal file
75
node_modules/@octokit/auth-unauthenticated/dist-node/index.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
// pkg/dist-src/auth.js
|
||||
async function auth(reason) {
|
||||
return {
|
||||
type: "unauthenticated",
|
||||
reason
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/is-rate-limit-error.js
|
||||
function isRateLimitError(error) {
|
||||
if (error.status !== 403) {
|
||||
return false;
|
||||
}
|
||||
if (!error.response) {
|
||||
return false;
|
||||
}
|
||||
return error.response.headers["x-ratelimit-remaining"] === "0";
|
||||
}
|
||||
|
||||
// pkg/dist-src/is-abuse-limit-error.js
|
||||
var REGEX_ABUSE_LIMIT_MESSAGE = /\babuse\b/i;
|
||||
function isAbuseLimitError(error) {
|
||||
if (error.status !== 403) {
|
||||
return false;
|
||||
}
|
||||
return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message);
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
async function hook(reason, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
return request(endpoint).catch((error) => {
|
||||
if (error.status === 404) {
|
||||
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (isRateLimitError(error)) {
|
||||
error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (isAbuseLimitError(error)) {
|
||||
error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (error.status === 401) {
|
||||
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (error.status >= 400 && error.status < 500) {
|
||||
error.message = error.message.replace(
|
||||
/\.?$/,
|
||||
`. May be caused by lack of authentication (${reason}).`
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) {
|
||||
if (!options || !options.reason) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth"
|
||||
);
|
||||
}
|
||||
return Object.assign(auth.bind(null, options.reason), {
|
||||
hook: hook.bind(null, options.reason)
|
||||
});
|
||||
};
|
||||
export {
|
||||
createUnauthenticatedAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-unauthenticated/dist-node/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/auth-unauthenticated/dist-node/index.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../dist-src/auth.js", "../dist-src/is-rate-limit-error.js", "../dist-src/is-abuse-limit-error.js", "../dist-src/hook.js", "../dist-src/index.js"],
|
||||
"sourcesContent": ["async function auth(reason) {\n return {\n type: \"unauthenticated\",\n reason\n };\n}\nexport {\n auth\n};\n", "function isRateLimitError(error) {\n if (error.status !== 403) {\n return false;\n }\n if (!error.response) {\n return false;\n }\n return error.response.headers[\"x-ratelimit-remaining\"] === \"0\";\n}\nexport {\n isRateLimitError\n};\n", "const REGEX_ABUSE_LIMIT_MESSAGE = /\\babuse\\b/i;\nfunction isAbuseLimitError(error) {\n if (error.status !== 403) {\n return false;\n }\n return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message);\n}\nexport {\n isAbuseLimitError\n};\n", "import { isRateLimitError } from \"./is-rate-limit-error.js\";\nimport { isAbuseLimitError } from \"./is-abuse-limit-error.js\";\nasync function hook(reason, request, route, parameters) {\n const endpoint = request.endpoint.merge(\n route,\n parameters\n );\n return request(endpoint).catch((error) => {\n if (error.status === 404) {\n error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;\n throw error;\n }\n if (isRateLimitError(error)) {\n error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;\n throw error;\n }\n if (isAbuseLimitError(error)) {\n error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;\n throw error;\n }\n if (error.status === 401) {\n error.message = `Unauthorized. \"${endpoint.method} ${endpoint.url}\" failed most likely due to lack of authentication. Reason: ${reason}`;\n throw error;\n }\n if (error.status >= 400 && error.status < 500) {\n error.message = error.message.replace(\n /\\.?$/,\n `. May be caused by lack of authentication (${reason}).`\n );\n }\n throw error;\n });\n}\nexport {\n hook\n};\n", "import { auth } from \"./auth.js\";\nimport { hook } from \"./hook.js\";\nconst createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) {\n if (!options || !options.reason) {\n throw new Error(\n \"[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth\"\n );\n }\n return Object.assign(auth.bind(null, options.reason), {\n hook: hook.bind(null, options.reason)\n });\n};\nexport {\n createUnauthenticatedAuth\n};\n"],
|
||||
"mappings": ";AAAA,eAAe,KAAK,QAAQ;AAC1B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;;;ACLA,SAAS,iBAAiB,OAAO;AAC/B,MAAI,MAAM,WAAW,KAAK;AACxB,WAAO;AAAA,EACT;AACA,MAAI,CAAC,MAAM,UAAU;AACnB,WAAO;AAAA,EACT;AACA,SAAO,MAAM,SAAS,QAAQ,uBAAuB,MAAM;AAC7D;;;ACRA,IAAM,4BAA4B;AAClC,SAAS,kBAAkB,OAAO;AAChC,MAAI,MAAM,WAAW,KAAK;AACxB,WAAO;AAAA,EACT;AACA,SAAO,0BAA0B,KAAK,MAAM,OAAO;AACrD;;;ACJA,eAAe,KAAK,QAAQ,SAAS,OAAO,YAAY;AACtD,QAAM,WAAW,QAAQ,SAAS;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AACA,SAAO,QAAQ,QAAQ,EAAE,MAAM,CAAC,UAAU;AACxC,QAAI,MAAM,WAAW,KAAK;AACxB,YAAM,UAAU,4DAA4D,MAAM;AAClF,YAAM;AAAA,IACR;AACA,QAAI,iBAAiB,KAAK,GAAG;AAC3B,YAAM,UAAU,qFAAqF,MAAM;AAC3G,YAAM;AAAA,IACR;AACA,QAAI,kBAAkB,KAAK,GAAG;AAC5B,YAAM,UAAU,6GAA6G,MAAM;AACnI,YAAM;AAAA,IACR;AACA,QAAI,MAAM,WAAW,KAAK;AACxB,YAAM,UAAU,kBAAkB,SAAS,MAAM,IAAI,SAAS,GAAG,+DAA+D,MAAM;AACtI,YAAM;AAAA,IACR;AACA,QAAI,MAAM,UAAU,OAAO,MAAM,SAAS,KAAK;AAC7C,YAAM,UAAU,MAAM,QAAQ;AAAA,QAC5B;AAAA,QACA,8CAA8C,MAAM;AAAA,MACtD;AAAA,IACF;AACA,UAAM;AAAA,EACR,CAAC;AACH;;;AC9BA,IAAM,4BAA4B,SAAS,2BAA2B,SAAS;AAC7E,MAAI,CAAC,WAAW,CAAC,QAAQ,QAAQ;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,OAAO,OAAO,KAAK,KAAK,MAAM,QAAQ,MAAM,GAAG;AAAA,IACpD,MAAM,KAAK,KAAK,MAAM,QAAQ,MAAM;AAAA,EACtC,CAAC;AACH;",
|
||||
"names": []
|
||||
}
|
||||
9
node_modules/@octokit/auth-unauthenticated/dist-src/auth.js
generated
vendored
Normal file
9
node_modules/@octokit/auth-unauthenticated/dist-src/auth.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
async function auth(reason) {
|
||||
return {
|
||||
type: "unauthenticated",
|
||||
reason
|
||||
};
|
||||
}
|
||||
export {
|
||||
auth
|
||||
};
|
||||
36
node_modules/@octokit/auth-unauthenticated/dist-src/hook.js
generated
vendored
Normal file
36
node_modules/@octokit/auth-unauthenticated/dist-src/hook.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { isRateLimitError } from "./is-rate-limit-error.js";
|
||||
import { isAbuseLimitError } from "./is-abuse-limit-error.js";
|
||||
async function hook(reason, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
return request(endpoint).catch((error) => {
|
||||
if (error.status === 404) {
|
||||
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (isRateLimitError(error)) {
|
||||
error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (isAbuseLimitError(error)) {
|
||||
error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (error.status === 401) {
|
||||
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (error.status >= 400 && error.status < 500) {
|
||||
error.message = error.message.replace(
|
||||
/\.?$/,
|
||||
`. May be caused by lack of authentication (${reason}).`
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
export {
|
||||
hook
|
||||
};
|
||||
15
node_modules/@octokit/auth-unauthenticated/dist-src/index.js
generated
vendored
Normal file
15
node_modules/@octokit/auth-unauthenticated/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { auth } from "./auth.js";
|
||||
import { hook } from "./hook.js";
|
||||
const createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) {
|
||||
if (!options || !options.reason) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth"
|
||||
);
|
||||
}
|
||||
return Object.assign(auth.bind(null, options.reason), {
|
||||
hook: hook.bind(null, options.reason)
|
||||
});
|
||||
};
|
||||
export {
|
||||
createUnauthenticatedAuth
|
||||
};
|
||||
10
node_modules/@octokit/auth-unauthenticated/dist-src/is-abuse-limit-error.js
generated
vendored
Normal file
10
node_modules/@octokit/auth-unauthenticated/dist-src/is-abuse-limit-error.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
const REGEX_ABUSE_LIMIT_MESSAGE = /\babuse\b/i;
|
||||
function isAbuseLimitError(error) {
|
||||
if (error.status !== 403) {
|
||||
return false;
|
||||
}
|
||||
return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message);
|
||||
}
|
||||
export {
|
||||
isAbuseLimitError
|
||||
};
|
||||
12
node_modules/@octokit/auth-unauthenticated/dist-src/is-rate-limit-error.js
generated
vendored
Normal file
12
node_modules/@octokit/auth-unauthenticated/dist-src/is-rate-limit-error.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
function isRateLimitError(error) {
|
||||
if (error.status !== 403) {
|
||||
return false;
|
||||
}
|
||||
if (!error.response) {
|
||||
return false;
|
||||
}
|
||||
return error.response.headers["x-ratelimit-remaining"] === "0";
|
||||
}
|
||||
export {
|
||||
isRateLimitError
|
||||
};
|
||||
2
node_modules/@octokit/auth-unauthenticated/dist-types/auth.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-unauthenticated/dist-types/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { Authentication } from "./types.js";
|
||||
export declare function auth(reason: string): Promise<Authentication>;
|
||||
2
node_modules/@octokit/auth-unauthenticated/dist-types/hook.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-unauthenticated/dist-types/hook.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { AnyResponse, EndpointOptions, RequestInterface, RequestParameters, Route } from "./types.js";
|
||||
export declare function hook(reason: string, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
||||
7
node_modules/@octokit/auth-unauthenticated/dist-types/index.d.ts
generated
vendored
Normal file
7
node_modules/@octokit/auth-unauthenticated/dist-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { StrategyInterface, Options, Authentication } from "./types.js";
|
||||
export type Types = {
|
||||
StrategyOptions: Options;
|
||||
AuthOptions: never;
|
||||
Authentication: Authentication;
|
||||
};
|
||||
export declare const createUnauthenticatedAuth: StrategyInterface;
|
||||
2
node_modules/@octokit/auth-unauthenticated/dist-types/is-abuse-limit-error.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-unauthenticated/dist-types/is-abuse-limit-error.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { RequestError } from "@octokit/request-error";
|
||||
export declare function isAbuseLimitError(error: RequestError): boolean;
|
||||
2
node_modules/@octokit/auth-unauthenticated/dist-types/is-rate-limit-error.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-unauthenticated/dist-types/is-rate-limit-error.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { RequestError } from "@octokit/request-error";
|
||||
export declare function isRateLimitError(error: RequestError): boolean;
|
||||
14
node_modules/@octokit/auth-unauthenticated/dist-types/types.d.ts
generated
vendored
Normal file
14
node_modules/@octokit/auth-unauthenticated/dist-types/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { OctokitResponse, StrategyInterface as OctokitStrategyInterface } from "@octokit/types";
|
||||
export type AnyResponse = OctokitResponse<any>;
|
||||
export type StrategyInterface = OctokitStrategyInterface<[
|
||||
Options
|
||||
], [
|
||||
], Authentication>;
|
||||
export type { EndpointDefaults, EndpointOptions, RequestParameters, RequestInterface, Route, } from "@octokit/types";
|
||||
export type Options = {
|
||||
reason: string;
|
||||
};
|
||||
export type Authentication = {
|
||||
type: "unauthenticated";
|
||||
reason: string;
|
||||
};
|
||||
75
node_modules/@octokit/auth-unauthenticated/dist-web/index.js
generated
vendored
Normal file
75
node_modules/@octokit/auth-unauthenticated/dist-web/index.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
// pkg/dist-src/auth.js
|
||||
async function auth(reason) {
|
||||
return {
|
||||
type: "unauthenticated",
|
||||
reason
|
||||
};
|
||||
}
|
||||
|
||||
// pkg/dist-src/is-rate-limit-error.js
|
||||
function isRateLimitError(error) {
|
||||
if (error.status !== 403) {
|
||||
return false;
|
||||
}
|
||||
if (!error.response) {
|
||||
return false;
|
||||
}
|
||||
return error.response.headers["x-ratelimit-remaining"] === "0";
|
||||
}
|
||||
|
||||
// pkg/dist-src/is-abuse-limit-error.js
|
||||
var REGEX_ABUSE_LIMIT_MESSAGE = /\babuse\b/i;
|
||||
function isAbuseLimitError(error) {
|
||||
if (error.status !== 403) {
|
||||
return false;
|
||||
}
|
||||
return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message);
|
||||
}
|
||||
|
||||
// pkg/dist-src/hook.js
|
||||
async function hook(reason, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(
|
||||
route,
|
||||
parameters
|
||||
);
|
||||
return request(endpoint).catch((error) => {
|
||||
if (error.status === 404) {
|
||||
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (isRateLimitError(error)) {
|
||||
error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (isAbuseLimitError(error)) {
|
||||
error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (error.status === 401) {
|
||||
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
|
||||
throw error;
|
||||
}
|
||||
if (error.status >= 400 && error.status < 500) {
|
||||
error.message = error.message.replace(
|
||||
/\.?$/,
|
||||
`. May be caused by lack of authentication (${reason}).`
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) {
|
||||
if (!options || !options.reason) {
|
||||
throw new Error(
|
||||
"[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth"
|
||||
);
|
||||
}
|
||||
return Object.assign(auth.bind(null, options.reason), {
|
||||
hook: hook.bind(null, options.reason)
|
||||
});
|
||||
};
|
||||
export {
|
||||
createUnauthenticatedAuth
|
||||
};
|
||||
7
node_modules/@octokit/auth-unauthenticated/dist-web/index.js.map
generated
vendored
Normal file
7
node_modules/@octokit/auth-unauthenticated/dist-web/index.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../dist-src/auth.js", "../dist-src/is-rate-limit-error.js", "../dist-src/is-abuse-limit-error.js", "../dist-src/hook.js", "../dist-src/index.js"],
|
||||
"sourcesContent": ["async function auth(reason) {\n return {\n type: \"unauthenticated\",\n reason\n };\n}\nexport {\n auth\n};\n", "function isRateLimitError(error) {\n if (error.status !== 403) {\n return false;\n }\n if (!error.response) {\n return false;\n }\n return error.response.headers[\"x-ratelimit-remaining\"] === \"0\";\n}\nexport {\n isRateLimitError\n};\n", "const REGEX_ABUSE_LIMIT_MESSAGE = /\\babuse\\b/i;\nfunction isAbuseLimitError(error) {\n if (error.status !== 403) {\n return false;\n }\n return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message);\n}\nexport {\n isAbuseLimitError\n};\n", "import { isRateLimitError } from \"./is-rate-limit-error.js\";\nimport { isAbuseLimitError } from \"./is-abuse-limit-error.js\";\nasync function hook(reason, request, route, parameters) {\n const endpoint = request.endpoint.merge(\n route,\n parameters\n );\n return request(endpoint).catch((error) => {\n if (error.status === 404) {\n error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;\n throw error;\n }\n if (isRateLimitError(error)) {\n error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;\n throw error;\n }\n if (isAbuseLimitError(error)) {\n error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;\n throw error;\n }\n if (error.status === 401) {\n error.message = `Unauthorized. \"${endpoint.method} ${endpoint.url}\" failed most likely due to lack of authentication. Reason: ${reason}`;\n throw error;\n }\n if (error.status >= 400 && error.status < 500) {\n error.message = error.message.replace(\n /\\.?$/,\n `. May be caused by lack of authentication (${reason}).`\n );\n }\n throw error;\n });\n}\nexport {\n hook\n};\n", "import { auth } from \"./auth.js\";\nimport { hook } from \"./hook.js\";\nconst createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) {\n if (!options || !options.reason) {\n throw new Error(\n \"[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth\"\n );\n }\n return Object.assign(auth.bind(null, options.reason), {\n hook: hook.bind(null, options.reason)\n });\n};\nexport {\n createUnauthenticatedAuth\n};\n"],
|
||||
"mappings": ";AAAA,eAAe,KAAK,QAAQ;AAC1B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;;;ACLA,SAAS,iBAAiB,OAAO;AAC/B,MAAI,MAAM,WAAW,KAAK;AACxB,WAAO;AAAA,EACT;AACA,MAAI,CAAC,MAAM,UAAU;AACnB,WAAO;AAAA,EACT;AACA,SAAO,MAAM,SAAS,QAAQ,uBAAuB,MAAM;AAC7D;;;ACRA,IAAM,4BAA4B;AAClC,SAAS,kBAAkB,OAAO;AAChC,MAAI,MAAM,WAAW,KAAK;AACxB,WAAO;AAAA,EACT;AACA,SAAO,0BAA0B,KAAK,MAAM,OAAO;AACrD;;;ACJA,eAAe,KAAK,QAAQ,SAAS,OAAO,YAAY;AACtD,QAAM,WAAW,QAAQ,SAAS;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AACA,SAAO,QAAQ,QAAQ,EAAE,MAAM,CAAC,UAAU;AACxC,QAAI,MAAM,WAAW,KAAK;AACxB,YAAM,UAAU,4DAA4D,MAAM;AAClF,YAAM;AAAA,IACR;AACA,QAAI,iBAAiB,KAAK,GAAG;AAC3B,YAAM,UAAU,qFAAqF,MAAM;AAC3G,YAAM;AAAA,IACR;AACA,QAAI,kBAAkB,KAAK,GAAG;AAC5B,YAAM,UAAU,6GAA6G,MAAM;AACnI,YAAM;AAAA,IACR;AACA,QAAI,MAAM,WAAW,KAAK;AACxB,YAAM,UAAU,kBAAkB,SAAS,MAAM,IAAI,SAAS,GAAG,+DAA+D,MAAM;AACtI,YAAM;AAAA,IACR;AACA,QAAI,MAAM,UAAU,OAAO,MAAM,SAAS,KAAK;AAC7C,YAAM,UAAU,MAAM,QAAQ;AAAA,QAC5B;AAAA,QACA,8CAA8C,MAAM;AAAA,MACtD;AAAA,IACF;AACA,UAAM;AAAA,EACR,CAAC;AACH;;;AC9BA,IAAM,4BAA4B,SAAS,2BAA2B,SAAS;AAC7E,MAAI,CAAC,WAAW,CAAC,QAAQ,QAAQ;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,OAAO,OAAO,KAAK,KAAK,MAAM,QAAQ,MAAM,GAAG;AAAA,IACpD,MAAM,KAAK,KAAK,MAAM,QAAQ,MAAM;AAAA,EACtC,CAAC;AACH;",
|
||||
"names": []
|
||||
}
|
||||
60
node_modules/@octokit/auth-unauthenticated/package.json
generated
vendored
Normal file
60
node_modules/@octokit/auth-unauthenticated/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "@octokit/auth-unauthenticated",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"type": "module",
|
||||
"version": "7.0.3",
|
||||
"description": "GitHub API token authentication for browsers and Node.js",
|
||||
"repository": "github:octokit/auth-unauthenticated.js",
|
||||
"keywords": [
|
||||
"github",
|
||||
"octokit",
|
||||
"authentication",
|
||||
"api"
|
||||
],
|
||||
"author": "Gregor Martynus (https://github.com/gr2m)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/request-error": "^7.0.2",
|
||||
"@octokit/types": "^16.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/core": "^7.0.6",
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/tsconfig": "^4.0.0",
|
||||
"@types/node": "^24.0.0",
|
||||
"@vitest/coverage-v8": "^3.0.0",
|
||||
"esbuild": "^0.25.0",
|
||||
"fetch-mock": "^12.0.0",
|
||||
"prettier": "3.6.2",
|
||||
"tinyglobby": "^0.2.13",
|
||||
"typescript": "^5.0.0",
|
||||
"vitest": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/**",
|
||||
"bin/**"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"node": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-node/index.js"
|
||||
},
|
||||
"browser": {
|
||||
"types": "./dist-types/web.d.ts",
|
||||
"import": "./dist-web/index.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist-types/index.d.ts",
|
||||
"import": "./dist-node/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
Reference in New Issue
Block a user