@dvelop-sdk/identityprovider 4.0.2 → 4.0.4

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.
@@ -1,104 +1,104 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getImpersonatedAuthSessionId = exports._getImpersonatedAuthSessionIdFactory = exports._getImpersonatedAuthSessionIdDefaultTransformFunction = void 0;
40
- var http_1 = require("../../utils/http");
41
- /**
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
44
- * @category Authentication
45
- */
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;
60
- return __generator(this, function (_a) {
61
- switch (_a.label) {
62
- case 0: return [4 /*yield*/, httpRequestFunction(context, {
63
- method: "GET",
64
- url: "/identityprovider/impersonatesession",
65
- params: {
66
- userId: params.userId
67
- }
68
- })];
69
- case 1:
70
- response = _a.sent();
71
- return [2 /*return*/, transformFunction(response, context, params)];
72
- }
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
- });
101
- });
102
- }
103
- exports.getImpersonatedAuthSessionId = getImpersonatedAuthSessionId;
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getImpersonatedAuthSessionId = exports._getImpersonatedAuthSessionIdFactory = exports._getImpersonatedAuthSessionIdDefaultTransformFunction = void 0;
40
+ var http_1 = require("../../utils/http");
41
+ /**
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
44
+ * @category Authentication
45
+ */
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 transformFunction 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;
60
+ return __generator(this, function (_a) {
61
+ switch (_a.label) {
62
+ case 0: return [4 /*yield*/, httpRequestFunction(context, {
63
+ method: "GET",
64
+ url: "/identityprovider/impersonatesession",
65
+ params: {
66
+ userId: params.userId
67
+ }
68
+ })];
69
+ case 1:
70
+ response = _a.sent();
71
+ return [2 /*return*/, transformFunction(response, context, params)];
72
+ }
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
+ });
101
+ });
102
+ }
103
+ exports.getImpersonatedAuthSessionId = getImpersonatedAuthSessionId;
104
104
  //# sourceMappingURL=get-impersonated-auth-session-id.js.map
@@ -1,12 +1,12 @@
1
- /**
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
- *
4
- * ```typescript
5
- * const redirectionUri = getLoginRedirectionUri("https://monster-ag.d-velop.cloud/cda-compliance/feature");
6
- * redirect(redirectionUri); // respond with 302
7
- * ```
8
- *
9
- * @category Authentication
10
- */
11
- export declare function getLoginRedirectionUri(successUri: string): string;
1
+ /**
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
+ *
4
+ * ```typescript
5
+ * const redirectionUri = getLoginRedirectionUri("https://monster-ag.d-velop.cloud/cda-compliance/feature");
6
+ * redirect(redirectionUri); // respond with 302
7
+ * ```
8
+ *
9
+ * @category Authentication
10
+ */
11
+ export declare function getLoginRedirectionUri(successUri: string): string;
12
12
  //# sourceMappingURL=get-login-redirection-uri.d.ts.map
@@ -1,18 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLoginRedirectionUri = void 0;
4
- /**
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
- *
7
- * ```typescript
8
- * const redirectionUri = getLoginRedirectionUri("https://monster-ag.d-velop.cloud/cda-compliance/feature");
9
- * redirect(redirectionUri); // respond with 302
10
- * ```
11
- *
12
- * @category Authentication
13
- */
14
- function getLoginRedirectionUri(successUri) {
15
- return "/identityprovider/login?redirect=" + encodeURIComponent(successUri);
16
- }
17
- exports.getLoginRedirectionUri = getLoginRedirectionUri;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLoginRedirectionUri = void 0;
4
+ /**
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
+ *
7
+ * ```typescript
8
+ * const redirectionUri = getLoginRedirectionUri("https://monster-ag.d-velop.cloud/cda-compliance/feature");
9
+ * redirect(redirectionUri); // respond with 302
10
+ * ```
11
+ *
12
+ * @category Authentication
13
+ */
14
+ function getLoginRedirectionUri(successUri) {
15
+ return "/identityprovider/login?redirect=" + encodeURIComponent(successUri);
16
+ }
17
+ exports.getLoginRedirectionUri = getLoginRedirectionUri;
18
18
  //# sourceMappingURL=get-login-redirection-uri.js.map
@@ -1,37 +1,37 @@
1
- import { DvelopContext } from "../../../../core/lib";
2
- import { HttpConfig, HttpResponse } from "../../utils/http";
3
- /**
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
- * Factory for the {@link requestAppSession}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
15
- * @typeparam T Return type of the {@link requestAppSession}-function. A corresponding transformFuntion has to be supplied.
16
- * @category Authentication
17
- */
18
- 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>;
19
- /**
20
- * Request an appSession for your app. The appSession will be sent via POST to your defined callback.
21
- * **Do not forget to validate the appSessionId via the {@link validateAppSessionSignature}-function**
22
- *
23
- * ```typescript
24
- * import { requestAppSession } from "@dvelop-sdk/identityprovider";
25
- *
26
- * await requestAppSession({
27
- * systemBaseUri: "https://monster-ag.d-velop.cloud",
28
- * authSessionId: "dQw4w9WgXcQ"
29
- * }, {
30
- * appName: "cda-compliance",
31
- * callback: "/cda-compliance/appsession"
32
- * });
33
- * ```
34
- * @category Authentication
35
- */
36
- export declare function requestAppSession(context: DvelopContext, params: RequestAppSessionParams): Promise<void>;
1
+ import { DvelopContext } from "../../../../core/lib";
2
+ import { HttpConfig, HttpResponse } from "../../utils/http";
3
+ /**
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
+ * Factory for the {@link requestAppSession}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
15
+ * @typeparam T Return type of the {@link requestAppSession}-function. A corresponding transformFunction has to be supplied.
16
+ * @category Authentication
17
+ */
18
+ 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>;
19
+ /**
20
+ * Request an appSession for your app. The appSession will be sent via POST to your defined callback.
21
+ * **Do not forget to validate the appSessionId via the {@link validateAppSessionSignature}-function**
22
+ *
23
+ * ```typescript
24
+ * import { requestAppSession } from "@dvelop-sdk/identityprovider";
25
+ *
26
+ * await requestAppSession({
27
+ * systemBaseUri: "https://monster-ag.d-velop.cloud",
28
+ * authSessionId: "dQw4w9WgXcQ"
29
+ * }, {
30
+ * appName: "cda-compliance",
31
+ * callback: "/cda-compliance/appsession"
32
+ * });
33
+ * ```
34
+ * @category Authentication
35
+ */
36
+ export declare function requestAppSession(context: DvelopContext, params: RequestAppSessionParams): Promise<void>;
37
37
  //# sourceMappingURL=request-app-session.d.ts.map
@@ -1,98 +1,98 @@
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.requestAppSession = exports._requestAppSessionFactory = void 0;
40
- var http_1 = require("../../utils/http");
41
- /**
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.
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**
72
- *
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
- * });
83
- * ```
84
- * @category Authentication
85
- */
86
- /* istanbul ignore next */
87
- function requestAppSession(context, params) {
88
- return __awaiter(this, void 0, void 0, function () {
89
- return __generator(this, function (_a) {
90
- switch (_a.label) {
91
- case 0: return [4 /*yield*/, _requestAppSessionFactory(http_1._defaultHttpRequestFunction, function () { })(context, params)];
92
- case 1: return [2 /*return*/, _a.sent()];
93
- }
94
- });
95
- });
96
- }
97
- exports.requestAppSession = requestAppSession;
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.requestAppSession = exports._requestAppSessionFactory = void 0;
40
+ var http_1 = require("../../utils/http");
41
+ /**
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 transformFunction has to be supplied.
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**
72
+ *
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
+ * });
83
+ * ```
84
+ * @category Authentication
85
+ */
86
+ /* istanbul ignore next */
87
+ function requestAppSession(context, params) {
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0: return [4 /*yield*/, _requestAppSessionFactory(http_1._defaultHttpRequestFunction, function () { })(context, params)];
92
+ case 1: return [2 /*return*/, _a.sent()];
93
+ }
94
+ });
95
+ });
96
+ }
97
+ exports.requestAppSession = requestAppSession;
98
98
  //# sourceMappingURL=request-app-session.js.map
@@ -1,32 +1,32 @@
1
- /**
2
- * Indicates an invalid sign-value
3
- * @category Error
4
- */
5
- export declare class InvalidAppSessionSignatureError extends Error {
6
- constructor();
7
- }
8
- /**
9
- * AppSession which will be postet to your app after using the {@link requestAppSession}-function.
10
- * @category Authentication
11
- */
12
- export interface AppSession {
13
- authSessionId: string;
14
- expire: string;
15
- sign: string;
16
- }
17
- /**
18
- * Validate the sign value which is provided when an appSession is sent to your app. For further information on this process refer to the [documentation](https://developer.d-velop.de/documentation/idpapi/en/identityprovider-app-201523580.html#IdentityproviderApp-Inter-appcommunicationwithappsessions).
19
- *
20
- * ```typescript
21
- * try {
22
- * validateAppSessionSignature("cda-compliance", "qP-7GNoDJ5c", requestBody); //pass or error
23
- * } catch(e) {
24
- * // respond with 403 - Forbidden
25
- * }
26
- * }
27
- * ```
28
- * @throws {@link InvalidAppSessionSignatureError} indicates that the sign-value is not valid
29
- * @category Authentication
30
- */
31
- export declare function validateAppSessionSignature(appName: string, requestId: string, appSession: AppSession): void;
1
+ /**
2
+ * Indicates an invalid sign-value
3
+ * @category Error
4
+ */
5
+ export declare class InvalidAppSessionSignatureError extends Error {
6
+ constructor();
7
+ }
8
+ /**
9
+ * AppSession which will be postet to your app after using the {@link requestAppSession}-function.
10
+ * @category Authentication
11
+ */
12
+ export interface AppSession {
13
+ authSessionId: string;
14
+ expire: string;
15
+ sign: string;
16
+ }
17
+ /**
18
+ * Validate the sign value which is provided when an appSession is sent to your app. For further information on this process refer to the [documentation](https://developer.d-velop.de/documentation/idpapi/en/identityprovider-app-201523580.html#IdentityproviderApp-Inter-appcommunicationwithappsessions).
19
+ *
20
+ * ```typescript
21
+ * try {
22
+ * validateAppSessionSignature("cda-compliance", "qP-7GNoDJ5c", requestBody); //pass or error
23
+ * } catch(e) {
24
+ * // respond with 403 - Forbidden
25
+ * }
26
+ * }
27
+ * ```
28
+ * @throws {@link InvalidAppSessionSignatureError} indicates that the sign-value is not valid
29
+ * @category Authentication
30
+ */
31
+ export declare function validateAppSessionSignature(appName: string, requestId: string, appSession: AppSession): void;
32
32
  //# sourceMappingURL=validate-app-session-signature.d.ts.map