@dvelop-sdk/identityprovider 3.1.0 → 4.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.
Files changed (26) hide show
  1. package/README.md +29 -29
  2. package/lib/authentication/get-auth-session/get-auth-session.d.ts +44 -44
  3. package/lib/authentication/get-auth-session/get-auth-session.js +104 -104
  4. package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.d.ts +41 -41
  5. package/lib/authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id.js +103 -103
  6. package/lib/authentication/get-login-redirection-uri/get-login-redirection-uri.d.ts +11 -11
  7. package/lib/authentication/get-login-redirection-uri/get-login-redirection-uri.js +17 -17
  8. package/lib/authentication/request-app-session/request-app-session.d.ts +36 -45
  9. package/lib/authentication/request-app-session/request-app-session.d.ts.map +1 -1
  10. package/lib/authentication/request-app-session/request-app-session.js +97 -97
  11. package/lib/authentication/request-app-session/request-app-session.js.map +1 -1
  12. package/lib/authentication/validate-app-session-signature/validate-app-session-signature.d.ts +31 -23
  13. package/lib/authentication/validate-app-session-signature/validate-app-session-signature.d.ts.map +1 -1
  14. package/lib/authentication/validate-app-session-signature/validate-app-session-signature.js +62 -55
  15. package/lib/authentication/validate-app-session-signature/validate-app-session-signature.js.map +1 -1
  16. package/lib/authentication/validate-auth-session-id/validate-auth-session-id.d.ts +61 -61
  17. package/lib/authentication/validate-auth-session-id/validate-auth-session-id.js +100 -100
  18. package/lib/index.d.ts +40 -40
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/index.js +45 -45
  21. package/lib/index.js.map +1 -1
  22. package/lib/internal.d.ts +5 -5
  23. package/lib/internal.js +18 -18
  24. package/lib/utils/http.d.ts +23 -23
  25. package/lib/utils/http.js +129 -129
  26. package/package.json +27 -27
@@ -1,56 +1,63 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.validateAppSessionSignature = exports.InvalidAppSessionSignatureError = void 0;
19
- var crypto_1 = require("crypto");
20
- /**
21
- * Indicates an invalid sign-value
22
- * @category Error
23
- */
24
- var InvalidAppSessionSignatureError = /** @class */ (function (_super) {
25
- __extends(InvalidAppSessionSignatureError, _super);
26
- // eslint-disable-next-line no-unused-vars
27
- function InvalidAppSessionSignatureError() {
28
- var _this = _super.call(this, "Invalid AppSessionSingature: An AppSession was sent that contains no valid signature.") || this;
29
- Object.setPrototypeOf(_this, InvalidAppSessionSignatureError.prototype);
30
- return _this;
31
- }
32
- return InvalidAppSessionSignatureError;
33
- }(Error));
34
- exports.InvalidAppSessionSignatureError = InvalidAppSessionSignatureError;
35
- /**
36
- * 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).
37
- *
38
- * ```typescript
39
- * try {
40
- * validateAppSessionSignature("cda-compliance", "qP-7GNoDJ5c", requestBody); //pass or error
41
- * } catch(e) {
42
- * // respond with 403 - Forbidden
43
- * }
44
- * }
45
- * ```
46
- * @throws {@link InvalidAppSessionSignatureError} indicates that the sign-value is not valid
47
- * @category Authentication
48
- */
49
- function validateAppSessionSignature(appName, requestId, appSession) {
50
- var expectedSign = crypto_1.createHash("sha256").update(appName + appSession.appSessionId + appSession.expire + requestId, "utf8").digest("hex");
51
- if (expectedSign !== appSession.sign) {
52
- throw new InvalidAppSessionSignatureError();
53
- }
54
- }
55
- exports.validateAppSessionSignature = validateAppSessionSignature;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.validateAppSessionSignature = exports.InvalidAppSessionSignatureError = void 0;
19
+ var crypto_1 = require("crypto");
20
+ /**
21
+ * Indicates an invalid sign-value
22
+ * @category Error
23
+ */
24
+ var InvalidAppSessionSignatureError = /** @class */ (function (_super) {
25
+ __extends(InvalidAppSessionSignatureError, _super);
26
+ // eslint-disable-next-line no-unused-vars
27
+ function InvalidAppSessionSignatureError() {
28
+ var _this = _super.call(this, "Invalid AppSessionSingature: An AppSession was sent that contains no valid signature.") || this;
29
+ Object.setPrototypeOf(_this, InvalidAppSessionSignatureError.prototype);
30
+ return _this;
31
+ }
32
+ return InvalidAppSessionSignatureError;
33
+ }(Error));
34
+ exports.InvalidAppSessionSignatureError = InvalidAppSessionSignatureError;
35
+ /**
36
+ * 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).
37
+ *
38
+ * ```typescript
39
+ * try {
40
+ * validateAppSessionSignature("cda-compliance", "qP-7GNoDJ5c", requestBody); //pass or error
41
+ * } catch(e) {
42
+ * // respond with 403 - Forbidden
43
+ * }
44
+ * }
45
+ * ```
46
+ * @throws {@link InvalidAppSessionSignatureError} indicates that the sign-value is not valid
47
+ * @category Authentication
48
+ */
49
+ function validateAppSessionSignature(appName, requestId, appSession) {
50
+ var validSignature = false;
51
+ try {
52
+ var expectedSign = crypto_1.createHash("sha256").update(appName + appSession.authSessionId + appSession.expire + requestId, "utf8").digest("hex");
53
+ validSignature = crypto_1.timingSafeEqual(Buffer.from(appSession.sign), Buffer.from(expectedSign));
54
+ }
55
+ catch (e) {
56
+ throw new InvalidAppSessionSignatureError();
57
+ }
58
+ if (!validSignature) {
59
+ throw new InvalidAppSessionSignatureError();
60
+ }
61
+ }
62
+ exports.validateAppSessionSignature = validateAppSessionSignature;
56
63
  //# sourceMappingURL=validate-app-session-signature.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-app-session-signature.js","sourceRoot":"","sources":["../../../src/authentication/validate-app-session-signature/validate-app-session-signature.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAAoC;AAGpC;;;EAGE;AACF;IAAqD,mDAAK;IACxD,0CAA0C;IAC1C;QAAA,YACE,kBAAM,uFAAuF,CAAC,SAE/F;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,+BAA+B,CAAC,SAAS,CAAC,CAAC;;IACzE,CAAC;IACH,sCAAC;AAAD,CAAC,AAND,CAAqD,KAAK,GAMzD;AANY,0EAA+B;AAQ5C;;;;;;;;;;;;;GAaG;AACH,SAAgB,2BAA2B,CAAC,OAAe,EAAE,SAAiB,EAAE,UAAsB;IACpG,IAAM,YAAY,GAAW,mBAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,YAAY,GAAG,UAAU,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClJ,IAAI,YAAY,KAAK,UAAU,CAAC,IAAI,EAAE;QACpC,MAAM,IAAI,+BAA+B,EAAE,CAAC;KAC7C;AACH,CAAC;AALD,kEAKC"}
1
+ {"version":3,"file":"validate-app-session-signature.js","sourceRoot":"","sources":["../../../src/authentication/validate-app-session-signature/validate-app-session-signature.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iCAAqD;AAErD;;;EAGE;AACF;IAAqD,mDAAK;IACxD,0CAA0C;IAC1C;QAAA,YACE,kBAAM,uFAAuF,CAAC,SAE/F;QADC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,+BAA+B,CAAC,SAAS,CAAC,CAAC;;IACzE,CAAC;IACH,sCAAC;AAAD,CAAC,AAND,CAAqD,KAAK,GAMzD;AANY,0EAA+B;AAkB5C;;;;;;;;;;;;;GAaG;AACH,SAAgB,2BAA2B,CAAC,OAAe,EAAE,SAAiB,EAAE,UAAsB;IAEpG,IAAI,cAAc,GAAY,KAAK,CAAC;IAEpC,IAAI;QACF,IAAM,YAAY,GAAW,mBAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,aAAa,GAAG,UAAU,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnJ,cAAc,GAAG,wBAAe,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;KAC3F;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,+BAA+B,EAAE,CAAC;KAC7C;IACD,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,+BAA+B,EAAE,CAAC;KAC7C;AACH,CAAC;AAbD,kEAaC"}
@@ -1,62 +1,62 @@
1
- import { DvelopContext } from "../../../../core/lib";
2
- import { HttpConfig, HttpResponse } from "../../utils/http";
3
- /**
4
- * User representation according to the [System for Cross-domain Identity Management (SCIM)]{@link https://tools.ietf.org/html/rfc7644}.
5
- * @category Authentication
6
- */
7
- export interface DvelopUser {
8
- /** Unique UserId */
9
- id?: string;
10
- /** Technical username */
11
- userName?: string;
12
- /** Name object containg family name and given name */
13
- name?: {
14
- familyName?: string;
15
- givenName?: string;
16
- };
17
- /** Display name assigned by the administrators */
18
- displayName?: string;
19
- /** E-Mail addesses */
20
- emails?: {
21
- value?: string;
22
- }[];
23
- /** Groups assigned to the user */
24
- groups?: {
25
- value?: string;
26
- display?: string;
27
- }[];
28
- /** Photos for the user usually provided by URL in value */
29
- photos?: {
30
- value?: string;
31
- type?: string;
32
- }[];
33
- }
34
- /**
35
- * Default transform-function provided to the {@link validateAuthSessionId}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
36
- * @internal
37
- * @category Authentication
38
- */
39
- export declare function _validateAuthSessionIdDefaultTransformFunction(response: HttpResponse, _: DvelopContext): DvelopUser;
40
- /**
41
- * Factory for the {@link validateAuthSessionId}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
42
- * @typeparam T Return type of the {@link validateAuthSessionId}-function. A corresponding transformFuntion has to be supplied.
43
- * @category Authentication
44
- */
45
- export declare function _validateAuthSessionIdFactory<T>(httpRequestFunction: (context: DvelopContext, config: HttpConfig) => Promise<HttpResponse>, transformFunction: (response: HttpResponse, context: DvelopContext) => T): (context: DvelopContext) => Promise<T>;
46
- /**
47
- * Validates an AuthSessionId and returns a {@link DvelopUser}.
48
- *
49
- * ```typescript
50
- * import { validateAuthSessionId } from "@dvelop-sdk/identityprovider";
51
- *
52
- * const user: DvelopUser = await validateAuthSessionId({
53
- * systemBaseUri: "https://monster-ag.d-velop.cloud",
54
- * authSessionId: "dQw4w9WgXcQ"
55
- * });
56
- *
57
- * console.log(user.displayName) //Mike Glotzkowski
58
- * ```
59
- * @category Authentication
60
- */
61
- export declare function validateAuthSessionId(context: DvelopContext): Promise<DvelopUser>;
1
+ import { DvelopContext } from "../../../../core/lib";
2
+ import { HttpConfig, HttpResponse } from "../../utils/http";
3
+ /**
4
+ * User representation according to the [System for Cross-domain Identity Management (SCIM)]{@link https://tools.ietf.org/html/rfc7644}.
5
+ * @category Authentication
6
+ */
7
+ export interface DvelopUser {
8
+ /** Unique UserId */
9
+ id?: string;
10
+ /** Technical username */
11
+ userName?: string;
12
+ /** Name object containg family name and given name */
13
+ name?: {
14
+ familyName?: string;
15
+ givenName?: string;
16
+ };
17
+ /** Display name assigned by the administrators */
18
+ displayName?: string;
19
+ /** E-Mail addesses */
20
+ emails?: {
21
+ value?: string;
22
+ }[];
23
+ /** Groups assigned to the user */
24
+ groups?: {
25
+ value?: string;
26
+ display?: string;
27
+ }[];
28
+ /** Photos for the user usually provided by URL in value */
29
+ photos?: {
30
+ value?: string;
31
+ type?: string;
32
+ }[];
33
+ }
34
+ /**
35
+ * Default transform-function provided to the {@link validateAuthSessionId}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
36
+ * @internal
37
+ * @category Authentication
38
+ */
39
+ export declare function _validateAuthSessionIdDefaultTransformFunction(response: HttpResponse, _: DvelopContext): DvelopUser;
40
+ /**
41
+ * Factory for the {@link validateAuthSessionId}-function. See [Advanced Topics](https://github.com/d-velop/dvelop-sdk-node#advanced-topics) for more information.
42
+ * @typeparam T Return type of the {@link validateAuthSessionId}-function. A corresponding transformFuntion has to be supplied.
43
+ * @category Authentication
44
+ */
45
+ export declare function _validateAuthSessionIdFactory<T>(httpRequestFunction: (context: DvelopContext, config: HttpConfig) => Promise<HttpResponse>, transformFunction: (response: HttpResponse, context: DvelopContext) => T): (context: DvelopContext) => Promise<T>;
46
+ /**
47
+ * Validates an AuthSessionId and returns a {@link DvelopUser}.
48
+ *
49
+ * ```typescript
50
+ * import { validateAuthSessionId } from "@dvelop-sdk/identityprovider";
51
+ *
52
+ * const user: DvelopUser = await validateAuthSessionId({
53
+ * systemBaseUri: "https://monster-ag.d-velop.cloud",
54
+ * authSessionId: "dQw4w9WgXcQ"
55
+ * });
56
+ *
57
+ * console.log(user.displayName) //Mike Glotzkowski
58
+ * ```
59
+ * @category Authentication
60
+ */
61
+ export declare function validateAuthSessionId(context: DvelopContext): Promise<DvelopUser>;
62
62
  //# sourceMappingURL=validate-auth-session-id.d.ts.map
@@ -1,101 +1,101 @@
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.validateAuthSessionId = exports._validateAuthSessionIdFactory = exports._validateAuthSessionIdDefaultTransformFunction = void 0;
40
- var http_1 = require("../../utils/http");
41
- /**
42
- * Default transform-function provided to the {@link validateAuthSessionId}-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 _validateAuthSessionIdDefaultTransformFunction(response, _) {
47
- return response.data;
48
- }
49
- exports._validateAuthSessionIdDefaultTransformFunction = _validateAuthSessionIdDefaultTransformFunction;
50
- /**
51
- * Factory for the {@link validateAuthSessionId}-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 validateAuthSessionId}-function. A corresponding transformFuntion has to be supplied.
53
- * @category Authentication
54
- */
55
- function _validateAuthSessionIdFactory(httpRequestFunction, transformFunction) {
56
- var _this = this;
57
- return function (context) { return __awaiter(_this, void 0, void 0, function () {
58
- var response;
59
- return __generator(this, function (_a) {
60
- switch (_a.label) {
61
- case 0: return [4 /*yield*/, httpRequestFunction(context, {
62
- method: "GET",
63
- url: "/identityprovider",
64
- follows: ["validate"]
65
- })];
66
- case 1:
67
- response = _a.sent();
68
- return [2 /*return*/, transformFunction(response, context)];
69
- }
70
- });
71
- }); };
72
- }
73
- exports._validateAuthSessionIdFactory = _validateAuthSessionIdFactory;
74
- /**
75
- * Validates an AuthSessionId and returns a {@link DvelopUser}.
76
- *
77
- * ```typescript
78
- * import { validateAuthSessionId } from "@dvelop-sdk/identityprovider";
79
- *
80
- * const user: DvelopUser = await validateAuthSessionId({
81
- * systemBaseUri: "https://monster-ag.d-velop.cloud",
82
- * authSessionId: "dQw4w9WgXcQ"
83
- * });
84
- *
85
- * console.log(user.displayName) //Mike Glotzkowski
86
- * ```
87
- * @category Authentication
88
- */
89
- /* istanbul ignore next */
90
- function validateAuthSessionId(context) {
91
- return __awaiter(this, void 0, void 0, function () {
92
- return __generator(this, function (_a) {
93
- switch (_a.label) {
94
- case 0: return [4 /*yield*/, _validateAuthSessionIdFactory(http_1._defaultHttpRequestFunction, _validateAuthSessionIdDefaultTransformFunction)(context)];
95
- case 1: return [2 /*return*/, _a.sent()];
96
- }
97
- });
98
- });
99
- }
100
- exports.validateAuthSessionId = validateAuthSessionId;
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.validateAuthSessionId = exports._validateAuthSessionIdFactory = exports._validateAuthSessionIdDefaultTransformFunction = void 0;
40
+ var http_1 = require("../../utils/http");
41
+ /**
42
+ * Default transform-function provided to the {@link validateAuthSessionId}-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 _validateAuthSessionIdDefaultTransformFunction(response, _) {
47
+ return response.data;
48
+ }
49
+ exports._validateAuthSessionIdDefaultTransformFunction = _validateAuthSessionIdDefaultTransformFunction;
50
+ /**
51
+ * Factory for the {@link validateAuthSessionId}-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 validateAuthSessionId}-function. A corresponding transformFuntion has to be supplied.
53
+ * @category Authentication
54
+ */
55
+ function _validateAuthSessionIdFactory(httpRequestFunction, transformFunction) {
56
+ var _this = this;
57
+ return function (context) { return __awaiter(_this, void 0, void 0, function () {
58
+ var response;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0: return [4 /*yield*/, httpRequestFunction(context, {
62
+ method: "GET",
63
+ url: "/identityprovider",
64
+ follows: ["validate"]
65
+ })];
66
+ case 1:
67
+ response = _a.sent();
68
+ return [2 /*return*/, transformFunction(response, context)];
69
+ }
70
+ });
71
+ }); };
72
+ }
73
+ exports._validateAuthSessionIdFactory = _validateAuthSessionIdFactory;
74
+ /**
75
+ * Validates an AuthSessionId and returns a {@link DvelopUser}.
76
+ *
77
+ * ```typescript
78
+ * import { validateAuthSessionId } from "@dvelop-sdk/identityprovider";
79
+ *
80
+ * const user: DvelopUser = await validateAuthSessionId({
81
+ * systemBaseUri: "https://monster-ag.d-velop.cloud",
82
+ * authSessionId: "dQw4w9WgXcQ"
83
+ * });
84
+ *
85
+ * console.log(user.displayName) //Mike Glotzkowski
86
+ * ```
87
+ * @category Authentication
88
+ */
89
+ /* istanbul ignore next */
90
+ function validateAuthSessionId(context) {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0: return [4 /*yield*/, _validateAuthSessionIdFactory(http_1._defaultHttpRequestFunction, _validateAuthSessionIdDefaultTransformFunction)(context)];
95
+ case 1: return [2 /*return*/, _a.sent()];
96
+ }
97
+ });
98
+ });
99
+ }
100
+ exports.validateAuthSessionId = validateAuthSessionId;
101
101
  //# sourceMappingURL=validate-auth-session-id.js.map
package/lib/index.d.ts CHANGED
@@ -1,41 +1,41 @@
1
- /**
2
- <div align="center">
3
- <h1>@dvelop-sdk/identityprovider</h1>
4
- <a href="https://www.npmjs.com/package/@dvelop-sdk/identityprovider">
5
- <img alt="npm (scoped)" src="https://img.shields.io/npm/v/@dvelop-sdk/identityprovider?style=for-the-badge">
6
- </a>
7
- <a href="https://www.npmjs.com/package/@dvelop-sdk/identityprovider">
8
- <img alt="npm bundle size (scoped)" src="https://img.shields.io/bundlephobia/min/@dvelop-sdk/identityprovider?style=for-the-badge">
9
- </a>
10
- <a href="https://github.com/d-velop/dvelop-sdk-node">
11
- <img alt="GitHub" src="https://img.shields.io/badge/GitHub-dvelop--sdk--node-%23ff0844?logo=github&style=for-the-badge">
12
- </a>
13
- <a href="https://github.com/d-velop/dvelop-sdk-node/blob/master/LICENSE">
14
- <img alt="license" src="https://img.shields.io/github/license/d-velop/dvelop-sdk-node?style=for-the-badge">
15
- </a
16
- </br>
17
- <p>This package contains functionality for the <a href="https://developer.d-velop.de/documentation/idpapi/en/identityprovider-app-201523580.html">Identityprovider-App</a> in the d.velop cloud.</p>
18
- <a href="https://d-velop.github.io/dvelop-sdk-node/modules/identityprovider.html"><strong>Explore the docs »</strong></a>
19
- </br>
20
- <a href="https://www.npmjs.com/package/@dvelop-sdk/identityprovider"><strong>Install via npm »</strong></a>
21
- </br>
22
- <a href="https://github.com/d-velop/dvelop-sdk-node"><strong>Check us out on GitHub »</strong></a>
23
- </div>
24
- * @module identityprovider
25
- */
26
- import { DvelopUser } from "./authentication/validate-auth-session-id/validate-auth-session-id";
27
- declare module "@dvelop-sdk/core" {
28
- interface DvelopContext {
29
- user?: DvelopUser;
30
- }
31
- }
32
- export { DvelopContext, BadInputError, UnauthorizedError, ForbiddenError, NotFoundError } from "@dvelop-sdk/core";
33
- export { IdentityproviderError } from "./utils/http";
34
- export * as internals from "./internal";
35
- export { getAuthSession } from "./authentication/get-auth-session/get-auth-session";
36
- export { GetImpersonatedAuthSessionIdParams, getImpersonatedAuthSessionId } from "./authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id";
37
- export { RequestAppSessionParams, requestAppSession, AppSession } from "./authentication/request-app-session/request-app-session";
38
- export { getLoginRedirectionUri } from "./authentication/get-login-redirection-uri/get-login-redirection-uri";
39
- export { validateAppSessionSignature, InvalidAppSessionSignatureError } from "./authentication/validate-app-session-signature/validate-app-session-signature";
40
- export { validateAuthSessionId, DvelopUser } from "./authentication/validate-auth-session-id/validate-auth-session-id";
1
+ /**
2
+ <div align="center">
3
+ <h1>@dvelop-sdk/identityprovider</h1>
4
+ <a href="https://www.npmjs.com/package/@dvelop-sdk/identityprovider">
5
+ <img alt="npm (scoped)" src="https://img.shields.io/npm/v/@dvelop-sdk/identityprovider?style=for-the-badge">
6
+ </a>
7
+ <a href="https://www.npmjs.com/package/@dvelop-sdk/identityprovider">
8
+ <img alt="npm bundle size (scoped)" src="https://img.shields.io/bundlephobia/min/@dvelop-sdk/identityprovider?style=for-the-badge">
9
+ </a>
10
+ <a href="https://github.com/d-velop/dvelop-sdk-node">
11
+ <img alt="GitHub" src="https://img.shields.io/badge/GitHub-dvelop--sdk--node-%23ff0844?logo=github&style=for-the-badge">
12
+ </a>
13
+ <a href="https://github.com/d-velop/dvelop-sdk-node/blob/master/LICENSE">
14
+ <img alt="license" src="https://img.shields.io/github/license/d-velop/dvelop-sdk-node?style=for-the-badge">
15
+ </a
16
+ </br>
17
+ <p>This package contains functionality for the <a href="https://developer.d-velop.de/documentation/idpapi/en/identityprovider-app-201523580.html">Identityprovider-App</a> in the d.velop cloud.</p>
18
+ <a href="https://d-velop.github.io/dvelop-sdk-node/modules/identityprovider.html"><strong>Explore the docs »</strong></a>
19
+ </br>
20
+ <a href="https://www.npmjs.com/package/@dvelop-sdk/identityprovider"><strong>Install via npm »</strong></a>
21
+ </br>
22
+ <a href="https://github.com/d-velop/dvelop-sdk-node"><strong>Check us out on GitHub »</strong></a>
23
+ </div>
24
+ * @module identityprovider
25
+ */
26
+ import { DvelopUser } from "./authentication/validate-auth-session-id/validate-auth-session-id";
27
+ declare module "@dvelop-sdk/core" {
28
+ interface DvelopContext {
29
+ user?: DvelopUser;
30
+ }
31
+ }
32
+ export { DvelopContext, BadInputError, UnauthorizedError, ForbiddenError, NotFoundError } from "@dvelop-sdk/core";
33
+ export { IdentityproviderError } from "./utils/http";
34
+ export * as internals from "./internal";
35
+ export { getAuthSession } from "./authentication/get-auth-session/get-auth-session";
36
+ export { GetImpersonatedAuthSessionIdParams, getImpersonatedAuthSessionId } from "./authentication/get-impersonated-auth-session-id/get-impersonated-auth-session-id";
37
+ export { RequestAppSessionParams, requestAppSession } from "./authentication/request-app-session/request-app-session";
38
+ export { getLoginRedirectionUri } from "./authentication/get-login-redirection-uri/get-login-redirection-uri";
39
+ export { AppSession, validateAppSessionSignature, InvalidAppSessionSignatureError } from "./authentication/validate-app-session-signature/validate-app-session-signature";
40
+ export { validateAuthSessionId, DvelopUser } from "./authentication/validate-auth-session-id/validate-auth-session-id";
41
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oEAAoE,CAAC;AAEhG,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,aAAa;QACrB,IAAI,CAAC,EAAE,UAAU,CAAA;KAClB;CACF;AAGD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AACpF,OAAO,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AACtK,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,0DAA0D,CAAC;AAClI,OAAO,EAAE,sBAAsB,EAAE,MAAM,sEAAsE,CAAC;AAC9G,OAAO,EAAE,2BAA2B,EAAE,+BAA+B,EAAE,MAAM,gFAAgF,CAAC;AAC9J,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,oEAAoE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oEAAoE,CAAC;AAEhG,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,aAAa;QACrB,IAAI,CAAC,EAAE,UAAU,CAAA;KAClB;CACF;AAGD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AACpF,OAAO,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AACtK,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAC;AACtH,OAAO,EAAE,sBAAsB,EAAE,MAAM,sEAAsE,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,2BAA2B,EAAE,+BAA+B,EAAE,MAAM,gFAAgF,CAAC;AAC1K,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,oEAAoE,CAAC"}