@edirect/oidc-client 3.2.4 → 11.0.28
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/README.md +39 -39
- package/dist/README.md +39 -0
- package/dist/package.json +23 -0
- package/dist/src/connect.d.ts +11 -0
- package/dist/src/connect.d.ts.map +1 -0
- package/dist/src/connect.js +33 -0
- package/dist/{grant-type → src/grant-type}/client_credentials.d.ts +16 -16
- package/dist/src/grant-type/client_credentials.d.ts.map +1 -0
- package/dist/src/grant-type/client_credentials.js +55 -0
- package/dist/{grant-type → src/grant-type}/password.d.ts +16 -14
- package/dist/src/grant-type/password.d.ts.map +1 -0
- package/dist/src/grant-type/password.js +92 -0
- package/dist/{grant-type → src/grant-type}/sso.d.ts +16 -14
- package/dist/src/grant-type/sso.d.ts.map +1 -0
- package/dist/src/grant-type/sso.js +92 -0
- package/dist/{index.d.ts → src/index.d.ts} +4 -3
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +20 -0
- package/dist/{token.d.ts → src/token.d.ts} +7 -6
- package/dist/src/token.d.ts.map +1 -0
- package/dist/{token.js → src/token.js} +22 -23
- package/dist/{types → src/types}/connect.type.d.ts +12 -12
- package/dist/src/types/connect.type.d.ts.map +1 -0
- package/dist/{types → src/types}/connect.type.js +2 -3
- package/dist/src/types/error-handler.type.d.ts +6 -0
- package/dist/src/types/error-handler.type.d.ts.map +1 -0
- package/dist/{types → src/types}/error-handler.type.js +2 -3
- package/dist/{types → src/types}/token-set.type.d.ts +22 -21
- package/dist/src/types/token-set.type.d.ts.map +1 -0
- package/dist/{types → src/types}/token-set.type.js +2 -3
- package/dist/{utils → src/utils}/error-handler.d.ts +6 -5
- package/dist/src/utils/error-handler.d.ts.map +1 -0
- package/dist/{utils → src/utils}/error-handler.js +12 -13
- package/dist/{utils → src/utils}/parse-token.d.ts +4 -3
- package/dist/src/utils/parse-token.d.ts.map +1 -0
- package/dist/{utils → src/utils}/parse-token.js +25 -26
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +40 -39
- package/.editorconfig +0 -14
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -46
- package/.husky/pre-commit +0 -4
- package/.husky/pre-push +0 -4
- package/.prettierrc.js +0 -6
- package/dist/connect.d.ts +0 -11
- package/dist/connect.js +0 -55
- package/dist/connect.js.map +0 -1
- package/dist/grant-type/client_credentials.js +0 -58
- package/dist/grant-type/client_credentials.js.map +0 -1
- package/dist/grant-type/password.js +0 -58
- package/dist/grant-type/password.js.map +0 -1
- package/dist/grant-type/sso.js +0 -65
- package/dist/grant-type/sso.js.map +0 -1
- package/dist/index.js +0 -30
- package/dist/index.js.map +0 -1
- package/dist/token.js.map +0 -1
- package/dist/types/connect.type.js.map +0 -1
- package/dist/types/error-handler.type.d.ts +0 -5
- package/dist/types/error-handler.type.js.map +0 -1
- package/dist/types/token-set.type.js.map +0 -1
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/parse-token.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
export type Connect = {
|
|
2
|
+
grantType?: string;
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
oidcPath: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
responseTypes?: string[];
|
|
8
|
+
grantTypes?: string[];
|
|
9
|
+
timeout?: number;
|
|
10
|
+
redirectUri?: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=connect.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.type.d.ts","sourceRoot":"","sources":["../../../src/types/connect.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=connect.type.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.type.d.ts","sourceRoot":"","sources":["../../../src/types/error-handler.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG,CACtC,KAAK,EAAE,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3C,IAAI,CAAC;AAEV,MAAM,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,yBAAyB,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=error-handler.type.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
export
|
|
2
|
-
accessToken: string;
|
|
3
|
-
expiresAt: number;
|
|
4
|
-
expiresIn: number;
|
|
5
|
-
idToken: string;
|
|
6
|
-
refreshToken: string;
|
|
7
|
-
scope: string;
|
|
8
|
-
sessionState: string;
|
|
9
|
-
tokenType: string;
|
|
10
|
-
};
|
|
11
|
-
export
|
|
12
|
-
access_token: string;
|
|
13
|
-
expires_at: number;
|
|
14
|
-
expires_in: number;
|
|
15
|
-
id_token: string;
|
|
16
|
-
refresh_token: string;
|
|
17
|
-
scope: string;
|
|
18
|
-
session_state: string;
|
|
19
|
-
token_type: string;
|
|
20
|
-
};
|
|
21
|
-
export
|
|
1
|
+
export type TokenSetParsed = {
|
|
2
|
+
accessToken: string;
|
|
3
|
+
expiresAt: number;
|
|
4
|
+
expiresIn: number;
|
|
5
|
+
idToken: string;
|
|
6
|
+
refreshToken: string;
|
|
7
|
+
scope: string;
|
|
8
|
+
sessionState: string;
|
|
9
|
+
tokenType: string;
|
|
10
|
+
};
|
|
11
|
+
export type TokenSetSource = {
|
|
12
|
+
access_token: string;
|
|
13
|
+
expires_at: number;
|
|
14
|
+
expires_in: number;
|
|
15
|
+
id_token: string;
|
|
16
|
+
refresh_token: string;
|
|
17
|
+
scope: string;
|
|
18
|
+
session_state: string;
|
|
19
|
+
token_type: string;
|
|
20
|
+
};
|
|
21
|
+
export type TokenSet = TokenSetSource & TokenSetParsed;
|
|
22
|
+
//# sourceMappingURL=token-set.type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-set.type.d.ts","sourceRoot":"","sources":["../../../src/types/token-set.type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,cAAc,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=token-set.type.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
declare const _default: (grantType: string) => (error: Error & {
|
|
2
|
-
code?: number;
|
|
3
|
-
url?: string;
|
|
4
|
-
}) => never;
|
|
5
|
-
export default _default;
|
|
1
|
+
declare const _default: (grantType: string) => (error: Error & {
|
|
2
|
+
code?: number;
|
|
3
|
+
url?: string;
|
|
4
|
+
}) => never;
|
|
5
|
+
export default _default;
|
|
6
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../../src/utils/error-handler.ts"],"names":[],"mappings":"yBAAgB,WAAW,MAAM,MAC9B,OAAO,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE;AADjD,wBAeI"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = (grantType) => (error) => {
|
|
4
|
-
const { name, code, url, message } = error;
|
|
5
|
-
if (name && code && url) {
|
|
6
|
-
throw new Error(`[${grantType}] Error: ${JSON.stringify({ name, code, url })}`);
|
|
7
|
-
}
|
|
8
|
-
if (message) {
|
|
9
|
-
throw new Error(`[${grantType}] Error: ${message}`);
|
|
10
|
-
}
|
|
11
|
-
throw error;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=error-handler.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = (grantType) => (error) => {
|
|
4
|
+
const { name, code, url, message } = error;
|
|
5
|
+
if (name && code && url) {
|
|
6
|
+
throw new Error(`[${grantType}] Error: ${JSON.stringify({ name, code, url })}`);
|
|
7
|
+
}
|
|
8
|
+
if (message) {
|
|
9
|
+
throw new Error(`[${grantType}] Error: ${message}`);
|
|
10
|
+
}
|
|
11
|
+
throw error;
|
|
12
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { TokenSet } from '../types/token-set.type';
|
|
2
|
-
declare const _default: (tokenSet: TokenSet, revert?: boolean) => TokenSet;
|
|
3
|
-
export default _default;
|
|
1
|
+
import { TokenSet } from '../types/token-set.type';
|
|
2
|
+
declare const _default: (tokenSet: TokenSet, revert?: boolean) => TokenSet;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=parse-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-token.d.ts","sourceRoot":"","sources":["../../../src/utils/parse-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGT,MAAM,yBAAyB,CAAC;yBAajB,UAAU,QAAQ,EAAE,gBAAc,KAAG,QAAQ;AAA7D,wBAgBE"}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tokenMapper = {
|
|
4
|
-
accessToken: 'access_token',
|
|
5
|
-
expiresAt: 'expires_at',
|
|
6
|
-
expiresIn: 'expires_in',
|
|
7
|
-
idToken: 'id_token',
|
|
8
|
-
refreshToken: 'refresh_token',
|
|
9
|
-
scope: 'scope',
|
|
10
|
-
sessionState: 'session_state',
|
|
11
|
-
tokenType: 'token_type',
|
|
12
|
-
};
|
|
13
|
-
exports.default = (tokenSet, revert = false) => {
|
|
14
|
-
const tokenSetParsed = {};
|
|
15
|
-
Object.keys(tokenMapper).forEach(
|
|
16
|
-
const key = ((revert && tokenMapper[mapperKey]) ||
|
|
17
|
-
mapperKey);
|
|
18
|
-
const value = (revert && tokenSet[mapperKey]) ||
|
|
19
|
-
tokenSet[tokenMapper[mapperKey]];
|
|
20
|
-
if (typeof value !== 'undefined') {
|
|
21
|
-
tokenSetParsed[key] = value;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return tokenSetParsed;
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=parse-token.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tokenMapper = {
|
|
4
|
+
accessToken: 'access_token',
|
|
5
|
+
expiresAt: 'expires_at',
|
|
6
|
+
expiresIn: 'expires_in',
|
|
7
|
+
idToken: 'id_token',
|
|
8
|
+
refreshToken: 'refresh_token',
|
|
9
|
+
scope: 'scope',
|
|
10
|
+
sessionState: 'session_state',
|
|
11
|
+
tokenType: 'token_type',
|
|
12
|
+
};
|
|
13
|
+
exports.default = (tokenSet, revert = false) => {
|
|
14
|
+
const tokenSetParsed = {};
|
|
15
|
+
Object.keys(tokenMapper).forEach(mapperKey => {
|
|
16
|
+
const key = ((revert && tokenMapper[mapperKey]) ||
|
|
17
|
+
mapperKey);
|
|
18
|
+
const value = (revert && tokenSet[mapperKey]) ||
|
|
19
|
+
tokenSet[tokenMapper[mapperKey]];
|
|
20
|
+
if (typeof value !== 'undefined') {
|
|
21
|
+
tokenSetParsed[key] = value;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return tokenSetParsed;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.9.2"}
|
package/package.json
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@edirect/oidc-client",
|
|
3
|
-
"version": "
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@edirect/oidc-client",
|
|
3
|
+
"version": "11.0.28",
|
|
4
|
+
"packageScope": "@edirect",
|
|
5
|
+
"main": "./dist/src/index.js",
|
|
6
|
+
"types": "./dist/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./package.json": "./package.json",
|
|
9
|
+
".": {
|
|
10
|
+
"development": "./src/index.ts",
|
|
11
|
+
"default": "./dist/src/index.js",
|
|
12
|
+
"types": "./dist/src/index.d.ts",
|
|
13
|
+
"require": "./dist/src/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"openid-client": "^6.7.1",
|
|
21
|
+
"tslib": "^2.8.1"
|
|
22
|
+
},
|
|
23
|
+
"nx": {
|
|
24
|
+
"name": "@edirect/oidc-client",
|
|
25
|
+
"targets": {
|
|
26
|
+
"build": {
|
|
27
|
+
"executor": "@nx/js:tsc",
|
|
28
|
+
"options": {
|
|
29
|
+
"main": "{workspaceRoot}/packages/edirect-oidc-client/src/index.ts",
|
|
30
|
+
"tsConfig": "{workspaceRoot}/packages/edirect-oidc-client/tsconfig.lib.json",
|
|
31
|
+
"outputPath": "{workspaceRoot}/packages/edirect-oidc-client/dist",
|
|
32
|
+
"assets": [
|
|
33
|
+
"{workspaceRoot}/packages/edirect-oidc-client/package.json",
|
|
34
|
+
"{workspaceRoot}/packages/edirect-oidc-client/README.md"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/.editorconfig
DELETED
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/node_modules
|
package/.eslintrc.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
node: true,
|
|
5
|
-
es6: true,
|
|
6
|
-
},
|
|
7
|
-
parserOptions: {
|
|
8
|
-
ecmaFeatures: {
|
|
9
|
-
jsx: true,
|
|
10
|
-
},
|
|
11
|
-
ecmaVersion: 2018,
|
|
12
|
-
sourceType: 'module',
|
|
13
|
-
project: './tsconfig.json',
|
|
14
|
-
tsconfigRootDir: __dirname,
|
|
15
|
-
},
|
|
16
|
-
ignorePatterns: ['node_modules/*', 'dist/*', '!.prettierrc.js'],
|
|
17
|
-
extends: ['eslint:recommended'],
|
|
18
|
-
overrides: [
|
|
19
|
-
{
|
|
20
|
-
files: ['./src/**/*.ts'],
|
|
21
|
-
parser: '@typescript-eslint/parser',
|
|
22
|
-
settings: {
|
|
23
|
-
react: {
|
|
24
|
-
version: 'detect',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
env: {
|
|
28
|
-
browser: true,
|
|
29
|
-
node: true,
|
|
30
|
-
es6: true,
|
|
31
|
-
},
|
|
32
|
-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
|
|
33
|
-
rules: {
|
|
34
|
-
'@typescript-eslint/no-unused-vars': ['error'],
|
|
35
|
-
|
|
36
|
-
'@typescript-eslint/explicit-function-return-type': [
|
|
37
|
-
'warn',
|
|
38
|
-
{
|
|
39
|
-
allowExpressions: true,
|
|
40
|
-
allowConciseArrowFunctionExpressionsStartingWithVoid: true,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
};
|
package/.husky/pre-commit
DELETED
package/.husky/pre-push
DELETED
package/.prettierrc.js
DELETED
package/dist/connect.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Client } from 'openid-client';
|
|
2
|
-
import { ErrorHandlerType } from './types/error-handler.type';
|
|
3
|
-
import { Connect } from './types/connect.type';
|
|
4
|
-
export default class OidcConnect {
|
|
5
|
-
client: Client;
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
redirectUri?: string;
|
|
8
|
-
ErrorHandler: ErrorHandlerType;
|
|
9
|
-
constructor();
|
|
10
|
-
connect({ baseUrl, oidcPath, clientId, clientSecret, redirectUri, responseTypes, grantTypes, timeout, }: Connect): Promise<Client>;
|
|
11
|
-
}
|
package/dist/connect.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const openid_client_1 = require("openid-client");
|
|
16
|
-
const http_1 = __importDefault(require("http"));
|
|
17
|
-
const https_1 = __importDefault(require("https"));
|
|
18
|
-
const error_handler_1 = __importDefault(require("./utils/error-handler"));
|
|
19
|
-
class OidcConnect {
|
|
20
|
-
constructor() {
|
|
21
|
-
this.ErrorHandler = error_handler_1.default;
|
|
22
|
-
}
|
|
23
|
-
connect({ baseUrl, oidcPath, clientId, clientSecret, redirectUri, responseTypes, grantTypes, timeout, }) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
this.baseUrl = baseUrl;
|
|
26
|
-
this.redirectUri = redirectUri;
|
|
27
|
-
const oidcConfiguration = {
|
|
28
|
-
client_id: clientId,
|
|
29
|
-
client_secret: clientSecret,
|
|
30
|
-
redirect_uris: [redirectUri],
|
|
31
|
-
response_types: responseTypes,
|
|
32
|
-
grant_types: grantTypes,
|
|
33
|
-
};
|
|
34
|
-
const protocol = (baseUrl.includes('https') && 'https:') || 'http:';
|
|
35
|
-
if (openid_client_1.custom && openid_client_1.custom.setHttpOptionsDefaults) {
|
|
36
|
-
openid_client_1.custom.setHttpOptionsDefaults({
|
|
37
|
-
url: `${baseUrl}/${oidcPath}`,
|
|
38
|
-
timeout: timeout || 60000,
|
|
39
|
-
protocol,
|
|
40
|
-
agent: {
|
|
41
|
-
http: new http_1.default.Agent({ keepAlive: true }),
|
|
42
|
-
https: baseUrl.includes('https')
|
|
43
|
-
? new https_1.default.Agent({ keepAlive: true })
|
|
44
|
-
: undefined,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
const oidcIssuer = yield openid_client_1.Issuer.discover(`${baseUrl}/${oidcPath}`);
|
|
49
|
-
this.client = new oidcIssuer.Client(oidcConfiguration);
|
|
50
|
-
return this.client;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.default = OidcConnect;
|
|
55
|
-
//# sourceMappingURL=connect.js.map
|
package/dist/connect.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iDAAuE;AACvE,gDAAwB;AACxB,kDAA0B;AAE1B,0EAAiD;AAIjD,MAAqB,WAAW;IAM9B;QACE,IAAI,CAAC,YAAY,GAAG,uBAAY,CAAC;IACnC,CAAC;IAEK,OAAO,CAAC,EACZ,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,OAAO,GACC;;YACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAE/B,MAAM,iBAAiB,GAAmB;gBACxC,SAAS,EAAE,QAAQ;gBACnB,aAAa,EAAE,YAAY;gBAC3B,aAAa,EAAE,CAAC,WAAqB,CAAC;gBACtC,cAAc,EAAE,aAAa;gBAC7B,WAAW,EAAE,UAAU;aACxB,CAAC;YAEF,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,IAAI,OAAO,CAAC;YAEpE,IAAI,sBAAM,IAAI,sBAAM,CAAC,sBAAsB,EAAE;gBAC3C,sBAAM,CAAC,sBAAsB,CAAC;oBAC5B,GAAG,EAAE,GAAG,OAAO,IAAI,QAAQ,EAAE;oBAC7B,OAAO,EAAE,OAAO,IAAI,KAAK;oBACzB,QAAQ;oBACR,KAAK,EAAE;wBACL,IAAI,EAAE,IAAI,cAAI,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;wBACzC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;4BAC9B,CAAC,CAAC,IAAI,eAAK,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;4BACtC,CAAC,CAAC,SAAS;qBACd;iBACF,CAAC,CAAC;aACJ;YAED,MAAM,UAAU,GAAG,MAAM,sBAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAC,CAAC;YACnE,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;KAAA;CACF;AAnDD,8BAmDC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.oidc = void 0;
|
|
16
|
-
const connect_1 = __importDefault(require("../connect"));
|
|
17
|
-
const token_1 = __importDefault(require("../token"));
|
|
18
|
-
const grantType = 'client_credentials';
|
|
19
|
-
class OidcClient extends connect_1.default {
|
|
20
|
-
constructor() {
|
|
21
|
-
super();
|
|
22
|
-
this.errorHandler = this.ErrorHandler(grantType);
|
|
23
|
-
const { getToken, setToken } = new token_1.default();
|
|
24
|
-
this.getToken = getToken;
|
|
25
|
-
this.setToken = setToken;
|
|
26
|
-
}
|
|
27
|
-
connect({ baseUrl, oidcPath, clientId, clientSecret, redirectUri, }) {
|
|
28
|
-
return super.connect({
|
|
29
|
-
baseUrl,
|
|
30
|
-
oidcPath,
|
|
31
|
-
clientId,
|
|
32
|
-
clientSecret,
|
|
33
|
-
redirectUri,
|
|
34
|
-
responseTypes: ['none'],
|
|
35
|
-
grantTypes: [grantType],
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
getAccessToken(data) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
if (!this.client)
|
|
41
|
-
throw new Error(`[${grantType}] Client not initialized.`);
|
|
42
|
-
if (this.getToken())
|
|
43
|
-
return this.getToken();
|
|
44
|
-
const params = Object.assign({ grant_type: grantType }, data);
|
|
45
|
-
return this.client
|
|
46
|
-
.grant(params)
|
|
47
|
-
.then((tokenSet) => this.setToken(tokenSet))
|
|
48
|
-
.catch(this.errorHandler);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
getRefreshToken() {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
throw new Error(`[${grantType}] This method is not allowed to this grant type.`);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.oidc = new OidcClient();
|
|
58
|
-
//# sourceMappingURL=client_credentials.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client_credentials.js","sourceRoot":"","sources":["../../src/grant-type/client_credentials.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,yDAAqC;AACrC,qDAA6B;AAK7B,MAAM,SAAS,GAAG,oBAAoB,CAAC;AAEvC,MAAM,UAAW,SAAQ,iBAAW;IAKlC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAEjD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,eAAK,EAAE,CAAC;QAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,OAAO,CAAC,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,GACH;QACR,OAAO,KAAK,CAAC,OAAO,CAAC;YACnB,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,YAAY;YACZ,WAAW;YACX,aAAa,EAAE,CAAC,MAAM,CAAC;YACvB,UAAU,EAAE,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;IACL,CAAC;IAEK,cAAc,CAClB,IAA6B;;YAE7B,IAAI,CAAC,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,IAAI,SAAS,2BAA2B,CAAC,CAAC;YAC5E,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAAE,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;YAE5C,MAAM,MAAM,mBACV,UAAU,EAAE,SAAS,IAClB,IAAI,CACR,CAAC;YAEF,OAAO,IAAI,CAAC,MAAM;iBACf,KAAK,CAAC,MAAM,CAAC;iBACb,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAA+B,CAAC,CAAC;iBACvE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9B,CAAC;KAAA;IAEK,eAAe;;YACnB,MAAM,IAAI,KAAK,CACb,IAAI,SAAS,kDAAkD,CAChE,CAAC;QACJ,CAAC;KAAA;CACF;AAEY,QAAA,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.oidc = void 0;
|
|
16
|
-
const connect_1 = __importDefault(require("../connect"));
|
|
17
|
-
const parse_token_1 = __importDefault(require("../utils/parse-token"));
|
|
18
|
-
const grantType = 'password';
|
|
19
|
-
class OidcClient extends connect_1.default {
|
|
20
|
-
constructor() {
|
|
21
|
-
super();
|
|
22
|
-
this.errorHandler = this.ErrorHandler(grantType);
|
|
23
|
-
}
|
|
24
|
-
connect({ baseUrl, oidcPath, clientId, clientSecret, redirectUri, }) {
|
|
25
|
-
return super.connect({
|
|
26
|
-
baseUrl,
|
|
27
|
-
oidcPath,
|
|
28
|
-
clientId,
|
|
29
|
-
clientSecret,
|
|
30
|
-
redirectUri,
|
|
31
|
-
responseTypes: ['none'],
|
|
32
|
-
grantTypes: [grantType, 'refresh_token'],
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
getAccessToken(data) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
if (!this.client)
|
|
38
|
-
throw new Error(`[${grantType}] Client not initialized.`);
|
|
39
|
-
const params = Object.assign({ grant_type: grantType }, data);
|
|
40
|
-
return this.client
|
|
41
|
-
.grant(params)
|
|
42
|
-
.then((tokenSet) => (0, parse_token_1.default)(tokenSet))
|
|
43
|
-
.catch(this.errorHandler);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
getRefreshToken(tokenSet) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
if (!this.client)
|
|
49
|
-
throw new Error(`[${grantType}] Client not initialized.`);
|
|
50
|
-
return this.client
|
|
51
|
-
.refresh(tokenSet.refreshToken)
|
|
52
|
-
.then((tokenSet) => (0, parse_token_1.default)(tokenSet))
|
|
53
|
-
.catch(this.errorHandler);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.oidc = new OidcClient();
|
|
58
|
-
//# sourceMappingURL=password.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"password.js","sourceRoot":"","sources":["../../src/grant-type/password.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,yDAAqC;AACrC,uEAA8C;AAE9C,MAAM,SAAS,GAAG,UAAU,CAAC;AAE7B,MAAM,UAAW,SAAQ,iBAAW;IAGlC;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,CAAC,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,GACH;QACR,OAAO,KAAK,CAAC,OAAO,CAAC;YACnB,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,YAAY;YACZ,WAAW;YACX,aAAa,EAAE,CAAC,MAAM,CAAC;YACvB,UAAU,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC;SACzC,CAAC,CAAC;IACL,CAAC;IAEK,cAAc,CAClB,IAA6B;;YAE7B,IAAI,CAAC,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,IAAI,SAAS,2BAA2B,CAAC,CAAC;YAE5E,MAAM,MAAM,mBACV,UAAU,EAAE,SAAS,IAClB,IAAI,CACR,CAAC;YAEF,OAAO,IAAI,CAAC,MAAM;iBACf,KAAK,CAAC,MAAM,CAAC;iBACb,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAA,qBAAU,EAAC,QAA+B,CAAC,CAAC;iBAC/D,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9B,CAAC;KAAA;IAEK,eAAe,CAAC,QAAkB;;YACtC,IAAI,CAAC,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,IAAI,SAAS,2BAA2B,CAAC,CAAC;YAE5E,OAAO,IAAI,CAAC,MAAM;iBACf,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;iBAC9B,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAA,qBAAU,EAAC,QAA+B,CAAC,CAAC;iBAC/D,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9B,CAAC;KAAA;CACF;AAEY,QAAA,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC"}
|