@nsshunt/stsutils 1.10.2 → 1.10.6
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/oauth2terms.ts +58 -58
- package/package.json +2 -2
- package/types/oauth2terms.d.ts +54 -54
- package/types/oauth2terms.d.ts.map +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.OAuth2ParameterErrorType = exports.OIDCAddressClaim = exports.OIDCStandardClaim = exports.OAuth2ParameterType = void 0;
|
|
4
|
+
// Ref: https://datatracker.ietf.org/doc/html/rfc6749#appendix-A
|
|
5
|
+
var OAuth2ParameterType;
|
|
6
|
+
(function (OAuth2ParameterType) {
|
|
7
|
+
OAuth2ParameterType["AUDIENCE"] = "AUDIENCE";
|
|
8
|
+
OAuth2ParameterType["CLIENT_ID"] = "client_id";
|
|
9
|
+
OAuth2ParameterType["CLIENT_SECRET"] = "client_secret";
|
|
10
|
+
OAuth2ParameterType["RESPONSE_TYPE"] = "response_type";
|
|
11
|
+
OAuth2ParameterType["SCOPE"] = "scope";
|
|
12
|
+
OAuth2ParameterType["STATE"] = "state";
|
|
13
|
+
OAuth2ParameterType["REDIRECT_URI"] = "redirect_uri";
|
|
14
|
+
OAuth2ParameterType["ERROR"] = "error";
|
|
15
|
+
OAuth2ParameterType["ERROR_DESCRIPTION"] = "error_description";
|
|
16
|
+
OAuth2ParameterType["ERROR_CODES"] = "error_codes";
|
|
17
|
+
OAuth2ParameterType["ERROR_URI"] = "error_uri";
|
|
18
|
+
OAuth2ParameterType["GRANT_TYPE"] = "grant_type";
|
|
19
|
+
OAuth2ParameterType["CODE"] = "code";
|
|
20
|
+
OAuth2ParameterType["ACCESS_TOKEN"] = "access_token";
|
|
21
|
+
OAuth2ParameterType["TOKEN_TYPE"] = "token_type";
|
|
22
|
+
OAuth2ParameterType["EXPIRES_IN"] = "expires_in";
|
|
23
|
+
OAuth2ParameterType["USERNAME"] = "username";
|
|
24
|
+
OAuth2ParameterType["PASSWORD"] = "password";
|
|
25
|
+
OAuth2ParameterType["REFRESH_TOKEN"] = "refresh_token";
|
|
26
|
+
OAuth2ParameterType["RESPONSE_MODE"] = "response_mode";
|
|
27
|
+
OAuth2ParameterType["TIMESTAMP"] = "timestamp";
|
|
28
|
+
OAuth2ParameterType["TRACE_ID"] = "trace_id";
|
|
29
|
+
OAuth2ParameterType["CORRELATION_ID"] = "correlation_id"; // STS Extension
|
|
30
|
+
})(OAuth2ParameterType = exports.OAuth2ParameterType || (exports.OAuth2ParameterType = {}));
|
|
31
|
+
// OIDC Standard Claims
|
|
32
|
+
// Ref: https://openid.net/specs/openid-connect-core-1_0.html#Claims
|
|
33
|
+
var OIDCStandardClaim;
|
|
34
|
+
(function (OIDCStandardClaim) {
|
|
35
|
+
OIDCStandardClaim["SUB"] = "sub";
|
|
36
|
+
OIDCStandardClaim["NAME"] = "name";
|
|
37
|
+
OIDCStandardClaim["GIVEN_NAME"] = "given_name";
|
|
38
|
+
OIDCStandardClaim["FAMILY_NAME"] = "family_name";
|
|
39
|
+
OIDCStandardClaim["MIDDLE_NAME"] = "middle_name";
|
|
40
|
+
OIDCStandardClaim["NICKNAME"] = "nickname";
|
|
41
|
+
OIDCStandardClaim["PREFERRED_USERNAME"] = "preferred_username";
|
|
42
|
+
OIDCStandardClaim["PROFILE"] = "profile";
|
|
43
|
+
OIDCStandardClaim["PICTURE"] = "picture";
|
|
44
|
+
OIDCStandardClaim["WEBSITE"] = "website";
|
|
45
|
+
OIDCStandardClaim["EMAIL"] = "email";
|
|
46
|
+
OIDCStandardClaim["EMAIL_VERIFIED"] = "email_verified";
|
|
47
|
+
OIDCStandardClaim["GENDER"] = "gender";
|
|
48
|
+
OIDCStandardClaim["BIRTHDATE"] = "birthdate";
|
|
49
|
+
OIDCStandardClaim["ZONEINFO"] = "zoneinfo";
|
|
50
|
+
OIDCStandardClaim["LOCALE"] = "locale";
|
|
51
|
+
OIDCStandardClaim["PHONE_NUMBER"] = "phone_number";
|
|
52
|
+
OIDCStandardClaim["PHONE_NUMBER_VERIFIED"] = "phone_number_verified";
|
|
53
|
+
OIDCStandardClaim["ADDRESS"] = "address";
|
|
54
|
+
OIDCStandardClaim["CLIENT_SECRET"] = "client_secret";
|
|
55
|
+
OIDCStandardClaim["NONCE"] = "nonce"; // STS Extension
|
|
56
|
+
})(OIDCStandardClaim = exports.OIDCStandardClaim || (exports.OIDCStandardClaim = {}));
|
|
57
|
+
var OIDCAddressClaim;
|
|
58
|
+
(function (OIDCAddressClaim) {
|
|
59
|
+
OIDCAddressClaim["FORMATTED"] = "formatted";
|
|
60
|
+
OIDCAddressClaim["STREET_ADDRESS"] = "street_address";
|
|
61
|
+
OIDCAddressClaim["LOCALITY"] = "locality";
|
|
62
|
+
OIDCAddressClaim["REGION"] = "region";
|
|
63
|
+
OIDCAddressClaim["COUNTRY"] = "country";
|
|
64
|
+
})(OIDCAddressClaim = exports.OIDCAddressClaim || (exports.OIDCAddressClaim = {}));
|
|
65
|
+
class OAuth2ParameterErrorType {
|
|
66
|
+
}
|
|
67
|
+
exports.OAuth2ParameterErrorType = OAuth2ParameterErrorType;
|
|
68
|
+
OAuth2ParameterErrorType.NOT_EQUAL = {
|
|
69
|
+
code: 'STS_OAUTH2_ERR_0001',
|
|
70
|
+
description: 'Parameter values not equal.'
|
|
71
|
+
};
|
|
72
|
+
OAuth2ParameterErrorType.NOT_PRESENT = {
|
|
73
|
+
code: 'STS_OAUTH2_ERR_0002',
|
|
74
|
+
description: 'Parameter not provided.'
|
|
75
|
+
};
|
|
76
|
+
OAuth2ParameterErrorType.INVALID_FORMAT = {
|
|
77
|
+
code: 'STS_OAUTH2_ERR_0003',
|
|
78
|
+
description: 'Parameter value format invalid.'
|
|
79
|
+
};
|
|
80
|
+
OAuth2ParameterErrorType.EXPIRED = {
|
|
81
|
+
code: 'STS_OAUTH2_ERR_0004',
|
|
82
|
+
description: 'Parameter value expired.'
|
|
83
|
+
};
|
|
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":";;;AAEA,gEAAgE;AAChE,IAAY,mBAwBX;AAxBD,WAAY,mBAAmB;IAC9B,4CAAqB,CAAA;IACrB,8CAAuB,CAAA;IACvB,sDAA+B,CAAA;IAC/B,sDAA+B,CAAA;IAC/B,sCAAe,CAAA;IACf,sCAAe,CAAA;IACf,oDAA6B,CAAA;IAC7B,sCAAe,CAAA;IACf,8DAAuC,CAAA;IACvC,kDAA2B,CAAA;IAC3B,8CAAuB,CAAA;IACvB,gDAAyB,CAAA;IACzB,oCAAa,CAAA;IACb,oDAA6B,CAAA;IAC7B,gDAAyB,CAAA;IACzB,gDAAyB,CAAA;IACzB,4CAAqB,CAAA;IACrB,4CAAqB,CAAA;IACrB,sDAA+B,CAAA;IAC/B,sDAA+B,CAAA;IAC/B,8CAAuB,CAAA;IACvB,4CAAqB,CAAA;IACrB,wDAAiC,CAAA,CAAC,gBAAgB;AACnD,CAAC,EAxBW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAwB9B;AAED,uBAAuB;AACvB,oEAAoE;AACpE,IAAY,iBAsBX;AAtBD,WAAY,iBAAiB;IAC5B,gCAAW,CAAA;IACX,kCAAa,CAAA;IACb,8CAAyB,CAAA;IACzB,gDAA2B,CAAA;IAC3B,gDA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iB,CAAC,CAAC,KAAK,CAAC,EAAE;YAC/E,MAAM,KAAK,GAAiB;gBAC3B,KAAK,EAAE,wBAAwB,CAAC,SAAS,CAAC,IAAI;gBAC9C,iBAAiB,EAAE,wBAAwB,CAAC,SAAS,CAAC,WAAW;gBACjE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,OAAO,EAAE,GAAG,wBAAwB,CAAC,SAAS,CAAC,WAAW,iBAAiB,iBAAiB,GAAG;aAC/F,CAAA;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACnB;IACF,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC;AAdD,sDAcC"}
|
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"}
|
package/oauth2terms.ts
CHANGED
|
@@ -1,30 +1,64 @@
|
|
|
1
1
|
import { errorCode, errorPayload } from './errorhandling'
|
|
2
2
|
|
|
3
3
|
// Ref: https://datatracker.ietf.org/doc/html/rfc6749#appendix-A
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
4
|
+
export enum OAuth2ParameterType {
|
|
5
|
+
AUDIENCE = 'AUDIENCE', // STS Extension
|
|
6
|
+
CLIENT_ID = 'client_id',
|
|
7
|
+
CLIENT_SECRET = 'client_secret',
|
|
8
|
+
RESPONSE_TYPE = 'response_type',
|
|
9
|
+
SCOPE = 'scope',
|
|
10
|
+
STATE = 'state',
|
|
11
|
+
REDIRECT_URI = 'redirect_uri',
|
|
12
|
+
ERROR = 'error',
|
|
13
|
+
ERROR_DESCRIPTION = 'error_description',
|
|
14
|
+
ERROR_CODES = 'error_codes', // STS Extension
|
|
15
|
+
ERROR_URI = 'error_uri',
|
|
16
|
+
GRANT_TYPE = 'grant_type',
|
|
17
|
+
CODE = 'code',
|
|
18
|
+
ACCESS_TOKEN = 'access_token',
|
|
19
|
+
TOKEN_TYPE = 'token_type',
|
|
20
|
+
EXPIRES_IN = 'expires_in',
|
|
21
|
+
USERNAME = 'username',
|
|
22
|
+
PASSWORD = 'password',
|
|
23
|
+
REFRESH_TOKEN = 'refresh_token',
|
|
24
|
+
RESPONSE_MODE = 'response_mode', // STS Extension
|
|
25
|
+
TIMESTAMP = 'timestamp', // STS Extension
|
|
26
|
+
TRACE_ID = 'trace_id', // STS Extension
|
|
27
|
+
CORRELATION_ID = 'correlation_id' // STS Extension
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// OIDC Standard Claims
|
|
31
|
+
// Ref: https://openid.net/specs/openid-connect-core-1_0.html#Claims
|
|
32
|
+
export enum OIDCStandardClaim {
|
|
33
|
+
SUB = 'sub',
|
|
34
|
+
NAME = 'name',
|
|
35
|
+
GIVEN_NAME = 'given_name',
|
|
36
|
+
FAMILY_NAME = 'family_name',
|
|
37
|
+
MIDDLE_NAME = 'middle_name',
|
|
38
|
+
NICKNAME = 'nickname',
|
|
39
|
+
PREFERRED_USERNAME = 'preferred_username',
|
|
40
|
+
PROFILE = 'profile',
|
|
41
|
+
PICTURE = 'picture',
|
|
42
|
+
WEBSITE = 'website',
|
|
43
|
+
EMAIL = 'email',
|
|
44
|
+
EMAIL_VERIFIED = 'email_verified',
|
|
45
|
+
GENDER = 'gender',
|
|
46
|
+
BIRTHDATE = 'birthdate',
|
|
47
|
+
ZONEINFO = 'zoneinfo',
|
|
48
|
+
LOCALE = 'locale',
|
|
49
|
+
PHONE_NUMBER = 'phone_number',
|
|
50
|
+
PHONE_NUMBER_VERIFIED = 'phone_number_verified',
|
|
51
|
+
ADDRESS = 'address',
|
|
52
|
+
CLIENT_SECRET = 'client_secret',
|
|
53
|
+
NONCE = 'nonce' // STS Extension
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export enum OIDCAddressClaim {
|
|
57
|
+
FORMATTED = 'formatted',
|
|
58
|
+
STREET_ADDRESS = 'street_address',
|
|
59
|
+
LOCALITY = 'locality',
|
|
60
|
+
REGION = 'region',
|
|
61
|
+
COUNTRY = 'country'
|
|
28
62
|
}
|
|
29
63
|
|
|
30
64
|
export class OAuth2ParameterErrorType {
|
|
@@ -46,40 +80,6 @@ export class OAuth2ParameterErrorType {
|
|
|
46
80
|
}
|
|
47
81
|
}
|
|
48
82
|
|
|
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
83
|
export function compareParameterTypes(source1: string[], source2: string[], authParameterTypes: string[]): errorPayload[] {
|
|
84
84
|
const errors: errorPayload[] = [ ];
|
|
85
85
|
authParameterTypes.forEach(authParameterType => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsshunt/stsutils",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"eslint": "^8.14.0",
|
|
36
36
|
"jest": "^28.0.2",
|
|
37
37
|
"supertest": "^6.2.2",
|
|
38
|
-
"typescript": "^4.6.
|
|
38
|
+
"typescript": "^4.6.4"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"ajv": "^8.11.0",
|
package/types/oauth2terms.d.ts
CHANGED
|
@@ -1,28 +1,58 @@
|
|
|
1
1
|
import { errorCode, errorPayload } from './errorhandling';
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
export declare enum OAuth2ParameterType {
|
|
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_CODES = "error_codes",
|
|
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",
|
|
23
|
+
TIMESTAMP = "timestamp",
|
|
24
|
+
TRACE_ID = "trace_id",
|
|
25
|
+
CORRELATION_ID = "correlation_id"
|
|
26
|
+
}
|
|
27
|
+
export declare enum OIDCStandardClaim {
|
|
28
|
+
SUB = "sub",
|
|
29
|
+
NAME = "name",
|
|
30
|
+
GIVEN_NAME = "given_name",
|
|
31
|
+
FAMILY_NAME = "family_name",
|
|
32
|
+
MIDDLE_NAME = "middle_name",
|
|
33
|
+
NICKNAME = "nickname",
|
|
34
|
+
PREFERRED_USERNAME = "preferred_username",
|
|
35
|
+
PROFILE = "profile",
|
|
36
|
+
PICTURE = "picture",
|
|
37
|
+
WEBSITE = "website",
|
|
38
|
+
EMAIL = "email",
|
|
39
|
+
EMAIL_VERIFIED = "email_verified",
|
|
40
|
+
GENDER = "gender",
|
|
41
|
+
BIRTHDATE = "birthdate",
|
|
42
|
+
ZONEINFO = "zoneinfo",
|
|
43
|
+
LOCALE = "locale",
|
|
44
|
+
PHONE_NUMBER = "phone_number",
|
|
45
|
+
PHONE_NUMBER_VERIFIED = "phone_number_verified",
|
|
46
|
+
ADDRESS = "address",
|
|
47
|
+
CLIENT_SECRET = "client_secret",
|
|
48
|
+
NONCE = "nonce"
|
|
49
|
+
}
|
|
50
|
+
export declare enum OIDCAddressClaim {
|
|
51
|
+
FORMATTED = "formatted",
|
|
52
|
+
STREET_ADDRESS = "street_address",
|
|
53
|
+
LOCALITY = "locality",
|
|
54
|
+
REGION = "region",
|
|
55
|
+
COUNTRY = "country"
|
|
26
56
|
}
|
|
27
57
|
export declare class OAuth2ParameterErrorType {
|
|
28
58
|
static readonly NOT_EQUAL: errorCode;
|
|
@@ -30,35 +60,5 @@ export declare class OAuth2ParameterErrorType {
|
|
|
30
60
|
static readonly INVALID_FORMAT: errorCode;
|
|
31
61
|
static readonly EXPIRED: errorCode;
|
|
32
62
|
}
|
|
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
63
|
export declare function compareParameterTypes(source1: string[], source2: string[], authParameterTypes: string[]): errorPayload[];
|
|
64
64
|
//# sourceMappingURL=oauth2terms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2terms.d.ts","sourceRoot":"","sources":["../oauth2terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGzD,
|
|
1
|
+
{"version":3,"file":"oauth2terms.d.ts","sourceRoot":"","sources":["../oauth2terms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGzD,oBAAY,mBAAmB;IAC9B,QAAQ,aAAa;IACrB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