@edirect/oidc-client 3.0.0 → 3.1.2
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/dist/connect.js +34 -21
- package/dist/connect.js.map +1 -1
- package/dist/index.js +9 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/connect.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -7,32 +16,36 @@ const openid_client_1 = require("openid-client");
|
|
|
7
16
|
const http_1 = __importDefault(require("http"));
|
|
8
17
|
const https_1 = __importDefault(require("https"));
|
|
9
18
|
const error_handler_1 = __importDefault(require("./utils/error-handler"));
|
|
10
|
-
const httpAgent = new http_1.default.Agent({ keepAlive: true });
|
|
11
|
-
const httpsAgent = new https_1.default.Agent({ keepAlive: true });
|
|
12
19
|
class OidcConnect {
|
|
13
20
|
constructor() {
|
|
14
21
|
this.ErrorHandler = error_handler_1.default;
|
|
15
22
|
}
|
|
16
23
|
connect({ baseUrl, oidcPath, clientId, clientSecret, redirectUri, responseTypes, grantTypes, timeout, }) {
|
|
17
|
-
this
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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}`);
|
|
36
49
|
this.client = new oidcIssuer.Client(oidcConfiguration);
|
|
37
50
|
return this.client;
|
|
38
51
|
});
|
package/dist/connect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA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,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;KAAA;CACF;AAnDD,8BAmDC"}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -28,8 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
28
9
|
});
|
|
29
10
|
};
|
|
30
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const client_credentials_1 = require("./grant-type/client_credentials");
|
|
13
|
+
const password_1 = require("./grant-type/password");
|
|
14
|
+
const sso_1 = require("./grant-type/sso");
|
|
15
|
+
const clients = {
|
|
16
|
+
client_credentials: client_credentials_1.oidc,
|
|
17
|
+
password: password_1.oidc,
|
|
18
|
+
sso: sso_1.oidc,
|
|
19
|
+
};
|
|
31
20
|
exports.default = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
const
|
|
21
|
+
const oidc = clients[params.grantType];
|
|
33
22
|
yield oidc.connect({
|
|
34
23
|
baseUrl: params.baseUrl,
|
|
35
24
|
oidcPath: params.oidcPath,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,wEAA6E;AAC7E,oDAAyD;AACzD,0CAA+C;AAE/C,MAAM,OAAO,GAAgC;IAC3C,kBAAkB,EAAlB,yBAAkB;IAClB,QAAQ,EAAR,eAAQ;IACR,GAAG,EAAH,UAAG;CACJ,CAAC;AAEF,kBAAe,CAAO,MAAe,EAAoB,EAAE;IACzD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,SAAmB,CAAC,CAAC;IAEjD,MAAM,IAAI,CAAC,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,YAAY,EAAE,MAAM,CAAC,YAAY;KAClC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC,CAAA,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edirect/oidc-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "OpenId Connect Client",
|
|
5
5
|
"author": "Bolttech <devs@bolttech.io>",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"eslint": "eslint --fix \"./src/**/*.ts\""
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"openid-client": "^
|
|
21
|
+
"openid-client": "^4.9.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^17.0.12",
|