@octokit/oauth-app
Advanced tools
Comparing version 3.3.4 to 3.3.5
@@ -68,3 +68,3 @@ 'use strict'; | ||
const VERSION = "3.3.4"; | ||
const VERSION = "3.3.5"; | ||
@@ -91,2 +91,21 @@ function addEventHandler(state, eventName, eventHandler) { | ||
async function emitEvent(state, context) { | ||
const { | ||
name, | ||
action | ||
} = context; | ||
if (state.eventHandlers[`${name}.${action}`]) { | ||
for (const eventHandler of state.eventHandlers[`${name}.${action}`]) { | ||
await eventHandler(context); | ||
} | ||
} | ||
if (state.eventHandlers[name]) { | ||
for (const eventHandler of state.eventHandlers[name]) { | ||
await eventHandler(context); | ||
} | ||
} | ||
} | ||
async function getUserOctokitWithState(state, options) { | ||
@@ -96,7 +115,19 @@ return state.octokit.auth(_objectSpread2(_objectSpread2({ | ||
}, options), {}, { | ||
factory(options) { | ||
return new state.Octokit({ | ||
async factory(options) { | ||
const octokit = new state.Octokit({ | ||
authStrategy: authOauthUser.createOAuthUserAuth, | ||
auth: options | ||
}); | ||
const authentication = await octokit.auth({ | ||
type: "get" | ||
}); | ||
await emitEvent(state, { | ||
name: "token", | ||
action: "created", | ||
token: authentication.token, | ||
scopes: authentication.scopes, | ||
authentication, | ||
octokit | ||
}); | ||
return octokit; | ||
} | ||
@@ -121,21 +152,2 @@ | ||
async function emitEvent(state, context) { | ||
const { | ||
name, | ||
action | ||
} = context; | ||
if (state.eventHandlers[`${name}.${action}`]) { | ||
for (const eventHandler of state.eventHandlers[`${name}.${action}`]) { | ||
await eventHandler(context); | ||
} | ||
} | ||
if (state.eventHandlers[name]) { | ||
for (const eventHandler of state.eventHandlers[name]) { | ||
await eventHandler(context); | ||
} | ||
} | ||
} | ||
async function createTokenWithState(state, options) { | ||
@@ -142,0 +154,0 @@ const authentication = await state.octokit.auth(_objectSpread2({ |
import { createOAuthUserAuth, } from "@octokit/auth-oauth-user"; | ||
import { emitEvent } from "../emit-event"; | ||
export async function getUserOctokitWithState(state, options) { | ||
@@ -6,9 +7,21 @@ return state.octokit.auth({ | ||
...options, | ||
factory(options) { | ||
return new state.Octokit({ | ||
async factory(options) { | ||
const octokit = new state.Octokit({ | ||
authStrategy: createOAuthUserAuth, | ||
auth: options, | ||
}); | ||
const authentication = (await octokit.auth({ | ||
type: "get", | ||
})); | ||
await emitEvent(state, { | ||
name: "token", | ||
action: "created", | ||
token: authentication.token, | ||
scopes: authentication.scopes, | ||
authentication, | ||
octokit, | ||
}); | ||
return octokit; | ||
}, | ||
}); | ||
} |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "3.3.4"; | ||
export const VERSION = "3.3.5"; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "3.3.4"; | ||
export declare const VERSION = "3.3.5"; |
{ | ||
"name": "@octokit/oauth-app", | ||
"description": "GitHub OAuth toolset for Node.js", | ||
"version": "3.3.4", | ||
"version": "3.3.5", | ||
"license": "MIT", | ||
@@ -21,3 +21,3 @@ "files": [ | ||
"@octokit/auth-oauth-app": "^4.0.0", | ||
"@octokit/auth-oauth-user": "^1.2.3", | ||
"@octokit/auth-oauth-user": "^1.3.0", | ||
"@octokit/auth-unauthenticated": "^2.0.0", | ||
@@ -24,0 +24,0 @@ "@octokit/core": "^3.3.2", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134919
1510