@signageos/lib 23.23.0 → 23.23.1-master.4632
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/Auth0/ManagementClient/Auth0ManagementClient.d.ts +2 -11
- package/dist/Auth0/ManagementClient/Auth0ManagementClient.js +51 -43
- package/dist/Auth0/ManagementClient/Auth0ManagementClient.js.map +1 -1
- package/dist/Auth0/ManagementClient/auth0ManagementClient.utils.d.ts +0 -2
- package/dist/Auth0/ManagementClient/auth0ManagementClient.utils.js +0 -2
- package/dist/Auth0/ManagementClient/auth0ManagementClient.utils.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { ApiResponse, Connection } from 'auth0';
|
|
2
|
-
import { GetConnections200ResponseOneOf } from 'auth0/dist/cjs/management/__generated/models';
|
|
3
1
|
type CreatePasswordChangeTicketParams = {
|
|
4
2
|
email: string;
|
|
5
3
|
resultUrl: string;
|
|
6
4
|
connectionId: string;
|
|
7
5
|
markEmailAsVerified?: boolean;
|
|
8
6
|
};
|
|
9
|
-
type GetConnectionsParams = {
|
|
10
|
-
perPage?: number;
|
|
11
|
-
page?: number;
|
|
12
|
-
};
|
|
13
|
-
type GetAllConnectionsParams = GetConnectionsParams;
|
|
14
7
|
type IsSamlConnectionParams = {
|
|
15
8
|
email: string;
|
|
16
9
|
};
|
|
@@ -23,8 +16,6 @@ export type Auth0Config = {
|
|
|
23
16
|
export type OptionalAuth0Config = Partial<Auth0Config>;
|
|
24
17
|
export interface IAuth0ManagementClient {
|
|
25
18
|
createPasswordChangeTicket: (params: CreatePasswordChangeTicketParams) => Promise<PasswordUrl>;
|
|
26
|
-
getConnections: (params: GetConnectionsParams) => Promise<ApiResponse<GetConnections200ResponseOneOf>>;
|
|
27
|
-
getAllConnections: (params: GetConnectionsParams) => Promise<Connection[]>;
|
|
28
19
|
isSamlConnection: (params: IsSamlConnectionParams) => Promise<boolean>;
|
|
29
20
|
}
|
|
30
21
|
export declare class Auth0ManagementClient implements IAuth0ManagementClient {
|
|
@@ -35,8 +26,8 @@ export declare class Auth0ManagementClient implements IAuth0ManagementClient {
|
|
|
35
26
|
clientSecret: Auth0Config['clientSecret'];
|
|
36
27
|
});
|
|
37
28
|
createPasswordChangeTicket: ({ email, resultUrl, connectionId, markEmailAsVerified }: CreatePasswordChangeTicketParams) => Promise<string>;
|
|
38
|
-
getConnections: ({ perPage, page }: GetConnectionsParams) => Promise<ApiResponse<GetConnections200ResponseOneOf>>;
|
|
39
|
-
getAllConnections: ({ perPage, page }: GetAllConnectionsParams) => Promise<Connection[]>;
|
|
40
29
|
isSamlConnection: ({ email }: IsSamlConnectionParams) => Promise<boolean>;
|
|
30
|
+
private getConnectionsPage;
|
|
31
|
+
private getAllConnections;
|
|
41
32
|
}
|
|
42
33
|
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -44,11 +55,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
44
55
|
}
|
|
45
56
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
57
|
};
|
|
58
|
+
var _a;
|
|
47
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
60
|
exports.Auth0ManagementClient = void 0;
|
|
49
61
|
var auth0_1 = require("auth0");
|
|
50
62
|
var auth0_types_1 = require("../auth0.types");
|
|
51
63
|
var string_1 = require("../../Lib/String/string");
|
|
64
|
+
var CONNECTIONS_PER_PAGE = 50;
|
|
65
|
+
var strategyToGetConnectionsStrategy = (_a = {},
|
|
66
|
+
_a[auth0_types_1.AuthenticationStrategy.Auth0] = auth0_1.GetConnectionsStrategyEnum.auth0,
|
|
67
|
+
_a[auth0_types_1.AuthenticationStrategy.Samlp] = auth0_1.GetConnectionsStrategyEnum.samlp,
|
|
68
|
+
_a);
|
|
52
69
|
var Auth0ManagementClient = /** @class */ (function () {
|
|
53
70
|
function Auth0ManagementClient(_a) {
|
|
54
71
|
var domain = _a.domain, clientId = _a.clientId, clientSecret = _a.clientSecret;
|
|
@@ -70,62 +87,53 @@ var Auth0ManagementClient = /** @class */ (function () {
|
|
|
70
87
|
}
|
|
71
88
|
});
|
|
72
89
|
}); };
|
|
73
|
-
this.
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
this.isSamlConnection = function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
91
|
+
var emailDomain, connections, connection;
|
|
92
|
+
var email = _b.email;
|
|
93
|
+
return __generator(this, function (_c) {
|
|
94
|
+
switch (_c.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
emailDomain = (0, string_1.getEmailDomain)(email);
|
|
97
|
+
return [4 /*yield*/, this.getAllConnections(auth0_types_1.AuthenticationStrategy.Samlp)];
|
|
98
|
+
case 1:
|
|
99
|
+
connections = _c.sent();
|
|
100
|
+
connection = connections.find(function (conn) { var _a, _b; return ((_b = (_a = conn === null || conn === void 0 ? void 0 : conn.options) === null || _a === void 0 ? void 0 : _a.domain_aliases) !== null && _b !== void 0 ? _b : []).includes(emailDomain); });
|
|
101
|
+
return [2 /*return*/, connection !== undefined];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}); };
|
|
105
|
+
this.getConnectionsPage = function (page, strategy) { return __awaiter(_this, void 0, void 0, function () {
|
|
106
|
+
return __generator(this, function (_a) {
|
|
107
|
+
// enabled_clients is deprecated on GET /api/v2/connections and must not be requested
|
|
108
|
+
return [2 /*return*/, this.managementClient.connections.getAll(__assign(__assign({ include_totals: true, per_page: CONNECTIONS_PER_PAGE, page: page }, (strategy ? { strategy: [strategyToGetConnectionsStrategy[strategy]] } : {})), { fields: 'id,name,strategy,options', include_fields: true }))];
|
|
81
109
|
});
|
|
82
110
|
}); };
|
|
83
|
-
this.getAllConnections = function (
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
switch (_e.label) {
|
|
111
|
+
this.getAllConnections = function (strategy) { return __awaiter(_this, void 0, void 0, function () {
|
|
112
|
+
var currentPage, connectionsResponse, allConnections;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
88
115
|
case 0:
|
|
89
|
-
|
|
90
|
-
return [4 /*yield*/, this.
|
|
91
|
-
perPage: perPage,
|
|
92
|
-
page: page,
|
|
93
|
-
})];
|
|
116
|
+
currentPage = 0;
|
|
117
|
+
return [4 /*yield*/, this.getConnectionsPage(currentPage, strategy)];
|
|
94
118
|
case 1:
|
|
95
|
-
connectionsResponse =
|
|
96
|
-
allConnections = connectionsResponse.data.connections;
|
|
97
|
-
|
|
98
|
-
_e.label = 2;
|
|
119
|
+
connectionsResponse = _a.sent();
|
|
120
|
+
allConnections = __spreadArray([], connectionsResponse.data.connections, true);
|
|
121
|
+
_a.label = 2;
|
|
99
122
|
case 2:
|
|
100
123
|
if (!(allConnections.length < connectionsResponse.data.total)) return [3 /*break*/, 4];
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
page: currentPage,
|
|
104
|
-
})];
|
|
124
|
+
currentPage = currentPage + 1;
|
|
125
|
+
return [4 /*yield*/, this.getConnectionsPage(currentPage, strategy)];
|
|
105
126
|
case 3:
|
|
106
|
-
connectionsResponse =
|
|
107
|
-
|
|
127
|
+
connectionsResponse = _a.sent();
|
|
128
|
+
if (connectionsResponse.data.connections.length === 0) {
|
|
129
|
+
return [3 /*break*/, 4];
|
|
130
|
+
}
|
|
108
131
|
allConnections = __spreadArray(__spreadArray([], allConnections, true), connectionsResponse.data.connections, true);
|
|
109
132
|
return [3 /*break*/, 2];
|
|
110
133
|
case 4: return [2 /*return*/, allConnections];
|
|
111
134
|
}
|
|
112
135
|
});
|
|
113
136
|
}); };
|
|
114
|
-
this.isSamlConnection = function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
115
|
-
var emailDomain, connections, connectionByEmailDomain;
|
|
116
|
-
var email = _b.email;
|
|
117
|
-
return __generator(this, function (_c) {
|
|
118
|
-
switch (_c.label) {
|
|
119
|
-
case 0:
|
|
120
|
-
emailDomain = (0, string_1.getEmailDomain)(email);
|
|
121
|
-
return [4 /*yield*/, this.getAllConnections({})];
|
|
122
|
-
case 1:
|
|
123
|
-
connections = _c.sent();
|
|
124
|
-
connectionByEmailDomain = connections.find(function (connection) { var _a, _b; return ((_b = (_a = connection === null || connection === void 0 ? void 0 : connection.options) === null || _a === void 0 ? void 0 : _a.domain_aliases) !== null && _b !== void 0 ? _b : []).includes(emailDomain); });
|
|
125
|
-
return [2 /*return*/, (connectionByEmailDomain === null || connectionByEmailDomain === void 0 ? void 0 : connectionByEmailDomain.strategy) === auth0_types_1.AuthenticationStrategy.Samlp];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}); };
|
|
129
137
|
this.managementClient = new auth0_1.ManagementClient({
|
|
130
138
|
domain: domain,
|
|
131
139
|
clientId: clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Auth0ManagementClient.js","sourceRoot":"","sources":["../../../src/Auth0/ManagementClient/Auth0ManagementClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Auth0ManagementClient.js","sourceRoot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CAAC,gBAAgB,GAAG,IAAI,wBAAgB,CAAC;YAC5C,MAAM,QAAA;YACN,QAAQ,UAAA;YACR,YAAY,cAAA;SACZ,CAAC,CAAC;IACJ,CAAC;IAiDF,4BAAC;AAAD,CAAC,AAlED,IAkEC;AAlEY,sDAAqB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as sinon from 'sinon';
|
|
2
2
|
export interface MockedAuth0ManagementClient {
|
|
3
3
|
createPasswordChangeTicket: sinon.SinonStub;
|
|
4
|
-
getConnections: sinon.SinonStub;
|
|
5
|
-
getAllConnections: sinon.SinonStub;
|
|
6
4
|
isSamlConnection: sinon.SinonStub;
|
|
7
5
|
}
|
|
8
6
|
export declare function createMockedAuth0ManagementClient(): MockedAuth0ManagementClient;
|
|
@@ -29,8 +29,6 @@ var sinon = __importStar(require("sinon"));
|
|
|
29
29
|
function createMockedAuth0ManagementClient() {
|
|
30
30
|
return {
|
|
31
31
|
createPasswordChangeTicket: sinon.stub(),
|
|
32
|
-
getConnections: sinon.stub(),
|
|
33
|
-
getAllConnections: sinon.stub(),
|
|
34
32
|
isSamlConnection: sinon.stub(),
|
|
35
33
|
};
|
|
36
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0ManagementClient.utils.js","sourceRoot":"","sources":["../../../src/Auth0/ManagementClient/auth0ManagementClient.utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"auth0ManagementClient.utils.js","sourceRoot":"","sources":["../../../src/Auth0/ManagementClient/auth0ManagementClient.utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAQA,8EAKC;AAbD,2CAA+B;AAO/B,gCAAgC;AAChC,SAAgB,iCAAiC;IAChD,OAAO;QACN,0BAA0B,EAAE,KAAK,CAAC,IAAI,EAAE;QACxC,gBAAgB,EAAE,KAAK,CAAC,IAAI,EAAE;KAC9B,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signageos/lib",
|
|
3
|
-
"version": "23.23.
|
|
3
|
+
"version": "23.23.1-master.4632",
|
|
4
4
|
"main": "./dist",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@signageos/amqp": "^0.14.0",
|
|
42
42
|
"@signageos/core": "^1.5.0",
|
|
43
|
-
"@signageos/lib-ci": "23.23.
|
|
43
|
+
"@signageos/lib-ci": "23.23.1-master.4632",
|
|
44
44
|
"@signageos/metrics": "^1.0.0",
|
|
45
45
|
"@signageos/redis": "^3.1.0",
|
|
46
46
|
"@signageos/service": "^1.2.0",
|
|
47
47
|
"async-lock": "1.4.0",
|
|
48
|
-
"auth0": "4.
|
|
48
|
+
"auth0": "4.37.1",
|
|
49
49
|
"co": "4.6.0",
|
|
50
50
|
"debug": "^4.3.4",
|
|
51
51
|
"express": "^4.21.2",
|