hcloud-sdk 0.0.16 → 15.0.0
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 -0
- package/changelog.md +45 -0
- package/index.d.ts +3 -2
- package/index.js +5 -2
- package/lib/Base.d.ts +26 -0
- package/lib/Base.js +12 -0
- package/lib/Hcloud.d.ts +90 -0
- package/lib/Hcloud.js +184 -0
- package/lib/helper/ErrorHelper.d.ts +7 -0
- package/lib/helper/ErrorHelper.js +19 -0
- package/lib/helper/paginatedResponseHelper.d.ts +3 -0
- package/lib/helper/paginatedResponseHelper.js +9 -0
- package/lib/helper/searchFilter.d.ts +9 -0
- package/lib/helper/searchFilter.js +12 -0
- package/lib/interfaces/agent/bundle/dev/index.d.ts +3 -0
- package/lib/interfaces/agent/context/index.d.ts +19 -0
- package/lib/interfaces/agent/index.d.ts +21 -0
- package/lib/interfaces/agent/index.js +2 -0
- package/lib/interfaces/{Auditor.d.ts → auditor/index.d.ts} +31 -5
- package/lib/interfaces/{Auditor.js → auditor/index.js} +15 -5
- package/lib/interfaces/axios/index.d.ts +5 -0
- package/lib/interfaces/axios/index.js +8 -0
- package/lib/interfaces/bouncer/features/index.d.ts +7 -0
- package/lib/interfaces/bouncer/features/index.js +2 -0
- package/lib/interfaces/bouncer/index.d.ts +6 -0
- package/lib/interfaces/bouncer/index.js +17 -0
- package/lib/interfaces/dali/index.d.ts +3 -0
- package/lib/interfaces/dali/index.js +2 -0
- package/lib/interfaces/frontend/config/index.d.ts +33 -0
- package/lib/interfaces/frontend/config/index.js +10 -0
- package/lib/interfaces/frontend/featureflags/index.d.ts +7 -0
- package/lib/interfaces/frontend/featureflags/index.js +2 -0
- package/lib/interfaces/fuse/index.d.ts +3 -0
- package/lib/interfaces/fuse/index.js +19 -0
- package/lib/interfaces/fuse/space/cronjob/Cronjob.d.ts +38 -0
- package/lib/interfaces/fuse/space/cronjob/Cronjob.js +8 -0
- package/lib/interfaces/fuse/space/cronjob/CronjobLog.d.ts +16 -0
- package/lib/interfaces/fuse/space/cronjob/CronjobLog.js +2 -0
- package/lib/interfaces/fuse/space/index.d.ts +21 -0
- package/lib/interfaces/fuse/space/index.js +11 -0
- package/lib/interfaces/global/HCloudError.d.ts +8 -0
- package/lib/interfaces/global/HCloudError.js +13 -0
- package/lib/interfaces/global/Header.d.ts +4 -0
- package/lib/interfaces/global/Header.js +2 -0
- package/lib/interfaces/global/HttpMethod.d.ts +7 -0
- package/lib/interfaces/global/HttpMethod.js +11 -0
- package/lib/interfaces/global/PaginatedResponse.d.ts +4 -0
- package/lib/interfaces/global/PaginatedResponse.js +2 -0
- package/lib/interfaces/global/Products.d.ts +11 -0
- package/lib/interfaces/global/Products.js +15 -0
- package/lib/interfaces/global/SearchFilters.d.ts +86 -0
- package/lib/interfaces/global/SearchFilters.js +49 -0
- package/lib/interfaces/global/Space.d.ts +20 -0
- package/lib/interfaces/global/Space.js +8 -0
- package/lib/interfaces/global/Version.d.ts +3 -0
- package/lib/interfaces/global/Version.js +2 -0
- package/lib/interfaces/global/Views.d.ts +8 -0
- package/lib/interfaces/global/Views.js +12 -0
- package/lib/interfaces/global/index.d.ts +9 -0
- package/lib/interfaces/global/index.js +25 -0
- package/lib/interfaces/high5/index.d.ts +16 -0
- package/lib/interfaces/high5/index.js +32 -0
- package/lib/interfaces/high5/joinToken/index.d.ts +10 -0
- package/lib/interfaces/high5/joinToken/index.js +2 -0
- package/lib/interfaces/high5/space/event/index.d.ts +15 -0
- package/lib/interfaces/high5/space/event/index.js +2 -0
- package/lib/interfaces/high5/space/event/stream/design/DesignOperation.d.ts +68 -0
- package/lib/interfaces/high5/space/event/stream/design/DesignOperation.js +20 -0
- package/lib/interfaces/high5/space/event/stream/design/StreamDesign.d.ts +92 -0
- package/lib/interfaces/high5/space/event/stream/design/StreamDesign.js +20 -0
- package/lib/interfaces/high5/space/event/stream/design/index.d.ts +22 -0
- package/lib/interfaces/high5/space/event/stream/design/index.js +2 -0
- package/lib/interfaces/high5/space/event/stream/design/snapshot/index.d.ts +30 -0
- package/lib/interfaces/high5/space/event/stream/design/snapshot/index.js +8 -0
- package/lib/interfaces/high5/space/event/stream/index.d.ts +77 -0
- package/lib/interfaces/high5/space/event/stream/index.js +13 -0
- package/lib/interfaces/high5/space/event/stream/node/index.d.ts +62 -0
- package/lib/interfaces/high5/space/event/stream/node/index.js +7 -0
- package/lib/interfaces/high5/space/execution/index.d.ts +148 -0
- package/lib/interfaces/high5/space/execution/index.js +21 -0
- package/lib/interfaces/high5/space/index.d.ts +23 -0
- package/lib/interfaces/high5/space/index.js +12 -0
- package/lib/interfaces/high5/space/secret/index.d.ts +12 -0
- package/lib/interfaces/high5/space/secret/index.js +2 -0
- package/lib/interfaces/high5/space/webhook/index.d.ts +75 -0
- package/lib/interfaces/high5/space/webhook/index.js +9 -0
- package/lib/interfaces/high5/wave/changelog.d.ts +30 -0
- package/lib/interfaces/high5/wave/changelog.js +18 -0
- package/lib/interfaces/high5/wave/index.d.ts +201 -0
- package/lib/interfaces/high5/wave/index.js +61 -0
- package/lib/interfaces/idp/index.d.ts +26 -0
- package/lib/interfaces/idp/index.js +38 -0
- package/lib/interfaces/idp/oauth/index.d.ts +19 -0
- package/lib/interfaces/idp/oauth/index.js +8 -0
- package/lib/interfaces/idp/organization/index.d.ts +32 -0
- package/lib/interfaces/idp/organization/index.js +25 -0
- package/lib/interfaces/idp/organization/license/index.d.ts +84 -0
- package/lib/interfaces/idp/organization/license/index.js +15 -0
- package/lib/interfaces/idp/organization/member/index.d.ts +15 -0
- package/lib/interfaces/idp/organization/member/index.js +2 -0
- package/lib/interfaces/idp/organization/member/invitations/index.d.ts +26 -0
- package/lib/interfaces/idp/organization/member/invitations/index.js +18 -0
- package/lib/interfaces/idp/organization/settings/domain/index.d.ts +19 -0
- package/lib/interfaces/idp/organization/settings/domain/index.js +8 -0
- package/lib/interfaces/idp/organization/settings/domain/saml/index.d.ts +10 -0
- package/lib/interfaces/idp/organization/settings/domain/saml/index.js +2 -0
- package/lib/interfaces/idp/organization/settings/oauthApp/index.d.ts +37 -0
- package/lib/interfaces/idp/organization/settings/oauthApp/index.js +2 -0
- package/lib/interfaces/idp/organization/team/index.d.ts +24 -0
- package/lib/interfaces/idp/organization/team/index.js +9 -0
- package/lib/interfaces/idp/user/ConnectionSettings.d.ts +6 -0
- package/lib/interfaces/idp/user/ConnectionSettings.js +2 -0
- package/lib/interfaces/idp/user/GeneralSettings.d.ts +45 -0
- package/lib/interfaces/idp/user/GeneralSettings.js +38 -0
- package/lib/interfaces/idp/user/NotificationSettings.d.ts +8 -0
- package/lib/interfaces/idp/user/NotificationSettings.js +2 -0
- package/lib/interfaces/idp/user/Pat.d.ts +19 -0
- package/lib/interfaces/idp/user/Pat.js +2 -0
- package/lib/interfaces/idp/user/Scopes.d.ts +40 -0
- package/lib/interfaces/idp/user/Scopes.js +50 -0
- package/lib/interfaces/idp/user/SuccessfulAuth.d.ts +5 -0
- package/lib/interfaces/idp/user/SuccessfulAuth.js +2 -0
- package/lib/interfaces/idp/user/Totp.d.ts +20 -0
- package/lib/interfaces/idp/user/Totp.js +2 -0
- package/lib/interfaces/idp/user/index.d.ts +23 -0
- package/lib/interfaces/idp/user/index.js +2 -0
- package/lib/interfaces/mailer/index.d.ts +66 -0
- package/lib/interfaces/mailer/index.js +81 -0
- package/lib/interfaces/mothership/index.d.ts +28 -0
- package/lib/interfaces/mothership/index.js +8 -0
- package/lib/interfaces/nats/index.d.ts +239 -0
- package/lib/interfaces/nats/index.js +316 -0
- package/lib/service/agent/bundle/dev/index.d.ts +17 -0
- package/lib/service/agent/bundle/dev/index.js +44 -0
- package/lib/service/agent/bundle/index.d.ts +11 -0
- package/lib/service/agent/bundle/index.js +55 -0
- package/lib/service/agent/context/index.d.ts +35 -0
- package/lib/service/agent/context/index.js +90 -0
- package/lib/service/agent/index.d.ts +16 -0
- package/lib/service/agent/index.js +37 -0
- package/lib/service/agent/installer/index.d.ts +15 -0
- package/lib/service/agent/installer/index.js +97 -0
- package/lib/service/auditor/index.d.ts +25 -0
- package/lib/service/auditor/index.js +55 -0
- package/lib/service/auditor/internal/index.d.ts +27 -0
- package/lib/service/auditor/internal/index.js +65 -0
- package/lib/service/bouncer/features/index.d.ts +8 -0
- package/lib/service/bouncer/features/index.js +27 -0
- package/lib/service/bouncer/index.d.ts +7 -0
- package/lib/service/bouncer/index.js +16 -0
- package/lib/service/dali/DaliAvatar.d.ts +40 -0
- package/lib/service/dali/DaliAvatar.js +70 -0
- package/lib/service/dali/avatar/DaliFuseSpace.d.ts +26 -0
- package/lib/service/dali/avatar/DaliFuseSpace.js +58 -0
- package/lib/service/dali/avatar/DaliHigh5Space.d.ts +26 -0
- package/lib/service/dali/avatar/DaliHigh5Space.js +58 -0
- package/lib/service/dali/avatar/DaliOAuthApp.d.ts +26 -0
- package/lib/service/dali/avatar/DaliOAuthApp.js +58 -0
- package/lib/service/dali/avatar/DaliOrganization.d.ts +23 -0
- package/lib/service/dali/avatar/DaliOrganization.js +55 -0
- package/lib/service/dali/avatar/DaliTeam.d.ts +26 -0
- package/lib/service/dali/avatar/DaliTeam.js +58 -0
- package/lib/service/dali/avatar/DaliUser.d.ts +20 -0
- package/lib/service/dali/avatar/DaliUser.js +52 -0
- package/lib/service/dali/index.d.ts +15 -0
- package/lib/service/dali/index.js +37 -0
- package/lib/service/fuse/index.d.ts +18 -0
- package/lib/service/fuse/index.js +48 -0
- package/lib/service/fuse/internal/index.d.ts +8 -0
- package/lib/service/fuse/internal/index.js +31 -0
- package/lib/service/fuse/internal/space/cronjob/index.d.ts +7 -0
- package/lib/service/fuse/internal/space/cronjob/index.js +17 -0
- package/lib/service/fuse/internal/space/cronjob/log/index.d.ts +15 -0
- package/lib/service/fuse/internal/space/cronjob/log/index.js +34 -0
- package/lib/service/fuse/internal/space/index.d.ts +22 -0
- package/lib/service/fuse/internal/space/index.js +49 -0
- package/lib/service/fuse/space/cronjob/index.d.ts +123 -0
- package/lib/service/fuse/space/cronjob/index.js +203 -0
- package/lib/service/fuse/space/cronjob/log/index.d.ts +31 -0
- package/lib/service/fuse/space/cronjob/log/index.js +58 -0
- package/lib/service/fuse/space/index.d.ts +81 -0
- package/lib/service/fuse/space/index.js +152 -0
- package/lib/service/high5/execution/index.d.ts +10 -0
- package/lib/service/high5/execution/index.js +24 -0
- package/lib/service/high5/execution/log/index.d.ts +19 -0
- package/lib/service/high5/execution/log/index.js +40 -0
- package/lib/service/high5/execution/status/index.d.ts +18 -0
- package/lib/service/high5/execution/status/index.js +40 -0
- package/lib/service/high5/index.d.ts +25 -0
- package/lib/service/high5/index.js +63 -0
- package/lib/service/high5/internal/index.d.ts +8 -0
- package/lib/service/high5/internal/index.js +31 -0
- package/lib/service/high5/internal/space/index.d.ts +21 -0
- package/lib/service/high5/internal/space/index.js +45 -0
- package/lib/service/high5/joinToken/index.d.ts +40 -0
- package/lib/service/high5/joinToken/index.js +72 -0
- package/lib/service/high5/space/event/index.d.ts +55 -0
- package/lib/service/high5/space/event/index.js +101 -0
- package/lib/service/high5/space/event/stream/design/DesignOperations.d.ts +31 -0
- package/lib/service/high5/space/event/stream/design/DesignOperations.js +117 -0
- package/lib/service/high5/space/event/stream/design/index.d.ts +53 -0
- package/lib/service/high5/space/event/stream/design/index.js +91 -0
- package/lib/service/high5/space/event/stream/design/snapshot/index.d.ts +62 -0
- package/lib/service/high5/space/event/stream/design/snapshot/index.js +107 -0
- package/lib/service/high5/space/event/stream/index.d.ts +113 -0
- package/lib/service/high5/space/event/stream/index.js +186 -0
- package/lib/service/high5/space/execution/index.d.ts +48 -0
- package/lib/service/high5/space/execution/index.js +89 -0
- package/lib/service/high5/space/execution/log/index.d.ts +29 -0
- package/lib/service/high5/space/execution/log/index.js +58 -0
- package/lib/service/high5/space/execution/status/index.d.ts +16 -0
- package/lib/service/high5/space/execution/status/index.js +36 -0
- package/lib/service/high5/space/index.d.ts +111 -0
- package/lib/service/high5/space/index.js +205 -0
- package/lib/service/high5/space/node/index.d.ts +58 -0
- package/lib/service/high5/space/node/index.js +116 -0
- package/lib/service/high5/space/secret/index.d.ts +60 -0
- package/lib/service/high5/space/secret/index.js +102 -0
- package/lib/service/high5/space/wave/index.d.ts +36 -0
- package/lib/service/high5/space/wave/index.js +73 -0
- package/lib/service/high5/space/webhook/index.d.ts +90 -0
- package/lib/service/high5/space/webhook/index.js +165 -0
- package/lib/service/high5/space/webhook/log/index.d.ts +16 -0
- package/lib/service/high5/space/webhook/log/index.js +37 -0
- package/lib/service/high5/wave/index.d.ts +8 -0
- package/lib/service/high5/wave/index.js +15 -0
- package/lib/service/high5/wave/s3/index.d.ts +48 -0
- package/lib/service/high5/wave/s3/index.js +100 -0
- package/lib/service/idp/index.d.ts +84 -0
- package/lib/service/idp/index.js +185 -0
- package/lib/service/idp/internal/index.d.ts +17 -0
- package/lib/service/idp/internal/index.js +33 -0
- package/lib/service/idp/oauth/index.d.ts +49 -0
- package/lib/service/idp/oauth/index.js +117 -0
- package/lib/service/idp/organization/index.d.ts +56 -0
- package/lib/service/idp/organization/index.js +114 -0
- package/lib/service/idp/organization/license/index.d.ts +7 -0
- package/lib/service/idp/organization/license/index.js +31 -0
- package/lib/service/idp/organization/member/index.d.ts +57 -0
- package/lib/service/idp/organization/member/index.js +110 -0
- package/lib/service/idp/organization/member/invitations/index.d.ts +79 -0
- package/lib/service/idp/organization/member/invitations/index.js +122 -0
- package/lib/service/idp/organization/settings/domain/index.d.ts +37 -0
- package/lib/service/idp/organization/settings/domain/index.js +76 -0
- package/lib/service/idp/organization/settings/domain/saml/index.d.ts +43 -0
- package/lib/service/idp/organization/settings/domain/saml/index.js +98 -0
- package/lib/service/idp/organization/settings/index.d.ts +16 -0
- package/lib/service/idp/organization/settings/index.js +29 -0
- package/lib/service/idp/organization/settings/oauth/index.d.ts +62 -0
- package/lib/service/idp/organization/settings/oauth/index.js +117 -0
- package/lib/service/idp/organization/team/index.d.ts +72 -0
- package/lib/service/idp/organization/team/index.js +124 -0
- package/lib/service/idp/registration/index.d.ts +37 -0
- package/lib/service/idp/registration/index.js +87 -0
- package/lib/service/idp/user/index.d.ts +83 -0
- package/lib/service/idp/user/index.js +160 -0
- package/lib/service/idp/user/license/index.d.ts +7 -0
- package/lib/service/idp/user/license/index.js +31 -0
- package/lib/service/idp/user/password/index.d.ts +19 -0
- package/lib/service/idp/user/password/index.js +51 -0
- package/lib/service/idp/user/settings/connections/index.d.ts +13 -0
- package/lib/service/idp/user/settings/connections/index.js +32 -0
- package/lib/service/idp/user/settings/general/index.d.ts +22 -0
- package/lib/service/idp/user/settings/general/index.js +51 -0
- package/lib/service/idp/user/settings/index.d.ts +40 -0
- package/lib/service/idp/user/settings/index.js +70 -0
- package/lib/service/idp/user/settings/notifications/index.d.ts +16 -0
- package/lib/service/idp/user/settings/notifications/index.js +40 -0
- package/lib/service/idp/user/settings/oauthApps/index.d.ts +20 -0
- package/lib/service/idp/user/settings/oauthApps/index.js +55 -0
- package/lib/service/idp/user/settings/pats/index.d.ts +48 -0
- package/lib/service/idp/user/settings/pats/index.js +104 -0
- package/lib/service/idp/user/settings/twoFactor/index.d.ts +10 -0
- package/lib/service/idp/user/settings/twoFactor/index.js +20 -0
- package/lib/service/idp/user/settings/twoFactor/totp/index.d.ts +32 -0
- package/lib/service/idp/user/settings/twoFactor/totp/index.js +72 -0
- package/lib/service/mailer/index.d.ts +13 -0
- package/lib/service/{Mailer.js → mailer/index.js} +17 -16
- package/lib/service/mailer/internal/index.d.ts +36 -0
- package/lib/service/mailer/internal/index.js +69 -0
- package/lib/service/mothership/index.d.ts +97 -0
- package/lib/service/mothership/index.js +149 -0
- package/lib/service/nats/index.d.ts +49 -0
- package/lib/service/nats/index.js +138 -0
- package/lib/utils/Types.d.ts +1 -0
- package/lib/utils/Types.js +2 -0
- package/lib/utils/bouncer/features/Provider.d.ts +19 -0
- package/lib/utils/bouncer/features/Provider.js +101 -0
- package/package.json +37 -29
- package/lib/base.d.ts +0 -12
- package/lib/base.js +0 -8
- package/lib/hcloud.d.ts +0 -13
- package/lib/hcloud.js +0 -29
- package/lib/interfaces/Global.d.ts +0 -8
- package/lib/interfaces/IDP.d.ts +0 -9
- package/lib/interfaces/Mail.d.ts +0 -29
- package/lib/interfaces/Mail.js +0 -8
- package/lib/service/Auditor.d.ts +0 -22
- package/lib/service/Auditor.js +0 -61
- package/lib/service/AuditorInternal.d.ts +0 -28
- package/lib/service/AuditorInternal.js +0 -65
- package/lib/service/High5.d.ts +0 -4
- package/lib/service/High5.js +0 -9
- package/lib/service/IDP.d.ts +0 -39
- package/lib/service/IDP.js +0 -84
- package/lib/service/Mailer.d.ts +0 -13
- package/lib/service/MailerInternal.d.ts +0 -32
- package/lib/service/MailerInternal.js +0 -64
- /package/lib/interfaces/{Global.js → agent/bundle/dev/index.js} +0 -0
- /package/lib/interfaces/{IDP.js → agent/context/index.js} +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.S3 = void 0;
|
|
13
|
+
const Base_1 = require("../../../../Base");
|
|
14
|
+
const axios_1 = require("../../../../interfaces/axios");
|
|
15
|
+
/**
|
|
16
|
+
* Class for reading the S3 bucket of a wave engine and catalogs
|
|
17
|
+
*/
|
|
18
|
+
class S3 extends Base_1.default {
|
|
19
|
+
constructor(options, axios) {
|
|
20
|
+
super(options, axios);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the registry.json of the default wave catalog from the S3 bucket
|
|
24
|
+
* @param waveBucketUrl Public base url to S3 bucket
|
|
25
|
+
* @returns registry.json
|
|
26
|
+
*/
|
|
27
|
+
getCatalogRegistry(waveBucketUrl) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const resp = yield this.axios.get(`${waveBucketUrl}/catalogs/registry.json`, { headers: axios_1.disableCacheHeaders });
|
|
30
|
+
return resp.data;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the registry.json of the default wave engine from the S3 bucket
|
|
35
|
+
* @param waveBucketUrl Public base url to S3 bucket
|
|
36
|
+
* @returns registry.json
|
|
37
|
+
*/
|
|
38
|
+
getEngineRegistry(waveBucketUrl) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const resp = yield this.axios.get(`${waveBucketUrl}/engines/registry.json`, { headers: axios_1.disableCacheHeaders });
|
|
41
|
+
return resp.data;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the catalog.json from the S3 bucket
|
|
46
|
+
* @param catalogUrl Public url of the catalog
|
|
47
|
+
* @returns index.json of catalog
|
|
48
|
+
*/
|
|
49
|
+
getCatalog(catalogUrl) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const resp = yield this.axios.get(`${catalogUrl}`, { headers: axios_1.disableCacheHeaders });
|
|
52
|
+
return resp.data;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the catalog.json from the S3 bucket
|
|
57
|
+
* @param catalogUrl Public url of the catalog
|
|
58
|
+
* @returns index.json of catalog
|
|
59
|
+
*/
|
|
60
|
+
getEngine(engineUrl) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const resp = yield this.axios.get(`${engineUrl}`, { headers: axios_1.disableCacheHeaders });
|
|
63
|
+
return resp.data;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the node specifications of all nodes of a specific catalog version from the S3 bucket
|
|
68
|
+
* @param catalogUrl Public url of the catalog
|
|
69
|
+
* @param version The catalog version
|
|
70
|
+
* @returns StreamNodeSpecification[] | StreamNodeSpecificationWrappedWithEngineVersion an array of all node specification of that catalog version, maybe wrapped in an object with the engine version
|
|
71
|
+
*/
|
|
72
|
+
getCatalogVersion(catalogUrl, version) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const specificationUrl = catalogUrl.split("/").slice(0, -1).join("/") + "/" + version + "/specification.json";
|
|
75
|
+
const resp = yield this.axios.get(specificationUrl, {
|
|
76
|
+
headers: axios_1.disableCacheHeaders,
|
|
77
|
+
});
|
|
78
|
+
return resp.data;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the node documentation from the S3 bucket
|
|
83
|
+
* @param catalogUrl Public url of the catalog
|
|
84
|
+
* @param version The catalog version
|
|
85
|
+
* @returns string the markdown documentation of the node
|
|
86
|
+
*/
|
|
87
|
+
getNodeDocumentation(catalogUrl, version, nodeName) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const specificationUrl = catalogUrl.split("/").slice(0, -1).join("/") + `/${version}/docs/${nodeName}.md`;
|
|
90
|
+
const resp = yield this.axios.get(specificationUrl).catch(err => {
|
|
91
|
+
throw new Error(`Node documentation not found: ${err}`);
|
|
92
|
+
});
|
|
93
|
+
return resp.data;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
getEndpoint() {
|
|
97
|
+
throw new Error("Method not implemented.");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.S3 = S3;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import Base from "../../Base";
|
|
2
|
+
import { Version } from "../../interfaces/global";
|
|
3
|
+
import { PreLoginResponse } from "../../interfaces/idp";
|
|
4
|
+
import { SuccessfulAuth } from "../../interfaces/idp/user/SuccessfulAuth";
|
|
5
|
+
import { IdpInternal } from "./internal";
|
|
6
|
+
import { IdpOAuth } from "./oauth";
|
|
7
|
+
import { IdpOrganization } from "./organization";
|
|
8
|
+
import { IdpRegistration } from "./registration";
|
|
9
|
+
import { IdpUser } from "./user";
|
|
10
|
+
export default class Idp extends Base {
|
|
11
|
+
/**
|
|
12
|
+
* Handles everything around organizations
|
|
13
|
+
*/
|
|
14
|
+
get organization(): IdpOrganization;
|
|
15
|
+
private _organization?;
|
|
16
|
+
/**
|
|
17
|
+
* Handles everything around registration
|
|
18
|
+
*/
|
|
19
|
+
get registration(): IdpRegistration;
|
|
20
|
+
private _registration?;
|
|
21
|
+
/**
|
|
22
|
+
* Handles everything around open authorization and openId requests
|
|
23
|
+
*/
|
|
24
|
+
get oAuth(): IdpOAuth;
|
|
25
|
+
private _oAuth?;
|
|
26
|
+
/**
|
|
27
|
+
* Handles everything around a user
|
|
28
|
+
*/
|
|
29
|
+
get user(): IdpUser;
|
|
30
|
+
private _user?;
|
|
31
|
+
/**
|
|
32
|
+
* Handles everything around idp's internal endpoints
|
|
33
|
+
*/
|
|
34
|
+
get internal(): IdpInternal;
|
|
35
|
+
private _internal?;
|
|
36
|
+
/**
|
|
37
|
+
* Requests the endpoint version
|
|
38
|
+
* @returns Version object
|
|
39
|
+
*/
|
|
40
|
+
version(): Promise<Version>;
|
|
41
|
+
/**
|
|
42
|
+
* Authenticates against the identity provider with a given email and password.
|
|
43
|
+
* @param email Email of the user
|
|
44
|
+
* @param password Password of the user
|
|
45
|
+
* @param token (optional) token if 2FA-TOTP is enabled
|
|
46
|
+
* @returns SuccessfulAuth object holding the token and the user
|
|
47
|
+
*/
|
|
48
|
+
login(email: string, password: string, token?: string): Promise<SuccessfulAuth>;
|
|
49
|
+
/**
|
|
50
|
+
* Starts the login process via OIDC
|
|
51
|
+
* @param origin The starting URL of the process. After obtaining the credentials, the user will be redirected back to this url.
|
|
52
|
+
* @param oidcProvider The provider to use for the process. Only optional if the user is part of an organization that has a preferred
|
|
53
|
+
* OIDC provider and an associated email that matches the user's. The list of available providers can be found in the public config endpoint.
|
|
54
|
+
* @param hint Valid email address of the user that wants to login. Hint must be defined when provider is not.
|
|
55
|
+
* @returns URL that must be accessed via a browser to continue the login process.
|
|
56
|
+
*/
|
|
57
|
+
loginWithOIDC(origin: string, oidcProvider?: string, hint?: string): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Starts the login process via SAML 2.0
|
|
60
|
+
* @param origin The starting URL of the process. After obtaining the credentials, the user will be redirected back to this url.
|
|
61
|
+
* @param email Email of the user. The email domain will be used to determine the appropriate SAML 2.0 provider to use going forward.
|
|
62
|
+
* @returns URL that must be accessed via a browser to continue the login process.
|
|
63
|
+
*/
|
|
64
|
+
loginWithSAML(origin: string, email: string): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Determine if/how the given email can authenticate.
|
|
67
|
+
*
|
|
68
|
+
* @param email Email of the user
|
|
69
|
+
* @param origin The starting URL of the process. If the authentication process bound to this email is SAML or OIDC,
|
|
70
|
+
* then the response's location property will include this origin.
|
|
71
|
+
* @returns object that dictates if: the user needs to REGISTER; the user needs to VERIFY_EMAIL; the user can LOGIN using this email;
|
|
72
|
+
* or the authentication process should continue via an EXTERNAL provider that can be found via the location property.
|
|
73
|
+
*/
|
|
74
|
+
preLogin(email: string, origin: string): Promise<PreLoginResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Initiate the password reset process. An email will be sent to the user to move to the next phase.
|
|
77
|
+
*
|
|
78
|
+
* @param email Email of the user
|
|
79
|
+
* @param captcha Valid google reCAPTCHAV2
|
|
80
|
+
* @param targetUrl Optional url the link in the mail will point to
|
|
81
|
+
*/
|
|
82
|
+
resetPassword(email: string, captcha: string, targetUrl?: string): Promise<void>;
|
|
83
|
+
protected getEndpoint(endpoint: string): string;
|
|
84
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const Base_1 = require("../../Base");
|
|
13
|
+
const internal_1 = require("./internal");
|
|
14
|
+
const oauth_1 = require("./oauth");
|
|
15
|
+
const organization_1 = require("./organization");
|
|
16
|
+
const registration_1 = require("./registration");
|
|
17
|
+
const user_1 = require("./user");
|
|
18
|
+
class Idp extends Base_1.default {
|
|
19
|
+
/**
|
|
20
|
+
* Handles everything around organizations
|
|
21
|
+
*/
|
|
22
|
+
get organization() {
|
|
23
|
+
if (this._organization === undefined) {
|
|
24
|
+
this._organization = new organization_1.IdpOrganization(this.options, this.axios);
|
|
25
|
+
}
|
|
26
|
+
return this._organization;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Handles everything around registration
|
|
30
|
+
*/
|
|
31
|
+
get registration() {
|
|
32
|
+
if (this._registration === undefined) {
|
|
33
|
+
this._registration = new registration_1.IdpRegistration(this.options, this.axios);
|
|
34
|
+
}
|
|
35
|
+
return this._registration;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Handles everything around open authorization and openId requests
|
|
39
|
+
*/
|
|
40
|
+
get oAuth() {
|
|
41
|
+
if (this._oAuth === undefined) {
|
|
42
|
+
this._oAuth = new oauth_1.IdpOAuth(this.options, this.axios);
|
|
43
|
+
}
|
|
44
|
+
return this._oAuth;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Handles everything around a user
|
|
48
|
+
*/
|
|
49
|
+
get user() {
|
|
50
|
+
if (this._user === undefined) {
|
|
51
|
+
this._user = new user_1.IdpUser(this.options, this.axios);
|
|
52
|
+
}
|
|
53
|
+
return this._user;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Handles everything around idp's internal endpoints
|
|
57
|
+
*/
|
|
58
|
+
get internal() {
|
|
59
|
+
if (this._internal === undefined) {
|
|
60
|
+
this._internal = new internal_1.IdpInternal(this.options, this.axios);
|
|
61
|
+
}
|
|
62
|
+
return this._internal;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Requests the endpoint version
|
|
66
|
+
* @returns Version object
|
|
67
|
+
*/
|
|
68
|
+
version() {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const resp = yield this.axios.get(this.getEndpoint("/v1/version"));
|
|
71
|
+
return resp.data;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Authenticates against the identity provider with a given email and password.
|
|
76
|
+
* @param email Email of the user
|
|
77
|
+
* @param password Password of the user
|
|
78
|
+
* @param token (optional) token if 2FA-TOTP is enabled
|
|
79
|
+
* @returns SuccessfulAuth object holding the token and the user
|
|
80
|
+
*/
|
|
81
|
+
login(email, password, token) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
var _a;
|
|
84
|
+
let body = { email: email, password: password };
|
|
85
|
+
if (token) {
|
|
86
|
+
body = Object.assign(Object.assign({}, body), { token: token });
|
|
87
|
+
}
|
|
88
|
+
const resp = yield this.axios.post(this.getEndpoint("/v1/login"), body);
|
|
89
|
+
const authed = {
|
|
90
|
+
token: ((_a = resp.headers["authorization"]) === null || _a === void 0 ? void 0 : _a.toString()) || "",
|
|
91
|
+
user: resp.data,
|
|
92
|
+
};
|
|
93
|
+
return authed;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Starts the login process via OIDC
|
|
98
|
+
* @param origin The starting URL of the process. After obtaining the credentials, the user will be redirected back to this url.
|
|
99
|
+
* @param oidcProvider The provider to use for the process. Only optional if the user is part of an organization that has a preferred
|
|
100
|
+
* OIDC provider and an associated email that matches the user's. The list of available providers can be found in the public config endpoint.
|
|
101
|
+
* @param hint Valid email address of the user that wants to login. Hint must be defined when provider is not.
|
|
102
|
+
* @returns URL that must be accessed via a browser to continue the login process.
|
|
103
|
+
*/
|
|
104
|
+
loginWithOIDC(origin, oidcProvider, hint) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const resp = yield this.axios.get(this.getEndpoint("/v1/login/oidc"), {
|
|
107
|
+
params: {
|
|
108
|
+
origin,
|
|
109
|
+
provider: oidcProvider,
|
|
110
|
+
hint,
|
|
111
|
+
},
|
|
112
|
+
maxRedirects: 0,
|
|
113
|
+
validateStatus: status => {
|
|
114
|
+
return status >= 300 && status < 400;
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
const location = resp.headers.location;
|
|
118
|
+
if (!location) {
|
|
119
|
+
throw new Error("Location header is undefined.");
|
|
120
|
+
}
|
|
121
|
+
return location;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Starts the login process via SAML 2.0
|
|
126
|
+
* @param origin The starting URL of the process. After obtaining the credentials, the user will be redirected back to this url.
|
|
127
|
+
* @param email Email of the user. The email domain will be used to determine the appropriate SAML 2.0 provider to use going forward.
|
|
128
|
+
* @returns URL that must be accessed via a browser to continue the login process.
|
|
129
|
+
*/
|
|
130
|
+
loginWithSAML(origin, email) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const resp = yield this.axios.get(this.getEndpoint("/v1/login/saml"), {
|
|
133
|
+
params: {
|
|
134
|
+
origin,
|
|
135
|
+
email,
|
|
136
|
+
},
|
|
137
|
+
maxRedirects: 0,
|
|
138
|
+
validateStatus: status => {
|
|
139
|
+
return status >= 300 && status < 400;
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
const location = resp.headers.location;
|
|
143
|
+
if (!location) {
|
|
144
|
+
throw new Error("Location header is undefined.");
|
|
145
|
+
}
|
|
146
|
+
return location;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Determine if/how the given email can authenticate.
|
|
151
|
+
*
|
|
152
|
+
* @param email Email of the user
|
|
153
|
+
* @param origin The starting URL of the process. If the authentication process bound to this email is SAML or OIDC,
|
|
154
|
+
* then the response's location property will include this origin.
|
|
155
|
+
* @returns object that dictates if: the user needs to REGISTER; the user needs to VERIFY_EMAIL; the user can LOGIN using this email;
|
|
156
|
+
* or the authentication process should continue via an EXTERNAL provider that can be found via the location property.
|
|
157
|
+
*/
|
|
158
|
+
preLogin(email, origin) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
const resp = yield this.axios.get(this.getEndpoint("/v1/login/pre"), {
|
|
161
|
+
params: {
|
|
162
|
+
origin,
|
|
163
|
+
email,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
return resp.data;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Initiate the password reset process. An email will be sent to the user to move to the next phase.
|
|
171
|
+
*
|
|
172
|
+
* @param email Email of the user
|
|
173
|
+
* @param captcha Valid google reCAPTCHAV2
|
|
174
|
+
* @param targetUrl Optional url the link in the mail will point to
|
|
175
|
+
*/
|
|
176
|
+
resetPassword(email, captcha, targetUrl) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
yield this.axios.post(this.getEndpoint("/v1/login/forgot_password"), { email, captcha, targetUrl });
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
getEndpoint(endpoint) {
|
|
182
|
+
return `${this.options.server}/api/account${endpoint}`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.default = Idp;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Base from "../../../Base";
|
|
2
|
+
import { User } from "../../../interfaces/idp/user";
|
|
3
|
+
export declare class IdpInternal extends Base {
|
|
4
|
+
/**
|
|
5
|
+
* Creates an agent user for an organization.
|
|
6
|
+
*
|
|
7
|
+
* This is an internal endpoint and requires HCloud admin credentials to use.
|
|
8
|
+
*
|
|
9
|
+
* @param orgName Name of the organization
|
|
10
|
+
* @returns the created user and a pat token
|
|
11
|
+
*/
|
|
12
|
+
createAgentUser(orgName: string): Promise<{
|
|
13
|
+
user: User;
|
|
14
|
+
pat: string;
|
|
15
|
+
}>;
|
|
16
|
+
protected getEndpoint(endpoint: string): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IdpInternal = void 0;
|
|
13
|
+
const Base_1 = require("../../../Base");
|
|
14
|
+
class IdpInternal extends Base_1.default {
|
|
15
|
+
/**
|
|
16
|
+
* Creates an agent user for an organization.
|
|
17
|
+
*
|
|
18
|
+
* This is an internal endpoint and requires HCloud admin credentials to use.
|
|
19
|
+
*
|
|
20
|
+
* @param orgName Name of the organization
|
|
21
|
+
* @returns the created user and a pat token
|
|
22
|
+
*/
|
|
23
|
+
createAgentUser(orgName) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const res = yield this.axios.post(this.getEndpoint(`/internal/v1/org/${orgName}/agent`));
|
|
26
|
+
return { user: res.data, pat: res.headers.authorization };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
getEndpoint(endpoint) {
|
|
30
|
+
return `${this.options.server}/api/account${endpoint}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.IdpInternal = IdpInternal;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Base from "../../../Base";
|
|
2
|
+
import { OAuthToken, OAuthTokenRequest } from "../../../interfaces/idp/oauth";
|
|
3
|
+
import { OAuthAppWithConsent } from "../../../interfaces/idp/organization/settings/oauthApp";
|
|
4
|
+
export declare class IdpOAuth extends Base {
|
|
5
|
+
/**
|
|
6
|
+
* getAuthorizationCodeInsideRedirectUrl throws for an invalid request (query params do not match OAuthApp).
|
|
7
|
+
* It returns the redirect URL with the code, which is used to redirect to the client application,
|
|
8
|
+
* which can use the code for a back-channel request to get the access token.
|
|
9
|
+
* @param queryString expect the user's / browser's query string, containing the response_type, client_id,
|
|
10
|
+
* redirect_uri, scopes and optionally state.
|
|
11
|
+
* @returns the entire redirect uri including the authorization code if successful
|
|
12
|
+
*/
|
|
13
|
+
getAuthorizationCodeInsideRedirectUrl(queryString: string, doNotRedirect?: boolean): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Check if the user has consented to specified scopes. If the user has already consented this request
|
|
16
|
+
* will return the redirect URL, otherwise, it will be a consent.not.given error.
|
|
17
|
+
*
|
|
18
|
+
* To consent the createScopesAndGetAuthorizationCodeInsideRedirectUrl method should be used.
|
|
19
|
+
* @see IdpOAuth.createScopesAndGetAuthorizationCodeInsideRedirectUrl
|
|
20
|
+
*
|
|
21
|
+
* @param queryString {string} - Query string containing the OAuth parameters: response_type, client_id, scope, state
|
|
22
|
+
* @param doNotRedirect [boolean] - Flag to make the request return a 200 instead of a 3xx status code
|
|
23
|
+
* @returns A string with the redirect URL if the user already consented to the specificied scope. Otherwise, an OAuthApp
|
|
24
|
+
* @see OAuthApp
|
|
25
|
+
*/
|
|
26
|
+
getInfoOrAuthorizationCodeInsideRedirectUrl(queryString: string, doNotRedirect?: boolean): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* createScopesAndGetAuthorizationCodeInsideRedirectUrl throws for an invalid request (query params do not match OAuthApp).
|
|
29
|
+
* It returns the redirect URL with the code, which is used to redirect to the client application,
|
|
30
|
+
* which can use the code for a back-channel request to get the access token. It also adds the scopes for the user.
|
|
31
|
+
* @param queryString expect the user's / browser's query string, containing the response_type, client_id,
|
|
32
|
+
* redirect_uri, scopes and optionally state.
|
|
33
|
+
* @returns the entire redirect uri including the authorization code if successful
|
|
34
|
+
*/
|
|
35
|
+
createScopesAndGetAuthorizationCodeInsideRedirectUrl(queryString: string, doNotRedirect?: boolean): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* A valid code can be used to request a new API token.
|
|
38
|
+
* @param tokenRequest contains the code, client_id, client_secret and redirect_uri
|
|
39
|
+
*/
|
|
40
|
+
exchangeCodeForToken(tokenRequest: OAuthTokenRequest): Promise<OAuthToken>;
|
|
41
|
+
/**
|
|
42
|
+
* Get OAuth app public information via client ID
|
|
43
|
+
*
|
|
44
|
+
* @param clientId {string} - Client ID of the OAuth app
|
|
45
|
+
* @returns Public OAuth app information
|
|
46
|
+
*/
|
|
47
|
+
getOAuthAppInfo: (clientId: string) => Promise<OAuthAppWithConsent>;
|
|
48
|
+
protected getEndpoint(endpoint: string): string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IdpOAuth = void 0;
|
|
13
|
+
const Base_1 = require("../../../Base");
|
|
14
|
+
class IdpOAuth extends Base_1.default {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
/**
|
|
18
|
+
* Get OAuth app public information via client ID
|
|
19
|
+
*
|
|
20
|
+
* @param clientId {string} - Client ID of the OAuth app
|
|
21
|
+
* @returns Public OAuth app information
|
|
22
|
+
*/
|
|
23
|
+
this.getOAuthAppInfo = (clientId) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const response = yield this.axios.get(this.getEndpoint(`/v1/login/oauth/app/${clientId}`));
|
|
25
|
+
return response.data;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* getAuthorizationCodeInsideRedirectUrl throws for an invalid request (query params do not match OAuthApp).
|
|
30
|
+
* It returns the redirect URL with the code, which is used to redirect to the client application,
|
|
31
|
+
* which can use the code for a back-channel request to get the access token.
|
|
32
|
+
* @param queryString expect the user's / browser's query string, containing the response_type, client_id,
|
|
33
|
+
* redirect_uri, scopes and optionally state.
|
|
34
|
+
* @returns the entire redirect uri including the authorization code if successful
|
|
35
|
+
*/
|
|
36
|
+
getAuthorizationCodeInsideRedirectUrl(queryString, doNotRedirect) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (!queryString.startsWith("?")) {
|
|
39
|
+
queryString = `?${queryString}`;
|
|
40
|
+
}
|
|
41
|
+
if (doNotRedirect) {
|
|
42
|
+
queryString += "&no_redirect=true";
|
|
43
|
+
}
|
|
44
|
+
const response = yield this.axios.get(this.getEndpoint(`/v1/login/oauth/authorize${queryString}`), { maxRedirects: 0 });
|
|
45
|
+
if (doNotRedirect) {
|
|
46
|
+
return response.data.redirectUrl;
|
|
47
|
+
}
|
|
48
|
+
return response.headers.location;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if the user has consented to specified scopes. If the user has already consented this request
|
|
53
|
+
* will return the redirect URL, otherwise, it will be a consent.not.given error.
|
|
54
|
+
*
|
|
55
|
+
* To consent the createScopesAndGetAuthorizationCodeInsideRedirectUrl method should be used.
|
|
56
|
+
* @see IdpOAuth.createScopesAndGetAuthorizationCodeInsideRedirectUrl
|
|
57
|
+
*
|
|
58
|
+
* @param queryString {string} - Query string containing the OAuth parameters: response_type, client_id, scope, state
|
|
59
|
+
* @param doNotRedirect [boolean] - Flag to make the request return a 200 instead of a 3xx status code
|
|
60
|
+
* @returns A string with the redirect URL if the user already consented to the specificied scope. Otherwise, an OAuthApp
|
|
61
|
+
* @see OAuthApp
|
|
62
|
+
*/
|
|
63
|
+
getInfoOrAuthorizationCodeInsideRedirectUrl(queryString, doNotRedirect) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
if (!queryString.startsWith("?")) {
|
|
66
|
+
queryString = `?${queryString}`;
|
|
67
|
+
}
|
|
68
|
+
if (doNotRedirect) {
|
|
69
|
+
queryString += "&no_redirect=true";
|
|
70
|
+
}
|
|
71
|
+
const response = yield this.axios.get(this.getEndpoint(`/v1/login/oauth/info${queryString}`), {
|
|
72
|
+
maxRedirects: 0,
|
|
73
|
+
});
|
|
74
|
+
if (response.status < 300) {
|
|
75
|
+
return response.data.redirectUrl;
|
|
76
|
+
}
|
|
77
|
+
return response.headers.location;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* createScopesAndGetAuthorizationCodeInsideRedirectUrl throws for an invalid request (query params do not match OAuthApp).
|
|
82
|
+
* It returns the redirect URL with the code, which is used to redirect to the client application,
|
|
83
|
+
* which can use the code for a back-channel request to get the access token. It also adds the scopes for the user.
|
|
84
|
+
* @param queryString expect the user's / browser's query string, containing the response_type, client_id,
|
|
85
|
+
* redirect_uri, scopes and optionally state.
|
|
86
|
+
* @returns the entire redirect uri including the authorization code if successful
|
|
87
|
+
*/
|
|
88
|
+
createScopesAndGetAuthorizationCodeInsideRedirectUrl(queryString, doNotRedirect) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (!queryString.startsWith("?")) {
|
|
91
|
+
queryString = `?${queryString}`;
|
|
92
|
+
}
|
|
93
|
+
if (doNotRedirect) {
|
|
94
|
+
queryString += "&no_redirect=true";
|
|
95
|
+
}
|
|
96
|
+
const response = yield this.axios.post(this.getEndpoint(`/v1/login/oauth/authorize${queryString}`));
|
|
97
|
+
if (doNotRedirect) {
|
|
98
|
+
return response.data.redirectUrl;
|
|
99
|
+
}
|
|
100
|
+
return response.data;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A valid code can be used to request a new API token.
|
|
105
|
+
* @param tokenRequest contains the code, client_id, client_secret and redirect_uri
|
|
106
|
+
*/
|
|
107
|
+
exchangeCodeForToken(tokenRequest) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const response = yield this.axios.post(this.getEndpoint(`/v1/login/oauth/access_token`), tokenRequest);
|
|
110
|
+
return response.data;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
getEndpoint(endpoint) {
|
|
114
|
+
return `${this.options.server}/api/account${endpoint}`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.IdpOAuth = IdpOAuth;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Base from "../../../Base";
|
|
2
|
+
import { Organization, OrganizationQueryOptions } from "../../../interfaces/idp/organization";
|
|
3
|
+
import { IdpOrganizationLicense } from "./license";
|
|
4
|
+
import { IdpOrganizationMember } from "./member";
|
|
5
|
+
import IdpOrganizationSettings from "./settings";
|
|
6
|
+
import { IdpOrganizationTeams } from "./team";
|
|
7
|
+
export declare class IdpOrganization extends Base {
|
|
8
|
+
/**
|
|
9
|
+
* Handles everything around organization members
|
|
10
|
+
*/
|
|
11
|
+
get member(): IdpOrganizationMember;
|
|
12
|
+
private _member?;
|
|
13
|
+
/**
|
|
14
|
+
* Handles everything around organization settings
|
|
15
|
+
*/
|
|
16
|
+
get settings(): IdpOrganizationSettings;
|
|
17
|
+
private _settings?;
|
|
18
|
+
/**
|
|
19
|
+
* Handles everything around teams of organizations.
|
|
20
|
+
*/
|
|
21
|
+
get teams(): IdpOrganizationTeams;
|
|
22
|
+
private _teams?;
|
|
23
|
+
/**
|
|
24
|
+
* Handles everything around licenses.
|
|
25
|
+
*/
|
|
26
|
+
get license(): IdpOrganizationLicense;
|
|
27
|
+
private _license?;
|
|
28
|
+
/**
|
|
29
|
+
* Updates an Organization.
|
|
30
|
+
* @param orgName Current name of the Organization
|
|
31
|
+
* @param newName New name for the organization
|
|
32
|
+
* @param company (optional) New company name
|
|
33
|
+
* @returns The updated Organization
|
|
34
|
+
*/
|
|
35
|
+
updateOrganization(orgName: string, newName: string, company?: string): Promise<Organization>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new Organization.
|
|
38
|
+
* @param name Name of the new Organization
|
|
39
|
+
* @param company (optional) Company name for the new Organization
|
|
40
|
+
* @returns The created Organization
|
|
41
|
+
*/
|
|
42
|
+
createOrganization(name: string, company?: string): Promise<Organization>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves an Organization by its name.
|
|
45
|
+
* @param orgName Name of the Organization
|
|
46
|
+
* @param options Defines query options to retrieve additional properties in the response
|
|
47
|
+
* @returns The requested Organization
|
|
48
|
+
*/
|
|
49
|
+
getOrganization(orgName: string, options?: OrganizationQueryOptions): Promise<Organization>;
|
|
50
|
+
/**
|
|
51
|
+
* Deletes an Organization. This will also delete all dependencies that the Organization has (Teams, Spaces, apps, ...).
|
|
52
|
+
* @param orgName Name of the Organization to be deleted
|
|
53
|
+
*/
|
|
54
|
+
deleteOrganization(orgName: string): Promise<void>;
|
|
55
|
+
protected getEndpoint(endpoint: string): string;
|
|
56
|
+
}
|