@nsshunt/stsutils 1.9.3 → 1.9.4
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/errorhandling.ts +24 -0
- package/index.ts +5 -24
- package/oauth2terms.ts +97 -0
- package/package.json +1 -1
- package/{sleep.js → sleep.ts} +4 -5
- package/stsoptionsbase.ts +1 -1
- package/types/errorhandling.d.ts +9 -5
- package/types/errorhandling.d.ts.map +1 -1
- package/types/index.d.ts +5 -11
- package/types/index.d.ts.map +1 -1
- package/types/oauth2terms.d.ts +63 -74
- package/types/oauth2terms.d.ts.map +1 -1
- package/types/sleep.d.ts +2 -2
- package/types/sleep.d.ts.map +1 -1
- package/types/validate.d.ts +3 -2
- package/types/validate.d.ts.map +1 -1
- package/{validate.js → validate.ts} +9 -9
- package/authutilsbrowser.js +0 -66
- package/errorhandling.js +0 -12
- package/oauth2terms.js +0 -96
- package/types/authutilsbrowser.d.ts +0 -12
- package/types/authutilsbrowser.d.ts.map +0 -1
package/errorhandling.ts
ADDED
|
@@ -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,24 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare class status {
|
|
8
|
-
static readonly SUCCESS = 200;
|
|
9
|
-
static readonly CREATED = 201;
|
|
10
|
-
static readonly NO_CONTENT = 204;
|
|
11
|
-
static readonly BAD = 400;
|
|
12
|
-
static readonly UNAUTHORIZED = 401;
|
|
13
|
-
static readonly NOTFOUND = 404;
|
|
14
|
-
static readonly CONFLICT = 409;
|
|
15
|
-
static readonly ERROR = 500;
|
|
16
|
-
static readonly SERVER_ERROR_MALFORMED = 520;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
import { STSOptionsBase } from './stsoptionsbase.js'
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
sleep, STSOptionsBase, AuthUtilsBrowser, AddSchema, Validate, GetErrorPayload,
|
|
23
|
-
OAuth2ParameterType, OIDCStandardClaim, OIDCAddressClaim, compareParameterTypes
|
|
24
|
-
};
|
|
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
package/{sleep.js → sleep.ts}
RENAMED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export async function JestSleep(): Promise<void> {
|
|
7
|
+
return Sleep(100);
|
|
8
|
+
}
|
package/stsoptionsbase.ts
CHANGED
package/types/errorhandling.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
export =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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.
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/types/oauth2terms.d.ts
CHANGED
|
@@ -1,75 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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.
|
|
1
|
+
{"version":3,"file":"oauth2terms.d.ts","sourceRoot":"","sources":["../oauth2terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGzD,qBAAa,mBAAmB;IAC/B,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAa;IACrC,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAc;IACvC,MAAM,CAAC,QAAQ,CAAC,aAAa,mBAAkB;IAC/C,MAAM,CAAC,QAAQ,CAAC,aAAa,mBAAkB;IAC/C,MAAM,CAAC,QA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/sleep.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function
|
|
2
|
-
export function
|
|
1
|
+
export declare function Sleep(milliseconds?: number): Promise<void>;
|
|
2
|
+
export declare function JestSleep(): Promise<void>;
|
|
3
3
|
//# sourceMappingURL=sleep.d.ts.map
|
package/types/sleep.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../sleep.
|
|
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"}
|
package/types/validate.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export function
|
|
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
|
package/types/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../validate.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
}
|
package/authutilsbrowser.js
DELETED
|
@@ -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/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"}
|