First upload version 0.0.1
This commit is contained in:
50
node_modules/@octokit/auth-oauth-user/dist-src/get-authentication.js
generated
vendored
Normal file
50
node_modules/@octokit/auth-oauth-user/dist-src/get-authentication.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
||||
import { exchangeWebFlowCode } from "@octokit/oauth-methods";
|
||||
async function getAuthentication(state) {
|
||||
if ("code" in state.strategyOptions) {
|
||||
const { authentication } = await exchangeWebFlowCode({
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions,
|
||||
request: state.request
|
||||
});
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
...authentication
|
||||
};
|
||||
}
|
||||
if ("onVerification" in state.strategyOptions) {
|
||||
const deviceAuth = createOAuthDeviceAuth({
|
||||
clientType: state.clientType,
|
||||
clientId: state.clientId,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions,
|
||||
request: state.request
|
||||
});
|
||||
const authentication = await deviceAuth({
|
||||
type: "oauth"
|
||||
});
|
||||
return {
|
||||
clientSecret: state.clientSecret,
|
||||
...authentication
|
||||
};
|
||||
}
|
||||
if ("token" in state.strategyOptions) {
|
||||
return {
|
||||
type: "token",
|
||||
tokenType: "oauth",
|
||||
clientId: state.clientId,
|
||||
clientSecret: state.clientSecret,
|
||||
clientType: state.clientType,
|
||||
onTokenCreated: state.onTokenCreated,
|
||||
...state.strategyOptions
|
||||
};
|
||||
}
|
||||
throw new Error("[@octokit/auth-oauth-user] Invalid strategy options");
|
||||
}
|
||||
export {
|
||||
getAuthentication
|
||||
};
|
||||
Reference in New Issue
Block a user