@villedemontreal/jwt-validator 5.7.7
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/LICENSE +21 -0
- package/README.md +313 -0
- package/dist/scripts/index.d.ts +6 -0
- package/dist/scripts/index.js +16 -0
- package/dist/scripts/index.js.map +1 -0
- package/dist/scripts/lint.d.ts +6 -0
- package/dist/scripts/lint.js +18 -0
- package/dist/scripts/lint.js.map +1 -0
- package/dist/scripts/lintFix.d.ts +6 -0
- package/dist/scripts/lintFix.js +21 -0
- package/dist/scripts/lintFix.js.map +1 -0
- package/dist/scripts/showCoverage.d.ts +13 -0
- package/dist/scripts/showCoverage.js +40 -0
- package/dist/scripts/showCoverage.js.map +1 -0
- package/dist/scripts/test.d.ts +13 -0
- package/dist/scripts/test.js +29 -0
- package/dist/scripts/test.js.map +1 -0
- package/dist/scripts/testUnits.d.ts +15 -0
- package/dist/scripts/testUnits.js +95 -0
- package/dist/scripts/testUnits.js.map +1 -0
- package/dist/scripts/watch.d.ts +14 -0
- package/dist/scripts/watch.js +96 -0
- package/dist/scripts/watch.js.map +1 -0
- package/dist/src/config/configs.d.ts +88 -0
- package/dist/src/config/configs.js +123 -0
- package/dist/src/config/configs.js.map +1 -0
- package/dist/src/config/constants.d.ts +56 -0
- package/dist/src/config/constants.js +66 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/init.d.ts +15 -0
- package/dist/src/config/init.js +48 -0
- package/dist/src/config/init.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +32 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/jwtValidator.d.ts +21 -0
- package/dist/src/jwtValidator.js +129 -0
- package/dist/src/jwtValidator.js.map +1 -0
- package/dist/src/jwtValidator.test.d.ts +1 -0
- package/dist/src/jwtValidator.test.js +500 -0
- package/dist/src/jwtValidator.test.js.map +1 -0
- package/dist/src/middleware/jwtMiddleware.d.ts +7 -0
- package/dist/src/middleware/jwtMiddleware.js +27 -0
- package/dist/src/middleware/jwtMiddleware.js.map +1 -0
- package/dist/src/models/customError.d.ts +11 -0
- package/dist/src/models/customError.js +38 -0
- package/dist/src/models/customError.js.map +1 -0
- package/dist/src/models/expressRequest.d.ts +15 -0
- package/dist/src/models/expressRequest.js +17 -0
- package/dist/src/models/expressRequest.js.map +1 -0
- package/dist/src/models/gluuUserType.d.ts +9 -0
- package/dist/src/models/gluuUserType.js +14 -0
- package/dist/src/models/gluuUserType.js.map +1 -0
- package/dist/src/models/jwtPayload.d.ts +30 -0
- package/dist/src/models/jwtPayload.js +19 -0
- package/dist/src/models/jwtPayload.js.map +1 -0
- package/dist/src/models/pagination.d.ts +16 -0
- package/dist/src/models/pagination.js +16 -0
- package/dist/src/models/pagination.js.map +1 -0
- package/dist/src/models/publicKey.d.ts +29 -0
- package/dist/src/models/publicKey.js +13 -0
- package/dist/src/models/publicKey.js.map +1 -0
- package/dist/src/repositories/cachedPublicKeyRepository.d.ts +53 -0
- package/dist/src/repositories/cachedPublicKeyRepository.js +102 -0
- package/dist/src/repositories/cachedPublicKeyRepository.js.map +1 -0
- package/dist/src/repositories/publicKeyRepository.d.ts +19 -0
- package/dist/src/repositories/publicKeyRepository.js +44 -0
- package/dist/src/repositories/publicKeyRepository.js.map +1 -0
- package/dist/src/userValidator.d.ts +30 -0
- package/dist/src/userValidator.js +35 -0
- package/dist/src/userValidator.js.map +1 -0
- package/dist/src/userValidator.test.d.ts +1 -0
- package/dist/src/userValidator.test.js +251 -0
- package/dist/src/userValidator.test.js.map +1 -0
- package/dist/src/utils/jwtMock.d.ts +31 -0
- package/dist/src/utils/jwtMock.js +221 -0
- package/dist/src/utils/jwtMock.js.map +1 -0
- package/dist/src/utils/logger.d.ts +11 -0
- package/dist/src/utils/logger.js +54 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/testingConfigurations.d.ts +7 -0
- package/dist/src/utils/testingConfigurations.js +16 -0
- package/dist/src/utils/testingConfigurations.js.map +1 -0
- package/package.json +82 -0
- package/src/config/configs.ts +145 -0
- package/src/config/constants.ts +83 -0
- package/src/config/init.ts +58 -0
- package/src/index.ts +15 -0
- package/src/jwtValidator.test.ts +607 -0
- package/src/jwtValidator.ts +162 -0
- package/src/middleware/jwtMiddleware.ts +33 -0
- package/src/models/customError.ts +37 -0
- package/src/models/expressRequest.ts +27 -0
- package/src/models/gluuUserType.ts +9 -0
- package/src/models/jwtPayload.ts +58 -0
- package/src/models/pagination.ts +26 -0
- package/src/models/publicKey.ts +33 -0
- package/src/repositories/cachedPublicKeyRepository.ts +121 -0
- package/src/repositories/publicKeyRepository.ts +75 -0
- package/src/userValidator.test.ts +279 -0
- package/src/userValidator.ts +54 -0
- package/src/utils/jwtMock.ts +243 -0
- package/src/utils/logger.ts +60 -0
- package/src/utils/testingConfigurations.ts +12 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '@caporal/core';
|
|
2
|
+
import { ScriptBase } from '@villedemontreal/scripting/dist/src';
|
|
3
|
+
export interface Options {
|
|
4
|
+
/**
|
|
5
|
+
* Disable the visual notification
|
|
6
|
+
*/
|
|
7
|
+
dn?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class WatchScript extends ScriptBase<Options> {
|
|
10
|
+
get name(): string;
|
|
11
|
+
get description(): string;
|
|
12
|
+
protected configure(command: Command): Promise<void>;
|
|
13
|
+
protected main(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WatchScript = void 0;
|
|
4
|
+
const general_utils_1 = require("@villedemontreal/general-utils");
|
|
5
|
+
const src_1 = require("@villedemontreal/scripting/dist/src");
|
|
6
|
+
const _ = require("lodash");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const configs_1 = require("../src/config/configs");
|
|
9
|
+
const notifier = require('node-notifier');
|
|
10
|
+
class WatchScript extends src_1.ScriptBase {
|
|
11
|
+
get name() {
|
|
12
|
+
return 'watch';
|
|
13
|
+
}
|
|
14
|
+
get description() {
|
|
15
|
+
return `Start Typescript incremental compilation. \
|
|
16
|
+
You can run this script in an external terminal and then debug your \
|
|
17
|
+
application in your IDE. When you have made some modifications and want \
|
|
18
|
+
to test them, you stop your application and restart it \
|
|
19
|
+
using the "Debug Locally - fast" launch configuration (if you are \
|
|
20
|
+
in VSCode) or \`run start --nc\`. No compilation is required at \
|
|
21
|
+
that point since the incremental compilation is already done by this script.`;
|
|
22
|
+
}
|
|
23
|
+
async configure(command) {
|
|
24
|
+
command.option(`--dn`, `Disable the visual notifications`);
|
|
25
|
+
}
|
|
26
|
+
async main() {
|
|
27
|
+
this.logger.info(`\n==========================================\n` +
|
|
28
|
+
`Starting incremental compilation...\n` +
|
|
29
|
+
`==========================================\n`);
|
|
30
|
+
const projectName = require(configs_1.configs.libRoot + '/package.json').namae;
|
|
31
|
+
let ignoreNextCompilationComplete = false;
|
|
32
|
+
const compilationCompletetRegEx = /(Compilation complete)|(Found 0 errors)/;
|
|
33
|
+
// eslint-disable-next-line no-control-regex
|
|
34
|
+
const errorRegEx = /(: error)|(error)/;
|
|
35
|
+
const outputHandler = (stdoutData, stderrData) => {
|
|
36
|
+
if (stdoutData) {
|
|
37
|
+
const stdoutDataClean = stdoutData.toString();
|
|
38
|
+
this.logger.info(stdoutDataClean);
|
|
39
|
+
if (this.options.dn) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let error = false;
|
|
43
|
+
if (errorRegEx.test(stdoutDataClean)) {
|
|
44
|
+
error = true;
|
|
45
|
+
notifier.notify({
|
|
46
|
+
title: projectName,
|
|
47
|
+
message: 'incremental compilation error',
|
|
48
|
+
icon: path.normalize(`${__dirname}/../../../assets/notifications/error.png`),
|
|
49
|
+
sound: false,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else if (compilationCompletetRegEx.test(stdoutDataClean)) {
|
|
53
|
+
if (!ignoreNextCompilationComplete) {
|
|
54
|
+
notifier.notify({
|
|
55
|
+
title: projectName,
|
|
56
|
+
message: 'incremental compilation done',
|
|
57
|
+
icon: path.normalize(`${__dirname}/../../../assets/notifications/success.png`),
|
|
58
|
+
sound: false,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
ignoreNextCompilationComplete = error && !compilationCompletetRegEx.test(stdoutDataClean);
|
|
63
|
+
}
|
|
64
|
+
if (stderrData && !stderrData.match(/^Debugger attached.(\n|\r\n)$/)) {
|
|
65
|
+
this.logger.error(stderrData);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
// eslint-disable-next-line no-constant-condition
|
|
69
|
+
while (true) {
|
|
70
|
+
try {
|
|
71
|
+
await this.invokeShellCommand('node', [
|
|
72
|
+
`${configs_1.configs.libRoot}/node_modules/typescript/lib/tsc.js`,
|
|
73
|
+
'--project',
|
|
74
|
+
configs_1.configs.libRoot,
|
|
75
|
+
'--watch',
|
|
76
|
+
'--pretty',
|
|
77
|
+
], {
|
|
78
|
+
outputHandler,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
// ==========================================
|
|
83
|
+
// @see https://stackoverflow.com/a/25444766/843699
|
|
84
|
+
// ==========================================
|
|
85
|
+
if (_.isString(err) && err.indexOf('3221225786') >= 0) {
|
|
86
|
+
this.logger.error('Exiting...');
|
|
87
|
+
process.exit(0);
|
|
88
|
+
}
|
|
89
|
+
this.logger.error('Error, restarting incremental compilation in a second : ' + String(err));
|
|
90
|
+
await general_utils_1.utils.sleep(1000);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.WatchScript = WatchScript;
|
|
96
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../scripts/watch.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ILogger } from '@villedemontreal/logger';
|
|
2
|
+
/**
|
|
3
|
+
* Lib configs
|
|
4
|
+
*/
|
|
5
|
+
export declare class Configs {
|
|
6
|
+
isWindows: boolean;
|
|
7
|
+
libRoot: string;
|
|
8
|
+
/**
|
|
9
|
+
* The host to query the public keys
|
|
10
|
+
*/
|
|
11
|
+
private _host;
|
|
12
|
+
/**
|
|
13
|
+
* The endpoint to query the public keys
|
|
14
|
+
*/
|
|
15
|
+
private _endpoint;
|
|
16
|
+
/**
|
|
17
|
+
* The parameters to query the public keys
|
|
18
|
+
*/
|
|
19
|
+
private _fetchKeysParameters;
|
|
20
|
+
/**
|
|
21
|
+
* Cache duration
|
|
22
|
+
*/
|
|
23
|
+
private _cacheDuration;
|
|
24
|
+
private _loggerCreator;
|
|
25
|
+
private _correlationIdProvider;
|
|
26
|
+
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Get the host to query the public keys
|
|
29
|
+
* @return {string} host
|
|
30
|
+
*/
|
|
31
|
+
getHost(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get the endpoint to query the public keys
|
|
34
|
+
* @return {string} endpoint
|
|
35
|
+
*/
|
|
36
|
+
getEndpoint(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get the parameters to query the public keys
|
|
39
|
+
* @return {string} fetchKeysParameters
|
|
40
|
+
*/
|
|
41
|
+
getFetchKeysParameters(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get the cache duration in seconds
|
|
44
|
+
* @return {number} cacheDuration
|
|
45
|
+
*/
|
|
46
|
+
getCacheDuration(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Set the host to query the public keys
|
|
49
|
+
* @param {string} host
|
|
50
|
+
* @return
|
|
51
|
+
*/
|
|
52
|
+
setHost(host: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Set the endpoint to query the public keys
|
|
55
|
+
* @param {string} endpoint
|
|
56
|
+
* @return
|
|
57
|
+
*/
|
|
58
|
+
setEndpoint(endpoint: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Set the paramters to query the public keys
|
|
61
|
+
* @param {string} fetchKeysParameters
|
|
62
|
+
* @return
|
|
63
|
+
*/
|
|
64
|
+
setFetchKeysParameters(fetchKeysParameters: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get the cache duration in seconds
|
|
67
|
+
* @param {number} cacheDuration
|
|
68
|
+
* @return
|
|
69
|
+
*/
|
|
70
|
+
setCacheDuration(cacheDuration: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* The Logger creator
|
|
73
|
+
*/
|
|
74
|
+
get loggerCreator(): (name: string) => ILogger;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the Logger creator.
|
|
77
|
+
*/
|
|
78
|
+
setLoggerCreator(loggerCreator: (name: string) => ILogger): void;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the Correlation Id provider.
|
|
81
|
+
*/
|
|
82
|
+
setCorrelationIdProvider(correlationIdProvider: () => string): void;
|
|
83
|
+
/**
|
|
84
|
+
* The Correlation Id provider
|
|
85
|
+
*/
|
|
86
|
+
get correlationIdProvider(): () => string;
|
|
87
|
+
}
|
|
88
|
+
export declare const configs: Configs;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configs = exports.Configs = void 0;
|
|
4
|
+
const os = require("os");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
/**
|
|
8
|
+
* Lib configs
|
|
9
|
+
*/
|
|
10
|
+
class Configs {
|
|
11
|
+
constructor() {
|
|
12
|
+
/**
|
|
13
|
+
* The endpoint to query the public keys
|
|
14
|
+
*/
|
|
15
|
+
this._endpoint = constants_1.constants.default.endpoint;
|
|
16
|
+
/**
|
|
17
|
+
* The parameters to query the public keys
|
|
18
|
+
*/
|
|
19
|
+
this._fetchKeysParameters = constants_1.constants.default.fetchKeysParameters;
|
|
20
|
+
/**
|
|
21
|
+
* Cache duration
|
|
22
|
+
*/
|
|
23
|
+
this._cacheDuration = constants_1.constants.default.cacheDuration;
|
|
24
|
+
this.libRoot = path.normalize(__dirname + '/../../..');
|
|
25
|
+
this.isWindows = os.platform() === 'win32';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the host to query the public keys
|
|
29
|
+
* @return {string} host
|
|
30
|
+
*/
|
|
31
|
+
getHost() {
|
|
32
|
+
if (!this._host) {
|
|
33
|
+
throw new Error(`The "host" must be set!`);
|
|
34
|
+
}
|
|
35
|
+
return this._host;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the endpoint to query the public keys
|
|
39
|
+
* @return {string} endpoint
|
|
40
|
+
*/
|
|
41
|
+
getEndpoint() {
|
|
42
|
+
return this._endpoint;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the parameters to query the public keys
|
|
46
|
+
* @return {string} fetchKeysParameters
|
|
47
|
+
*/
|
|
48
|
+
getFetchKeysParameters() {
|
|
49
|
+
return this._fetchKeysParameters;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the cache duration in seconds
|
|
53
|
+
* @return {number} cacheDuration
|
|
54
|
+
*/
|
|
55
|
+
getCacheDuration() {
|
|
56
|
+
return this._cacheDuration;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Set the host to query the public keys
|
|
60
|
+
* @param {string} host
|
|
61
|
+
* @return
|
|
62
|
+
*/
|
|
63
|
+
setHost(host) {
|
|
64
|
+
this._host = host;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Set the endpoint to query the public keys
|
|
68
|
+
* @param {string} endpoint
|
|
69
|
+
* @return
|
|
70
|
+
*/
|
|
71
|
+
setEndpoint(endpoint) {
|
|
72
|
+
this._endpoint = endpoint;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Set the paramters to query the public keys
|
|
76
|
+
* @param {string} fetchKeysParameters
|
|
77
|
+
* @return
|
|
78
|
+
*/
|
|
79
|
+
setFetchKeysParameters(fetchKeysParameters) {
|
|
80
|
+
this._fetchKeysParameters = fetchKeysParameters;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the cache duration in seconds
|
|
84
|
+
* @param {number} cacheDuration
|
|
85
|
+
* @return
|
|
86
|
+
*/
|
|
87
|
+
setCacheDuration(cacheDuration) {
|
|
88
|
+
this._cacheDuration = cacheDuration;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The Logger creator
|
|
92
|
+
*/
|
|
93
|
+
get loggerCreator() {
|
|
94
|
+
if (!this._loggerCreator) {
|
|
95
|
+
throw new Error(`The Logger Creator HAS to be set as a configuration`);
|
|
96
|
+
}
|
|
97
|
+
return this._loggerCreator;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Sets the Logger creator.
|
|
101
|
+
*/
|
|
102
|
+
setLoggerCreator(loggerCreator) {
|
|
103
|
+
this._loggerCreator = loggerCreator;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Sets the Correlation Id provider.
|
|
107
|
+
*/
|
|
108
|
+
setCorrelationIdProvider(correlationIdProvider) {
|
|
109
|
+
this._correlationIdProvider = correlationIdProvider;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The Correlation Id provider
|
|
113
|
+
*/
|
|
114
|
+
get correlationIdProvider() {
|
|
115
|
+
if (!this._correlationIdProvider) {
|
|
116
|
+
throw new Error(`The Correlation Id provider HAS to be set as a configuration! Please call the init(...) fonction first.`);
|
|
117
|
+
}
|
|
118
|
+
return this._correlationIdProvider;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.Configs = Configs;
|
|
122
|
+
exports.configs = new Configs();
|
|
123
|
+
//# sourceMappingURL=configs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configs.js","sourceRoot":"","sources":["../../../src/config/configs.ts"],"names":[],"mappings":";;;AACA,yBAAyB;AACzB,6BAA6B;AAC7B,2CAAwC;AAExC;;GAEG;AACH,MAAa,OAAO;IAuBlB;QAhBA;;WAEG;QACK,cAAS,GAAW,qBAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;QACvD;;WAEG;QACK,yBAAoB,GAAW,qBAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC7E;;WAEG;QACK,mBAAc,GAAW,qBAAS,CAAC,OAAO,CAAC,aAAa,CAAC;QAM/D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,WAAW,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACI,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC5C;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;OAGG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,sBAAsB;QAC3B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,IAAY;QACzB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,QAAgB;QACjC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,sBAAsB,CAAC,mBAA2B;QACvD,IAAI,CAAC,oBAAoB,GAAG,mBAAmB,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,aAAqB;QAC3C,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,gBAAgB,CAAC,aAAwC;QAC9D,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,wBAAwB,CAAC,qBAAmC;QACjE,IAAI,CAAC,sBAAsB,GAAG,qBAAqB,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,IAAI,qBAAqB;QACvB,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE;YAChC,MAAM,IAAI,KAAK,CACb,yGAAyG,CAC1G,CAAC;SACH;QACD,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACrC,CAAC;CACF;AAtID,0BAsIC;AAEY,QAAA,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library constants
|
|
3
|
+
*/
|
|
4
|
+
export declare class Constants {
|
|
5
|
+
/**
|
|
6
|
+
* The library root. When this library is used
|
|
7
|
+
* as a dependency in a project, the "libRoot"
|
|
8
|
+
* will be the path to the dependency folder,
|
|
9
|
+
* inside the "node_modules".
|
|
10
|
+
*/
|
|
11
|
+
libRoot: string;
|
|
12
|
+
/**
|
|
13
|
+
* The app root. When this library is used
|
|
14
|
+
* as a dependency in a project, the "appRoot"
|
|
15
|
+
* will be the path to the root project!
|
|
16
|
+
*/
|
|
17
|
+
appRoot: string;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Errors related constants
|
|
21
|
+
*/
|
|
22
|
+
get errors(): {
|
|
23
|
+
codes: {
|
|
24
|
+
INVALID_HEADER: string;
|
|
25
|
+
ACCOUNT_ALREADY_EXISTS: string;
|
|
26
|
+
ACCOUNT_NOT_FOUND: string;
|
|
27
|
+
ACCOUNT_ALREADY_VERIFIED: string;
|
|
28
|
+
INVALID_AUTHORIZATION_HEADER: string;
|
|
29
|
+
INVALID_JWT: string;
|
|
30
|
+
CODE_NOT_FOUND: string;
|
|
31
|
+
CODE_EXPIRED: string;
|
|
32
|
+
PHONE_NOT_FOUND: string;
|
|
33
|
+
UNABLE_TO_GET_PUBLIC_KEY: string;
|
|
34
|
+
NULL_VALUE: string;
|
|
35
|
+
INVALID_VALUE: string;
|
|
36
|
+
INVALID_EMAIL_VALUE: string;
|
|
37
|
+
UNAUTHORIZED_ACCESS: string;
|
|
38
|
+
TEST_REMAINING: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Extra values that we can add to the original Express request.
|
|
43
|
+
*/
|
|
44
|
+
get requestExtraVariables(): {
|
|
45
|
+
JWT: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Default values
|
|
49
|
+
*/
|
|
50
|
+
get default(): {
|
|
51
|
+
endpoint: string;
|
|
52
|
+
fetchKeysParameters: string;
|
|
53
|
+
cacheDuration: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export declare const constants: Constants;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.constants = exports.Constants = void 0;
|
|
4
|
+
// ==========================================
|
|
5
|
+
// Application constants
|
|
6
|
+
// ==========================================
|
|
7
|
+
const app_root_path_1 = require("app-root-path");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
/**
|
|
10
|
+
* Library constants
|
|
11
|
+
*/
|
|
12
|
+
class Constants {
|
|
13
|
+
constructor() {
|
|
14
|
+
// From the "dist/src/config" folder
|
|
15
|
+
this.libRoot = path.normalize(__dirname + '/../../..');
|
|
16
|
+
this.appRoot = app_root_path_1.path;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Errors related constants
|
|
20
|
+
*/
|
|
21
|
+
get errors() {
|
|
22
|
+
return {
|
|
23
|
+
codes: {
|
|
24
|
+
// Main Code
|
|
25
|
+
INVALID_HEADER: 'invalidHeader',
|
|
26
|
+
ACCOUNT_ALREADY_EXISTS: 'accountAlreadyExists',
|
|
27
|
+
ACCOUNT_NOT_FOUND: 'accountNotFound',
|
|
28
|
+
ACCOUNT_ALREADY_VERIFIED: 'accountAlreadyVerified',
|
|
29
|
+
INVALID_AUTHORIZATION_HEADER: 'invalidAuthorizationHeader',
|
|
30
|
+
INVALID_JWT: 'invalidJWT',
|
|
31
|
+
CODE_NOT_FOUND: 'codeNotFound',
|
|
32
|
+
CODE_EXPIRED: 'codeExpired',
|
|
33
|
+
PHONE_NOT_FOUND: 'phoneNotFound',
|
|
34
|
+
UNABLE_TO_GET_PUBLIC_KEY: 'unableToGetPublicKey',
|
|
35
|
+
// Value Code
|
|
36
|
+
NULL_VALUE: 'nullValue',
|
|
37
|
+
INVALID_VALUE: 'invalidValue',
|
|
38
|
+
INVALID_EMAIL_VALUE: 'invalidEmailValue',
|
|
39
|
+
UNAUTHORIZED_ACCESS: 'unauthorizedAccess',
|
|
40
|
+
// Information Code
|
|
41
|
+
TEST_REMAINING: 'testRemaining',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Extra values that we can add to the original Express request.
|
|
47
|
+
*/
|
|
48
|
+
get requestExtraVariables() {
|
|
49
|
+
return {
|
|
50
|
+
JWT: 'jwt',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Default values
|
|
55
|
+
*/
|
|
56
|
+
get default() {
|
|
57
|
+
return {
|
|
58
|
+
endpoint: '/api/security/v1/keys',
|
|
59
|
+
fetchKeysParameters: 'state=active&state=revoked&offset=0&limit=25',
|
|
60
|
+
cacheDuration: 60 * 5,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.Constants = Constants;
|
|
65
|
+
exports.constants = new Constants();
|
|
66
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/config/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,wBAAwB;AACxB,6CAA6C;AAC7C,iDAAgD;AAChD,6BAA6B;AAE7B;;GAEG;AACH,MAAa,SAAS;IAgBpB;QACE,oCAAoC;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,WAAW,CAAC,CAAC;QACvD,IAAI,CAAC,OAAO,GAAG,oBAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO;YACL,KAAK,EAAE;gBACL,YAAY;gBACZ,cAAc,EAAE,eAAe;gBAC/B,sBAAsB,EAAE,sBAAsB;gBAC9C,iBAAiB,EAAE,iBAAiB;gBACpC,wBAAwB,EAAE,wBAAwB;gBAClD,4BAA4B,EAAE,4BAA4B;gBAC1D,WAAW,EAAE,YAAY;gBACzB,cAAc,EAAE,cAAc;gBAC9B,YAAY,EAAE,aAAa;gBAC3B,eAAe,EAAE,eAAe;gBAChC,wBAAwB,EAAE,sBAAsB;gBAEhD,aAAa;gBACb,UAAU,EAAE,WAAW;gBACvB,aAAa,EAAE,cAAc;gBAC7B,mBAAmB,EAAE,mBAAmB;gBACxC,mBAAmB,EAAE,oBAAoB;gBAEzC,mBAAmB;gBACnB,cAAc,EAAE,eAAe;aAChC;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,IAAI,qBAAqB;QACvB,OAAO;YACL,GAAG,EAAE,KAAK;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO;YACL,QAAQ,EAAE,uBAAuB;YACjC,mBAAmB,EAAE,8CAA8C;YACnE,aAAa,EAAE,EAAE,GAAG,CAAC;SACtB,CAAC;IACJ,CAAC;CACF;AAvED,8BAuEC;AAEY,QAAA,SAAS,GAAc,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ILogger } from '@villedemontreal/logger';
|
|
2
|
+
/**
|
|
3
|
+
* Inits the library.
|
|
4
|
+
*/
|
|
5
|
+
export declare function init(loggerCreator: (name: string) => ILogger, correlationIdProvider: () => string, host: string, endpoint?: string, fetchKeysParameters?: string, cacheDuration?: number, urlCaseSensitive?: boolean): void;
|
|
6
|
+
/**
|
|
7
|
+
* Is the library properly initialized?
|
|
8
|
+
*
|
|
9
|
+
* This function MUST be named "isInited()"!
|
|
10
|
+
* Code using this library may loop over all its "@villedemontreal"
|
|
11
|
+
* dependencies and, if one of those exports a "isInited" fonction,
|
|
12
|
+
* it will enforce that the lib has been properly initialized before
|
|
13
|
+
* starting...
|
|
14
|
+
*/
|
|
15
|
+
export declare function isInited(): boolean;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isInited = exports.init = void 0;
|
|
4
|
+
const http_request_1 = require("@villedemontreal/http-request");
|
|
5
|
+
const configs_1 = require("./configs");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
let libIsInited = false;
|
|
8
|
+
/**
|
|
9
|
+
* Inits the library.
|
|
10
|
+
*/
|
|
11
|
+
function init(loggerCreator, correlationIdProvider, host, endpoint = constants_1.constants.default.endpoint, fetchKeysParameters = constants_1.constants.default.fetchKeysParameters, cacheDuration = constants_1.constants.default.cacheDuration, urlCaseSensitive = false) {
|
|
12
|
+
if (!loggerCreator) {
|
|
13
|
+
throw new Error(`The Logger Creator is required.`);
|
|
14
|
+
}
|
|
15
|
+
configs_1.configs.setLoggerCreator(loggerCreator);
|
|
16
|
+
if (!correlationIdProvider) {
|
|
17
|
+
throw new Error(`The Correlation Id provider is required.`);
|
|
18
|
+
}
|
|
19
|
+
configs_1.configs.setCorrelationIdProvider(correlationIdProvider);
|
|
20
|
+
configs_1.configs.setHost(host);
|
|
21
|
+
configs_1.configs.setEndpoint(endpoint);
|
|
22
|
+
configs_1.configs.setFetchKeysParameters(fetchKeysParameters);
|
|
23
|
+
configs_1.configs.setCacheDuration(cacheDuration);
|
|
24
|
+
// ==========================================
|
|
25
|
+
// Inits the Http Utils library!
|
|
26
|
+
// ==========================================
|
|
27
|
+
(0, http_request_1.init)(loggerCreator, correlationIdProvider, urlCaseSensitive);
|
|
28
|
+
// ==========================================
|
|
29
|
+
// Set as being "properly initialized".
|
|
30
|
+
// At the very end of the "init()" function!
|
|
31
|
+
// ==========================================
|
|
32
|
+
libIsInited = true;
|
|
33
|
+
}
|
|
34
|
+
exports.init = init;
|
|
35
|
+
/**
|
|
36
|
+
* Is the library properly initialized?
|
|
37
|
+
*
|
|
38
|
+
* This function MUST be named "isInited()"!
|
|
39
|
+
* Code using this library may loop over all its "@villedemontreal"
|
|
40
|
+
* dependencies and, if one of those exports a "isInited" fonction,
|
|
41
|
+
* it will enforce that the lib has been properly initialized before
|
|
42
|
+
* starting...
|
|
43
|
+
*/
|
|
44
|
+
function isInited() {
|
|
45
|
+
return libIsInited;
|
|
46
|
+
}
|
|
47
|
+
exports.isInited = isInited;
|
|
48
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/config/init.ts"],"names":[],"mappings":";;;AAAA,gEAAsE;AAEtE,uCAAoC;AACpC,2CAAwC;AAExC,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;GAEG;AACH,SAAgB,IAAI,CAClB,aAAwC,EACxC,qBAAmC,EACnC,IAAY,EACZ,WAAmB,qBAAS,CAAC,OAAO,CAAC,QAAQ,EAC7C,sBAA8B,qBAAS,CAAC,OAAO,CAAC,mBAAmB,EACnE,gBAAwB,qBAAS,CAAC,OAAO,CAAC,aAAa,EACvD,gBAAgB,GAAG,KAAK;IAExB,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;KACpD;IACD,iBAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAExC,IAAI,CAAC,qBAAqB,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IACD,iBAAO,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;IAExD,iBAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,iBAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,iBAAO,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;IACpD,iBAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAExC,6CAA6C;IAC7C,gCAAgC;IAChC,6CAA6C;IAC7C,IAAA,mBAAa,EAAC,aAAa,EAAE,qBAAqB,EAAE,gBAAgB,CAAC,CAAC;IAEtE,6CAA6C;IAC7C,uCAAuC;IACvC,4CAA4C;IAC5C,6CAA6C;IAC7C,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAlCD,oBAkCC;AAED;;;;;;;;GAQG;AACH,SAAgB,QAAQ;IACtB,OAAO,WAAW,CAAC;AACrB,CAAC;AAFD,4BAEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './config/constants';
|
|
2
|
+
export * from './config/init';
|
|
3
|
+
export * from './jwtValidator';
|
|
4
|
+
export * from './middleware/jwtMiddleware';
|
|
5
|
+
export * from './models/expressRequest';
|
|
6
|
+
export * from './models/gluuUserType';
|
|
7
|
+
export * from './models/jwtPayload';
|
|
8
|
+
export * from './models/publicKey';
|
|
9
|
+
export * from './userValidator';
|
|
10
|
+
export * from './utils/jwtMock';
|
|
@@ -0,0 +1,32 @@
|
|
|
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("./config/constants"), exports);
|
|
18
|
+
// ==========================================
|
|
19
|
+
// We do not export the configs instance itself,
|
|
20
|
+
// only the "init()" method, so we can define
|
|
21
|
+
// which are the required parameters.
|
|
22
|
+
// ==========================================
|
|
23
|
+
__exportStar(require("./config/init"), exports);
|
|
24
|
+
__exportStar(require("./jwtValidator"), exports);
|
|
25
|
+
__exportStar(require("./middleware/jwtMiddleware"), exports);
|
|
26
|
+
__exportStar(require("./models/expressRequest"), exports);
|
|
27
|
+
__exportStar(require("./models/gluuUserType"), exports);
|
|
28
|
+
__exportStar(require("./models/jwtPayload"), exports);
|
|
29
|
+
__exportStar(require("./models/publicKey"), exports);
|
|
30
|
+
__exportStar(require("./userValidator"), exports);
|
|
31
|
+
__exportStar(require("./utils/jwtMock"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,6CAA6C;AAC7C,gDAAgD;AAChD,6CAA6C;AAC7C,qCAAqC;AACrC,6CAA6C;AAC7C,gDAA8B;AAC9B,iDAA+B;AAC/B,6DAA2C;AAC3C,0DAAwC;AACxC,wDAAsC;AACtC,sDAAoC;AACpC,qDAAmC;AACnC,kDAAgC;AAChC,kDAAgC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IJWTPayload } from './models/jwtPayload';
|
|
2
|
+
/**
|
|
3
|
+
* JWT validator
|
|
4
|
+
*/
|
|
5
|
+
export interface IJwtValidator {
|
|
6
|
+
/**
|
|
7
|
+
* Verifies an "Authorization" header containing a JWT, checks
|
|
8
|
+
* the JWT with the public key and returns the decoded payload.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} header
|
|
11
|
+
* @return {Promise<IJWTPayload>}
|
|
12
|
+
*/
|
|
13
|
+
verifyAuthorizationHeader(header: string): Promise<IJWTPayload>;
|
|
14
|
+
/**
|
|
15
|
+
* Verifies a JWT with the public key and returns the decoded payload.
|
|
16
|
+
* @param {string} token
|
|
17
|
+
* @return {Promise<IJWTPayload>}
|
|
18
|
+
*/
|
|
19
|
+
verifyToken(token: string): Promise<IJWTPayload>;
|
|
20
|
+
}
|
|
21
|
+
export declare const jwtValidator: IJwtValidator;
|