piral-oauth2 1.0.0-pre.2217 → 1.0.1-beta.5640

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/setup.d.ts CHANGED
@@ -1,72 +1,4 @@
1
- /**
2
- * Available configuration options for the OAuth 2.0 plugin.
3
- */
4
- export interface OAuth2Config {
5
- /**
6
- * The id of the client. Required for the setup of OAuth 2.0.
7
- */
8
- clientId: string;
9
- /**
10
- * The client secret. Only required for the `code` flow.
11
- */
12
- clientSecret?: string;
13
- /**
14
- * The Uri pointing to the authorization endpoint of the Identity Provider.
15
- */
16
- authorizationUri: string;
17
- /**
18
- * The Uri pointing to the access token endpoint of the Identity Provider.
19
- */
20
- accessTokenUri?: string;
21
- /**
22
- * The redirect Uri to use. By default the origin with /auth
23
- * is used.
24
- */
25
- redirectUri?: string;
26
- /**
27
- * The scopes to be used.
28
- */
29
- scopes?: Array<string>;
30
- /**
31
- * The OAuth 2.0 authorization flow type to be used.
32
- */
33
- flow?: 'implicit' | 'code';
34
- /**
35
- * Restricts token sharing such that other integrations, e.g., with
36
- * fetch would need to be done manually.
37
- * Otherwise, the client is responsive to the `before-fetch` event.
38
- */
39
- restrict?: boolean;
40
- }
41
- export interface OAuth2Request {
42
- /**
43
- * Sets the headers of the request.
44
- * @param headers Headers or a promise to headers.
45
- */
46
- setHeaders(headers: any): void;
47
- }
48
- export interface OAuth2Client {
49
- /**
50
- * Performs a login.
51
- */
52
- login(): void;
53
- /**
54
- * Performs a logout.
55
- */
56
- logout(): void;
57
- /**
58
- * Gets a token.
59
- */
60
- token(): Promise<string>;
61
- /**
62
- * Checks if the user is currently logged in.
63
- */
64
- account(): boolean;
65
- /**
66
- * Extends the headers of the provided request.
67
- */
68
- extendHeaders(req: OAuth2Request): void;
69
- }
1
+ import { OAuth2Config, OAuth2Client } from './types';
70
2
  /**
71
3
  * Sets up a new client wrapping the OAuth 2.0 API.
72
4
  * @param config The configuration for the client.
package/lib/setup.js CHANGED
@@ -1,80 +1,104 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupOAuth2Client = void 0;
4
- var ClientOAuth2 = require("client-oauth2");
5
- var callbackName = 'oauth2Cb';
4
+ const tslib_1 = require("tslib");
5
+ const client_oauth2_1 = tslib_1.__importDefault(require("client-oauth2"));
6
+ const utils_1 = require("./utils");
7
+ const callbackName = 'oauth2Cb';
6
8
  /**
7
9
  * Sets up a new client wrapping the OAuth 2.0 API.
8
10
  * @param config The configuration for the client.
9
11
  */
10
12
  function setupOAuth2Client(config) {
11
- var clientId = config.clientId, clientSecret = config.clientSecret, authorizationUri = config.authorizationUri, accessTokenUri = config.accessTokenUri, _a = config.redirectUri, redirectUri = _a === void 0 ? location.origin + "/auth" : _a, _b = config.scopes, scopes = _b === void 0 ? [] : _b, flow = config.flow, _c = config.restrict, restrict = _c === void 0 ? false : _c;
12
- var client = new ClientOAuth2({
13
- clientId: clientId,
14
- clientSecret: clientSecret,
15
- redirectUri: redirectUri,
16
- authorizationUri: authorizationUri,
17
- accessTokenUri: accessTokenUri,
18
- scopes: scopes,
13
+ const { clientId, clientSecret, authorizationUri, accessTokenUri, redirectUri = `${location.origin}/auth`, scopes = [], flow, headers, query, state, restrict = false, returnPath = '/', persist = (0, utils_1.createOAuth2MemoryPersistence)(), } = config;
14
+ const client = new client_oauth2_1.default({
15
+ clientId,
16
+ clientSecret,
17
+ redirectUri,
18
+ authorizationUri,
19
+ accessTokenUri,
20
+ scopes,
21
+ headers,
22
+ query,
23
+ state,
19
24
  });
20
- var currentToken;
21
- var retrieveToken;
22
- var getLoginUri;
23
- if (flow === 'code') {
24
- client.code.getToken(location.href).then(function (token) { return (currentToken = token); }, function () { });
25
- retrieveToken = function () {
25
+ let currentToken;
26
+ let retrieveToken;
27
+ let getLoginUri;
28
+ const setCurrentToken = (token) => {
29
+ persist.save({
30
+ accessToken: token.accessToken,
31
+ data: token.data,
32
+ refreshToken: token.refreshToken,
33
+ });
34
+ currentToken = token;
35
+ };
36
+ const retrieve = (init, refresh) => {
37
+ return init.then(() => {
26
38
  if (!currentToken) {
27
39
  return Promise.reject('Not logged in. Please call `login()` to retrieve a token.');
28
40
  }
29
41
  if (!currentToken.expired()) {
30
- return Promise.resolve(currentToken.accessToken);
42
+ return currentToken.accessToken;
31
43
  }
32
- return currentToken.refresh().then(function (refreshedToken) {
33
- currentToken = refreshedToken;
44
+ return refresh().then((refreshedToken) => {
45
+ setCurrentToken(refreshedToken);
34
46
  return currentToken.accessToken;
35
47
  });
48
+ });
49
+ };
50
+ const initialize = (load) => {
51
+ const info = persist.load();
52
+ if (info) {
53
+ currentToken = client.createToken(info.accessToken, info.refreshToken, info.data);
54
+ return Promise.resolve();
55
+ }
56
+ else {
57
+ return load().then((token) => {
58
+ const opener = window.opener;
59
+ setCurrentToken(token);
60
+ if (opener && typeof opener[callbackName] === 'function') {
61
+ opener[callbackName](token);
62
+ window.close();
63
+ }
64
+ }, () => { });
65
+ }
66
+ };
67
+ if (flow === 'code') {
68
+ const init = initialize(() => {
69
+ const url = location.href;
70
+ history.replaceState(undefined, undefined, returnPath);
71
+ return client.code.getToken(url);
72
+ });
73
+ retrieveToken = () => {
74
+ return retrieve(init, () => currentToken.refresh());
36
75
  };
37
- getLoginUri = function () { return client.code.getUri(); };
76
+ getLoginUri = () => client.code.getUri();
38
77
  }
39
78
  else {
40
- client.token.getToken(location.href).then(function (token) {
41
- var opener = window.opener;
42
- if (opener && typeof opener[callbackName] === 'function') {
43
- opener[callbackName](token);
44
- window.close();
45
- }
46
- currentToken = token;
47
- }, function () { });
48
- retrieveToken = function () {
49
- if (!currentToken) {
50
- return Promise.reject('Not logged in. Please call `login()` to retrieve a token.');
51
- }
52
- if (!currentToken.expired()) {
53
- return Promise.resolve(currentToken.accessToken);
54
- }
55
- return new Promise(function (res) {
56
- window[callbackName] = function (token) {
57
- currentToken = token;
58
- res(currentToken.accessToken);
59
- };
79
+ const init = initialize(() => client.token.getToken(location.href));
80
+ retrieveToken = () => {
81
+ return retrieve(init, () => new Promise((resolve) => {
82
+ window[callbackName] = resolve;
60
83
  window.open(client.token.getUri());
61
- });
84
+ }));
62
85
  };
63
- getLoginUri = function () { return client.token.getUri(); };
86
+ getLoginUri = () => client.token.getUri();
64
87
  }
65
88
  return {
66
- login: function () {
89
+ _: client,
90
+ login() {
67
91
  window.location.href = getLoginUri();
68
92
  },
69
- logout: function () {
93
+ logout() {
70
94
  currentToken = undefined;
71
95
  },
72
- extendHeaders: function (req) {
96
+ extendHeaders(req) {
73
97
  if (!restrict) {
74
- req.setHeaders(retrieveToken().then(function (token) { return token && { Authorization: "Bearer " + token }; }, function () { return undefined; }));
98
+ req.setHeaders(retrieveToken().then((token) => token && { Authorization: `Bearer ${token}` }, () => undefined));
75
99
  }
76
100
  },
77
- account: function () {
101
+ account() {
78
102
  return !!currentToken;
79
103
  },
80
104
  token: retrieveToken,
package/lib/setup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AA0E9C,IAAM,YAAY,GAAG,UAAU,CAAC;AAEhC;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,MAAoB;IAElD,IAAA,QAAQ,GAQN,MAAM,SARA,EACR,YAAY,GAOV,MAAM,aAPI,EACZ,gBAAgB,GAMd,MAAM,iBANQ,EAChB,cAAc,GAKZ,MAAM,eALM,EACd,KAIE,MAAM,YAJ+B,EAAvC,WAAW,mBAAM,QAAQ,CAAC,MAAM,UAAO,KAAA,EACvC,KAGE,MAAM,OAHG,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,IAAI,GAEF,MAAM,KAFJ,EACJ,KACE,MAAM,SADQ,EAAhB,QAAQ,mBAAG,KAAK,KAAA,CACP;IACX,IAAM,MAAM,GAAG,IAAI,YAAY,CAAC;QAC9B,QAAQ,UAAA;QACR,YAAY,cAAA;QACZ,WAAW,aAAA;QACX,gB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Aa;KACrB,CAAC;AACJ,CAAC;AArID,8CAqIC"}
package/lib/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Data } from 'client-oauth2';
1
2
  declare module 'piral-core/lib/types/custom' {
2
3
  interface PiletCustomApi extends PiralOAuth2Api {
3
4
  }
@@ -8,3 +9,119 @@ export interface PiralOAuth2Api {
8
9
  */
9
10
  getAccessToken(): Promise<string | undefined>;
10
11
  }
12
+ /**
13
+ * The relevant OAuth 2 token information.
14
+ */
15
+ export interface OAuth2TokenInfo {
16
+ accessToken: string;
17
+ refreshToken: string;
18
+ data: Data;
19
+ }
20
+ /**
21
+ * Available configuration options for the OAuth 2 plugin.
22
+ */
23
+ export interface OAuth2Config {
24
+ /**
25
+ * The id of the client. Required for the setup of OAuth 2.
26
+ */
27
+ clientId: string;
28
+ /**
29
+ * The client secret. Only required for the `code` flow.
30
+ */
31
+ clientSecret?: string;
32
+ /**
33
+ * The Uri pointing to the authorization endpoint of the Identity Provider.
34
+ */
35
+ authorizationUri: string;
36
+ /**
37
+ * The Uri pointing to the access token endpoint of the Identity Provider.
38
+ */
39
+ accessTokenUri?: string;
40
+ /**
41
+ * The redirect Uri to use. By default the origin with /auth
42
+ * is used.
43
+ */
44
+ redirectUri?: string;
45
+ /**
46
+ * The return path to use in case of the "code" flow. By default the
47
+ * path will be set to "/".
48
+ */
49
+ returnPath?: string;
50
+ /**
51
+ * The scopes to be used.
52
+ */
53
+ scopes?: Array<string>;
54
+ /**
55
+ * The OAuth 2 authorization flow type to be used.
56
+ */
57
+ flow?: 'implicit' | 'code';
58
+ /**
59
+ * Restricts token sharing such that other integrations, e.g., with
60
+ * fetch would need to be done manually.
61
+ * Otherwise, the client is responsive to the `before-fetch` event.
62
+ */
63
+ restrict?: boolean;
64
+ /**
65
+ * Optional persistence layer for OAuth 2. By default nothing is stored.
66
+ */
67
+ persist?: OAuth2Persistence;
68
+ /**
69
+ * The optional headers to supply in OAuth 2 requests.
70
+ */
71
+ headers?: Record<string, string | Array<string>>;
72
+ /**
73
+ * The optional query parameters to supply in OAuth 2 requests.
74
+ */
75
+ query?: Record<string, string | Array<string>>;
76
+ /**
77
+ * The optional state parameter to supply in OAuth 2 requests.
78
+ */
79
+ state?: string;
80
+ }
81
+ export interface OAuth2Request {
82
+ /**
83
+ * Sets the headers of the request.
84
+ * @param headers Headers or a promise to headers.
85
+ */
86
+ setHeaders(headers: any): void;
87
+ }
88
+ export interface OAuth2Client {
89
+ /**
90
+ * The underlying OAuth2 client.
91
+ */
92
+ _: any;
93
+ /**
94
+ * Performs a login.
95
+ */
96
+ login(): void;
97
+ /**
98
+ * Performs a logout.
99
+ */
100
+ logout(): void;
101
+ /**
102
+ * Gets a token.
103
+ */
104
+ token(): Promise<string>;
105
+ /**
106
+ * Checks if the user is currently logged in.
107
+ */
108
+ account(): boolean;
109
+ /**
110
+ * Extends the headers of the provided request.
111
+ */
112
+ extendHeaders(req: OAuth2Request): void;
113
+ }
114
+ /**
115
+ * Defines the interface for the OAuth 2 persistence layer.
116
+ */
117
+ export interface OAuth2Persistence {
118
+ /**
119
+ * Loads an OAuth 2 token structure.
120
+ */
121
+ load(): OAuth2TokenInfo;
122
+ /**
123
+ * Stores an OAuth 2 token structure.
124
+ * @param info The token infos to store.
125
+ */
126
+ save(info: OAuth2TokenInfo): void;
127
+ }
package/lib/utils.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { OAuth2Persistence } from './types';
2
+ /**
3
+ * Creates an OAuth 2 persistence layer using memory.
4
+ */
5
+ export declare function createOAuth2MemoryPersistence(): OAuth2Persistence;
6
+ /**
7
+ * Creates an OAuth 2 persistence layer using sessionStorage.
8
+ */
9
+ export declare function createOAuth2SessionPersistence(sessionKey?: string): OAuth2Persistence;
10
+ /**
11
+ * Creates an OAuth 2 persistence layer using localStorage.
12
+ */
13
+ export declare function createOAuth2BrowserPersistence(localKey?: string): OAuth2Persistence;
package/lib/utils.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOAuth2BrowserPersistence = exports.createOAuth2SessionPersistence = exports.createOAuth2MemoryPersistence = void 0;
4
+ /**
5
+ * Creates an OAuth 2 persistence layer using memory.
6
+ */
7
+ function createOAuth2MemoryPersistence() {
8
+ return {
9
+ load() {
10
+ return undefined;
11
+ },
12
+ save() { },
13
+ };
14
+ }
15
+ exports.createOAuth2MemoryPersistence = createOAuth2MemoryPersistence;
16
+ /**
17
+ * Creates an OAuth 2 persistence layer using sessionStorage.
18
+ */
19
+ function createOAuth2SessionPersistence(sessionKey = '$piral_oauth2_info') {
20
+ return {
21
+ load() {
22
+ const content = sessionStorage.getItem(sessionKey);
23
+ if (typeof content === 'string') {
24
+ try {
25
+ return JSON.parse(content);
26
+ }
27
+ catch (_a) {
28
+ console.error('Found invalid data in the OAuth 2 session storage key. Skipped.');
29
+ }
30
+ }
31
+ return undefined;
32
+ },
33
+ save(info) {
34
+ sessionStorage.setItem(sessionKey, JSON.stringify(info));
35
+ },
36
+ };
37
+ }
38
+ exports.createOAuth2SessionPersistence = createOAuth2SessionPersistence;
39
+ /**
40
+ * Creates an OAuth 2 persistence layer using localStorage.
41
+ */
42
+ function createOAuth2BrowserPersistence(localKey = '$piral_oauth2_info') {
43
+ return {
44
+ load() {
45
+ const content = localStorage.getItem(localKey);
46
+ if (typeof content === 'string') {
47
+ try {
48
+ return JSON.parse(content);
49
+ }
50
+ catch (_a) {
51
+ console.error('Found invalid data in the OAuth 2 local storage key. Skipped.');
52
+ }
53
+ }
54
+ return undefined;
55
+ },
56
+ save(info) {
57
+ localStorage.setItem(localKey, JSON.stringify(info));
58
+ },
59
+ };
60
+ }
61
+ exports.createOAuth2BrowserPersistence = createOAuth2BrowserPersistence;
62
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,6BAA6B;IAC3C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 @@
1
1
  {
2
2
  "name": "piral-oauth2",
3
- "version": "1.0.0-pre.2217",
3
+ "version": "1.0.1-beta.5640",
4
4
  "description": "Plugin to integrate OAuth 2.0 authentication in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -22,11 +22,29 @@
22
22
  "module": "esm/index.js",
23
23
  "main": "lib/index.js",
24
24
  "typings": "lib/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "import": "./esm/index.js",
28
+ "require": "./lib/index.js"
29
+ },
30
+ "./esm/*": {
31
+ "import": "./esm/*"
32
+ },
33
+ "./lib/*": {
34
+ "require": "./lib/*"
35
+ },
36
+ "./_/*": {
37
+ "import": "./esm/*.js",
38
+ "require": "./lib/*.js"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
25
42
  "sideEffects": false,
26
43
  "files": [
27
44
  "esm",
28
45
  "lib",
29
- "src"
46
+ "src",
47
+ "piral-oauth2.min.js"
30
48
  ],
31
49
  "repository": {
32
50
  "type": "git",
@@ -36,7 +54,9 @@
36
54
  "url": "https://github.com/smapiot/piral/issues"
37
55
  },
38
56
  "scripts": {
39
- "build": "yarn build:commonjs && yarn build:esnext",
57
+ "cleanup": "rimraf esm lib piral-oauth2.min.js",
58
+ "build": "yarn build:bundle && yarn build:commonjs && yarn build:esnext",
59
+ "build:bundle": "esbuild src/index.ts --outfile=piral-oauth2.min.js --bundle --external:piral-core --minify --global-name=piralOAuth2",
40
60
  "build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
41
61
  "build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
42
62
  "typedoc": "typedoc --json ../../../docs/types/piral-oauth2.json src --exclude \"src/**/*.test.*\"",
@@ -46,10 +66,7 @@
46
66
  "client-oauth2": "^4.2.5"
47
67
  },
48
68
  "devDependencies": {
49
- "piral-core": "^1.0.0-pre.2217"
50
- },
51
- "peerDependencies": {
52
- "piral-core": "1.x"
69
+ "piral-core": "1.0.1-beta.5640"
53
70
  },
54
- "gitHead": "39479fee9a718f9f2fec97ce1a119fc0818805da"
71
+ "gitHead": "fa0a72b28fd0a20afec7ef491ec19e93c090fc72"
55
72
  }
@@ -0,0 +1 @@
1
+ var piralOAuth2=(()=>{var ce=Object.create;var x=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var de=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var $=e=>x(e,"__esModule",{value:!0});var y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),fe=(e,t)=>{$(e);for(var n in t)x(e,n,{get:t[n],enumerable:!0})},pe=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of he(t))!le.call(e,r)&&r!=="default"&&x(e,r,{get:()=>t[r],enumerable:!(n=ue(t,r))||n.enumerable});return e},ge=e=>pe($(x(e!=null?ce(de(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var X=y(()=>{});var Q=y((Se,K)=>{"use strict";function me(e,t){return Object.prototype.hasOwnProperty.call(e,t)}K.exports=function(e,t,n,r){t=t||"&",n=n||"=";var o={};if(typeof e!="string"||e.length===0)return o;var i=/\+/g;e=e.split(t);var s=1e3;r&&typeof r.maxKeys=="number"&&(s=r.maxKeys);var a=e.length;s>0&&a>s&&(a=s);for(var d=0;d<a;++d){var p=e[d].replace(i,"%20"),m=p.indexOf(n),T,w,l,h;m>=0?(T=p.substr(0,m),w=p.substr(m+1)):(T=p,w=""),l=decodeURIComponent(T),h=decodeURIComponent(w),me(o,l)?Array.isArray(o[l])?o[l].push(h):o[l]=[o[l],h]:o[l]=h}return o}});var V=y((Ce,G)=>{"use strict";var v=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};G.exports=function(e,t,n,r){return t=t||"&",n=n||"=",e===null&&(e=void 0),typeof e=="object"?Object.keys(e).map(function(o){var i=encodeURIComponent(v(o))+n;return Array.isArray(e[o])?e[o].map(function(s){return i+encodeURIComponent(v(s))}).join(t):i+encodeURIComponent(v(e[o]))}).filter(Boolean).join(t):r?encodeURIComponent(v(r))+n+encodeURIComponent(v(e)):""}});var W=y(k=>{"use strict";k.decode=k.parse=Q();k.encode=k.stringify=V()});var Z=y((ze,Y)=>{Y.exports=function(t,n,r,o){return new Promise(function(i,s){var a=new window.XMLHttpRequest;a.open(t,n),a.onload=function(){return i({status:a.status,body:a.responseText})},a.onerror=a.onabort=function(){return s(new Error(a.statusText||"XHR aborted: "+n))},Object.keys(o).forEach(function(d){a.setRequestHeader(d,o[d])}),a.send(r)})}});var se=y((Ee,ie)=>{var ee=X().Buffer,g=W(),Te=Z(),S="https://example.org/",R;typeof ee=="function"?R=ve:R=window.btoa.bind(window);ie.exports=_;var b={Accept:"application/json, application/x-www-form-urlencoded","Content-Type":"application/x-www-form-urlencoded"},we={invalid_request:["The request is missing a required parameter, includes an","invalid parameter value, includes a parameter more than","once, or is otherwise malformed."].join(" "),invalid_client:["Client authentication failed (e.g., unknown client, no","client authentication included, or unsupported","authentication method)."].join(" "),invalid_grant:["The provided authorization grant (e.g., authorization","code, resource owner credentials) or refresh token is","invalid, expired, revoked, does not match the redirection","URI used in the authorization request, or was issued to","another client."].join(" "),unauthorized_client:["The client is not authorized to request an authorization","code using this method."].join(" "),unsupported_grant_type:["The authorization grant type is not supported by the","authorization server."].join(" "),access_denied:["The resource owner or authorization server denied the request."].join(" "),unsupported_response_type:["The authorization server does not support obtaining","an authorization code using this method."].join(" "),invalid_scope:["The requested scope is invalid, unknown, or malformed."].join(" "),server_error:["The authorization server encountered an unexpected","condition that prevented it from fulfilling the request.","(This error code is needed because a 500 Internal Server","Error HTTP status code cannot be returned to the client","via an HTTP redirect.)"].join(" "),temporarily_unavailable:["The authorization server is currently unable to handle","the request due to a temporary overloading or maintenance","of the server."].join(" ")};function ve(e){return ee.from(e).toString("base64")}function C(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(e[n]==null)throw new TypeError('Expected "'+n+'" to exist')}}function q(e){var t=we[e.error]||e.error_description||e.error;if(t){var n=new Error(t);return n.body=e,n.code="EAUTH",n}}function ke(e){try{return JSON.parse(e)}catch{return g.parse(e)}}function I(e){return Array.isArray(e)?e.join(" "):B(e)}function te(e,t){C(e,"clientId","authorizationUri");let n={client_id:e.clientId,redirect_uri:e.redirectUri,response_type:t,state:e.state};e.scopes!==void 0&&(n.scope=I(e.scopes));let r=e.authorizationUri.includes("?")?"&":"?";return e.authorizationUri+r+g.stringify(Object.assign(n,e.query))}function O(e,t){return"Basic "+R(B(e)+":"+B(t))}function B(e){return e==null?"":String(e)}function A(e,t){return{url:e.url,method:e.method,body:Object.assign({},e.body,t.body),query:Object.assign({},e.query,t.query),headers:Object.assign({},e.headers,t.headers)}}function _(e,t){this.options=e,this.request=t||Te,this.code=new F(this),this.token=new H(this),this.owner=new re(this),this.credentials=new ne(this),this.jwt=new oe(this)}_.Token=P;_.prototype.createToken=function(e,t,n,r){var o=Object.assign({},r,typeof e=="string"?{access_token:e}:e,typeof t=="string"?{refresh_token:t}:t,typeof n=="string"?{token_type:n}:n);return new _.Token(this,o)};_.prototype._request=function(e){var t=e.url,n=g.stringify(e.body),r=g.stringify(e.query);return r&&(t+=(t.indexOf("?")===-1?"?":"&")+r),this.request(e.method,t,n,e.headers).then(function(o){var i=ke(o.body),s=q(i);if(s)return Promise.reject(s);if(o.status<200||o.status>=399){var a=new Error("HTTP status "+o.status);return a.status=o.status,a.body=o.body,a.code="ESTATUS",Promise.reject(a)}return i})};function P(e,t){this.client=e,this.data=t,this.tokenType=t.token_type&&t.token_type.toLowerCase(),this.accessToken=t.access_token,this.refreshToken=t.refresh_token,this.expiresIn(Number(t.expires_in))}P.prototype.expiresIn=function(e){if(typeof e=="number")this.expires=new Date,this.expires.setSeconds(this.expires.getSeconds()+e);else if(e instanceof Date)this.expires=new Date(e.getTime());else throw new TypeError("Unknown duration: "+e);return this.expires};P.prototype.sign=function(e){if(!this.accessToken)throw new Error("Unable to sign without access token");if(e.headers=e.headers||{},this.tokenType==="bearer")e.headers.Authorization="Bearer "+this.accessToken;else{var t=e.url.split("#"),n="access_token="+this.accessToken,r=t[0].replace(/[?&]access_token=[^&#]/,""),o=t[1]?"#"+t[1]:"";e.url=r+(r.indexOf("?")>-1?"&":"?")+n+o,e.headers.Pragma="no-store",e.headers["Cache-Control"]="no-store"}return e};P.prototype.refresh=function(e){var t=this,n=Object.assign({},this.client.options,e);return this.refreshToken?this.client._request(A({url:n.accessTokenUri,method:"POST",headers:Object.assign({},b,{Authorization:O(n.clientId,n.clientSecret)}),body:{refresh_token:this.refreshToken,grant_type:"refresh_token"}},n)).then(function(r){return t.client.createToken(Object.assign({},t.data,r))}):Promise.reject(new Error("No refresh token"))};P.prototype.expired=function(){return Date.now()>this.expires.getTime()};function re(e){this.client=e}re.prototype.getToken=function(e,t,n){var r=this,o=Object.assign({},this.client.options,n);let i={username:e,password:t,grant_type:"password"};return o.scopes!==void 0&&(i.scope=I(o.scopes)),this.client._request(A({url:o.accessTokenUri,method:"POST",headers:Object.assign({},b,{Authorization:O(o.clientId,o.clientSecret)}),body:i},o)).then(function(s){return r.client.createToken(s)})};function H(e){this.client=e}H.prototype.getUri=function(e){var t=Object.assign({},this.client.options,e);return te(t,"token")};H.prototype.getToken=function(e,t){var n=Object.assign({},this.client.options,t),r=typeof e=="object"?e:new URL(e,S),o=new URL(n.redirectUri,S);if(typeof r.pathname=="string"&&r.pathname!==o.pathname)return Promise.reject(new TypeError("Redirected path should match configured path, but got: "+r.pathname));if(!r.hash&&!r.search)return Promise.reject(new TypeError("Unable to process uri: "+e));var i=Object.assign({},typeof r.search=="string"?g.parse(r.search.substr(1)):r.search||{},typeof r.hash=="string"?g.parse(r.hash.substr(1)):r.hash||{}),s=q(i);return s?Promise.reject(s):n.state!=null&&i.state!==n.state?Promise.reject(new TypeError("Invalid state: "+i.state)):Promise.resolve(this.client.createToken(i))};function ne(e){this.client=e}ne.prototype.getToken=function(e){var t=this,n=Object.assign({},this.client.options,e);C(n,"clientId","clientSecret","accessTokenUri");let r={grant_type:"client_credentials"};return n.scopes!==void 0&&(r.scope=I(n.scopes)),this.client._request(A({url:n.accessTokenUri,method:"POST",headers:Object.assign({},b,{Authorization:O(n.clientId,n.clientSecret)}),body:r},n)).then(function(o){return t.client.createToken(o)})};function F(e){this.client=e}F.prototype.getUri=function(e){var t=Object.assign({},this.client.options,e);return te(t,"code")};F.prototype.getToken=function(e,t){var n=this,r=Object.assign({},this.client.options,t);C(r,"clientId","accessTokenUri");var o=typeof e=="object"?e:new URL(e,S);if(typeof r.redirectUri=="string"&&typeof o.pathname=="string"&&o.pathname!==new URL(r.redirectUri,S).pathname)return Promise.reject(new TypeError("Redirected path should match configured path, but got: "+o.pathname));if(!o.search||!o.search.substr(1))return Promise.reject(new TypeError("Unable to process uri: "+e));var i=typeof o.search=="string"?g.parse(o.search.substr(1)):o.search||{},s=q(i);if(s)return Promise.reject(s);if(r.state!=null&&i.state!==r.state)return Promise.reject(new TypeError("Invalid state: "+i.state));if(!i.code)return Promise.reject(new TypeError("Missing code, unable to request token"));var a=Object.assign({},b),d={code:i.code,grant_type:"authorization_code",redirect_uri:r.redirectUri};return r.clientSecret?a.Authorization=O(r.clientId,r.clientSecret):d.client_id=r.clientId,this.client._request(A({url:r.accessTokenUri,method:"POST",headers:a,body:d},r)).then(function(p){return n.client.createToken(p)})};function oe(e){this.client=e}oe.prototype.getToken=function(e,t){var n=this,r=Object.assign({},this.client.options,t),o=Object.assign({},b);C(r,"accessTokenUri"),r.clientId&&(o.Authorization=O(r.clientId,r.clientSecret));let i={grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:e};return r.scopes!==void 0&&(i.scope=I(r.scopes)),this.client._request(A({url:r.accessTokenUri,method:"POST",headers:o,body:i},r)).then(function(s){return n.client.createToken(s)})}});var _e={};fe(_e,{createOAuth2Api:()=>ye,createOAuth2BrowserPersistence:()=>Oe,createOAuth2MemoryPersistence:()=>L,createOAuth2SessionPersistence:()=>be,setupOAuth2Client:()=>Ae});function ye(e){return t=>(t.on("before-fetch",e.extendHeaders),{getAccessToken(){return e.token()}})}var ae=ge(se());function L(){return{load(){},save(){}}}function be(e="$piral_oauth2_info"){return{load(){let t=sessionStorage.getItem(e);if(typeof t=="string")try{return JSON.parse(t)}catch(n){console.error("Found invalid data in the OAuth 2 session storage key. Skipped.")}},save(t){sessionStorage.setItem(e,JSON.stringify(t))}}}function Oe(e="$piral_oauth2_info"){return{load(){let t=localStorage.getItem(e);if(typeof t=="string")try{return JSON.parse(t)}catch(n){console.error("Found invalid data in the OAuth 2 local storage key. Skipped.")}},save(t){localStorage.setItem(e,JSON.stringify(t))}}}var N="oauth2Cb";function Ae(e){let{clientId:t,clientSecret:n,authorizationUri:r,accessTokenUri:o,redirectUri:i=`${location.origin}/auth`,scopes:s=[],flow:a,headers:d,query:p,state:m,restrict:T=!1,returnPath:w="/",persist:l=L()}=e,h=new ae.default({clientId:t,clientSecret:n,redirectUri:i,authorizationUri:r,accessTokenUri:o,scopes:s,headers:d,query:p,state:m}),f,U,z,D=c=>{l.save({accessToken:c.accessToken,data:c.data,refreshToken:c.refreshToken}),f=c},J=(c,u)=>c.then(()=>f?f.expired()?u().then(j=>(D(j),f.accessToken)):f.accessToken:Promise.reject("Not logged in. Please call `login()` to retrieve a token.")),M=c=>{let u=l.load();return u?(f=h.createToken(u.accessToken,u.refreshToken,u.data),Promise.resolve()):c().then(j=>{let E=window.opener;D(j),E&&typeof E[N]=="function"&&(E[N](j),window.close())},()=>{})};if(a==="code"){let c=M(()=>{let u=location.href;return history.replaceState(void 0,void 0,w),h.code.getToken(u)});U=()=>J(c,()=>f.refresh()),z=()=>h.code.getUri()}else{let c=M(()=>h.token.getToken(location.href));U=()=>J(c,()=>new Promise(u=>{window[N]=u,window.open(h.token.getUri())})),z=()=>h.token.getUri()}return{_:h,login(){window.location.href=z()},logout(){f=void 0},extendHeaders(c){T||c.setHeaders(U().then(u=>u&&{Authorization:`Bearer ${u}`},()=>{}))},account(){return!!f},token:U}}return _e;})();
package/src/create.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { PiralPlugin } from 'piral-core';
2
- import { OAuth2Client } from './setup';
3
- import { PiralOAuth2Api } from './types';
2
+ import { OAuth2Client, PiralOAuth2Api } from './types';
4
3
 
5
4
  /**
6
5
  * Creates new Pilet API extensions for the integration of OAuth 2.0.
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './create';
2
2
  export * from './setup';
3
3
  export * from './types';
4
+ export * from './utils';