piral-oauth2
Advanced tools
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createOAuth2Api = void 0; | ||
/** | ||
@@ -4,0 +5,0 @@ * Creates new Pilet API extensions for the integration of OAuth 2.0. |
@@ -6,2 +6,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./setup"), exports); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setupOAuth2Client = void 0; | ||
var ClientOAuth2 = require("client-oauth2"); | ||
@@ -4,0 +5,0 @@ var callbackName = 'oauth2Cb'; |
{ | ||
"name": "piral-oauth2", | ||
"version": "1.0.0-pre.1742", | ||
"version": "1.0.0-pre.1758", | ||
"description": "Plugin to integrate OAuth 2.0 authentication in Piral.", | ||
@@ -45,8 +45,8 @@ "keywords": [ | ||
"devDependencies": { | ||
"piral-core": "^1.0.0-pre.1742" | ||
"piral-core": "^1.0.0-pre.1758" | ||
}, | ||
"peerDependencies": { | ||
"piral-core": "^1.0.0" | ||
"piral-core": "0.12.x || 1.x" | ||
}, | ||
"gitHead": "256e47bf1a506ea653e2bf53932154f717fd2787" | ||
"gitHead": "b73ae118f029dfa6ea6c24be553e490869bd21b6" | ||
} |
@@ -9,3 +9,3 @@ import { PiralPlugin } from 'piral-core'; | ||
export function createOAuth2Api(client: OAuth2Client): PiralPlugin<PiralOAuth2Api> { | ||
return context => { | ||
return (context) => { | ||
context.on('before-fetch', client.extendHeaders); | ||
@@ -12,0 +12,0 @@ |
@@ -100,3 +100,3 @@ import * as ClientOAuth2 from 'client-oauth2'; | ||
client.code.getToken(location.href).then( | ||
token => (currentToken = token), | ||
(token) => (currentToken = token), | ||
() => {}, | ||
@@ -114,3 +114,3 @@ ); | ||
return currentToken.refresh().then(refreshedToken => { | ||
return currentToken.refresh().then((refreshedToken) => { | ||
currentToken = refreshedToken; | ||
@@ -132,3 +132,3 @@ return currentToken.accessToken; | ||
retrieveToken().then( | ||
token => token && { Authorization: `Bearer ${token}` }, | ||
(token) => token && { Authorization: `Bearer ${token}` }, | ||
() => undefined, | ||
@@ -143,3 +143,3 @@ ), | ||
client.token.getToken(location.href).then( | ||
token => { | ||
(token) => { | ||
const opener = window.opener; | ||
@@ -164,3 +164,3 @@ if (opener && typeof opener[callbackName] === 'function') { | ||
return new Promise<string>(res => { | ||
return new Promise<string>((res) => { | ||
window[callbackName] = (token: ClientOAuth2.Token) => { | ||
@@ -185,3 +185,3 @@ currentToken = token; | ||
retrieveToken().then( | ||
token => token && { Authorization: `Bearer ${token}` }, | ||
(token) => token && { Authorization: `Bearer ${token}` }, | ||
() => undefined, | ||
@@ -188,0 +188,0 @@ ), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21328
1.49%409
0.74%