First upload version 0.0.1
This commit is contained in:
40
node_modules/@octokit/oauth-app/dist-src/methods/refresh-token.js
generated
vendored
Normal file
40
node_modules/@octokit/oauth-app/dist-src/methods/refresh-token.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import * as OAuthMethods from "@octokit/oauth-methods";
|
||||
import { emitEvent } from "../emit-event.js";
|
||||
import { createOAuthUserAuth } from "@octokit/auth-oauth-user";
|
||||
async function refreshTokenWithState(state, options) {
|
||||
if (state.clientType === "oauth-app") {
|
||||
throw new Error(
|
||||
"[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps"
|
||||
);
|
||||
}
|
||||
const response = await OAuthMethods.refreshToken({
|
||||
clientType: "github-app",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
request: state.octokit.request,
|
||||
refreshToken: options.refreshToken
|
||||
});
|
||||
const authentication = Object.assign(response.authentication, {
|
||||
type: "token",
|
||||
tokenType: "oauth"
|
||||
});
|
||||
await emitEvent(state, {
|
||||
name: "token",
|
||||
action: "refreshed",
|
||||
token: response.authentication.token,
|
||||
authentication,
|
||||
octokit: new state.Octokit({
|
||||
authStrategy: createOAuthUserAuth,
|
||||
auth: {
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
token: response.authentication.token
|
||||
}
|
||||
})
|
||||
});
|
||||
return { ...response, authentication };
|
||||
}
|
||||
export {
|
||||
refreshTokenWithState
|
||||
};
|
||||
Reference in New Issue
Block a user