First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

9
node_modules/@octokit/auth-oauth-user/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) 2021 Octokit contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1038
node_modules/@octokit/auth-oauth-user/README.md generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,208 @@
// pkg/dist-src/index.js
import { getUserAgent } from "universal-user-agent";
import { request as octokitRequest } from "@octokit/request";
// pkg/dist-src/version.js
var VERSION = "0.0.0-development";
// pkg/dist-src/get-authentication.js
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
import { exchangeWebFlowCode } from "@octokit/oauth-methods";
async function getAuthentication(state) {
if ("code" in state.strategyOptions) {
const { authentication } = await exchangeWebFlowCode({
clientId: state.clientId,
clientSecret: state.clientSecret,
clientType: state.clientType,
onTokenCreated: state.onTokenCreated,
...state.strategyOptions,
request: state.request
});
return {
type: "token",
tokenType: "oauth",
...authentication
};
}
if ("onVerification" in state.strategyOptions) {
const deviceAuth = createOAuthDeviceAuth({
clientType: state.clientType,
clientId: state.clientId,
onTokenCreated: state.onTokenCreated,
...state.strategyOptions,
request: state.request
});
const authentication = await deviceAuth({
type: "oauth"
});
return {
clientSecret: state.clientSecret,
...authentication
};
}
if ("token" in state.strategyOptions) {
return {
type: "token",
tokenType: "oauth",
clientId: state.clientId,
clientSecret: state.clientSecret,
clientType: state.clientType,
onTokenCreated: state.onTokenCreated,
...state.strategyOptions
};
}
throw new Error("[@octokit/auth-oauth-user] Invalid strategy options");
}
// pkg/dist-src/auth.js
import {
checkToken,
deleteAuthorization,
deleteToken,
refreshToken,
resetToken
} from "@octokit/oauth-methods";
async function auth(state, options = {}) {
if (!state.authentication) {
state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state);
}
if (state.authentication.invalid) {
throw new Error("[@octokit/auth-oauth-user] Token is invalid");
}
const currentAuthentication = state.authentication;
if ("expiresAt" in currentAuthentication) {
if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ new Date()) {
const { authentication } = await refreshToken({
clientType: "github-app",
clientId: state.clientId,
clientSecret: state.clientSecret,
refreshToken: currentAuthentication.refreshToken,
request: state.request
});
state.authentication = {
tokenType: "oauth",
type: "token",
...authentication
};
}
}
if (options.type === "refresh") {
if (state.clientType === "oauth-app") {
throw new Error(
"[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens"
);
}
if (!currentAuthentication.hasOwnProperty("expiresAt")) {
throw new Error("[@octokit/auth-oauth-user] Refresh token missing");
}
await state.onTokenCreated?.(state.authentication, {
type: options.type
});
}
if (options.type === "check" || options.type === "reset") {
const method = options.type === "check" ? checkToken : resetToken;
try {
const { authentication } = await method({
// @ts-expect-error making TS happy would require unnecessary code so no
clientType: state.clientType,
clientId: state.clientId,
clientSecret: state.clientSecret,
token: state.authentication.token,
request: state.request
});
state.authentication = {
tokenType: "oauth",
type: "token",
// @ts-expect-error TBD
...authentication
};
if (options.type === "reset") {
await state.onTokenCreated?.(state.authentication, {
type: options.type
});
}
return state.authentication;
} catch (error) {
if (error.status === 404) {
error.message = "[@octokit/auth-oauth-user] Token is invalid";
state.authentication.invalid = true;
}
throw error;
}
}
if (options.type === "delete" || options.type === "deleteAuthorization") {
const method = options.type === "delete" ? deleteToken : deleteAuthorization;
try {
await method({
// @ts-expect-error making TS happy would require unnecessary code so no
clientType: state.clientType,
clientId: state.clientId,
clientSecret: state.clientSecret,
token: state.authentication.token,
request: state.request
});
} catch (error) {
if (error.status !== 404) throw error;
}
state.authentication.invalid = true;
return state.authentication;
}
return state.authentication;
}
// pkg/dist-src/requires-basic-auth.js
var ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/;
function requiresBasicAuth(url) {
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);
}
// pkg/dist-src/hook.js
async function hook(state, request, route, parameters = {}) {
const endpoint = request.endpoint.merge(
route,
parameters
);
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
return request(endpoint);
}
if (requiresBasicAuth(endpoint.url)) {
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
endpoint.headers.authorization = `basic ${credentials}`;
return request(endpoint);
}
const { token } = state.clientType === "oauth-app" ? await auth({ ...state, request }) : await auth({ ...state, request });
endpoint.headers.authorization = "token " + token;
return request(endpoint);
}
// pkg/dist-src/index.js
function createOAuthUserAuth({
clientId,
clientSecret,
clientType = "oauth-app",
request = octokitRequest.defaults({
headers: {
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`
}
}),
onTokenCreated,
...strategyOptions
}) {
const state = Object.assign({
clientType,
clientId,
clientSecret,
onTokenCreated,
strategyOptions,
request
});
return Object.assign(auth.bind(null, state), {
// @ts-expect-error not worth the extra code needed to appease TS
hook: hook.bind(null, state)
});
}
createOAuthUserAuth.VERSION = VERSION;
export {
createOAuthUserAuth,
requiresBasicAuth
};

File diff suppressed because one or more lines are too long

98
node_modules/@octokit/auth-oauth-user/dist-src/auth.js generated vendored Normal file
View File

@@ -0,0 +1,98 @@
import { getAuthentication } from "./get-authentication.js";
import {
checkToken,
deleteAuthorization,
deleteToken,
refreshToken,
resetToken
} from "@octokit/oauth-methods";
async function auth(state, options = {}) {
if (!state.authentication) {
state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state);
}
if (state.authentication.invalid) {
throw new Error("[@octokit/auth-oauth-user] Token is invalid");
}
const currentAuthentication = state.authentication;
if ("expiresAt" in currentAuthentication) {
if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ new Date()) {
const { authentication } = await refreshToken({
clientType: "github-app",
clientId: state.clientId,
clientSecret: state.clientSecret,
refreshToken: currentAuthentication.refreshToken,
request: state.request
});
state.authentication = {
tokenType: "oauth",
type: "token",
...authentication
};
}
}
if (options.type === "refresh") {
if (state.clientType === "oauth-app") {
throw new Error(
"[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens"
);
}
if (!currentAuthentication.hasOwnProperty("expiresAt")) {
throw new Error("[@octokit/auth-oauth-user] Refresh token missing");
}
await state.onTokenCreated?.(state.authentication, {
type: options.type
});
}
if (options.type === "check" || options.type === "reset") {
const method = options.type === "check" ? checkToken : resetToken;
try {
const { authentication } = await method({
// @ts-expect-error making TS happy would require unnecessary code so no
clientType: state.clientType,
clientId: state.clientId,
clientSecret: state.clientSecret,
token: state.authentication.token,
request: state.request
});
state.authentication = {
tokenType: "oauth",
type: "token",
// @ts-expect-error TBD
...authentication
};
if (options.type === "reset") {
await state.onTokenCreated?.(state.authentication, {
type: options.type
});
}
return state.authentication;
} catch (error) {
if (error.status === 404) {
error.message = "[@octokit/auth-oauth-user] Token is invalid";
state.authentication.invalid = true;
}
throw error;
}
}
if (options.type === "delete" || options.type === "deleteAuthorization") {
const method = options.type === "delete" ? deleteToken : deleteAuthorization;
try {
await method({
// @ts-expect-error making TS happy would require unnecessary code so no
clientType: state.clientType,
clientId: state.clientId,
clientSecret: state.clientSecret,
token: state.authentication.token,
request: state.request
});
} catch (error) {
if (error.status !== 404) throw error;
}
state.authentication.invalid = true;
return state.authentication;
}
return state.authentication;
}
export {
auth
};

View File

@@ -0,0 +1,50 @@
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
import { exchangeWebFlowCode } from "@octokit/oauth-methods";
async function getAuthentication(state) {
if ("code" in state.strategyOptions) {
const { authentication } = await exchangeWebFlowCode({
clientId: state.clientId,
clientSecret: state.clientSecret,
clientType: state.clientType,
onTokenCreated: state.onTokenCreated,
...state.strategyOptions,
request: state.request
});
return {
type: "token",
tokenType: "oauth",
...authentication
};
}
if ("onVerification" in state.strategyOptions) {
const deviceAuth = createOAuthDeviceAuth({
clientType: state.clientType,
clientId: state.clientId,
onTokenCreated: state.onTokenCreated,
...state.strategyOptions,
request: state.request
});
const authentication = await deviceAuth({
type: "oauth"
});
return {
clientSecret: state.clientSecret,
...authentication
};
}
if ("token" in state.strategyOptions) {
return {
type: "token",
tokenType: "oauth",
clientId: state.clientId,
clientSecret: state.clientSecret,
clientType: state.clientType,
onTokenCreated: state.onTokenCreated,
...state.strategyOptions
};
}
throw new Error("[@octokit/auth-oauth-user] Invalid strategy options");
}
export {
getAuthentication
};

22
node_modules/@octokit/auth-oauth-user/dist-src/hook.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import { auth } from "./auth.js";
import { requiresBasicAuth } from "./requires-basic-auth.js";
async function hook(state, request, route, parameters = {}) {
const endpoint = request.endpoint.merge(
route,
parameters
);
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
return request(endpoint);
}
if (requiresBasicAuth(endpoint.url)) {
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
endpoint.headers.authorization = `basic ${credentials}`;
return request(endpoint);
}
const { token } = state.clientType === "oauth-app" ? await auth({ ...state, request }) : await auth({ ...state, request });
endpoint.headers.authorization = "token " + token;
return request(endpoint);
}
export {
hook
};

View File

@@ -0,0 +1,36 @@
import { getUserAgent } from "universal-user-agent";
import { request as octokitRequest } from "@octokit/request";
import { VERSION } from "./version.js";
import { auth } from "./auth.js";
import { hook } from "./hook.js";
import { requiresBasicAuth } from "./requires-basic-auth.js";
function createOAuthUserAuth({
clientId,
clientSecret,
clientType = "oauth-app",
request = octokitRequest.defaults({
headers: {
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`
}
}),
onTokenCreated,
...strategyOptions
}) {
const state = Object.assign({
clientType,
clientId,
clientSecret,
onTokenCreated,
strategyOptions,
request
});
return Object.assign(auth.bind(null, state), {
// @ts-expect-error not worth the extra code needed to appease TS
hook: hook.bind(null, state)
});
}
createOAuthUserAuth.VERSION = VERSION;
export {
createOAuthUserAuth,
requiresBasicAuth
};

View File

@@ -0,0 +1,7 @@
const ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/;
function requiresBasicAuth(url) {
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);
}
export {
requiresBasicAuth
};

View File

@@ -0,0 +1,4 @@
const VERSION = "6.0.2";
export {
VERSION
};

View File

@@ -0,0 +1,3 @@
import type { OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, OAuthAppState, GitHubAppState } from "./types.js";
export declare function auth(state: OAuthAppState, options?: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
export declare function auth(state: GitHubAppState, options?: GitHubAppAuthOptions): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;

View File

@@ -0,0 +1,3 @@
import type { OAuthAppState, GitHubAppState, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration } from "./types.js";
export declare function getAuthentication(state: OAuthAppState): Promise<OAuthAppAuthentication>;
export declare function getAuthentication(state: GitHubAppState): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;

View File

@@ -0,0 +1,6 @@
import type { EndpointOptions, OctokitResponse, RequestInterface, RequestParameters, Route } from "@octokit/types";
import type { OAuthAppState, GitHubAppState } from "./types.js";
type AnyResponse = OctokitResponse<any>;
export declare function hook(state: OAuthAppState, request: RequestInterface, route: Route | EndpointOptions, parameters: RequestParameters): Promise<AnyResponse>;
export declare function hook(state: GitHubAppState, request: RequestInterface, route: Route | EndpointOptions, parameters: RequestParameters): Promise<AnyResponse>;
export {};

View File

@@ -0,0 +1,8 @@
import type { OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthInterface, GitHubAppAuthInterface } from "./types.js";
export type { OAuthAppStrategyOptionsWebFlow, GitHubAppStrategyOptionsWebFlow, OAuthAppStrategyOptionsDeviceFlow, GitHubAppStrategyOptionsDeviceFlow, OAuthAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsExistingAuthentication, GitHubAppStrategyOptionsExistingAuthenticationWithExpiration, OAuthAppStrategyOptions, GitHubAppStrategyOptions, OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, } from "./types.js";
export { requiresBasicAuth } from "./requires-basic-auth.js";
export declare function createOAuthUserAuth(options: OAuthAppStrategyOptions): OAuthAppAuthInterface;
export declare function createOAuthUserAuth(options: GitHubAppStrategyOptions): GitHubAppAuthInterface;
export declare namespace createOAuthUserAuth {
var VERSION: string;
}

View File

@@ -0,0 +1 @@
export declare function requiresBasicAuth(url: string | undefined): boolean | "" | undefined;

View File

@@ -0,0 +1,114 @@
import type * as OctokitTypes from "@octokit/types";
import type * as DeviceTypes from "@octokit/auth-oauth-device";
import type * as OAuthMethodsTypes from "@octokit/oauth-methods";
export type ClientType = "oauth-app" | "github-app";
export type WebFlowOptions = {
code: string;
state?: string;
redirectUrl?: string;
};
type CommonAppStrategyOptions = {
clientType?: ClientType;
clientId: string;
clientSecret: string;
request?: OctokitTypes.RequestInterface;
onTokenCreated?: OnTokenCreatedCallback;
};
type CommonOAuthAppStrategyOptions = {
clientType?: "oauth-app";
} & CommonAppStrategyOptions;
type CommonGitHubAppStrategyOptions = {
clientType?: "github-app";
} & CommonAppStrategyOptions;
type OAuthAppDeviceFlowOptions = {
onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"];
scopes?: string[];
};
type GitHubDeviceFlowOptions = {
onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"];
};
type ExistingOAuthAppAuthenticationOptions = {
clientType: "oauth-app";
token: string;
scopes: string[];
};
type ExistingGitHubAppAuthenticationOptions = {
token: string;
};
type ExistingGitHubAppAuthenticationWithExpirationOptions = {
token: string;
refreshToken: string;
expiresAt: string;
refreshTokenExpiresAt: string;
};
export type OAuthAppStrategyOptionsWebFlow = CommonOAuthAppStrategyOptions & WebFlowOptions;
export type GitHubAppStrategyOptionsWebFlow = CommonGitHubAppStrategyOptions & WebFlowOptions;
export type OAuthAppStrategyOptionsDeviceFlow = CommonOAuthAppStrategyOptions & OAuthAppDeviceFlowOptions;
export type GitHubAppStrategyOptionsDeviceFlow = CommonGitHubAppStrategyOptions & GitHubDeviceFlowOptions;
export type OAuthAppStrategyOptionsExistingAuthentication = CommonOAuthAppStrategyOptions & ExistingOAuthAppAuthenticationOptions;
export type GitHubAppStrategyOptionsExistingAuthentication = CommonGitHubAppStrategyOptions & ExistingGitHubAppAuthenticationOptions;
export type GitHubAppStrategyOptionsExistingAuthenticationWithExpiration = CommonGitHubAppStrategyOptions & ExistingGitHubAppAuthenticationWithExpirationOptions;
export type OAuthAppStrategyOptions = OAuthAppStrategyOptionsWebFlow | OAuthAppStrategyOptionsDeviceFlow | OAuthAppStrategyOptionsExistingAuthentication;
export type GitHubAppStrategyOptions = GitHubAppStrategyOptionsWebFlow | GitHubAppStrategyOptionsDeviceFlow | GitHubAppStrategyOptionsExistingAuthentication | GitHubAppStrategyOptionsExistingAuthenticationWithExpiration;
export type OAuthAppAuthentication = {
tokenType: "oauth";
type: "token";
} & OAuthMethodsTypes.OAuthAppAuthentication;
export type GitHubAppAuthentication = {
tokenType: "oauth";
type: "token";
} & OAuthMethodsTypes.GitHubAppAuthentication;
export type GitHubAppAuthenticationWithExpiration = {
tokenType: "oauth";
type: "token";
} & OAuthMethodsTypes.GitHubAppAuthenticationWithExpiration;
export interface OAuthAppAuthInterface {
(options?: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
hook(request: OctokitTypes.RequestInterface, route: OctokitTypes.Route | OctokitTypes.EndpointOptions, parameters?: OctokitTypes.RequestParameters): Promise<OctokitTypes.OctokitResponse<any>>;
}
export interface GitHubAppAuthInterface {
(options?: GitHubAppAuthOptions): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;
hook(request: OctokitTypes.RequestInterface, route: OctokitTypes.Route | OctokitTypes.EndpointOptions, parameters?: OctokitTypes.RequestParameters): Promise<OctokitTypes.OctokitResponse<any>>;
}
type OnTokenCreatedCallback = (authentication: OAuthAppAuthentication | GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration | undefined, options: OAuthAppAuthOptions | GitHubAppAuthOptions) => void | Promise<void>;
export type OAuthAppState = {
clientId: string;
clientSecret: string;
clientType: "oauth-app";
request: OctokitTypes.RequestInterface;
onTokenCreated?: CommonAppStrategyOptions["onTokenCreated"];
strategyOptions: WebFlowOptions | OAuthAppDeviceFlowOptions | ExistingOAuthAppAuthenticationOptions;
authentication?: OAuthAppAuthentication & {
invalid?: true;
};
};
type GitHubAppStateAuthentication = GitHubAppAuthentication & {
invalid?: true;
};
type GitHubAppStateAuthenticationWIthExpiration = GitHubAppAuthenticationWithExpiration & {
invalid?: true;
};
export type GitHubAppState = {
clientId: string;
clientSecret: string;
clientType: "github-app";
request: OctokitTypes.RequestInterface;
onTokenCreated?: CommonAppStrategyOptions["onTokenCreated"];
strategyOptions: WebFlowOptions | GitHubDeviceFlowOptions | ExistingGitHubAppAuthenticationOptions | ExistingGitHubAppAuthenticationWithExpirationOptions;
authentication?: GitHubAppStateAuthentication | GitHubAppStateAuthenticationWIthExpiration;
};
export type State = OAuthAppState | GitHubAppState;
export type WebFlowState = {
clientId: string;
clientSecret: string;
clientType: ClientType;
request: OctokitTypes.RequestInterface;
strategyOptions: WebFlowOptions;
};
export type OAuthAppAuthOptions = {
type?: "get" | "check" | "reset" | "delete" | "deleteAuthorization";
};
export type GitHubAppAuthOptions = {
type?: "get" | "check" | "reset" | "refresh" | "delete" | "deleteAuthorization";
};
export {};

View File

@@ -0,0 +1 @@
export declare const VERSION = "6.0.2";

56
node_modules/@octokit/auth-oauth-user/package.json generated vendored Normal file
View File

@@ -0,0 +1,56 @@
{
"name": "@octokit/auth-oauth-user",
"publishConfig": {
"access": "public",
"provenance": true
},
"type": "module",
"version": "6.0.2",
"description": "Octokit authentication strategy for OAuth clients",
"repository": "https://github.com/octokit/auth-oauth-user.js",
"keywords": [
"github",
"api",
"sdk",
"toolkit"
],
"author": "Gregor Martynus (https://dev.to/gr2m)",
"license": "MIT",
"dependencies": {
"@octokit/auth-oauth-device": "^8.0.3",
"@octokit/oauth-methods": "^6.0.2",
"@octokit/request": "^10.0.6",
"@octokit/types": "^16.0.0",
"universal-user-agent": "^7.0.0"
},
"devDependencies": {
"@octokit/core": "^7.0.6",
"@octokit/tsconfig": "^4.0.0",
"@types/node": "^24.0.0",
"@vitest/coverage-v8": "^3.0.0",
"esbuild": "^0.25.0",
"fetch-mock": "^11.0.0",
"glob": "^11.0.0",
"mockdate": "^3.0.4",
"prettier": "3.6.2",
"semantic-release-plugin-update-version-in-files": "^2.0.0",
"typescript": "^5.0.0",
"vitest": "^3.0.0"
},
"engines": {
"node": ">= 20"
},
"files": [
"dist-*/**",
"bin/**"
],
"types": "./dist-types/index.d.ts",
"exports": {
".": {
"types": "./dist-types/index.d.ts",
"import": "./dist-bundle/index.js",
"default": "./dist-bundle/index.js"
}
},
"sideEffects": false
}