@nsshunt/stsutils 1.9.2 → 1.10.0

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,24 @@
1
+ export type errorCode = {
2
+ code: string
3
+ description: string
4
+ }
5
+
6
+ export type errorPayload = {
7
+ error: string,
8
+ error_description: string,
9
+ timestamp: number,
10
+ //trace_id: "255d1aef-8c98-452f-ac51-23d051240864", //@@
11
+ //correlation_id: "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7", //@@
12
+ details?: any
13
+ }
14
+
15
+ export function GetErrorPayload(errorCode: errorCode, details: any = null): errorPayload {
16
+ return {
17
+ error: errorCode.code,
18
+ error_description: errorCode.description,
19
+ timestamp: Date.now(),
20
+ //trace_id: "255d1aef-8c98-452f-ac51-23d051240864", //@@
21
+ //correlation_id: "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7", //@@
22
+ details: details
23
+ }
24
+ }
package/index.ts CHANGED
@@ -1,23 +1,5 @@
1
- const sleep = require('./sleep.js');
2
- const AuthUtilsBrowser = require('./authutilsbrowser.js');
3
- //const STSOptionsBase = require('./stsoptionsbase.js');
4
- const { AddSchema, Validate } = require('./validate.js');
5
- const GetErrorPayload = require('./errorhandling.js');
6
- const { OAuth2ParameterType, OIDCStandardClaim, OIDCAddressClaim, compareParameterTypes } = require('./oauth2terms.js');
7
-
8
- export declare class status {
9
- static readonly SUCCESS = 200;
10
- static readonly CREATED = 201;
11
- static readonly NO_CONTENT = 204;
12
- static readonly BAD = 400;
13
- static readonly UNAUTHORIZED = 401;
14
- static readonly NOTFOUND = 404;
15
- static readonly CONFLICT = 409;
16
- static readonly ERROR = 500;
17
- static readonly SERVER_ERROR_MALFORMED = 520;
18
- }
19
-
20
- module.exports = {
21
- sleep, AuthUtilsBrowser, AddSchema, Validate, GetErrorPayload,
22
- OAuth2ParameterType, OIDCStandardClaim, OIDCAddressClaim, compareParameterTypes
23
- };
1
+ export * from './errorhandling'
2
+ export * from './stsoptionsbase'
3
+ export * from './sleep'
4
+ export * from './validate'
5
+ export * from './oauth2terms'
package/oauth2terms.ts ADDED
@@ -0,0 +1,97 @@
1
+ import { errorCode, errorPayload } from './errorhandling'
2
+
3
+ // Ref: https://datatracker.ietf.org/doc/html/rfc6749#appendix-A
4
+ export class OAuth2ParameterType {
5
+ static readonly AUDIENCE = 'AUDIENCE' // STS Extension
6
+ static readonly CLIENT_ID = 'client_id'
7
+ static readonly CLIENT_SECRET = 'client_secret'
8
+ static readonly RESPONSE_TYPE = 'response_type'
9
+ static readonly SCOPE = 'scope'
10
+ static readonly STATE = 'state'
11
+ static readonly REDIRECT_URI = 'redirect_uri'
12
+ static readonly ERROR = 'error'
13
+ static readonly ERROR_DESCRIPTION = 'error_description'
14
+ static readonly ERROR_CODES = 'error_codes' // STS Extension
15
+ static readonly ERROR_URI = 'error_uri'
16
+ static readonly GRANT_TYPE = 'grant_type'
17
+ static readonly CODE = 'code'
18
+ static readonly ACCESS_TOKEN = 'access_token'
19
+ static readonly TOKEN_TYPE = 'token_type'
20
+ static readonly EXPIRES_IN = 'expires_in'
21
+ static readonly USERNAME = 'username'
22
+ static readonly PASSWORD = 'password'
23
+ static readonly REFRESH_TOKEN = 'refresh_token'
24
+ static readonly RESPONSE_MODE = 'response_mode' // STS Extension
25
+ static readonly TIMESTAMP = 'timestamp' // STS Extension
26
+ static readonly TRACE_ID = 'trace_id' // STS Extension
27
+ static readonly CORRELATION_ID = 'correlation_id' // STS Extension
28
+ }
29
+
30
+ export class OAuth2ParameterErrorType {
31
+ static readonly NOT_EQUAL: errorCode = {
32
+ code: 'STS_OAUTH2_ERR_0001',
33
+ description: 'Parameter values not equal.'
34
+ }
35
+ static readonly NOT_PRESENT: errorCode = {
36
+ code: 'STS_OAUTH2_ERR_0002',
37
+ description: 'Parameter not provided.'
38
+ }
39
+ static readonly INVALID_FORMAT: errorCode = {
40
+ code: 'STS_OAUTH2_ERR_0003',
41
+ description: 'Parameter value format invalid.'
42
+ }
43
+ static readonly EXPIRED: errorCode = {
44
+ code: 'STS_OAUTH2_ERR_0004',
45
+ description: 'Parameter value expired.'
46
+ }
47
+ }
48
+
49
+ // OIDC Standard Claims
50
+ // Ref: https://openid.net/specs/openid-connect-core-1_0.html#Claims
51
+ export class OIDCStandardClaim {
52
+ static readonly SUB = 'sub'
53
+ static readonly NAME = 'name'
54
+ static readonly GIVEN_NAME = 'given_name'
55
+ static readonly FAMILY_NAME = 'family_name'
56
+ static readonly MIDDLE_NAME = 'middle_name'
57
+ static readonly NICKNAME = 'nickname'
58
+ static readonly PREFERRED_USERNAME = 'preferred_username'
59
+ static readonly PROFILE = 'profile'
60
+ static readonly PICTURE = 'picture'
61
+ static readonly WEBSITE = 'website'
62
+ static readonly EMAIL = 'email'
63
+ static readonly EMAIL_VERIFIED = 'email_verified'
64
+ static readonly GENDER = 'gender'
65
+ static readonly BIRTHDATE = 'birthdate'
66
+ static readonly ZONEINFO = 'zoneinfo'
67
+ static readonly LOCALE = 'locale'
68
+ static readonly PHONE_NUMBER = 'phone_number'
69
+ static readonly PHONE_NUMBER_VERIFIED = 'phone_number_verified'
70
+ static readonly ADDRESS = 'address'
71
+ static readonly CLIENT_SECRET = 'client_secret'
72
+ static readonly NONCE = 'nonce' // STS Extension
73
+ }
74
+
75
+ export class OIDCAddressClaim {
76
+ static readonly FORMATTED = 'formatted'
77
+ static readonly STREET_ADDRESS = 'street_address'
78
+ static readonly LOCALITY = 'locality'
79
+ static readonly REGION = 'region'
80
+ static readonly COUNTRY = 'country'
81
+ }
82
+
83
+ export function compareParameterTypes(source1: string[], source2: string[], authParameterTypes: string[]): errorPayload[] {
84
+ const errors: errorPayload[] = [ ];
85
+ authParameterTypes.forEach(authParameterType => {
86
+ if (source1[authParameterType].localeCompare(source2[authParameterType]) !== 0) {
87
+ const error: errorPayload = {
88
+ error: OAuth2ParameterErrorType.NOT_EQUAL.code,
89
+ error_description: OAuth2ParameterErrorType.NOT_EQUAL.description,
90
+ timestamp: Date.now(),
91
+ details: `${OAuth2ParameterErrorType.NOT_EQUAL.description}: Parameter: [${authParameterType}]`
92
+ }
93
+ errors.push(error);
94
+ }
95
+ });
96
+ return errors;
97
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@nsshunt/stsutils",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "lint": "eslint . --ext js,jsx,ts,tsx --fix",
8
8
  "test": "jest --detectOpenHandles --no-cache",
9
- "testwatch": "jest --watchAll --detectOpenHandles --no-cache"
9
+ "testwatch": "jest --watchAll --detectOpenHandles --no-cache",
10
+ "build": "tsc"
10
11
  },
11
12
  "repository": {
12
13
  "type": "git",
@@ -1,9 +1,8 @@
1
- const sleep = (milliseconds) =>
2
- {
1
+ export async function Sleep(milliseconds = 1000): Promise<void> {
3
2
  return new Promise(resolve => setTimeout(resolve, milliseconds))
4
3
  }
5
4
 
6
5
  // poolsleep is required to avoid JEST reporting unclosed handles during shutdown of all tests
7
- const jestsleep = () => sleep(100);
8
-
9
- module.exports = { sleep, jestsleep }
6
+ export async function JestSleep(): Promise<void> {
7
+ return Sleep(100);
8
+ }
package/stsoptionsbase.ts CHANGED
@@ -1,4 +1,4 @@
1
- const { Validate } = require('./validate.js');
1
+ import { Validate } from './validate.js'
2
2
 
3
3
  export class STSOptionsBase
4
4
  {
@@ -1,8 +1,12 @@
1
- export = GetErrorPayload;
2
- declare function GetErrorPayload(errorCode: any, details?: any): {
3
- error: any;
4
- error_description: any;
1
+ export declare type errorCode = {
2
+ code: string;
3
+ description: string;
4
+ };
5
+ export declare type errorPayload = {
6
+ error: string;
7
+ error_description: string;
5
8
  timestamp: number;
6
- details: any;
9
+ details?: any;
7
10
  };
11
+ export declare function GetErrorPayload(errorCode: errorCode, details?: any): errorPayload;
8
12
  //# sourceMappingURL=errorhandling.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorhandling.d.ts","sourceRoot":"","sources":["../errorhandling.js"],"names":[],"mappings":";AAAA;;;;;EASC"}
1
+ {"version":3,"file":"errorhandling.d.ts","sourceRoot":"","sources":["../errorhandling.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,oBAAY,YAAY,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAGlB,OAAO,CAAC,EAAE,GAAG,CAAA;CACb,CAAA;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAE,GAAU,GAAG,YAAY,CASvF"}
package/types/index.d.ts CHANGED
@@ -1,12 +1,6 @@
1
- export declare class status {
2
- static readonly SUCCESS = 200;
3
- static readonly CREATED = 201;
4
- static readonly NO_CONTENT = 204;
5
- static readonly BAD = 400;
6
- static readonly UNAUTHORIZED = 401;
7
- static readonly NOTFOUND = 404;
8
- static readonly CONFLICT = 409;
9
- static readonly ERROR = 500;
10
- static readonly SERVER_ERROR_MALFORMED = 520;
11
- }
1
+ export * from './errorhandling';
2
+ export * from './stsoptionsbase';
3
+ export * from './sleep';
4
+ export * from './validate';
5
+ export * from './oauth2terms';
12
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,OAAO,MAAM;IAC1B,MAAM,CAAC,QAAQ,CAAC,OAAO,OAAO;IAC9B,MAAM,CAAC,QAAQ,CAAC,OAAO,OAAO;IAC9B,MAAM,CAAC,QAAQ,CAAC,UAAU,OAAO;IACjC,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO;IAC1B,MAAM,CAAC,QAAQ,CAAC,YAAY,OAAO;IACnC,MAAM,CAAC,QAAQ,CAAC,QAAQ,OAAO;IAC/B,MAAM,CAAC,QAAQ,CAAC,QAAQ,OAAO;IAC/B,MAAM,CAAC,QAAQ,CAAC,KAAK,OAAO;IAC5B,MAAM,CAAC,QAAQ,CAAC,sBAAsB,OAAO;CAC7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA"}
@@ -1,75 +1,64 @@
1
- export const OAuth2ParameterType: Readonly<{
2
- AUDIENCE: string;
3
- CLIENT_ID: string;
4
- CLIENT_SECRET: string;
5
- RESPONSE_TYPE: string;
6
- SCOPE: string;
7
- STATE: string;
8
- REDIRECT_URI: string;
9
- ERROR: string;
10
- ERROR_DESCRIPTION: string;
11
- ERROR_CODES: string;
12
- ERROR_URI: string;
13
- GRANT_TYPE: string;
14
- CODE: string;
15
- ACCESS_TOKEN: string;
16
- TOKEN_TYPE: string;
17
- EXPIRES_IN: string;
18
- USERNAME: string;
19
- PASSWORD: string;
20
- REFRESH_TOKEN: string;
21
- RESPONSE_MODE: string;
22
- TIMESTAMP: string;
23
- TRACE_ID: string;
24
- CORRELATION_ID: string;
25
- }>;
26
- export const OIDCStandardClaim: Readonly<{
27
- SUB: string;
28
- NAME: string;
29
- GIVEN_NAME: string;
30
- FAMILY_NAME: string;
31
- MIDDLE_NAME: string;
32
- NICKNAME: string;
33
- PREFERRED_USERNAME: string;
34
- PROFILE: string;
35
- PICTURE: string;
36
- WEBSITE: string;
37
- EMAIL: string;
38
- EMAIL_VERIFIED: string;
39
- GENDER: string;
40
- BIRTHDATE: string;
41
- ZONEINFO: string;
42
- LOCALE: string;
43
- PHONE_NUMBER: string;
44
- PHONE_NUMBER_VERIFIED: string;
45
- ADDRESS: string;
46
- CLIENT_SECRET: string;
47
- NONCE: string;
48
- }>;
49
- export const OIDCAddressClaim: Readonly<{
50
- FORMATTED: string;
51
- STREET_ADDRESS: string;
52
- LOCALITY: string;
53
- REGION: string;
54
- COUNTRY: string;
55
- }>;
56
- export const OAuth2ParameterErrorType: Readonly<{
57
- NOT_EQUAL: {
58
- code: string;
59
- description: string;
60
- };
61
- NOT_PRESENT: {
62
- code: string;
63
- description: string;
64
- };
65
- INVALID_FORMAT: {
66
- code: string;
67
- description: string;
68
- };
69
- EXPIRED: {
70
- code: string;
71
- description: string;
72
- };
73
- }>;
74
- export function compareParameterTypes(source1: any, source2: any, authParameterTypes: any): any[];
1
+ import { errorCode, errorPayload } from './errorhandling';
2
+ export declare class OAuth2ParameterType {
3
+ static readonly AUDIENCE = "AUDIENCE";
4
+ static readonly CLIENT_ID = "client_id";
5
+ static readonly CLIENT_SECRET = "client_secret";
6
+ static readonly RESPONSE_TYPE = "response_type";
7
+ static readonly SCOPE = "scope";
8
+ static readonly STATE = "state";
9
+ static readonly REDIRECT_URI = "redirect_uri";
10
+ static readonly ERROR = "error";
11
+ static readonly ERROR_DESCRIPTION = "error_description";
12
+ static readonly ERROR_CODES = "error_codes";
13
+ static readonly ERROR_URI = "error_uri";
14
+ static readonly GRANT_TYPE = "grant_type";
15
+ static readonly CODE = "code";
16
+ static readonly ACCESS_TOKEN = "access_token";
17
+ static readonly TOKEN_TYPE = "token_type";
18
+ static readonly EXPIRES_IN = "expires_in";
19
+ static readonly USERNAME = "username";
20
+ static readonly PASSWORD = "password";
21
+ static readonly REFRESH_TOKEN = "refresh_token";
22
+ static readonly RESPONSE_MODE = "response_mode";
23
+ static readonly TIMESTAMP = "timestamp";
24
+ static readonly TRACE_ID = "trace_id";
25
+ static readonly CORRELATION_ID = "correlation_id";
26
+ }
27
+ export declare class OAuth2ParameterErrorType {
28
+ static readonly NOT_EQUAL: errorCode;
29
+ static readonly NOT_PRESENT: errorCode;
30
+ static readonly INVALID_FORMAT: errorCode;
31
+ static readonly EXPIRED: errorCode;
32
+ }
33
+ export declare class OIDCStandardClaim {
34
+ static readonly SUB = "sub";
35
+ static readonly NAME = "name";
36
+ static readonly GIVEN_NAME = "given_name";
37
+ static readonly FAMILY_NAME = "family_name";
38
+ static readonly MIDDLE_NAME = "middle_name";
39
+ static readonly NICKNAME = "nickname";
40
+ static readonly PREFERRED_USERNAME = "preferred_username";
41
+ static readonly PROFILE = "profile";
42
+ static readonly PICTURE = "picture";
43
+ static readonly WEBSITE = "website";
44
+ static readonly EMAIL = "email";
45
+ static readonly EMAIL_VERIFIED = "email_verified";
46
+ static readonly GENDER = "gender";
47
+ static readonly BIRTHDATE = "birthdate";
48
+ static readonly ZONEINFO = "zoneinfo";
49
+ static readonly LOCALE = "locale";
50
+ static readonly PHONE_NUMBER = "phone_number";
51
+ static readonly PHONE_NUMBER_VERIFIED = "phone_number_verified";
52
+ static readonly ADDRESS = "address";
53
+ static readonly CLIENT_SECRET = "client_secret";
54
+ static readonly NONCE = "nonce";
55
+ }
56
+ export declare class OIDCAddressClaim {
57
+ static readonly FORMATTED = "formatted";
58
+ static readonly STREET_ADDRESS = "street_address";
59
+ static readonly LOCALITY = "locality";
60
+ static readonly REGION = "region";
61
+ static readonly COUNTRY = "country";
62
+ }
63
+ export declare function compareParameterTypes(source1: string[], source2: string[], authParameterTypes: string[]): errorPayload[];
75
64
  //# sourceMappingURL=oauth2terms.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oauth2terms.d.ts","sourceRoot":"","sources":["../oauth2terms.js"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAuBH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;GAMG;AAnDH;;;;;;;;;;;;;;;;;GAiBG;AAoCH,kGAaC"}
1
+ {"version":3,"file":"oauth2terms.d.ts","sourceRoot":"","sources":["../oauth2terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AA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,QAAQ,CAAC,MAAM,YAAW;IACjC,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAY;CACnC;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,kBAAkB,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,CAcxH"}
package/types/sleep.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export function sleep(milliseconds: any): Promise<any>;
2
- export function jestsleep(): Promise<any>;
1
+ export declare function Sleep(milliseconds?: number): Promise<void>;
2
+ export declare function JestSleep(): Promise<void>;
3
3
  //# sourceMappingURL=sleep.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../sleep.js"],"names":[],"mappings":"AAAA,uDAGC;AAGD,0CAAkC"}
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../sleep.ts"],"names":[],"mappings":"AAAA,wBAAsB,KAAK,CAAC,YAAY,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;AAGD,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/C"}
@@ -1,6 +1,6 @@
1
1
  export declare class STSOptionsBase {
2
- private _options;
3
- constructor(options?: any);
4
- get options(): any;
2
+ private _options;
3
+ constructor(options?: any);
4
+ get options(): any;
5
5
  }
6
6
  //# sourceMappingURL=stsoptionsbase.d.ts.map
@@ -1,3 +1,4 @@
1
- export function AddSchema(name: any, schema: any): (payload: any) => void;
2
- export function Validate(name: any, payload: any): any;
1
+ import { Schema } from 'ajv/dist/jtd';
2
+ export declare function AddSchema(name: string, schema: Schema): void;
3
+ export declare function Validate(name: string, payload: string): any;
3
4
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../validate.js"],"names":[],"mappings":"AAoBA,0EAMC;AAED,uDAGC"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../validate.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAoB1C,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAQ5D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAG3D"}
@@ -1,8 +1,8 @@
1
- const Ajv = require('ajv/dist/jtd');
1
+ import Ajv, { Schema } from 'ajv/dist/jtd'
2
2
 
3
3
  const ajv = new Ajv();
4
4
 
5
- const _Validate = (validator, payload) => {
5
+ const _Validate = (validator: any, payload: any): any => {
6
6
  const valid = validator(payload);
7
7
  if (!valid) {
8
8
  return validator.errors;
@@ -18,17 +18,17 @@ const _Validate = (validator, payload) => {
18
18
  */
19
19
  };
20
20
 
21
- const AddSchema = (name, schema) => {
21
+ export function AddSchema(name: string, schema: Schema): void {
22
22
  ajv.addSchema(schema, name);
23
+ /*
23
24
  return (payload) => {
24
25
  const validator = ajv.getSchema(name)
25
26
  _Validate(validator, payload)
26
- }
27
- };
27
+ }*/
28
28
 
29
- const Validate = (name, payload) => {
29
+ }
30
+
31
+ export function Validate(name: string, payload: string): any {
30
32
  const validator = ajv.getSchema(name)
31
33
  return _Validate(validator, payload);
32
- };
33
-
34
- module.exports = { AddSchema, Validate };
34
+ }
@@ -1,66 +0,0 @@
1
- const debug = require('debug')(`stsutils`);
2
- const axios = require('axios');
3
-
4
- class AuthUtilsBrowser
5
- {
6
- LoginBrowser = async (options) => {
7
- const { authendpoint, authUserName, authUserEMail, authUserPassword, defaultTimeout, publishDebug } = options;
8
- try {
9
- let processStart = performance.now();
10
- let duration = 0;
11
- let accessToken = null;
12
- let payload = { name: authUserName, password: authUserPassword, email: authUserEMail }
13
- let retVal = await axios({
14
- url: `${authendpoint}/login`
15
- ,method: 'post'
16
- ,data: payload
17
- ,timeout: defaultTimeout
18
- });
19
- duration = (performance.now() - processStart).toFixed(4);
20
- if (publishDebug) debug(`AuthUtilsBrowser.LoginBrowser request duration: [${duration}]`);
21
- accessToken = retVal.data.detail.token;
22
- return {
23
- accessToken: accessToken,
24
- duration: duration
25
- }
26
- } catch (error) {
27
- if (publishDebug) debug(`Error (AuthUtilsBrowser:LoginBrowser): ${error}`.red);
28
- throw error;
29
- }
30
- };
31
-
32
- // https://stackoverflow.com/questions/43002444/make-axios-send-cookies-in-its-requests-automatically
33
- // axios.get('some api url', {withCredentials: true});
34
- // https://medium.com/@adityasrivast/handling-cookies-with-axios-872790241a9b
35
- // https://www.codegrepper.com/code-examples/javascript/axios+send+cookies
36
- // http only cookies
37
- RefreshAuthTokenBrowser = async (options) => {
38
- const { authendpoint, defaultTimeout, publishDebug } = options;
39
- try {
40
- let processStart = performance.now();
41
- let duration = 0;
42
- let accessToken = null;
43
- // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
44
- // https://stackoverflow.com/questions/43002444/make-axios-send-cookies-in-its-requests-automatically
45
- // axios.get('some api url', {withCredentials: true});
46
- let retVal = await axios({
47
- url: `${authendpoint}/refreshtoken`
48
- ,method: 'post'
49
- ,timeout: defaultTimeout
50
- ,withCredentials: true
51
- });
52
- duration = (performance.now() - processStart).toFixed(4);
53
- if (publishDebug) debug(`AuthUtilsBrowser.RefreshAuthTokenBrowser request duration: [${duration}]`);
54
- accessToken = retVal.data.detail.token;
55
- return {
56
- accessToken: accessToken,
57
- duration: duration
58
- }
59
- } catch (error) {
60
- if (publishDebug) debug(`Error (AuthUtilsBrowser:RefreshAuthTokenBrowser): ${error}`.red);
61
- throw error;
62
- }
63
- }
64
- }
65
-
66
- module.exports = AuthUtilsBrowser;
package/errorhandling.js DELETED
@@ -1,12 +0,0 @@
1
- const GetErrorPayload = (errorCode, details = null) => {
2
- return {
3
- error: errorCode.code,
4
- error_description: errorCode.description,
5
- timestamp: Date.now(),
6
- //trace_id: "255d1aef-8c98-452f-ac51-23d051240864", //@@
7
- //correlation_id: "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7", //@@
8
- details: details
9
- }
10
- }
11
-
12
- module.exports = GetErrorPayload;
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare class STSOptionsBase {
2
- private _options;
3
- constructor(options?: any);
4
- get options(): any;
5
- }
package/oauth2terms.js DELETED
@@ -1,96 +0,0 @@
1
- // Ref: https://datatracker.ietf.org/doc/html/rfc6749#appendix-A
2
- const OAuth2ParameterType = Object.freeze({
3
- AUDIENCE: 'AUDIENCE', // STS Extension
4
- CLIENT_ID: 'client_id',
5
- CLIENT_SECRET: 'client_secret',
6
- RESPONSE_TYPE: 'response_type',
7
- SCOPE: 'scope',
8
- STATE: 'state',
9
- REDIRECT_URI: 'redirect_uri',
10
- ERROR: 'error',
11
- ERROR_DESCRIPTION: 'error_description',
12
- ERROR_CODES: 'error_codes', // STS Extension
13
- ERROR_URI: 'error_uri',
14
- GRANT_TYPE: 'grant_type',
15
- CODE: 'code',
16
- ACCESS_TOKEN: 'access_token',
17
- TOKEN_TYPE: 'token_type',
18
- EXPIRES_IN: 'expires_in',
19
- USERNAME: 'username',
20
- PASSWORD: 'password',
21
- REFRESH_TOKEN: 'refresh_token',
22
- RESPONSE_MODE: 'response_mode', // STS Extension
23
- TIMESTAMP: 'timestamp', // STS Extension
24
- TRACE_ID: 'trace_id', // STS Extension
25
- CORRELATION_ID: 'correlation_id' // STS Extension
26
- });
27
-
28
- const OAuth2ParameterErrorType = Object.freeze({
29
- NOT_EQUAL: {
30
- code: 'STS_OAUTH2_ERR_0001',
31
- description: 'Parameter values not equal.'
32
- },
33
- NOT_PRESENT: {
34
- code: 'STS_OAUTH2_ERR_0002',
35
- description: 'Parameter not provided.'
36
- },
37
- INVALID_FORMAT: {
38
- code: 'STS_OAUTH2_ERR_0003',
39
- description: 'Parameter value format invalid.'
40
- },
41
- EXPIRED: {
42
- code: 'STS_OAUTH2_ERR_0004',
43
- description: 'Parameter value expired.'
44
- }
45
- });
46
-
47
- // OIDC Standard Claims
48
- // Ref: https://openid.net/specs/openid-connect-core-1_0.html#Claims
49
- const OIDCStandardClaim = Object.freeze({
50
- SUB: 'sub',
51
- NAME: 'name',
52
- GIVEN_NAME: 'given_name',
53
- FAMILY_NAME: 'family_name',
54
- MIDDLE_NAME: 'middle_name',
55
- NICKNAME: 'nickname',
56
- PREFERRED_USERNAME: 'preferred_username',
57
- PROFILE: 'profile',
58
- PICTURE: 'picture',
59
- WEBSITE: 'website',
60
- EMAIL: 'email',
61
- EMAIL_VERIFIED: 'email_verified',
62
- GENDER: 'gender',
63
- BIRTHDATE: 'birthdate',
64
- ZONEINFO: 'zoneinfo',
65
- LOCALE: 'locale',
66
- PHONE_NUMBER: 'phone_number',
67
- PHONE_NUMBER_VERIFIED: 'phone_number_verified',
68
- ADDRESS: 'address',
69
- CLIENT_SECRET: 'client_secret',
70
- NONCE: 'nonce' // STS Extension
71
- });
72
-
73
- const OIDCAddressClaim = Object.freeze({
74
- FORMATTED: 'formatted',
75
- STREET_ADDRESS: 'street_address',
76
- LOCALITY: 'locality',
77
- REGION: 'region',
78
- COUNTRY: 'country'
79
- });
80
-
81
- const compareParameterTypes = (source1, source2, authParameterTypes) => {
82
- let errors = [ ];
83
- authParameterTypes.forEach(authParameterType => {
84
- if (source1[authParameterType].localeCompare(source2[authParameterType]) !== 0) {
85
- errors.push({
86
- [OAuth2ParameterType.ERROR]: OAuth2ParameterErrorType.NOT_EQUAL.description,
87
- [OAuth2ParameterType.ERROR_DESCRIPTION]: `${OAuth2ParameterErrorType.NOT_EQUAL.description}: Parameter: [${authParameterType}]`,
88
- [OAuth2ParameterType.ERROR_CODES]: OAuth2ParameterErrorType.NOT_EQUAL.code,
89
- [OAuth2ParameterType.TIMESTAMP]: Date.now(),
90
- })
91
- }
92
- });
93
- return errors;
94
- }
95
-
96
- module.exports = { OAuth2ParameterType, OIDCStandardClaim, OIDCAddressClaim, OAuth2ParameterErrorType, compareParameterTypes }
@@ -1,12 +0,0 @@
1
- export = AuthUtilsBrowser;
2
- declare class AuthUtilsBrowser {
3
- LoginBrowser: (options: any) => Promise<{
4
- accessToken: any;
5
- duration: number;
6
- }>;
7
- RefreshAuthTokenBrowser: (options: any) => Promise<{
8
- accessToken: any;
9
- duration: number;
10
- }>;
11
- }
12
- //# sourceMappingURL=authutilsbrowser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authutilsbrowser.d.ts","sourceRoot":"","sources":["../authutilsbrowser.js"],"names":[],"mappings":";AAGA;IAEC;;;OAwBE;IAOF;;;OA0BC;CACD"}