@octokit/oauth-app
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -12,5 +12,6 @@ 'use strict'; | ||
var request = require('@octokit/request'); | ||
var btoa = _interopDefault(require('btoa-lite')); | ||
var fromEntries = _interopDefault(require('fromentries')); | ||
const VERSION = "1.0.0"; | ||
const VERSION = "1.0.1"; | ||
@@ -109,3 +110,3 @@ function addEventHandler(state, eventName, eventHandler) { | ||
async function createTokenWithAuth(auth, options) { | ||
// @ts-ignore fix return value for state.octokit.auth() | ||
// @ts-ignore fix return types for auth() | ||
const { | ||
@@ -159,6 +160,3 @@ token, | ||
data | ||
} = await request("POST /applications/:client_id/token", { | ||
client_id: options.clientId, | ||
access_token: options.token | ||
}); | ||
} = await request("POST /applications/:client_id/token", options); | ||
return data; | ||
@@ -168,9 +166,17 @@ } | ||
async function checkToken(options) { | ||
return sendCheckTokenRequest(request.request, options); | ||
const request$1 = request.request.defaults({ | ||
headers: { | ||
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}` | ||
} | ||
}); | ||
return sendCheckTokenRequest(request$1, { | ||
client_id: options.clientId, | ||
access_token: options.token | ||
}); | ||
} | ||
function checkTokenWithState(state, options) { | ||
return sendCheckTokenRequest(state.octokit.request, Object.assign({ | ||
clientId: state.clientId, | ||
clientSecret: state.clientSecret | ||
}, options)); | ||
return sendCheckTokenRequest(state.octokit.request, { | ||
client_id: state.clientId, | ||
access_token: options.token | ||
}); | ||
} | ||
@@ -187,7 +193,4 @@ | ||
const request$1 = request.request.defaults({ | ||
request: { | ||
hook: authOauthApp.createOAuthAppAuth({ | ||
clientId: options.clientId, | ||
clientSecret: options.clientSecret | ||
}).hook | ||
headers: { | ||
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}` | ||
} | ||
@@ -230,7 +233,4 @@ }); | ||
const request$1 = request.request.defaults({ | ||
request: { | ||
hook: authOauthApp.createOAuthAppAuth({ | ||
clientId: options.clientId, | ||
clientSecret: options.clientSecret | ||
}).hook | ||
headers: { | ||
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}` | ||
} | ||
@@ -237,0 +237,0 @@ }); |
import { request as defaultRequest } from "@octokit/request"; | ||
import btoa from "btoa-lite"; | ||
async function sendCheckTokenRequest(request, options) { | ||
const { data } = await request("POST /applications/:client_id/token", { | ||
const { data } = await request("POST /applications/:client_id/token", options); | ||
return data; | ||
} | ||
export async function checkToken(options) { | ||
const request = defaultRequest.defaults({ | ||
headers: { | ||
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}` | ||
} | ||
}); | ||
return sendCheckTokenRequest(request, { | ||
client_id: options.clientId, | ||
access_token: options.token | ||
}); | ||
return data; | ||
} | ||
export async function checkToken(options) { | ||
return sendCheckTokenRequest(defaultRequest, options); | ||
} | ||
export function checkTokenWithState(state, options) { | ||
return sendCheckTokenRequest(state.octokit.request, Object.assign({ | ||
clientId: state.clientId, | ||
clientSecret: state.clientSecret | ||
}, options)); | ||
return sendCheckTokenRequest(state.octokit.request, { | ||
client_id: state.clientId, | ||
access_token: options.token | ||
}); | ||
} |
import { createOAuthAppAuth } from "@octokit/auth-oauth-app"; | ||
import { emitEvent } from "../emit-event"; | ||
async function createTokenWithAuth(auth, options) { | ||
// @ts-ignore fix return value for state.octokit.auth() | ||
// @ts-ignore fix return types for auth() | ||
const { token, scopes } = await auth({ | ||
@@ -6,0 +6,0 @@ type: "token", |
@@ -1,3 +0,3 @@ | ||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app"; | ||
import { request as defaultRequest } from "@octokit/request"; | ||
import btoa from "btoa-lite"; | ||
import { emitEvent } from "../emit-event"; | ||
@@ -10,7 +10,4 @@ async function sendDeleteTokenRequest(request, options) { | ||
const request = defaultRequest.defaults({ | ||
request: { | ||
hook: createOAuthAppAuth({ | ||
clientId: options.clientId, | ||
clientSecret: options.clientSecret | ||
}).hook | ||
headers: { | ||
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}` | ||
} | ||
@@ -17,0 +14,0 @@ }); |
@@ -1,3 +0,3 @@ | ||
import { createOAuthAppAuth } from "@octokit/auth-oauth-app"; | ||
import { request as defaultRequest } from "@octokit/request"; | ||
import btoa from "btoa-lite"; | ||
import { emitEvent } from "../emit-event"; | ||
@@ -10,7 +10,4 @@ async function sendResetTokenRequest(request, options) { | ||
const request = defaultRequest.defaults({ | ||
request: { | ||
hook: createOAuthAppAuth({ | ||
clientId: options.clientId, | ||
clientSecret: options.clientSecret | ||
}).hook | ||
headers: { | ||
authorization: `basic ${btoa(`${options.clientId}:${options.clientSecret}`)}` | ||
} | ||
@@ -17,0 +14,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "1.0.0"; | ||
export const VERSION = "1.0.1"; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.0.0"; | ||
export declare const VERSION = "1.0.1"; |
{ | ||
"name": "@octokit/oauth-app", | ||
"description": "GitHub OAuth toolset for Node.js", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -23,2 +23,4 @@ "files": [ | ||
"@octokit/oauth-authorization-url": "^4.0.0", | ||
"@types/btoa-lite": "^1.0.0", | ||
"btoa-lite": "^1.0.0", | ||
"fromentries": "^1.2.0", | ||
@@ -25,0 +27,0 @@ "universal-user-agent": "^4.0.0" |
@@ -15,2 +15,3 @@ # oauth-app.js | ||
- [Usage](#usage) | ||
- [Examples](#examples) | ||
- [Constructor options](#constructor-options) | ||
@@ -85,2 +86,6 @@ - [`app.on(eventName, eventHandler)`](#apponeventname-eventhandler) | ||
## Examples | ||
- Simple Node server with the default OAuth routes as well as static files served from a `public/` folder: https://glitch.com/~github-oauth-client | ||
## Constructor options | ||
@@ -87,0 +92,0 @@ |
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
105387
1273
7
+ Added@types/btoa-lite@^1.0.0
+ Addedbtoa-lite@^1.0.0