|
2 | 2 | // THIS CODE IS NOT EXECUTED. IT IS JUST FOR TYPECHECKING |
3 | 3 | // ************************************************************ |
4 | 4 |
|
| 5 | +import { getAppAuthentication } from "../src/get-app-authentication.js"; |
| 6 | +import { request } from "@octokit/request"; |
5 | 7 | import { createAppAuth } from "../src/index.js"; |
| 8 | +import { State, StrategyOptions } from "../src/types.js"; |
| 9 | +import { getCache } from "../src/cache.js"; |
| 10 | +import { createOAuthAppAuth } from "@octokit/auth-oauth-app"; |
6 | 11 | function isString(what: string) {} |
7 | 12 |
|
8 | 13 | export async function readmeExample() { |
@@ -31,3 +36,40 @@ export async function issue282() { |
31 | 36 |
|
32 | 37 | isString(authentication.token); |
33 | 38 | } |
| 39 | + |
| 40 | +// https://github.com/octokit/auth-app.js/issues/603 |
| 41 | +export async function issue603() { |
| 42 | + createAppAuth({ |
| 43 | + appId: "Iv1.0123456789abcdef", |
| 44 | + privateKey: "", |
| 45 | + }); |
| 46 | + |
| 47 | + const options: StrategyOptions = { |
| 48 | + appId: "Iv1.0123456789abcdef", |
| 49 | + privateKey: "", |
| 50 | + }; |
| 51 | + |
| 52 | + const state: State = Object.assign( |
| 53 | + { |
| 54 | + request, |
| 55 | + cache: getCache(), |
| 56 | + }, |
| 57 | + options, |
| 58 | + options.installationId |
| 59 | + ? { installationId: Number(options.installationId) } |
| 60 | + : {}, |
| 61 | + { |
| 62 | + log: { |
| 63 | + warn: console.warn.bind(console), |
| 64 | + }, |
| 65 | + oauthApp: createOAuthAppAuth({ |
| 66 | + clientType: "github-app", |
| 67 | + clientId: options.clientId || "", |
| 68 | + clientSecret: options.clientSecret || "", |
| 69 | + request, |
| 70 | + }), |
| 71 | + }, |
| 72 | + ); |
| 73 | + |
| 74 | + getAppAuthentication(state); |
| 75 | +} |
0 commit comments