@nsshunt/stsutils 1.10.2 → 1.10.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/.github/workflows/npm-publish.yml +1 -0
- package/dist/errorhandling.js +15 -0
- package/dist/errorhandling.js.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/oauth2terms.js +100 -0
- package/dist/oauth2terms.js.map +1 -0
- package/dist/sleep.js +26 -0
- package/dist/sleep.js.map +1 -0
- package/dist/stsoptionsbase.js +24 -0
- package/dist/stsoptionsbase.js.map +1 -0
- package/dist/stsutils.test.js +16 -0
- package/dist/stsutils.test.js.map +1 -0
- package/dist/validate.js +39 -0
- package/dist/validate.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetErrorPayload = void 0;
|
|
4
|
+
function GetErrorPayload(errorCode, details = null) {
|
|
5
|
+
return {
|
|
6
|
+
error: errorCode.code,
|
|
7
|
+
error_description: errorCode.description,
|
|
8
|
+
timestamp: Date.now(),
|
|
9
|
+
//trace_id: "255d1aef-8c98-452f-ac51-23d051240864", //@@
|
|
10
|
+
//correlation_id: "fb3d2015-bc17-4bb9-bb85-30c5cf1aaaa7", //@@
|
|
11
|
+
details: details
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.GetErrorPayload = GetErrorPayload;
|
|
15
|
+
//# sourceMappingURL=errorhandling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorhandling.js","sourceRoot":"","sources":["../errorhandling.ts"],"names":[],"mappings":";;;AAcA,SAAgB,eAAe,CAAC,SAAoB,EAAE,UAAe,IAAI;IACxE,OAAO;QACN,KAAK,EAAE,SAAS,CAAC,IAAI;QACrB,iBAAiB,EAAE,SAAS,CAAC,WAAW;QACxC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,wDAAwD;QACxD,8DAA8D;QAC9D,OAAO,EAAE,OAAO;KAChB,CAAA;AACF,CAAC;AATD,0CASC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./errorhandling"), exports);
|
|
18
|
+
__exportStar(require("./stsoptionsbase"), exports);
|
|
19
|
+
__exportStar(require("./sleep"), exports);
|
|
20
|
+
__exportStar(require("./validate"), exports);
|
|
21
|
+
__exportStar(require("./oauth2terms"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,0CAAuB;AACvB,6CAA0B;AAC1B,gDAA6B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareParameterTypes = exports.OIDCAddressClaim = exports.OIDCStandardClaim = exports.OAuth2ParameterErrorType = exports.OAuth2ParameterType = void 0;
|
|
4
|
+
// Ref: https://datatracker.ietf.org/doc/html/rfc6749#appendix-A
|
|
5
|
+
class OAuth2ParameterType {
|
|
6
|
+
}
|
|
7
|
+
exports.OAuth2ParameterType = OAuth2ParameterType;
|
|
8
|
+
OAuth2ParameterType.AUDIENCE = 'AUDIENCE'; // STS Extension
|
|
9
|
+
OAuth2ParameterType.CLIENT_ID = 'client_id';
|
|
10
|
+
OAuth2ParameterType.CLIENT_SECRET = 'client_secret';
|
|
11
|
+
OAuth2ParameterType.RESPONSE_TYPE = 'response_type';
|
|
12
|
+
OAuth2ParameterType.SCOPE = 'scope';
|
|
13
|
+
OAuth2ParameterType.STATE = 'state';
|
|
14
|
+
OAuth2ParameterType.REDIRECT_URI = 'redirect_uri';
|
|
15
|
+
OAuth2ParameterType.ERROR = 'error';
|
|
16
|
+
OAuth2ParameterType.ERROR_DESCRIPTION = 'error_description';
|
|
17
|
+
OAuth2ParameterType.ERROR_CODES = 'error_codes'; // STS Extension
|
|
18
|
+
OAuth2ParameterType.ERROR_URI = 'error_uri';
|
|
19
|
+
OAuth2ParameterType.GRANT_TYPE = 'grant_type';
|
|
20
|
+
OAuth2ParameterType.CODE = 'code';
|
|
21
|
+
OAuth2ParameterType.ACCESS_TOKEN = 'access_token';
|
|
22
|
+
OAuth2ParameterType.TOKEN_TYPE = 'token_type';
|
|
23
|
+
OAuth2ParameterType.EXPIRES_IN = 'expires_in';
|
|
24
|
+
OAuth2ParameterType.USERNAME = 'username';
|
|
25
|
+
OAuth2ParameterType.PASSWORD = 'password';
|
|
26
|
+
OAuth2ParameterType.REFRESH_TOKEN = 'refresh_token';
|
|
27
|
+
OAuth2ParameterType.RESPONSE_MODE = 'response_mode'; // STS Extension
|
|
28
|
+
OAuth2ParameterType.TIMESTAMP = 'timestamp'; // STS Extension
|
|
29
|
+
OAuth2ParameterType.TRACE_ID = 'trace_id'; // STS Extension
|
|
30
|
+
OAuth2ParameterType.CORRELATION_ID = 'correlation_id'; // STS Extension
|
|
31
|
+
class OAuth2ParameterErrorType {
|
|
32
|
+
}
|
|
33
|
+
exports.OAuth2ParameterErrorType = OAuth2ParameterErrorType;
|
|
34
|
+
OAuth2ParameterErrorType.NOT_EQUAL = {
|
|
35
|
+
code: 'STS_OAUTH2_ERR_0001',
|
|
36
|
+
description: 'Parameter values not equal.'
|
|
37
|
+
};
|
|
38
|
+
OAuth2ParameterErrorType.NOT_PRESENT = {
|
|
39
|
+
code: 'STS_OAUTH2_ERR_0002',
|
|
40
|
+
description: 'Parameter not provided.'
|
|
41
|
+
};
|
|
42
|
+
OAuth2ParameterErrorType.INVALID_FORMAT = {
|
|
43
|
+
code: 'STS_OAUTH2_ERR_0003',
|
|
44
|
+
description: 'Parameter value format invalid.'
|
|
45
|
+
};
|
|
46
|
+
OAuth2ParameterErrorType.EXPIRED = {
|
|
47
|
+
code: 'STS_OAUTH2_ERR_0004',
|
|
48
|
+
description: 'Parameter value expired.'
|
|
49
|
+
};
|
|
50
|
+
// OIDC Standard Claims
|
|
51
|
+
// Ref: https://openid.net/specs/openid-connect-core-1_0.html#Claims
|
|
52
|
+
class OIDCStandardClaim {
|
|
53
|
+
}
|
|
54
|
+
exports.OIDCStandardClaim = OIDCStandardClaim;
|
|
55
|
+
OIDCStandardClaim.SUB = 'sub';
|
|
56
|
+
OIDCStandardClaim.NAME = 'name';
|
|
57
|
+
OIDCStandardClaim.GIVEN_NAME = 'given_name';
|
|
58
|
+
OIDCStandardClaim.FAMILY_NAME = 'family_name';
|
|
59
|
+
OIDCStandardClaim.MIDDLE_NAME = 'middle_name';
|
|
60
|
+
OIDCStandardClaim.NICKNAME = 'nickname';
|
|
61
|
+
OIDCStandardClaim.PREFERRED_USERNAME = 'preferred_username';
|
|
62
|
+
OIDCStandardClaim.PROFILE = 'profile';
|
|
63
|
+
OIDCStandardClaim.PICTURE = 'picture';
|
|
64
|
+
OIDCStandardClaim.WEBSITE = 'website';
|
|
65
|
+
OIDCStandardClaim.EMAIL = 'email';
|
|
66
|
+
OIDCStandardClaim.EMAIL_VERIFIED = 'email_verified';
|
|
67
|
+
OIDCStandardClaim.GENDER = 'gender';
|
|
68
|
+
OIDCStandardClaim.BIRTHDATE = 'birthdate';
|
|
69
|
+
OIDCStandardClaim.ZONEINFO = 'zoneinfo';
|
|
70
|
+
OIDCStandardClaim.LOCALE = 'locale';
|
|
71
|
+
OIDCStandardClaim.PHONE_NUMBER = 'phone_number';
|
|
72
|
+
OIDCStandardClaim.PHONE_NUMBER_VERIFIED = 'phone_number_verified';
|
|
73
|
+
OIDCStandardClaim.ADDRESS = 'address';
|
|
74
|
+
OIDCStandardClaim.CLIENT_SECRET = 'client_secret';
|
|
75
|
+
OIDCStandardClaim.NONCE = 'nonce'; // STS Extension
|
|
76
|
+
class OIDCAddressClaim {
|
|
77
|
+
}
|
|
78
|
+
exports.OIDCAddressClaim = OIDCAddressClaim;
|
|
79
|
+
OIDCAddressClaim.FORMATTED = 'formatted';
|
|
80
|
+
OIDCAddressClaim.STREET_ADDRESS = 'street_address';
|
|
81
|
+
OIDCAddressClaim.LOCALITY = 'locality';
|
|
82
|
+
OIDCAddressClaim.REGION = 'region';
|
|
83
|
+
OIDCAddressClaim.COUNTRY = 'country';
|
|
84
|
+
function compareParameterTypes(source1, source2, authParameterTypes) {
|
|
85
|
+
const errors = [];
|
|
86
|
+
authParameterTypes.forEach(authParameterType => {
|
|
87
|
+
if (source1[authParameterType].localeCompare(source2[authParameterType]) !== 0) {
|
|
88
|
+
const error = {
|
|
89
|
+
error: OAuth2ParameterErrorType.NOT_EQUAL.code,
|
|
90
|
+
error_description: OAuth2ParameterErrorType.NOT_EQUAL.description,
|
|
91
|
+
timestamp: Date.now(),
|
|
92
|
+
details: `${OAuth2ParameterErrorType.NOT_EQUAL.description}: Parameter: [${authParameterType}]`
|
|
93
|
+
};
|
|
94
|
+
errors.push(error);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return errors;
|
|
98
|
+
}
|
|
99
|
+
exports.compareParameterTypes = compareParameterTypes;
|
|
100
|
+
//# sourceMappingURL=oauth2terms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth2terms.js","sourceRoot":"","sources":["../oauth2terms.ts"],"names":[],"mappings":"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"}
|
package/dist/sleep.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JestSleep = exports.Sleep = void 0;
|
|
13
|
+
function Sleep(milliseconds = 1000) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.Sleep = Sleep;
|
|
19
|
+
// poolsleep is required to avoid JEST reporting unclosed handles during shutdown of all tests
|
|
20
|
+
function JestSleep() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return Sleep(100);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.JestSleep = JestSleep;
|
|
26
|
+
//# sourceMappingURL=sleep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../sleep.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,SAAsB,KAAK,CAAC,YAAY,GAAG,IAAI;;QAC9C,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAA;IACjE,CAAC;CAAA;AAFD,sBAEC;AAED,8FAA8F;AAC9F,SAAsB,SAAS;;QAC9B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CAAA;AAFD,8BAEC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STSOptionsBase = void 0;
|
|
4
|
+
const validate_js_1 = require("./validate.js");
|
|
5
|
+
class STSOptionsBase {
|
|
6
|
+
constructor(options = null) {
|
|
7
|
+
this._options = null;
|
|
8
|
+
this._options = options;
|
|
9
|
+
if (options !== null) {
|
|
10
|
+
if (typeof options.validator === 'undefined') {
|
|
11
|
+
console.log(JSON.stringify(options));
|
|
12
|
+
console.trace("Options Here ------------------------------------------------------------------------------------------");
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
(0, validate_js_1.Validate)(options.validator, options);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
get options() {
|
|
20
|
+
return this._options;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.STSOptionsBase = STSOptionsBase;
|
|
24
|
+
//# sourceMappingURL=stsoptionsbase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stsoptionsbase.js","sourceRoot":"","sources":["../stsoptionsbase.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAExC,MAAa,cAAc;IAI1B,YAAY,UAAe,IAAI;QAFvB,aAAQ,GAAQ,IAAI,CAAC;QAIzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAE3B,IAAI,OAAO,KAAK,IAAI,EAAE;YACrB,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,WAAW,EAAE;gBAC7C,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBACrC,OAAO,CAAC,KAAK,CAAC,yGAAyG,CAAC,CAAA;aACxH;iBAAM;gBACN,IAAA,sBAAQ,EAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;aACrC;SACD;IACF,CAAC;IAED,IAAI,OAAO;QAEV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;CACD;AAtBD,wCAsBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
describe("Test Latency Controller", () => {
|
|
11
|
+
test('Testing Module', () => __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
expect.assertions(1);
|
|
13
|
+
expect(1).toEqual(1);
|
|
14
|
+
}));
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=stsutils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stsutils.test.js","sourceRoot":"","sources":["../stsutils.test.js"],"names":[],"mappings":";;;;;;;;;AACA,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IAExC,IAAI,CAAC,gBAAgB,EAAE,GAAS,EAAE;QAEjC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CAAA,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Validate = exports.AddSchema = void 0;
|
|
7
|
+
const jtd_1 = __importDefault(require("ajv/dist/jtd"));
|
|
8
|
+
const ajv = new jtd_1.default();
|
|
9
|
+
const _Validate = (validator, payload) => {
|
|
10
|
+
const valid = validator(payload);
|
|
11
|
+
if (!valid) {
|
|
12
|
+
return validator.errors;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/*
|
|
18
|
+
console.error(validator.errors);
|
|
19
|
+
console.trace('Invalid Schema');
|
|
20
|
+
console.log('Payload:-');
|
|
21
|
+
console.log(JSON.stringify(payload));
|
|
22
|
+
process.exit(1);
|
|
23
|
+
*/
|
|
24
|
+
};
|
|
25
|
+
function AddSchema(name, schema) {
|
|
26
|
+
ajv.addSchema(schema, name);
|
|
27
|
+
/*
|
|
28
|
+
return (payload) => {
|
|
29
|
+
const validator = ajv.getSchema(name)
|
|
30
|
+
_Validate(validator, payload)
|
|
31
|
+
}*/
|
|
32
|
+
}
|
|
33
|
+
exports.AddSchema = AddSchema;
|
|
34
|
+
function Validate(name, payload) {
|
|
35
|
+
const validator = ajv.getSchema(name);
|
|
36
|
+
return _Validate(validator, payload);
|
|
37
|
+
}
|
|
38
|
+
exports.Validate = Validate;
|
|
39
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../validate.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA0C;AAE1C,MAAM,GAAG,GAAG,IAAI,aAAG,EAAE,CAAC;AAEtB,MAAM,SAAS,GAAG,CAAC,SAAc,EAAE,OAAY,EAAO,EAAE;IACvD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE;QACX,OAAO,SAAS,CAAC,MAAM,CAAC;KACxB;SAAM;QACN,OAAO,IAAI,CAAC;KACZ;IACD;;;;;;UAMG;AACJ,CAAC,CAAC;AAEF,SAAgB,SAAS,CAAC,IAAY,EAAE,MAAc;IACrD,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B;;;;OAIG;AAEJ,CAAC;AARD,8BAQC;AAED,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAe;IACrD,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACrC,OAAO,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAHD,4BAGC"}
|