@nsshunt/stsoauth2plugin 0.1.13 → 0.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsoauth2plugin",
3
- "version": "0.1.13",
3
+ "version": "0.1.16",
4
4
  "description": "STS OAuth2 VUE Plugin",
5
5
  "files": [
6
6
  "dist",
@@ -20,8 +20,7 @@
20
20
  "lint": "eslint . --ext js,jsx,ts,tsx --fix",
21
21
  "test": "jest --detectOpenHandles --no-cache",
22
22
  "testwatch": "jest --watchAll --detectOpenHandles --no-cache",
23
- "build": "vite build",
24
- "build2": "vue-tsc --noEmit && vite build"
23
+ "build": "tsc && vite build"
25
24
  },
26
25
  "repository": {
27
26
  "type": "git",
@@ -50,6 +49,8 @@
50
49
  "homepage": "https://github.com/nsshunt/stsoauth2plugin#readme",
51
50
  "dependencies": {
52
51
  "@nsshunt/stsutils": "^1.15.1",
52
+ "axios": "^0.27.2",
53
+ "debug": "^4.3.4",
53
54
  "es-cookie": "^1.3.2",
54
55
  "http-status-codes": "^2.2.0",
55
56
  "jwt-decode": "^3.1.2",
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ import { STSOAuth2Manager } from './stsoauth2manager'
2
2
 
3
3
  export * from './stsoauth2types'
4
4
  export * from './stsoauth2manager'
5
+ export * from './stsoauth2worker'
5
6
 
6
7
  export const STSOAuth2ManagerPlugin = {
7
8
  install: (app, router) => {
@@ -17,10 +17,6 @@ import { IStsStorage, ClientStorageType, ClientStorageFactory } from './stsStora
17
17
  import jwt_decode from "jwt-decode";
18
18
  //import { transformWithEsbuild } from "vite";
19
19
 
20
- declare module "./stsoauth2worker?*"
21
-
22
- import MyWorker from './stsoauth2worker?worker&inline'
23
-
24
20
  // STS Client SDK for SPAs
25
21
  export class STSOAuth2Manager {
26
22
  #storageManager = null;
@@ -56,8 +52,7 @@ export class STSOAuth2Manager {
56
52
  });
57
53
  */
58
54
 
59
- //this.#worker = new Worker(new URL('./stsoauth2worker.ts', import.meta.url));
60
- this.#worker = new MyWorker();
55
+ this.#worker = new Worker(new URL('./stsoauth2worker.ts', import.meta.url));
61
56
 
62
57
  this.#worker.onmessage = (data: MessageEvent) => {
63
58
  console.log(`this.#worker.onmessage = [${data}]`); // green
@@ -28,7 +28,7 @@ const CreateRandomString = (size = 43) => {
28
28
  }
29
29
 
30
30
  // STS Client SDK for SPAs
31
- class STSOAuth2Worker {
31
+ export class STSOAuth2Worker {
32
32
  //#storageManager = null;
33
33
  #clientSessionStore: IStsStorage<ITokenResponse> = null; // In memory tokens while the client is logged in
34
34
  #cUtils = new CryptoUtils();
@@ -0,0 +1,7 @@
1
+ export declare class CryptoUtils {
2
+ DigestMessage: (message: any) => Promise<string>;
3
+ CreateRandomString: (size?: number) => string;
4
+ CreateRandomStringEx: () => string;
5
+ }
6
+ export default CryptoUtils;
7
+ //# sourceMappingURL=CryptoUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CryptoUtils.d.ts","sourceRoot":"","sources":["../../src/Utils/CryptoUtils.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACvB,aAAa,oCASZ;IAED,kBAAkB,4BAOjB;IAED,oBAAoB,eAOnB;CACD;AAED,eAAe,WAAW,CAAA"}
@@ -0,0 +1,8 @@
1
+ declare class QueryParams {
2
+ DecodeQueryParams: (params: any) => {};
3
+ CreateQueryParams: (params: any) => string;
4
+ _GetQueryParams: (param: any) => {};
5
+ GetQueryParams: () => {};
6
+ }
7
+ export default QueryParams;
8
+ //# sourceMappingURL=QueryParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryParams.d.ts","sourceRoot":"","sources":["../../src/Utils/QueryParams.ts"],"names":[],"mappings":"AAEA,cAAM,WAAW;IAChB,iBAAiB,sBAQhB;IAED,iBAAiB,0BAWhB;IAED,eAAe,qBAcd;IAED,cAAc,WAEb;CACD;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './stsoauth2types';
2
+ export * from './stsoauth2manager';
3
+ export * from './stsoauth2worker';
4
+ export declare const STSOAuth2ManagerPlugin: {
5
+ install: (app: any, router: any) => void;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AAEjC,eAAO,MAAM,sBAAsB;;CAKlC,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { JSONObject } from "@nsshunt/stsutils";
2
+ export interface IStsStorage<T> {
3
+ get(key: string): T;
4
+ set(key: string, value: T, options?: JSONObject): void;
5
+ remove(key: string): void;
6
+ }
7
+ export declare enum ClientStorageType {
8
+ LOCAL_STORAGE = "LocalStorage",
9
+ SESSION_STORAGE = "SessionStorage",
10
+ COOKIE_STORAGE = "CookieStorage",
11
+ MEMORY_STORAGE = "MemoryStorage"
12
+ }
13
+ export declare class ClientStorageOptions {
14
+ clientStorageType: ClientStorageType;
15
+ storageOptions?: JSONObject;
16
+ }
17
+ export declare class ClientStorageFactory<T> {
18
+ #private;
19
+ constructor(options: ClientStorageOptions);
20
+ GetStorage(): IStsStorage<T>;
21
+ }
22
+ //# sourceMappingURL=stsStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsStorage.d.ts","sourceRoot":"","sources":["../src/stsStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;IACnB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACtD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,oBAAY,iBAAiB;IAC5B,aAAa,iBAAiB;IAC9B,eAAe,mBAAmB;IAClC,cAAc,kBAAkB;IAChC,cAAc,kBAAkB;CAChC;AA2GD,qBAAa,oBAAoB;IAChC,iBAAiB,EAAE,iBAAiB,CAAoC;IACxE,cAAc,CAAC,EAAE,UAAU,CAAA;CAC3B;AAED,qBAAa,oBAAoB,CAAC,CAAC;;gBAItB,OAAO,EAAE,oBAAoB;IAoBzC,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC;CAI5B"}
@@ -0,0 +1,11 @@
1
+ import { JSONObject } from '@nsshunt/stsutils';
2
+ import { ISTSOAuth2ManagerOptions } from './stsoauth2types';
3
+ export declare class STSOAuth2Manager {
4
+ #private;
5
+ constructor(app: any, options: ISTSOAuth2ManagerOptions);
6
+ RestoreSession: () => Promise<boolean>;
7
+ Authorize: () => Promise<void>;
8
+ HandleRedirect: (queryVars: JSONObject) => Promise<boolean>;
9
+ Logout: () => Promise<boolean>;
10
+ }
11
+ //# sourceMappingURL=stsoauth2manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsoauth2manager.d.ts","sourceRoot":"","sources":["../src/stsoauth2manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAuB,MAAM,mBAAmB,CAAC;AAKpE,OAAO,EACN,wBAAwB,EAAkF,MAAM,kBAAkB,CAAA;AAWnI,qBAAa,gBAAgB;;gBAkBhB,GAAG,KAAA,EAAE,OAAO,EAAE,wBAAwB;IA8PlD,cAAc,QAAY,QAAQ,OAAO,CAAC,CAQzC;IAED,SAAS,QAAa,QAAQ,IAAI,CAAC,CASlC;IAED,cAAc,cAAqB,UAAU,KAAG,QAAQ,OAAO,CAAC,CAoB/D;IAED,MAAM,QAAa,QAAQ,OAAO,CAAC,CAQlC;CACD"}
@@ -0,0 +1,89 @@
1
+ import { Router } from 'vue-router';
2
+ export declare enum AuthorizeOptionsResponseType {
3
+ CODE = "code",
4
+ ID_TOKEN = "id_token",
5
+ TOKEN = "token"
6
+ }
7
+ export declare enum AuthorizeOptionsResponseMode {
8
+ QUERY = "query",
9
+ FRAGMENT = "fragment",
10
+ FORM_POST = "form_post"
11
+ }
12
+ export interface IAuthorizeOptions {
13
+ client_id: string;
14
+ nonce: string;
15
+ response_type: AuthorizeOptionsResponseType[];
16
+ redirect_uri: string;
17
+ response_mode: AuthorizeOptionsResponseMode;
18
+ scope: string;
19
+ state: string;
20
+ code_challenge: string;
21
+ code_challenge_method: string;
22
+ code_verifier?: string;
23
+ }
24
+ export interface IAuthorizeResponse {
25
+ state: string;
26
+ code: string;
27
+ }
28
+ export interface IAuthorizeErrorResponse {
29
+ error: string;
30
+ error_description: string;
31
+ }
32
+ export declare enum OAuthGrantTypes {
33
+ CLIENT_CREDENTIALS = "client_credentials",
34
+ AUTHORIZATION_CODE = "authorization_code",
35
+ REFRESH_TOKEN = "refresh_token"
36
+ }
37
+ export interface IAuthorizationCodeFlowParameters {
38
+ client_id: string;
39
+ scope: string;
40
+ code: string;
41
+ redirect_uri: string;
42
+ grant_type: OAuthGrantTypes;
43
+ code_verifier: string;
44
+ }
45
+ export interface IRefreshFlowParameters {
46
+ client_id: string;
47
+ scope: string;
48
+ refresh_token: string;
49
+ grant_type: OAuthGrantTypes;
50
+ }
51
+ export interface ITokenResponse {
52
+ access_token: string;
53
+ token_type: string;
54
+ expires_in: number;
55
+ scope: string;
56
+ refresh_token: string;
57
+ id_token: string;
58
+ }
59
+ export interface ITokenErrorResponse {
60
+ error: string;
61
+ error_description: string;
62
+ error_codes: number[];
63
+ timestamp: number;
64
+ details: unknown;
65
+ }
66
+ export declare type AuthenticateEvent = (id_token: string) => void;
67
+ export declare enum IOauth2ListenerCommand {
68
+ RESTORE_SESSION = "RestoreSession",
69
+ AUTHORIZE = "Authorize",
70
+ HANDLE_REDIRECT = "HandleRedirect",
71
+ LOGOUT = "Logout",
72
+ AUTHENTICATE_EVENT = "AuthenticateEvent",
73
+ ERROR = "Error"
74
+ }
75
+ export interface IOauth2ListenerMessage {
76
+ messageId?: number;
77
+ command: IOauth2ListenerCommand;
78
+ payload?: any;
79
+ }
80
+ export interface IOauth2ListenerMessageResponse {
81
+ messageId: number;
82
+ command: IOauth2ListenerCommand;
83
+ payload: any;
84
+ }
85
+ export interface ISTSOAuth2ManagerOptions {
86
+ router: Router;
87
+ authenticateEvent?: AuthenticateEvent;
88
+ }
89
+ //# sourceMappingURL=stsoauth2types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsoauth2types.d.ts","sourceRoot":"","sources":["../src/stsoauth2types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,oBAAY,4BAA4B;IACvC,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,KAAK,UAAU;CACf;AAED,oBAAY,4BAA4B;IACvC,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,SAAS,cAAc;CACvB;AAGD,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,4BAA4B,EAAE,CAAC;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,4BAA4B,CAAA;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CA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AA;IAClB,OAAO,EAAE,sBAAsB,CAAA;IAC/B,OAAO,CAAC,EAAE,GAAG,CAAA;CACb;AAED,MAAM,WAAW,8BAA8B;IAC9C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,sBAAsB,CAAA;IAC/B,OAAO,EAAE,GAAG,CAAA;CACZ;AAED,MAAM,WAAW,wBAAwB;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CACrC"}
@@ -0,0 +1,6 @@
1
+ export declare class STSOAuth2Worker {
2
+ #private;
3
+ constructor(workerPort: MessagePort);
4
+ SetupListener: () => void;
5
+ }
6
+ //# sourceMappingURL=stsoauth2worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsoauth2worker.d.ts","sourceRoot":"","sources":["../src/stsoauth2worker.ts"],"names":[],"mappings":"AA8BA,qBAAa,eAAe;;gBAcf,UAAU,EAAE,WAAW;IA6DnC,aAAa,aAoBZ;CAwZD"}