@nsshunt/stsutils 1.7.5 → 1.8.1
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.js +12 -0
- package/index.js +6 -1
- package/oauth2terms.js +67 -0
- package/package.json +2 -2
- package/validate.js +1 -1
package/errorhandling.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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.js
CHANGED
|
@@ -3,5 +3,10 @@ let status = require('./status.js');
|
|
|
3
3
|
const AuthUtilsBrowser = require('./authutilsbrowser.js');
|
|
4
4
|
const STSOptionsBase = require('./stsoptionsbase.js');
|
|
5
5
|
const { AddSchema, Validate } = require('./validate.js');
|
|
6
|
+
const GetErrorPayload = require('./errorhandling.js');
|
|
7
|
+
const { OAuth2ParameterType, OIDCStandardClaim, OIDCAddressClaim, compareParameterType } = require('./oauth2terms.js');
|
|
6
8
|
|
|
7
|
-
module.exports = {
|
|
9
|
+
module.exports = {
|
|
10
|
+
sleep, status, STSOptionsBase, AuthUtilsBrowser, AddSchema, Validate, GetErrorPayload,
|
|
11
|
+
OAuth2ParameterType, OIDCStandardClaim, OIDCAddressClaim, compareParameterType
|
|
12
|
+
};
|
package/oauth2terms.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Ref: https://datatracker.ietf.org/doc/html/rfc6749#appendix-A
|
|
2
|
+
const OAuth2ParameterType = Object.freeze({
|
|
3
|
+
AUDIENCE: 'AUDIENCE',
|
|
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_URI: 'error_uri',
|
|
13
|
+
GRANT_TYPE: 'grant_type',
|
|
14
|
+
CODE: 'code',
|
|
15
|
+
ACCESS_TOKEN: 'access_token',
|
|
16
|
+
TOKEN_TYPE: 'token_type',
|
|
17
|
+
EXPIRES_IN: 'expires_in',
|
|
18
|
+
USERNAME: 'username',
|
|
19
|
+
PASSWORD: 'password',
|
|
20
|
+
REFRESH_TOKEN: 'refresh_token',
|
|
21
|
+
RESPONSE_MODE: 'response_mode'
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// OIDC Standard Claims
|
|
25
|
+
// Ref: https://openid.net/specs/openid-connect-core-1_0.html#Claims
|
|
26
|
+
const OIDCStandardClaim = Object.freeze({
|
|
27
|
+
SUB: 'sub',
|
|
28
|
+
NAME: 'name',
|
|
29
|
+
GIVEN_NAME: 'given_name',
|
|
30
|
+
FAMILY_NAME: 'family_name',
|
|
31
|
+
MIDDLE_NAME: 'middle_name',
|
|
32
|
+
NICKNAME: 'nickname',
|
|
33
|
+
PREFERRED_USERNAME: 'preferred_username',
|
|
34
|
+
PROFILE: 'profile',
|
|
35
|
+
PICTURE: 'picture',
|
|
36
|
+
WEBSITE: 'website',
|
|
37
|
+
EMAIL: 'email',
|
|
38
|
+
EMAIL_VERIFIED: 'email_verified',
|
|
39
|
+
GENDER: 'gender',
|
|
40
|
+
BIRTHDATE: 'birthdate',
|
|
41
|
+
ZONEINFO: 'zoneinfo',
|
|
42
|
+
LOCALE: 'locale',
|
|
43
|
+
PHONE_NUMBER: 'phone_number',
|
|
44
|
+
PHONE_NUMBER_VERIFIED: 'phone_number_verified',
|
|
45
|
+
ADDRESS: 'address',
|
|
46
|
+
CLIENT_SECRET: 'updated_at'
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const OIDCAddressClaim = Object.freeze({
|
|
50
|
+
FORMATTED: 'formatted',
|
|
51
|
+
STREET_ADDRESS: 'street_address',
|
|
52
|
+
LOCALITY: 'locality',
|
|
53
|
+
REGION: 'region',
|
|
54
|
+
COUNTRY: 'country'
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const compareParameterType = (source1, source2, authParameterTypes) => {
|
|
58
|
+
let errors = [ ];
|
|
59
|
+
authParameterTypes.forEach(authParameterType => {
|
|
60
|
+
if (source1[authParameterType.paramaterType].localeCompare(source2[authParameterType.paramaterType]) !== 0) {
|
|
61
|
+
errors.push(authParameterType.errorType);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return errors;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = { OAuth2ParameterType, OIDCStandardClaim, OIDCAddressClaim, compareParameterType }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsshunt/stsutils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"jest": "^27.5.1"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"ajv": "^8.
|
|
33
|
+
"ajv": "^8.11.0",
|
|
34
34
|
"axios": "^0.26.1",
|
|
35
35
|
"colors": "^1.4.0",
|
|
36
36
|
"debug": "^4.3.4"
|
package/validate.js
CHANGED