@dvelop-sdk/identityprovider 2.1.6 → 3.0.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/README.md +1 -1
- package/lib/authentication/get-auth-session/get-auth-session.d.ts +21 -14
- package/lib/authentication/get-auth-session/get-auth-session.d.ts.map +1 -1
- package/lib/authentication/get-auth-session/get-auth-session.js +52 -48
- package/lib/authentication/get-auth-session/get-auth-session.js.map +1 -1
- package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.d.ts +21 -10
- package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.d.ts.map +1 -1
- package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.js +53 -50
- package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.js.map +1 -1
- package/lib/authentication/get-login-redirection-uri/get-login-redirection-uri.d.ts +4 -6
- package/lib/authentication/get-login-redirection-uri/get-login-redirection-uri.d.ts.map +1 -1
- package/lib/authentication/get-login-redirection-uri/get-login-redirection-uri.js +4 -6
- package/lib/authentication/get-login-redirection-uri/get-login-redirection-uri.js.map +1 -1
- package/lib/authentication/request-app-session/request-app-session.d.ts +40 -10
- package/lib/authentication/request-app-session/request-app-session.d.ts.map +1 -1
- package/lib/authentication/request-app-session/request-app-session.js +46 -40
- package/lib/authentication/request-app-session/request-app-session.js.map +1 -1
- package/lib/authentication/validate-app-session-signature/validate-app-session-signature.d.ts +15 -15
- package/lib/authentication/validate-app-session-signature/validate-app-session-signature.d.ts.map +1 -1
- package/lib/authentication/validate-app-session-signature/validate-app-session-signature.js +41 -20
- package/lib/authentication/validate-app-session-signature/validate-app-session-signature.js.map +1 -1
- package/lib/authentication/validate-auth-session-id/validate-auth-session-id.d.ts +48 -11
- package/lib/authentication/validate-auth-session-id/validate-auth-session-id.d.ts.map +1 -1
- package/lib/authentication/validate-auth-session-id/validate-auth-session-id.js +47 -48
- package/lib/authentication/validate-auth-session-id/validate-auth-session-id.js.map +1 -1
- package/lib/index.d.ts +32 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +38 -19
- package/lib/index.js.map +1 -1
- package/lib/internal.d.ts +6 -0
- package/lib/internal.d.ts.map +1 -0
- package/lib/internal.js +19 -0
- package/lib/internal.js.map +1 -0
- package/lib/utils/http.d.ts +12 -0
- package/lib/utils/http.d.ts.map +1 -0
- package/lib/utils/http.js +130 -0
- package/lib/utils/http.js.map +1 -0
- package/package.json +3 -5
- package/LICENSE +0 -201
- package/lib/authentication/get-auth-session/auth-session.d.ts +0 -15
- package/lib/authentication/get-auth-session/auth-session.d.ts.map +0 -1
- package/lib/authentication/get-auth-session/auth-session.js +0 -3
- package/lib/authentication/get-auth-session/auth-session.js.map +0 -1
- package/lib/authentication/validate-auth-session-id/scim-user.d.ts +0 -32
- package/lib/authentication/validate-auth-session-id/scim-user.d.ts.map +0 -1
- package/lib/authentication/validate-auth-session-id/scim-user.js +0 -3
- package/lib/authentication/validate-auth-session-id/scim-user.js.map +0 -1
- package/lib/errors.d.ts +0 -33
- package/lib/errors.d.ts.map +0 -1
- package/lib/errors.js +0 -82
- package/lib/errors.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
</br>
|
|
17
17
|
|
|
18
|
-
<p>This package contains functionality for the <a href="https://developer.d-velop.de/documentation/idpapi/en
|
|
18
|
+
<p>This package contains functionality for the <a href="https://developer.d-velop.de/documentation/idpapi/en">Identityprovider-App</a> in the d.velop cloud.</p>
|
|
19
19
|
|
|
20
20
|
<a href="https://d-velop.github.io/dvelop-sdk-node/modules/identityprovider.html"><strong>Explore the docs »</strong></a>
|
|
21
21
|
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { DvelopContext } from "../../../../core/lib";
|
|
2
|
+
/**
|
|
3
|
+
* Used for authentication in the d.velop cloud. Refer to the [documentation](https://developer.d-velop.de/documentation/idpapi/en/identityprovider-app-201523580.html#validating-the-login) for further information.
|
|
4
|
+
* @category Authentication
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthSession {
|
|
7
|
+
/** This key will validate your requests (usually sent as Bearer-Token). **The AuthSessionId should be kept secret and never be publicly available** */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Date at which the AuthSessionId will no longer be valid. */
|
|
10
|
+
expire: Date;
|
|
5
11
|
}
|
|
6
12
|
/**
|
|
7
|
-
* Returns an
|
|
13
|
+
* Returns an {@link AuthSession} based on an API-Key. API-Keys can be generated by d.velop cloud tenant administrators.
|
|
8
14
|
* **The AuthSessionId should be kept secret and never be publicly available.**
|
|
9
15
|
*
|
|
10
|
-
* @param {string} systemBaseUri SystemBaseUri for the tenant
|
|
11
|
-
* @param {string} apiKey API-Key provided by the d.velop cloud
|
|
12
|
-
* @throws {@link UnauthorizedError} indicates an invalid authSessionId or no authSessionId was sent.
|
|
13
16
|
*
|
|
14
|
-
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { getAuthSession } from "@dvelop-sdk/identityprovider";
|
|
19
|
+
*
|
|
20
|
+
* const authSession = await getAuthSession({
|
|
21
|
+
* systemBaseUri: "https://monster-ag.d-velop.cloud",
|
|
22
|
+
* authSessionId: "dQw4w9WgXcQ"
|
|
23
|
+
* });
|
|
15
24
|
*
|
|
16
|
-
|
|
17
|
-
* const authSession: AuthSession = await getAuthSession("https://monster-ag.d-velop.cloud", "<API_KEY>");
|
|
18
|
-
* console.log(authSession.id); //a valid authSessionId
|
|
19
|
-
* console.log('still valid:', authSession.expire.getTime() > new Date().getTime()); //still valid: true
|
|
25
|
+
console.log(authSession);
|
|
20
26
|
* ```
|
|
21
27
|
*
|
|
28
|
+
* @category Authentication
|
|
22
29
|
*/
|
|
23
|
-
export declare function getAuthSession(
|
|
30
|
+
export declare function getAuthSession(context: DvelopContext): Promise<AuthSession>;
|
|
24
31
|
//# sourceMappingURL=get-auth-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-auth-session.d.ts","sourceRoot":"","sources":["../../../src/authentication/get-auth-session/get-auth-session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-auth-session.d.ts","sourceRoot":"","sources":["../../../src/authentication/get-auth-session/get-auth-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,uJAAuJ;IACvJ,EAAE,EAAE,MAAM,CAAC;IACX,+DAA+D;IAC/D,MAAM,EAAE,IAAI,CAAC;CACd;AAkCD;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAsB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAEjF"}
|
|
@@ -35,65 +35,69 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.getAuthSession = void 0;
|
|
43
|
-
var
|
|
44
|
-
|
|
39
|
+
exports.getAuthSession = exports._getAuthSessionFactory = exports._getAuthSessionDefaultTransformFunction = void 0;
|
|
40
|
+
var http_1 = require("../../utils/http");
|
|
41
|
+
/**
|
|
42
|
+
* Default transform-function provided to the {@link getAuthSession}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
|
|
43
|
+
* @internal
|
|
44
|
+
* @category Authentication
|
|
45
|
+
*/
|
|
46
|
+
function _getAuthSessionDefaultTransformFunction(response, _) {
|
|
47
|
+
return {
|
|
48
|
+
id: response.data.AuthSessionId,
|
|
49
|
+
expire: new Date(response.data.Expire)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports._getAuthSessionDefaultTransformFunction = _getAuthSessionDefaultTransformFunction;
|
|
53
|
+
/**
|
|
54
|
+
* Factory for the {@link getAuthSession}-function. See internals for more information. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
|
|
55
|
+
* @typeparam T Return type of the {@link getAuthSession}-function. A corresponding transformFuntion has to be supplied.
|
|
56
|
+
* @internal
|
|
57
|
+
* @category Authentication
|
|
58
|
+
*/
|
|
59
|
+
function _getAuthSessionFactory(httpRequestFunction, transformFunction) {
|
|
60
|
+
var _this = this;
|
|
61
|
+
return function (context) { return __awaiter(_this, void 0, void 0, function () {
|
|
62
|
+
var response;
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (_a.label) {
|
|
65
|
+
case 0: return [4 /*yield*/, httpRequestFunction(context, {
|
|
66
|
+
method: "GET",
|
|
67
|
+
url: "/identityprovider",
|
|
68
|
+
follows: ["login"],
|
|
69
|
+
})];
|
|
70
|
+
case 1:
|
|
71
|
+
response = _a.sent();
|
|
72
|
+
return [2 /*return*/, transformFunction(response, context)];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}); };
|
|
76
|
+
}
|
|
77
|
+
exports._getAuthSessionFactory = _getAuthSessionFactory;
|
|
45
78
|
/**
|
|
46
|
-
* Returns an
|
|
79
|
+
* Returns an {@link AuthSession} based on an API-Key. API-Keys can be generated by d.velop cloud tenant administrators.
|
|
47
80
|
* **The AuthSessionId should be kept secret and never be publicly available.**
|
|
48
81
|
*
|
|
49
|
-
* @param {string} systemBaseUri SystemBaseUri for the tenant
|
|
50
|
-
* @param {string} apiKey API-Key provided by the d.velop cloud
|
|
51
|
-
* @throws {@link UnauthorizedError} indicates an invalid authSessionId or no authSessionId was sent.
|
|
52
82
|
*
|
|
53
|
-
*
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { getAuthSession } from "@dvelop-sdk/identityprovider";
|
|
85
|
+
*
|
|
86
|
+
* const authSession = await getAuthSession({
|
|
87
|
+
* systemBaseUri: "https://monster-ag.d-velop.cloud",
|
|
88
|
+
* authSessionId: "dQw4w9WgXcQ"
|
|
89
|
+
* });
|
|
54
90
|
*
|
|
55
|
-
|
|
56
|
-
* const authSession: AuthSession = await getAuthSession("https://monster-ag.d-velop.cloud", "<API_KEY>");
|
|
57
|
-
* console.log(authSession.id); //a valid authSessionId
|
|
58
|
-
* console.log('still valid:', authSession.expire.getTime() > new Date().getTime()); //still valid: true
|
|
91
|
+
console.log(authSession);
|
|
59
92
|
* ```
|
|
60
93
|
*
|
|
94
|
+
* @category Authentication
|
|
61
95
|
*/
|
|
62
|
-
|
|
96
|
+
/* istanbul ignore next */
|
|
97
|
+
function getAuthSession(context) {
|
|
63
98
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var errorContext, response, e_1;
|
|
65
99
|
return __generator(this, function (_a) {
|
|
66
|
-
|
|
67
|
-
case 0:
|
|
68
|
-
errorContext = "Failed to get authSession";
|
|
69
|
-
_a.label = 1;
|
|
70
|
-
case 1:
|
|
71
|
-
_a.trys.push([1, 3, , 4]);
|
|
72
|
-
return [4 /*yield*/, axios_1.default.get("/identityprovider", {
|
|
73
|
-
baseURL: systemBaseUri,
|
|
74
|
-
headers: {
|
|
75
|
-
"Authorization": "Bearer " + apiKey
|
|
76
|
-
},
|
|
77
|
-
follows: ["login"]
|
|
78
|
-
})];
|
|
79
|
-
case 2:
|
|
80
|
-
response = _a.sent();
|
|
81
|
-
return [2 /*return*/, {
|
|
82
|
-
id: response.data.AuthSessionId,
|
|
83
|
-
expire: new Date(response.data.Expire)
|
|
84
|
-
}];
|
|
85
|
-
case 3:
|
|
86
|
-
e_1 = _a.sent();
|
|
87
|
-
if (e_1.response) {
|
|
88
|
-
switch (e_1.response.status) {
|
|
89
|
-
case 401:
|
|
90
|
-
throw new index_1.UnauthorizedError(errorContext, e_1.response);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
e_1.message = errorContext + ": " + e_1.message;
|
|
94
|
-
throw e_1;
|
|
95
|
-
case 4: return [2 /*return*/];
|
|
96
|
-
}
|
|
100
|
+
return [2 /*return*/, _getAuthSessionFactory(http_1._defaultHttpRequestFunction, _getAuthSessionDefaultTransformFunction)(context)];
|
|
97
101
|
});
|
|
98
102
|
});
|
|
99
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-auth-session.js","sourceRoot":"","sources":["../../../src/authentication/get-auth-session/get-auth-session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-auth-session.js","sourceRoot":"","sources":["../../../src/authentication/get-auth-session/get-auth-session.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAyF;AAazF;;;;GAIG;AACH,SAAgB,uCAAuC,CAAC,QAAsB,EAAE,CAAgB;IAC9F,OAAO;QACL,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa;QAC/B,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;KACvC,CAAC;AACJ,CAAC;AALD,0FAKC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,mBAA0F,EAC1F,iBAAwE;IAF1E,iBAYC;IARC,OAAO,UAAO,OAAsB;;;;wBACH,qBAAM,mBAAmB,CAAC,OAAO,EAAE;wBAChE,MAAM,EAAE,KAAK;wBACb,GAAG,EAAE,mBAAmB;wBACxB,OAAO,EAAE,CAAC,OAAO,CAAC;qBACnB,CAAC,EAAA;;oBAJI,QAAQ,GAAiB,SAI7B;oBACF,sBAAO,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAC;;;SAC7C,CAAC;AACJ,CAAC;AAZD,wDAYC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,0BAA0B;AAC1B,SAAsB,cAAc,CAAC,OAAsB;;;YACzD,sBAAO,sBAAsB,CAAC,kCAA2B,EAAE,uCAAuC,CAAC,CAAC,OAAO,CAAC,EAAC;;;CAC9G;AAFD,wCAEC"}
|
package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.d.ts
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
import { DvelopContext } from "@dvelop-sdk/core";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Parameters for the {@link getImpersonatedAuthSessionId}-function.
|
|
4
|
+
* @category Authentication
|
|
5
|
+
*/
|
|
6
|
+
export interface GetImpersonatedAuthSessionIdParams {
|
|
7
|
+
userId: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns an authSessionId for the given user. All requests with this authSessionId will be in that users name.
|
|
11
|
+
* **The AuthSessionId should be kept secret and never be publicly available.**
|
|
3
12
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param {string} userId User that should be impersonated
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { getImpersonatedAuthSessionId } from "@dvelop-sdk/identityprovider";
|
|
7
15
|
*
|
|
8
|
-
*
|
|
16
|
+
* const authSessionId = await getImpersonatedAuthSessionId({
|
|
17
|
+
* systemBaseUri: "https://monster-ag.d-velop.cloud",
|
|
18
|
+
* authSessionId: "dQw4w9WgXcQ" // has to be an AppSession
|
|
19
|
+
* }, {
|
|
20
|
+
* userId: "XiFkyR35v2Y"
|
|
21
|
+
* });
|
|
9
22
|
*
|
|
10
|
-
*
|
|
11
|
-
* const authSessionIdForSulley = await getImpersonedAuthSessionId("https://monster-ag.d-velop.cloud", "<APP_SESSION>", "<SULLEYS_USER_ID>");
|
|
12
|
-
* const sulley: ScimUser = await validateAuthSessionId("https://monster-ag.d-velop.cloud", authSessionIdForSulley);
|
|
13
|
-
* console.log(sulley.displayName) // James P. Sullivan
|
|
23
|
+
* console.log(authSessionId);
|
|
14
24
|
* ```
|
|
25
|
+
* @category Authentication
|
|
15
26
|
*/
|
|
16
|
-
export declare function getImpersonatedAuthSessionId(
|
|
27
|
+
export declare function getImpersonatedAuthSessionId(context: DvelopContext, params: GetImpersonatedAuthSessionIdParams): Promise<string>;
|
|
17
28
|
//# sourceMappingURL=get-impersonated-auth-session-id.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-impersonated-auth-session-id.d.ts","sourceRoot":"","sources":["../../../src/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-impersonated-auth-session-id.d.ts","sourceRoot":"","sources":["../../../src/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD;;;GAGG;AACH,MAAM,WAAW,kCAAkC;IACjD,MAAM,EAAE,MAAM,CAAC;CAChB;AAiCD;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,kCAAkC,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtI"}
|
package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.js
CHANGED
|
@@ -35,66 +35,69 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.getImpersonatedAuthSessionId = void 0;
|
|
43
|
-
var
|
|
44
|
-
var index_1 = require("../../index");
|
|
39
|
+
exports.getImpersonatedAuthSessionId = exports._getImpersonatedAuthSessionIdFactory = exports._getImpersonatedAuthSessionIdDefaultTransformFunction = void 0;
|
|
40
|
+
var http_1 = require("../../utils/http");
|
|
45
41
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @param {string} systemBaseUri SystemBaseUri for the tenant
|
|
49
|
-
* @param {string} appSession A valid appSession
|
|
50
|
-
* @param {string} userId User that should be impersonated
|
|
51
|
-
*
|
|
42
|
+
* Default transform-function provided to the {@link getImpersontedAuthSessionId}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
|
|
43
|
+
* @internal
|
|
52
44
|
* @category Authentication
|
|
53
|
-
*
|
|
54
|
-
* @example ```typescript
|
|
55
|
-
* const authSessionIdForSulley = await getImpersonedAuthSessionId("https://monster-ag.d-velop.cloud", "<APP_SESSION>", "<SULLEYS_USER_ID>");
|
|
56
|
-
* const sulley: ScimUser = await validateAuthSessionId("https://monster-ag.d-velop.cloud", authSessionIdForSulley);
|
|
57
|
-
* console.log(sulley.displayName) // James P. Sullivan
|
|
58
|
-
* ```
|
|
59
45
|
*/
|
|
60
|
-
function
|
|
61
|
-
return
|
|
62
|
-
|
|
46
|
+
function _getImpersonatedAuthSessionIdDefaultTransformFunction(response, _, __) {
|
|
47
|
+
return response.data.authSessionId;
|
|
48
|
+
}
|
|
49
|
+
exports._getImpersonatedAuthSessionIdDefaultTransformFunction = _getImpersonatedAuthSessionIdDefaultTransformFunction;
|
|
50
|
+
/**
|
|
51
|
+
* Factory for the {@link getImpersonatedAuthSessionId}}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
|
|
52
|
+
* @typeparam T Return type of the {@link getImpersonatedAuthSessionId}-function. A corresponding transformFuntion has to be supplied.
|
|
53
|
+
* @internal
|
|
54
|
+
* @category Authentication
|
|
55
|
+
*/
|
|
56
|
+
function _getImpersonatedAuthSessionIdFactory(httpRequestFunction, transformFunction) {
|
|
57
|
+
var _this = this;
|
|
58
|
+
return function (context, params) { return __awaiter(_this, void 0, void 0, function () {
|
|
59
|
+
var response;
|
|
63
60
|
return __generator(this, function (_a) {
|
|
64
61
|
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
case 0: return [4 /*yield*/, httpRequestFunction(context, {
|
|
63
|
+
method: "GET",
|
|
64
|
+
url: "/identityprovider/impersonatesession",
|
|
65
|
+
params: {
|
|
66
|
+
userId: params.userId
|
|
67
|
+
}
|
|
68
|
+
})];
|
|
68
69
|
case 1:
|
|
69
|
-
_a.trys.push([1, 3, , 4]);
|
|
70
|
-
return [4 /*yield*/, axios_1.default.get("/identityprovider/impersonatesession", {
|
|
71
|
-
baseURL: systemBaseUri,
|
|
72
|
-
headers: {
|
|
73
|
-
"Content-Type": "application/json",
|
|
74
|
-
"Accept": "application/hal+json",
|
|
75
|
-
"Authorization": "Bearer " + appSession
|
|
76
|
-
},
|
|
77
|
-
params: {
|
|
78
|
-
userId: userId
|
|
79
|
-
}
|
|
80
|
-
})];
|
|
81
|
-
case 2:
|
|
82
70
|
response = _a.sent();
|
|
83
|
-
return [2 /*return*/, response
|
|
84
|
-
case 3:
|
|
85
|
-
e_1 = _a.sent();
|
|
86
|
-
if (e_1.response) {
|
|
87
|
-
switch (e_1.response.status) {
|
|
88
|
-
case 401:
|
|
89
|
-
throw new index_1.UnauthorizedError(errorContext, e_1.response);
|
|
90
|
-
//TODO: 404 if user does not exist?
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
e_1.message = errorContext + ": " + e_1.message;
|
|
94
|
-
throw e_1;
|
|
95
|
-
case 4: return [2 /*return*/];
|
|
71
|
+
return [2 /*return*/, transformFunction(response, context, params)];
|
|
96
72
|
}
|
|
97
73
|
});
|
|
74
|
+
}); };
|
|
75
|
+
}
|
|
76
|
+
exports._getImpersonatedAuthSessionIdFactory = _getImpersonatedAuthSessionIdFactory;
|
|
77
|
+
/**
|
|
78
|
+
* Returns an authSessionId for the given user. All requests with this authSessionId will be in that users name.
|
|
79
|
+
* **The AuthSessionId should be kept secret and never be publicly available.**
|
|
80
|
+
*
|
|
81
|
+
* ```typescript
|
|
82
|
+
* import { getImpersonatedAuthSessionId } from "@dvelop-sdk/identityprovider";
|
|
83
|
+
*
|
|
84
|
+
* const authSessionId = await getImpersonatedAuthSessionId({
|
|
85
|
+
* systemBaseUri: "https://monster-ag.d-velop.cloud",
|
|
86
|
+
* authSessionId: "dQw4w9WgXcQ" // has to be an AppSession
|
|
87
|
+
* }, {
|
|
88
|
+
* userId: "XiFkyR35v2Y"
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* console.log(authSessionId);
|
|
92
|
+
* ```
|
|
93
|
+
* @category Authentication
|
|
94
|
+
*/
|
|
95
|
+
/* istanbul ignore next */
|
|
96
|
+
function getImpersonatedAuthSessionId(context, params) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
return __generator(this, function (_a) {
|
|
99
|
+
return [2 /*return*/, _getImpersonatedAuthSessionIdFactory(http_1._defaultHttpRequestFunction, _getImpersonatedAuthSessionIdDefaultTransformFunction)(context, params)];
|
|
100
|
+
});
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
103
|
exports.getImpersonatedAuthSessionId = getImpersonatedAuthSessionId;
|
package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-impersonated-auth-session-id.js","sourceRoot":"","sources":["../../../src/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-impersonated-auth-session-id.js","sourceRoot":"","sources":["../../../src/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAyF;AAUzF;;;;GAIG;AACH,SAAgB,qDAAqD,CAAC,QAAsB,EAAE,CAAgB,EAAE,EAAsC;IACpJ,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;AACrC,CAAC;AAFD,sHAEC;AAED;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,mBAA0F,EAC1F,iBAAoH;IAFtH,iBAcC;IAVC,OAAO,UAAO,OAAsB,EAAE,MAA0C;;;;wBAC/C,qBAAM,mBAAmB,CAAC,OAAO,EAAE;wBAChE,MAAM,EAAE,KAAK;wBACb,GAAG,EAAE,sCAAsC;wBAC3C,MAAM,EAAE;4BACN,MAAM,EAAE,MAAM,CAAC,MAAM;yBACtB;qBACF,CAAC,EAAA;;oBANI,QAAQ,GAAiB,SAM7B;oBACF,sBAAO,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,EAAC;;;SACrD,CAAC;AACJ,CAAC;AAdD,oFAcC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,0BAA0B;AAC1B,SAAsB,4BAA4B,CAAC,OAAsB,EAAE,MAA0C;;;YACnH,sBAAO,oCAAoC,CAAC,kCAA2B,EAAE,qDAAqD,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAC;;;CAClJ;AAFD,oEAEC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the URI a request should be redirected to in case it does not contain a valid authSessionId. Redirected requests will display a HTML Login for users to authenticate.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* ```typescript
|
|
5
|
+
* const redirectionUri = getLoginRedirectionUri("https://monster-ag.d-velop.cloud/cda-compliance/feature");
|
|
6
|
+
* redirect(redirectionUri); // respond with 302
|
|
7
|
+
* ```
|
|
5
8
|
*
|
|
6
9
|
* @category Authentication
|
|
7
|
-
*
|
|
8
|
-
* @example ```typescript
|
|
9
|
-
* const redirectionUri = getLoginRedirectionUri("<ORIGINAL_URL>");
|
|
10
|
-
* request.redirect(redirectionUri);
|
|
11
|
-
* ```
|
|
12
10
|
*/
|
|
13
11
|
export declare function getLoginRedirectionUri(successUri: string): string;
|
|
14
12
|
//# sourceMappingURL=get-login-redirection-uri.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-login-redirection-uri.d.ts","sourceRoot":"","sources":["../../../src/authentication/get-login-redirection-uri/get-login-redirection-uri.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"get-login-redirection-uri.d.ts","sourceRoot":"","sources":["../../../src/authentication/get-login-redirection-uri/get-login-redirection-uri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEjE"}
|
|
@@ -4,14 +4,12 @@ exports.getLoginRedirectionUri = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns the URI a request should be redirected to in case it does not contain a valid authSessionId. Redirected requests will display a HTML Login for users to authenticate.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const redirectionUri = getLoginRedirectionUri("https://monster-ag.d-velop.cloud/cda-compliance/feature");
|
|
9
|
+
* redirect(redirectionUri); // respond with 302
|
|
10
|
+
* ```
|
|
8
11
|
*
|
|
9
12
|
* @category Authentication
|
|
10
|
-
*
|
|
11
|
-
* @example ```typescript
|
|
12
|
-
* const redirectionUri = getLoginRedirectionUri("<ORIGINAL_URL>");
|
|
13
|
-
* request.redirect(redirectionUri);
|
|
14
|
-
* ```
|
|
15
13
|
*/
|
|
16
14
|
function getLoginRedirectionUri(successUri) {
|
|
17
15
|
return "/identityprovider/login?redirect=" + encodeURIComponent(successUri);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-login-redirection-uri.js","sourceRoot":"","sources":["../../../src/authentication/get-login-redirection-uri/get-login-redirection-uri.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"get-login-redirection-uri.js","sourceRoot":"","sources":["../../../src/authentication/get-login-redirection-uri/get-login-redirection-uri.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CAAC,UAAkB;IACvD,OAAO,sCAAoC,kBAAkB,CAAC,UAAU,CAAG,CAAC;AAC9E,CAAC;AAFD,wDAEC"}
|
|
@@ -1,16 +1,46 @@
|
|
|
1
|
+
import { DvelopContext } from "../../../../core/lib";
|
|
2
|
+
import { HttpConfig, HttpResponse } from "../../utils/http";
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
* Parameters for the {@link requestAppSession}-function.
|
|
5
|
+
* @category Authentication
|
|
6
|
+
*/
|
|
7
|
+
export interface RequestAppSessionParams {
|
|
8
|
+
/** Name of the app requesting the appSession */
|
|
9
|
+
appName: string;
|
|
10
|
+
/** Relative URI to which the appSession will be sent via POST */
|
|
11
|
+
callback: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* AppSession which will be postet to your app after using the {@link requestAppSession}-function.
|
|
15
|
+
* @category Authentication
|
|
16
|
+
*/
|
|
17
|
+
export interface AppSession {
|
|
18
|
+
appSessionId: string;
|
|
19
|
+
expire: string;
|
|
20
|
+
sign: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Factory for the {@link requestAppSession}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
|
|
24
|
+
* @typeparam T Return type of the {@link requestAppSession}-function. A corresponding transformFuntion has to be supplied.
|
|
9
25
|
* @category Authentication
|
|
26
|
+
*/
|
|
27
|
+
export declare function _requestAppSessionFactory<T>(httpRequestFunction: (context: DvelopContext, config: HttpConfig) => Promise<HttpResponse>, transformFunction: (response: HttpResponse, context: DvelopContext, params: RequestAppSessionParams) => T): (context: DvelopContext, params: RequestAppSessionParams) => Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Request an appSession for your app. The appSession will be sent via POST to your defined callback.
|
|
30
|
+
* **Do not forget to validate the appSessionId via the {@link validateAppSessionSignature}-function**
|
|
31
|
+
*
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { requestAppSession } from "@dvelop-sdk/identityprovider";
|
|
10
34
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
35
|
+
* await requestAppSession({
|
|
36
|
+
* systemBaseUri: "https://monster-ag.d-velop.cloud",
|
|
37
|
+
* authSessionId: "dQw4w9WgXcQ"
|
|
38
|
+
* }, {
|
|
39
|
+
* appName: "cda-compliance",
|
|
40
|
+
* callback: "/cda-compliance/appsession"
|
|
41
|
+
* });
|
|
13
42
|
* ```
|
|
43
|
+
* @category Authentication
|
|
14
44
|
*/
|
|
15
|
-
export declare function requestAppSession(
|
|
45
|
+
export declare function requestAppSession(context: DvelopContext, params: RequestAppSessionParams): Promise<void>;
|
|
16
46
|
//# sourceMappingURL=request-app-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-app-session.d.ts","sourceRoot":"","sources":["../../../src/authentication/request-app-session/request-app-session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-app-session.d.ts","sourceRoot":"","sources":["../../../src/authentication/request-app-session/request-app-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,YAAY,EAA+B,MAAM,kBAAkB,CAAC;AAEzF;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EACzC,mBAAmB,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC,EAC1F,iBAAiB,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,uBAAuB,KAAK,CAAC,GACxG,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,uBAAuB,KAAK,OAAO,CAAC,CAAC,CAAC,CAgBzE;AAED;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9G"}
|
|
@@ -35,55 +35,61 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.requestAppSession = void 0;
|
|
43
|
-
var
|
|
39
|
+
exports.requestAppSession = exports._requestAppSessionFactory = void 0;
|
|
40
|
+
var http_1 = require("../../utils/http");
|
|
44
41
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @param {string} systemBaseUri SystemBaseUri for the tenant
|
|
48
|
-
* @param {string} appName AppName of the requesting app
|
|
49
|
-
* @param {string} callback CallbackUri with leading slash and appName
|
|
50
|
-
* @param {string} requestId Unique requestId
|
|
51
|
-
*
|
|
42
|
+
* Factory for the {@link requestAppSession}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
|
|
43
|
+
* @typeparam T Return type of the {@link requestAppSession}-function. A corresponding transformFuntion has to be supplied.
|
|
52
44
|
* @category Authentication
|
|
45
|
+
*/
|
|
46
|
+
function _requestAppSessionFactory(httpRequestFunction, transformFunction) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
return function (context, params) { return __awaiter(_this, void 0, void 0, function () {
|
|
49
|
+
var response;
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0: return [4 /*yield*/, httpRequestFunction(context, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
url: "/identityprovider/appsession",
|
|
55
|
+
data: {
|
|
56
|
+
appname: params.appName,
|
|
57
|
+
callback: params.callback,
|
|
58
|
+
requestid: context.requestId
|
|
59
|
+
}
|
|
60
|
+
})];
|
|
61
|
+
case 1:
|
|
62
|
+
response = _a.sent();
|
|
63
|
+
return [2 /*return*/, transformFunction(response, context, params)];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}); };
|
|
67
|
+
}
|
|
68
|
+
exports._requestAppSessionFactory = _requestAppSessionFactory;
|
|
69
|
+
/**
|
|
70
|
+
* Request an appSession for your app. The appSession will be sent via POST to your defined callback.
|
|
71
|
+
* **Do not forget to validate the appSessionId via the {@link validateAppSessionSignature}-function**
|
|
53
72
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { requestAppSession } from "@dvelop-sdk/identityprovider";
|
|
75
|
+
*
|
|
76
|
+
* await requestAppSession({
|
|
77
|
+
* systemBaseUri: "https://monster-ag.d-velop.cloud",
|
|
78
|
+
* authSessionId: "dQw4w9WgXcQ"
|
|
79
|
+
* }, {
|
|
80
|
+
* appName: "cda-compliance",
|
|
81
|
+
* callback: "/cda-compliance/appsession"
|
|
82
|
+
* });
|
|
56
83
|
* ```
|
|
84
|
+
* @category Authentication
|
|
57
85
|
*/
|
|
58
|
-
|
|
86
|
+
/* istanbul ignore next */
|
|
87
|
+
function requestAppSession(context, params) {
|
|
59
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
-
var errorContext, e_1;
|
|
61
89
|
return __generator(this, function (_a) {
|
|
62
90
|
switch (_a.label) {
|
|
63
|
-
case 0:
|
|
64
|
-
|
|
65
|
-
_a.label = 1;
|
|
66
|
-
case 1:
|
|
67
|
-
_a.trys.push([1, 3, , 4]);
|
|
68
|
-
return [4 /*yield*/, axios_1.default.post("/identityprovider/appsession", {
|
|
69
|
-
appname: appName,
|
|
70
|
-
callback: callback,
|
|
71
|
-
requestid: requestId
|
|
72
|
-
}, {
|
|
73
|
-
baseURL: systemBaseUri,
|
|
74
|
-
headers: {
|
|
75
|
-
"Content-Type": "application/json",
|
|
76
|
-
"Origin": systemBaseUri
|
|
77
|
-
}
|
|
78
|
-
})];
|
|
79
|
-
case 2:
|
|
80
|
-
_a.sent();
|
|
81
|
-
return [3 /*break*/, 4];
|
|
82
|
-
case 3:
|
|
83
|
-
e_1 = _a.sent();
|
|
84
|
-
e_1.message = errorContext + ": " + e_1.message;
|
|
85
|
-
throw e_1;
|
|
86
|
-
case 4: return [2 /*return*/];
|
|
91
|
+
case 0: return [4 /*yield*/, _requestAppSessionFactory(http_1._defaultHttpRequestFunction, function () { })(context, params)];
|
|
92
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
87
93
|
}
|
|
88
94
|
});
|
|
89
95
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-app-session.js","sourceRoot":"","sources":["../../../src/authentication/request-app-session/request-app-session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-app-session.js","sourceRoot":"","sources":["../../../src/authentication/request-app-session/request-app-session.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAyF;AAuBzF;;;;GAIG;AACH,SAAgB,yBAAyB,CACvC,mBAA0F,EAC1F,iBAAyG;IAF3G,iBAmBC;IAdC,OAAO,UAAO,OAAsB,EAAE,MAA+B;;;;wBAElD,qBAAM,mBAAmB,CAAC,OAAO,EAAE;wBAClD,MAAM,EAAE,MAAM;wBACd,GAAG,EAAE,8BAA8B;wBACnC,IAAI,EAAE;4BACJ,OAAO,EAAE,MAAM,CAAC,OAAO;4BACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;4BACzB,SAAS,EAAE,OAAO,CAAC,SAAS;yBAC7B;qBACF,CAAC,EAAA;;oBARI,QAAQ,GAAG,SAQf;oBAEF,sBAAO,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,EAAC;;;SACrD,CAAC;AACJ,CAAC;AAnBD,8DAmBC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,0BAA0B;AAC1B,SAAsB,iBAAiB,CAAC,OAAsB,EAAE,MAA+B;;;;wBACtF,qBAAM,yBAAyB,CAAC,kCAA2B,EAAE,cAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAA;wBAA/F,sBAAO,SAAwF,EAAC;;;;CACjG;AAFD,8CAEC"}
|