@depup/octokit__oauth-methods 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 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__oauth-methods
2
+
3
+ > Dependency-bumped version of [@octokit/oauth-methods](https://www.npmjs.com/package/@octokit/oauth-methods)
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__oauth-methods
12
+ ```
13
+
14
+ | Field | Value |
15
+ |-------|-------|
16
+ | Original | [@octokit/oauth-methods](https://www.npmjs.com/package/@octokit/oauth-methods) @ 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
+ | @octokit/request-error | ^7.0.2 | ^7.1.0 |
27
+
28
+ ---
29
+
30
+ Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/@octokit/oauth-methods
31
+
32
+ License inherited from the original package.
package/changes.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "bumped": {
3
+ "@octokit/request": {
4
+ "from": "^10.0.6",
5
+ "to": "^10.0.8"
6
+ },
7
+ "@octokit/request-error": {
8
+ "from": "^7.0.2",
9
+ "to": "^7.1.0"
10
+ }
11
+ },
12
+ "timestamp": "2026-03-17T16:33:28.229Z",
13
+ "totalUpdated": 2
14
+ }
@@ -0,0 +1,317 @@
1
+ // pkg/dist-src/version.js
2
+ var VERSION = "0.0.0-development";
3
+
4
+ // pkg/dist-src/get-web-flow-authorization-url.js
5
+ import { oauthAuthorizationUrl } from "@octokit/oauth-authorization-url";
6
+ import { request as defaultRequest } from "@octokit/request";
7
+
8
+ // pkg/dist-src/utils.js
9
+ import { RequestError } from "@octokit/request-error";
10
+ function requestToOAuthBaseUrl(request) {
11
+ const endpointDefaults = request.endpoint.DEFAULTS;
12
+ return /^https:\/\/(api\.)?github\.com$/.test(endpointDefaults.baseUrl) ? "https://github.com" : endpointDefaults.baseUrl.replace("/api/v3", "");
13
+ }
14
+ async function oauthRequest(request, route, parameters) {
15
+ const withOAuthParameters = {
16
+ baseUrl: requestToOAuthBaseUrl(request),
17
+ headers: {
18
+ accept: "application/json"
19
+ },
20
+ ...parameters
21
+ };
22
+ const response = await request(route, withOAuthParameters);
23
+ if ("error" in response.data) {
24
+ const error = new RequestError(
25
+ `${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`,
26
+ 400,
27
+ {
28
+ request: request.endpoint.merge(
29
+ route,
30
+ withOAuthParameters
31
+ )
32
+ }
33
+ );
34
+ error.response = response;
35
+ throw error;
36
+ }
37
+ return response;
38
+ }
39
+
40
+ // pkg/dist-src/get-web-flow-authorization-url.js
41
+ function getWebFlowAuthorizationUrl({
42
+ request = defaultRequest,
43
+ ...options
44
+ }) {
45
+ const baseUrl = requestToOAuthBaseUrl(request);
46
+ return oauthAuthorizationUrl({
47
+ ...options,
48
+ baseUrl
49
+ });
50
+ }
51
+
52
+ // pkg/dist-src/exchange-web-flow-code.js
53
+ import { request as defaultRequest2 } from "@octokit/request";
54
+ async function exchangeWebFlowCode(options) {
55
+ const request = options.request || defaultRequest2;
56
+ const response = await oauthRequest(
57
+ request,
58
+ "POST /login/oauth/access_token",
59
+ {
60
+ client_id: options.clientId,
61
+ client_secret: options.clientSecret,
62
+ code: options.code,
63
+ redirect_uri: options.redirectUrl
64
+ }
65
+ );
66
+ const authentication = {
67
+ clientType: options.clientType,
68
+ clientId: options.clientId,
69
+ clientSecret: options.clientSecret,
70
+ token: response.data.access_token,
71
+ scopes: response.data.scope.split(/\s+/).filter(Boolean)
72
+ };
73
+ if (options.clientType === "github-app") {
74
+ if ("refresh_token" in response.data) {
75
+ const apiTimeInMs = new Date(response.headers.date).getTime();
76
+ authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp(
77
+ apiTimeInMs,
78
+ response.data.expires_in
79
+ ), authentication.refreshTokenExpiresAt = toTimestamp(
80
+ apiTimeInMs,
81
+ response.data.refresh_token_expires_in
82
+ );
83
+ }
84
+ delete authentication.scopes;
85
+ }
86
+ return { ...response, authentication };
87
+ }
88
+ function toTimestamp(apiTimeInMs, expirationInSeconds) {
89
+ return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
90
+ }
91
+
92
+ // pkg/dist-src/create-device-code.js
93
+ import { request as defaultRequest3 } from "@octokit/request";
94
+ async function createDeviceCode(options) {
95
+ const request = options.request || defaultRequest3;
96
+ const parameters = {
97
+ client_id: options.clientId
98
+ };
99
+ if ("scopes" in options && Array.isArray(options.scopes)) {
100
+ parameters.scope = options.scopes.join(" ");
101
+ }
102
+ return oauthRequest(request, "POST /login/device/code", parameters);
103
+ }
104
+
105
+ // pkg/dist-src/exchange-device-code.js
106
+ import { request as defaultRequest4 } from "@octokit/request";
107
+ async function exchangeDeviceCode(options) {
108
+ const request = options.request || defaultRequest4;
109
+ const response = await oauthRequest(
110
+ request,
111
+ "POST /login/oauth/access_token",
112
+ {
113
+ client_id: options.clientId,
114
+ device_code: options.code,
115
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code"
116
+ }
117
+ );
118
+ const authentication = {
119
+ clientType: options.clientType,
120
+ clientId: options.clientId,
121
+ token: response.data.access_token,
122
+ scopes: response.data.scope.split(/\s+/).filter(Boolean)
123
+ };
124
+ if ("clientSecret" in options) {
125
+ authentication.clientSecret = options.clientSecret;
126
+ }
127
+ if (options.clientType === "github-app") {
128
+ if ("refresh_token" in response.data) {
129
+ const apiTimeInMs = new Date(response.headers.date).getTime();
130
+ authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp2(
131
+ apiTimeInMs,
132
+ response.data.expires_in
133
+ ), authentication.refreshTokenExpiresAt = toTimestamp2(
134
+ apiTimeInMs,
135
+ response.data.refresh_token_expires_in
136
+ );
137
+ }
138
+ delete authentication.scopes;
139
+ }
140
+ return { ...response, authentication };
141
+ }
142
+ function toTimestamp2(apiTimeInMs, expirationInSeconds) {
143
+ return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
144
+ }
145
+
146
+ // pkg/dist-src/check-token.js
147
+ import { request as defaultRequest5 } from "@octokit/request";
148
+ async function checkToken(options) {
149
+ const request = options.request || defaultRequest5;
150
+ const response = await request("POST /applications/{client_id}/token", {
151
+ headers: {
152
+ authorization: `basic ${btoa(
153
+ `${options.clientId}:${options.clientSecret}`
154
+ )}`
155
+ },
156
+ client_id: options.clientId,
157
+ access_token: options.token
158
+ });
159
+ const authentication = {
160
+ clientType: options.clientType,
161
+ clientId: options.clientId,
162
+ clientSecret: options.clientSecret,
163
+ token: options.token,
164
+ scopes: response.data.scopes
165
+ };
166
+ if (response.data.expires_at)
167
+ authentication.expiresAt = response.data.expires_at;
168
+ if (options.clientType === "github-app") {
169
+ delete authentication.scopes;
170
+ }
171
+ return { ...response, authentication };
172
+ }
173
+
174
+ // pkg/dist-src/refresh-token.js
175
+ import { request as defaultRequest6 } from "@octokit/request";
176
+ async function refreshToken(options) {
177
+ const request = options.request || defaultRequest6;
178
+ const response = await oauthRequest(
179
+ request,
180
+ "POST /login/oauth/access_token",
181
+ {
182
+ client_id: options.clientId,
183
+ client_secret: options.clientSecret,
184
+ grant_type: "refresh_token",
185
+ refresh_token: options.refreshToken
186
+ }
187
+ );
188
+ const apiTimeInMs = new Date(response.headers.date).getTime();
189
+ const authentication = {
190
+ clientType: "github-app",
191
+ clientId: options.clientId,
192
+ clientSecret: options.clientSecret,
193
+ token: response.data.access_token,
194
+ refreshToken: response.data.refresh_token,
195
+ expiresAt: toTimestamp3(apiTimeInMs, response.data.expires_in),
196
+ refreshTokenExpiresAt: toTimestamp3(
197
+ apiTimeInMs,
198
+ response.data.refresh_token_expires_in
199
+ )
200
+ };
201
+ return { ...response, authentication };
202
+ }
203
+ function toTimestamp3(apiTimeInMs, expirationInSeconds) {
204
+ return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
205
+ }
206
+
207
+ // pkg/dist-src/scope-token.js
208
+ import { request as defaultRequest7 } from "@octokit/request";
209
+ async function scopeToken(options) {
210
+ const {
211
+ request: optionsRequest,
212
+ clientType,
213
+ clientId,
214
+ clientSecret,
215
+ token,
216
+ ...requestOptions
217
+ } = options;
218
+ const request = options.request || defaultRequest7;
219
+ const response = await request(
220
+ "POST /applications/{client_id}/token/scoped",
221
+ {
222
+ headers: {
223
+ authorization: `basic ${btoa(`${clientId}:${clientSecret}`)}`
224
+ },
225
+ client_id: clientId,
226
+ access_token: token,
227
+ ...requestOptions
228
+ }
229
+ );
230
+ const authentication = Object.assign(
231
+ {
232
+ clientType,
233
+ clientId,
234
+ clientSecret,
235
+ token: response.data.token
236
+ },
237
+ response.data.expires_at ? { expiresAt: response.data.expires_at } : {}
238
+ );
239
+ return { ...response, authentication };
240
+ }
241
+
242
+ // pkg/dist-src/reset-token.js
243
+ import { request as defaultRequest8 } from "@octokit/request";
244
+ async function resetToken(options) {
245
+ const request = options.request || defaultRequest8;
246
+ const auth = btoa(`${options.clientId}:${options.clientSecret}`);
247
+ const response = await request(
248
+ "PATCH /applications/{client_id}/token",
249
+ {
250
+ headers: {
251
+ authorization: `basic ${auth}`
252
+ },
253
+ client_id: options.clientId,
254
+ access_token: options.token
255
+ }
256
+ );
257
+ const authentication = {
258
+ clientType: options.clientType,
259
+ clientId: options.clientId,
260
+ clientSecret: options.clientSecret,
261
+ token: response.data.token,
262
+ scopes: response.data.scopes
263
+ };
264
+ if (response.data.expires_at)
265
+ authentication.expiresAt = response.data.expires_at;
266
+ if (options.clientType === "github-app") {
267
+ delete authentication.scopes;
268
+ }
269
+ return { ...response, authentication };
270
+ }
271
+
272
+ // pkg/dist-src/delete-token.js
273
+ import { request as defaultRequest9 } from "@octokit/request";
274
+ async function deleteToken(options) {
275
+ const request = options.request || defaultRequest9;
276
+ const auth = btoa(`${options.clientId}:${options.clientSecret}`);
277
+ return request(
278
+ "DELETE /applications/{client_id}/token",
279
+ {
280
+ headers: {
281
+ authorization: `basic ${auth}`
282
+ },
283
+ client_id: options.clientId,
284
+ access_token: options.token
285
+ }
286
+ );
287
+ }
288
+
289
+ // pkg/dist-src/delete-authorization.js
290
+ import { request as defaultRequest10 } from "@octokit/request";
291
+ async function deleteAuthorization(options) {
292
+ const request = options.request || defaultRequest10;
293
+ const auth = btoa(`${options.clientId}:${options.clientSecret}`);
294
+ return request(
295
+ "DELETE /applications/{client_id}/grant",
296
+ {
297
+ headers: {
298
+ authorization: `basic ${auth}`
299
+ },
300
+ client_id: options.clientId,
301
+ access_token: options.token
302
+ }
303
+ );
304
+ }
305
+ export {
306
+ VERSION,
307
+ checkToken,
308
+ createDeviceCode,
309
+ deleteAuthorization,
310
+ deleteToken,
311
+ exchangeDeviceCode,
312
+ exchangeWebFlowCode,
313
+ getWebFlowAuthorizationUrl,
314
+ refreshToken,
315
+ resetToken,
316
+ scopeToken
317
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../dist-src/version.js", "../dist-src/get-web-flow-authorization-url.js", "../dist-src/utils.js", "../dist-src/exchange-web-flow-code.js", "../dist-src/create-device-code.js", "../dist-src/exchange-device-code.js", "../dist-src/check-token.js", "../dist-src/refresh-token.js", "../dist-src/scope-token.js", "../dist-src/reset-token.js", "../dist-src/delete-token.js", "../dist-src/delete-authorization.js"],
4
+ "sourcesContent": ["const VERSION = \"0.0.0-development\";\nexport {\n VERSION\n};\n", "import { oauthAuthorizationUrl } from \"@octokit/oauth-authorization-url\";\nimport { request as defaultRequest } from \"@octokit/request\";\nimport { requestToOAuthBaseUrl } from \"./utils.js\";\nfunction getWebFlowAuthorizationUrl({\n request = defaultRequest,\n ...options\n}) {\n const baseUrl = requestToOAuthBaseUrl(request);\n return oauthAuthorizationUrl({\n ...options,\n baseUrl\n });\n}\nexport {\n getWebFlowAuthorizationUrl\n};\n", "import { RequestError } from \"@octokit/request-error\";\nfunction requestToOAuthBaseUrl(request) {\n const endpointDefaults = request.endpoint.DEFAULTS;\n return /^https:\\/\\/(api\\.)?github\\.com$/.test(endpointDefaults.baseUrl) ? \"https://github.com\" : endpointDefaults.baseUrl.replace(\"/api/v3\", \"\");\n}\nasync function oauthRequest(request, route, parameters) {\n const withOAuthParameters = {\n baseUrl: requestToOAuthBaseUrl(request),\n headers: {\n accept: \"application/json\"\n },\n ...parameters\n };\n const response = await request(route, withOAuthParameters);\n if (\"error\" in response.data) {\n const error = new RequestError(\n `${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`,\n 400,\n {\n request: request.endpoint.merge(\n route,\n withOAuthParameters\n )\n }\n );\n error.response = response;\n throw error;\n }\n return response;\n}\nexport {\n oauthRequest,\n requestToOAuthBaseUrl\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nimport { oauthRequest } from \"./utils.js\";\nasync function exchangeWebFlowCode(options) {\n const request = options.request || defaultRequest;\n const response = await oauthRequest(\n request,\n \"POST /login/oauth/access_token\",\n {\n client_id: options.clientId,\n client_secret: options.clientSecret,\n code: options.code,\n redirect_uri: options.redirectUrl\n }\n );\n const authentication = {\n clientType: options.clientType,\n clientId: options.clientId,\n clientSecret: options.clientSecret,\n token: response.data.access_token,\n scopes: response.data.scope.split(/\\s+/).filter(Boolean)\n };\n if (options.clientType === \"github-app\") {\n if (\"refresh_token\" in response.data) {\n const apiTimeInMs = new Date(response.headers.date).getTime();\n authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp(\n apiTimeInMs,\n response.data.expires_in\n ), authentication.refreshTokenExpiresAt = toTimestamp(\n apiTimeInMs,\n response.data.refresh_token_expires_in\n );\n }\n delete authentication.scopes;\n }\n return { ...response, authentication };\n}\nfunction toTimestamp(apiTimeInMs, expirationInSeconds) {\n return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();\n}\nexport {\n exchangeWebFlowCode\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nimport { oauthRequest } from \"./utils.js\";\nasync function createDeviceCode(options) {\n const request = options.request || defaultRequest;\n const parameters = {\n client_id: options.clientId\n };\n if (\"scopes\" in options && Array.isArray(options.scopes)) {\n parameters.scope = options.scopes.join(\" \");\n }\n return oauthRequest(request, \"POST /login/device/code\", parameters);\n}\nexport {\n createDeviceCode\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nimport { oauthRequest } from \"./utils.js\";\nasync function exchangeDeviceCode(options) {\n const request = options.request || defaultRequest;\n const response = await oauthRequest(\n request,\n \"POST /login/oauth/access_token\",\n {\n client_id: options.clientId,\n device_code: options.code,\n grant_type: \"urn:ietf:params:oauth:grant-type:device_code\"\n }\n );\n const authentication = {\n clientType: options.clientType,\n clientId: options.clientId,\n token: response.data.access_token,\n scopes: response.data.scope.split(/\\s+/).filter(Boolean)\n };\n if (\"clientSecret\" in options) {\n authentication.clientSecret = options.clientSecret;\n }\n if (options.clientType === \"github-app\") {\n if (\"refresh_token\" in response.data) {\n const apiTimeInMs = new Date(response.headers.date).getTime();\n authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp(\n apiTimeInMs,\n response.data.expires_in\n ), authentication.refreshTokenExpiresAt = toTimestamp(\n apiTimeInMs,\n response.data.refresh_token_expires_in\n );\n }\n delete authentication.scopes;\n }\n return { ...response, authentication };\n}\nfunction toTimestamp(apiTimeInMs, expirationInSeconds) {\n return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();\n}\nexport {\n exchangeDeviceCode\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nasync function checkToken(options) {\n const request = options.request || defaultRequest;\n const response = await request(\"POST /applications/{client_id}/token\", {\n headers: {\n authorization: `basic ${btoa(\n `${options.clientId}:${options.clientSecret}`\n )}`\n },\n client_id: options.clientId,\n access_token: options.token\n });\n const authentication = {\n clientType: options.clientType,\n clientId: options.clientId,\n clientSecret: options.clientSecret,\n token: options.token,\n scopes: response.data.scopes\n };\n if (response.data.expires_at)\n authentication.expiresAt = response.data.expires_at;\n if (options.clientType === \"github-app\") {\n delete authentication.scopes;\n }\n return { ...response, authentication };\n}\nexport {\n checkToken\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nimport { oauthRequest } from \"./utils.js\";\nasync function refreshToken(options) {\n const request = options.request || defaultRequest;\n const response = await oauthRequest(\n request,\n \"POST /login/oauth/access_token\",\n {\n client_id: options.clientId,\n client_secret: options.clientSecret,\n grant_type: \"refresh_token\",\n refresh_token: options.refreshToken\n }\n );\n const apiTimeInMs = new Date(response.headers.date).getTime();\n const authentication = {\n clientType: \"github-app\",\n clientId: options.clientId,\n clientSecret: options.clientSecret,\n token: response.data.access_token,\n refreshToken: response.data.refresh_token,\n expiresAt: toTimestamp(apiTimeInMs, response.data.expires_in),\n refreshTokenExpiresAt: toTimestamp(\n apiTimeInMs,\n response.data.refresh_token_expires_in\n )\n };\n return { ...response, authentication };\n}\nfunction toTimestamp(apiTimeInMs, expirationInSeconds) {\n return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();\n}\nexport {\n refreshToken\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nasync function scopeToken(options) {\n const {\n request: optionsRequest,\n clientType,\n clientId,\n clientSecret,\n token,\n ...requestOptions\n } = options;\n const request = options.request || defaultRequest;\n const response = await request(\n \"POST /applications/{client_id}/token/scoped\",\n {\n headers: {\n authorization: `basic ${btoa(`${clientId}:${clientSecret}`)}`\n },\n client_id: clientId,\n access_token: token,\n ...requestOptions\n }\n );\n const authentication = Object.assign(\n {\n clientType,\n clientId,\n clientSecret,\n token: response.data.token\n },\n response.data.expires_at ? { expiresAt: response.data.expires_at } : {}\n );\n return { ...response, authentication };\n}\nexport {\n scopeToken\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nasync function resetToken(options) {\n const request = options.request || defaultRequest;\n const auth = btoa(`${options.clientId}:${options.clientSecret}`);\n const response = await request(\n \"PATCH /applications/{client_id}/token\",\n {\n headers: {\n authorization: `basic ${auth}`\n },\n client_id: options.clientId,\n access_token: options.token\n }\n );\n const authentication = {\n clientType: options.clientType,\n clientId: options.clientId,\n clientSecret: options.clientSecret,\n token: response.data.token,\n scopes: response.data.scopes\n };\n if (response.data.expires_at)\n authentication.expiresAt = response.data.expires_at;\n if (options.clientType === \"github-app\") {\n delete authentication.scopes;\n }\n return { ...response, authentication };\n}\nexport {\n resetToken\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nasync function deleteToken(options) {\n const request = options.request || defaultRequest;\n const auth = btoa(`${options.clientId}:${options.clientSecret}`);\n return request(\n \"DELETE /applications/{client_id}/token\",\n {\n headers: {\n authorization: `basic ${auth}`\n },\n client_id: options.clientId,\n access_token: options.token\n }\n );\n}\nexport {\n deleteToken\n};\n", "import { request as defaultRequest } from \"@octokit/request\";\nasync function deleteAuthorization(options) {\n const request = options.request || defaultRequest;\n const auth = btoa(`${options.clientId}:${options.clientSecret}`);\n return request(\n \"DELETE /applications/{client_id}/grant\",\n {\n headers: {\n authorization: `basic ${auth}`\n },\n client_id: options.clientId,\n access_token: options.token\n }\n );\n}\nexport {\n deleteAuthorization\n};\n"],
5
+ "mappings": ";AAAA,IAAM,UAAU;;;ACAhB,SAAS,6BAA6B;AACtC,SAAS,WAAW,sBAAsB;;;ACD1C,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB,SAAS;AACtC,QAAM,mBAAmB,QAAQ,SAAS;AAC1C,SAAO,kCAAkC,KAAK,iBAAiB,OAAO,IAAI,uBAAuB,iBAAiB,QAAQ,QAAQ,WAAW,EAAE;AACjJ;AACA,eAAe,aAAa,SAAS,OAAO,YAAY;AACtD,QAAM,sBAAsB;AAAA,IAC1B,SAAS,sBAAsB,OAAO;AAAA,IACtC,SAAS;AAAA,MACP,QAAQ;AAAA,IACV;AAAA,IACA,GAAG;AAAA,EACL;AACA,QAAM,WAAW,MAAM,QAAQ,OAAO,mBAAmB;AACzD,MAAI,WAAW,SAAS,MAAM;AAC5B,UAAM,QAAQ,IAAI;AAAA,MAChB,GAAG,SAAS,KAAK,iBAAiB,KAAK,SAAS,KAAK,KAAK,KAAK,SAAS,KAAK,SAAS;AAAA,MACtF;AAAA,MACA;AAAA,QACE,SAAS,QAAQ,SAAS;AAAA,UACxB;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,UAAM,WAAW;AACjB,UAAM;AAAA,EACR;AACA,SAAO;AACT;;;AD1BA,SAAS,2BAA2B;AAAA,EAClC,UAAU;AAAA,EACV,GAAG;AACL,GAAG;AACD,QAAM,UAAU,sBAAsB,OAAO;AAC7C,SAAO,sBAAsB;AAAA,IAC3B,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH;;;AEZA,SAAS,WAAWA,uBAAsB;AAE1C,eAAe,oBAAoB,SAAS;AAC1C,QAAM,UAAU,QAAQ,WAAWC;AACnC,QAAM,WAA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AE;AAC/D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,SAAS;AAAA,QACP,eAAe,SAAS,IAAI;AAAA,MAC9B;AAAA,MACA,WAAW,QAAQ;AAAA,MACnB,cAAc,QAAQ;AAAA,IACxB;AAAA,EACF;AACF;;;ACdA,SAAS,WAAWC,wBAAsB;AAC1C,eAAe,oBAAoB,SAAS;AAC1C,QAAM,UAAU,QAAQ,WAAWA;AACnC,QAAM,OAAO,KAAK,GAAG,QAAQ,QAAQ,IAAI,QAAQ,YAAY,EAAE;AAC/D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,SAAS;AAAA,QACP,eAAe,SAAS,IAAI;AAAA,MAC9B;AAAA,MACA,WAAW,QAAQ;AAAA,MACnB,cAAc,QAAQ;AAAA,IACxB;AAAA,EACF;AACF;",
6
+ "names": ["defaultRequest", "defaultRequest", "defaultRequest", "defaultRequest", "defaultRequest", "defaultRequest", "toTimestamp", "defaultRequest", "defaultRequest", "defaultRequest", "toTimestamp", "defaultRequest", "defaultRequest", "defaultRequest", "defaultRequest"]
7
+ }
@@ -0,0 +1,29 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ async function checkToken(options) {
3
+ const request = options.request || defaultRequest;
4
+ const response = await request("POST /applications/{client_id}/token", {
5
+ headers: {
6
+ authorization: `basic ${btoa(
7
+ `${options.clientId}:${options.clientSecret}`
8
+ )}`
9
+ },
10
+ client_id: options.clientId,
11
+ access_token: options.token
12
+ });
13
+ const authentication = {
14
+ clientType: options.clientType,
15
+ clientId: options.clientId,
16
+ clientSecret: options.clientSecret,
17
+ token: options.token,
18
+ scopes: response.data.scopes
19
+ };
20
+ if (response.data.expires_at)
21
+ authentication.expiresAt = response.data.expires_at;
22
+ if (options.clientType === "github-app") {
23
+ delete authentication.scopes;
24
+ }
25
+ return { ...response, authentication };
26
+ }
27
+ export {
28
+ checkToken
29
+ };
@@ -0,0 +1,15 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ import { oauthRequest } from "./utils.js";
3
+ async function createDeviceCode(options) {
4
+ const request = options.request || defaultRequest;
5
+ const parameters = {
6
+ client_id: options.clientId
7
+ };
8
+ if ("scopes" in options && Array.isArray(options.scopes)) {
9
+ parameters.scope = options.scopes.join(" ");
10
+ }
11
+ return oauthRequest(request, "POST /login/device/code", parameters);
12
+ }
13
+ export {
14
+ createDeviceCode
15
+ };
@@ -0,0 +1,18 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ async function deleteAuthorization(options) {
3
+ const request = options.request || defaultRequest;
4
+ const auth = btoa(`${options.clientId}:${options.clientSecret}`);
5
+ return request(
6
+ "DELETE /applications/{client_id}/grant",
7
+ {
8
+ headers: {
9
+ authorization: `basic ${auth}`
10
+ },
11
+ client_id: options.clientId,
12
+ access_token: options.token
13
+ }
14
+ );
15
+ }
16
+ export {
17
+ deleteAuthorization
18
+ };
@@ -0,0 +1,18 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ async function deleteToken(options) {
3
+ const request = options.request || defaultRequest;
4
+ const auth = btoa(`${options.clientId}:${options.clientSecret}`);
5
+ return request(
6
+ "DELETE /applications/{client_id}/token",
7
+ {
8
+ headers: {
9
+ authorization: `basic ${auth}`
10
+ },
11
+ client_id: options.clientId,
12
+ access_token: options.token
13
+ }
14
+ );
15
+ }
16
+ export {
17
+ deleteToken
18
+ };
@@ -0,0 +1,43 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ import { oauthRequest } from "./utils.js";
3
+ async function exchangeDeviceCode(options) {
4
+ const request = options.request || defaultRequest;
5
+ const response = await oauthRequest(
6
+ request,
7
+ "POST /login/oauth/access_token",
8
+ {
9
+ client_id: options.clientId,
10
+ device_code: options.code,
11
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code"
12
+ }
13
+ );
14
+ const authentication = {
15
+ clientType: options.clientType,
16
+ clientId: options.clientId,
17
+ token: response.data.access_token,
18
+ scopes: response.data.scope.split(/\s+/).filter(Boolean)
19
+ };
20
+ if ("clientSecret" in options) {
21
+ authentication.clientSecret = options.clientSecret;
22
+ }
23
+ if (options.clientType === "github-app") {
24
+ if ("refresh_token" in response.data) {
25
+ const apiTimeInMs = new Date(response.headers.date).getTime();
26
+ authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp(
27
+ apiTimeInMs,
28
+ response.data.expires_in
29
+ ), authentication.refreshTokenExpiresAt = toTimestamp(
30
+ apiTimeInMs,
31
+ response.data.refresh_token_expires_in
32
+ );
33
+ }
34
+ delete authentication.scopes;
35
+ }
36
+ return { ...response, authentication };
37
+ }
38
+ function toTimestamp(apiTimeInMs, expirationInSeconds) {
39
+ return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
40
+ }
41
+ export {
42
+ exchangeDeviceCode
43
+ };
@@ -0,0 +1,42 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ import { oauthRequest } from "./utils.js";
3
+ async function exchangeWebFlowCode(options) {
4
+ const request = options.request || defaultRequest;
5
+ const response = await oauthRequest(
6
+ request,
7
+ "POST /login/oauth/access_token",
8
+ {
9
+ client_id: options.clientId,
10
+ client_secret: options.clientSecret,
11
+ code: options.code,
12
+ redirect_uri: options.redirectUrl
13
+ }
14
+ );
15
+ const authentication = {
16
+ clientType: options.clientType,
17
+ clientId: options.clientId,
18
+ clientSecret: options.clientSecret,
19
+ token: response.data.access_token,
20
+ scopes: response.data.scope.split(/\s+/).filter(Boolean)
21
+ };
22
+ if (options.clientType === "github-app") {
23
+ if ("refresh_token" in response.data) {
24
+ const apiTimeInMs = new Date(response.headers.date).getTime();
25
+ authentication.refreshToken = response.data.refresh_token, authentication.expiresAt = toTimestamp(
26
+ apiTimeInMs,
27
+ response.data.expires_in
28
+ ), authentication.refreshTokenExpiresAt = toTimestamp(
29
+ apiTimeInMs,
30
+ response.data.refresh_token_expires_in
31
+ );
32
+ }
33
+ delete authentication.scopes;
34
+ }
35
+ return { ...response, authentication };
36
+ }
37
+ function toTimestamp(apiTimeInMs, expirationInSeconds) {
38
+ return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
39
+ }
40
+ export {
41
+ exchangeWebFlowCode
42
+ };
@@ -0,0 +1,16 @@
1
+ import { oauthAuthorizationUrl } from "@octokit/oauth-authorization-url";
2
+ import { request as defaultRequest } from "@octokit/request";
3
+ import { requestToOAuthBaseUrl } from "./utils.js";
4
+ function getWebFlowAuthorizationUrl({
5
+ request = defaultRequest,
6
+ ...options
7
+ }) {
8
+ const baseUrl = requestToOAuthBaseUrl(request);
9
+ return oauthAuthorizationUrl({
10
+ ...options,
11
+ baseUrl
12
+ });
13
+ }
14
+ export {
15
+ getWebFlowAuthorizationUrl
16
+ };
@@ -0,0 +1,14 @@
1
+ import { VERSION } from "./version.js";
2
+ export * from "./get-web-flow-authorization-url.js";
3
+ export * from "./exchange-web-flow-code.js";
4
+ export * from "./create-device-code.js";
5
+ export * from "./exchange-device-code.js";
6
+ export * from "./check-token.js";
7
+ export * from "./refresh-token.js";
8
+ export * from "./scope-token.js";
9
+ export * from "./reset-token.js";
10
+ export * from "./delete-token.js";
11
+ export * from "./delete-authorization.js";
12
+ export {
13
+ VERSION
14
+ };
@@ -0,0 +1,35 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ import { oauthRequest } from "./utils.js";
3
+ async function refreshToken(options) {
4
+ const request = options.request || defaultRequest;
5
+ const response = await oauthRequest(
6
+ request,
7
+ "POST /login/oauth/access_token",
8
+ {
9
+ client_id: options.clientId,
10
+ client_secret: options.clientSecret,
11
+ grant_type: "refresh_token",
12
+ refresh_token: options.refreshToken
13
+ }
14
+ );
15
+ const apiTimeInMs = new Date(response.headers.date).getTime();
16
+ const authentication = {
17
+ clientType: "github-app",
18
+ clientId: options.clientId,
19
+ clientSecret: options.clientSecret,
20
+ token: response.data.access_token,
21
+ refreshToken: response.data.refresh_token,
22
+ expiresAt: toTimestamp(apiTimeInMs, response.data.expires_in),
23
+ refreshTokenExpiresAt: toTimestamp(
24
+ apiTimeInMs,
25
+ response.data.refresh_token_expires_in
26
+ )
27
+ };
28
+ return { ...response, authentication };
29
+ }
30
+ function toTimestamp(apiTimeInMs, expirationInSeconds) {
31
+ return new Date(apiTimeInMs + expirationInSeconds * 1e3).toISOString();
32
+ }
33
+ export {
34
+ refreshToken
35
+ };
@@ -0,0 +1,31 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ async function resetToken(options) {
3
+ const request = options.request || defaultRequest;
4
+ const auth = btoa(`${options.clientId}:${options.clientSecret}`);
5
+ const response = await request(
6
+ "PATCH /applications/{client_id}/token",
7
+ {
8
+ headers: {
9
+ authorization: `basic ${auth}`
10
+ },
11
+ client_id: options.clientId,
12
+ access_token: options.token
13
+ }
14
+ );
15
+ const authentication = {
16
+ clientType: options.clientType,
17
+ clientId: options.clientId,
18
+ clientSecret: options.clientSecret,
19
+ token: response.data.token,
20
+ scopes: response.data.scopes
21
+ };
22
+ if (response.data.expires_at)
23
+ authentication.expiresAt = response.data.expires_at;
24
+ if (options.clientType === "github-app") {
25
+ delete authentication.scopes;
26
+ }
27
+ return { ...response, authentication };
28
+ }
29
+ export {
30
+ resetToken
31
+ };
@@ -0,0 +1,36 @@
1
+ import { request as defaultRequest } from "@octokit/request";
2
+ async function scopeToken(options) {
3
+ const {
4
+ request: optionsRequest,
5
+ clientType,
6
+ clientId,
7
+ clientSecret,
8
+ token,
9
+ ...requestOptions
10
+ } = options;
11
+ const request = options.request || defaultRequest;
12
+ const response = await request(
13
+ "POST /applications/{client_id}/token/scoped",
14
+ {
15
+ headers: {
16
+ authorization: `basic ${btoa(`${clientId}:${clientSecret}`)}`
17
+ },
18
+ client_id: clientId,
19
+ access_token: token,
20
+ ...requestOptions
21
+ }
22
+ );
23
+ const authentication = Object.assign(
24
+ {
25
+ clientType,
26
+ clientId,
27
+ clientSecret,
28
+ token: response.data.token
29
+ },
30
+ response.data.expires_at ? { expiresAt: response.data.expires_at } : {}
31
+ );
32
+ return { ...response, authentication };
33
+ }
34
+ export {
35
+ scopeToken
36
+ };
@@ -0,0 +1,34 @@
1
+ import { RequestError } from "@octokit/request-error";
2
+ function requestToOAuthBaseUrl(request) {
3
+ const endpointDefaults = request.endpoint.DEFAULTS;
4
+ return /^https:\/\/(api\.)?github\.com$/.test(endpointDefaults.baseUrl) ? "https://github.com" : endpointDefaults.baseUrl.replace("/api/v3", "");
5
+ }
6
+ async function oauthRequest(request, route, parameters) {
7
+ const withOAuthParameters = {
8
+ baseUrl: requestToOAuthBaseUrl(request),
9
+ headers: {
10
+ accept: "application/json"
11
+ },
12
+ ...parameters
13
+ };
14
+ const response = await request(route, withOAuthParameters);
15
+ if ("error" in response.data) {
16
+ const error = new RequestError(
17
+ `${response.data.error_description} (${response.data.error}, ${response.data.error_uri})`,
18
+ 400,
19
+ {
20
+ request: request.endpoint.merge(
21
+ route,
22
+ withOAuthParameters
23
+ )
24
+ }
25
+ );
26
+ error.response = response;
27
+ throw error;
28
+ }
29
+ return response;
30
+ }
31
+ export {
32
+ oauthRequest,
33
+ requestToOAuthBaseUrl
34
+ };
@@ -0,0 +1,4 @@
1
+ const VERSION = "6.0.2";
2
+ export {
3
+ VERSION
4
+ };
@@ -0,0 +1,24 @@
1
+ import type { RequestInterface, Endpoints } from "@octokit/types";
2
+ import type { OAuthAppAuthentication, GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithExpirationDisabled } from "./types.js";
3
+ export type CheckTokenOAuthAppOptions = {
4
+ clientType: "oauth-app";
5
+ clientId: string;
6
+ clientSecret: string;
7
+ token: string;
8
+ request?: RequestInterface;
9
+ };
10
+ export type CheckTokenGitHubAppOptions = {
11
+ clientType: "github-app";
12
+ clientId: string;
13
+ clientSecret: string;
14
+ token: string;
15
+ request?: RequestInterface;
16
+ };
17
+ export type CheckTokenOAuthAppResponse = Endpoints["POST /applications/{client_id}/token"]["response"] & {
18
+ authentication: OAuthAppAuthentication;
19
+ };
20
+ export type CheckTokenGitHubAppResponse = Endpoints["POST /applications/{client_id}/token"]["response"] & {
21
+ authentication: GitHubAppAuthenticationWithExpirationEnabled | GitHubAppAuthenticationWithExpirationDisabled;
22
+ };
23
+ export declare function checkToken(options: CheckTokenOAuthAppOptions): Promise<CheckTokenOAuthAppResponse>;
24
+ export declare function checkToken(options: CheckTokenGitHubAppOptions): Promise<CheckTokenGitHubAppResponse>;
@@ -0,0 +1,20 @@
1
+ import type { OctokitResponse, RequestInterface } from "@octokit/types";
2
+ export type CreateDeviceCodeOAuthAppOptions = {
3
+ clientType: "oauth-app";
4
+ clientId: string;
5
+ scopes?: string[];
6
+ request?: RequestInterface;
7
+ };
8
+ export type CreateDeviceCodeGitHubAppOptions = {
9
+ clientType: "github-app";
10
+ clientId: string;
11
+ request?: RequestInterface;
12
+ };
13
+ export type CreateDeviceCodeDeviceTokenResponse = OctokitResponse<{
14
+ device_code: string;
15
+ user_code: string;
16
+ verification_uri: string;
17
+ expires_in: number;
18
+ interval: number;
19
+ }>;
20
+ export declare function createDeviceCode(options: CreateDeviceCodeOAuthAppOptions | CreateDeviceCodeGitHubAppOptions): Promise<CreateDeviceCodeDeviceTokenResponse>;
@@ -0,0 +1,18 @@
1
+ import type { RequestInterface, Endpoints } from "@octokit/types";
2
+ export type DeleteAuthorizationOAuthAppOptions = {
3
+ clientType: "oauth-app";
4
+ clientId: string;
5
+ clientSecret: string;
6
+ token: string;
7
+ request?: RequestInterface;
8
+ };
9
+ export type DeleteAuthorizationGitHubAppOptions = {
10
+ clientType: "github-app";
11
+ clientId: string;
12
+ clientSecret: string;
13
+ token: string;
14
+ request?: RequestInterface;
15
+ };
16
+ export type DeleteAuthorizationResponse = Endpoints["DELETE /applications/{client_id}/grant"]["response"];
17
+ export declare function deleteAuthorization(options: DeleteAuthorizationOAuthAppOptions): Promise<DeleteAuthorizationResponse>;
18
+ export declare function deleteAuthorization(options: DeleteAuthorizationGitHubAppOptions): Promise<DeleteAuthorizationResponse>;
@@ -0,0 +1,18 @@
1
+ import type { RequestInterface, Endpoints } from "@octokit/types";
2
+ export type DeleteTokenOAuthAppOptions = {
3
+ clientType: "oauth-app";
4
+ clientId: string;
5
+ clientSecret: string;
6
+ token: string;
7
+ request?: RequestInterface;
8
+ };
9
+ export type DeleteTokenGitHubAppOptions = {
10
+ clientType: "github-app";
11
+ clientId: string;
12
+ clientSecret: string;
13
+ token: string;
14
+ request?: RequestInterface;
15
+ };
16
+ export type DeleteTokenResponse = Endpoints["DELETE /applications/{client_id}/token"]["response"];
17
+ export declare function deleteToken(options: DeleteTokenOAuthAppOptions): Promise<DeleteTokenResponse>;
18
+ export declare function deleteToken(options: DeleteTokenGitHubAppOptions): Promise<DeleteTokenResponse>;
@@ -0,0 +1,57 @@
1
+ import type { OctokitResponse, RequestInterface } from "@octokit/types";
2
+ import type { OAuthAppAuthentication, GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithExpirationDisabled, GitHubAppAuthenticationWithRefreshToken, OAuthAppCreateTokenResponseData, GitHubAppCreateTokenResponseData, GitHubAppCreateTokenWithExpirationResponseData } from "./types.js";
3
+ export type ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret = {
4
+ clientType: "oauth-app";
5
+ clientId: string;
6
+ code: string;
7
+ redirectUrl?: string;
8
+ state?: string;
9
+ request?: RequestInterface;
10
+ scopes?: string[];
11
+ };
12
+ export type ExchangeDeviceCodeOAuthAppOptions = ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret & {
13
+ clientSecret: string;
14
+ };
15
+ export type ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret = {
16
+ clientType: "github-app";
17
+ clientId: string;
18
+ code: string;
19
+ redirectUrl?: string;
20
+ state?: string;
21
+ request?: RequestInterface;
22
+ };
23
+ export type ExchangeDeviceCodeGitHubAppOptions = ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret & {
24
+ clientSecret: string;
25
+ };
26
+ type OAuthAppAuthenticationWithoutClientSecret = Omit<OAuthAppAuthentication, "clientSecret">;
27
+ type GitHubAppAuthenticationWithoutClientSecret = Omit<GitHubAppAuthenticationWithExpirationEnabled | GitHubAppAuthenticationWithExpirationDisabled, "clientSecret">;
28
+ type GitHubAppAuthenticationWithExpirationWithoutClientSecret = Omit<GitHubAppAuthenticationWithRefreshToken, "clientSecret">;
29
+ export type ExchangeDeviceCodeOAuthAppResponse = OctokitResponse<OAuthAppCreateTokenResponseData> & {
30
+ authentication: OAuthAppAuthentication;
31
+ };
32
+ export type ExchangeDeviceCodeOAuthAppResponseWithoutClientSecret = OctokitResponse<OAuthAppCreateTokenResponseData> & {
33
+ authentication: OAuthAppAuthenticationWithoutClientSecret;
34
+ };
35
+ export type ExchangeDeviceCodeGitHubAppResponse = OctokitResponse<GitHubAppCreateTokenResponseData | GitHubAppCreateTokenWithExpirationResponseData> & {
36
+ authentication: GitHubAppAuthenticationWithExpirationEnabled | GitHubAppAuthenticationWithExpirationDisabled | GitHubAppAuthenticationWithRefreshToken;
37
+ };
38
+ export type ExchangeDeviceCodeGitHubAppResponseWithoutClientSecret = OctokitResponse<GitHubAppCreateTokenResponseData | GitHubAppCreateTokenWithExpirationResponseData> & {
39
+ authentication: GitHubAppAuthenticationWithoutClientSecret | GitHubAppAuthenticationWithExpirationWithoutClientSecret;
40
+ };
41
+ /**
42
+ * Exchange the code from GitHub's OAuth Web flow for OAuth Apps.
43
+ */
44
+ export declare function exchangeDeviceCode(options: ExchangeDeviceCodeOAuthAppOptions): Promise<ExchangeDeviceCodeOAuthAppResponse>;
45
+ /**
46
+ * Exchange the code from GitHub's OAuth Web flow for OAuth Apps without clientSecret
47
+ */
48
+ export declare function exchangeDeviceCode(options: ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret): Promise<ExchangeDeviceCodeOAuthAppResponseWithoutClientSecret>;
49
+ /**
50
+ * Exchange the code from GitHub's OAuth Web flow for GitHub Apps. `scopes` are not supported by GitHub Apps.
51
+ */
52
+ export declare function exchangeDeviceCode(options: ExchangeDeviceCodeGitHubAppOptions): Promise<ExchangeDeviceCodeGitHubAppResponse>;
53
+ /**
54
+ * Exchange the code from GitHub's OAuth Web flow for GitHub Apps without using `clientSecret`. `scopes` are not supported by GitHub Apps.
55
+ */
56
+ export declare function exchangeDeviceCode(options: ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret): Promise<ExchangeDeviceCodeGitHubAppResponseWithoutClientSecret>;
57
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { OctokitResponse, RequestInterface } from "@octokit/types";
2
+ import type { OAuthAppAuthentication, GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithExpirationDisabled, GitHubAppAuthenticationWithRefreshToken, OAuthAppCreateTokenResponseData, GitHubAppCreateTokenResponseData, GitHubAppCreateTokenWithExpirationResponseData } from "./types.js";
3
+ export type ExchangeWebFlowCodeOAuthAppOptions = {
4
+ clientType: "oauth-app";
5
+ clientId: string;
6
+ clientSecret: string;
7
+ code: string;
8
+ redirectUrl?: string;
9
+ request?: RequestInterface;
10
+ };
11
+ export type ExchangeWebFlowCodeGitHubAppOptions = {
12
+ clientType: "github-app";
13
+ clientId: string;
14
+ clientSecret: string;
15
+ code: string;
16
+ redirectUrl?: string;
17
+ request?: RequestInterface;
18
+ };
19
+ export type ExchangeWebFlowCodeOAuthAppResponse = OctokitResponse<OAuthAppCreateTokenResponseData> & {
20
+ authentication: OAuthAppAuthentication;
21
+ };
22
+ export type ExchangeWebFlowCodeGitHubAppResponse = OctokitResponse<GitHubAppCreateTokenResponseData | GitHubAppCreateTokenWithExpirationResponseData> & {
23
+ authentication: GitHubAppAuthenticationWithExpirationEnabled | GitHubAppAuthenticationWithExpirationDisabled | GitHubAppAuthenticationWithRefreshToken;
24
+ };
25
+ /**
26
+ * Exchange the code from GitHub's OAuth Web flow for OAuth Apps.
27
+ */
28
+ export declare function exchangeWebFlowCode(options: ExchangeWebFlowCodeOAuthAppOptions): Promise<ExchangeWebFlowCodeOAuthAppResponse>;
29
+ /**
30
+ * Exchange the code from GitHub's OAuth Web flow for GitHub Apps. Note that `scopes` are not supported by GitHub Apps.
31
+ */
32
+ export declare function exchangeWebFlowCode(options: ExchangeWebFlowCodeGitHubAppOptions): Promise<ExchangeWebFlowCodeGitHubAppResponse>;
@@ -0,0 +1,25 @@
1
+ import type { OAuthAppResult, GitHubAppResult } from "@octokit/oauth-authorization-url";
2
+ import type { RequestInterface } from "@octokit/types";
3
+ export type GetWebFlowAuthorizationUrlOAuthAppOptions = {
4
+ clientType: "oauth-app";
5
+ clientId: string;
6
+ allowSignup?: boolean;
7
+ login?: string;
8
+ scopes?: string | string[];
9
+ redirectUrl?: string;
10
+ state?: string;
11
+ request?: RequestInterface;
12
+ };
13
+ export type GetWebFlowAuthorizationUrlGitHubAppOptions = {
14
+ clientType: "github-app";
15
+ clientId: string;
16
+ allowSignup?: boolean;
17
+ login?: string;
18
+ redirectUrl?: string;
19
+ state?: string;
20
+ request?: RequestInterface;
21
+ };
22
+ export type GetWebFlowAuthorizationUrlOAuthAppResult = OAuthAppResult;
23
+ export type GetWebFlowAuthorizationUrlGitHubAppResult = GitHubAppResult;
24
+ export declare function getWebFlowAuthorizationUrl(options: GetWebFlowAuthorizationUrlOAuthAppOptions): OAuthAppResult;
25
+ export declare function getWebFlowAuthorizationUrl(options: GetWebFlowAuthorizationUrlGitHubAppOptions): GitHubAppResult;
@@ -0,0 +1,12 @@
1
+ export { VERSION } from "./version.js";
2
+ export * from "./get-web-flow-authorization-url.js";
3
+ export * from "./exchange-web-flow-code.js";
4
+ export * from "./create-device-code.js";
5
+ export * from "./exchange-device-code.js";
6
+ export * from "./check-token.js";
7
+ export * from "./refresh-token.js";
8
+ export * from "./scope-token.js";
9
+ export * from "./reset-token.js";
10
+ export * from "./delete-token.js";
11
+ export * from "./delete-authorization.js";
12
+ export type { OAuthAppAuthentication, GitHubAppAuthenticationWithExpirationDisabled, GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithRefreshToken, GitHubAppAuthentication, GitHubAppAuthenticationWithExpiration, } from "./types.js";
@@ -0,0 +1,13 @@
1
+ import type { OctokitResponse, RequestInterface } from "@octokit/types";
2
+ import type { GitHubAppAuthenticationWithRefreshToken, GitHubAppCreateTokenWithExpirationResponseData } from "./types.js";
3
+ export type RefreshTokenOptions = {
4
+ clientType: "github-app";
5
+ clientId: string;
6
+ clientSecret: string;
7
+ refreshToken: string;
8
+ request?: RequestInterface;
9
+ };
10
+ export type RefreshTokenResponse = OctokitResponse<GitHubAppCreateTokenWithExpirationResponseData> & {
11
+ authentication: GitHubAppAuthenticationWithRefreshToken;
12
+ };
13
+ export declare function refreshToken(options: RefreshTokenOptions): Promise<RefreshTokenResponse>;
@@ -0,0 +1,24 @@
1
+ import type { Endpoints, RequestInterface } from "@octokit/types";
2
+ import type { OAuthAppAuthentication, GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithExpirationDisabled } from "./types.js";
3
+ export type ResetTokenOAuthAppOptions = {
4
+ clientType: "oauth-app";
5
+ clientId: string;
6
+ clientSecret: string;
7
+ token: string;
8
+ request?: RequestInterface;
9
+ };
10
+ export type ResetTokenGitHubAppOptions = {
11
+ clientType: "github-app";
12
+ clientId: string;
13
+ clientSecret: string;
14
+ token: string;
15
+ request?: RequestInterface;
16
+ };
17
+ export type ResetTokenOAuthAppResponse = Endpoints["PATCH /applications/{client_id}/token"]["response"] & {
18
+ authentication: OAuthAppAuthentication;
19
+ };
20
+ export type ResetTokenGitHubAppResponse = Endpoints["PATCH /applications/{client_id}/token"]["response"] & {
21
+ authentication: GitHubAppAuthenticationWithExpirationEnabled | GitHubAppAuthenticationWithExpirationDisabled;
22
+ };
23
+ export declare function resetToken(options: ResetTokenOAuthAppOptions): Promise<ResetTokenOAuthAppResponse>;
24
+ export declare function resetToken(options: ResetTokenGitHubAppOptions): Promise<ResetTokenGitHubAppResponse>;
@@ -0,0 +1,29 @@
1
+ import type { RequestInterface, Endpoints } from "@octokit/types";
2
+ import type { GitHubAppAuthenticationWithExpirationEnabled, GitHubAppAuthenticationWithExpirationDisabled } from "./types.js";
3
+ type CommonOptions = {
4
+ clientType: "github-app";
5
+ clientId: string;
6
+ clientSecret: string;
7
+ token: string;
8
+ permissions?: Endpoint["parameters"]["permissions"];
9
+ request?: RequestInterface;
10
+ };
11
+ type TargetOption = {
12
+ target: string;
13
+ };
14
+ type TargetIdOption = {
15
+ target_id: number;
16
+ };
17
+ type RepositoriesOption = {
18
+ repositories?: string[];
19
+ };
20
+ type RepositoryIdsOption = {
21
+ repository_ids?: number[];
22
+ };
23
+ type Endpoint = Endpoints["POST /applications/{client_id}/token/scoped"];
24
+ export type ScopeTokenOptions = (CommonOptions & TargetOption & RepositoriesOption) | (CommonOptions & TargetIdOption & RepositoriesOption) | (CommonOptions & TargetOption & RepositoryIdsOption) | (CommonOptions & TargetIdOption & RepositoryIdsOption);
25
+ export type ScopeTokenResponse = Endpoint["response"] & {
26
+ authentication: GitHubAppAuthenticationWithExpirationEnabled | GitHubAppAuthenticationWithExpirationDisabled;
27
+ };
28
+ export declare function scopeToken(options: ScopeTokenOptions): Promise<ScopeTokenResponse>;
29
+ export {};
@@ -0,0 +1,58 @@
1
+ export type OAuthAppAuthentication = {
2
+ clientType: "oauth-app";
3
+ clientId: string;
4
+ clientSecret: string;
5
+ token: string;
6
+ scopes: string[];
7
+ };
8
+ export type GitHubAppAuthenticationWithExpirationDisabled = {
9
+ clientType: "github-app";
10
+ clientId: string;
11
+ clientSecret: string;
12
+ token: string;
13
+ };
14
+ export type GitHubAppAuthenticationWithExpirationEnabled = GitHubAppAuthenticationWithExpirationDisabled & {
15
+ expiresAt: string;
16
+ };
17
+ export type GitHubAppAuthenticationWithRefreshToken = GitHubAppAuthenticationWithExpirationEnabled & {
18
+ refreshToken: string;
19
+ refreshTokenExpiresAt: string;
20
+ };
21
+ /**
22
+ * @deprecated Use `GitHubAppAuthenticationWithExpirationDisabled` or
23
+ * `GitHubAppAuthenticationWithExpirationEnabled` instead.
24
+ */
25
+ export type GitHubAppAuthentication = {
26
+ clientType: "github-app";
27
+ clientId: string;
28
+ clientSecret: string;
29
+ token: string;
30
+ };
31
+ /**
32
+ * @deprecated Use `GitHubAppAuthenticationWithRefreshToken` instead.
33
+ */
34
+ export type GitHubAppAuthenticationWithExpiration = {
35
+ clientType: "github-app";
36
+ clientId: string;
37
+ clientSecret: string;
38
+ token: string;
39
+ refreshToken: string;
40
+ expiresAt: string;
41
+ refreshTokenExpiresAt: string;
42
+ };
43
+ export type OAuthAppCreateTokenResponseData = {
44
+ access_token: string;
45
+ scope: string;
46
+ token_type: "bearer";
47
+ };
48
+ export type GitHubAppCreateTokenResponseData = {
49
+ access_token: string;
50
+ token_type: "bearer";
51
+ };
52
+ export type GitHubAppCreateTokenWithExpirationResponseData = {
53
+ access_token: string;
54
+ token_type: "bearer";
55
+ expires_in: number;
56
+ refresh_token: string;
57
+ refresh_token_expires_in: number;
58
+ };
@@ -0,0 +1,3 @@
1
+ import type { RequestInterface } from "@octokit/types";
2
+ export declare function requestToOAuthBaseUrl(request: RequestInterface): string;
3
+ export declare function oauthRequest(request: RequestInterface, route: string, parameters: Record<string, unknown>): Promise<import("@octokit/types").OctokitResponse<any, number>>;
@@ -0,0 +1 @@
1
+ export declare const VERSION = "6.0.2";
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@depup/octokit__oauth-methods",
3
+ "type": "module",
4
+ "version": "6.0.2-depup.0",
5
+ "description": "[DepUp] Set of stateless request methods to create, check, reset, refresh, and delete user access tokens for OAuth and GitHub Apps",
6
+ "repository": "https://github.com/octokit/oauth-methods.js",
7
+ "keywords": [
8
+ "depup",
9
+ "dependency-bumped",
10
+ "updated-deps",
11
+ "@octokit/oauth-methods",
12
+ "github",
13
+ "api",
14
+ "sdk",
15
+ "toolkit",
16
+ "oauth"
17
+ ],
18
+ "author": "Gregor Martynus (https://dev.to/gr2m)",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "@octokit/oauth-authorization-url": "^8.0.0",
22
+ "@octokit/request": "^10.0.8",
23
+ "@octokit/request-error": "^7.1.0",
24
+ "@octokit/types": "^16.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@octokit/tsconfig": "^4.0.0",
28
+ "@types/node": "^24.0.0",
29
+ "@vitest/coverage-v8": "^3.0.0",
30
+ "esbuild": "^0.25.0",
31
+ "fetch-mock": "^11.0.0",
32
+ "glob": "^11.0.0",
33
+ "prettier": "3.5.3",
34
+ "semantic-release-plugin-update-version-in-files": "^2.0.0",
35
+ "typescript": "^5.0.0",
36
+ "vitest": "^3.0.0"
37
+ },
38
+ "engines": {
39
+ "node": ">= 20"
40
+ },
41
+ "files": [
42
+ "dist-*/**",
43
+ "bin/**",
44
+ "changes.json",
45
+ "README.md"
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
+ "depup": {
57
+ "changes": {
58
+ "@octokit/request": {
59
+ "from": "^10.0.6",
60
+ "to": "^10.0.8"
61
+ },
62
+ "@octokit/request-error": {
63
+ "from": "^7.0.2",
64
+ "to": "^7.1.0"
65
+ }
66
+ },
67
+ "depsUpdated": 2,
68
+ "originalPackage": "@octokit/oauth-methods",
69
+ "originalVersion": "6.0.2",
70
+ "processedAt": "2026-03-17T16:33:33.969Z",
71
+ "smokeTest": "passed"
72
+ }
73
+ }