@verii/endpoints-organizations-registrar 1.0.0-pre.1752076816
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/LICENSE +202 -0
- package/NOTICE +1 -0
- package/README.md +3 -0
- package/package.json +86 -0
- package/src/config/abi.json +1 -0
- package/src/config/config.js +261 -0
- package/src/controllers/consents/autohooks.js +6 -0
- package/src/controllers/consents/controller.js +106 -0
- package/src/controllers/consents/schemas/consent-response.schema.js +45 -0
- package/src/controllers/did-web-host/controller.js +64 -0
- package/src/controllers/groups/autohooks.js +10 -0
- package/src/controllers/groups/controller.js +172 -0
- package/src/controllers/groups/schemas/group.schema.json +22 -0
- package/src/controllers/groups/schemas/index.js +7 -0
- package/src/controllers/groups/schemas/modify-group.schema.json +25 -0
- package/src/controllers/image_upload/controller.js +48 -0
- package/src/controllers/invitations/controller.js +79 -0
- package/src/controllers/organizations/_did/autohooks.js +16 -0
- package/src/controllers/organizations/_did/controller.js +617 -0
- package/src/controllers/organizations/_did/invitations/_invitationId/autohooks.js +16 -0
- package/src/controllers/organizations/_did/invitations/_invitationId/controller.js +217 -0
- package/src/controllers/organizations/_did/invitations/controller.js +197 -0
- package/src/controllers/organizations/_did/keys/controller.js +141 -0
- package/src/controllers/organizations/_did/services/controller.js +195 -0
- package/src/controllers/organizations/_did/signatories/controller.js +63 -0
- package/src/controllers/organizations/autohooks.js +65 -0
- package/src/controllers/organizations/controller.js +322 -0
- package/src/controllers/organizations/full/controller.js +285 -0
- package/src/controllers/organizations/plugins.js +21 -0
- package/src/controllers/organizations/schemas/add-key-body.schema.json +35 -0
- package/src/controllers/organizations/schemas/create-did-service.schema.json +70 -0
- package/src/controllers/organizations/schemas/did-key.schema.json +178 -0
- package/src/controllers/organizations/schemas/full-organization.schema.json +35 -0
- package/src/controllers/organizations/schemas/index.js +33 -0
- package/src/controllers/organizations/schemas/invitationCodeProperty.schema.json +3 -0
- package/src/controllers/organizations/schemas/organization-ids.schema.json +34 -0
- package/src/controllers/organizations/schemas/organization-kyb-profile-creation.schema.json +26 -0
- package/src/controllers/organizations/schemas/organization-profile-creation.schema.json +20 -0
- package/src/controllers/organizations/schemas/organization-profile-update.schema.json +19 -0
- package/src/controllers/organizations/schemas/organization-profile-verifiable-credential.schema.json +25 -0
- package/src/controllers/organizations/schemas/organization-registry-service-response.schema.json +26 -0
- package/src/controllers/organizations/schemas/organization-service.schema.json +34 -0
- package/src/controllers/organizations/schemas/organization-verified-profile.schema.json +123 -0
- package/src/controllers/organizations/schemas/organization.search-profile.query-params.schema.json +50 -0
- package/src/controllers/organizations/schemas/organization.search.query-params.schema.json +42 -0
- package/src/controllers/reference/controller.js +103 -0
- package/src/controllers/resolve-did/controller.js +45 -0
- package/src/controllers/resolve-did/resolve-did.js +30 -0
- package/src/controllers/resolve-did/schemas/did-doc.schema.json +155 -0
- package/src/controllers/resolve-did/schemas/did-proof.schema.json +44 -0
- package/src/controllers/resolve-did/schemas/index.js +26 -0
- package/src/controllers/resolve-did/schemas/public-key.schema.json +173 -0
- package/src/controllers/resolve-kid/controller.js +76 -0
- package/src/controllers/resolve-kid/public-key-formats.js +8 -0
- package/src/controllers/service-types/controller.js +81 -0
- package/src/controllers/setup_image_upload/controller.js +99 -0
- package/src/controllers/signatories/controller.js +43 -0
- package/src/controllers/users/autohooks.js +10 -0
- package/src/controllers/users/controller.js +221 -0
- package/src/controllers/users/schemas/base-user.schema.json +55 -0
- package/src/controllers/users/schemas/index.js +4 -0
- package/src/controllers/users/schemas/modify-user.schema.js +17 -0
- package/src/controllers/users/schemas/user.schema.js +20 -0
- package/src/entities/groups/domain/constants.js +21 -0
- package/src/entities/groups/domain/index.js +19 -0
- package/src/entities/groups/factories/groups-factory.js +48 -0
- package/src/entities/groups/factories/index.js +17 -0
- package/src/entities/groups/index.js +19 -0
- package/src/entities/groups/repo.js +122 -0
- package/src/entities/images/domain/constant.js +11 -0
- package/src/entities/images/domain/index.js +3 -0
- package/src/entities/images/extension/activate.extension.js +35 -0
- package/src/entities/images/extension/deactivate.extension.js +27 -0
- package/src/entities/images/extension/find-by-url.extension.js +24 -0
- package/src/entities/images/extension/index.js +5 -0
- package/src/entities/images/factories/images-factory.js +43 -0
- package/src/entities/images/factories/index.js +17 -0
- package/src/entities/images/index.js +5 -0
- package/src/entities/images/repo.js +43 -0
- package/src/entities/images/schema/image-metadata.schema.js +58 -0
- package/src/entities/images/schema/index.js +3 -0
- package/src/entities/index.js +31 -0
- package/src/entities/invitations/domains/build-invitation-url.js +14 -0
- package/src/entities/invitations/domains/get-given-family-name-from-name.js +20 -0
- package/src/entities/invitations/domains/index.js +7 -0
- package/src/entities/invitations/domains/init-invitation-emails.js +17 -0
- package/src/entities/invitations/domains/is-invitation-expired.js +5 -0
- package/src/entities/invitations/domains/validate-invitee-email.js +18 -0
- package/src/entities/invitations/factories/index.js +17 -0
- package/src/entities/invitations/factories/invitations-factory.js +51 -0
- package/src/entities/invitations/index.js +6 -0
- package/src/entities/invitations/orchestrators/accept-invitation.js +24 -0
- package/src/entities/invitations/orchestrators/index.js +4 -0
- package/src/entities/invitations/orchestrators/send-email-invitee.js +36 -0
- package/src/entities/invitations/repo.js +37 -0
- package/src/entities/invitations/schemas/add-invitation-body.js +122 -0
- package/src/entities/invitations/schemas/get-invitation-response-body.js +20 -0
- package/src/entities/invitations/schemas/index.js +5 -0
- package/src/entities/invitations/schemas/invitation-response-item-body.js +61 -0
- package/src/entities/kms/factories/index.js +17 -0
- package/src/entities/kms/factories/kms-factory.js +31 -0
- package/src/entities/monitors/index.js +17 -0
- package/src/entities/monitors/orchestrators/index.js +17 -0
- package/src/entities/monitors/orchestrators/monitors.js +230 -0
- package/src/entities/oauth/domain/constants.js +23 -0
- package/src/entities/oauth/domain/index.js +5 -0
- package/src/entities/oauth/domain/roles.js +92 -0
- package/src/entities/oauth/domain/scopes.js +35 -0
- package/src/entities/oauth/index.js +4 -0
- package/src/entities/oauth/orchestrators/auth0-provisioner.js +293 -0
- package/src/entities/oauth/orchestrators/index.js +3 -0
- package/src/entities/organization-keys/domains/build-organization-key.js +50 -0
- package/src/entities/organization-keys/domains/constants.js +30 -0
- package/src/entities/organization-keys/domains/extract-verification-method-from-byo-did-document.js +38 -0
- package/src/entities/organization-keys/domains/find-key-by-purpose.js +6 -0
- package/src/entities/organization-keys/domains/index.js +10 -0
- package/src/entities/organization-keys/domains/jwk-to-hex-key-transformer.js +13 -0
- package/src/entities/organization-keys/domains/map-key-response.js +29 -0
- package/src/entities/organization-keys/domains/validate-non-custodial-key.js +11 -0
- package/src/entities/organization-keys/domains/validate-organization-key.js +42 -0
- package/src/entities/organization-keys/factories/index.js +17 -0
- package/src/entities/organization-keys/factories/organization-keys-factory.js +55 -0
- package/src/entities/organization-keys/index.js +5 -0
- package/src/entities/organization-keys/orchestrators/add-key-to-did-doc.js +19 -0
- package/src/entities/organization-keys/orchestrators/add-key.js +155 -0
- package/src/entities/organization-keys/orchestrators/add-operator-keys.js +46 -0
- package/src/entities/organization-keys/orchestrators/delete-key.js +93 -0
- package/src/entities/organization-keys/orchestrators/get-key.js +39 -0
- package/src/entities/organization-keys/orchestrators/index.js +24 -0
- package/src/entities/organization-keys/orchestrators/resolve-verification-method-byo-did.js +28 -0
- package/src/entities/organization-keys/repos/repo.js +48 -0
- package/src/entities/organization-services/adapters/index.js +21 -0
- package/src/entities/organization-services/adapters/init-provision-auth0-client-grants.js +44 -0
- package/src/entities/organization-services/adapters/init-provision-auth0-clients.js +56 -0
- package/src/entities/organization-services/adapters/update-blockchain-permissions-from-permitted-services.js +118 -0
- package/src/entities/organization-services/domains/activate-services.js +12 -0
- package/src/entities/organization-services/domains/build-organizations-services.js +38 -0
- package/src/entities/organization-services/domains/build-public-services.js +19 -0
- package/src/entities/organization-services/domains/constants.js +32 -0
- package/src/entities/organization-services/domains/extract-cao-service-refs.js +10 -0
- package/src/entities/organization-services/domains/extract-service-endpoint-did.js +10 -0
- package/src/entities/organization-services/domains/get-service-consent-type.js +16 -0
- package/src/entities/organization-services/domains/get-service-types-from-categories.js +18 -0
- package/src/entities/organization-services/domains/index.js +17 -0
- package/src/entities/organization-services/domains/is-new-node-operator-service.js +25 -0
- package/src/entities/organization-services/domains/is-service-category.js +31 -0
- package/src/entities/organization-services/domains/normalize-service-endpoint.js +6 -0
- package/src/entities/organization-services/domains/select-activated-services.js +8 -0
- package/src/entities/organization-services/domains/transform-profile-service.js +88 -0
- package/src/entities/organization-services/domains/validate-cao-service-refs.js +25 -0
- package/src/entities/organization-services/domains/validate-service-credential-type.js +47 -0
- package/src/entities/organization-services/domains/validate-service-endpoint.js +35 -0
- package/src/entities/organization-services/domains/validate-service-fields-by-service-type.js +37 -0
- package/src/entities/organization-services/domains/validate-service-id-uniqueness.js +19 -0
- package/src/entities/organization-services/domains/validate-service-key-purposes.js +56 -0
- package/src/entities/organization-services/domains/validate-service-type.js +12 -0
- package/src/entities/organization-services/domains/validate-service.js +80 -0
- package/src/entities/organization-services/domains/validate-services-for-delete.js +32 -0
- package/src/entities/organization-services/index.js +5 -0
- package/src/entities/organization-services/orchestrators/add-service.js +106 -0
- package/src/entities/organization-services/orchestrators/delete-service.js +142 -0
- package/src/entities/organization-services/orchestrators/get-service.js +36 -0
- package/src/entities/organization-services/orchestrators/index.js +8 -0
- package/src/entities/organization-services/orchestrators/init-add-service-to-organization.js +141 -0
- package/src/entities/organization-services/orchestrators/load-cao-service-refs.js +56 -0
- package/src/entities/organization-services/orchestrators/update-service.js +103 -0
- package/src/entities/organizations/adapters/index.js +6 -0
- package/src/entities/organizations/adapters/init-organization-registrar-emails.js +215 -0
- package/src/entities/organizations/adapters/init-send-activation-emails-to-caos.js +89 -0
- package/src/entities/organizations/adapters/send-email-invitation-accepted-to-inviter.js +70 -0
- package/src/entities/organizations/adapters/send-email-notifications.js +212 -0
- package/src/entities/organizations/domains/build-custodied-did-web.js +12 -0
- package/src/entities/organizations/domains/build-full-organization-response.js +40 -0
- package/src/entities/organizations/domains/build-organization-modifications-on-service-change.js +82 -0
- package/src/entities/organizations/domains/build-profile-vc-url.js +8 -0
- package/src/entities/organizations/domains/build-profile-verifiable-credential.js +36 -0
- package/src/entities/organizations/domains/build-public-profile.js +9 -0
- package/src/entities/organizations/domains/constants.js +54 -0
- package/src/entities/organizations/domains/index.js +17 -0
- package/src/entities/organizations/domains/organization-vc-checks.js +49 -0
- package/src/entities/organizations/domains/parse-profile-to-csv.js +41 -0
- package/src/entities/organizations/domains/prepare-profile-vc.js +28 -0
- package/src/entities/organizations/domains/profile-name-normalization.js +5 -0
- package/src/entities/organizations/domains/validate-byo-did-keys.js +28 -0
- package/src/entities/organizations/domains/validate-profile-name.js +48 -0
- package/src/entities/organizations/domains/validate-profile-website.js +17 -0
- package/src/entities/organizations/domains/validate-update-profile.js +11 -0
- package/src/entities/organizations/factories/index.js +17 -0
- package/src/entities/organizations/factories/organizations-factory.js +180 -0
- package/src/entities/organizations/index.js +6 -0
- package/src/entities/organizations/orchestrators/add-primary-permissions.js +28 -0
- package/src/entities/organizations/orchestrators/build-custodied-organization.js +92 -0
- package/src/entities/organizations/orchestrators/build-non-custodied-organization.js +83 -0
- package/src/entities/organizations/orchestrators/index.js +6 -0
- package/src/entities/organizations/orchestrators/init-create-organization.js +221 -0
- package/src/entities/organizations/orchestrators/init-provision-group.js +48 -0
- package/src/entities/organizations/orchestrators/verify-profile-website-unique.js +15 -0
- package/src/entities/organizations/repos/find-caos-extension.js +49 -0
- package/src/entities/organizations/repos/index.js +17 -0
- package/src/entities/organizations/repos/repo.js +156 -0
- package/src/entities/organizations/repos/search-by-aggregation-extension.js +128 -0
- package/src/entities/organizations/repos/transform-did-filter.js +13 -0
- package/src/entities/organizations/repos/transform-organization-filter.js +106 -0
- package/src/entities/registrar-consents/constants.js +10 -0
- package/src/entities/registrar-consents/factories/index.js +17 -0
- package/src/entities/registrar-consents/factories/registrar-consents-factory.js +38 -0
- package/src/entities/registrar-consents/index.js +3 -0
- package/src/entities/registrar-consents/repos/registrar-consent-repo-extension.js +55 -0
- package/src/entities/registrar-consents/repos/repo.js +31 -0
- package/src/entities/signatories/domain/constants.js +12 -0
- package/src/entities/signatories/domain/index.js +4 -0
- package/src/entities/signatories/domain/organization-emails.js +29 -0
- package/src/entities/signatories/factories/index.js +17 -0
- package/src/entities/signatories/factories/signatory-status-factory.js +53 -0
- package/src/entities/signatories/index.js +5 -0
- package/src/entities/signatories/orchestrators/approve-reminder.js +24 -0
- package/src/entities/signatories/orchestrators/index.js +6 -0
- package/src/entities/signatories/orchestrators/reject-reminder.js +17 -0
- package/src/entities/signatories/orchestrators/send-reminders.js +102 -0
- package/src/entities/signatories/orchestrators/validate-auth-code.js +56 -0
- package/src/entities/signatories/repos/index.js +3 -0
- package/src/entities/signatories/repos/repo.js +35 -0
- package/src/entities/signatories/repos/signatory-status-state-repo-extension.js +124 -0
- package/src/entities/users/domains/constants.js +40 -0
- package/src/entities/users/domains/index.js +4 -0
- package/src/entities/users/domains/user-registrar-emails.js +52 -0
- package/src/entities/users/index.js +4 -0
- package/src/entities/users/orchestrators/create-auth0-user.js +60 -0
- package/src/entities/users/orchestrators/get-or-create-auth0-user.js +63 -0
- package/src/entities/users/orchestrators/index.js +22 -0
- package/src/entities/users/orchestrators/user-management.js +157 -0
- package/src/fetchers/index.js +19 -0
- package/src/fetchers/monitoring/index.js +9 -0
- package/src/fetchers/monitoring/monitor-add-to-page-fetcher.js +18 -0
- package/src/fetchers/monitoring/monitor-create-fetcher.js +23 -0
- package/src/fetchers/monitoring/monitor-delete-fetcher.js +6 -0
- package/src/fetchers/monitoring/monitor-get-all-fetcher.js +6 -0
- package/src/fetchers/monitoring/section-create-fetcher.js +16 -0
- package/src/fetchers/monitoring/section-get-all-fetcher.js +6 -0
- package/src/fetchers/monitoring/service-version-fetcher.js +6 -0
- package/src/helpers/init-permissions-contract.js +48 -0
- package/src/index.js +23 -0
- package/src/init-server.js +91 -0
- package/src/organizations-registrar-endpoints.js +68 -0
- package/src/plugins/authorization.js +233 -0
- package/src/plugins/index.js +4 -0
- package/src/plugins/pubsub-plugin.js +82 -0
- package/src/subscribers/notify-caos.js +63 -0
- package/src/subscribers/notify-inviters.js +42 -0
- package/src/subscribers/notify-monitoring.js +40 -0
- package/src/subscribers/notify-signatory.js +51 -0
- package/src/subscribers/notify-support-and-groups.js +95 -0
- package/src/templates/invitee-invitation-email-body.hbs +13 -0
- package/src/templates/invitee-invitation-email-subject.hbs +1 -0
- package/src/templates/signatory-approval-email-body.hbs +92 -0
- package/src/templates/support-organization-created-body.hbs +17 -0
- package/src/templates/support-organization-created-subject.hbs +1 -0
- package/src/templates/support-signatory-max-reminders-reached-email-body.hbs +6 -0
- package/src/templates/support-signatory-max-reminders-reached-email-subject.hbs +1 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const { isBefore, subMinutes } = require('date-fns/fp');
|
|
2
|
+
const newError = require('http-errors');
|
|
3
|
+
const { isEmpty, find, flow, sortBy, last } = require('lodash/fp');
|
|
4
|
+
const { SignatoryEventStatus } = require('../domain/constants');
|
|
5
|
+
|
|
6
|
+
const validateAuthCode = async (organization, authCode, context) => {
|
|
7
|
+
const { repos, config } = context;
|
|
8
|
+
|
|
9
|
+
const signatoryStatus = await repos.signatoryStatus.findOne({
|
|
10
|
+
filter: {
|
|
11
|
+
organizationId: organization._id,
|
|
12
|
+
authCodes: {
|
|
13
|
+
$elemMatch: {
|
|
14
|
+
code: authCode,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (isEmpty(signatoryStatus)) {
|
|
21
|
+
throw newError(401, 'Unauthorized', {
|
|
22
|
+
errorCode: 'unauthorized',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (find({ state: SignatoryEventStatus.COMPLETED }, signatoryStatus.events)) {
|
|
27
|
+
throw newError(400, 'Signatory has already signed', {
|
|
28
|
+
errorCode: 'signatory_status_already_complete',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const latestAuthCode = flow(
|
|
33
|
+
sortBy(['timestamp']),
|
|
34
|
+
last
|
|
35
|
+
)(signatoryStatus.authCodes);
|
|
36
|
+
|
|
37
|
+
if (latestAuthCode.code !== authCode) {
|
|
38
|
+
throw newError(400, 'Please use the latest email sent.', {
|
|
39
|
+
errorCode: 'auth_code_must_be_most_recent',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const isTimestampExpired = isBefore(
|
|
44
|
+
subMinutes(config.signatoryLinkExpiration, new Date())
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (isTimestampExpired(new Date(latestAuthCode.timestamp))) {
|
|
48
|
+
throw newError(400, 'Auth code has expired.', {
|
|
49
|
+
errorCode: 'auth_code_expired',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
validateAuthCode,
|
|
56
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const {
|
|
2
|
+
repoFactory,
|
|
3
|
+
autoboxIdsExtension,
|
|
4
|
+
} = require('@spencejs/spence-mongo-repos');
|
|
5
|
+
const {
|
|
6
|
+
signatoryStatusStateRepoExtension,
|
|
7
|
+
} = require('./signatory-status-state-repo-extension');
|
|
8
|
+
|
|
9
|
+
module.exports = (app, options, next = () => {}) => {
|
|
10
|
+
next();
|
|
11
|
+
return repoFactory(
|
|
12
|
+
{
|
|
13
|
+
name: 'signatoryStatus',
|
|
14
|
+
entityName: 'signatoryStatus',
|
|
15
|
+
defaultProjection: {
|
|
16
|
+
_id: 1,
|
|
17
|
+
organizationDid: 1,
|
|
18
|
+
organizationId: 1,
|
|
19
|
+
approvedAt: 1,
|
|
20
|
+
rejectedAt: 1,
|
|
21
|
+
events: 1,
|
|
22
|
+
authCodes: 1,
|
|
23
|
+
error: 1,
|
|
24
|
+
createdAt: 1,
|
|
25
|
+
updatedAt: 1,
|
|
26
|
+
},
|
|
27
|
+
timestampKeys: {
|
|
28
|
+
createdAt: 'createdAt',
|
|
29
|
+
updatedAt: 'updatedAt',
|
|
30
|
+
},
|
|
31
|
+
extensions: [autoboxIdsExtension, signatoryStatusStateRepoExtension],
|
|
32
|
+
},
|
|
33
|
+
app
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const { map, isPlainObject, includes } = require('lodash/fp');
|
|
18
|
+
const { ObjectId } = require('mongodb');
|
|
19
|
+
const { SignatoryEventStatus } = require('../domain');
|
|
20
|
+
|
|
21
|
+
const signatoryStatusStateRepoExtension = (parent) => ({
|
|
22
|
+
insertWithState: ({ states, authCode, ...val }, ...args) => {
|
|
23
|
+
const timestamp = new Date();
|
|
24
|
+
return parent.insert(
|
|
25
|
+
{
|
|
26
|
+
events: [...map((state) => ({ state, timestamp }), states)],
|
|
27
|
+
authCodes: [{ code: authCode, timestamp }],
|
|
28
|
+
...val,
|
|
29
|
+
},
|
|
30
|
+
...args
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
addState: async (
|
|
34
|
+
_idOrFilter,
|
|
35
|
+
state,
|
|
36
|
+
$set,
|
|
37
|
+
projection = parent.defaultColumnsSelection
|
|
38
|
+
) => {
|
|
39
|
+
const eventsArr = [{ state, timestamp: new Date() }];
|
|
40
|
+
if (
|
|
41
|
+
includes(state, [
|
|
42
|
+
SignatoryEventStatus.APPROVED,
|
|
43
|
+
SignatoryEventStatus.REJECTED,
|
|
44
|
+
SignatoryEventStatus.MAX_REACHED,
|
|
45
|
+
])
|
|
46
|
+
) {
|
|
47
|
+
eventsArr.push({
|
|
48
|
+
state: SignatoryEventStatus.COMPLETED,
|
|
49
|
+
timestamp: new Date(),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
let updateStatement = {
|
|
53
|
+
$push: { events: { $each: eventsArr } },
|
|
54
|
+
};
|
|
55
|
+
if ($set) {
|
|
56
|
+
updateStatement = {
|
|
57
|
+
...updateStatement,
|
|
58
|
+
$set: parent.prepModification($set),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const filter = isPlainObject(_idOrFilter)
|
|
62
|
+
? _idOrFilter
|
|
63
|
+
: { _id: new ObjectId(_idOrFilter) };
|
|
64
|
+
|
|
65
|
+
const result = await parent
|
|
66
|
+
.collection()
|
|
67
|
+
.findOneAndUpdate(parent.prepFilter(filter), updateStatement, {
|
|
68
|
+
returnDocument: 'after',
|
|
69
|
+
includeResultMetadata: true,
|
|
70
|
+
projection,
|
|
71
|
+
});
|
|
72
|
+
return result.value;
|
|
73
|
+
},
|
|
74
|
+
addStateAndCode: async (
|
|
75
|
+
_id,
|
|
76
|
+
state,
|
|
77
|
+
authCode,
|
|
78
|
+
projection = parent.defaultColumnsSelection
|
|
79
|
+
) => {
|
|
80
|
+
const timestamp = new Date();
|
|
81
|
+
const result = await parent.collection().findOneAndUpdate(
|
|
82
|
+
parent.prepFilter({ _id: new ObjectId(_id) }),
|
|
83
|
+
{
|
|
84
|
+
$push: {
|
|
85
|
+
events: { state, timestamp },
|
|
86
|
+
authCodes: { code: authCode, timestamp },
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
returnDocument: 'after',
|
|
91
|
+
includeResultMetadata: true,
|
|
92
|
+
projection,
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
return result.value;
|
|
96
|
+
},
|
|
97
|
+
findByEvent: async (eventTimestamp) => {
|
|
98
|
+
const aggregationPipeline = [
|
|
99
|
+
{
|
|
100
|
+
$match: {
|
|
101
|
+
'events.state': {
|
|
102
|
+
$ne: SignatoryEventStatus.COMPLETED,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
$addFields: {
|
|
108
|
+
latestEvent: { $last: '$events' },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
$match: {
|
|
113
|
+
'latestEvent.timestamp': {
|
|
114
|
+
$lte: eventTimestamp,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
return parent.collection().aggregate(aggregationPipeline);
|
|
120
|
+
},
|
|
121
|
+
extensions: parent.extensions.concat(['signatoryStatusStateRepoExtension']),
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
module.exports = { signatoryStatusStateRepoExtension };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { VNF_GROUP_ID_CLAIM } = require('../../oauth');
|
|
19
|
+
|
|
20
|
+
const UserErrorMessages = {
|
|
21
|
+
USER_NOT_FOUND: 'User not found',
|
|
22
|
+
USER_MUST_HAVE_GROUP_CLAIM: ({ user }) =>
|
|
23
|
+
`User ${user?.sub} must have a group claim`,
|
|
24
|
+
USER_INVALID_GROUP_CLAIM: ({ user }) =>
|
|
25
|
+
`User ${user?.sub} has an invalid group claim ${user[VNF_GROUP_ID_CLAIM]}`,
|
|
26
|
+
USER_NOT_GROUP_CLIENT_ADMIN: ({ user, group }) =>
|
|
27
|
+
`User ${user?.sub} must be in clientAdminIds of group ${
|
|
28
|
+
group?.groupId ?? user[VNF_GROUP_ID_CLAIM]
|
|
29
|
+
}`,
|
|
30
|
+
USER_CANNOT_ACCESS_ORGANIZATION_GROUP: ({ user, did, group }) =>
|
|
31
|
+
`User ${user?.sub} (group claim ${user[VNF_GROUP_ID_CLAIM]}) access forbidden to organization ${did} (groupId ${group?.groupId})`,
|
|
32
|
+
MISSING_REQUIRED_SCOPES_TEMPLATE: ({ requiredScopes }) =>
|
|
33
|
+
`User must have one of the following scopes: ${JSON.stringify(
|
|
34
|
+
requiredScopes
|
|
35
|
+
)}`,
|
|
36
|
+
USER_CANNOT_SPECIFY_GROUP_ID: 'User must not contain a "groupId"',
|
|
37
|
+
USER_MUST_SPECIFY_GROUP_ID: 'User must specify a "groupId"',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = { UserErrorMessages };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
const { reduce, compact } = require('lodash/fp');
|
|
3
|
+
|
|
4
|
+
const renderInviteTextTokenWalletRole = (
|
|
5
|
+
tokenWalletRole,
|
|
6
|
+
organizations,
|
|
7
|
+
config
|
|
8
|
+
) => {
|
|
9
|
+
const hasRole = compact(tokenWalletRole).length;
|
|
10
|
+
|
|
11
|
+
if (!hasRole) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return `To access the Payment and Rewards Hub, please follow the link(s) below and use the credentials you just created to login.<br>
|
|
16
|
+
PLEASE NOTE - Access to the Payment and Rewards Hub will only be possible once your services are activated.<br>
|
|
17
|
+
${reduce(
|
|
18
|
+
(text, org) =>
|
|
19
|
+
`${text}<a href='${config.tokenWalletBaseUrl}/o/${org.didDoc.id}'>${org.profile.name}</a> <br>`,
|
|
20
|
+
'',
|
|
21
|
+
organizations
|
|
22
|
+
)}`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const initUserRegistrarEmails = (config) => ({
|
|
26
|
+
emailToUserForUserInvite: ({
|
|
27
|
+
user,
|
|
28
|
+
ticket,
|
|
29
|
+
organizations = [],
|
|
30
|
+
tokenWalletRole,
|
|
31
|
+
}) => ({
|
|
32
|
+
subject: 'Velocity Network Registrar Invitation',
|
|
33
|
+
message: `${user.givenName} ${user.familyName},
|
|
34
|
+
Welcome to the Velocity Network Registrar.<br><br>
|
|
35
|
+
Please accept your invite and set your password at <a href='${ticket}'>${ticket}</a>
|
|
36
|
+
<br>
|
|
37
|
+
<br>
|
|
38
|
+
${renderInviteTextTokenWalletRole(tokenWalletRole, organizations, config)}
|
|
39
|
+
<br>
|
|
40
|
+
Regards,
|
|
41
|
+
<br>
|
|
42
|
+
<br>
|
|
43
|
+
The Velocity Network Registrar
|
|
44
|
+
`,
|
|
45
|
+
sender: config.registrarSupportEmail,
|
|
46
|
+
recipients: [user.email],
|
|
47
|
+
replyTo: config.noReplyEmail,
|
|
48
|
+
html: true,
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
module.exports = { initUserRegistrarEmails };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { compact, map, isEmpty } = require('lodash/fp');
|
|
19
|
+
const { RoleNames, initAuth0Provisioner } = require('../../oauth');
|
|
20
|
+
|
|
21
|
+
const initCreateAuth0User = (fastify) => {
|
|
22
|
+
const { createAuth0User, addRoleToAuth0User, createPasswordChangeTicket } =
|
|
23
|
+
initAuth0Provisioner(fastify.config);
|
|
24
|
+
|
|
25
|
+
return async (
|
|
26
|
+
{ userPayload, registrarRole = null, tokenWalletRole = null, groupId },
|
|
27
|
+
context
|
|
28
|
+
) => {
|
|
29
|
+
const { tokenWalletBaseUrl, registrarAppUiUrl } = fastify.config;
|
|
30
|
+
const { repos } = context;
|
|
31
|
+
const user = await createAuth0User({ user: userPayload });
|
|
32
|
+
|
|
33
|
+
const roles = compact([registrarRole, tokenWalletRole]);
|
|
34
|
+
|
|
35
|
+
await Promise.all(
|
|
36
|
+
map((roleName) => addRoleToAuth0User({ user, roleName }), roles)
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (groupId != null && registrarRole === RoleNames.RegistrarClientAdmin) {
|
|
40
|
+
await repos.groups.addUserToGroupClientAdmins(groupId, user.id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const { ticket } = await createPasswordChangeTicket({
|
|
44
|
+
user,
|
|
45
|
+
resultUrl:
|
|
46
|
+
isEmpty(registrarRole) && !isEmpty(tokenWalletRole)
|
|
47
|
+
? tokenWalletBaseUrl
|
|
48
|
+
: registrarAppUiUrl,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
user,
|
|
53
|
+
ticket,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
initCreateAuth0User,
|
|
60
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { first, isEmpty } = require('lodash/fp');
|
|
19
|
+
const { initUserManagement } = require('./user-management');
|
|
20
|
+
const { RoleNames, initAuth0Provisioner } = require('../../oauth');
|
|
21
|
+
const { initCreateAuth0User } = require('./create-auth0-user');
|
|
22
|
+
|
|
23
|
+
const initGetOrCreateAuth0User = (fastify) => {
|
|
24
|
+
const createAuth0User = initCreateAuth0User(fastify);
|
|
25
|
+
const { createPasswordChangeTicket } = initAuth0Provisioner(fastify.config);
|
|
26
|
+
const { getUserByEmail } = initUserManagement(fastify.config);
|
|
27
|
+
|
|
28
|
+
return async (email, givenName, familyName, req) => {
|
|
29
|
+
const existingUser = first(await getUserByEmail(email));
|
|
30
|
+
|
|
31
|
+
if (!isEmpty(existingUser)) {
|
|
32
|
+
if (existingUser.isRegistered) {
|
|
33
|
+
return { user: existingUser };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const { ticket } = await createPasswordChangeTicket({
|
|
37
|
+
user: existingUser,
|
|
38
|
+
resultUrl: fastify.config.registrarAppUiUrl,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return { user: existingUser, ticket };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { user, ticket } = await createAuth0User(
|
|
45
|
+
{
|
|
46
|
+
userPayload: {
|
|
47
|
+
email,
|
|
48
|
+
givenName,
|
|
49
|
+
familyName,
|
|
50
|
+
},
|
|
51
|
+
registrarRole: RoleNames.RegistrarClientAdmin,
|
|
52
|
+
tokenWalletRole: RoleNames.TokenWalletClientFinanceAdmin,
|
|
53
|
+
},
|
|
54
|
+
req
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return { user, ticket };
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
initGetOrCreateAuth0User,
|
|
63
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
...require('./create-auth0-user'),
|
|
20
|
+
...require('./get-or-create-auth0-user'),
|
|
21
|
+
...require('./user-management'),
|
|
22
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { ManagementClient } = require('auth0');
|
|
19
|
+
const {
|
|
20
|
+
camelCase,
|
|
21
|
+
flow,
|
|
22
|
+
omitBy,
|
|
23
|
+
isNil,
|
|
24
|
+
map,
|
|
25
|
+
mapKeys,
|
|
26
|
+
pick,
|
|
27
|
+
omit,
|
|
28
|
+
} = require('lodash/fp');
|
|
29
|
+
const { initAuth0RoleArrToRolesObj } = require('../../oauth');
|
|
30
|
+
|
|
31
|
+
const initManagementClient = ({ domain, clientId, clientSecret, audience }) => {
|
|
32
|
+
return new ManagementClient({
|
|
33
|
+
audience,
|
|
34
|
+
domain,
|
|
35
|
+
clientId,
|
|
36
|
+
clientSecret,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const initUserManagement = ({
|
|
41
|
+
auth0ManagementApiAudience,
|
|
42
|
+
auth0Domain,
|
|
43
|
+
auth0ClientId,
|
|
44
|
+
auth0ClientSecret,
|
|
45
|
+
auth0SuperuserRoleId,
|
|
46
|
+
auth0ClientAdminRoleId,
|
|
47
|
+
auth0ClientFinanceAdminRoleId,
|
|
48
|
+
auth0ClientSystemUserRoleId,
|
|
49
|
+
} = {}) => {
|
|
50
|
+
const managementClient = initManagementClient({
|
|
51
|
+
audience: auth0ManagementApiAudience,
|
|
52
|
+
domain: auth0Domain,
|
|
53
|
+
clientId: auth0ClientId,
|
|
54
|
+
clientSecret: auth0ClientSecret,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const auth0RolesArrToRolesObj = initAuth0RoleArrToRolesObj({
|
|
58
|
+
auth0SuperuserRoleId,
|
|
59
|
+
auth0ClientAdminRoleId,
|
|
60
|
+
auth0ClientFinanceAdminRoleId,
|
|
61
|
+
auth0ClientSystemUserRoleId,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const softDeleteUser = async ({ id }, context) => {
|
|
65
|
+
const { data: user } = await managementClient.users.get({ id });
|
|
66
|
+
if (isUserAccessPermitted(mapUser(user), context)) {
|
|
67
|
+
await managementClient.users.update(
|
|
68
|
+
{ id },
|
|
69
|
+
{
|
|
70
|
+
blocked: true,
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// defaults for dodgy invitations that were created without correct names. See VL-7602
|
|
77
|
+
const defaultUserValues = {
|
|
78
|
+
given_name: '',
|
|
79
|
+
family_name: '',
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const getUser = async ({ id }, context) => {
|
|
83
|
+
const { data: user } = await managementClient.users.get({ id });
|
|
84
|
+
return scopeUser(mapUser(user), context);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const getUserWithRoles = async ({ id }, context) => {
|
|
88
|
+
const [{ data: user }, roles] = await Promise.all([
|
|
89
|
+
managementClient.users.get({ id }),
|
|
90
|
+
getRolesOfUser({ id, page: 0, perPage: 10 }),
|
|
91
|
+
]);
|
|
92
|
+
const currentRolesObj = auth0RolesArrToRolesObj(roles);
|
|
93
|
+
return scopeUser(mapUser(user, currentRolesObj), context);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const getUserByEmail = async (email, context) => {
|
|
97
|
+
const { data: users } = await managementClient.usersByEmail.getByEmail({
|
|
98
|
+
email,
|
|
99
|
+
});
|
|
100
|
+
return map((user) => scopeUser(mapUser(user), context), users);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const mapUser = (user, otherProps) => {
|
|
104
|
+
const obj = {
|
|
105
|
+
id: user.user_id,
|
|
106
|
+
groupId: user.app_metadata?.groupId,
|
|
107
|
+
isRegistered: user.logins_count > 0,
|
|
108
|
+
...defaultUserValues,
|
|
109
|
+
...omit(['user_id', 'app_metadata'], user),
|
|
110
|
+
...otherProps,
|
|
111
|
+
};
|
|
112
|
+
return flow(omitBy(isNil), mapKeys(camelCase))(obj);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const scopeUser = (user, context) => {
|
|
116
|
+
if (isUserAccessPermitted(user, context)) {
|
|
117
|
+
return user;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return pick(
|
|
121
|
+
['email', 'givenName', 'familyName', 'id', 'isRegistered'],
|
|
122
|
+
user
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const getRolesOfUser = async ({ id, page, perPage }) => {
|
|
127
|
+
const { data: roles } = await managementClient.users.getRoles(
|
|
128
|
+
{
|
|
129
|
+
id,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
page,
|
|
133
|
+
per_page: perPage,
|
|
134
|
+
// sort: 'date:-1',
|
|
135
|
+
// include_totals: true,
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
return roles;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
getUser,
|
|
143
|
+
getUserWithRoles,
|
|
144
|
+
softDeleteUser,
|
|
145
|
+
getUserByEmail,
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const isUserAccessPermitted = (user, context) =>
|
|
150
|
+
context != null &&
|
|
151
|
+
(context.scope == null ||
|
|
152
|
+
(context.scope?.userId != null && context.scope.userId === user.id) ||
|
|
153
|
+
(context.scope?.groupId != null && context.scope.groupId === user.groupId));
|
|
154
|
+
|
|
155
|
+
module.exports = {
|
|
156
|
+
initUserManagement,
|
|
157
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
module.exports = {
|
|
18
|
+
...require('./monitoring'),
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
...require('./monitor-create-fetcher'),
|
|
3
|
+
...require('./monitor-delete-fetcher'),
|
|
4
|
+
...require('./monitor-get-all-fetcher'),
|
|
5
|
+
...require('./monitor-add-to-page-fetcher'),
|
|
6
|
+
...require('./section-create-fetcher'),
|
|
7
|
+
...require('./section-get-all-fetcher'),
|
|
8
|
+
...require('./service-version-fetcher'),
|
|
9
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const addMonitorToStatusPage = async (
|
|
2
|
+
{ resourceId, publicName, statusPageId, statusPageSectionId },
|
|
3
|
+
{ betterUptimeFetch }
|
|
4
|
+
) => {
|
|
5
|
+
const payload = {
|
|
6
|
+
resource_id: resourceId,
|
|
7
|
+
resource_type: 'Monitor',
|
|
8
|
+
public_name: publicName,
|
|
9
|
+
explanation: 'Add Comment here',
|
|
10
|
+
status_page_section_id: statusPageSectionId,
|
|
11
|
+
};
|
|
12
|
+
return betterUptimeFetch
|
|
13
|
+
.post(`status-pages/${statusPageId}/resources`, { json: payload })
|
|
14
|
+
.json();
|
|
15
|
+
};
|
|
16
|
+
module.exports = {
|
|
17
|
+
addMonitorToStatusPage,
|
|
18
|
+
};
|