@depup/octokit__auth-oauth-user 6.0.2-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +32 -0
- package/changes.json +14 -0
- package/dist-bundle/index.js +208 -0
- package/dist-bundle/index.js.map +7 -0
- package/dist-src/auth.js +98 -0
- package/dist-src/get-authentication.js +50 -0
- package/dist-src/hook.js +22 -0
- package/dist-src/index.js +36 -0
- package/dist-src/requires-basic-auth.js +7 -0
- package/dist-src/version.js +4 -0
- package/dist-types/auth.d.ts +3 -0
- package/dist-types/get-authentication.d.ts +3 -0
- package/dist-types/hook.d.ts +6 -0
- package/dist-types/index.d.ts +8 -0
- package/dist-types/requires-basic-auth.d.ts +1 -0
- package/dist-types/types.d.ts +114 -0
- package/dist-types/version.d.ts +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Octokit contributors
|
|
4
|
+
|
|
5
|
+
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:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @depup/octokit__auth-oauth-user
|
|
2
|
+
|
|
3
|
+
> Dependency-bumped version of [@octokit/auth-oauth-user](https://www.npmjs.com/package/@octokit/auth-oauth-user)
|
|
4
|
+
|
|
5
|
+
Generated by [DepUp](https://github.com/depup/npm) -- all production
|
|
6
|
+
dependencies bumped to latest versions.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @depup/octokit__auth-oauth-user
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Field | Value |
|
|
15
|
+
|-------|-------|
|
|
16
|
+
| Original | [@octokit/auth-oauth-user](https://www.npmjs.com/package/@octokit/auth-oauth-user) @ 6.0.2 |
|
|
17
|
+
| Processed | 2026-03-17 |
|
|
18
|
+
| Smoke test | passed |
|
|
19
|
+
| Deps updated | 2 |
|
|
20
|
+
|
|
21
|
+
## Dependency Changes
|
|
22
|
+
|
|
23
|
+
| Dependency | From | To |
|
|
24
|
+
|------------|------|-----|
|
|
25
|
+
| @octokit/request | ^10.0.6 | ^10.0.8 |
|
|
26
|
+
| universal-user-agent | ^7.0.0 | ^7.0.3 |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/@octokit/auth-oauth-user
|
|
31
|
+
|
|
32
|
+
License inherited from the original package.
|
package/changes.json
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// pkg/dist-src/index.js
|
|
2
|
+
import { getUserAgent } from "universal-user-agent";
|
|
3
|
+
import { request as octokitRequest } from "@octokit/request";
|
|
4
|
+
|
|
5
|
+
// pkg/dist-src/version.js
|
|
6
|
+
var VERSION = "0.0.0-development";
|
|
7
|
+
|
|
8
|
+
// pkg/dist-src/get-authentication.js
|
|
9
|
+
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
|
10
|
+
import { exchangeWebFlowCode } from "@octokit/oauth-methods";
|
|
11
|
+
async function getAuthentication(state) {
|
|
12
|
+
if ("code" in state.strategyOptions) {
|
|
13
|
+
const { authentication } = await exchangeWebFlowCode({
|
|
14
|
+
clientId: state.clientId,
|
|
15
|
+
clientSecret: state.clientSecret,
|
|
16
|
+
clientType: state.clientType,
|
|
17
|
+
onTokenCreated: state.onTokenCreated,
|
|
18
|
+
...state.strategyOptions,
|
|
19
|
+
request: state.request
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
type: "token",
|
|
23
|
+
tokenType: "oauth",
|
|
24
|
+
...authentication
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if ("onVerification" in state.strategyOptions) {
|
|
28
|
+
const deviceAuth = createOAuthDeviceAuth({
|
|
29
|
+
clientType: state.clientType,
|
|
30
|
+
clientId: state.clientId,
|
|
31
|
+
onTokenCreated: state.onTokenCreated,
|
|
32
|
+
...state.strategyOptions,
|
|
33
|
+
request: state.request
|
|
34
|
+
});
|
|
35
|
+
const authentication = await deviceAuth({
|
|
36
|
+
type: "oauth"
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
clientSecret: state.clientSecret,
|
|
40
|
+
...authentication
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if ("token" in state.strategyOptions) {
|
|
44
|
+
return {
|
|
45
|
+
type: "token",
|
|
46
|
+
tokenType: "oauth",
|
|
47
|
+
clientId: state.clientId,
|
|
48
|
+
clientSecret: state.clientSecret,
|
|
49
|
+
clientType: state.clientType,
|
|
50
|
+
onTokenCreated: state.onTokenCreated,
|
|
51
|
+
...state.strategyOptions
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
throw new Error("[@octokit/auth-oauth-user] Invalid strategy options");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// pkg/dist-src/auth.js
|
|
58
|
+
import {
|
|
59
|
+
checkToken,
|
|
60
|
+
deleteAuthorization,
|
|
61
|
+
deleteToken,
|
|
62
|
+
refreshToken,
|
|
63
|
+
resetToken
|
|
64
|
+
} from "@octokit/oauth-methods";
|
|
65
|
+
async function auth(state, options = {}) {
|
|
66
|
+
if (!state.authentication) {
|
|
67
|
+
state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state);
|
|
68
|
+
}
|
|
69
|
+
if (state.authentication.invalid) {
|
|
70
|
+
throw new Error("[@octokit/auth-oauth-user] Token is invalid");
|
|
71
|
+
}
|
|
72
|
+
const currentAuthentication = state.authentication;
|
|
73
|
+
if ("expiresAt" in currentAuthentication) {
|
|
74
|
+
if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ new Date()) {
|
|
75
|
+
const { authentication } = await refreshToken({
|
|
76
|
+
clientType: "github-app",
|
|
77
|
+
clientId: state.clientId,
|
|
78
|
+
clientSecret: state.clientSecret,
|
|
79
|
+
refreshToken: currentAuthentication.refreshToken,
|
|
80
|
+
request: state.request
|
|
81
|
+
});
|
|
82
|
+
state.authentication = {
|
|
83
|
+
tokenType: "oauth",
|
|
84
|
+
type: "token",
|
|
85
|
+
...authentication
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (options.type === "refresh") {
|
|
90
|
+
if (state.clientType === "oauth-app") {
|
|
91
|
+
throw new Error(
|
|
92
|
+
"[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens"
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
if (!currentAuthentication.hasOwnProperty("expiresAt")) {
|
|
96
|
+
throw new Error("[@octokit/auth-oauth-user] Refresh token missing");
|
|
97
|
+
}
|
|
98
|
+
await state.onTokenCreated?.(state.authentication, {
|
|
99
|
+
type: options.type
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (options.type === "check" || options.type === "reset") {
|
|
103
|
+
const method = options.type === "check" ? checkToken : resetToken;
|
|
104
|
+
try {
|
|
105
|
+
const { authentication } = await method({
|
|
106
|
+
// @ts-expect-error making TS happy would require unnecessary code so no
|
|
107
|
+
clientType: state.clientType,
|
|
108
|
+
clientId: state.clientId,
|
|
109
|
+
clientSecret: state.clientSecret,
|
|
110
|
+
token: state.authentication.token,
|
|
111
|
+
request: state.request
|
|
112
|
+
});
|
|
113
|
+
state.authentication = {
|
|
114
|
+
tokenType: "oauth",
|
|
115
|
+
type: "token",
|
|
116
|
+
// @ts-expect-error TBD
|
|
117
|
+
...authentication
|
|
118
|
+
};
|
|
119
|
+
if (options.type === "reset") {
|
|
120
|
+
await state.onTokenCreated?.(state.authentication, {
|
|
121
|
+
type: options.type
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return state.authentication;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (error.status === 404) {
|
|
127
|
+
error.message = "[@octokit/auth-oauth-user] Token is invalid";
|
|
128
|
+
state.authentication.invalid = true;
|
|
129
|
+
}
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (options.type === "delete" || options.type === "deleteAuthorization") {
|
|
134
|
+
const method = options.type === "delete" ? deleteToken : deleteAuthorization;
|
|
135
|
+
try {
|
|
136
|
+
await method({
|
|
137
|
+
// @ts-expect-error making TS happy would require unnecessary code so no
|
|
138
|
+
clientType: state.clientType,
|
|
139
|
+
clientId: state.clientId,
|
|
140
|
+
clientSecret: state.clientSecret,
|
|
141
|
+
token: state.authentication.token,
|
|
142
|
+
request: state.request
|
|
143
|
+
});
|
|
144
|
+
} catch (error) {
|
|
145
|
+
if (error.status !== 404) throw error;
|
|
146
|
+
}
|
|
147
|
+
state.authentication.invalid = true;
|
|
148
|
+
return state.authentication;
|
|
149
|
+
}
|
|
150
|
+
return state.authentication;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// pkg/dist-src/requires-basic-auth.js
|
|
154
|
+
var ROUTES_REQUIRING_BASIC_AUTH = /\/applications\/[^/]+\/(token|grant)s?/;
|
|
155
|
+
function requiresBasicAuth(url) {
|
|
156
|
+
return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// pkg/dist-src/hook.js
|
|
160
|
+
async function hook(state, request, route, parameters = {}) {
|
|
161
|
+
const endpoint = request.endpoint.merge(
|
|
162
|
+
route,
|
|
163
|
+
parameters
|
|
164
|
+
);
|
|
165
|
+
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
|
166
|
+
return request(endpoint);
|
|
167
|
+
}
|
|
168
|
+
if (requiresBasicAuth(endpoint.url)) {
|
|
169
|
+
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
|
170
|
+
endpoint.headers.authorization = `basic ${credentials}`;
|
|
171
|
+
return request(endpoint);
|
|
172
|
+
}
|
|
173
|
+
const { token } = state.clientType === "oauth-app" ? await auth({ ...state, request }) : await auth({ ...state, request });
|
|
174
|
+
endpoint.headers.authorization = "token " + token;
|
|
175
|
+
return request(endpoint);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// pkg/dist-src/index.js
|
|
179
|
+
function createOAuthUserAuth({
|
|
180
|
+
clientId,
|
|
181
|
+
clientSecret,
|
|
182
|
+
clientType = "oauth-app",
|
|
183
|
+
request = octokitRequest.defaults({
|
|
184
|
+
headers: {
|
|
185
|
+
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
188
|
+
onTokenCreated,
|
|
189
|
+
...strategyOptions
|
|
190
|
+
}) {
|
|
191
|
+
const state = Object.assign({
|
|
192
|
+
clientType,
|
|
193
|
+
clientId,
|
|
194
|
+
clientSecret,
|
|
195
|
+
onTokenCreated,
|
|
196
|
+
strategyOptions,
|
|
197
|
+
request
|
|
198
|
+
});
|
|
199
|
+
return Object.assign(auth.bind(null, state), {
|
|
200
|
+
// @ts-expect-error not worth the extra code needed to appease TS
|
|
201
|
+
hook: hook.bind(null, state)
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
createOAuthUserAuth.VERSION = VERSION;
|
|
205
|
+
export {
|
|
206
|
+
createOAuthUserAuth,
|
|
207
|
+
requiresBasicAuth
|
|
208
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../dist-src/index.js", "../dist-src/version.js", "../dist-src/get-authentication.js", "../dist-src/auth.js", "../dist-src/requires-basic-auth.js", "../dist-src/hook.js"],
|
|
4
|
+
"sourcesContent": ["import { getUserAgent } from \"universal-user-agent\";\nimport { request as octokitRequest } from \"@octokit/request\";\nimport { VERSION } from \"./version.js\";\nimport { auth } from \"./auth.js\";\nimport { hook } from \"./hook.js\";\nimport { requiresBasicAuth } from \"./requires-basic-auth.js\";\nfunction createOAuthUserAuth({\n clientId,\n clientSecret,\n clientType = \"oauth-app\",\n request = octokitRequest.defaults({\n headers: {\n \"user-agent\": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`\n }\n }),\n onTokenCreated,\n ...strategyOptions\n}) {\n const state = Object.assign({\n clientType,\n clientId,\n clientSecret,\n onTokenCreated,\n strategyOptions,\n request\n });\n return Object.assign(auth.bind(null, state), {\n // @ts-expect-error not worth the extra code needed to appease TS\n hook: hook.bind(null, state)\n });\n}\ncreateOAuthUserAuth.VERSION = VERSION;\nexport {\n createOAuthUserAuth,\n requiresBasicAuth\n};\n", "const VERSION = \"0.0.0-development\";\nexport {\n VERSION\n};\n", "import { createOAuthDeviceAuth } from \"@octokit/auth-oauth-device\";\nimport { exchangeWebFlowCode } from \"@octokit/oauth-methods\";\nasync function getAuthentication(state) {\n if (\"code\" in state.strategyOptions) {\n const { authentication } = await exchangeWebFlowCode({\n clientId: state.clientId,\n clientSecret: state.clientSecret,\n clientType: state.clientType,\n onTokenCreated: state.onTokenCreated,\n ...state.strategyOptions,\n request: state.request\n });\n return {\n type: \"token\",\n tokenType: \"oauth\",\n ...authentication\n };\n }\n if (\"onVerification\" in state.strategyOptions) {\n const deviceAuth = createOAuthDeviceAuth({\n clientType: state.clientType,\n clientId: state.clientId,\n onTokenCreated: state.onTokenCreated,\n ...state.strategyOptions,\n request: state.request\n });\n const authentication = await deviceAuth({\n type: \"oauth\"\n });\n return {\n clientSecret: state.clientSecret,\n ...authentication\n };\n }\n if (\"token\" in state.strategyOptions) {\n return {\n type: \"token\",\n tokenType: \"oauth\",\n clientId: state.clientId,\n clientSecret: state.clientSecret,\n clientType: state.clientType,\n onTokenCreated: state.onTokenCreated,\n ...state.strategyOptions\n };\n }\n throw new Error(\"[@octokit/auth-oauth-user] Invalid strategy options\");\n}\nexport {\n getAuthentication\n};\n", "import { getAuthentication } from \"./get-authentication.js\";\nimport {\n checkToken,\n deleteAuthorization,\n deleteToken,\n refreshToken,\n resetToken\n} from \"@octokit/oauth-methods\";\nasync function auth(state, options = {}) {\n if (!state.authentication) {\n state.authentication = state.clientType === \"oauth-app\" ? await getAuthentication(state) : await getAuthentication(state);\n }\n if (state.authentication.invalid) {\n throw new Error(\"[@octokit/auth-oauth-user] Token is invalid\");\n }\n const currentAuthentication = state.authentication;\n if (\"expiresAt\" in currentAuthentication) {\n if (options.type === \"refresh\" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ new Date()) {\n const { authentication } = await refreshToken({\n clientType: \"github-app\",\n clientId: state.clientId,\n clientSecret: state.clientSecret,\n refreshToken: currentAuthentication.refreshToken,\n request: state.request\n });\n state.authentication = {\n tokenType: \"oauth\",\n type: \"token\",\n ...authentication\n };\n }\n }\n if (options.type === \"refresh\") {\n if (state.clientType === \"oauth-app\") {\n throw new Error(\n \"[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens\"\n );\n }\n if (!currentAuthentication.hasOwnProperty(\"expiresAt\")) {\n throw new Error(\"[@octokit/auth-oauth-user] Refresh token missing\");\n }\n await state.onTokenCreated?.(state.authentication, {\n type: options.type\n });\n }\n if (options.type === \"check\" || options.type === \"reset\") {\n const method = options.type === \"check\" ? checkToken : resetToken;\n try {\n const { authentication } = await method({\n // @ts-expect-error making TS happy would require unnecessary code so no\n clientType: state.clientType,\n clientId: state.clientId,\n clientSecret: state.clientSecret,\n token: state.authentication.token,\n request: state.request\n });\n state.authentication = {\n tokenType: \"oauth\",\n type: \"token\",\n // @ts-expect-error TBD\n ...authentication\n };\n if (options.type === \"reset\") {\n await state.onTokenCreated?.(state.authentication, {\n type: options.type\n });\n }\n return state.authentication;\n } catch (error) {\n if (error.status === 404) {\n error.message = \"[@octokit/auth-oauth-user] Token is invalid\";\n state.authentication.invalid = true;\n }\n throw error;\n }\n }\n if (options.type === \"delete\" || options.type === \"deleteAuthorization\") {\n const method = options.type === \"delete\" ? deleteToken : deleteAuthorization;\n try {\n await method({\n // @ts-expect-error making TS happy would require unnecessary code so no\n clientType: state.clientType,\n clientId: state.clientId,\n clientSecret: state.clientSecret,\n token: state.authentication.token,\n request: state.request\n });\n } catch (error) {\n if (error.status !== 404) throw error;\n }\n state.authentication.invalid = true;\n return state.authentication;\n }\n return state.authentication;\n}\nexport {\n auth\n};\n", "const ROUTES_REQUIRING_BASIC_AUTH = /\\/applications\\/[^/]+\\/(token|grant)s?/;\nfunction requiresBasicAuth(url) {\n return url && ROUTES_REQUIRING_BASIC_AUTH.test(url);\n}\nexport {\n requiresBasicAuth\n};\n", "import { auth } from \"./auth.js\";\nimport { requiresBasicAuth } from \"./requires-basic-auth.js\";\nasync function hook(state, request, route, parameters = {}) {\n const endpoint = request.endpoint.merge(\n route,\n parameters\n );\n if (/\\/login\\/(oauth\\/access_token|device\\/code)$/.test(endpoint.url)) {\n return request(endpoint);\n }\n if (requiresBasicAuth(endpoint.url)) {\n const credentials = btoa(`${state.clientId}:${state.clientSecret}`);\n endpoint.headers.authorization = `basic ${credentials}`;\n return request(endpoint);\n }\n const { token } = state.clientType === \"oauth-app\" ? await auth({ ...state, request }) : await auth({ ...state, request });\n endpoint.headers.authorization = \"token \" + token;\n return request(endpoint);\n}\nexport {\n hook\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist-src/auth.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { getAuthentication } from "./get-authentication.js";
|
|
2
|
+
import {
|
|
3
|
+
checkToken,
|
|
4
|
+
deleteAuthorization,
|
|
5
|
+
deleteToken,
|
|
6
|
+
refreshToken,
|
|
7
|
+
resetToken
|
|
8
|
+
} from "@octokit/oauth-methods";
|
|
9
|
+
async function auth(state, options = {}) {
|
|
10
|
+
if (!state.authentication) {
|
|
11
|
+
state.authentication = state.clientType === "oauth-app" ? await getAuthentication(state) : await getAuthentication(state);
|
|
12
|
+
}
|
|
13
|
+
if (state.authentication.invalid) {
|
|
14
|
+
throw new Error("[@octokit/auth-oauth-user] Token is invalid");
|
|
15
|
+
}
|
|
16
|
+
const currentAuthentication = state.authentication;
|
|
17
|
+
if ("expiresAt" in currentAuthentication) {
|
|
18
|
+
if (options.type === "refresh" || new Date(currentAuthentication.expiresAt) < /* @__PURE__ */ new Date()) {
|
|
19
|
+
const { authentication } = await refreshToken({
|
|
20
|
+
clientType: "github-app",
|
|
21
|
+
clientId: state.clientId,
|
|
22
|
+
clientSecret: state.clientSecret,
|
|
23
|
+
refreshToken: currentAuthentication.refreshToken,
|
|
24
|
+
request: state.request
|
|
25
|
+
});
|
|
26
|
+
state.authentication = {
|
|
27
|
+
tokenType: "oauth",
|
|
28
|
+
type: "token",
|
|
29
|
+
...authentication
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (options.type === "refresh") {
|
|
34
|
+
if (state.clientType === "oauth-app") {
|
|
35
|
+
throw new Error(
|
|
36
|
+
"[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens"
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (!currentAuthentication.hasOwnProperty("expiresAt")) {
|
|
40
|
+
throw new Error("[@octokit/auth-oauth-user] Refresh token missing");
|
|
41
|
+
}
|
|
42
|
+
await state.onTokenCreated?.(state.authentication, {
|
|
43
|
+
type: options.type
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (options.type === "check" || options.type === "reset") {
|
|
47
|
+
const method = options.type === "check" ? checkToken : resetToken;
|
|
48
|
+
try {
|
|
49
|
+
const { authentication } = await method({
|
|
50
|
+
// @ts-expect-error making TS happy would require unnecessary code so no
|
|
51
|
+
clientType: state.clientType,
|
|
52
|
+
clientId: state.clientId,
|
|
53
|
+
clientSecret: state.clientSecret,
|
|
54
|
+
token: state.authentication.token,
|
|
55
|
+
request: state.request
|
|
56
|
+
});
|
|
57
|
+
state.authentication = {
|
|
58
|
+
tokenType: "oauth",
|
|
59
|
+
type: "token",
|
|
60
|
+
// @ts-expect-error TBD
|
|
61
|
+
...authentication
|
|
62
|
+
};
|
|
63
|
+
if (options.type === "reset") {
|
|
64
|
+
await state.onTokenCreated?.(state.authentication, {
|
|
65
|
+
type: options.type
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return state.authentication;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error.status === 404) {
|
|
71
|
+
error.message = "[@octokit/auth-oauth-user] Token is invalid";
|
|
72
|
+
state.authentication.invalid = true;
|
|
73
|
+
}
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (options.type === "delete" || options.type === "deleteAuthorization") {
|
|
78
|
+
const method = options.type === "delete" ? deleteToken : deleteAuthorization;
|
|
79
|
+
try {
|
|
80
|
+
await method({
|
|
81
|
+
// @ts-expect-error making TS happy would require unnecessary code so no
|
|
82
|
+
clientType: state.clientType,
|
|
83
|
+
clientId: state.clientId,
|
|
84
|
+
clientSecret: state.clientSecret,
|
|
85
|
+
token: state.authentication.token,
|
|
86
|
+
request: state.request
|
|
87
|
+
});
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error.status !== 404) throw error;
|
|
90
|
+
}
|
|
91
|
+
state.authentication.invalid = true;
|
|
92
|
+
return state.authentication;
|
|
93
|
+
}
|
|
94
|
+
return state.authentication;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
auth
|
|
98
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
|
2
|
+
import { exchangeWebFlowCode } from "@octokit/oauth-methods";
|
|
3
|
+
async function getAuthentication(state) {
|
|
4
|
+
if ("code" in state.strategyOptions) {
|
|
5
|
+
const { authentication } = await exchangeWebFlowCode({
|
|
6
|
+
clientId: state.clientId,
|
|
7
|
+
clientSecret: state.clientSecret,
|
|
8
|
+
clientType: state.clientType,
|
|
9
|
+
onTokenCreated: state.onTokenCreated,
|
|
10
|
+
...state.strategyOptions,
|
|
11
|
+
request: state.request
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
type: "token",
|
|
15
|
+
tokenType: "oauth",
|
|
16
|
+
...authentication
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if ("onVerification" in state.strategyOptions) {
|
|
20
|
+
const deviceAuth = createOAuthDeviceAuth({
|
|
21
|
+
clientType: state.clientType,
|
|
22
|
+
clientId: state.clientId,
|
|
23
|
+
onTokenCreated: state.onTokenCreated,
|
|
24
|
+
...state.strategyOptions,
|
|
25
|
+
request: state.request
|
|
26
|
+
});
|
|
27
|
+
const authentication = await deviceAuth({
|
|
28
|
+
type: "oauth"
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
clientSecret: state.clientSecret,
|
|
32
|
+
...authentication
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if ("token" in state.strategyOptions) {
|
|
36
|
+
return {
|
|
37
|
+
type: "token",
|
|
38
|
+
tokenType: "oauth",
|
|
39
|
+
clientId: state.clientId,
|
|
40
|
+
clientSecret: state.clientSecret,
|
|
41
|
+
clientType: state.clientType,
|
|
42
|
+
onTokenCreated: state.onTokenCreated,
|
|
43
|
+
...state.strategyOptions
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
throw new Error("[@octokit/auth-oauth-user] Invalid strategy options");
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
getAuthentication
|
|
50
|
+
};
|
package/dist-src/hook.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { auth } from "./auth.js";
|
|
2
|
+
import { requiresBasicAuth } from "./requires-basic-auth.js";
|
|
3
|
+
async function hook(state, request, route, parameters = {}) {
|
|
4
|
+
const endpoint = request.endpoint.merge(
|
|
5
|
+
route,
|
|
6
|
+
parameters
|
|
7
|
+
);
|
|
8
|
+
if (/\/login\/(oauth\/access_token|device\/code)$/.test(endpoint.url)) {
|
|
9
|
+
return request(endpoint);
|
|
10
|
+
}
|
|
11
|
+
if (requiresBasicAuth(endpoint.url)) {
|
|
12
|
+
const credentials = btoa(`${state.clientId}:${state.clientSecret}`);
|
|
13
|
+
endpoint.headers.authorization = `basic ${credentials}`;
|
|
14
|
+
return request(endpoint);
|
|
15
|
+
}
|
|
16
|
+
const { token } = state.clientType === "oauth-app" ? await auth({ ...state, request }) : await auth({ ...state, request });
|
|
17
|
+
endpoint.headers.authorization = "token " + token;
|
|
18
|
+
return request(endpoint);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
hook
|
|
22
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getUserAgent } from "universal-user-agent";
|
|
2
|
+
import { request as octokitRequest } from "@octokit/request";
|
|
3
|
+
import { VERSION } from "./version.js";
|
|
4
|
+
import { auth } from "./auth.js";
|
|
5
|
+
import { hook } from "./hook.js";
|
|
6
|
+
import { requiresBasicAuth } from "./requires-basic-auth.js";
|
|
7
|
+
function createOAuthUserAuth({
|
|
8
|
+
clientId,
|
|
9
|
+
clientSecret,
|
|
10
|
+
clientType = "oauth-app",
|
|
11
|
+
request = octokitRequest.defaults({
|
|
12
|
+
headers: {
|
|
13
|
+
"user-agent": `octokit-auth-oauth-app.js/${VERSION} ${getUserAgent()}`
|
|
14
|
+
}
|
|
15
|
+
}),
|
|
16
|
+
onTokenCreated,
|
|
17
|
+
...strategyOptions
|
|
18
|
+
}) {
|
|
19
|
+
const state = Object.assign({
|
|
20
|
+
clientType,
|
|
21
|
+
clientId,
|
|
22
|
+
clientSecret,
|
|
23
|
+
onTokenCreated,
|
|
24
|
+
strategyOptions,
|
|
25
|
+
request
|
|
26
|
+
});
|
|
27
|
+
return Object.assign(auth.bind(null, state), {
|
|
28
|
+
// @ts-expect-error not worth the extra code needed to appease TS
|
|
29
|
+
hook: hook.bind(null, state)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
createOAuthUserAuth.VERSION = VERSION;
|
|
33
|
+
export {
|
|
34
|
+
createOAuthUserAuth,
|
|
35
|
+
requiresBasicAuth
|
|
36
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { OAuthAppAuthOptions, GitHubAppAuthOptions, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, OAuthAppState, GitHubAppState } from "./types.js";
|
|
2
|
+
export declare function auth(state: OAuthAppState, options?: OAuthAppAuthOptions): Promise<OAuthAppAuthentication>;
|
|
3
|
+
export declare function auth(state: GitHubAppState, options?: GitHubAppAuthOptions): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { OAuthAppState, GitHubAppState, OAuthAppAuthentication, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration } from "./types.js";
|
|
2
|
+
export declare function getAuthentication(state: OAuthAppState): Promise<OAuthAppAuthentication>;
|
|
3
|
+
export declare function getAuthentication(state: GitHubAppState): Promise<GitHubAppAuthentication | GitHubAppAuthenticationWithExpiration>;
|
|
@@ -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 {};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function requiresBasicAuth(url: string | undefined): boolean | "" | undefined;
|
|
@@ -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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "6.0.2";
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depup/octokit__auth-oauth-user",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "6.0.2-depup.0",
|
|
5
|
+
"description": "[DepUp] Octokit authentication strategy for OAuth clients",
|
|
6
|
+
"repository": "https://github.com/octokit/auth-oauth-user.js",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"depup",
|
|
9
|
+
"dependency-bumped",
|
|
10
|
+
"updated-deps",
|
|
11
|
+
"@octokit/auth-oauth-user",
|
|
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.8",
|
|
23
|
+
"@octokit/types": "^16.0.0",
|
|
24
|
+
"universal-user-agent": "^7.0.3"
|
|
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
|
+
"changes.json",
|
|
47
|
+
"README.md"
|
|
48
|
+
],
|
|
49
|
+
"types": "./dist-types/index.d.ts",
|
|
50
|
+
"exports": {
|
|
51
|
+
".": {
|
|
52
|
+
"types": "./dist-types/index.d.ts",
|
|
53
|
+
"import": "./dist-bundle/index.js",
|
|
54
|
+
"default": "./dist-bundle/index.js"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"sideEffects": false,
|
|
58
|
+
"depup": {
|
|
59
|
+
"changes": {
|
|
60
|
+
"@octokit/request": {
|
|
61
|
+
"from": "^10.0.6",
|
|
62
|
+
"to": "^10.0.8"
|
|
63
|
+
},
|
|
64
|
+
"universal-user-agent": {
|
|
65
|
+
"from": "^7.0.0",
|
|
66
|
+
"to": "^7.0.3"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"depsUpdated": 2,
|
|
70
|
+
"originalPackage": "@octokit/auth-oauth-user",
|
|
71
|
+
"originalVersion": "6.0.2",
|
|
72
|
+
"processedAt": "2026-03-17T16:32:28.758Z",
|
|
73
|
+
"smokeTest": "passed"
|
|
74
|
+
}
|
|
75
|
+
}
|