@edirect/oidc-client 3.2.3 → 11.0.25
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/src/grant-type/client_credentials.d.ts +16 -0
- package/dist/src/grant-type/client_credentials.d.ts.map +1 -0
- package/dist/src/grant-type/client_credentials.js +55 -0
- package/dist/src/grant-type/password.d.ts +16 -0
- package/dist/src/grant-type/password.d.ts.map +1 -0
- package/dist/src/grant-type/password.js +92 -0
- package/dist/src/grant-type/sso.d.ts +16 -0
- package/dist/src/grant-type/sso.d.ts.map +1 -0
- package/dist/src/grant-type/sso.js +92 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +20 -0
- package/dist/src/token.d.ts +7 -0
- package/dist/src/token.d.ts.map +1 -0
- package/dist/src/token.js +22 -0
- package/dist/src/types/connect.type.d.ts +12 -0
- package/dist/src/types/connect.type.d.ts.map +1 -0
- package/dist/src/types/connect.type.js +2 -0
- 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/src/types/error-handler.type.js +2 -0
- package/dist/src/types/token-set.type.d.ts +22 -0
- package/dist/src/types/token-set.type.d.ts.map +1 -0
- package/dist/src/types/token-set.type.js +2 -0
- package/dist/src/utils/error-handler.d.ts +6 -0
- package/dist/src/utils/error-handler.d.ts.map +1 -0
- package/dist/src/utils/error-handler.js +12 -0
- package/dist/src/utils/parse-token.d.ts +4 -0
- package/dist/src/utils/parse-token.d.ts.map +1 -0
- package/dist/src/utils/parse-token.js +25 -0
- 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/README.md
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
# @edirect/oidc-client
|
|
2
|
-
|
|
3
|
-
The EDirectInsure OpenId Connect Client.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```shell
|
|
8
|
-
$ npm i --save @edirect/oidc-client
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
(async () => {
|
|
15
|
-
const OidcClient = require('@edirect/oidc-client');
|
|
16
|
-
const oidcClient = await OidcClient({
|
|
17
|
-
grantType: 'GRANT_TYPE',
|
|
18
|
-
baseUrl: 'OIDC_PROVIDER_URL',
|
|
19
|
-
oidcPath: 'OIDC_PROVIDER_PATH',
|
|
20
|
-
clientId: 'YOUR_CLIENT_ID',
|
|
21
|
-
clientSecret: 'YOUR_CLIENT_SECRET',
|
|
22
|
-
redirectUri: 'YOUR_CALLBACK_URL'
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const loginData = {
|
|
26
|
-
username: 'USERNAME',
|
|
27
|
-
password: 'PASSWORD',
|
|
28
|
-
}; // only necessary to password grant type
|
|
29
|
-
|
|
30
|
-
const accessTokenSet = await oidcClient
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
console.log('\n', { refreshTokenSet }, '\n');
|
|
38
|
-
})()
|
|
39
|
-
```
|
|
1
|
+
# @edirect/oidc-client
|
|
2
|
+
|
|
3
|
+
The EDirectInsure OpenId Connect Client.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
$ npm i --save @edirect/oidc-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
(async () => {
|
|
15
|
+
const OidcClient = require('@edirect/oidc-client');
|
|
16
|
+
const oidcClient = await OidcClient({
|
|
17
|
+
grantType: 'GRANT_TYPE',
|
|
18
|
+
baseUrl: 'OIDC_PROVIDER_URL',
|
|
19
|
+
oidcPath: 'OIDC_PROVIDER_PATH',
|
|
20
|
+
clientId: 'YOUR_CLIENT_ID',
|
|
21
|
+
clientSecret: 'YOUR_CLIENT_SECRET',
|
|
22
|
+
redirectUri: 'YOUR_CALLBACK_URL',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const loginData = {
|
|
26
|
+
username: 'USERNAME',
|
|
27
|
+
password: 'PASSWORD',
|
|
28
|
+
}; // only necessary to password grant type
|
|
29
|
+
|
|
30
|
+
const accessTokenSet = await oidcClient.getAccessToken(
|
|
31
|
+
loginData || undefined
|
|
32
|
+
);
|
|
33
|
+
console.log('\n', { accessTokenSet }, '\n');
|
|
34
|
+
|
|
35
|
+
// not applicable to client_credentials grant type
|
|
36
|
+
const refreshTokenSet = await oidcClient.getRefreshToken(accessTokenSet);
|
|
37
|
+
console.log('\n', { refreshTokenSet }, '\n');
|
|
38
|
+
})();
|
|
39
|
+
```
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @edirect/oidc-client
|
|
2
|
+
|
|
3
|
+
The EDirectInsure OpenId Connect Client.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
$ npm i --save @edirect/oidc-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
(async () => {
|
|
15
|
+
const OidcClient = require('@edirect/oidc-client');
|
|
16
|
+
const oidcClient = await OidcClient({
|
|
17
|
+
grantType: 'GRANT_TYPE',
|
|
18
|
+
baseUrl: 'OIDC_PROVIDER_URL',
|
|
19
|
+
oidcPath: 'OIDC_PROVIDER_PATH',
|
|
20
|
+
clientId: 'YOUR_CLIENT_ID',
|
|
21
|
+
clientSecret: 'YOUR_CLIENT_SECRET',
|
|
22
|
+
redirectUri: 'YOUR_CALLBACK_URL',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const loginData = {
|
|
26
|
+
username: 'USERNAME',
|
|
27
|
+
password: 'PASSWORD',
|
|
28
|
+
}; // only necessary to password grant type
|
|
29
|
+
|
|
30
|
+
const accessTokenSet = await oidcClient.getAccessToken(
|
|
31
|
+
loginData || undefined
|
|
32
|
+
);
|
|
33
|
+
console.log('\n', { accessTokenSet }, '\n');
|
|
34
|
+
|
|
35
|
+
// not applicable to client_credentials grant type
|
|
36
|
+
const refreshTokenSet = await oidcClient.getRefreshToken(accessTokenSet);
|
|
37
|
+
console.log('\n', { refreshTokenSet }, '\n');
|
|
38
|
+
})();
|
|
39
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@edirect/oidc-client",
|
|
3
|
+
"version": "11.0.24",
|
|
4
|
+
"main": "./dist/src/index.js",
|
|
5
|
+
"types": "./dist/src/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": {
|
|
9
|
+
"development": "./src/index.ts",
|
|
10
|
+
"default": "./dist/src/index.js",
|
|
11
|
+
"types": "./dist/src/index.d.ts",
|
|
12
|
+
"require": "./dist/src/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"openid-client": "^6.7.1",
|
|
20
|
+
"tslib": "^2.8.1"
|
|
21
|
+
},
|
|
22
|
+
"type": "commonjs"
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ErrorHandlerType } from './types/error-handler.type';
|
|
2
|
+
import { Connect } from './types/connect.type';
|
|
3
|
+
export declare class OidcConnect {
|
|
4
|
+
configuration: any;
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
redirectUri?: string;
|
|
7
|
+
ErrorHandler: ErrorHandlerType;
|
|
8
|
+
constructor();
|
|
9
|
+
connect(params: Connect): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/connect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,qBAAa,WAAW;IACtB,aAAa,EAAE,GAAG,CAAC;IACnB,OAAO,EAAG,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,gBAAgB,CAAC;;IAMzB,OAAO,CAAC,MAAM,EAAE,OAAO;CAqB9B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OidcConnect = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const client = tslib_1.__importStar(require("openid-client"));
|
|
6
|
+
const error_handler_1 = tslib_1.__importDefault(require("./utils/error-handler"));
|
|
7
|
+
class OidcConnect {
|
|
8
|
+
configuration;
|
|
9
|
+
baseUrl;
|
|
10
|
+
redirectUri;
|
|
11
|
+
ErrorHandler;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.ErrorHandler = error_handler_1.default;
|
|
14
|
+
}
|
|
15
|
+
async connect(params) {
|
|
16
|
+
this.baseUrl = params.baseUrl;
|
|
17
|
+
this.redirectUri = params.redirectUri;
|
|
18
|
+
const issuer = new URL(`${params.baseUrl}/${params.oidcPath}`);
|
|
19
|
+
this.configuration = await client.discovery(issuer, params.clientId, params.clientSecret);
|
|
20
|
+
// Set additional metadata if needed
|
|
21
|
+
if (this.configuration) {
|
|
22
|
+
this.configuration.token_endpoint_auth_method = 'client_secret_post';
|
|
23
|
+
if (params.responseTypes)
|
|
24
|
+
this.configuration.response_types = params.responseTypes;
|
|
25
|
+
if (params.grantTypes)
|
|
26
|
+
this.configuration.grant_types = params.grantTypes;
|
|
27
|
+
if (params.redirectUri)
|
|
28
|
+
this.configuration.redirect_uris = [params.redirectUri];
|
|
29
|
+
}
|
|
30
|
+
return this.configuration;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.OidcConnect = OidcConnect;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OidcConnect } from '../connect';
|
|
2
|
+
import { Connect } from '../types/connect.type';
|
|
3
|
+
import { GrantTypeErrorHandlerType } from '../types/error-handler.type';
|
|
4
|
+
import { TokenSet } from '../types/token-set.type';
|
|
5
|
+
export declare class OidcClient extends OidcConnect {
|
|
6
|
+
errorHandler: GrantTypeErrorHandlerType;
|
|
7
|
+
token: TokenSet | null;
|
|
8
|
+
getToken: (revert?: boolean) => TokenSet | null;
|
|
9
|
+
setToken: (token: TokenSet, revert?: boolean) => TokenSet;
|
|
10
|
+
constructor();
|
|
11
|
+
connect(params: Connect): Promise<void>;
|
|
12
|
+
getAccessToken(data: Record<string, unknown>): Promise<TokenSet | null>;
|
|
13
|
+
getRefreshToken(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare const oidc: OidcClient;
|
|
16
|
+
//# sourceMappingURL=client_credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client_credentials.d.ts","sourceRoot":"","sources":["../../../src/grant-type/client_credentials.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAKnD,qBAAa,UAAW,SAAQ,WAAW;IACzC,YAAY,EAAE,yBAAyB,CAAC;IACxC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,CAAC;IAChD,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC;;IAW3C,OAAO,CAAC,MAAM,EAAE,OAAO;IAQhC,cAAc,CAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAuBrB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAKvC;AAED,eAAO,MAAM,IAAI,YAAmB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.oidc = exports.OidcClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const client = tslib_1.__importStar(require("openid-client"));
|
|
6
|
+
const connect_1 = require("../connect");
|
|
7
|
+
const token_1 = require("../token");
|
|
8
|
+
const parse_token_1 = tslib_1.__importDefault(require("../utils/parse-token"));
|
|
9
|
+
const grantType = 'client_credentials';
|
|
10
|
+
class OidcClient extends connect_1.OidcConnect {
|
|
11
|
+
errorHandler;
|
|
12
|
+
token;
|
|
13
|
+
getToken;
|
|
14
|
+
setToken;
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.errorHandler = this.ErrorHandler(grantType);
|
|
18
|
+
this.token = null;
|
|
19
|
+
const tokenHelper = new token_1.Token();
|
|
20
|
+
this.getToken = tokenHelper.getToken.bind(tokenHelper);
|
|
21
|
+
this.setToken = tokenHelper.setToken.bind(tokenHelper);
|
|
22
|
+
}
|
|
23
|
+
async connect(params) {
|
|
24
|
+
await super.connect({
|
|
25
|
+
...params,
|
|
26
|
+
responseTypes: ['none'],
|
|
27
|
+
grantTypes: [grantType],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async getAccessToken(data) {
|
|
31
|
+
if (!this.configuration)
|
|
32
|
+
throw new Error(`[${grantType}] Not initialized.`);
|
|
33
|
+
if (this.token)
|
|
34
|
+
return this.token;
|
|
35
|
+
const params = {
|
|
36
|
+
grant_type: grantType,
|
|
37
|
+
...data,
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
const tokenSetRaw = await client.clientCredentialsGrant(this.configuration, params);
|
|
41
|
+
const tokenSet = (0, parse_token_1.default)(tokenSetRaw);
|
|
42
|
+
this.token = this.setToken(tokenSet);
|
|
43
|
+
return this.token;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
this.errorHandler(error);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async getRefreshToken() {
|
|
51
|
+
throw new Error(`[${grantType}] This method is not allowed to this grant type.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.OidcClient = OidcClient;
|
|
55
|
+
exports.oidc = new OidcClient();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OidcConnect } from '../connect';
|
|
2
|
+
import { Connect } from '../types/connect.type';
|
|
3
|
+
import { GrantTypeErrorHandlerType } from '../types/error-handler.type';
|
|
4
|
+
import { TokenSet } from '../types/token-set.type';
|
|
5
|
+
export declare class OidcClient extends OidcConnect {
|
|
6
|
+
errorHandler: GrantTypeErrorHandlerType;
|
|
7
|
+
token: TokenSet | null;
|
|
8
|
+
getToken: (revert?: boolean) => TokenSet | null;
|
|
9
|
+
setToken: (token: TokenSet, revert?: boolean) => TokenSet;
|
|
10
|
+
constructor();
|
|
11
|
+
connect(params: Connect): Promise<void>;
|
|
12
|
+
getAccessToken(data: Record<string, unknown>): Promise<TokenSet | null>;
|
|
13
|
+
getRefreshToken(tokenSet: TokenSet): Promise<TokenSet | null>;
|
|
14
|
+
}
|
|
15
|
+
export declare const oidc: OidcClient;
|
|
16
|
+
//# sourceMappingURL=password.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../../src/grant-type/password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAKnD,qBAAa,UAAW,SAAQ,WAAW;IACzC,YAAY,EAAE,yBAAyB,CAAC;IACxC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,CAAC;IAChD,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC;;IAW3C,OAAO,CAAC,MAAM,EAAE,OAAO;IAQhC,cAAc,CAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAkCrB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CA2BpE;AAED,eAAO,MAAM,IAAI,YAAmB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.oidc = exports.OidcClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const connect_1 = require("../connect");
|
|
6
|
+
const token_1 = require("../token");
|
|
7
|
+
const parse_token_1 = tslib_1.__importDefault(require("../utils/parse-token"));
|
|
8
|
+
const grantType = 'password';
|
|
9
|
+
class OidcClient extends connect_1.OidcConnect {
|
|
10
|
+
errorHandler;
|
|
11
|
+
token;
|
|
12
|
+
getToken;
|
|
13
|
+
setToken;
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.errorHandler = this.ErrorHandler(grantType);
|
|
17
|
+
this.token = null;
|
|
18
|
+
const tokenHelper = new token_1.Token();
|
|
19
|
+
this.getToken = tokenHelper.getToken.bind(tokenHelper);
|
|
20
|
+
this.setToken = tokenHelper.setToken.bind(tokenHelper);
|
|
21
|
+
}
|
|
22
|
+
async connect(params) {
|
|
23
|
+
await super.connect({
|
|
24
|
+
...params,
|
|
25
|
+
responseTypes: ['none'],
|
|
26
|
+
grantTypes: [grantType, 'refresh_token'],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async getAccessToken(data) {
|
|
30
|
+
if (!this.configuration)
|
|
31
|
+
throw new Error(`[${grantType}] Not initialized.`);
|
|
32
|
+
if (this.token)
|
|
33
|
+
return this.token;
|
|
34
|
+
const tokenEndpoint = this.configuration.server.token_endpoint;
|
|
35
|
+
const params = new URLSearchParams({
|
|
36
|
+
grant_type: grantType,
|
|
37
|
+
client_id: this.configuration.client_id,
|
|
38
|
+
client_secret: this.configuration.client_secret,
|
|
39
|
+
...Object.fromEntries(Object.entries(data).map(([k, v]) => [k, String(v)])),
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetch(tokenEndpoint, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
46
|
+
},
|
|
47
|
+
body: params.toString(),
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok)
|
|
50
|
+
throw new Error(`Token endpoint error: ${response.status}`);
|
|
51
|
+
const tokenSetRaw = (await response.json());
|
|
52
|
+
const tokenSet = (0, parse_token_1.default)(tokenSetRaw);
|
|
53
|
+
this.token = this.setToken(tokenSet);
|
|
54
|
+
return this.token;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
this.errorHandler(error);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async getRefreshToken(tokenSet) {
|
|
62
|
+
if (!this.configuration)
|
|
63
|
+
throw new Error(`[${grantType}] Not initialized.`);
|
|
64
|
+
const tokenEndpoint = this.configuration.server.token_endpoint;
|
|
65
|
+
const params = new URLSearchParams({
|
|
66
|
+
grant_type: 'refresh_token',
|
|
67
|
+
client_id: this.configuration.client_id,
|
|
68
|
+
client_secret: this.configuration.client_secret,
|
|
69
|
+
refresh_token: tokenSet.refreshToken,
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const response = await fetch(tokenEndpoint, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
76
|
+
},
|
|
77
|
+
body: params.toString(),
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok)
|
|
80
|
+
throw new Error(`Token endpoint error: ${response.status}`);
|
|
81
|
+
const refreshTokenSetRaw = (await response.json());
|
|
82
|
+
const refreshTokenSet = (0, parse_token_1.default)(refreshTokenSetRaw);
|
|
83
|
+
return this.setToken(refreshTokenSet);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
this.errorHandler(error);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.OidcClient = OidcClient;
|
|
92
|
+
exports.oidc = new OidcClient();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OidcConnect } from '../connect';
|
|
2
|
+
import { Connect } from '../types/connect.type';
|
|
3
|
+
import { TokenSet } from '../types/token-set.type';
|
|
4
|
+
import { GrantTypeErrorHandlerType } from '../types/error-handler.type';
|
|
5
|
+
export declare class OidcClient extends OidcConnect {
|
|
6
|
+
errorHandler: GrantTypeErrorHandlerType;
|
|
7
|
+
token: TokenSet | null;
|
|
8
|
+
getToken: (revert?: boolean) => TokenSet | null;
|
|
9
|
+
setToken: (token: TokenSet, revert?: boolean) => TokenSet;
|
|
10
|
+
constructor();
|
|
11
|
+
connect(params: Connect): Promise<void>;
|
|
12
|
+
getAccessToken(data: Record<string, unknown>): Promise<TokenSet | null>;
|
|
13
|
+
getRefreshToken(tokenSet: TokenSet): Promise<TokenSet | null>;
|
|
14
|
+
}
|
|
15
|
+
export declare const oidc: OidcClient;
|
|
16
|
+
//# sourceMappingURL=sso.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sso.d.ts","sourceRoot":"","sources":["../../../src/grant-type/sso.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAKxE,qBAAa,UAAW,SAAQ,WAAW;IACzC,YAAY,EAAE,yBAAyB,CAAC;IACxC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,CAAC;IAChD,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC;;IAW3C,OAAO,CAAC,MAAM,EAAE,OAAO;IAQhC,cAAc,CAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAkCrB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CA2BpE;AAED,eAAO,MAAM,IAAI,YAAmB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.oidc = exports.OidcClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const connect_1 = require("../connect");
|
|
6
|
+
const token_1 = require("../token");
|
|
7
|
+
const parse_token_1 = tslib_1.__importDefault(require("../utils/parse-token"));
|
|
8
|
+
const grantType = 'sso';
|
|
9
|
+
class OidcClient extends connect_1.OidcConnect {
|
|
10
|
+
errorHandler;
|
|
11
|
+
token;
|
|
12
|
+
getToken;
|
|
13
|
+
setToken;
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.errorHandler = this.ErrorHandler(grantType);
|
|
17
|
+
this.token = null;
|
|
18
|
+
const tokenHelper = new token_1.Token();
|
|
19
|
+
this.getToken = tokenHelper.getToken.bind(tokenHelper);
|
|
20
|
+
this.setToken = tokenHelper.setToken.bind(tokenHelper);
|
|
21
|
+
}
|
|
22
|
+
async connect(params) {
|
|
23
|
+
await super.connect({
|
|
24
|
+
...params,
|
|
25
|
+
responseTypes: ['none'],
|
|
26
|
+
grantTypes: [grantType, 'refresh_token'],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async getAccessToken(data) {
|
|
30
|
+
if (!this.configuration)
|
|
31
|
+
throw new Error(`[${grantType}] Not initialized.`);
|
|
32
|
+
if (this.token)
|
|
33
|
+
return this.token;
|
|
34
|
+
const tokenEndpoint = this.configuration.server.token_endpoint;
|
|
35
|
+
const params = new URLSearchParams({
|
|
36
|
+
grant_type: grantType,
|
|
37
|
+
client_id: this.configuration.client_id,
|
|
38
|
+
client_secret: this.configuration.client_secret,
|
|
39
|
+
...Object.fromEntries(Object.entries(data).map(([k, v]) => [k, String(v)])),
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetch(tokenEndpoint, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
46
|
+
},
|
|
47
|
+
body: params.toString(),
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok)
|
|
50
|
+
throw new Error(`Token endpoint error: ${response.status}`);
|
|
51
|
+
const tokenSetRaw = (await response.json());
|
|
52
|
+
const tokenSet = (0, parse_token_1.default)(tokenSetRaw);
|
|
53
|
+
this.token = this.setToken(tokenSet);
|
|
54
|
+
return this.token;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
this.errorHandler(error);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async getRefreshToken(tokenSet) {
|
|
62
|
+
if (!this.configuration)
|
|
63
|
+
throw new Error(`[${grantType}] Not initialized.`);
|
|
64
|
+
const tokenEndpoint = this.configuration.server.token_endpoint;
|
|
65
|
+
const params = new URLSearchParams({
|
|
66
|
+
grant_type: 'refresh_token',
|
|
67
|
+
client_id: this.configuration.client_id,
|
|
68
|
+
client_secret: this.configuration.client_secret,
|
|
69
|
+
refresh_token: tokenSet.refreshToken,
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const response = await fetch(tokenEndpoint, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
76
|
+
},
|
|
77
|
+
body: params.toString(),
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok)
|
|
80
|
+
throw new Error(`Token endpoint error: ${response.status}`);
|
|
81
|
+
const refreshTokenSetRaw = (await response.json());
|
|
82
|
+
const refreshTokenSet = (0, parse_token_1.default)(refreshTokenSetRaw);
|
|
83
|
+
return this.setToken(refreshTokenSet);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
this.errorHandler(error);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.OidcClient = OidcClient;
|
|
92
|
+
exports.oidc = new OidcClient();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;yBAWzB,QAAQ,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC;AAAxD,wBAWE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_credentials_1 = require("./grant-type/client_credentials");
|
|
4
|
+
const password_1 = require("./grant-type/password");
|
|
5
|
+
const sso_1 = require("./grant-type/sso");
|
|
6
|
+
const clients = {
|
|
7
|
+
client_credentials: client_credentials_1.oidc,
|
|
8
|
+
password: password_1.oidc,
|
|
9
|
+
sso: sso_1.oidc,
|
|
10
|
+
};
|
|
11
|
+
exports.default = async (params) => {
|
|
12
|
+
const oidc = clients[params.grantType];
|
|
13
|
+
await oidc.connect({
|
|
14
|
+
baseUrl: params.baseUrl,
|
|
15
|
+
oidcPath: params.oidcPath,
|
|
16
|
+
clientId: params.clientId,
|
|
17
|
+
clientSecret: params.clientSecret,
|
|
18
|
+
});
|
|
19
|
+
return oidc;
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD,qBAAa,KAAK;IAChB,KAAK,EAAG,QAAQ,CAAC;IAEjB,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAQ,GAAG,QAAQ;IAKnD,QAAQ,CAAC,MAAM,UAAQ,GAAG,QAAQ,GAAG,IAAI;CAO1C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Token = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const parse_token_1 = tslib_1.__importDefault(require("./utils/parse-token"));
|
|
6
|
+
class Token {
|
|
7
|
+
token;
|
|
8
|
+
setToken(token, revert = false) {
|
|
9
|
+
this.token = (0, parse_token_1.default)(token, revert);
|
|
10
|
+
return this.token;
|
|
11
|
+
}
|
|
12
|
+
getToken(revert = false) {
|
|
13
|
+
if (!this.token)
|
|
14
|
+
return null;
|
|
15
|
+
const expiresAt = this.token.expiresAt || this.token.expires_at;
|
|
16
|
+
const now = Math.floor(new Date().getTime() / 1000);
|
|
17
|
+
if (expiresAt - 60 <= now)
|
|
18
|
+
return null;
|
|
19
|
+
return (revert && (0, parse_token_1.default)(this.token, revert)) || this.token;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Token = Token;
|
|
@@ -0,0 +1,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"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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"}
|
|
@@ -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"}
|
|
@@ -0,0 +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
|
+
};
|
|
@@ -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"}
|
|
@@ -0,0 +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(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.25",
|
|
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