@nsshunt/stsoauth2plugin 0.1.22 → 0.1.23

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.
@@ -0,0 +1,32 @@
1
+ export class CryptoUtils {
2
+ constructor() {
3
+ this.DigestMessage = async function (message) {
4
+ const encoder = new TextEncoder();
5
+ const data = encoder.encode(message);
6
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
7
+ const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
8
+ //let b64 = window.btoa(String.fromCharCode(...hashArray));
9
+ const b64 = btoa(String.fromCharCode(...hashArray)); // Use below if a HEX string is required
10
+ // const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
11
+ return b64;
12
+ };
13
+ this.CreateRandomString = (size = 43) => {
14
+ //const randomValues = Array.from(window.crypto.getRandomValues(new Uint8Array(size)))
15
+ const randomValues = Array.from(crypto.getRandomValues(new Uint8Array(size)));
16
+ //let b64 = window.btoa(String.fromCharCode(...randomValues));
17
+ const b64 = btoa(String.fromCharCode(...randomValues));
18
+ return b64;
19
+ //return randomValues.toString('base64');
20
+ };
21
+ this.CreateRandomStringEx = () => {
22
+ const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.';
23
+ let random = '';
24
+ //const randomValues = Array.from(window.crypto.getRandomValues(new Uint8Array(43)));
25
+ const randomValues = Array.from(crypto.getRandomValues(new Uint8Array(43)));
26
+ randomValues.forEach(v => (random += charset[v % charset.length]));
27
+ return random;
28
+ };
29
+ }
30
+ }
31
+ export default CryptoUtils;
32
+ //# sourceMappingURL=CryptoUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CryptoUtils.js","sourceRoot":"","sources":["../../src/Utils/CryptoUtils.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAW;IAAxB;QACC,kBAAa,GAAG,KAAK,WAAW,OAAO;YACtC,M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AO,MAAM,CAAC;QACf,CAAC,CAAA;IACF,CAAC;CAAA;AAED,eAAe,WAAW,CAAA"}
@@ -0,0 +1,49 @@
1
+ // https://github.com/auth0/auth0-spa-js/blob/1de6427f81a8c5b005e9b6d10b9efb1e73542528/static/index.html
2
+ // https://stackoverflow.com/questions/12446317/change-url-without-redirecting-using-javascript
3
+ class QueryParams {
4
+ constructor() {
5
+ this.DecodeQueryParams = (params) => {
6
+ const retObj = {};
7
+ const arr = Object.keys(params)
8
+ .filter(k => typeof params[k] !== 'undefined')
9
+ .map(k => {
10
+ retObj[decodeURIComponent(k)] = decodeURIComponent(params[k]);
11
+ });
12
+ return retObj;
13
+ };
14
+ this.CreateQueryParams = (params) => {
15
+ return Object.keys(params)
16
+ .filter(k => typeof params[k] !== 'undefined')
17
+ .map(k => {
18
+ if (Array.isArray(params[k])) {
19
+ return encodeURIComponent(k) + '=' + encodeURIComponent(params[k].join(' '));
20
+ }
21
+ else {
22
+ return encodeURIComponent(k) + '=' + encodeURIComponent(params[k]);
23
+ }
24
+ })
25
+ .join('&');
26
+ };
27
+ this._GetQueryParams = (param) => {
28
+ let retVal = {};
29
+ const uri = param.split("?");
30
+ if (uri.length == 2) {
31
+ const vars = uri[1].split("&");
32
+ const getVars = {};
33
+ let tmp = "";
34
+ vars.forEach(function (v) {
35
+ tmp = v.split("=");
36
+ if (tmp.length == 2)
37
+ getVars[tmp[0]] = tmp[1];
38
+ });
39
+ retVal = this.DecodeQueryParams(getVars);
40
+ }
41
+ return retVal;
42
+ };
43
+ this.GetQueryParams = () => {
44
+ return this._GetQueryParams(window.location.href);
45
+ };
46
+ }
47
+ }
48
+ export default QueryParams;
49
+ //# sourceMappingURL=QueryParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryParams.js","sourceRoot":"","sources":["../../src/Utils/QueryParams.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,+FAA+F;AAC/F,MAAM,WAAW;IAAjB;QACC,sBAAiB,GAAG,CAA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,IAAI,CAAC,EAAE;gBACpB,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC/B,MAAM,OAAO,GAAG,EAAE,CAAC;gBACnB,IAAI,GAAG,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;oBACvB,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBACnB,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC;wBAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC,CAAC,CAAC;gBACH,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;aACzC;YACD,OAAO,MAAM,CAAC;QACf,CAAC,CAAA;QAED,mBAAc,GAAG,GAAG,EAAE;YACrB,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnD,CAAC,CAAA;IACF,CAAC;CAAA;AAED,eAAe,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { STSOAuth2Manager } from './stsoauth2manager';
2
+ export * from './stsoauth2types';
3
+ export * from './stsoauth2manager';
4
+ export * from './stsoauth2worker';
5
+ export const STSOAuth2ManagerPlugin = {
6
+ install: (app, router) => {
7
+ const om = new STSOAuth2Manager(app, router);
8
+ app.config.globalProperties.$sts.om = om;
9
+ }
10
+ };
11
+ //export default STSOAuth2ManagerPlugin
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AAEjC,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACxB,MAAM,EAAE,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC7C,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IAC1C,CAAC;CACD,CAAA;AACD,uCAAuC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ describe("Test Latency Controller", () => {
3
+ test('Testing Module', async () => {
4
+ expect.assertions(1);
5
+ expect(1).toEqual(1);
6
+ });
7
+ });
8
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";AACA,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IAExC,IAAI,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;QAEjC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,152 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _MemoryStorage_store, _ClientStorageFactory_storage;
13
+ import Debug from "debug";
14
+ const debug = Debug(`proc:${process.pid}:storage.ts`);
15
+ import * as Cookies from 'es-cookie';
16
+ export var ClientStorageType;
17
+ (function (ClientStorageType) {
18
+ ClientStorageType["LOCAL_STORAGE"] = "LocalStorage";
19
+ ClientStorageType["SESSION_STORAGE"] = "SessionStorage";
20
+ ClientStorageType["COOKIE_STORAGE"] = "CookieStorage";
21
+ ClientStorageType["MEMORY_STORAGE"] = "MemoryStorage"; //@@ todo
22
+ })(ClientStorageType || (ClientStorageType = {}));
23
+ class CookieStorage {
24
+ constructor() {
25
+ this.get = (key) => {
26
+ const raw = Cookies.get(key);
27
+ if (raw) {
28
+ return JSON.parse(raw);
29
+ }
30
+ else {
31
+ return null;
32
+ }
33
+ };
34
+ this.set = (key, value, options = {}) => {
35
+ let cookieAttributes = {};
36
+ if ('https:' === window.location.protocol) {
37
+ cookieAttributes = {
38
+ secure: true,
39
+ sameSite: 'none'
40
+ };
41
+ }
42
+ if (options && options.daysUntilExpire) {
43
+ cookieAttributes.expires = options.daysUntilExpire;
44
+ }
45
+ else {
46
+ cookieAttributes.expires = 1;
47
+ }
48
+ debug(`CookieStorage.set: key: ${key}, value: [${value}]`);
49
+ Cookies.set(key, JSON.stringify(value), cookieAttributes);
50
+ };
51
+ this.remove = (key) => {
52
+ Cookies.remove(key);
53
+ };
54
+ }
55
+ }
56
+ class SessionStorage {
57
+ constructor() {
58
+ this.get = (key) => {
59
+ const value = sessionStorage.getItem(key);
60
+ if (typeof value === 'undefined') {
61
+ return null;
62
+ }
63
+ if (value === null) {
64
+ return null;
65
+ }
66
+ return JSON.parse(value);
67
+ };
68
+ this.set = (key, value) => {
69
+ debug(`SessionStorage.set: key: ${key}, value: [${value}]`);
70
+ sessionStorage.setItem(key, JSON.stringify(value));
71
+ };
72
+ this.remove = (key) => {
73
+ sessionStorage.removeItem(key);
74
+ };
75
+ }
76
+ }
77
+ class LocalStorage {
78
+ constructor() {
79
+ this.get = (key) => {
80
+ const value = localStorage.getItem(key);
81
+ if (typeof value === 'undefined') {
82
+ return null;
83
+ }
84
+ if (value === null) {
85
+ return null;
86
+ }
87
+ return JSON.parse(value);
88
+ };
89
+ this.set = (key, value) => {
90
+ debug(`LocalStorage.set: key: ${key}, value: [${value}]`);
91
+ localStorage.setItem(key, JSON.stringify(value));
92
+ };
93
+ this.remove = (key) => {
94
+ localStorage.removeItem(key);
95
+ };
96
+ }
97
+ }
98
+ class MemoryStorage {
99
+ constructor() {
100
+ _MemoryStorage_store.set(this, {});
101
+ this.get = (key) => {
102
+ const value = __classPrivateFieldGet(this, _MemoryStorage_store, "f")[key];
103
+ if (typeof value === 'undefined') {
104
+ return null;
105
+ }
106
+ if (value === null) {
107
+ return null;
108
+ }
109
+ return value;
110
+ };
111
+ this.set = (key, value) => {
112
+ debug(`MemoryStorage.set: key: ${key}, value: [${value}]`);
113
+ __classPrivateFieldGet(this, _MemoryStorage_store, "f")[key] = value;
114
+ };
115
+ this.remove = (key) => {
116
+ delete __classPrivateFieldGet(this, _MemoryStorage_store, "f")[key];
117
+ };
118
+ }
119
+ }
120
+ _MemoryStorage_store = new WeakMap();
121
+ export class ClientStorageOptions {
122
+ constructor() {
123
+ this.clientStorageType = ClientStorageType.MEMORY_STORAGE;
124
+ }
125
+ }
126
+ export class ClientStorageFactory {
127
+ constructor(options) {
128
+ _ClientStorageFactory_storage.set(this, null);
129
+ switch (options.clientStorageType) {
130
+ case ClientStorageType.SESSION_STORAGE:
131
+ __classPrivateFieldSet(this, _ClientStorageFactory_storage, new SessionStorage(), "f");
132
+ break;
133
+ case ClientStorageType.LOCAL_STORAGE:
134
+ __classPrivateFieldSet(this, _ClientStorageFactory_storage, new LocalStorage(), "f");
135
+ break;
136
+ case ClientStorageType.COOKIE_STORAGE:
137
+ __classPrivateFieldSet(this, _ClientStorageFactory_storage, new CookieStorage(), "f");
138
+ break;
139
+ case ClientStorageType.MEMORY_STORAGE:
140
+ __classPrivateFieldSet(this, _ClientStorageFactory_storage, new MemoryStorage(), "f");
141
+ break;
142
+ default:
143
+ throw new Error(`Unknown [${options.clientStorageType}] storage type.`);
144
+ }
145
+ return;
146
+ }
147
+ GetStorage() {
148
+ return __classPrivateFieldGet(this, _ClientStorageFactory_storage, "f");
149
+ }
150
+ }
151
+ _ClientStorageFactory_storage = new WeakMap();
152
+ //# sourceMappingURL=stsStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsStorage.js","sourceRoot":"","sources":["../src/stsStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC;AAEtD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AASrC,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC5B,mDAA8B,CAAA;IAC9B,uDAAkC,CAAA;IAClC,qDAAgC,CAAA;IAChC,qDAAgC,CAAA,CAAC,SAAS;AAC3C,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AAED,MAAM,aAAa;IAAnB;QAEC,QAAG,GAAG,CAAC,GAAW,EAAK,EAAE;YACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,GAAG,EAAE;gBACR,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACvB;iBAAM;gBACN,OAAO,IAAI,CAAC;aACZ;QACF,CAAC,CAAA;QAED,QAAG,GAAG,CAAC,GAAW,EAAE,KAAQ,EAAE,UAAsB,EAAG,EAAE,EAAE;YAC1D,IAAI,gBAAgB,GAA6B,EAAG,CAAC;YACrD,IAAI,QAAQ,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AAC,CAAC;YAC3D,uBAAA,IAAI,4BAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC1B,CAAC,CAAA;QAED,WAAM,GAAG,CAAC,GAAW,EAAQ,EAAE;YAC9B,OAAO,uBAAA,IAAI,4BAAO,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC,CAAA;IACF,CAAC;CAAA;;AAED,MAAM,OAAO,oBAAoB;IAAjC;QACC,sBAAiB,GAAsB,iBAAiB,CAAC,cAAc,CAAC;IAEzE,CAAC;CAAA;AAED,MAAM,OAAO,oBAAoB;IAIhC,YAAY,OAA6B;QAFzC,wCAAW,IAAI,EAAC;QAGf,QAAQ,OAAO,CAAC,iBAAiB,EAAE;YACnC,KAAK,iBAAiB,CAAC,eAAe;gBACrC,uBAAA,IAAI,iCAAY,IAAI,cAAc,EAAK,MAAA,CAAC;gBACxC,MAAM;YACP,KAAK,iBAAiB,CAAC,aAAa;gBACnC,uBAAA,IAAI,iCAAY,IAAI,YAAY,EAAK,MAAA,CAAC;gBACtC,MAAM;YACP,KAAK,iBAAiB,CAAC,cAAc;gBACpC,uBAAA,IAAI,iCAAY,IAAI,aAAa,EAAK,MAAA,CAAC;gBACvC,MAAM;YACP,KAAK,iBAAiB,CAAC,cAAc;gBACpC,uBAAA,IAAI,iCAAY,IAAI,aAAa,EAAK,MAAA,CAAC;gBACvC,MAAM;YACP;gBACC,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,CAAC,iBAAiB,iBAAiB,CAAC,CAAC;SACxE;QACD,OAAO;IACR,CAAC;IAED,UAAU;QAET,OAAO,uBAAA,IAAI,qCAAS,CAAC;IACtB,CAAC;CACD"}
@@ -0,0 +1,325 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _STSOAuth2Manager_storageManager, _STSOAuth2Manager_router, _STSOAuth2Manager_store, _STSOAuth2Manager_cUtils, _STSOAuth2Manager_qParams, _STSOAuth2Manager_STORAGE_AUTHORIZE_OPTIONS_KEY, _STSOAuth2Manager_STORAGE_SESSION_KEY, _STSOAuth2Manager_aic, _STSOAuth2Manager_options, _STSOAuth2Manager_messages, _STSOAuth2Manager_oauth2ManagerPort, _STSOAuth2Manager_messageId, _STSOAuth2Manager_messageHandlers, _STSOAuth2Manager_messageTimeout, _STSOAuth2Manager_worker, _STSOAuth2Manager_transactionStore, _STSOAuth2Manager_ProcessMessageResponse, _STSOAuth2Manager_PostMessage, _STSOAuth2Manager_HandleErrorEvent, _STSOAuth2Manager_HandleAuthenticateEvent, _STSOAuth2Manager_SetupRoute, _STSOAuth2Manager_SetupStoreNamespace;
13
+ import Debug from "debug";
14
+ const debug = Debug(`proc:${process.pid}:stsoauth2manager.ts`);
15
+ import { OAuth2ParameterType } from '@nsshunt/stsutils';
16
+ import CryptoUtils from './Utils/CryptoUtils';
17
+ import QueryParams from './Utils/QueryParams';
18
+ import { IOauth2ListenerCommand } from './stsoauth2types';
19
+ import { ClientStorageType, ClientStorageFactory } from './stsStorage';
20
+ //import createPersistedState from "vuex-persistedstate"; // https://www.npmjs.com/package/vuex-persistedstate
21
+ import jwt_decode from "jwt-decode";
22
+ //import { transformWithEsbuild } from "vite";
23
+ // STS Client SDK for SPAs
24
+ export class STSOAuth2Manager {
25
+ constructor(app, options) {
26
+ _STSOAuth2Manager_storageManager.set(this, null);
27
+ _STSOAuth2Manager_router.set(this, null);
28
+ _STSOAuth2Manager_store.set(this, null);
29
+ _STSOAuth2Manager_cUtils.set(this, new CryptoUtils());
30
+ _STSOAuth2Manager_qParams.set(this, new QueryParams());
31
+ _STSOAuth2Manager_STORAGE_AUTHORIZE_OPTIONS_KEY.set(this, 'authorize_options.stsmda.com.au');
32
+ _STSOAuth2Manager_STORAGE_SESSION_KEY.set(this, 'session.stsmda.com.au');
33
+ _STSOAuth2Manager_aic.set(this, null);
34
+ _STSOAuth2Manager_options.set(this, null);
35
+ _STSOAuth2Manager_messages.set(this, {});
36
+ _STSOAuth2Manager_oauth2ManagerPort.set(this, void 0);
37
+ _STSOAuth2Manager_messageId.set(this, 0);
38
+ _STSOAuth2Manager_messageHandlers.set(this, {}); // keyed by messageId
39
+ _STSOAuth2Manager_messageTimeout.set(this, 1000);
40
+ _STSOAuth2Manager_worker.set(this, null);
41
+ _STSOAuth2Manager_transactionStore.set(this, null); // Transient transaction data used to establish a session via OAuth2 authorize handshake
42
+ _STSOAuth2Manager_ProcessMessageResponse.set(this, (data) => {
43
+ const messageResponse = data.data;
44
+ if (messageResponse.messageId === -1) {
45
+ // unsolicted message
46
+ switch (messageResponse.command) {
47
+ case IOauth2ListenerCommand.AUTHENTICATE_EVENT:
48
+ __classPrivateFieldGet(this, _STSOAuth2Manager_HandleAuthenticateEvent, "f").call(this, messageResponse.payload);
49
+ break;
50
+ case IOauth2ListenerCommand.ERROR:
51
+ __classPrivateFieldGet(this, _STSOAuth2Manager_HandleErrorEvent, "f").call(this, messageResponse.payload);
52
+ break;
53
+ default:
54
+ throw new Error(`ProcessMessageResponse command [${messageResponse.command}] not valid.`);
55
+ }
56
+ }
57
+ else {
58
+ const callBack = __classPrivateFieldGet(this, _STSOAuth2Manager_messageHandlers, "f")[messageResponse.messageId];
59
+ if (callBack) {
60
+ callBack(messageResponse);
61
+ }
62
+ else {
63
+ throw new Error(`Message: [${messageResponse.messageId}] does not exists in callBacks.`);
64
+ }
65
+ }
66
+ });
67
+ _STSOAuth2Manager_PostMessage.set(this, (message) => {
68
+ var _a, _b;
69
+ message.messageId = (__classPrivateFieldSet(this, _STSOAuth2Manager_messageId, (_b = __classPrivateFieldGet(this, _STSOAuth2Manager_messageId, "f"), _a = _b++, _b), "f"), _a);
70
+ return new Promise((resolve, reject) => {
71
+ // Setup message timeout
72
+ const timeout = setTimeout(() => {
73
+ delete __classPrivateFieldGet(this, _STSOAuth2Manager_messageHandlers, "f")[message.messageId];
74
+ reject(`Message: [${message.messageId}] timeout error after: [${__classPrivateFieldGet(this, _STSOAuth2Manager_messageTimeout, "f")}] ms.`);
75
+ }, __classPrivateFieldGet(this, _STSOAuth2Manager_messageTimeout, "f"));
76
+ // Setup message callback based on messageId
77
+ __classPrivateFieldGet(this, _STSOAuth2Manager_messageHandlers, "f")[message.messageId] = (response) => {
78
+ clearTimeout(timeout);
79
+ delete __classPrivateFieldGet(this, _STSOAuth2Manager_messageHandlers, "f")[message.messageId];
80
+ resolve(response);
81
+ };
82
+ // Send the message
83
+ __classPrivateFieldGet(this, _STSOAuth2Manager_oauth2ManagerPort, "f").postMessage(message);
84
+ });
85
+ }
86
+ // Will come from message channel
87
+ );
88
+ // Will come from message channel
89
+ _STSOAuth2Manager_HandleErrorEvent.set(this, (error) => {
90
+ __classPrivateFieldGet(this, _STSOAuth2Manager_store, "f").commit('AuthorizeError', {
91
+ message: error
92
+ });
93
+ // plugin to do this ...
94
+ setTimeout(() => {
95
+ __classPrivateFieldGet(this, _STSOAuth2Manager_router, "f").replace('/error'); //@@ was push
96
+ }, 0);
97
+ });
98
+ _STSOAuth2Manager_HandleAuthenticateEvent.set(this, (id_token) => {
99
+ if (__classPrivateFieldGet(this, _STSOAuth2Manager_options, "f").authenticateEvent) {
100
+ __classPrivateFieldGet(this, _STSOAuth2Manager_options, "f").authenticateEvent(id_token);
101
+ }
102
+ __classPrivateFieldGet(this, _STSOAuth2Manager_store, "f").commit('stsOAuth2SDK/SessionData', id_token);
103
+ });
104
+ _STSOAuth2Manager_SetupRoute.set(this, (app, router) => {
105
+ router.beforeEach(async (to, from) => {
106
+ const store = app.config.globalProperties.$store;
107
+ const sts = app.config.globalProperties.$sts;
108
+ debug(`beforeEach: from: [${from.path}], to: [${to.path}]`); // gray
109
+ if (store.getters['stsOAuth2SDK/LoggedIn'] === false) {
110
+ console.log(`Not logged in`);
111
+ // Not logged in
112
+ if (to.path.localeCompare('/authorize') === 0) {
113
+ console.log(`to = /authorize`);
114
+ return true;
115
+ }
116
+ else if (to.path.localeCompare('/consent') === 0) {
117
+ // Need to check if we are in the correct state, if not - drop back to the start of the process
118
+ if (typeof store.getters.Session.sessionId !== 'undefined') {
119
+ return true;
120
+ }
121
+ }
122
+ if (to.path.localeCompare('/logout') === 0) {
123
+ return true;
124
+ }
125
+ if (to.path.localeCompare('/error') === 0) {
126
+ return true;
127
+ }
128
+ if (to.path.localeCompare('/logout') === 0) {
129
+ return true;
130
+ }
131
+ const str = to.query;
132
+ // Check if this route is from a redirect from the authorization server
133
+ if (str[OAuth2ParameterType.CODE] || str[OAuth2ParameterType.ERROR]) {
134
+ console.log(`#SetupRout:str = [${str}]`);
135
+ const retVal = await sts.om.HandleRedirect(str);
136
+ if (retVal) {
137
+ // Success
138
+ setTimeout(() => {
139
+ window.history.replaceState({}, document.title, window.location.origin + '/');
140
+ }, 0);
141
+ return true;
142
+ }
143
+ else {
144
+ // Error
145
+ //@@ need the error data here - or use the vuex store ?
146
+ __classPrivateFieldGet(this, _STSOAuth2Manager_router, "f").replace('/error'); //@@ was push
147
+ //@@ should replaceState be used as in above?
148
+ return false;
149
+ }
150
+ }
151
+ const sessionRestored = await sts.om.RestoreSession();
152
+ console.log(`#SetupRoute:sessionRestored [${sessionRestored}]`);
153
+ if (sessionRestored !== true) {
154
+ console.log('Session not restored - Need to Authorize');
155
+ sts.om.Authorize();
156
+ return false;
157
+ }
158
+ else {
159
+ return '/';
160
+ //router.replace({ path: '/' })
161
+ }
162
+ }
163
+ else {
164
+ // Prevent pages if already logged in
165
+ if (to.path.localeCompare('/consent') === 0) {
166
+ return '/';
167
+ /*
168
+ router.replace({ path: '/' })
169
+ return false;
170
+ */
171
+ }
172
+ if (to.path.localeCompare('/authorize') === 0) {
173
+ router.replace({ path: '/' });
174
+ return false;
175
+ }
176
+ if (to.path.localeCompare('/logout') === 0) {
177
+ router.replace({ path: '/' });
178
+ return false;
179
+ }
180
+ return true;
181
+ /*
182
+ if (to.path.localeCompare('/') === 0) {
183
+ // In case press the back button in the browser shows previous query string params, replace them ...
184
+ setTimeout(() => {
185
+ window.history.replaceState(
186
+ {},
187
+ document.title,
188
+ window.location.origin + '/');
189
+ }, 0);
190
+ return true;
191
+ }
192
+ */
193
+ }
194
+ });
195
+ });
196
+ _STSOAuth2Manager_SetupStoreNamespace.set(this, () => {
197
+ __classPrivateFieldGet(this, _STSOAuth2Manager_store, "f").registerModule('stsOAuth2SDK', {
198
+ namespaced: true,
199
+ state() {
200
+ return {
201
+ // STS Client SDK options. These are parameters initiated by the client SPA and used for the end-to-end transaction processing.
202
+ //authorizeOptions: { },
203
+ sessionData: {},
204
+ };
205
+ },
206
+ getters: {
207
+ SessionData(state) {
208
+ return state.sessionData;
209
+ },
210
+ LoggedIn(state) {
211
+ if (typeof state.sessionData === 'undefined') {
212
+ return false;
213
+ }
214
+ if (state.sessionData === null) {
215
+ return false;
216
+ }
217
+ return true;
218
+ },
219
+ UserDetails(state) {
220
+ //if (state.sessionData && state.sessionData.id_token) {
221
+ if (state.sessionData) {
222
+ const id_token = state.sessionData;
223
+ const decodedIdToken = jwt_decode(id_token);
224
+ return decodedIdToken;
225
+ }
226
+ else {
227
+ return null;
228
+ }
229
+ }
230
+ },
231
+ mutations: {
232
+ SessionData(state, sessionData) {
233
+ state.sessionData = sessionData;
234
+ console.log(`commit [sessionData]: ${JSON.stringify(sessionData)}`);
235
+ },
236
+ }
237
+ }, { preserveState: true });
238
+ });
239
+ this.RestoreSession = async () => {
240
+ try {
241
+ const response = await __classPrivateFieldGet(this, _STSOAuth2Manager_PostMessage, "f").call(this, { command: IOauth2ListenerCommand.RESTORE_SESSION });
242
+ return response.payload;
243
+ }
244
+ catch (error) {
245
+ console.log(`RestoreSession Error: ${error}`); //red
246
+ return false;
247
+ }
248
+ };
249
+ this.Authorize = async () => {
250
+ try {
251
+ const response = await __classPrivateFieldGet(this, _STSOAuth2Manager_PostMessage, "f").call(this, { command: IOauth2ListenerCommand.AUTHORIZE });
252
+ __classPrivateFieldGet(this, _STSOAuth2Manager_transactionStore, "f").set(__classPrivateFieldGet(this, _STSOAuth2Manager_STORAGE_AUTHORIZE_OPTIONS_KEY, "f"), response.payload.authorizeOptions);
253
+ const url = response.payload.url;
254
+ window.location.replace(url);
255
+ }
256
+ catch (error) {
257
+ console.log(`Authorize Error: ${error}`); // red
258
+ }
259
+ };
260
+ this.HandleRedirect = async (queryVars) => {
261
+ try {
262
+ let response = null;
263
+ if (queryVars[OAuth2ParameterType.CODE]) {
264
+ const authorizeOptions = __classPrivateFieldGet(this, _STSOAuth2Manager_transactionStore, "f").get(__classPrivateFieldGet(this, _STSOAuth2Manager_STORAGE_AUTHORIZE_OPTIONS_KEY, "f"));
265
+ __classPrivateFieldGet(this, _STSOAuth2Manager_transactionStore, "f").remove(__classPrivateFieldGet(this, _STSOAuth2Manager_STORAGE_AUTHORIZE_OPTIONS_KEY, "f"));
266
+ response = await __classPrivateFieldGet(this, _STSOAuth2Manager_PostMessage, "f").call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: {
267
+ queryVars: queryVars,
268
+ authorizeOptions
269
+ } });
270
+ }
271
+ else {
272
+ response = await __classPrivateFieldGet(this, _STSOAuth2Manager_PostMessage, "f").call(this, { command: IOauth2ListenerCommand.HANDLE_REDIRECT, payload: queryVars });
273
+ }
274
+ return response.payload;
275
+ }
276
+ catch (error) {
277
+ console.log(`HandleRedirect Error: ${error}`); // red
278
+ return false;
279
+ }
280
+ };
281
+ this.Logout = async () => {
282
+ try {
283
+ const response = await __classPrivateFieldGet(this, _STSOAuth2Manager_PostMessage, "f").call(this, { command: IOauth2ListenerCommand.LOGOUT });
284
+ return response.payload;
285
+ }
286
+ catch (error) {
287
+ console.log(`Logout Error: ${error}`); // red
288
+ return false;
289
+ }
290
+ };
291
+ __classPrivateFieldSet(this, _STSOAuth2Manager_options, options, "f");
292
+ __classPrivateFieldSet(this, _STSOAuth2Manager_storageManager, app.config.globalProperties.$sts.storage, "f");
293
+ __classPrivateFieldSet(this, _STSOAuth2Manager_store, app.config.globalProperties.$store, "f");
294
+ __classPrivateFieldSet(this, _STSOAuth2Manager_aic, app.config.globalProperties.$sts.aic.PrimaryPublishInstrumentController, "f");
295
+ __classPrivateFieldSet(this, _STSOAuth2Manager_router, app.config.globalProperties.$router, "f");
296
+ // Use session storage for the transient nature of the OAuth2 authorize handshake. Once completed, the storage will be removed.
297
+ __classPrivateFieldSet(this, _STSOAuth2Manager_transactionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.SESSION_STORAGE }).GetStorage(), "f");
298
+ if (__classPrivateFieldGet(this, _STSOAuth2Manager_options, "f").workerFactory) {
299
+ __classPrivateFieldSet(this, _STSOAuth2Manager_worker, __classPrivateFieldGet(this, _STSOAuth2Manager_options, "f").workerFactory(), "f");
300
+ }
301
+ else {
302
+ __classPrivateFieldSet(this, _STSOAuth2Manager_worker, new Worker(new URL('./stsoauth2worker.ts', import.meta.url), {
303
+ type: 'module'
304
+ }), "f");
305
+ }
306
+ __classPrivateFieldGet(this, _STSOAuth2Manager_worker, "f").onmessage = (data) => {
307
+ console.log(`this.#worker.onmessage = [${data}]`); // green
308
+ };
309
+ __classPrivateFieldGet(this, _STSOAuth2Manager_worker, "f").onerror = function (error) {
310
+ console.log(`this.#worker.onerror = [${error}]`); // green
311
+ };
312
+ const { port1: oauth2ManagerPort, // process message port
313
+ port2: oauth2WorkerPort // collector message port
314
+ } = new MessageChannel();
315
+ __classPrivateFieldSet(this, _STSOAuth2Manager_oauth2ManagerPort, oauth2ManagerPort, "f");
316
+ __classPrivateFieldGet(this, _STSOAuth2Manager_worker, "f").postMessage(oauth2WorkerPort, [oauth2WorkerPort]);
317
+ __classPrivateFieldGet(this, _STSOAuth2Manager_oauth2ManagerPort, "f").onmessage = (data) => {
318
+ __classPrivateFieldGet(this, _STSOAuth2Manager_ProcessMessageResponse, "f").call(this, data);
319
+ };
320
+ __classPrivateFieldGet(this, _STSOAuth2Manager_SetupStoreNamespace, "f").call(this);
321
+ __classPrivateFieldGet(this, _STSOAuth2Manager_SetupRoute, "f").call(this, app, options.router);
322
+ }
323
+ }
324
+ _STSOAuth2Manager_storageManager = new WeakMap(), _STSOAuth2Manager_router = new WeakMap(), _STSOAuth2Manager_store = new WeakMap(), _STSOAuth2Manager_cUtils = new WeakMap(), _STSOAuth2Manager_qParams = new WeakMap(), _STSOAuth2Manager_STORAGE_AUTHORIZE_OPTIONS_KEY = new WeakMap(), _STSOAuth2Manager_STORAGE_SESSION_KEY = new WeakMap(), _STSOAuth2Manager_aic = new WeakMap(), _STSOAuth2Manager_options = new WeakMap(), _STSOAuth2Manager_messages = new WeakMap(), _STSOAuth2Manager_oauth2ManagerPort = new WeakMap(), _STSOAuth2Manager_messageId = new WeakMap(), _STSOAuth2Manager_messageHandlers = new WeakMap(), _STSOAuth2Manager_messageTimeout = new WeakMap(), _STSOAuth2Manager_worker = new WeakMap(), _STSOAuth2Manager_transactionStore = new WeakMap(), _STSOAuth2Manager_ProcessMessageResponse = new WeakMap(), _STSOAuth2Manager_PostMessage = new WeakMap(), _STSOAuth2Manager_HandleErrorEvent = new WeakMap(), _STSOAuth2Manager_HandleAuthenticateEvent = new WeakMap(), _STSOAuth2Manager_SetupRoute = new WeakMap(), _STSOAuth2Manager_SetupStoreNamespace = new WeakMap();
325
+ //# sourceMappingURL=stsoauth2manager.js.map
@@ -0,0 +1 @@
1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gBAAgB,EAAE,CAAE,gBAAgB,CAAE,CAAC,CAAC;QAEjE,uBAAA,IAAI,2CAAmB,CAAC,SAAS,GAAG,CAAC,IAAkB,EAAE,EAAE;YAC1D,uBAAA,IAAI,gDAAwB,MAA5B,IAAI,EAAyB,IAAI,CAAC,CAAC;QACpC,CAAC,CAAA;QAGD,uBAAA,IAAI,6CAAqB,MAAzB,IAAI,CAAuB,CAAC;QAC5B,uBAAA,IAAI,oCAAY,MAAhB,IAAI,EAAa,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;CAyQD"}
@@ -0,0 +1,29 @@
1
+ export var AuthorizeOptionsResponseType;
2
+ (function (AuthorizeOptionsResponseType) {
3
+ AuthorizeOptionsResponseType["CODE"] = "code";
4
+ AuthorizeOptionsResponseType["ID_TOKEN"] = "id_token";
5
+ AuthorizeOptionsResponseType["TOKEN"] = "token";
6
+ })(AuthorizeOptionsResponseType || (AuthorizeOptionsResponseType = {}));
7
+ export var AuthorizeOptionsResponseMode;
8
+ (function (AuthorizeOptionsResponseMode) {
9
+ AuthorizeOptionsResponseMode["QUERY"] = "query";
10
+ AuthorizeOptionsResponseMode["FRAGMENT"] = "fragment";
11
+ AuthorizeOptionsResponseMode["FORM_POST"] = "form_post";
12
+ })(AuthorizeOptionsResponseMode || (AuthorizeOptionsResponseMode = {}));
13
+ export var OAuthGrantTypes;
14
+ (function (OAuthGrantTypes) {
15
+ OAuthGrantTypes["CLIENT_CREDENTIALS"] = "client_credentials";
16
+ OAuthGrantTypes["AUTHORIZATION_CODE"] = "authorization_code";
17
+ OAuthGrantTypes["REFRESH_TOKEN"] = "refresh_token";
18
+ })(OAuthGrantTypes || (OAuthGrantTypes = {}));
19
+ // ---------------
20
+ export var IOauth2ListenerCommand;
21
+ (function (IOauth2ListenerCommand) {
22
+ IOauth2ListenerCommand["RESTORE_SESSION"] = "RestoreSession";
23
+ IOauth2ListenerCommand["AUTHORIZE"] = "Authorize";
24
+ IOauth2ListenerCommand["HANDLE_REDIRECT"] = "HandleRedirect";
25
+ IOauth2ListenerCommand["LOGOUT"] = "Logout";
26
+ IOauth2ListenerCommand["AUTHENTICATE_EVENT"] = "AuthenticateEvent";
27
+ IOauth2ListenerCommand["ERROR"] = "Error";
28
+ })(IOauth2ListenerCommand || (IOauth2ListenerCommand = {}));
29
+ //# sourceMappingURL=stsoauth2types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsoauth2types.js","sourceRoot":"","sources":["../src/stsoauth2types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,4BAIX;AAJD,WAAY,4BAA4B;IACvC,6CAAa,CAAA;IACb,qDAAqB,CAAA;IACrB,+CAAe,CAAA;AAChB,CAAC,EAJW,4BAA4B,KAA5B,4BAA4B,QAIvC;AAED,MAAM,CAAN,IAAY,4BAIX;AAJD,WAAY,4BAA4B;IACvC,+CAAe,CAAA;IACf,qDAAqB,CAAA;IACrB,uDAAuB,CAAA;AACxB,CAAC,EAJW,4BAA4B,KAA5B,4BAA4B,QAIvC;AA0BD,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IAC1B,4DAAyC,CAAA;IACzC,4DAAyC,CAAA;IACzC,kDAA+B,CAAA;AAChC,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAuCD,kBAAkB;AAElB,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IACjC,4DAAkC,CAAA;IAClC,iDAAuB,CAAA;IACvB,4DAAkC,CAAA;IAClC,2CAAiB,CAAA;IACjB,kEAAwC,CAAA;IACxC,yCAAe,CAAA;AAChB,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC"}
@@ -0,0 +1,553 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _STSOAuth2Worker_clientSessionStore, _STSOAuth2Worker_cUtils, _STSOAuth2Worker_qParams, _STSOAuth2Worker_STORAGE_AUTHORIZE_OPTIONS_KEY, _STSOAuth2Worker_STORAGE_SESSION_KEY, _STSOAuth2Worker_aic, _STSOAuth2Worker_errorCallback, _STSOAuth2Worker_handleAuthenticateEvent, _STSOAuth2Worker_oauthWorkerPort, _STSOAuth2Worker_currentMessageId, _STSOAuth2Worker_ProcessCommand, _STSOAuth2Worker_RestoreSession, _STSOAuth2Worker_Authorize, _STSOAuth2Worker_HandleRedirect, _STSOAuth2Worker_GetTokenFromBroker, _STSOAuth2Worker_GetToken, _STSOAuth2Worker_RefreshToken, _STSOAuth2Worker_Logout;
13
+ import Debug from "debug";
14
+ const debug = Debug(`proc:${process.pid}:stsoauth2worker.ts`);
15
+ //import 'colors'
16
+ import axios from "axios";
17
+ import { OAuth2ParameterType } from '@nsshunt/stsutils';
18
+ import CryptoUtils from './Utils/CryptoUtils';
19
+ import QueryParams from './Utils/QueryParams';
20
+ import jwt_decode from "jwt-decode";
21
+ import { ClientStorageType, ClientStorageFactory } from './stsStorage';
22
+ import { StatusCodes } from 'http-status-codes';
23
+ import { AuthorizeOptionsResponseType, AuthorizeOptionsResponseMode, OAuthGrantTypes, IOauth2ListenerCommand } from './stsoauth2types';
24
+ const CreateRandomString = (size = 43) => {
25
+ const randomValues = Array.from(self.crypto.getRandomValues(new Uint8Array(size)));
26
+ const b64 = window.btoa(String.fromCharCode(...randomValues));
27
+ return b64;
28
+ //return randomValues.toString('base64');
29
+ };
30
+ // STS Client SDK for SPAs
31
+ export class STSOAuth2Worker {
32
+ constructor(workerPort) {
33
+ //this.#store = app.config.globalProperties.$store;
34
+ //#storageManager = null;
35
+ _STSOAuth2Worker_clientSessionStore.set(this, null); // In memory tokens while the client is logged in
36
+ _STSOAuth2Worker_cUtils.set(this, new CryptoUtils());
37
+ _STSOAuth2Worker_qParams.set(this, new QueryParams());
38
+ _STSOAuth2Worker_STORAGE_AUTHORIZE_OPTIONS_KEY.set(this, 'authorize_options.stsmda.com.au');
39
+ _STSOAuth2Worker_STORAGE_SESSION_KEY.set(this, 'session.stsmda.com.au');
40
+ _STSOAuth2Worker_aic.set(this, null);
41
+ _STSOAuth2Worker_errorCallback.set(this, null); //@@ will be replaced with a message back
42
+ //#store = null;
43
+ _STSOAuth2Worker_handleAuthenticateEvent.set(this, null);
44
+ _STSOAuth2Worker_oauthWorkerPort.set(this, null);
45
+ _STSOAuth2Worker_currentMessageId.set(this, 0);
46
+ // Attempt to restore a previous session using the STSBroker
47
+ /*
48
+ { parameterType: OAuth2ParameterType.CLIENT_ID, errorType: authErrorType.CLIENT_ID_MISMATCH },
49
+ { parameterType: OAuth2ParameterType.SCOPE, errorType: authErrorType.SCOPE_MISMATCH }
50
+ { parameterType: OAuth2ParameterType.REDIRECT_URI, errorType: authErrorType.REDIRECT_URI_MISMATCH },
51
+ { parameterType: OAuth2ParameterType.AUDIENCE, errorType: authErrorType.SCOPE_MISMATCH }
52
+
53
+ Successful Response
54
+ {
55
+ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
56
+ "token_type": "Bearer",
57
+ "expires_in": 3599,
58
+ "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
59
+ "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
60
+ "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
61
+ }
62
+
63
+ Error Response
64
+ {
65
+ "error": "invalid_scope",
66
+ "error_description": "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope https://foo.microsoft.com/mail.read is not valid.\r\nTrace ID: 255d1aef-8c98-452f-ac51-23d051240864\r\nCorrelation ID: fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7\r\nTimestamp: 2016-01-09 02:02:12Z",
67
+ "error_codes": [
68
+ 70011
69
+ ],
70
+ "timestamp": "2016-01-09 02:02:12Z",
71
+ }
72
+
73
+
74
+ */
75
+ this.SetupListener = () => {
76
+ __classPrivateFieldGet(this, _STSOAuth2Worker_oauthWorkerPort, "f").onmessage = async (data) => {
77
+ const auth2ListenerMessage = data.data;
78
+ switch (auth2ListenerMessage.command) {
79
+ case IOauth2ListenerCommand.RESTORE_SESSION:
80
+ __classPrivateFieldGet(this, _STSOAuth2Worker_ProcessCommand, "f").call(this, auth2ListenerMessage, await __classPrivateFieldGet(this, _STSOAuth2Worker_RestoreSession, "f").call(this));
81
+ break;
82
+ case IOauth2ListenerCommand.AUTHORIZE:
83
+ __classPrivateFieldGet(this, _STSOAuth2Worker_ProcessCommand, "f").call(this, auth2ListenerMessage, await __classPrivateFieldGet(this, _STSOAuth2Worker_Authorize, "f").call(this));
84
+ break;
85
+ case IOauth2ListenerCommand.HANDLE_REDIRECT:
86
+ __classPrivateFieldGet(this, _STSOAuth2Worker_ProcessCommand, "f").call(this, auth2ListenerMessage, await __classPrivateFieldGet(this, _STSOAuth2Worker_HandleRedirect, "f").call(this, auth2ListenerMessage.payload));
87
+ break;
88
+ case IOauth2ListenerCommand.LOGOUT:
89
+ __classPrivateFieldGet(this, _STSOAuth2Worker_ProcessCommand, "f").call(this, auth2ListenerMessage, await __classPrivateFieldGet(this, _STSOAuth2Worker_Logout, "f").call(this));
90
+ break;
91
+ default:
92
+ throw new Error(`Command: [${auth2ListenerMessage.command}'] not found.`);
93
+ }
94
+ };
95
+ };
96
+ _STSOAuth2Worker_ProcessCommand.set(this, async (auth2ListenerMessage, response) => {
97
+ const messageResponse = {
98
+ messageId: auth2ListenerMessage.messageId,
99
+ command: auth2ListenerMessage.command,
100
+ payload: response
101
+ };
102
+ __classPrivateFieldGet(this, _STSOAuth2Worker_oauthWorkerPort, "f").postMessage(messageResponse);
103
+ });
104
+ _STSOAuth2Worker_RestoreSession.set(this, async () => {
105
+ //@@ attempt to get from client storage first
106
+ let restoredSessionData = null;
107
+ restoredSessionData = __classPrivateFieldGet(this, _STSOAuth2Worker_clientSessionStore, "f").get(__classPrivateFieldGet(this, _STSOAuth2Worker_STORAGE_SESSION_KEY, "f"));
108
+ if (restoredSessionData !== null) {
109
+ console.log('Session restored from client storage.');
110
+ if (__classPrivateFieldGet(this, _STSOAuth2Worker_aic, "f")) {
111
+ __classPrivateFieldGet(this, _STSOAuth2Worker_aic, "f").UpdateInstrument('m', { LogMessage: 'Session restored from client storage.' });
112
+ }
113
+ }
114
+ else {
115
+ const url = `${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/session`;
116
+ console.log('RestoreSession');
117
+ console.log(url);
118
+ if (__classPrivateFieldGet(this, _STSOAuth2Worker_aic, "f")) {
119
+ __classPrivateFieldGet(this, _STSOAuth2Worker_aic, "f").UpdateInstrument('m', { LogMessage: 'RestoreSession' });
120
+ __classPrivateFieldGet(this, _STSOAuth2Worker_aic, "f").UpdateInstrument('m', { LogMessage: url });
121
+ }
122
+ try {
123
+ const retVal = await axios({
124
+ method: "post",
125
+ url: url,
126
+ data: {
127
+ [OAuth2ParameterType.CLIENT_ID]: process.env.CLIENT_ID,
128
+ [OAuth2ParameterType.SCOPE]: process.env.SCOPE,
129
+ [OAuth2ParameterType.REDIRECT_URI]: process.env.REDIRECT_URI,
130
+ [OAuth2ParameterType.AUDIENCE]: process.env.AUDIENCE
131
+ },
132
+ withCredentials: true,
133
+ timeout: parseInt(process.env.TIMEOUT),
134
+ });
135
+ if (retVal.data.status === StatusCodes.OK) {
136
+ restoredSessionData = retVal.data.detail;
137
+ __classPrivateFieldGet(this, _STSOAuth2Worker_clientSessionStore, "f").set(__classPrivateFieldGet(this, _STSOAuth2Worker_STORAGE_SESSION_KEY, "f"), restoredSessionData);
138
+ console.log('Session restored from server side cookie.');
139
+ //this.#store.commit('stsOAuth2SDK/SessionData', restoredSessionData);
140
+ }
141
+ else {
142
+ //@@ handle error better
143
+ //this.#store.commit('stsOAuth2SDK/SessionData', null);
144
+ console.log('Could not restore previous session:-');
145
+ console.log(JSON.stringify(retVal.data));
146
+ }
147
+ }
148
+ catch (error) {
149
+ //@@ handle error better
150
+ //this.#store.commit('stsOAuth2SDK/SessionData', null);
151
+ console.log('Could not restore previous session (error state):-');
152
+ console.log(error);
153
+ console.log(JSON.stringify(error));
154
+ }
155
+ }
156
+ //@@ must only use in-memory for this ...
157
+ //this.#store.commit('stsOAuth2SDK/SessionData', restoredSessionData);
158
+ if (restoredSessionData !== null) {
159
+ __classPrivateFieldGet(this, _STSOAuth2Worker_handleAuthenticateEvent, "f").call(this, restoredSessionData.id_token);
160
+ console.log('Refreshing tokens ...');
161
+ return __classPrivateFieldGet(this, _STSOAuth2Worker_RefreshToken, "f").call(this);
162
+ }
163
+ else {
164
+ __classPrivateFieldGet(this, _STSOAuth2Worker_handleAuthenticateEvent, "f").call(this, null);
165
+ return false;
166
+ }
167
+ });
168
+ _STSOAuth2Worker_Authorize.set(this, async () => {
169
+ console.log('Authorize ...');
170
+ /* MS Example
171
+ --------------
172
+ https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
173
+ client_id=6731de76-14a6-49ae-97bc-6eba6914391e
174
+ &response_type=code
175
+ &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
176
+ &response_mode=query
177
+ &scope=offline_access%20https%3A%2F%2Fgraph.microsoft.com%2Fuser.read%20api%3A%2F%2F
178
+ &state=12345
179
+ &code_challenge=YTFjNjI1OWYzMzA3MTI4ZDY2Njg5M2RkNmVjNDE5YmEyZGRhOGYyM2IzNjdmZWFhMTQ1ODg3NDcxY2Nl
180
+ &code_challenge_method=S256
181
+
182
+ Successful Response
183
+
184
+ GET http://localhost?
185
+ code=AwABAAAAvPM1KaPlrEqdFSBzjqfTGBCmLdgfSTLEMPGYuNHSUYBrq...
186
+ &state=12345
187
+
188
+ Error Response
189
+ GET http://localhost?
190
+ error=access_denied
191
+ &error_description=the+user+canceled+the+authentication
192
+
193
+ << Hybrid Flow >>
194
+
195
+ https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
196
+ client_id=6731de76-14a6-49ae-97bc-6eba6914391e
197
+ &response_type=code%20id_token
198
+ &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
199
+ &response_mode=fragment
200
+ &scope=openid%20offline_access%20https%3A%2F%2Fgraph.microsoft.com%2Fuser.read
201
+ &state=12345
202
+ &nonce=abcde
203
+ &code_challenge=YTFjNjI1OWYzMzA3MTI4ZDY2Njg5M2RkNmVjNDE5YmEyZGRhOGYyM2IzNjdmZWFhMTQ1ODg3NDcxY2Nl
204
+ &code_challenge_method=S256
205
+
206
+ Successful Response
207
+
208
+ GET https://login.microsoftonline.com/common/oauth2/nativeclient#
209
+ code=AwABAAAAvPM1KaPlrEqdFSBzjqfTGBCmLdgfSTLEMPGYuNHSUYBrq...
210
+ &id_token=eYj...
211
+ &state=12345
212
+
213
+ Notes:
214
+ The nonce is included as a claim inside the returned id_token
215
+ Ref: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
216
+ */
217
+ const client_id = process.env.CLIENT_ID;
218
+ const nonce = __classPrivateFieldGet(this, _STSOAuth2Worker_cUtils, "f").CreateRandomString();
219
+ const response_type = [AuthorizeOptionsResponseType.CODE];
220
+ const redirect_uri = process.env.REDIRECT_URI;
221
+ const response_mode = AuthorizeOptionsResponseMode.QUERY;
222
+ const scope = process.env.SCOPE;
223
+ const state = __classPrivateFieldGet(this, _STSOAuth2Worker_cUtils, "f").CreateRandomString();
224
+ const code_verifier = __classPrivateFieldGet(this, _STSOAuth2Worker_cUtils, "f").CreateRandomString();
225
+ const code_challenge = await __classPrivateFieldGet(this, _STSOAuth2Worker_cUtils, "f").DigestMessage(code_verifier);
226
+ const code_challenge_method = 'S256';
227
+ //let audience = process.env.AUDIENCE;
228
+ const authorizeOptions = {
229
+ client_id,
230
+ nonce,
231
+ response_type,
232
+ redirect_uri,
233
+ response_mode,
234
+ scope,
235
+ state,
236
+ code_challenge,
237
+ code_challenge_method
238
+ };
239
+ const url = `${process.env.AUTH_ENDPOINT}:${process.env.AUTH_PORT}${process.env.AUTH_APIROOT}?${__classPrivateFieldGet(this, _STSOAuth2Worker_qParams, "f").CreateQueryParams(authorizeOptions)}`;
240
+ console.log(url);
241
+ // Now add the code_verifier to the transaction data
242
+ authorizeOptions.code_verifier = code_verifier; //@@ Is this is the only thing required across the transaction ?
243
+ console.log(`Authorize:authorizeOptions: [${JSON.stringify(authorizeOptions)}]`);
244
+ return {
245
+ url,
246
+ authorizeOptions
247
+ };
248
+ //window.location.assign(url);
249
+ //@@ this may need to be a message back to the plugin to re-direct
250
+ //window.location.replace(url);
251
+ });
252
+ _STSOAuth2Worker_HandleRedirect.set(this, async (payload) => {
253
+ const queryVars = payload.queryVars;
254
+ const authorizeOptions = payload.authorizeOptions;
255
+ console.log('HandleRedirect');
256
+ // We have been re-direct back here from the /authorize end-point
257
+ console.log(`HandleRedirect:Query Vars: [${JSON.stringify(queryVars)}]`);
258
+ if (queryVars[OAuth2ParameterType.CODE]) {
259
+ const response = queryVars;
260
+ console.log(`authorizeOptions from transaction state: [${JSON.stringify(authorizeOptions)}]`);
261
+ const redirectState = response.state;
262
+ const authorizeOptionsState = authorizeOptions.state;
263
+ if (authorizeOptionsState.localeCompare(redirectState) === 0) {
264
+ console.log('redirected state (from queryVars) matched previously saved transaction authorizeOptions state'); // green
265
+ return await __classPrivateFieldGet(this, _STSOAuth2Worker_GetToken, "f").call(this, authorizeOptions, response);
266
+ }
267
+ else {
268
+ console.log('redirected state (from queryVars) did NOT match previously saved transaction authorizeOptions state'); // red
269
+ __classPrivateFieldGet(this, _STSOAuth2Worker_errorCallback, "f").call(this, { message: 'State un-matched' });
270
+ return false;
271
+ }
272
+ }
273
+ else if (queryVars[OAuth2ParameterType.ERROR]) {
274
+ const response = queryVars;
275
+ //@@ pass error back to parent thread (to the plugin) as a message
276
+ const error = response.error;
277
+ const errorDescription = response.error_description;
278
+ __classPrivateFieldGet(this, _STSOAuth2Worker_errorCallback, "f").call(this, { message: 'State un-matched' });
279
+ return false;
280
+ }
281
+ else {
282
+ // Invalid redirect query params
283
+ const error = 'Invalid redirect query params'; //@@ fix
284
+ const errorDescription = 'Invalid redirect query params description'; //@@ fix
285
+ __classPrivateFieldGet(this, _STSOAuth2Worker_errorCallback, "f").call(this, { message: 'State un-matched' });
286
+ return false;
287
+ }
288
+ }
289
+ /*
290
+ client_id=6731de76-14a6-49ae-97bc-6eba6914391e
291
+ &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
292
+ &code=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq3n8b2JRLk4OxVXr...
293
+ &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
294
+ &grant_type=authorization_code
295
+ &code_verifier=ThisIsntRandomButItNeedsToBe43CharactersLong
296
+ &client_secret=JqQX2PNo9bpM0uEihUPzyrh // NOTE: Only required for web apps. This secret needs to be URL-Encoded.
297
+
298
+ Successful Response
299
+ {
300
+ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
301
+ "token_type": "Bearer",
302
+ "expires_in": 3599,
303
+ "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
304
+ "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
305
+ "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
306
+ }
307
+ */
308
+ // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
309
+ );
310
+ /*
311
+ client_id=6731de76-14a6-49ae-97bc-6eba6914391e
312
+ &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
313
+ &code=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq3n8b2JRLk4OxVXr...
314
+ &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
315
+ &grant_type=authorization_code
316
+ &code_verifier=ThisIsntRandomButItNeedsToBe43CharactersLong
317
+ &client_secret=JqQX2PNo9bpM0uEihUPzyrh // NOTE: Only required for web apps. This secret needs to be URL-Encoded.
318
+
319
+ Successful Response
320
+ {
321
+ "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...",
322
+ "token_type": "Bearer",
323
+ "expires_in": 3599,
324
+ "scope": "https%3A%2F%2Fgraph.microsoft.com%2Fmail.read",
325
+ "refresh_token": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGAMxZGUTdM0t4B4...",
326
+ "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJhdWQiOiIyZDRkMTFhMi1mODE0LTQ2YTctOD...",
327
+ }
328
+ */
329
+ // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
330
+ _STSOAuth2Worker_GetTokenFromBroker.set(this, async (authorizationCodeFlowParameters) => {
331
+ console.log("#GetTokenFromBroker");
332
+ __classPrivateFieldGet(this, _STSOAuth2Worker_clientSessionStore, "f").remove(__classPrivateFieldGet(this, _STSOAuth2Worker_STORAGE_SESSION_KEY, "f"));
333
+ const url = `${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/token`;
334
+ console.log(`#GetTokenFromBroker:url = [${url}]`);
335
+ console.log(authorizationCodeFlowParameters);
336
+ try {
337
+ const retVal = await axios({
338
+ method: "post",
339
+ url: url,
340
+ data: authorizationCodeFlowParameters,
341
+ withCredentials: true,
342
+ timeout: parseInt(process.env.TIMEOUT),
343
+ });
344
+ console.log(`retVal: ${JSON.stringify(retVal)}`);
345
+ if (retVal.status === StatusCodes.OK) {
346
+ console.log('Storing tokens...');
347
+ const tokenResponse = retVal.data;
348
+ //this.#store.commit('stsOAuth2SDK/SessionData', tokenResponse);
349
+ __classPrivateFieldGet(this, _STSOAuth2Worker_handleAuthenticateEvent, "f").call(this, tokenResponse.id_token);
350
+ __classPrivateFieldGet(this, _STSOAuth2Worker_clientSessionStore, "f").set(__classPrivateFieldGet(this, _STSOAuth2Worker_STORAGE_SESSION_KEY, "f"), tokenResponse);
351
+ return true;
352
+ }
353
+ else if (retVal.status === StatusCodes.UNAUTHORIZED) {
354
+ console.log('NOT Storing tokens...');
355
+ console.log(retVal.status);
356
+ //this.#store.commit('stsOAuth2SDK/SessionData', null);
357
+ __classPrivateFieldGet(this, _STSOAuth2Worker_handleAuthenticateEvent, "f").call(this, null);
358
+ const response = retVal.data;
359
+ //@@ store response in state
360
+ //@@ go to error page ??
361
+ return false;
362
+ }
363
+ else {
364
+ // General error
365
+ console.log('NOT Storing tokens...');
366
+ console.log(retVal.status);
367
+ //this.#store.commit('stsOAuth2SDK/SessionData', null);
368
+ __classPrivateFieldGet(this, _STSOAuth2Worker_handleAuthenticateEvent, "f").call(this, null);
369
+ console.log('Could not obtain access_token from token end-point:-');
370
+ console.log(JSON.stringify(retVal.data));
371
+ //@@ store error in state to show in error page
372
+ return false;
373
+ }
374
+ }
375
+ catch (error) {
376
+ //this.#store.commit('stsOAuth2SDK/SessionData', null);
377
+ __classPrivateFieldGet(this, _STSOAuth2Worker_handleAuthenticateEvent, "f").call(this, null);
378
+ //console.log('Could not restore previous session (error state):-');
379
+ console.log(error);
380
+ console.log(JSON.stringify(error));
381
+ //@@ store error in state to show in error page
382
+ return false;
383
+ }
384
+ }
385
+ // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
386
+ );
387
+ // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
388
+ _STSOAuth2Worker_GetToken.set(this, async (authorizeOptions, authorizeResponse) => {
389
+ console.log("#GetToken");
390
+ console.log(authorizeResponse);
391
+ __classPrivateFieldGet(this, _STSOAuth2Worker_clientSessionStore, "f").set(__classPrivateFieldGet(this, _STSOAuth2Worker_STORAGE_SESSION_KEY, "f"), null);
392
+ const authorizationCodeFlowParameters = {
393
+ client_id: process.env.CLIENT_ID,
394
+ scope: process.env.SCOPE,
395
+ code: authorizeResponse.code,
396
+ redirect_uri: process.env.REDIRECT_URI,
397
+ grant_type: OAuthGrantTypes.AUTHORIZATION_CODE,
398
+ code_verifier: authorizeOptions.code_verifier
399
+ };
400
+ return __classPrivateFieldGet(this, _STSOAuth2Worker_GetTokenFromBroker, "f").call(this, authorizationCodeFlowParameters);
401
+ }
402
+ /*
403
+ // Line breaks for legibility only
404
+
405
+ POST /{tenant}/oauth2/v2.0/token HTTP/1.1
406
+ Host: https://login.microsoftonline.com
407
+ Content-Type: application/x-www-form-urlencoded
408
+
409
+ client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
410
+ &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
411
+ &refresh_token=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq...
412
+ &grant_type=refresh_token
413
+ &client_secret=sampleCredentia1s // NOTE: Only required for web apps. This secret needs to be URL-Encoded
414
+
415
+ Error Response
416
+ {
417
+ "error": "invalid_scope",
418
+ "error_description": "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope https://foo.microsoft.com/mail.read is not valid.\r\nTrace ID: 255d1aef-8c98-452f-ac51-23d051240864\r\nCorrelation ID: fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7\r\nTimestamp: 2016-01-09 02:02:12Z",
419
+ "error_codes": [
420
+ 70011
421
+ ],
422
+ "timestamp": "2016-01-09 02:02:12Z",
423
+ "trace_id": "255d1aef-8c98-452f-ac51-23d051240864",
424
+ "correlation_id": "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7"
425
+ }
426
+ */
427
+ );
428
+ /*
429
+ // Line breaks for legibility only
430
+
431
+ POST /{tenant}/oauth2/v2.0/token HTTP/1.1
432
+ Host: https://login.microsoftonline.com
433
+ Content-Type: application/x-www-form-urlencoded
434
+
435
+ client_id=535fb089-9ff3-47b6-9bfb-4f1264799865
436
+ &scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
437
+ &refresh_token=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq...
438
+ &grant_type=refresh_token
439
+ &client_secret=sampleCredentia1s // NOTE: Only required for web apps. This secret needs to be URL-Encoded
440
+
441
+ Error Response
442
+ {
443
+ "error": "invalid_scope",
444
+ "error_description": "AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope https://foo.microsoft.com/mail.read is not valid.\r\nTrace ID: 255d1aef-8c98-452f-ac51-23d051240864\r\nCorrelation ID: fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7\r\nTimestamp: 2016-01-09 02:02:12Z",
445
+ "error_codes": [
446
+ 70011
447
+ ],
448
+ "timestamp": "2016-01-09 02:02:12Z",
449
+ "trace_id": "255d1aef-8c98-452f-ac51-23d051240864",
450
+ "correlation_id": "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7"
451
+ }
452
+ */
453
+ _STSOAuth2Worker_RefreshToken.set(this, async () => {
454
+ // Get access_token, refresh_token and id_token using OAuth2 Authorization Code Flow
455
+ console.log("RefreshToken");
456
+ //let currentSessionData = this.#store.getters['stsOAuth2SDK/SessionData'];
457
+ const currentSessionData = __classPrivateFieldGet(this, _STSOAuth2Worker_clientSessionStore, "f").get(__classPrivateFieldGet(this, _STSOAuth2Worker_STORAGE_SESSION_KEY, "f"));
458
+ if (currentSessionData) {
459
+ const refreshFlowParameters = {
460
+ client_id: process.env.CLIENT_ID,
461
+ scope: process.env.SCOPE,
462
+ refresh_token: currentSessionData.refresh_token,
463
+ grant_type: OAuthGrantTypes.REFRESH_TOKEN
464
+ };
465
+ return __classPrivateFieldGet(this, _STSOAuth2Worker_GetTokenFromBroker, "f").call(this, refreshFlowParameters);
466
+ }
467
+ else {
468
+ // show error
469
+ //@@ no valid session exists for refresh
470
+ return false;
471
+ }
472
+ }
473
+ // call broker to logout
474
+ // broker to logout of server
475
+ // delete cookie
476
+ // clear session storage
477
+ // clear all state from $store
478
+ );
479
+ // call broker to logout
480
+ // broker to logout of server
481
+ // delete cookie
482
+ // clear session storage
483
+ // clear all state from $store
484
+ _STSOAuth2Worker_Logout.set(this, async () => {
485
+ console.log('Logout');
486
+ const url = `${process.env.BROKER_ENDPOINT}:${process.env.BROKER_PORT}${process.env.BROKER_API_ROOT}/logout`;
487
+ console.log(url);
488
+ const currentSessionData = __classPrivateFieldGet(this, _STSOAuth2Worker_clientSessionStore, "f").get(__classPrivateFieldGet(this, _STSOAuth2Worker_STORAGE_SESSION_KEY, "f"));
489
+ const refresh_token = currentSessionData.refresh_token;
490
+ console.log(refresh_token);
491
+ const decodedRefreshToken = jwt_decode(refresh_token);
492
+ console.log(decodedRefreshToken);
493
+ const sessionId = decodedRefreshToken.sts_session;
494
+ console.log(sessionId);
495
+ __classPrivateFieldGet(this, _STSOAuth2Worker_clientSessionStore, "f").remove(__classPrivateFieldGet(this, _STSOAuth2Worker_STORAGE_SESSION_KEY, "f"));
496
+ //this.#store.commit('stsOAuth2SDK/SessionData', null);
497
+ __classPrivateFieldGet(this, _STSOAuth2Worker_handleAuthenticateEvent, "f").call(this, null);
498
+ try {
499
+ const retVal = await axios({
500
+ method: "post",
501
+ url: url,
502
+ data: {
503
+ sessionId
504
+ },
505
+ withCredentials: true,
506
+ timeout: parseInt(process.env.TIMEOUT),
507
+ });
508
+ if (retVal.data.status === StatusCodes.OK) {
509
+ return true;
510
+ }
511
+ else {
512
+ console.log('Error during logout (server side)');
513
+ console.log(JSON.stringify(retVal.data));
514
+ return false;
515
+ }
516
+ }
517
+ catch (error) {
518
+ console.log('Error during logout (server side)');
519
+ console.log(error);
520
+ console.log(JSON.stringify(error));
521
+ return false;
522
+ }
523
+ });
524
+ // In memory storage for OAuth2 tokens for our valid session
525
+ __classPrivateFieldSet(this, _STSOAuth2Worker_clientSessionStore, new ClientStorageFactory({ clientStorageType: ClientStorageType.MEMORY_STORAGE }).GetStorage(), "f");
526
+ //@@ needs to be sent the instrument manager controller port
527
+ //@@this.#aic = app.config.globalProperties.$sts.aic.PrimaryPublishInstrumentController;
528
+ //this.#handleAuthenticateEvent = handleAuthenticateEvent;
529
+ __classPrivateFieldSet(this, _STSOAuth2Worker_handleAuthenticateEvent, (id_token) => {
530
+ const message = {
531
+ messageId: -1,
532
+ command: IOauth2ListenerCommand.AUTHENTICATE_EVENT
533
+ };
534
+ __classPrivateFieldGet(this, _STSOAuth2Worker_ProcessCommand, "f").call(this, message, id_token);
535
+ }, "f");
536
+ __classPrivateFieldSet(this, _STSOAuth2Worker_errorCallback, (error) => {
537
+ const message = {
538
+ messageId: -1,
539
+ command: IOauth2ListenerCommand.ERROR
540
+ };
541
+ __classPrivateFieldGet(this, _STSOAuth2Worker_ProcessCommand, "f").call(this, message, error);
542
+ }, "f");
543
+ __classPrivateFieldSet(this, _STSOAuth2Worker_oauthWorkerPort, workerPort, "f");
544
+ this.SetupListener();
545
+ }
546
+ }
547
+ _STSOAuth2Worker_clientSessionStore = new WeakMap(), _STSOAuth2Worker_cUtils = new WeakMap(), _STSOAuth2Worker_qParams = new WeakMap(), _STSOAuth2Worker_STORAGE_AUTHORIZE_OPTIONS_KEY = new WeakMap(), _STSOAuth2Worker_STORAGE_SESSION_KEY = new WeakMap(), _STSOAuth2Worker_aic = new WeakMap(), _STSOAuth2Worker_errorCallback = new WeakMap(), _STSOAuth2Worker_handleAuthenticateEvent = new WeakMap(), _STSOAuth2Worker_oauthWorkerPort = new WeakMap(), _STSOAuth2Worker_currentMessageId = new WeakMap(), _STSOAuth2Worker_ProcessCommand = new WeakMap(), _STSOAuth2Worker_RestoreSession = new WeakMap(), _STSOAuth2Worker_Authorize = new WeakMap(), _STSOAuth2Worker_HandleRedirect = new WeakMap(), _STSOAuth2Worker_GetTokenFromBroker = new WeakMap(), _STSOAuth2Worker_GetToken = new WeakMap(), _STSOAuth2Worker_RefreshToken = new WeakMap(), _STSOAuth2Worker_Logout = new WeakMap();
548
+ let oAuth2Worker = null;
549
+ onmessage = async function (data) {
550
+ const workerPort = data.data;
551
+ oAuth2Worker = new STSOAuth2Worker(workerPort);
552
+ };
553
+ //# sourceMappingURL=stsoauth2worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsoauth2worker.js","sourceRoot":"","sources":["../src/stsoauth2worker.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,OAAO,CAAC,GAAG,qBAAqB,CAAC,CAAC;AAE9D,iBAAiB;AAEjB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAc,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,WAAW,MAAM,qBAAqB,CAAA;AAC7C,OAAO,WAAW,MAAM,qBAAqB,CAAA;AAE7C,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAe,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,4BAA4B,EAAE,4BAA4B,EACmC,eAA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AI,uCAAuB,IAAI,oBAAoB,CAAiB,EAAC,iBAAiB,EAAE,iBAAiB,CAAC,cAAc,EAAC,CAAC,CAAC,UAAU,EAAE,MAAA,CAAC;QAExI,4DAA4D;QAC5D,wFAAwF;QAExF,0DAA0D;QAC1D,uBAAA,IAAI,4CAA4B,CAAC,QAAgB,EAAE,EAAE;YACpD,MAAM,OAAO,GAA2B;gBACvC,SAAS,EAAE,CAAC,CAAC;gBACb,OAAO,EAAE,sBAAsB,CAAC,kBAAkB;aAClD,CAAA;YACD,uBAAA,IAAI,uCAAgB,MAApB,IAAI,EAAiB,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzC,CAAC,MAAA,CAAA;QAED,uBAAA,IAAI,kCAAkB,CAAC,KAAU,EAAE,EAAE;YACpC,MAAM,OAAO,GAA2B;gBACvC,SAAS,EAAE,CAAC,CAAC;gBACb,OAAO,EAAE,sBAAsB,CAAC,KAAK;aACrC,CAAA;YACD,uBAAA,IAAI,uCAAgB,MAApB,IAAI,EAAiB,OAAO,EAAE,KAAK,CAAC,CAAC;QACtC,CAAC,MAAA,CAAA;QAED,uBAAA,IAAI,oCAAoB,UAAU,MAAA,CAAC;QACnC,IAAI,CAAC,aAAa,EAAE,CAAC;IACtB,CAAC;CA6cD;;AAED,IAAI,YAAY,GAAoB,IAAI,CAAC;AAEzC,SAAS,GAAG,KAAK,WAAU,IAAkB;IAE5C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAmB,CAAC;IAC5C,YAAY,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,CAAC;AAChD,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nsshunt/stsoauth2plugin",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "STS OAuth2 VUE Plugin",
5
- "main": "./dist/index.js",
5
+ "main": "dist/index.js",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
8
8
  "lint": "eslint . --ext js,jsx,ts,tsx --fix",