Spaces:
Paused
Paused
Upload folder using huggingface_hub (part 12)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/hook.d.ts +6 -0
- node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/index.d.ts +8 -0
- node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/requires-basic-auth.d.ts +1 -0
- node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/types.d.ts +114 -0
- node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/version.d.ts +1 -0
- node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/package.json +56 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/LICENSE +21 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/README.md +284 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-bundle/index.js +55 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-bundle/index.js.map +7 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/auth.js +15 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/hook.js +12 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/index.js +19 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/is-jwt.js +7 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/with-authorization-prefix.js +9 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/auth.d.ts +2 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/hook.d.ts +2 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/index.d.ts +7 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/is-jwt.d.ts +1 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/types.d.ts +33 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/with-authorization-prefix.d.ts +6 -0
- node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/package.json +50 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/LICENSE +21 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/README.md +148 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-node/index.js +75 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-node/index.js.map +7 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/auth.js +9 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/hook.js +36 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/index.js +15 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/is-abuse-limit-error.js +10 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/is-rate-limit-error.js +12 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/auth.d.ts +2 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/hook.d.ts +2 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/index.d.ts +7 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/is-abuse-limit-error.d.ts +2 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/is-rate-limit-error.d.ts +2 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/types.d.ts +14 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-web/index.js +75 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-web/index.js.map +7 -0
- node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/package.json +60 -0
- node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/LICENSE +21 -0
- node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/README.md +457 -0
- node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-src/index.js +141 -0
- node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-src/version.js +4 -0
- node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-types/index.d.ts +31 -0
- node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-types/types.d.ts +49 -0
- node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-types/version.d.ts +1 -0
- node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/package.json +67 -0
- node_modules/.pnpm/@octokit+endpoint@11.0.2/node_modules/@octokit/endpoint/LICENSE +21 -0
- node_modules/.pnpm/@octokit+endpoint@11.0.2/node_modules/@octokit/endpoint/README.md +412 -0
node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/hook.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { EndpointOptions, OctokitResponse, RequestInterface, RequestParameters, Route } from "@octokit/types";
|
| 2 |
+
import type { OAuthAppState, GitHubAppState } from "./types.js";
|
| 3 |
+
type AnyResponse = OctokitResponse<any>;
|
| 4 |
+
export declare function hook(state: OAuthAppState, request: RequestInterface, route: Route | EndpointOptions, parameters: RequestParameters): Promise<AnyResponse>;
|
| 5 |
+
export declare function hook(state: GitHubAppState, request: RequestInterface, route: Route | EndpointOptions, parameters: RequestParameters): Promise<AnyResponse>;
|
| 6 |
+
export {};
|
node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthInterface, GitHubAppAuthInterface } from "./types.js";
|
| 2 |
+
export type { OAuthAppStrategyOptionsWebFlow, GitHubAppStrategyOptionsWebFlow, OAuthAppStrategyOptionsDeviceFlow, GitHubAppStrategyOptionsDeviceFlow, OAuthAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsExistingAuthenticationWithExpiration, OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, } from "./types.js";
|
| 3 |
+
export { requiresBasicAuth } from "./requires-basic-auth.js";
|
| 4 |
+
export declare function createOAuthUserAuth(options: OAuthAppStrategyOptions): OAuthAppAuthInterface;
|
| 5 |
+
export declare function createOAuthUserAuth(options: GitHubAppStrategyOptions): GitHubAppAuthInterface;
|
| 6 |
+
export declare namespace createOAuthUserAuth {
|
| 7 |
+
var VERSION: string;
|
| 8 |
+
}
|
node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/requires-basic-auth.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export declare function requiresBasicAuth(url: string | undefined): boolean | "" | undefined;
|
node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/types.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as OctokitTypes from "@octokit/types";
|
| 2 |
+
import type * as DeviceTypes from "@octokit/auth-oauth-device";
|
| 3 |
+
import type * as OAuthMethodsTypes from "@octokit/oauth-methods";
|
| 4 |
+
export type ClientType = "oauth-app" | "github-app";
|
| 5 |
+
export type WebFlowOptions = {
|
| 6 |
+
code: string;
|
| 7 |
+
state?: string;
|
| 8 |
+
redirectUrl?: string;
|
| 9 |
+
};
|
| 10 |
+
type CommonAppStrategyOptions = {
|
| 11 |
+
clientType?: ClientType;
|
| 12 |
+
clientId: string;
|
| 13 |
+
clientSecret: string;
|
| 14 |
+
request?: OctokitTypes.RequestInterface;
|
| 15 |
+
onTokenCreated?: OnTokenCreatedCallback;
|
| 16 |
+
};
|
| 17 |
+
type CommonOAuthAppStrategyOptions = {
|
| 18 |
+
clientType?: "oauth-app";
|
| 19 |
+
} & CommonAppStrategyOptions;
|
| 20 |
+
type CommonGitHubAppStrategyOptions = {
|
| 21 |
+
clientType?: "github-app";
|
| 22 |
+
} & CommonAppStrategyOptions;
|
| 23 |
+
type OAuthAppDeviceFlowOptions = {
|
| 24 |
+
onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"];
|
| 25 |
+
scopes?: string[];
|
| 26 |
+
};
|
| 27 |
+
type GitHubDeviceFlowOptions = {
|
| 28 |
+
onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"];
|
| 29 |
+
};
|
| 30 |
+
type ExistingOAuthAppAuthenticationOptions = {
|
| 31 |
+
clientType: "oauth-app";
|
| 32 |
+
token: string;
|
| 33 |
+
scopes: string[];
|
| 34 |
+
};
|
| 35 |
+
type ExistingGitHubAppAuthenticationOptions = {
|
| 36 |
+
token: string;
|
| 37 |
+
};
|
| 38 |
+
type ExistingGitHubAppAuthenticationWithExpirationOptions = {
|
| 39 |
+
token: string;
|
| 40 |
+
refreshToken: string;
|
| 41 |
+
expiresAt: string;
|
| 42 |
+
refreshTokenExpiresAt: string;
|
| 43 |
+
};
|
| 44 |
+
export type OAuthAppStrategyOptionsWebFlow = CommonOAuthAppStrategyOptions & WebFlowOptions;
|
| 45 |
+
export type GitHubAppStrategyOptionsWebFlow = CommonGitHubAppStrategyOptions & WebFlowOptions;
|
| 46 |
+
export type OAuthAppStrategyOptionsDeviceFlow = CommonOAuthAppStrategyOptions & OAuthAppDeviceFlowOptions;
|
| 47 |
+
export type GitHubAppStrategyOptionsDeviceFlow = CommonGitHubAppStrategyOptions & GitHubDeviceFlowOptions;
|
| 48 |
+
export type OAuthAppStrategyOptionsExistingAuthentication = CommonOAuthAppStrategyOptions & ExistingOAuthAppAuthenticationOptions;
|
| 49 |
+
export type GitHubAppStrategyOptionsExistingAuthentication = CommonGitHubAppStrategyOptions & ExistingGitHubAppAuthenticationOptions;
|
| 50 |
+
export type GitHubAppStrategyOptionsExistingAuthenticationWithExpiration = CommonGitHubAppStrategyOptions & ExistingGitHubAppAuthenticationWithExpirationOptions;
|
| 51 |
+
export type OAuthAppStrategyOptions = OAuthAppStrategyOptionsWebFlow | OAuthAppStrategyOptionsDeviceFlow | OAuthAppStrategyOptionsExistingAuthentication;
|
| 52 |
+
export type GitHubAppStrategyOptions = GitHubAppStrategyOptionsWebFlow | GitHubAppStrategyOptionsDeviceFlow | GitHubAppStrategyOptionsExistingAuthentication | GitHubAppStrategyOptionsExistingAuthenticationWithExpiration;
|
| 53 |
+
export type OAuthAppAuthentication = {
|
| 54 |
+
tokenType: "oauth";
|
| 55 |
+
type: "token";
|
| 56 |
+
} & OAuthMethodsTypes.OAuthAppAuthentication;
|
| 57 |
+
export type GitHubAppAuthentication = {
|
| 58 |
+
tokenType: "oauth";
|
| 59 |
+
type: "token";
|
| 60 |
+
} & OAuthMethodsTypes.GitHubAppAuthentication;
|
| 61 |
+
export type GitHubAppAuthenticationWithExpiration = {
|
| 62 |
+
tokenType: "oauth";
|
| 63 |
+
type: "token";
|
| 64 |
+
} & OAuthMethodsTypes.GitHubAppAuthenticationWithExpiration;
|
| 65 |
+
export interface OAuthAppAuthInterface {
|
| 66 |
+
(options?: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
| 67 |
+
hook(request: OctokitTypes.RequestInterface, route: OctokitTypes.Route | OctokitTypes.EndpointOptions, parameters?: OctokitTypes.RequestParameters): Promise<OctokitTypes.OctokitResponse<any>>;
|
| 68 |
+
}
|
| 69 |
+
export interface GitHubAppAuthInterface {
|
| 70 |
+
(options?: GitHubAppAuthOptions): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;
|
| 71 |
+
hook(request: OctokitTypes.RequestInterface, route: OctokitTypes.Route | OctokitTypes.EndpointOptions, parameters?: OctokitTypes.RequestParameters): Promise<OctokitTypes.OctokitResponse<any>>;
|
| 72 |
+
}
|
| 73 |
+
type OnTokenCreatedCallback = (authentication: OAuthAppAuthentication | GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration | undefined, options: OAuthAppAuthOptions | GitHubAppAuthOptions) => void | Promise<void>;
|
| 74 |
+
export type OAuthAppState = {
|
| 75 |
+
clientId: string;
|
| 76 |
+
clientSecret: string;
|
| 77 |
+
clientType: "oauth-app";
|
| 78 |
+
request: OctokitTypes.RequestInterface;
|
| 79 |
+
onTokenCreated?: CommonAppStrategyOptions["onTokenCreated"];
|
| 80 |
+
strategyOptions: WebFlowOptions | OAuthAppDeviceFlowOptions | ExistingOAuthAppAuthenticationOptions;
|
| 81 |
+
authentication?: OAuthAppAuthentication & {
|
| 82 |
+
invalid?: true;
|
| 83 |
+
};
|
| 84 |
+
};
|
| 85 |
+
type GitHubAppStateAuthentication = GitHubAppAuthentication & {
|
| 86 |
+
invalid?: true;
|
| 87 |
+
};
|
| 88 |
+
type GitHubAppStateAuthenticationWIthExpiration = GitHubAppAuthenticationWithExpiration & {
|
| 89 |
+
invalid?: true;
|
| 90 |
+
};
|
| 91 |
+
export type GitHubAppState = {
|
| 92 |
+
clientId: string;
|
| 93 |
+
clientSecret: string;
|
| 94 |
+
clientType: "github-app";
|
| 95 |
+
request: OctokitTypes.RequestInterface;
|
| 96 |
+
onTokenCreated?: CommonAppStrategyOptions["onTokenCreated"];
|
| 97 |
+
strategyOptions: WebFlowOptions | GitHubDeviceFlowOptions | ExistingGitHubAppAuthenticationOptions | ExistingGitHubAppAuthenticationWithExpirationOptions;
|
| 98 |
+
authentication?: GitHubAppStateAuthentication | GitHubAppStateAuthenticationWIthExpiration;
|
| 99 |
+
};
|
| 100 |
+
export type State = OAuthAppState | GitHubAppState;
|
| 101 |
+
export type WebFlowState = {
|
| 102 |
+
clientId: string;
|
| 103 |
+
clientSecret: string;
|
| 104 |
+
clientType: ClientType;
|
| 105 |
+
request: OctokitTypes.RequestInterface;
|
| 106 |
+
strategyOptions: WebFlowOptions;
|
| 107 |
+
};
|
| 108 |
+
export type OAuthAppAuthOptions = {
|
| 109 |
+
type?: "get" | "check" | "reset" | "delete" | "deleteAuthorization";
|
| 110 |
+
};
|
| 111 |
+
export type GitHubAppAuthOptions = {
|
| 112 |
+
type?: "get" | "check" | "reset" | "refresh" | "delete" | "deleteAuthorization";
|
| 113 |
+
};
|
| 114 |
+
export {};
|
node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/dist-types/version.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export declare const VERSION = "6.0.2";
|
node_modules/.pnpm/@octokit+auth-oauth-user@6.0.2/node_modules/@octokit/auth-oauth-user/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@octokit/auth-oauth-user",
|
| 3 |
+
"publishConfig": {
|
| 4 |
+
"access": "public",
|
| 5 |
+
"provenance": true
|
| 6 |
+
},
|
| 7 |
+
"type": "module",
|
| 8 |
+
"version": "6.0.2",
|
| 9 |
+
"description": "Octokit authentication strategy for OAuth clients",
|
| 10 |
+
"repository": "https://github.com/octokit/auth-oauth-user.js",
|
| 11 |
+
"keywords": [
|
| 12 |
+
"github",
|
| 13 |
+
"api",
|
| 14 |
+
"sdk",
|
| 15 |
+
"toolkit"
|
| 16 |
+
],
|
| 17 |
+
"author": "Gregor Martynus (https://dev.to/gr2m)",
|
| 18 |
+
"license": "MIT",
|
| 19 |
+
"dependencies": {
|
| 20 |
+
"@octokit/auth-oauth-device": "^8.0.3",
|
| 21 |
+
"@octokit/oauth-methods": "^6.0.2",
|
| 22 |
+
"@octokit/request": "^10.0.6",
|
| 23 |
+
"@octokit/types": "^16.0.0",
|
| 24 |
+
"universal-user-agent": "^7.0.0"
|
| 25 |
+
},
|
| 26 |
+
"devDependencies": {
|
| 27 |
+
"@octokit/core": "^7.0.6",
|
| 28 |
+
"@octokit/tsconfig": "^4.0.0",
|
| 29 |
+
"@types/node": "^24.0.0",
|
| 30 |
+
"@vitest/coverage-v8": "^3.0.0",
|
| 31 |
+
"esbuild": "^0.25.0",
|
| 32 |
+
"fetch-mock": "^11.0.0",
|
| 33 |
+
"glob": "^11.0.0",
|
| 34 |
+
"mockdate": "^3.0.4",
|
| 35 |
+
"prettier": "3.6.2",
|
| 36 |
+
"semantic-release-plugin-update-version-in-files": "^2.0.0",
|
| 37 |
+
"typescript": "^5.0.0",
|
| 38 |
+
"vitest": "^3.0.0"
|
| 39 |
+
},
|
| 40 |
+
"engines": {
|
| 41 |
+
"node": ">= 20"
|
| 42 |
+
},
|
| 43 |
+
"files": [
|
| 44 |
+
"dist-*/**",
|
| 45 |
+
"bin/**"
|
| 46 |
+
],
|
| 47 |
+
"types": "./dist-types/index.d.ts",
|
| 48 |
+
"exports": {
|
| 49 |
+
".": {
|
| 50 |
+
"types": "./dist-types/index.d.ts",
|
| 51 |
+
"import": "./dist-bundle/index.js",
|
| 52 |
+
"default": "./dist-bundle/index.js"
|
| 53 |
+
}
|
| 54 |
+
},
|
| 55 |
+
"sideEffects": false
|
| 56 |
+
}
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2019 Octokit contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in
|
| 13 |
+
all copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 21 |
+
THE SOFTWARE.
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/README.md
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# auth-token.js
|
| 2 |
+
|
| 3 |
+
> GitHub API token authentication for browsers and Node.js
|
| 4 |
+
|
| 5 |
+
[](https://www.npmjs.com/package/@octokit/auth-token)
|
| 6 |
+
[](https://github.com/octokit/auth-token.js/actions?query=workflow%3ATest)
|
| 7 |
+
|
| 8 |
+
`@octokit/auth-token` is the simplest of [GitHub’s authentication strategies](https://github.com/octokit/auth.js).
|
| 9 |
+
|
| 10 |
+
It is useful if you want to support multiple authentication strategies, as it’s API is compatible with its sibling packages for [basic](https://github.com/octokit/auth-basic.js), [GitHub App](https://github.com/octokit/auth-app.js) and [OAuth app](https://github.com/octokit/auth.js) authentication.
|
| 11 |
+
|
| 12 |
+
<!-- toc -->
|
| 13 |
+
|
| 14 |
+
- [Usage](#usage)
|
| 15 |
+
- [`createTokenAuth(token) options`](#createtokenauthtoken-options)
|
| 16 |
+
- [`auth()`](#auth)
|
| 17 |
+
- [Authentication object](#authentication-object)
|
| 18 |
+
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
|
| 19 |
+
- [Find more information](#find-more-information)
|
| 20 |
+
- [Find out what scopes are enabled for oauth tokens](#find-out-what-scopes-are-enabled-for-oauth-tokens)
|
| 21 |
+
- [Find out if token is a personal access token or if it belongs to an OAuth app](#find-out-if-token-is-a-personal-access-token-or-if-it-belongs-to-an-oauth-app)
|
| 22 |
+
- [Find out what permissions are enabled for a repository](#find-out-what-permissions-are-enabled-for-a-repository)
|
| 23 |
+
- [Use token for git operations](#use-token-for-git-operations)
|
| 24 |
+
- [License](#license)
|
| 25 |
+
|
| 26 |
+
<!-- tocstop -->
|
| 27 |
+
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
<table>
|
| 31 |
+
<tbody valign=top align=left>
|
| 32 |
+
<tr><th>
|
| 33 |
+
Browsers
|
| 34 |
+
</th><td width=100%>
|
| 35 |
+
|
| 36 |
+
Load `@octokit/auth-token` directly from [esm.sh](https://esm.sh)
|
| 37 |
+
|
| 38 |
+
```html
|
| 39 |
+
<script type="module">
|
| 40 |
+
import { createTokenAuth } from "https://esm.sh/@octokit/auth-token";
|
| 41 |
+
</script>
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
</td></tr>
|
| 45 |
+
<tr><th>
|
| 46 |
+
Node
|
| 47 |
+
</th><td>
|
| 48 |
+
|
| 49 |
+
Install with <code>npm install @octokit/auth-token</code>
|
| 50 |
+
|
| 51 |
+
```js
|
| 52 |
+
import { createTokenAuth } from "@octokit/auth-token";
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
</td></tr>
|
| 56 |
+
</tbody>
|
| 57 |
+
</table>
|
| 58 |
+
|
| 59 |
+
```js
|
| 60 |
+
const auth = createTokenAuth("ghp_PersonalAccessToken01245678900000000");
|
| 61 |
+
const authentication = await auth();
|
| 62 |
+
// {
|
| 63 |
+
// type: 'token',
|
| 64 |
+
// token: 'ghp_PersonalAccessToken01245678900000000',
|
| 65 |
+
// tokenType: 'oauth'
|
| 66 |
+
// }
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
## `createTokenAuth(token) options`
|
| 70 |
+
|
| 71 |
+
The `createTokenAuth` method accepts a single argument of type string, which is the token. The passed token can be one of the following:
|
| 72 |
+
|
| 73 |
+
- [Personal access token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
|
| 74 |
+
- [OAuth access token](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)
|
| 75 |
+
- [GITHUB_TOKEN provided to GitHub Actions](https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables)
|
| 76 |
+
- Installation access token ([server-to-server](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation))
|
| 77 |
+
- User authentication for installation ([user-to-server](https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps))
|
| 78 |
+
|
| 79 |
+
Examples
|
| 80 |
+
|
| 81 |
+
```js
|
| 82 |
+
// Personal access token or OAuth access token
|
| 83 |
+
createTokenAuth("ghp_PersonalAccessToken01245678900000000");
|
| 84 |
+
// {
|
| 85 |
+
// type: 'token',
|
| 86 |
+
// token: 'ghp_PersonalAccessToken01245678900000000',
|
| 87 |
+
// tokenType: 'oauth'
|
| 88 |
+
// }
|
| 89 |
+
|
| 90 |
+
// Installation access token or GitHub Action token
|
| 91 |
+
createTokenAuth("ghs_InstallallationOrActionToken00000000");
|
| 92 |
+
// {
|
| 93 |
+
// type: 'token',
|
| 94 |
+
// token: 'ghs_InstallallationOrActionToken00000000',
|
| 95 |
+
// tokenType: 'installation'
|
| 96 |
+
// }
|
| 97 |
+
|
| 98 |
+
// Installation access token or GitHub Action token
|
| 99 |
+
createTokenAuth("ghu_InstallationUserToServer000000000000");
|
| 100 |
+
// {
|
| 101 |
+
// type: 'token',
|
| 102 |
+
// token: 'ghu_InstallationUserToServer000000000000',
|
| 103 |
+
// tokenType: 'user-to-server'
|
| 104 |
+
// }
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
## `auth()`
|
| 108 |
+
|
| 109 |
+
The `auth()` method has no options. It returns a promise which resolves with the the authentication object.
|
| 110 |
+
|
| 111 |
+
## Authentication object
|
| 112 |
+
|
| 113 |
+
<table width="100%">
|
| 114 |
+
<thead align=left>
|
| 115 |
+
<tr>
|
| 116 |
+
<th width=150>
|
| 117 |
+
name
|
| 118 |
+
</th>
|
| 119 |
+
<th width=70>
|
| 120 |
+
type
|
| 121 |
+
</th>
|
| 122 |
+
<th>
|
| 123 |
+
description
|
| 124 |
+
</th>
|
| 125 |
+
</tr>
|
| 126 |
+
</thead>
|
| 127 |
+
<tbody align=left valign=top>
|
| 128 |
+
<tr>
|
| 129 |
+
<th>
|
| 130 |
+
<code>type</code>
|
| 131 |
+
</th>
|
| 132 |
+
<th>
|
| 133 |
+
<code>string</code>
|
| 134 |
+
</th>
|
| 135 |
+
<td>
|
| 136 |
+
<code>"token"</code>
|
| 137 |
+
</td>
|
| 138 |
+
</tr>
|
| 139 |
+
<tr>
|
| 140 |
+
<th>
|
| 141 |
+
<code>token</code>
|
| 142 |
+
</th>
|
| 143 |
+
<th>
|
| 144 |
+
<code>string</code>
|
| 145 |
+
</th>
|
| 146 |
+
<td>
|
| 147 |
+
The provided token.
|
| 148 |
+
</td>
|
| 149 |
+
</tr>
|
| 150 |
+
<tr>
|
| 151 |
+
<th>
|
| 152 |
+
<code>tokenType</code>
|
| 153 |
+
</th>
|
| 154 |
+
<th>
|
| 155 |
+
<code>string</code>
|
| 156 |
+
</th>
|
| 157 |
+
<td>
|
| 158 |
+
Can be either <code>"oauth"</code> for personal access tokens and OAuth tokens, <code>"installation"</code> for installation access tokens (includes <code>GITHUB_TOKEN</code> provided to GitHub Actions), <code>"app"</code> for a GitHub App JSON Web Token, or <code>"user-to-server"</code> for a user authentication token through an app installation.
|
| 159 |
+
</td>
|
| 160 |
+
</tr>
|
| 161 |
+
</tbody>
|
| 162 |
+
</table>
|
| 163 |
+
|
| 164 |
+
## `auth.hook(request, route, options)` or `auth.hook(request, options)`
|
| 165 |
+
|
| 166 |
+
`auth.hook()` hooks directly into the request life cycle. It authenticates the request using the provided token.
|
| 167 |
+
|
| 168 |
+
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).
|
| 169 |
+
|
| 170 |
+
`auth.hook()` can be called directly to send an authenticated request
|
| 171 |
+
|
| 172 |
+
```js
|
| 173 |
+
const { data: authorizations } = await auth.hook(
|
| 174 |
+
request,
|
| 175 |
+
"GET /authorizations",
|
| 176 |
+
);
|
| 177 |
+
```
|
| 178 |
+
|
| 179 |
+
Or it can be passed as option to [`request()`](https://github.com/octokit/request.js#request).
|
| 180 |
+
|
| 181 |
+
```js
|
| 182 |
+
const requestWithAuth = request.defaults({
|
| 183 |
+
request: {
|
| 184 |
+
hook: auth.hook,
|
| 185 |
+
},
|
| 186 |
+
});
|
| 187 |
+
|
| 188 |
+
const { data: authorizations } = await requestWithAuth("GET /authorizations");
|
| 189 |
+
```
|
| 190 |
+
|
| 191 |
+
## Find more information
|
| 192 |
+
|
| 193 |
+
`auth()` does not send any requests, it only transforms the provided token string into an authentication object.
|
| 194 |
+
|
| 195 |
+
Here is a list of things you can do to retrieve further information
|
| 196 |
+
|
| 197 |
+
### Find out what scopes are enabled for oauth tokens
|
| 198 |
+
|
| 199 |
+
Note that this does not work for installations. There is no way to retrieve permissions based on an installation access tokens.
|
| 200 |
+
|
| 201 |
+
```js
|
| 202 |
+
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
| 203 |
+
|
| 204 |
+
const auth = createTokenAuth(TOKEN);
|
| 205 |
+
const authentication = await auth();
|
| 206 |
+
|
| 207 |
+
const response = await request("HEAD /");
|
| 208 |
+
const scopes = response.headers["x-oauth-scopes"].split(/,\s+/);
|
| 209 |
+
|
| 210 |
+
if (scopes.length) {
|
| 211 |
+
console.log(
|
| 212 |
+
`"${TOKEN}" has ${scopes.length} scopes enabled: ${scopes.join(", ")}`,
|
| 213 |
+
);
|
| 214 |
+
} else {
|
| 215 |
+
console.log(`"${TOKEN}" has no scopes enabled`);
|
| 216 |
+
}
|
| 217 |
+
```
|
| 218 |
+
|
| 219 |
+
### Find out if token is a personal access token or if it belongs to an OAuth app
|
| 220 |
+
|
| 221 |
+
```js
|
| 222 |
+
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
| 223 |
+
|
| 224 |
+
const auth = createTokenAuth(TOKEN);
|
| 225 |
+
const authentication = await auth();
|
| 226 |
+
|
| 227 |
+
const response = await request("HEAD /");
|
| 228 |
+
const clientId = response.headers["x-oauth-client-id"];
|
| 229 |
+
|
| 230 |
+
if (clientId) {
|
| 231 |
+
console.log(
|
| 232 |
+
`"${token}" is an OAuth token, its app’s client_id is ${clientId}.`,
|
| 233 |
+
);
|
| 234 |
+
} else {
|
| 235 |
+
console.log(`"${token}" is a personal access token`);
|
| 236 |
+
}
|
| 237 |
+
```
|
| 238 |
+
|
| 239 |
+
### Find out what permissions are enabled for a repository
|
| 240 |
+
|
| 241 |
+
Note that the `permissions` key is not set when authenticated using an installation access token.
|
| 242 |
+
|
| 243 |
+
```js
|
| 244 |
+
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
| 245 |
+
|
| 246 |
+
const auth = createTokenAuth(TOKEN);
|
| 247 |
+
const authentication = await auth();
|
| 248 |
+
|
| 249 |
+
const response = await request("GET /repos/{owner}/{repo}", {
|
| 250 |
+
owner: "octocat",
|
| 251 |
+
repo: "hello-world",
|
| 252 |
+
});
|
| 253 |
+
|
| 254 |
+
console.log(response.data.permissions);
|
| 255 |
+
// {
|
| 256 |
+
// admin: true,
|
| 257 |
+
// push: true,
|
| 258 |
+
// pull: true
|
| 259 |
+
// }
|
| 260 |
+
```
|
| 261 |
+
|
| 262 |
+
### Use token for git operations
|
| 263 |
+
|
| 264 |
+
Both OAuth and installation access tokens can be used for git operations. However, when using with an installation, [the token must be prefixed with `x-access-token`](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation).
|
| 265 |
+
|
| 266 |
+
This example is using the [`execa`](https://github.com/sindresorhus/execa) package to run a `git push` command.
|
| 267 |
+
|
| 268 |
+
```js
|
| 269 |
+
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
| 270 |
+
|
| 271 |
+
const auth = createTokenAuth(TOKEN);
|
| 272 |
+
const { token, tokenType } = await auth();
|
| 273 |
+
const tokenWithPrefix =
|
| 274 |
+
tokenType === "installation" ? `x-access-token:${token}` : token;
|
| 275 |
+
|
| 276 |
+
const repositoryUrl = `https://${tokenWithPrefix}@github.com/octocat/hello-world.git`;
|
| 277 |
+
|
| 278 |
+
const { stdout } = await execa("git", ["push", repositoryUrl]);
|
| 279 |
+
console.log(stdout);
|
| 280 |
+
```
|
| 281 |
+
|
| 282 |
+
## License
|
| 283 |
+
|
| 284 |
+
[MIT](LICENSE)
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-bundle/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// pkg/dist-src/is-jwt.js
|
| 2 |
+
var b64url = "(?:[a-zA-Z0-9_-]+)";
|
| 3 |
+
var sep = "\\.";
|
| 4 |
+
var jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);
|
| 5 |
+
var isJWT = jwtRE.test.bind(jwtRE);
|
| 6 |
+
|
| 7 |
+
// pkg/dist-src/auth.js
|
| 8 |
+
async function auth(token) {
|
| 9 |
+
const isApp = isJWT(token);
|
| 10 |
+
const isInstallation = token.startsWith("v1.") || token.startsWith("ghs_");
|
| 11 |
+
const isUserToServer = token.startsWith("ghu_");
|
| 12 |
+
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
| 13 |
+
return {
|
| 14 |
+
type: "token",
|
| 15 |
+
token,
|
| 16 |
+
tokenType
|
| 17 |
+
};
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
// pkg/dist-src/with-authorization-prefix.js
|
| 21 |
+
function withAuthorizationPrefix(token) {
|
| 22 |
+
if (token.split(/\./).length === 3) {
|
| 23 |
+
return `bearer ${token}`;
|
| 24 |
+
}
|
| 25 |
+
return `token ${token}`;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
// pkg/dist-src/hook.js
|
| 29 |
+
async function hook(token, request, route, parameters) {
|
| 30 |
+
const endpoint = request.endpoint.merge(
|
| 31 |
+
route,
|
| 32 |
+
parameters
|
| 33 |
+
);
|
| 34 |
+
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
| 35 |
+
return request(endpoint);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
// pkg/dist-src/index.js
|
| 39 |
+
var createTokenAuth = function createTokenAuth2(token) {
|
| 40 |
+
if (!token) {
|
| 41 |
+
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
| 42 |
+
}
|
| 43 |
+
if (typeof token !== "string") {
|
| 44 |
+
throw new Error(
|
| 45 |
+
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
| 46 |
+
);
|
| 47 |
+
}
|
| 48 |
+
token = token.replace(/^(token|bearer) +/i, "");
|
| 49 |
+
return Object.assign(auth.bind(null, token), {
|
| 50 |
+
hook: hook.bind(null, token)
|
| 51 |
+
});
|
| 52 |
+
};
|
| 53 |
+
export {
|
| 54 |
+
createTokenAuth
|
| 55 |
+
};
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-bundle/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": 3,
|
| 3 |
+
"sources": ["../dist-src/is-jwt.js", "../dist-src/auth.js", "../dist-src/with-authorization-prefix.js", "../dist-src/hook.js", "../dist-src/index.js"],
|
| 4 |
+
"sourcesContent": ["const b64url = \"(?:[a-zA-Z0-9_-]+)\";\nconst sep = \"\\\\.\";\nconst jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);\nconst isJWT = jwtRE.test.bind(jwtRE);\nexport {\n isJWT\n};\n", "import { isJWT } from \"./is-jwt.js\";\nasync function auth(token) {\n const isApp = isJWT(token);\n const isInstallation = token.startsWith(\"v1.\") || token.startsWith(\"ghs_\");\n const isUserToServer = token.startsWith(\"ghu_\");\n const tokenType = isApp ? \"app\" : isInstallation ? \"installation\" : isUserToServer ? \"user-to-server\" : \"oauth\";\n return {\n type: \"token\",\n token,\n tokenType\n };\n}\nexport {\n auth\n};\n", "function withAuthorizationPrefix(token) {\n if (token.split(/\\./).length === 3) {\n return `bearer ${token}`;\n }\n return `token ${token}`;\n}\nexport {\n withAuthorizationPrefix\n};\n", "import { withAuthorizationPrefix } from \"./with-authorization-prefix.js\";\nasync function hook(token, request, route, parameters) {\n const endpoint = request.endpoint.merge(\n route,\n parameters\n );\n endpoint.headers.authorization = withAuthorizationPrefix(token);\n return request(endpoint);\n}\nexport {\n hook\n};\n", "import { auth } from \"./auth.js\";\nimport { hook } from \"./hook.js\";\nconst createTokenAuth = function createTokenAuth2(token) {\n if (!token) {\n throw new Error(\"[@octokit/auth-token] No token passed to createTokenAuth\");\n }\n if (typeof token !== \"string\") {\n throw new Error(\n \"[@octokit/auth-token] Token passed to createTokenAuth is not a string\"\n );\n }\n token = token.replace(/^(token|bearer) +/i, \"\");\n return Object.assign(auth.bind(null, token), {\n hook: hook.bind(null, token)\n });\n};\nexport {\n createTokenAuth\n};\n"],
|
| 5 |
+
"mappings": ";AAAA,IAAM,SAAS;AACf,IAAM,MAAM;AACZ,IAAM,QAAQ,IAAI,OAAO,IAAI,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG;AACpE,IAAM,QAAQ,MAAM,KAAK,KAAK,KAAK;;;ACFnC,eAAe,KAAK,OAAO;AACzB,QAAM,QAAQ,MAAM,KAAK;AACzB,QAAM,iBAAiB,MAAM,WAAW,KAAK,KAAK,MAAM,WAAW,MAAM;AACzE,QAAM,iBAAiB,MAAM,WAAW,MAAM;AAC9C,QAAM,YAAY,QAAQ,QAAQ,iBAAiB,iBAAiB,iBAAiB,mBAAmB;AACxG,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF;AACF;;;ACXA,SAAS,wBAAwB,OAAO;AACtC,MAAI,MAAM,MAAM,IAAI,EAAE,WAAW,GAAG;AAClC,WAAO,UAAU,KAAK;AAAA,EACxB;AACA,SAAO,SAAS,KAAK;AACvB;;;ACJA,eAAe,KAAK,OAAO,SAAS,OAAO,YAAY;AACrD,QAAM,WAAW,QAAQ,SAAS;AAAA,IAChC;AAAA,IACA;AAAA,EACF;AACA,WAAS,QAAQ,gBAAgB,wBAAwB,KAAK;AAC9D,SAAO,QAAQ,QAAQ;AACzB;;;ACNA,IAAM,kBAAkB,SAAS,iBAAiB,OAAO;AACvD,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,UAAQ,MAAM,QAAQ,sBAAsB,EAAE;AAC9C,SAAO,OAAO,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG;AAAA,IAC3C,MAAM,KAAK,KAAK,MAAM,KAAK;AAAA,EAC7B,CAAC;AACH;",
|
| 6 |
+
"names": []
|
| 7 |
+
}
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/auth.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { isJWT } from "./is-jwt.js";
|
| 2 |
+
async function auth(token) {
|
| 3 |
+
const isApp = isJWT(token);
|
| 4 |
+
const isInstallation = token.startsWith("v1.") || token.startsWith("ghs_");
|
| 5 |
+
const isUserToServer = token.startsWith("ghu_");
|
| 6 |
+
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
| 7 |
+
return {
|
| 8 |
+
type: "token",
|
| 9 |
+
token,
|
| 10 |
+
tokenType
|
| 11 |
+
};
|
| 12 |
+
}
|
| 13 |
+
export {
|
| 14 |
+
auth
|
| 15 |
+
};
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/hook.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { withAuthorizationPrefix } from "./with-authorization-prefix.js";
|
| 2 |
+
async function hook(token, request, route, parameters) {
|
| 3 |
+
const endpoint = request.endpoint.merge(
|
| 4 |
+
route,
|
| 5 |
+
parameters
|
| 6 |
+
);
|
| 7 |
+
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
| 8 |
+
return request(endpoint);
|
| 9 |
+
}
|
| 10 |
+
export {
|
| 11 |
+
hook
|
| 12 |
+
};
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { auth } from "./auth.js";
|
| 2 |
+
import { hook } from "./hook.js";
|
| 3 |
+
const createTokenAuth = function createTokenAuth2(token) {
|
| 4 |
+
if (!token) {
|
| 5 |
+
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
| 6 |
+
}
|
| 7 |
+
if (typeof token !== "string") {
|
| 8 |
+
throw new Error(
|
| 9 |
+
"[@octokit/auth-token] Token passed to createTokenAuth is not a string"
|
| 10 |
+
);
|
| 11 |
+
}
|
| 12 |
+
token = token.replace(/^(token|bearer) +/i, "");
|
| 13 |
+
return Object.assign(auth.bind(null, token), {
|
| 14 |
+
hook: hook.bind(null, token)
|
| 15 |
+
});
|
| 16 |
+
};
|
| 17 |
+
export {
|
| 18 |
+
createTokenAuth
|
| 19 |
+
};
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/is-jwt.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const b64url = "(?:[a-zA-Z0-9_-]+)";
|
| 2 |
+
const sep = "\\.";
|
| 3 |
+
const jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);
|
| 4 |
+
const isJWT = jwtRE.test.bind(jwtRE);
|
| 5 |
+
export {
|
| 6 |
+
isJWT
|
| 7 |
+
};
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-src/with-authorization-prefix.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function withAuthorizationPrefix(token) {
|
| 2 |
+
if (token.split(/\./).length === 3) {
|
| 3 |
+
return `bearer ${token}`;
|
| 4 |
+
}
|
| 5 |
+
return `token ${token}`;
|
| 6 |
+
}
|
| 7 |
+
export {
|
| 8 |
+
withAuthorizationPrefix
|
| 9 |
+
};
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/auth.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Token, Authentication } from "./types.js";
|
| 2 |
+
export declare function auth(token: Token): Promise<Authentication>;
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/hook.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { AnyResponse, EndpointOptions, RequestInterface, RequestParameters, Route, Token } from "./types.js";
|
| 2 |
+
export declare function hook(token: Token, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { StrategyInterface, Token, Authentication } from "./types.js";
|
| 2 |
+
export type Types = {
|
| 3 |
+
StrategyOptions: Token;
|
| 4 |
+
AuthOptions: never;
|
| 5 |
+
Authentication: Authentication;
|
| 6 |
+
};
|
| 7 |
+
export declare const createTokenAuth: StrategyInterface;
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/is-jwt.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export declare const isJWT: (string: string) => boolean;
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/types.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as OctokitTypes from "@octokit/types";
|
| 2 |
+
export type AnyResponse = OctokitTypes.OctokitResponse<any>;
|
| 3 |
+
export type StrategyInterface = OctokitTypes.StrategyInterface<[
|
| 4 |
+
Token
|
| 5 |
+
], [
|
| 6 |
+
], Authentication>;
|
| 7 |
+
export type EndpointDefaults = OctokitTypes.EndpointDefaults;
|
| 8 |
+
export type EndpointOptions = OctokitTypes.EndpointOptions;
|
| 9 |
+
export type RequestParameters = OctokitTypes.RequestParameters;
|
| 10 |
+
export type RequestInterface = OctokitTypes.RequestInterface;
|
| 11 |
+
export type Route = OctokitTypes.Route;
|
| 12 |
+
export type Token = string;
|
| 13 |
+
export type OAuthTokenAuthentication = {
|
| 14 |
+
type: "token";
|
| 15 |
+
tokenType: "oauth";
|
| 16 |
+
token: Token;
|
| 17 |
+
};
|
| 18 |
+
export type InstallationTokenAuthentication = {
|
| 19 |
+
type: "token";
|
| 20 |
+
tokenType: "installation";
|
| 21 |
+
token: Token;
|
| 22 |
+
};
|
| 23 |
+
export type AppAuthentication = {
|
| 24 |
+
type: "token";
|
| 25 |
+
tokenType: "app";
|
| 26 |
+
token: Token;
|
| 27 |
+
};
|
| 28 |
+
export type UserToServerAuthentication = {
|
| 29 |
+
type: "token";
|
| 30 |
+
tokenType: "user-to-server";
|
| 31 |
+
token: Token;
|
| 32 |
+
};
|
| 33 |
+
export type Authentication = OAuthTokenAuthentication | InstallationTokenAuthentication | AppAuthentication | UserToServerAuthentication;
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/dist-types/with-authorization-prefix.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Prefix token for usage in the Authorization header
|
| 3 |
+
*
|
| 4 |
+
* @param token OAuth token or JSON Web Token
|
| 5 |
+
*/
|
| 6 |
+
export declare function withAuthorizationPrefix(token: string): string;
|
node_modules/.pnpm/@octokit+auth-token@6.0.0/node_modules/@octokit/auth-token/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@octokit/auth-token",
|
| 3 |
+
"publishConfig": {
|
| 4 |
+
"access": "public",
|
| 5 |
+
"provenance": true
|
| 6 |
+
},
|
| 7 |
+
"type": "module",
|
| 8 |
+
"version": "6.0.0",
|
| 9 |
+
"description": "GitHub API token authentication for browsers and Node.js",
|
| 10 |
+
"repository": "github:octokit/auth-token.js",
|
| 11 |
+
"keywords": [
|
| 12 |
+
"github",
|
| 13 |
+
"octokit",
|
| 14 |
+
"authentication",
|
| 15 |
+
"api"
|
| 16 |
+
],
|
| 17 |
+
"author": "Gregor Martynus (https://github.com/gr2m)",
|
| 18 |
+
"license": "MIT",
|
| 19 |
+
"devDependencies": {
|
| 20 |
+
"@octokit/request": "^9.0.0",
|
| 21 |
+
"@octokit/tsconfig": "^4.0.0",
|
| 22 |
+
"@octokit/types": "^14.0.0",
|
| 23 |
+
"@vitest/coverage-v8": "^3.0.0",
|
| 24 |
+
"esbuild": "^0.25.0",
|
| 25 |
+
"fetch-mock": "^12.0.0",
|
| 26 |
+
"glob": "^11.0.0",
|
| 27 |
+
"prettier": "3.5.3",
|
| 28 |
+
"typescript": "^5.3.0",
|
| 29 |
+
"vitest": "^3.0.0"
|
| 30 |
+
},
|
| 31 |
+
"engines": {
|
| 32 |
+
"node": ">= 20"
|
| 33 |
+
},
|
| 34 |
+
"files": [
|
| 35 |
+
"dist-*/**",
|
| 36 |
+
"bin/**"
|
| 37 |
+
],
|
| 38 |
+
"types": "./dist-types/index.d.ts",
|
| 39 |
+
"exports": {
|
| 40 |
+
".": {
|
| 41 |
+
"types": "./dist-types/index.d.ts",
|
| 42 |
+
"import": "./dist-bundle/index.js",
|
| 43 |
+
"default": "./dist-bundle/index.js"
|
| 44 |
+
},
|
| 45 |
+
"./types": {
|
| 46 |
+
"types": "./dist-types/index.d.ts"
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"sideEffects": false
|
| 50 |
+
}
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2020 Octokit contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in
|
| 13 |
+
all copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 21 |
+
THE SOFTWARE.
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# auth-unauthenticated.js
|
| 2 |
+
|
| 3 |
+
> strategy for explicitly unauthenticated Octokit instances
|
| 4 |
+
|
| 5 |
+
[](https://www.npmjs.com/package/@octokit/auth-unauthenticated)
|
| 6 |
+
[](https://github.com/octokit/auth-unauthenticated.js/actions?query=workflow%3ATest)
|
| 7 |
+
|
| 8 |
+
`@octokit/auth-unauthenticated` is useful for cases when an Octokit constructor has a default authentication strategy, but you require an explicitly unauthenticated instance.
|
| 9 |
+
|
| 10 |
+
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.
|
| 11 |
+
|
| 12 |
+
<!-- toc -->
|
| 13 |
+
|
| 14 |
+
- [Usage](#usage)
|
| 15 |
+
- [`createUnauthenticatedAuth() options`](#createunauthenticatedauth-options)
|
| 16 |
+
- [`auth()`](#auth)
|
| 17 |
+
- [Authentication object](#authentication-object)
|
| 18 |
+
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
|
| 19 |
+
- [License](#license)
|
| 20 |
+
|
| 21 |
+
<!-- tocstop -->
|
| 22 |
+
|
| 23 |
+
## Usage
|
| 24 |
+
|
| 25 |
+
<table>
|
| 26 |
+
<tbody valign=top align=left>
|
| 27 |
+
<tr><th>
|
| 28 |
+
Browsers
|
| 29 |
+
</th><td width=100%>
|
| 30 |
+
|
| 31 |
+
Load `@octokit/auth-unauthenticated` directly from [esm.sh](https://esm.sh)
|
| 32 |
+
|
| 33 |
+
```html
|
| 34 |
+
<script type="module">
|
| 35 |
+
import { createUnauthenticatedAuth } from "https://esm.sh/@octokit/auth-unauthenticated";
|
| 36 |
+
</script>
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
</td></tr>
|
| 40 |
+
<tr><th>
|
| 41 |
+
Node
|
| 42 |
+
</th><td>
|
| 43 |
+
|
| 44 |
+
Install with <code>npm install @octokit/auth-unauthenticated</code>
|
| 45 |
+
|
| 46 |
+
```js
|
| 47 |
+
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
</td></tr>
|
| 51 |
+
</tbody>
|
| 52 |
+
</table>
|
| 53 |
+
|
| 54 |
+
> [!IMPORTANT]
|
| 55 |
+
> 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"`.
|
| 56 |
+
>
|
| 57 |
+
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
|
| 58 |
+
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)
|
| 59 |
+
|
| 60 |
+
```js
|
| 61 |
+
const auth = createUnauthenticatedAuth({
|
| 62 |
+
reason:
|
| 63 |
+
"Handling an installation.deleted event (The app's access has been revoked)",
|
| 64 |
+
});
|
| 65 |
+
const authentication = await auth();
|
| 66 |
+
// {
|
| 67 |
+
// type: 'unauthenticated',
|
| 68 |
+
// reason: 'Handling an installation.deleted event (The app's access has been revoked)'
|
| 69 |
+
// }
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
## `createUnauthenticatedAuth() options`
|
| 73 |
+
|
| 74 |
+
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.
|
| 75 |
+
|
| 76 |
+
Examples
|
| 77 |
+
|
| 78 |
+
```js
|
| 79 |
+
createUnauthenticatedAuth({
|
| 80 |
+
reason:
|
| 81 |
+
"Handling an installation.deleted event: The app's access has been revoked from @octokit (id: 12345)",
|
| 82 |
+
});
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## `auth()`
|
| 86 |
+
|
| 87 |
+
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.
|
| 88 |
+
|
| 89 |
+
## Authentication object
|
| 90 |
+
|
| 91 |
+
<table width="100%">
|
| 92 |
+
<thead align=left>
|
| 93 |
+
<tr>
|
| 94 |
+
<th width=150>
|
| 95 |
+
name
|
| 96 |
+
</th>
|
| 97 |
+
<th width=70>
|
| 98 |
+
type
|
| 99 |
+
</th>
|
| 100 |
+
<th>
|
| 101 |
+
description
|
| 102 |
+
</th>
|
| 103 |
+
</tr>
|
| 104 |
+
</thead>
|
| 105 |
+
<tbody align=left valign=top>
|
| 106 |
+
<tr>
|
| 107 |
+
<th>
|
| 108 |
+
<code>type</code>
|
| 109 |
+
</th>
|
| 110 |
+
<th>
|
| 111 |
+
<code>string</code>
|
| 112 |
+
</th>
|
| 113 |
+
<td>
|
| 114 |
+
<code>"unauthenticated"</code>
|
| 115 |
+
</td>
|
| 116 |
+
</tr>
|
| 117 |
+
</tbody>
|
| 118 |
+
</table>
|
| 119 |
+
|
| 120 |
+
## `auth.hook(request, route, options)` or `auth.hook(request, options)`
|
| 121 |
+
|
| 122 |
+
`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 })`.
|
| 123 |
+
|
| 124 |
+
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 })`.
|
| 125 |
+
|
| 126 |
+
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).
|
| 127 |
+
|
| 128 |
+
`auth.hook()` can be called directly to send an authenticated request
|
| 129 |
+
|
| 130 |
+
```js
|
| 131 |
+
const { data } = await auth.hook(request, "GET /");
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
Or it can be passed as option to [`request()`](https://github.com/octokit/request.js#request).
|
| 135 |
+
|
| 136 |
+
```js
|
| 137 |
+
const requestWithAuth = request.defaults({
|
| 138 |
+
request: {
|
| 139 |
+
hook: auth.hook,
|
| 140 |
+
},
|
| 141 |
+
});
|
| 142 |
+
|
| 143 |
+
const { data } = await requestWithAuth("GET /");
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
## License
|
| 147 |
+
|
| 148 |
+
[MIT](LICENSE)
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-node/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// pkg/dist-src/auth.js
|
| 2 |
+
async function auth(reason) {
|
| 3 |
+
return {
|
| 4 |
+
type: "unauthenticated",
|
| 5 |
+
reason
|
| 6 |
+
};
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
// pkg/dist-src/is-rate-limit-error.js
|
| 10 |
+
function isRateLimitError(error) {
|
| 11 |
+
if (error.status !== 403) {
|
| 12 |
+
return false;
|
| 13 |
+
}
|
| 14 |
+
if (!error.response) {
|
| 15 |
+
return false;
|
| 16 |
+
}
|
| 17 |
+
return error.response.headers["x-ratelimit-remaining"] === "0";
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
// pkg/dist-src/is-abuse-limit-error.js
|
| 21 |
+
var REGEX_ABUSE_LIMIT_MESSAGE = /\babuse\b/i;
|
| 22 |
+
function isAbuseLimitError(error) {
|
| 23 |
+
if (error.status !== 403) {
|
| 24 |
+
return false;
|
| 25 |
+
}
|
| 26 |
+
return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
// pkg/dist-src/hook.js
|
| 30 |
+
async function hook(reason, request, route, parameters) {
|
| 31 |
+
const endpoint = request.endpoint.merge(
|
| 32 |
+
route,
|
| 33 |
+
parameters
|
| 34 |
+
);
|
| 35 |
+
return request(endpoint).catch((error) => {
|
| 36 |
+
if (error.status === 404) {
|
| 37 |
+
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
|
| 38 |
+
throw error;
|
| 39 |
+
}
|
| 40 |
+
if (isRateLimitError(error)) {
|
| 41 |
+
error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
| 42 |
+
throw error;
|
| 43 |
+
}
|
| 44 |
+
if (isAbuseLimitError(error)) {
|
| 45 |
+
error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
| 46 |
+
throw error;
|
| 47 |
+
}
|
| 48 |
+
if (error.status === 401) {
|
| 49 |
+
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
|
| 50 |
+
throw error;
|
| 51 |
+
}
|
| 52 |
+
if (error.status >= 400 && error.status < 500) {
|
| 53 |
+
error.message = error.message.replace(
|
| 54 |
+
/\.?$/,
|
| 55 |
+
`. May be caused by lack of authentication (${reason}).`
|
| 56 |
+
);
|
| 57 |
+
}
|
| 58 |
+
throw error;
|
| 59 |
+
});
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// pkg/dist-src/index.js
|
| 63 |
+
var createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) {
|
| 64 |
+
if (!options || !options.reason) {
|
| 65 |
+
throw new Error(
|
| 66 |
+
"[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth"
|
| 67 |
+
);
|
| 68 |
+
}
|
| 69 |
+
return Object.assign(auth.bind(null, options.reason), {
|
| 70 |
+
hook: hook.bind(null, options.reason)
|
| 71 |
+
});
|
| 72 |
+
};
|
| 73 |
+
export {
|
| 74 |
+
createUnauthenticatedAuth
|
| 75 |
+
};
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-node/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": 3,
|
| 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"],
|
| 4 |
+
"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"],
|
| 5 |
+
"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;",
|
| 6 |
+
"names": []
|
| 7 |
+
}
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/auth.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
async function auth(reason) {
|
| 2 |
+
return {
|
| 3 |
+
type: "unauthenticated",
|
| 4 |
+
reason
|
| 5 |
+
};
|
| 6 |
+
}
|
| 7 |
+
export {
|
| 8 |
+
auth
|
| 9 |
+
};
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/hook.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { isRateLimitError } from "./is-rate-limit-error.js";
|
| 2 |
+
import { isAbuseLimitError } from "./is-abuse-limit-error.js";
|
| 3 |
+
async function hook(reason, request, route, parameters) {
|
| 4 |
+
const endpoint = request.endpoint.merge(
|
| 5 |
+
route,
|
| 6 |
+
parameters
|
| 7 |
+
);
|
| 8 |
+
return request(endpoint).catch((error) => {
|
| 9 |
+
if (error.status === 404) {
|
| 10 |
+
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
|
| 11 |
+
throw error;
|
| 12 |
+
}
|
| 13 |
+
if (isRateLimitError(error)) {
|
| 14 |
+
error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
| 15 |
+
throw error;
|
| 16 |
+
}
|
| 17 |
+
if (isAbuseLimitError(error)) {
|
| 18 |
+
error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
| 19 |
+
throw error;
|
| 20 |
+
}
|
| 21 |
+
if (error.status === 401) {
|
| 22 |
+
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
|
| 23 |
+
throw error;
|
| 24 |
+
}
|
| 25 |
+
if (error.status >= 400 && error.status < 500) {
|
| 26 |
+
error.message = error.message.replace(
|
| 27 |
+
/\.?$/,
|
| 28 |
+
`. May be caused by lack of authentication (${reason}).`
|
| 29 |
+
);
|
| 30 |
+
}
|
| 31 |
+
throw error;
|
| 32 |
+
});
|
| 33 |
+
}
|
| 34 |
+
export {
|
| 35 |
+
hook
|
| 36 |
+
};
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { auth } from "./auth.js";
|
| 2 |
+
import { hook } from "./hook.js";
|
| 3 |
+
const createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) {
|
| 4 |
+
if (!options || !options.reason) {
|
| 5 |
+
throw new Error(
|
| 6 |
+
"[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth"
|
| 7 |
+
);
|
| 8 |
+
}
|
| 9 |
+
return Object.assign(auth.bind(null, options.reason), {
|
| 10 |
+
hook: hook.bind(null, options.reason)
|
| 11 |
+
});
|
| 12 |
+
};
|
| 13 |
+
export {
|
| 14 |
+
createUnauthenticatedAuth
|
| 15 |
+
};
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/is-abuse-limit-error.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const REGEX_ABUSE_LIMIT_MESSAGE = /\babuse\b/i;
|
| 2 |
+
function isAbuseLimitError(error) {
|
| 3 |
+
if (error.status !== 403) {
|
| 4 |
+
return false;
|
| 5 |
+
}
|
| 6 |
+
return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message);
|
| 7 |
+
}
|
| 8 |
+
export {
|
| 9 |
+
isAbuseLimitError
|
| 10 |
+
};
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-src/is-rate-limit-error.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function isRateLimitError(error) {
|
| 2 |
+
if (error.status !== 403) {
|
| 3 |
+
return false;
|
| 4 |
+
}
|
| 5 |
+
if (!error.response) {
|
| 6 |
+
return false;
|
| 7 |
+
}
|
| 8 |
+
return error.response.headers["x-ratelimit-remaining"] === "0";
|
| 9 |
+
}
|
| 10 |
+
export {
|
| 11 |
+
isRateLimitError
|
| 12 |
+
};
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/auth.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Authentication } from "./types.js";
|
| 2 |
+
export declare function auth(reason: string): Promise<Authentication>;
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/hook.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { AnyResponse, EndpointOptions, RequestInterface, RequestParameters, Route } from "./types.js";
|
| 2 |
+
export declare function hook(reason: string, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { StrategyInterface, Options, Authentication } from "./types.js";
|
| 2 |
+
export type Types = {
|
| 3 |
+
StrategyOptions: Options;
|
| 4 |
+
AuthOptions: never;
|
| 5 |
+
Authentication: Authentication;
|
| 6 |
+
};
|
| 7 |
+
export declare const createUnauthenticatedAuth: StrategyInterface;
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/is-abuse-limit-error.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { RequestError } from "@octokit/request-error";
|
| 2 |
+
export declare function isAbuseLimitError(error: RequestError): boolean;
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/is-rate-limit-error.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { RequestError } from "@octokit/request-error";
|
| 2 |
+
export declare function isRateLimitError(error: RequestError): boolean;
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-types/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { OctokitResponse, StrategyInterface as OctokitStrategyInterface } from "@octokit/types";
|
| 2 |
+
export type AnyResponse = OctokitResponse<any>;
|
| 3 |
+
export type StrategyInterface = OctokitStrategyInterface<[
|
| 4 |
+
Options
|
| 5 |
+
], [
|
| 6 |
+
], Authentication>;
|
| 7 |
+
export type { EndpointDefaults, EndpointOptions, RequestParameters, RequestInterface, Route, } from "@octokit/types";
|
| 8 |
+
export type Options = {
|
| 9 |
+
reason: string;
|
| 10 |
+
};
|
| 11 |
+
export type Authentication = {
|
| 12 |
+
type: "unauthenticated";
|
| 13 |
+
reason: string;
|
| 14 |
+
};
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-web/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// pkg/dist-src/auth.js
|
| 2 |
+
async function auth(reason) {
|
| 3 |
+
return {
|
| 4 |
+
type: "unauthenticated",
|
| 5 |
+
reason
|
| 6 |
+
};
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
// pkg/dist-src/is-rate-limit-error.js
|
| 10 |
+
function isRateLimitError(error) {
|
| 11 |
+
if (error.status !== 403) {
|
| 12 |
+
return false;
|
| 13 |
+
}
|
| 14 |
+
if (!error.response) {
|
| 15 |
+
return false;
|
| 16 |
+
}
|
| 17 |
+
return error.response.headers["x-ratelimit-remaining"] === "0";
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
// pkg/dist-src/is-abuse-limit-error.js
|
| 21 |
+
var REGEX_ABUSE_LIMIT_MESSAGE = /\babuse\b/i;
|
| 22 |
+
function isAbuseLimitError(error) {
|
| 23 |
+
if (error.status !== 403) {
|
| 24 |
+
return false;
|
| 25 |
+
}
|
| 26 |
+
return REGEX_ABUSE_LIMIT_MESSAGE.test(error.message);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
// pkg/dist-src/hook.js
|
| 30 |
+
async function hook(reason, request, route, parameters) {
|
| 31 |
+
const endpoint = request.endpoint.merge(
|
| 32 |
+
route,
|
| 33 |
+
parameters
|
| 34 |
+
);
|
| 35 |
+
return request(endpoint).catch((error) => {
|
| 36 |
+
if (error.status === 404) {
|
| 37 |
+
error.message = `Not found. May be due to lack of authentication. Reason: ${reason}`;
|
| 38 |
+
throw error;
|
| 39 |
+
}
|
| 40 |
+
if (isRateLimitError(error)) {
|
| 41 |
+
error.message = `API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
| 42 |
+
throw error;
|
| 43 |
+
}
|
| 44 |
+
if (isAbuseLimitError(error)) {
|
| 45 |
+
error.message = `You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${reason}`;
|
| 46 |
+
throw error;
|
| 47 |
+
}
|
| 48 |
+
if (error.status === 401) {
|
| 49 |
+
error.message = `Unauthorized. "${endpoint.method} ${endpoint.url}" failed most likely due to lack of authentication. Reason: ${reason}`;
|
| 50 |
+
throw error;
|
| 51 |
+
}
|
| 52 |
+
if (error.status >= 400 && error.status < 500) {
|
| 53 |
+
error.message = error.message.replace(
|
| 54 |
+
/\.?$/,
|
| 55 |
+
`. May be caused by lack of authentication (${reason}).`
|
| 56 |
+
);
|
| 57 |
+
}
|
| 58 |
+
throw error;
|
| 59 |
+
});
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// pkg/dist-src/index.js
|
| 63 |
+
var createUnauthenticatedAuth = function createUnauthenticatedAuth2(options) {
|
| 64 |
+
if (!options || !options.reason) {
|
| 65 |
+
throw new Error(
|
| 66 |
+
"[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth"
|
| 67 |
+
);
|
| 68 |
+
}
|
| 69 |
+
return Object.assign(auth.bind(null, options.reason), {
|
| 70 |
+
hook: hook.bind(null, options.reason)
|
| 71 |
+
});
|
| 72 |
+
};
|
| 73 |
+
export {
|
| 74 |
+
createUnauthenticatedAuth
|
| 75 |
+
};
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/dist-web/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": 3,
|
| 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"],
|
| 4 |
+
"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"],
|
| 5 |
+
"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;",
|
| 6 |
+
"names": []
|
| 7 |
+
}
|
node_modules/.pnpm/@octokit+auth-unauthenticated@7.0.3/node_modules/@octokit/auth-unauthenticated/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@octokit/auth-unauthenticated",
|
| 3 |
+
"publishConfig": {
|
| 4 |
+
"access": "public",
|
| 5 |
+
"provenance": true
|
| 6 |
+
},
|
| 7 |
+
"type": "module",
|
| 8 |
+
"version": "7.0.3",
|
| 9 |
+
"description": "GitHub API token authentication for browsers and Node.js",
|
| 10 |
+
"repository": "github:octokit/auth-unauthenticated.js",
|
| 11 |
+
"keywords": [
|
| 12 |
+
"github",
|
| 13 |
+
"octokit",
|
| 14 |
+
"authentication",
|
| 15 |
+
"api"
|
| 16 |
+
],
|
| 17 |
+
"author": "Gregor Martynus (https://github.com/gr2m)",
|
| 18 |
+
"license": "MIT",
|
| 19 |
+
"dependencies": {
|
| 20 |
+
"@octokit/request-error": "^7.0.2",
|
| 21 |
+
"@octokit/types": "^16.0.0"
|
| 22 |
+
},
|
| 23 |
+
"devDependencies": {
|
| 24 |
+
"@octokit/core": "^7.0.6",
|
| 25 |
+
"@octokit/request": "^10.0.6",
|
| 26 |
+
"@octokit/tsconfig": "^4.0.0",
|
| 27 |
+
"@types/node": "^24.0.0",
|
| 28 |
+
"@vitest/coverage-v8": "^3.0.0",
|
| 29 |
+
"esbuild": "^0.25.0",
|
| 30 |
+
"fetch-mock": "^12.0.0",
|
| 31 |
+
"prettier": "3.6.2",
|
| 32 |
+
"tinyglobby": "^0.2.13",
|
| 33 |
+
"typescript": "^5.0.0",
|
| 34 |
+
"vitest": "^3.0.0"
|
| 35 |
+
},
|
| 36 |
+
"engines": {
|
| 37 |
+
"node": ">= 20"
|
| 38 |
+
},
|
| 39 |
+
"files": [
|
| 40 |
+
"dist-*/**",
|
| 41 |
+
"bin/**"
|
| 42 |
+
],
|
| 43 |
+
"exports": {
|
| 44 |
+
".": {
|
| 45 |
+
"node": {
|
| 46 |
+
"types": "./dist-types/index.d.ts",
|
| 47 |
+
"import": "./dist-node/index.js"
|
| 48 |
+
},
|
| 49 |
+
"browser": {
|
| 50 |
+
"types": "./dist-types/web.d.ts",
|
| 51 |
+
"import": "./dist-web/index.js"
|
| 52 |
+
},
|
| 53 |
+
"default": {
|
| 54 |
+
"types": "./dist-types/index.d.ts",
|
| 55 |
+
"import": "./dist-node/index.js"
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
},
|
| 59 |
+
"sideEffects": false
|
| 60 |
+
}
|
node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2019 Octokit contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in
|
| 13 |
+
all copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 21 |
+
THE SOFTWARE.
|
node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/README.md
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# core.js
|
| 2 |
+
|
| 3 |
+
> Extendable client for GitHub's REST & GraphQL APIs
|
| 4 |
+
|
| 5 |
+
[](https://www.npmjs.com/package/@octokit/core)
|
| 6 |
+
[](https://github.com/octokit/core.js/actions?query=workflow%3ATest+branch%3Amain)
|
| 7 |
+
|
| 8 |
+
<!-- toc -->
|
| 9 |
+
|
| 10 |
+
- [Usage](#usage)
|
| 11 |
+
- [REST API example](#rest-api-example)
|
| 12 |
+
- [GraphQL example](#graphql-example)
|
| 13 |
+
- [Options](#options)
|
| 14 |
+
- [Defaults](#defaults)
|
| 15 |
+
- [Authentication](#authentication)
|
| 16 |
+
- [Logging](#logging)
|
| 17 |
+
- [Hooks](#hooks)
|
| 18 |
+
- [Plugins](#plugins)
|
| 19 |
+
- [Build your own Octokit with Plugins and Defaults](#build-your-own-octokit-with-plugins-and-defaults)
|
| 20 |
+
- [LICENSE](#license)
|
| 21 |
+
|
| 22 |
+
<!-- tocstop -->
|
| 23 |
+
|
| 24 |
+
If you need a minimalistic library to utilize GitHub's [REST API](https://developer.github.com/v3/) and [GraphQL API](https://developer.github.com/v4/) which you can extend with plugins as needed, then `@octokit/core` is a great starting point.
|
| 25 |
+
|
| 26 |
+
If you don't need the Plugin API then using [`@octokit/request`](https://github.com/octokit/request.js/) or [`@octokit/graphql`](https://github.com/octokit/graphql.js/) directly is a good alternative.
|
| 27 |
+
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
<table>
|
| 31 |
+
<tbody valign=top align=left>
|
| 32 |
+
<tr><th>
|
| 33 |
+
Browsers
|
| 34 |
+
</th><td width=100%>
|
| 35 |
+
Load <code>@octokit/core</code> directly from <a href="https://esm.sh">esm.sh</a>
|
| 36 |
+
|
| 37 |
+
```html
|
| 38 |
+
<script type="module">
|
| 39 |
+
import { Octokit } from "https://esm.sh/@octokit/core";
|
| 40 |
+
</script>
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
</td></tr>
|
| 44 |
+
<tr><th>
|
| 45 |
+
Node
|
| 46 |
+
</th><td>
|
| 47 |
+
|
| 48 |
+
Install with <code>npm install @octokit/core</code>
|
| 49 |
+
|
| 50 |
+
```js
|
| 51 |
+
import { Octokit } from "@octokit/core";
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
</td></tr>
|
| 55 |
+
</tbody>
|
| 56 |
+
</table>
|
| 57 |
+
|
| 58 |
+
As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json`. See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).
|
| 59 |
+
|
| 60 |
+
### REST API example
|
| 61 |
+
|
| 62 |
+
```js
|
| 63 |
+
// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
|
| 64 |
+
const octokit = new Octokit({ auth: `personal-access-token123` });
|
| 65 |
+
|
| 66 |
+
const response = await octokit.request("GET /orgs/{org}/repos", {
|
| 67 |
+
org: "octokit",
|
| 68 |
+
type: "private",
|
| 69 |
+
});
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
See [`@octokit/request`](https://github.com/octokit/request.js) for full documentation of the `.request` method.
|
| 73 |
+
|
| 74 |
+
### GraphQL example
|
| 75 |
+
|
| 76 |
+
```js
|
| 77 |
+
const octokit = new Octokit({ auth: `secret123` });
|
| 78 |
+
|
| 79 |
+
const response = await octokit.graphql(
|
| 80 |
+
`query ($login: String!) {
|
| 81 |
+
organization(login: $login) {
|
| 82 |
+
repositories(privacy: PRIVATE) {
|
| 83 |
+
totalCount
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
}`,
|
| 87 |
+
{ login: "octokit" },
|
| 88 |
+
);
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
See [`@octokit/graphql`](https://github.com/octokit/graphql.js) for full documentation of the `.graphql` method.
|
| 92 |
+
|
| 93 |
+
## Options
|
| 94 |
+
|
| 95 |
+
<table>
|
| 96 |
+
<thead align=left>
|
| 97 |
+
<tr>
|
| 98 |
+
<th>
|
| 99 |
+
name
|
| 100 |
+
</th>
|
| 101 |
+
<th>
|
| 102 |
+
type
|
| 103 |
+
</th>
|
| 104 |
+
<th width=100%>
|
| 105 |
+
description
|
| 106 |
+
</th>
|
| 107 |
+
</tr>
|
| 108 |
+
</thead>
|
| 109 |
+
<tbody align=left valign=top>
|
| 110 |
+
<tr>
|
| 111 |
+
<th>
|
| 112 |
+
<code>options.authStrategy</code>
|
| 113 |
+
</th>
|
| 114 |
+
<td>
|
| 115 |
+
<code>Function<code>
|
| 116 |
+
</td>
|
| 117 |
+
<td>
|
| 118 |
+
Defaults to <a href="https://github.com/octokit/auth-token.js#readme"><code>@octokit/auth-token</code></a>. See <a href="#authentication">Authentication</a> below for examples.
|
| 119 |
+
</td>
|
| 120 |
+
</tr>
|
| 121 |
+
<tr>
|
| 122 |
+
<th>
|
| 123 |
+
<code>options.auth</code>
|
| 124 |
+
</th>
|
| 125 |
+
<td>
|
| 126 |
+
<code>String</code> or <code>Object</code>
|
| 127 |
+
</td>
|
| 128 |
+
<td>
|
| 129 |
+
See <a href="#authentication">Authentication</a> below for examples.
|
| 130 |
+
</td>
|
| 131 |
+
</tr>
|
| 132 |
+
<tr>
|
| 133 |
+
<th>
|
| 134 |
+
<code>options.baseUrl</code>
|
| 135 |
+
</th>
|
| 136 |
+
<td>
|
| 137 |
+
<code>String</code>
|
| 138 |
+
</td>
|
| 139 |
+
<td>
|
| 140 |
+
|
| 141 |
+
When using with GitHub Enterprise Server, set `options.baseUrl` to the root URL of the API. For example, if your GitHub Enterprise Server's hostname is `github.acme-inc.com`, then set `options.baseUrl` to `https://github.acme-inc.com/api/v3`. Example
|
| 142 |
+
|
| 143 |
+
```js
|
| 144 |
+
const octokit = new Octokit({
|
| 145 |
+
baseUrl: "https://github.acme-inc.com/api/v3",
|
| 146 |
+
});
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
</td></tr>
|
| 150 |
+
<tr>
|
| 151 |
+
<th>
|
| 152 |
+
<code>options.previews</code>
|
| 153 |
+
</th>
|
| 154 |
+
<td>
|
| 155 |
+
<code>Array of Strings</code>
|
| 156 |
+
</td>
|
| 157 |
+
<td>
|
| 158 |
+
|
| 159 |
+
Some REST API endpoints require preview headers to be set, or enable
|
| 160 |
+
additional features. Preview headers can be set on a per-request basis, e.g.
|
| 161 |
+
|
| 162 |
+
```js
|
| 163 |
+
octokit.request("POST /repos/{owner}/{repo}/pulls", {
|
| 164 |
+
mediaType: {
|
| 165 |
+
previews: ["shadow-cat"],
|
| 166 |
+
},
|
| 167 |
+
owner,
|
| 168 |
+
repo,
|
| 169 |
+
title: "My pull request",
|
| 170 |
+
base: "main",
|
| 171 |
+
head: "my-feature",
|
| 172 |
+
draft: true,
|
| 173 |
+
});
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
You can also set previews globally, by setting the `options.previews` option on the constructor. Example:
|
| 177 |
+
|
| 178 |
+
```js
|
| 179 |
+
const octokit = new Octokit({
|
| 180 |
+
previews: ["shadow-cat"],
|
| 181 |
+
});
|
| 182 |
+
```
|
| 183 |
+
|
| 184 |
+
</td></tr>
|
| 185 |
+
<tr>
|
| 186 |
+
<th>
|
| 187 |
+
<code>options.request</code>
|
| 188 |
+
</th>
|
| 189 |
+
<td>
|
| 190 |
+
<code>Object</code>
|
| 191 |
+
</td>
|
| 192 |
+
<td>
|
| 193 |
+
|
| 194 |
+
Set a default request timeout (`options.request.timeout`) or an [`http(s).Agent`](https://nodejs.org/api/http.html#http_class_http_agent) e.g. for proxy usage (Node only, `options.request.agent`).
|
| 195 |
+
|
| 196 |
+
There are more `options.request.*` options, see [`@octokit/request` options](https://github.com/octokit/request.js#request). `options.request` can also be set on a per-request basis.
|
| 197 |
+
|
| 198 |
+
</td></tr>
|
| 199 |
+
<tr>
|
| 200 |
+
<th>
|
| 201 |
+
<code>options.timeZone</code>
|
| 202 |
+
</th>
|
| 203 |
+
<td>
|
| 204 |
+
<code>String</code>
|
| 205 |
+
</td>
|
| 206 |
+
<td>
|
| 207 |
+
|
| 208 |
+
Sets the `Time-Zone` header which defines a timezone according to the [list of names from the Olson database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
| 209 |
+
|
| 210 |
+
```js
|
| 211 |
+
const octokit = new Octokit({
|
| 212 |
+
timeZone: "America/Los_Angeles",
|
| 213 |
+
});
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
The time zone header will determine the timezone used for generating the timestamp when creating commits. See [GitHub's Timezones documentation](https://developer.github.com/v3/#timezones).
|
| 217 |
+
|
| 218 |
+
</td></tr>
|
| 219 |
+
<tr>
|
| 220 |
+
<th>
|
| 221 |
+
<code>options.userAgent</code>
|
| 222 |
+
</th>
|
| 223 |
+
<td>
|
| 224 |
+
<code>String</code>
|
| 225 |
+
</td>
|
| 226 |
+
<td>
|
| 227 |
+
|
| 228 |
+
A custom user agent string for your app or library. Example
|
| 229 |
+
|
| 230 |
+
```js
|
| 231 |
+
const octokit = new Octokit({
|
| 232 |
+
userAgent: "my-app/v1.2.3",
|
| 233 |
+
});
|
| 234 |
+
```
|
| 235 |
+
|
| 236 |
+
</td></tr>
|
| 237 |
+
</tbody>
|
| 238 |
+
</table>
|
| 239 |
+
|
| 240 |
+
## Defaults
|
| 241 |
+
|
| 242 |
+
You can create a new Octokit class with customized default options.
|
| 243 |
+
|
| 244 |
+
```js
|
| 245 |
+
const MyOctokit = Octokit.defaults({
|
| 246 |
+
auth: "personal-access-token123",
|
| 247 |
+
baseUrl: "https://github.acme-inc.com/api/v3",
|
| 248 |
+
userAgent: "my-app/v1.2.3",
|
| 249 |
+
});
|
| 250 |
+
const octokit1 = new MyOctokit();
|
| 251 |
+
const octokit2 = new MyOctokit();
|
| 252 |
+
```
|
| 253 |
+
|
| 254 |
+
If you pass additional options to your new constructor, the options will be merged shallowly.
|
| 255 |
+
|
| 256 |
+
```js
|
| 257 |
+
const MyOctokit = Octokit.defaults({
|
| 258 |
+
foo: {
|
| 259 |
+
opt1: 1,
|
| 260 |
+
},
|
| 261 |
+
});
|
| 262 |
+
const octokit = new MyOctokit({
|
| 263 |
+
foo: {
|
| 264 |
+
opt2: 1,
|
| 265 |
+
},
|
| 266 |
+
});
|
| 267 |
+
// options will be { foo: { opt2: 1 }}
|
| 268 |
+
```
|
| 269 |
+
|
| 270 |
+
If you need a deep or conditional merge, you can pass a function instead.
|
| 271 |
+
|
| 272 |
+
```js
|
| 273 |
+
const MyOctokit = Octokit.defaults((options) => {
|
| 274 |
+
return {
|
| 275 |
+
foo: Object.assign({}, options.foo, { opt1: 1 }),
|
| 276 |
+
};
|
| 277 |
+
});
|
| 278 |
+
const octokit = new MyOctokit({
|
| 279 |
+
foo: { opt2: 1 },
|
| 280 |
+
});
|
| 281 |
+
// options will be { foo: { opt1: 1, opt2: 1 }}
|
| 282 |
+
```
|
| 283 |
+
|
| 284 |
+
Be careful about mutating the `options` object in the `Octokit.defaults` callback, as it can have unforeseen consequences.
|
| 285 |
+
|
| 286 |
+
## Authentication
|
| 287 |
+
|
| 288 |
+
Authentication is optional for some REST API endpoints accessing public data, but is required for GraphQL queries. Using authentication also increases your [API rate limit](https://developer.github.com/v3/#rate-limiting).
|
| 289 |
+
|
| 290 |
+
By default, Octokit authenticates using the [token authentication strategy](https://github.com/octokit/auth-token.js). Pass in a token using `options.auth`. It can be a personal access token, an OAuth token, an installation access token or a JSON Web Token for GitHub App authentication. The `Authorization` header will be set according to the type of token.
|
| 291 |
+
|
| 292 |
+
```js
|
| 293 |
+
import { Octokit } from "@octokit/core";
|
| 294 |
+
|
| 295 |
+
const octokit = new Octokit({
|
| 296 |
+
auth: "mypersonalaccesstoken123",
|
| 297 |
+
});
|
| 298 |
+
|
| 299 |
+
const { data } = await octokit.request("/user");
|
| 300 |
+
```
|
| 301 |
+
|
| 302 |
+
To use a different authentication strategy, set `options.authStrategy`. A list of authentication strategies is available at [octokit/authentication-strategies.js](https://github.com/octokit/authentication-strategies.js/#readme).
|
| 303 |
+
|
| 304 |
+
Example
|
| 305 |
+
|
| 306 |
+
```js
|
| 307 |
+
import { Octokit } from "@octokit/core";
|
| 308 |
+
import { createAppAuth } from "@octokit/auth-app";
|
| 309 |
+
|
| 310 |
+
const appOctokit = new Octokit({
|
| 311 |
+
authStrategy: createAppAuth,
|
| 312 |
+
auth: {
|
| 313 |
+
appId: 123,
|
| 314 |
+
privateKey: process.env.PRIVATE_KEY,
|
| 315 |
+
},
|
| 316 |
+
});
|
| 317 |
+
|
| 318 |
+
const { data } = await appOctokit.request("/app");
|
| 319 |
+
```
|
| 320 |
+
|
| 321 |
+
The `.auth()` method returned by the current authentication strategy can be accessed at `octokit.auth()`. Example
|
| 322 |
+
|
| 323 |
+
```js
|
| 324 |
+
const { token } = await appOctokit.auth({
|
| 325 |
+
type: "installation",
|
| 326 |
+
installationId: 123,
|
| 327 |
+
});
|
| 328 |
+
```
|
| 329 |
+
|
| 330 |
+
## Logging
|
| 331 |
+
|
| 332 |
+
There are four built-in log methods
|
| 333 |
+
|
| 334 |
+
1. `octokit.log.debug(message[, additionalInfo])`
|
| 335 |
+
1. `octokit.log.info(message[, additionalInfo])`
|
| 336 |
+
1. `octokit.log.warn(message[, additionalInfo])`
|
| 337 |
+
1. `octokit.log.error(message[, additionalInfo])`
|
| 338 |
+
|
| 339 |
+
They can be configured using the [`log` client option](client-options). By default, `octokit.log.debug()` and `octokit.log.info()` are no-ops, while the other two call `console.warn()` and `console.error()` respectively.
|
| 340 |
+
|
| 341 |
+
This is useful if you build reusable [plugins](#plugins).
|
| 342 |
+
|
| 343 |
+
If you would like to make the log level configurable using an environment variable or external option, we recommend the [console-log-level](https://github.com/watson/console-log-level) package. Example
|
| 344 |
+
|
| 345 |
+
```js
|
| 346 |
+
import consoleLogLevel from "console-log-level";
|
| 347 |
+
const octokit = new Octokit({
|
| 348 |
+
log: consoleLogLevel({ level: "info" }),
|
| 349 |
+
});
|
| 350 |
+
```
|
| 351 |
+
|
| 352 |
+
## Hooks
|
| 353 |
+
|
| 354 |
+
You can customize Octokit's request lifecycle with hooks.
|
| 355 |
+
|
| 356 |
+
```js
|
| 357 |
+
octokit.hook.before("request", async (options) => {
|
| 358 |
+
validate(options);
|
| 359 |
+
});
|
| 360 |
+
octokit.hook.after("request", async (response, options) => {
|
| 361 |
+
console.log(`${options.method} ${options.url}: ${response.status}`);
|
| 362 |
+
});
|
| 363 |
+
octokit.hook.error("request", async (error, options) => {
|
| 364 |
+
if (error.status === 304) {
|
| 365 |
+
return findInCache(error.response.headers.etag);
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
throw error;
|
| 369 |
+
});
|
| 370 |
+
octokit.hook.wrap("request", async (request, options) => {
|
| 371 |
+
// add logic before, after, catch errors or replace the request altogether
|
| 372 |
+
return request(options);
|
| 373 |
+
});
|
| 374 |
+
```
|
| 375 |
+
|
| 376 |
+
See [before-after-hook](https://github.com/gr2m/before-after-hook#readme) for more documentation on hooks.
|
| 377 |
+
|
| 378 |
+
## Plugins
|
| 379 |
+
|
| 380 |
+
Octokit’s functionality can be extended using plugins. The `Octokit.plugin()` method accepts a plugin (or many) and returns a new constructor.
|
| 381 |
+
|
| 382 |
+
A plugin is a function which gets two arguments:
|
| 383 |
+
|
| 384 |
+
1. the current instance
|
| 385 |
+
2. the options passed to the constructor.
|
| 386 |
+
|
| 387 |
+
In order to extend `octokit`'s API, the plugin must return an object with the new methods. Please refrain from adding methods directly to the `octokit` instance, especialy if you depend on keys that do not exist in `@octokit/core`, such as `octokit.rest`.
|
| 388 |
+
|
| 389 |
+
```js
|
| 390 |
+
// index.js
|
| 391 |
+
import { Octokit } from "@octokit/core";
|
| 392 |
+
import myPlugin from "./lib/my-plugin.js";
|
| 393 |
+
import octokitPluginExample from "octokit-plugin-example";
|
| 394 |
+
const MyOctokit = Octokit.plugin(
|
| 395 |
+
myPlugin,
|
| 396 |
+
octokitPluginExample
|
| 397 |
+
);
|
| 398 |
+
|
| 399 |
+
const octokit = new MyOctokit({ greeting: "Moin moin" });
|
| 400 |
+
octokit.helloWorld(); // logs "Moin moin, world!"
|
| 401 |
+
octokit.request("GET /"); // logs "GET / - 200 in 123ms"
|
| 402 |
+
|
| 403 |
+
// lib/my-plugin.js
|
| 404 |
+
const plugin = (octokit, options = { greeting: "Hello" }) => {
|
| 405 |
+
// hook into the request lifecycle
|
| 406 |
+
octokit.hook.wrap("request", async (request, options) => {
|
| 407 |
+
const time = Date.now();
|
| 408 |
+
const response = await request(options);
|
| 409 |
+
console.log(
|
| 410 |
+
`${options.method} ${options.url} – ${response.status} in ${Date.now() -
|
| 411 |
+
time}ms`
|
| 412 |
+
);
|
| 413 |
+
return response;
|
| 414 |
+
});
|
| 415 |
+
|
| 416 |
+
// add a custom method
|
| 417 |
+
return {
|
| 418 |
+
helloWorld: () => console.log(`${options.greeting}, world!`);
|
| 419 |
+
}
|
| 420 |
+
};
|
| 421 |
+
export default plugin;
|
| 422 |
+
```
|
| 423 |
+
|
| 424 |
+
## Build your own Octokit with Plugins and Defaults
|
| 425 |
+
|
| 426 |
+
You can build your own Octokit class with preset default options and plugins. In fact, this is mostly how the `@octokit/<context>` modules work, such as [`@octokit/action`](https://github.com/octokit/action.js):
|
| 427 |
+
|
| 428 |
+
```js
|
| 429 |
+
import { Octokit } from "@octokit/core";
|
| 430 |
+
import { paginateRest } from "@octokit/plugin-paginate-rest";
|
| 431 |
+
import { throttling } from "@octokit/plugin-throttling";
|
| 432 |
+
import { retry } from "@octokit/plugin-retry";
|
| 433 |
+
import { createActionAuth } from "@octokit/auth-action";
|
| 434 |
+
const MyActionOctokit = Octokit.plugin(
|
| 435 |
+
paginateRest,
|
| 436 |
+
throttling,
|
| 437 |
+
retry,
|
| 438 |
+
).defaults({
|
| 439 |
+
throttle: {
|
| 440 |
+
onAbuseLimit: (retryAfter, options) => {
|
| 441 |
+
/* ... */
|
| 442 |
+
},
|
| 443 |
+
onRateLimit: (retryAfter, options) => {
|
| 444 |
+
/* ... */
|
| 445 |
+
},
|
| 446 |
+
},
|
| 447 |
+
authStrategy: createActionAuth,
|
| 448 |
+
userAgent: `my-octokit-action/v1.2.3`,
|
| 449 |
+
});
|
| 450 |
+
|
| 451 |
+
const octokit = new MyActionOctokit();
|
| 452 |
+
const installations = await octokit.paginate("GET /app/installations");
|
| 453 |
+
```
|
| 454 |
+
|
| 455 |
+
## LICENSE
|
| 456 |
+
|
| 457 |
+
[MIT](LICENSE)
|
node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-src/index.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { getUserAgent } from "universal-user-agent";
|
| 2 |
+
import Hook from "before-after-hook";
|
| 3 |
+
import { request } from "@octokit/request";
|
| 4 |
+
import { withCustomRequest } from "@octokit/graphql";
|
| 5 |
+
import { createTokenAuth } from "@octokit/auth-token";
|
| 6 |
+
import { VERSION } from "./version.js";
|
| 7 |
+
const noop = () => {
|
| 8 |
+
};
|
| 9 |
+
const consoleWarn = console.warn.bind(console);
|
| 10 |
+
const consoleError = console.error.bind(console);
|
| 11 |
+
function createLogger(logger = {}) {
|
| 12 |
+
if (typeof logger.debug !== "function") {
|
| 13 |
+
logger.debug = noop;
|
| 14 |
+
}
|
| 15 |
+
if (typeof logger.info !== "function") {
|
| 16 |
+
logger.info = noop;
|
| 17 |
+
}
|
| 18 |
+
if (typeof logger.warn !== "function") {
|
| 19 |
+
logger.warn = consoleWarn;
|
| 20 |
+
}
|
| 21 |
+
if (typeof logger.error !== "function") {
|
| 22 |
+
logger.error = consoleError;
|
| 23 |
+
}
|
| 24 |
+
return logger;
|
| 25 |
+
}
|
| 26 |
+
const userAgentTrail = `octokit-core.js/${VERSION} ${getUserAgent()}`;
|
| 27 |
+
class Octokit {
|
| 28 |
+
static VERSION = VERSION;
|
| 29 |
+
static defaults(defaults) {
|
| 30 |
+
const OctokitWithDefaults = class extends this {
|
| 31 |
+
constructor(...args) {
|
| 32 |
+
const options = args[0] || {};
|
| 33 |
+
if (typeof defaults === "function") {
|
| 34 |
+
super(defaults(options));
|
| 35 |
+
return;
|
| 36 |
+
}
|
| 37 |
+
super(
|
| 38 |
+
Object.assign(
|
| 39 |
+
{},
|
| 40 |
+
defaults,
|
| 41 |
+
options,
|
| 42 |
+
options.userAgent && defaults.userAgent ? {
|
| 43 |
+
userAgent: `${options.userAgent} ${defaults.userAgent}`
|
| 44 |
+
} : null
|
| 45 |
+
)
|
| 46 |
+
);
|
| 47 |
+
}
|
| 48 |
+
};
|
| 49 |
+
return OctokitWithDefaults;
|
| 50 |
+
}
|
| 51 |
+
static plugins = [];
|
| 52 |
+
/**
|
| 53 |
+
* Attach a plugin (or many) to your Octokit instance.
|
| 54 |
+
*
|
| 55 |
+
* @example
|
| 56 |
+
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
| 57 |
+
*/
|
| 58 |
+
static plugin(...newPlugins) {
|
| 59 |
+
const currentPlugins = this.plugins;
|
| 60 |
+
const NewOctokit = class extends this {
|
| 61 |
+
static plugins = currentPlugins.concat(
|
| 62 |
+
newPlugins.filter((plugin) => !currentPlugins.includes(plugin))
|
| 63 |
+
);
|
| 64 |
+
};
|
| 65 |
+
return NewOctokit;
|
| 66 |
+
}
|
| 67 |
+
constructor(options = {}) {
|
| 68 |
+
const hook = new Hook.Collection();
|
| 69 |
+
const requestDefaults = {
|
| 70 |
+
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
| 71 |
+
headers: {},
|
| 72 |
+
request: Object.assign({}, options.request, {
|
| 73 |
+
// @ts-ignore internal usage only, no need to type
|
| 74 |
+
hook: hook.bind(null, "request")
|
| 75 |
+
}),
|
| 76 |
+
mediaType: {
|
| 77 |
+
previews: [],
|
| 78 |
+
format: ""
|
| 79 |
+
}
|
| 80 |
+
};
|
| 81 |
+
requestDefaults.headers["user-agent"] = options.userAgent ? `${options.userAgent} ${userAgentTrail}` : userAgentTrail;
|
| 82 |
+
if (options.baseUrl) {
|
| 83 |
+
requestDefaults.baseUrl = options.baseUrl;
|
| 84 |
+
}
|
| 85 |
+
if (options.previews) {
|
| 86 |
+
requestDefaults.mediaType.previews = options.previews;
|
| 87 |
+
}
|
| 88 |
+
if (options.timeZone) {
|
| 89 |
+
requestDefaults.headers["time-zone"] = options.timeZone;
|
| 90 |
+
}
|
| 91 |
+
this.request = request.defaults(requestDefaults);
|
| 92 |
+
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
| 93 |
+
this.log = createLogger(options.log);
|
| 94 |
+
this.hook = hook;
|
| 95 |
+
if (!options.authStrategy) {
|
| 96 |
+
if (!options.auth) {
|
| 97 |
+
this.auth = async () => ({
|
| 98 |
+
type: "unauthenticated"
|
| 99 |
+
});
|
| 100 |
+
} else {
|
| 101 |
+
const auth = createTokenAuth(options.auth);
|
| 102 |
+
hook.wrap("request", auth.hook);
|
| 103 |
+
this.auth = auth;
|
| 104 |
+
}
|
| 105 |
+
} else {
|
| 106 |
+
const { authStrategy, ...otherOptions } = options;
|
| 107 |
+
const auth = authStrategy(
|
| 108 |
+
Object.assign(
|
| 109 |
+
{
|
| 110 |
+
request: this.request,
|
| 111 |
+
log: this.log,
|
| 112 |
+
// we pass the current octokit instance as well as its constructor options
|
| 113 |
+
// to allow for authentication strategies that return a new octokit instance
|
| 114 |
+
// that shares the same internal state as the current one. The original
|
| 115 |
+
// requirement for this was the "event-octokit" authentication strategy
|
| 116 |
+
// of https://github.com/probot/octokit-auth-probot.
|
| 117 |
+
octokit: this,
|
| 118 |
+
octokitOptions: otherOptions
|
| 119 |
+
},
|
| 120 |
+
options.auth
|
| 121 |
+
)
|
| 122 |
+
);
|
| 123 |
+
hook.wrap("request", auth.hook);
|
| 124 |
+
this.auth = auth;
|
| 125 |
+
}
|
| 126 |
+
const classConstructor = this.constructor;
|
| 127 |
+
for (let i = 0; i < classConstructor.plugins.length; ++i) {
|
| 128 |
+
Object.assign(this, classConstructor.plugins[i](this, options));
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
// assigned during constructor
|
| 132 |
+
request;
|
| 133 |
+
graphql;
|
| 134 |
+
log;
|
| 135 |
+
hook;
|
| 136 |
+
// TODO: type `octokit.auth` based on passed options.authStrategy
|
| 137 |
+
auth;
|
| 138 |
+
}
|
| 139 |
+
export {
|
| 140 |
+
Octokit
|
| 141 |
+
};
|
node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-src/version.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const VERSION = "7.0.6";
|
| 2 |
+
export {
|
| 3 |
+
VERSION
|
| 4 |
+
};
|
node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-types/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { HookCollection } from "before-after-hook";
|
| 2 |
+
import { request } from "@octokit/request";
|
| 3 |
+
import { type graphql } from "@octokit/graphql";
|
| 4 |
+
import type { Constructor, Hooks, OctokitOptions, OctokitPlugin, ReturnTypeOf, UnionToIntersection } from "./types.js";
|
| 5 |
+
export type { OctokitOptions } from "./types.js";
|
| 6 |
+
export declare class Octokit {
|
| 7 |
+
static VERSION: string;
|
| 8 |
+
static defaults<S extends Constructor<any>>(this: S, defaults: OctokitOptions | Function): typeof this;
|
| 9 |
+
static plugins: OctokitPlugin[];
|
| 10 |
+
/**
|
| 11 |
+
* Attach a plugin (or many) to your Octokit instance.
|
| 12 |
+
*
|
| 13 |
+
* @example
|
| 14 |
+
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
| 15 |
+
*/
|
| 16 |
+
static plugin<S extends Constructor<any> & {
|
| 17 |
+
plugins: any[];
|
| 18 |
+
}, T extends OctokitPlugin[]>(this: S, ...newPlugins: T): typeof this & Constructor<UnionToIntersection<ReturnTypeOf<T>>>;
|
| 19 |
+
constructor(options?: OctokitOptions);
|
| 20 |
+
request: typeof request;
|
| 21 |
+
graphql: typeof graphql;
|
| 22 |
+
log: {
|
| 23 |
+
debug: (message: string, additionalInfo?: object) => any;
|
| 24 |
+
info: (message: string, additionalInfo?: object) => any;
|
| 25 |
+
warn: (message: string, additionalInfo?: object) => any;
|
| 26 |
+
error: (message: string, additionalInfo?: object) => any;
|
| 27 |
+
[key: string]: any;
|
| 28 |
+
};
|
| 29 |
+
hook: HookCollection<Hooks>;
|
| 30 |
+
auth: (...args: unknown[]) => Promise<unknown>;
|
| 31 |
+
}
|
node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-types/types.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type * as OctokitTypes from "@octokit/types";
|
| 2 |
+
import type { RequestError } from "@octokit/request-error";
|
| 3 |
+
import type { Octokit } from "./index.js";
|
| 4 |
+
export type RequestParameters = OctokitTypes.RequestParameters;
|
| 5 |
+
export interface OctokitOptions {
|
| 6 |
+
authStrategy?: any;
|
| 7 |
+
auth?: any;
|
| 8 |
+
userAgent?: string;
|
| 9 |
+
previews?: string[];
|
| 10 |
+
baseUrl?: string;
|
| 11 |
+
log?: {
|
| 12 |
+
debug: (message: string) => unknown;
|
| 13 |
+
info: (message: string) => unknown;
|
| 14 |
+
warn: (message: string) => unknown;
|
| 15 |
+
error: (message: string) => unknown;
|
| 16 |
+
};
|
| 17 |
+
request?: OctokitTypes.RequestRequestOptions;
|
| 18 |
+
timeZone?: string;
|
| 19 |
+
[option: string]: any;
|
| 20 |
+
}
|
| 21 |
+
export type Constructor<T> = new (...args: any[]) => T;
|
| 22 |
+
export type ReturnTypeOf<T extends AnyFunction | AnyFunction[]> = T extends AnyFunction ? ReturnType<T> : T extends AnyFunction[] ? UnionToIntersection<Exclude<ReturnType<T[number]>, void>> : never;
|
| 23 |
+
/**
|
| 24 |
+
* @author https://stackoverflow.com/users/2887218/jcalz
|
| 25 |
+
* @see https://stackoverflow.com/a/50375286/10325032
|
| 26 |
+
*/
|
| 27 |
+
export type UnionToIntersection<Union> = (Union extends any ? (argument: Union) => void : never) extends (argument: infer Intersection) => void ? Intersection : never;
|
| 28 |
+
type AnyFunction = (...args: any) => any;
|
| 29 |
+
export type OctokitPlugin = (octokit: Octokit, options: OctokitOptions) => {
|
| 30 |
+
[key: string]: any;
|
| 31 |
+
} | void;
|
| 32 |
+
export type Hooks = {
|
| 33 |
+
request: {
|
| 34 |
+
Options: Required<OctokitTypes.EndpointDefaults>;
|
| 35 |
+
Result: OctokitTypes.OctokitResponse<any>;
|
| 36 |
+
Error: RequestError | Error;
|
| 37 |
+
};
|
| 38 |
+
[key: string]: {
|
| 39 |
+
Options: unknown;
|
| 40 |
+
Result: unknown;
|
| 41 |
+
Error: unknown;
|
| 42 |
+
};
|
| 43 |
+
};
|
| 44 |
+
export type StrictOmit<T, K extends keyof T> = {
|
| 45 |
+
[P in keyof T as P extends K ? never : P]: T[P];
|
| 46 |
+
} & {
|
| 47 |
+
[parameter: string]: unknown;
|
| 48 |
+
};
|
| 49 |
+
export {};
|
node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/dist-types/version.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export declare const VERSION = "7.0.6";
|
node_modules/.pnpm/@octokit+core@7.0.6/node_modules/@octokit/core/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@octokit/core",
|
| 3 |
+
"version": "7.0.6",
|
| 4 |
+
"publishConfig": {
|
| 5 |
+
"access": "public",
|
| 6 |
+
"provenance": true
|
| 7 |
+
},
|
| 8 |
+
"type": "module",
|
| 9 |
+
"description": "Extendable client for GitHub's REST & GraphQL APIs",
|
| 10 |
+
"repository": "github:octokit/core.js",
|
| 11 |
+
"keywords": [
|
| 12 |
+
"octokit",
|
| 13 |
+
"github",
|
| 14 |
+
"api",
|
| 15 |
+
"sdk",
|
| 16 |
+
"toolkit"
|
| 17 |
+
],
|
| 18 |
+
"author": "Gregor Martynus (https://github.com/gr2m)",
|
| 19 |
+
"license": "MIT",
|
| 20 |
+
"dependencies": {
|
| 21 |
+
"@octokit/auth-token": "^6.0.0",
|
| 22 |
+
"@octokit/graphql": "^9.0.3",
|
| 23 |
+
"@octokit/request": "^10.0.6",
|
| 24 |
+
"@octokit/request-error": "^7.0.2",
|
| 25 |
+
"@octokit/types": "^16.0.0",
|
| 26 |
+
"before-after-hook": "^4.0.0",
|
| 27 |
+
"universal-user-agent": "^7.0.0"
|
| 28 |
+
},
|
| 29 |
+
"devDependencies": {
|
| 30 |
+
"@octokit/auth-action": "^6.0.1",
|
| 31 |
+
"@octokit/auth-app": "^8.0.0",
|
| 32 |
+
"@octokit/auth-oauth-app": "^9.0.0",
|
| 33 |
+
"@octokit/tsconfig": "^4.0.0",
|
| 34 |
+
"@sinonjs/fake-timers": "^15.0.0",
|
| 35 |
+
"@types/lolex": "^5.1.0",
|
| 36 |
+
"@types/node": "^22.0.0",
|
| 37 |
+
"@types/sinonjs__fake-timers": "^15.0.0",
|
| 38 |
+
"@vitest/coverage-v8": "^3.0.5",
|
| 39 |
+
"esbuild": "^0.25.0",
|
| 40 |
+
"fetch-mock": "^12.0.0",
|
| 41 |
+
"prettier": "3.6.2",
|
| 42 |
+
"proxy": "^2.0.0",
|
| 43 |
+
"semantic-release-plugin-update-version-in-files": "^2.0.0",
|
| 44 |
+
"typescript": "^5.0.0",
|
| 45 |
+
"undici": "^7.0.0",
|
| 46 |
+
"vitest": "^3.0.5"
|
| 47 |
+
},
|
| 48 |
+
"engines": {
|
| 49 |
+
"node": ">= 20"
|
| 50 |
+
},
|
| 51 |
+
"files": [
|
| 52 |
+
"dist-*/**",
|
| 53 |
+
"bin/**"
|
| 54 |
+
],
|
| 55 |
+
"types": "./dist-types/index.d.ts",
|
| 56 |
+
"exports": {
|
| 57 |
+
".": {
|
| 58 |
+
"types": "./dist-types/index.d.ts",
|
| 59 |
+
"import": "./dist-src/index.js",
|
| 60 |
+
"default": "./dist-src/index.js"
|
| 61 |
+
},
|
| 62 |
+
"./types": {
|
| 63 |
+
"types": "./dist-types/types.d.ts"
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"sideEffects": false
|
| 67 |
+
}
|
node_modules/.pnpm/@octokit+endpoint@11.0.2/node_modules/@octokit/endpoint/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018 Octokit contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in
|
| 13 |
+
all copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 21 |
+
THE SOFTWARE.
|
node_modules/.pnpm/@octokit+endpoint@11.0.2/node_modules/@octokit/endpoint/README.md
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# endpoint.js
|
| 2 |
+
|
| 3 |
+
> Turns GitHub REST API endpoints into generic request options
|
| 4 |
+
|
| 5 |
+
[](https://www.npmjs.com/package/@octokit/endpoint)
|
| 6 |
+
[](https://github.com/octokit/endpoint.js/actions/workflows/test.yml?query=branch%3Amain)
|
| 7 |
+
|
| 8 |
+
`@octokit/endpoint` combines [GitHub REST API routes](https://developer.github.com/v3/) with your parameters and turns them into generic request options that can be used in any request library.
|
| 9 |
+
|
| 10 |
+
<!-- update table of contents by running `npx markdown-toc README.md -i` -->
|
| 11 |
+
|
| 12 |
+
<!-- toc -->
|
| 13 |
+
|
| 14 |
+
- [Usage](#usage)
|
| 15 |
+
- [API](#api)
|
| 16 |
+
- [`endpoint(route, options)` or `endpoint(options)`](#endpointroute-options-or-endpointoptions)
|
| 17 |
+
- [`endpoint.defaults()`](#endpointdefaults)
|
| 18 |
+
- [`endpoint.DEFAULTS`](#endpointdefaults)
|
| 19 |
+
- [`endpoint.merge(route, options)` or `endpoint.merge(options)`](#endpointmergeroute-options-or-endpointmergeoptions)
|
| 20 |
+
- [`endpoint.parse()`](#endpointparse)
|
| 21 |
+
- [Special cases](#special-cases)
|
| 22 |
+
- [The `data` parameter – set request body directly](#the-data-parameter-%E2%80%93-set-request-body-directly)
|
| 23 |
+
- [Set parameters for both the URL/query and the request body](#set-parameters-for-both-the-urlquery-and-the-request-body)
|
| 24 |
+
- [LICENSE](#license)
|
| 25 |
+
|
| 26 |
+
<!-- tocstop -->
|
| 27 |
+
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
<table>
|
| 31 |
+
<tbody valign=top align=left>
|
| 32 |
+
<tr><th>
|
| 33 |
+
Browsers
|
| 34 |
+
</th><td width=100%>
|
| 35 |
+
Load <code>@octokit/endpoint</code> directly from <a href="https://esm.sh">esm.sh</a>
|
| 36 |
+
|
| 37 |
+
```html
|
| 38 |
+
<script type="module">
|
| 39 |
+
import { endpoint } from "https://esm.sh/@octokit/endpoint";
|
| 40 |
+
</script>
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
</td></tr>
|
| 44 |
+
<tr><th>
|
| 45 |
+
Node
|
| 46 |
+
</th><td>
|
| 47 |
+
|
| 48 |
+
Install with <code>npm install @octokit/endpoint</code>
|
| 49 |
+
|
| 50 |
+
```js
|
| 51 |
+
import { endpoint } from "@octokit/endpoint";
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
</td></tr>
|
| 55 |
+
</tbody>
|
| 56 |
+
</table>
|
| 57 |
+
|
| 58 |
+
Example for [List organization repositories](https://developer.github.com/v3/repos/#list-organization-repositories)
|
| 59 |
+
|
| 60 |
+
```js
|
| 61 |
+
const requestOptions = endpoint("GET /orgs/{org}/repos", {
|
| 62 |
+
headers: {
|
| 63 |
+
authorization: "token 0000000000000000000000000000000000000001",
|
| 64 |
+
},
|
| 65 |
+
org: "octokit",
|
| 66 |
+
type: "private",
|
| 67 |
+
});
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
The resulting `requestOptions` looks as follows
|
| 71 |
+
|
| 72 |
+
```json
|
| 73 |
+
{
|
| 74 |
+
"method": "GET",
|
| 75 |
+
"url": "https://api.github.com/orgs/octokit/repos?type=private",
|
| 76 |
+
"headers": {
|
| 77 |
+
"accept": "application/vnd.github.v3+json",
|
| 78 |
+
"authorization": "token 0000000000000000000000000000000000000001",
|
| 79 |
+
"user-agent": "octokit/endpoint.js v1.2.3"
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
You can pass `requestOptions` to common request libraries
|
| 85 |
+
|
| 86 |
+
```js
|
| 87 |
+
const { url, ...options } = requestOptions;
|
| 88 |
+
// using with fetch (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
| 89 |
+
fetch(url, options);
|
| 90 |
+
// using with request (https://github.com/request/request)
|
| 91 |
+
request(requestOptions);
|
| 92 |
+
// using with got (https://github.com/sindresorhus/got)
|
| 93 |
+
got[options.method](url, options);
|
| 94 |
+
// using with axios
|
| 95 |
+
axios(requestOptions);
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
> [!IMPORTANT]
|
| 99 |
+
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json`. See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).
|
| 100 |
+
|
| 101 |
+
## API
|
| 102 |
+
|
| 103 |
+
### `endpoint(route, options)` or `endpoint(options)`
|
| 104 |
+
|
| 105 |
+
<table>
|
| 106 |
+
<thead align=left>
|
| 107 |
+
<tr>
|
| 108 |
+
<th>
|
| 109 |
+
name
|
| 110 |
+
</th>
|
| 111 |
+
<th>
|
| 112 |
+
type
|
| 113 |
+
</th>
|
| 114 |
+
<th width=100%>
|
| 115 |
+
description
|
| 116 |
+
</th>
|
| 117 |
+
</tr>
|
| 118 |
+
</thead>
|
| 119 |
+
<tbody align=left valign=top>
|
| 120 |
+
<tr>
|
| 121 |
+
<th>
|
| 122 |
+
<code>route</code>
|
| 123 |
+
</th>
|
| 124 |
+
<td>
|
| 125 |
+
String
|
| 126 |
+
</td>
|
| 127 |
+
<td>
|
| 128 |
+
If set, it has to be a string consisting of URL and the request method, e.g., <code>GET /orgs/{org}</code>. If it’s set to a URL, only the method defaults to <code>GET</code>.
|
| 129 |
+
</td>
|
| 130 |
+
</tr>
|
| 131 |
+
<tr>
|
| 132 |
+
<th>
|
| 133 |
+
<code>options.method</code>
|
| 134 |
+
</th>
|
| 135 |
+
<td>
|
| 136 |
+
String
|
| 137 |
+
</td>
|
| 138 |
+
<td>
|
| 139 |
+
<strong>Required unless <code>route</code> is set.</strong> Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>. <em>Defaults to <code>GET</code></em>.
|
| 140 |
+
</td>
|
| 141 |
+
</tr>
|
| 142 |
+
<tr>
|
| 143 |
+
<th>
|
| 144 |
+
<code>options.url</code>
|
| 145 |
+
</th>
|
| 146 |
+
<td>
|
| 147 |
+
String
|
| 148 |
+
</td>
|
| 149 |
+
<td>
|
| 150 |
+
<strong>Required unless <code>route</code> is set.</strong> A path or full URL which may contain <code>:variable</code> or <code>{variable}</code> placeholders,
|
| 151 |
+
e.g., <code>/orgs/{org}/repos</code>. The <code>url</code> is parsed using <a href="https://github.com/bramstein/url-template">url-template</a>.
|
| 152 |
+
</td>
|
| 153 |
+
</tr>
|
| 154 |
+
<tr>
|
| 155 |
+
<th>
|
| 156 |
+
<code>options.baseUrl</code>
|
| 157 |
+
</th>
|
| 158 |
+
<td>
|
| 159 |
+
String
|
| 160 |
+
</td>
|
| 161 |
+
<td>
|
| 162 |
+
<em>Defaults to <code>https://api.github.com</code></em>.
|
| 163 |
+
</td>
|
| 164 |
+
</tr>
|
| 165 |
+
<tr>
|
| 166 |
+
<th>
|
| 167 |
+
<code>options.headers</code>
|
| 168 |
+
</th>
|
| 169 |
+
<td>
|
| 170 |
+
Object
|
| 171 |
+
</td>
|
| 172 |
+
<td>
|
| 173 |
+
Custom headers. Passed headers are merged with defaults:<br>
|
| 174 |
+
<em><code>headers['user-agent']</code> defaults to <code>octokit-endpoint.js/1.2.3</code> (where <code>1.2.3</code> is the released version)</em>.<br>
|
| 175 |
+
<em><code>headers['accept']</code> defaults to <code>application/vnd.github.v3+json</code></em>.<br>
|
| 176 |
+
</td>
|
| 177 |
+
</tr>
|
| 178 |
+
<tr>
|
| 179 |
+
<th>
|
| 180 |
+
<code>options.mediaType.format</code>
|
| 181 |
+
</th>
|
| 182 |
+
<td>
|
| 183 |
+
String
|
| 184 |
+
</td>
|
| 185 |
+
<td>
|
| 186 |
+
Media type param, such as <code>raw</code>, <code>diff</code>, or <code>text+json</code>. See <a href="https://developer.github.com/v3/media/">Media Types</a>. Setting <code>options.mediaType.format</code> will amend the <code>headers.accept</code> value.
|
| 187 |
+
</td>
|
| 188 |
+
</tr>
|
| 189 |
+
<tr>
|
| 190 |
+
<th>
|
| 191 |
+
<code>options.data</code>
|
| 192 |
+
</th>
|
| 193 |
+
<td>
|
| 194 |
+
Any
|
| 195 |
+
</td>
|
| 196 |
+
<td>
|
| 197 |
+
Set request body directly instead of setting it to JSON based on additional parameters. See <a href="#data-parameter">"The <code>data</code> parameter"</a> below.
|
| 198 |
+
</td>
|
| 199 |
+
</tr>
|
| 200 |
+
<tr>
|
| 201 |
+
<th>
|
| 202 |
+
<code>options.request</code>
|
| 203 |
+
</th>
|
| 204 |
+
<td>
|
| 205 |
+
Object
|
| 206 |
+
</td>
|
| 207 |
+
<td>
|
| 208 |
+
Pass custom meta information for the request. The <code>request</code> object will be returned as is.
|
| 209 |
+
</td>
|
| 210 |
+
</tr>
|
| 211 |
+
</tbody>
|
| 212 |
+
</table>
|
| 213 |
+
|
| 214 |
+
All other options will be passed depending on the `method` and `url` options.
|
| 215 |
+
|
| 216 |
+
1. If the option key has a placeholder in the `url`, it will be used as the replacement. For example, if the passed options are `{url: '/orgs/{org}/repos', org: 'foo'}` the returned `options.url` is `https://api.github.com/orgs/foo/repos`.
|
| 217 |
+
2. If the `method` is `GET` or `HEAD`, the option is passed as a query parameter.
|
| 218 |
+
3. Otherwise, the parameter is passed in the request body as a JSON key.
|
| 219 |
+
|
| 220 |
+
**Result**
|
| 221 |
+
|
| 222 |
+
`endpoint()` is a synchronous method and returns an object with the following keys:
|
| 223 |
+
|
| 224 |
+
<table>
|
| 225 |
+
<thead align=left>
|
| 226 |
+
<tr>
|
| 227 |
+
<th>
|
| 228 |
+
key
|
| 229 |
+
</th>
|
| 230 |
+
<th>
|
| 231 |
+
type
|
| 232 |
+
</th>
|
| 233 |
+
<th width=100%>
|
| 234 |
+
description
|
| 235 |
+
</th>
|
| 236 |
+
</tr>
|
| 237 |
+
</thead>
|
| 238 |
+
<tbody align=left valign=top>
|
| 239 |
+
<tr>
|
| 240 |
+
<th><code>method</code></th>
|
| 241 |
+
<td>String</td>
|
| 242 |
+
<td>The http method. Always lowercase.</td>
|
| 243 |
+
</tr>
|
| 244 |
+
<tr>
|
| 245 |
+
<th><code>url</code></th>
|
| 246 |
+
<td>String</td>
|
| 247 |
+
<td>The url with placeholders replaced with passed parameters.</td>
|
| 248 |
+
</tr>
|
| 249 |
+
<tr>
|
| 250 |
+
<th><code>headers</code></th>
|
| 251 |
+
<td>Object</td>
|
| 252 |
+
<td>All header names are lowercased.</td>
|
| 253 |
+
</tr>
|
| 254 |
+
<tr>
|
| 255 |
+
<th><code>body</code></th>
|
| 256 |
+
<td>Any</td>
|
| 257 |
+
<td>The request body if one is present. Only for <code>PATCH</code>, <code>POST</code>, <code>PUT</code>, <code>DELETE</code> requests.</td>
|
| 258 |
+
</tr>
|
| 259 |
+
<tr>
|
| 260 |
+
<th><code>request</code></th>
|
| 261 |
+
<td>Object</td>
|
| 262 |
+
<td>Request meta option, it will be returned as it was passed into <code>endpoint()</code></td>
|
| 263 |
+
</tr>
|
| 264 |
+
</tbody>
|
| 265 |
+
</table>
|
| 266 |
+
|
| 267 |
+
### `endpoint.defaults()`
|
| 268 |
+
|
| 269 |
+
Override or set default options. Example:
|
| 270 |
+
|
| 271 |
+
```js
|
| 272 |
+
const request = require("request");
|
| 273 |
+
const myEndpoint = require("@octokit/endpoint").defaults({
|
| 274 |
+
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
| 275 |
+
headers: {
|
| 276 |
+
"user-agent": "myApp/1.2.3",
|
| 277 |
+
authorization: `token 0000000000000000000000000000000000000001`,
|
| 278 |
+
},
|
| 279 |
+
org: "my-project",
|
| 280 |
+
per_page: 100,
|
| 281 |
+
});
|
| 282 |
+
|
| 283 |
+
request(myEndpoint(`GET /orgs/{org}/repos`));
|
| 284 |
+
```
|
| 285 |
+
|
| 286 |
+
You can call `.defaults()` again on the returned method, the defaults will cascade.
|
| 287 |
+
|
| 288 |
+
```js
|
| 289 |
+
const myProjectEndpoint = endpoint.defaults({
|
| 290 |
+
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
| 291 |
+
headers: {
|
| 292 |
+
"user-agent": "myApp/1.2.3",
|
| 293 |
+
},
|
| 294 |
+
org: "my-project",
|
| 295 |
+
});
|
| 296 |
+
const myProjectEndpointWithAuth = myProjectEndpoint.defaults({
|
| 297 |
+
headers: {
|
| 298 |
+
authorization: `token 0000000000000000000000000000000000000001`,
|
| 299 |
+
},
|
| 300 |
+
});
|
| 301 |
+
```
|
| 302 |
+
|
| 303 |
+
`myProjectEndpointWithAuth` now defaults the `baseUrl`, `headers['user-agent']`,
|
| 304 |
+
`org` and `headers['authorization']` on top of `headers['accept']` that is set
|
| 305 |
+
by the global default.
|
| 306 |
+
|
| 307 |
+
### `endpoint.DEFAULTS`
|
| 308 |
+
|
| 309 |
+
The current default options.
|
| 310 |
+
|
| 311 |
+
```js
|
| 312 |
+
endpoint.DEFAULTS.baseUrl; // https://api.github.com
|
| 313 |
+
const myEndpoint = endpoint.defaults({
|
| 314 |
+
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
| 315 |
+
});
|
| 316 |
+
myEndpoint.DEFAULTS.baseUrl; // https://github-enterprise.acme-inc.com/api/v3
|
| 317 |
+
```
|
| 318 |
+
|
| 319 |
+
### `endpoint.merge(route, options)` or `endpoint.merge(options)`
|
| 320 |
+
|
| 321 |
+
Get the defaulted endpoint options, but without parsing them into request options:
|
| 322 |
+
|
| 323 |
+
```js
|
| 324 |
+
const myProjectEndpoint = endpoint.defaults({
|
| 325 |
+
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
| 326 |
+
headers: {
|
| 327 |
+
"user-agent": "myApp/1.2.3",
|
| 328 |
+
},
|
| 329 |
+
org: "my-project",
|
| 330 |
+
});
|
| 331 |
+
myProjectEndpoint.merge("GET /orgs/{org}/repos", {
|
| 332 |
+
headers: {
|
| 333 |
+
authorization: `token 0000000000000000000000000000000000000001`,
|
| 334 |
+
},
|
| 335 |
+
org: "my-secret-project",
|
| 336 |
+
type: "private",
|
| 337 |
+
});
|
| 338 |
+
|
| 339 |
+
// {
|
| 340 |
+
// baseUrl: 'https://github-enterprise.acme-inc.com/api/v3',
|
| 341 |
+
// method: 'GET',
|
| 342 |
+
// url: '/orgs/{org}/repos',
|
| 343 |
+
// headers: {
|
| 344 |
+
// accept: 'application/vnd.github.v3+json',
|
| 345 |
+
// authorization: `token 0000000000000000000000000000000000000001`,
|
| 346 |
+
// 'user-agent': 'myApp/1.2.3'
|
| 347 |
+
// },
|
| 348 |
+
// org: 'my-secret-project',
|
| 349 |
+
// type: 'private'
|
| 350 |
+
// }
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
### `endpoint.parse()`
|
| 354 |
+
|
| 355 |
+
Stateless method to turn endpoint options into request options. Calling
|
| 356 |
+
`endpoint(options)` is the same as calling `endpoint.parse(endpoint.merge(options))`.
|
| 357 |
+
|
| 358 |
+
## Special cases
|
| 359 |
+
|
| 360 |
+
<a name="data-parameter"></a>
|
| 361 |
+
|
| 362 |
+
### The `data` parameter – set request body directly
|
| 363 |
+
|
| 364 |
+
Some endpoints such as [Render a Markdown document in raw mode](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode) don’t have parameters that are sent as request body keys, instead, the request body needs to be set directly. In these cases, set the `data` parameter.
|
| 365 |
+
|
| 366 |
+
```js
|
| 367 |
+
const options = endpoint("POST /markdown/raw", {
|
| 368 |
+
data: "Hello world github/linguist#1 **cool**, and #1!",
|
| 369 |
+
headers: {
|
| 370 |
+
accept: "text/html;charset=utf-8",
|
| 371 |
+
"content-type": "text/plain",
|
| 372 |
+
},
|
| 373 |
+
});
|
| 374 |
+
|
| 375 |
+
// options is
|
| 376 |
+
// {
|
| 377 |
+
// method: 'post',
|
| 378 |
+
// url: 'https://api.github.com/markdown/raw',
|
| 379 |
+
// headers: {
|
| 380 |
+
// accept: 'text/html;charset=utf-8',
|
| 381 |
+
// 'content-type': 'text/plain',
|
| 382 |
+
// 'user-agent': userAgent
|
| 383 |
+
// },
|
| 384 |
+
// body: 'Hello world github/linguist#1 **cool**, and #1!'
|
| 385 |
+
// }
|
| 386 |
+
```
|
| 387 |
+
|
| 388 |
+
### Set parameters for both the URL/query and the request body
|
| 389 |
+
|
| 390 |
+
There are API endpoints that accept both query parameters as well as a body. In that case, you need to add the query parameters as templates to `options.url`, as defined in the [RFC 6570 URI Template specification](https://tools.ietf.org/html/rfc6570).
|
| 391 |
+
|
| 392 |
+
Example
|
| 393 |
+
|
| 394 |
+
```js
|
| 395 |
+
endpoint(
|
| 396 |
+
"POST https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}",
|
| 397 |
+
{
|
| 398 |
+
name: "example.zip",
|
| 399 |
+
label: "short description",
|
| 400 |
+
headers: {
|
| 401 |
+
"content-type": "text/plain",
|
| 402 |
+
"content-length": 14,
|
| 403 |
+
authorization: `token 0000000000000000000000000000000000000001`,
|
| 404 |
+
},
|
| 405 |
+
data: "Hello, world!",
|
| 406 |
+
},
|
| 407 |
+
);
|
| 408 |
+
```
|
| 409 |
+
|
| 410 |
+
## LICENSE
|
| 411 |
+
|
| 412 |
+
[MIT](LICENSE)
|