@velocitycareerlabs/server-careerwallet 1.25.0-dev-build.12642c864
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/.localdev.env +47 -0
- package/.standalone.env +13 -0
- package/LICENSE +248 -0
- package/jest.config.js +20 -0
- package/migrate-mongo.config.js +25 -0
- package/migrations/20211017180227-create-personas.js +478 -0
- package/migrations/20211026185916-create-vanessa.js +79 -0
- package/migrations/20211026185917-update-personas.js +30 -0
- package/migrations/20211108124410-remove-surplus-personas.js +33 -0
- package/migrations/20211108132353-fix-vanessa-and-sheila.js +25 -0
- package/migrations/20220222123110-add-career-wallet-app-config.js +6 -0
- package/migrations/20220411104157-add-min-app-versions.js +15 -0
- package/migrations/20220419131726-create-nicole-flores-persona.js +63 -0
- package/migrations/20220515114034-update-persona-id-credentials.js +628 -0
- package/migrations/20220608093743-disable-mainnet-holderapp-id-verification.js +21 -0
- package/migrations/20220609063708-enable-mainnet-holderapp-id-verification.js +21 -0
- package/migrations/20220623091507-add-push-url.js +43 -0
- package/migrations/20220624133205-set-min-app-versions-to-11.js +16 -0
- package/migrations/20220710125326-set-min-app-version-to-0.10.7.js +16 -0
- package/migrations/20220811103500-add-verification-service-disclosure-deeplink.js +45 -0
- package/migrations/20220811123751-add-holderapp-dids-to-config.js +74 -0
- package/migrations/20220818072306-add-holderapp-endpoints-to-config.js +21 -0
- package/migrations/20220825090656-update-deeplink.js +46 -0
- package/migrations/20221003151823-app-config-add-public-verification-api.js +18 -0
- package/migrations/20221116085242-add-holderapp-sdk-to-config.js +15 -0
- package/migrations/20221121091030-update-holderapp-deeplink.js +19 -0
- package/migrations/20221128103425-update-holderapp-presentation-template.js +19 -0
- package/migrations/20221221091436-app-config-add-oauth.js +13 -0
- package/migrations/20221226205900-app-config-add-presentation-extension-api.js +18 -0
- package/migrations/20230120113141-update-holderapp-cashSiquence.js +15 -0
- package/migrations/20230123084103-update-holderapp-cacheSequence.js +15 -0
- package/migrations/20230214083430-update-holderapp-cache-Sequence.js +15 -0
- package/migrations/20230225173335-set-min-app-version-1.5.1.js +30 -0
- package/migrations/20230323120629-add-sunil-singh-persona.js +87 -0
- package/migrations/20230329081529-add-personas-by-env.js +294 -0
- package/migrations/20230329103219-remove-unused-personas.js +14 -0
- package/migrations/20230504090208-disable-yoti-migration.js +21 -0
- package/migrations/20230504123425-set-min-app-version-1.8.1.js +38 -0
- package/migrations/20230504185047-enable-yoti-migration.js +21 -0
- package/migrations/20230524053203-add-devices-index.js +16 -0
- package/migrations/20230704000002-add-common-holder-endpoints-to-config.js +16 -0
- package/migrations/20230704000003-add-linkedin-holder-endpoints-to-config.js +18 -0
- package/migrations/20230704104055-update-push-url-and-yoti-url.js +18 -0
- package/migrations/20230705000001-add-liburl-to-holderapp-config.js +20 -0
- package/migrations/20230814113134-app-config-add-oauth-client-id.js +18 -0
- package/migrations/20230821154136-yoti-new-session-url-fix.js +19 -0
- package/migrations/20230907134442-update-holderapp-cache-Sequence.js +15 -0
- package/migrations/20230919180000-set-holderapp-min-app-versions-1.15.0.js +16 -0
- package/migrations/20231011083137-update-holderapp-cache-sequence-6.js +15 -0
- package/migrations/20231102083252-set-holderapp-min-app-versions-1.14.0.js +16 -0
- package/migrations/20231108202229-set-holderapp-min-app-versions-1.15.0.js +16 -0
- package/migrations/20231115143332-holderapp-isDirectIssuerCheckOn-true.js +16 -0
- package/migrations/20231120100020-insert-didKeyMetadatum-for-old-accounts.js +59 -0
- package/migrations/20231207142742-remove-devices-from-accounts.js +46 -0
- package/migrations/20231226090805-app-config-set-direct-issuer-check.js +13 -0
- package/migrations/202312271524-set-holderapp-app-version-1.15.1.js +16 -0
- package/migrations/20232211171700-app-config-update-base-urls.js +18 -0
- package/migrations/20240102093506-holderapp-revert-version-1.15.0.js +16 -0
- package/migrations/202401041618111-holderapp-isDebugOn-false.js +17 -0
- package/migrations/20240131095122-test-personas-add-did.js +102 -0
- package/migrations/202402051547000-update-sdk.js +18 -0
- package/migrations/20240206101448-update-personas-vc-to-v2.js +137 -0
- package/migrations/202402061233000-set-xVnfProtocolVersion-2.js +13 -0
- package/migrations/202402081240000-set-xVnfProtocolVersion-1.js +13 -0
- package/migrations/202402131319-set-holderapp-min-versions-1.17.js +16 -0
- package/migrations/202402141152-set-holderapp-min-version-1.16.js +16 -0
- package/migrations/20240221123501-transform-account-keys-to-stringified-jwk.js +81 -0
- package/migrations/202402290955-update-holderapp-to-verifyMyCreds.js +36 -0
- package/migrations/20240311134223-update-keyid-persona.js +66 -0
- package/migrations/20240312141618-vl-7409-persona-update-maria-williams.js +82 -0
- package/migrations/202403181733000-remove-devices-from-all-accounts.js +27 -0
- package/migrations/20240401091041-set-holderapp-min-version-1.18.1.js +16 -0
- package/migrations/202404071847-app-config-update-yoti-url.js +19 -0
- package/migrations/20240724063405-vl-3827-new-yoti-session-url.js +19 -0
- package/migrations/20240731112302-vl-8160-add-persona-keys.js +101 -0
- package/migrations/20240911115206-vanessa-lin-id-credentials.js +57 -0
- package/migrations/202409201219-add-isWalletAvailable-field.js +13 -0
- package/migrations/202409221012-set-isWalletAvailable-true.js +13 -0
- package/migrations/20240922114643-holderapp-isWalletAvailable-refactor.js +36 -0
- package/migrations/20240923132213-update-android-ios-app-config.js +36 -0
- package/migrations/20240926061732-inc-cacheSequence-to-7.js +15 -0
- package/migrations/20240926073339-inc-cacheSequence-to-7-fix.js +18 -0
- package/migrations/202410081217-adam-smith-id-credntials.js +57 -0
- package/migrations/202410101243-adam_smith-id-credential.js +57 -0
- package/migrations/20241015124307-persona-key-id-type-fix.js +26 -0
- package/migrations/202501291027000-set-holderapp-did-web.js +37 -0
- package/migrations/environments/dev.env +34 -0
- package/migrations/environments/localdev.env +22 -0
- package/migrations/environments/prod.env +18 -0
- package/migrations/environments/qa.env +54 -0
- package/migrations/environments/staging.env +31 -0
- package/migrations/environments/test.env +18 -0
- package/package.json +84 -0
- package/src/assets/category-icons/assessment.png +0 -0
- package/src/assets/category-icons/badge.png +0 -0
- package/src/assets/category-icons/certification.png +0 -0
- package/src/assets/category-icons/education.png +0 -0
- package/src/assets/category-icons/employment.png +0 -0
- package/src/assets/category-icons/gig.png +0 -0
- package/src/assets/category-icons/identity.png +0 -0
- package/src/assets/category-icons/pharmacy.png +0 -0
- package/src/assets/category-icons/training.png +0 -0
- package/src/assets/credentialCategories.json +119 -0
- package/src/config/config.js +156 -0
- package/src/controllers/api/v0.6/accounts/autohooks.js +36 -0
- package/src/controllers/api/v0.6/accounts/controller.js +288 -0
- package/src/controllers/api/v0.6/accounts/schemas/careerwallet-accounts-didkeymetadatum-response.schema.js +41 -0
- package/src/controllers/api/v0.6/accounts/schemas/careerwallet-accounts-request.schema.js +49 -0
- package/src/controllers/api/v0.6/accounts/schemas/careerwallet-accounts-response.schema.js +74 -0
- package/src/controllers/api/v0.6/accounts/schemas/careerwallet-get-account-response.schema.js +72 -0
- package/src/controllers/api/v0.6/accounts/schemas/index.js +6 -0
- package/src/controllers/api/v0.6/careerwallet/appconfig/controller.js +25 -0
- package/src/controllers/api/v0.6/careerwallet/appconfig/repo.js +40 -0
- package/src/controllers/api/v0.6/careerwallet/autohooks.js +5 -0
- package/src/controllers/api/v0.6/careerwallet/consents/controller.js +66 -0
- package/src/controllers/api/v0.6/careerwallet/consents/latest/autohooks.js +7 -0
- package/src/controllers/api/v0.6/careerwallet/consents/latest/controller.js +76 -0
- package/src/controllers/api/v0.6/careerwallet/consents/repo.js +24 -0
- package/src/controllers/api/v0.6/careerwallet/consents/schemas/careerwallet-consent-response.schema.js +23 -0
- package/src/controllers/api/v0.6/careerwallet/consents/schemas/index.js +3 -0
- package/src/controllers/api/v0.6/create_did_key/autohooks.js +10 -0
- package/src/controllers/api/v0.6/create_did_key/controller.js +84 -0
- package/src/controllers/api/v0.6/create_did_key/schemas/index.js +4 -0
- package/src/controllers/api/v0.6/create_did_key/schemas/jwk-did-request.schema.js +20 -0
- package/src/controllers/api/v0.6/create_did_key/schemas/jwk-did-response.schema.js +41 -0
- package/src/controllers/api/v0.6/create_jwk/autohooks.js +10 -0
- package/src/controllers/api/v0.6/create_jwk/controller.js +46 -0
- package/src/controllers/api/v0.6/create_jwk/schemas/index.js +3 -0
- package/src/controllers/api/v0.6/create_jwk/schemas/jwk-response.schema.js +33 -0
- package/src/controllers/api/v0.6/credential-categories/controller.js +35 -0
- package/src/controllers/api/v0.6/devices/autohooks.js +11 -0
- package/src/controllers/api/v0.6/devices/controller.js +323 -0
- package/src/controllers/api/v0.6/devices/repo.js +27 -0
- package/src/controllers/api/v0.6/devices/schemas/device.schema.json +43 -0
- package/src/controllers/api/v0.6/devices/schemas/index.js +3 -0
- package/src/controllers/api/v0.6/feedback/controller.js +24 -0
- package/src/controllers/api/v0.6/feedback/schemas/index.js +3 -0
- package/src/controllers/api/v0.6/feedback/schemas/new-feedback.schema.js +47 -0
- package/src/controllers/api/v0.6/jwt/autohooks.js +10 -0
- package/src/controllers/api/v0.6/jwt/controller.js +44 -0
- package/src/controllers/api/v0.6/jwt/schemas/index.js +4 -0
- package/src/controllers/api/v0.6/jwt/schemas/jwt-request.schema.js +40 -0
- package/src/controllers/api/v0.6/jwt/schemas/jwt-response.schema.js +14 -0
- package/src/controllers/api/v0.6/oauth/controller.js +131 -0
- package/src/controllers/api/v0.6/push/controller.js +296 -0
- package/src/controllers/api/v0.6/push/firebase-initializer.js +21 -0
- package/src/controllers/api/v0.6/push/notification-types.js +37 -0
- package/src/controllers/api/v0.6/push/push-gateway-auth.js +123 -0
- package/src/controllers/api/v0.6/push/repo.js +24 -0
- package/src/controllers/api/v0.6/verification-offers/repo.js +25 -0
- package/src/controllers/api/v0.6/verify/autohooks.js +15 -0
- package/src/controllers/api/v0.6/verify/controller.js +348 -0
- package/src/controllers/api/v0.6/verify/repo.js +23 -0
- package/src/controllers/api/v0.6/verify/verification-credential-types.js +6 -0
- package/src/controllers/jwt/autohooks.js +10 -0
- package/src/controllers/jwt/controller.js +106 -0
- package/src/controllers/jwt/schemas/index.js +31 -0
- package/src/controllers/jwt/schemas/jwt-decode.response.200.schema.json +20 -0
- package/src/controllers/jwt/schemas/jwt-decode.schema.json +15 -0
- package/src/controllers/jwt/schemas/jwt-sign.response.200.schema.json +14 -0
- package/src/controllers/jwt/schemas/jwt-sign.schema.json +40 -0
- package/src/controllers/jwt/schemas/jwt-verify.response.200.schema.json +17 -0
- package/src/controllers/jwt/schemas/jwt-verify.schema.json +19 -0
- package/src/controllers/reference/autohooks.js +5 -0
- package/src/controllers/reference/countries/controller.js +81 -0
- package/src/controllers/reference/personas/controller.js +91 -0
- package/src/controllers/reference/personas/repo.js +29 -0
- package/src/controllers/reference/personas/schemas/index.js +3 -0
- package/src/controllers/reference/personas/schemas/persona.schema.json +108 -0
- package/src/controllers/root/controller.js +27 -0
- package/src/entities/accounts/constants.js +18 -0
- package/src/entities/accounts/domain/index.js +3 -0
- package/src/entities/accounts/domain/merge-scopes.js +9 -0
- package/src/entities/accounts/index.js +5 -0
- package/src/entities/accounts/repos/accounts.repo.js +64 -0
- package/src/entities/accounts/repos/id-token-claims-extension.js +31 -0
- package/src/entities/accounts/repos/index.js +3 -0
- package/src/entities/devices/constants.js +7 -0
- package/src/entities/devices/index.js +3 -0
- package/src/entities/feedback/domain/generate-feedback-email.js +23 -0
- package/src/entities/feedback/domain/index.js +3 -0
- package/src/entities/feedback/index.js +3 -0
- package/src/entities/index.js +9 -0
- package/src/entities/key-pairs/index.js +4 -0
- package/src/entities/key-pairs/orchestrators/generate-jwk.js +28 -0
- package/src/entities/key-pairs/orchestrators/get-key-pair.js +58 -0
- package/src/entities/key-pairs/orchestrators/index.js +4 -0
- package/src/entities/key-pairs/repos/index.js +3 -0
- package/src/entities/key-pairs/repos/key-pairs.repo.js +23 -0
- package/src/entities/oauth/constants.js +13 -0
- package/src/entities/oauth/domain/build-access-token.js +14 -0
- package/src/entities/oauth/domain/index.js +10 -0
- package/src/entities/oauth/domain/validate-audience.js +13 -0
- package/src/entities/oauth/domain/validate-client-id.js +13 -0
- package/src/entities/oauth/domain/validate-credential.js +16 -0
- package/src/entities/oauth/domain/validate-presentation.js +17 -0
- package/src/entities/oauth/domain/validate-refresh-token.js +17 -0
- package/src/entities/oauth/domain/validate-scope.js +30 -0
- package/src/entities/oauth/domain/verify-presentation.js +24 -0
- package/src/entities/oauth/index.js +4 -0
- package/src/entities/pushes/domains/errors.js +11 -0
- package/src/entities/pushes/domains/index.js +3 -0
- package/src/entities/pushes/index.js +3 -0
- package/src/entities/verification-code-attempts/index.js +3 -0
- package/src/entities/verification-code-attempts/orchestrators/index.js +3 -0
- package/src/entities/verification-code-attempts/orchestrators/validate-verification-code-attempts.js +79 -0
- package/src/entities/verification-code-attempts/repo.js +99 -0
- package/src/entities/verifications/constants.js +8 -0
- package/src/entities/verifications/index.js +3 -0
- package/src/helpers/caching-constants.js +6 -0
- package/src/helpers/index.js +3 -0
- package/src/index.js +15 -0
- package/src/init-server.js +88 -0
- package/src/plugins/index.js +4 -0
- package/src/plugins/vcl-verification-version-plugin.js +10 -0
- package/src/plugins/verify-access-token-plugin.js +116 -0
- package/src/standalone.js +8 -0
- package/test/accounts-controller.test.js +893 -0
- package/test/accounts-repo.test.js +92 -0
- package/test/careerwallet-config-controller.test.js +142 -0
- package/test/careerwallet-consents-controller.test.js +409 -0
- package/test/create_did_key-controller.test.js +397 -0
- package/test/create_jwk-controller.test.js +188 -0
- package/test/credential-categories-controller.test.js +29 -0
- package/test/credential-icons-controller.test.js +36 -0
- package/test/devices-controller.test.js +1025 -0
- package/test/factories/accounts-factory.js +15 -0
- package/test/factories/career-wallet-config-factory.js +60 -0
- package/test/factories/consents-career-wallet-factory.js +21 -0
- package/test/factories/devices-factory.js +16 -0
- package/test/factories/key-pairs-factory.js +18 -0
- package/test/factories/notifications-factory.js +16 -0
- package/test/factories/persona-factory.js +17 -0
- package/test/factories/refresh-tokens-factory.js +14 -0
- package/test/factories/verification-code-attempts-factory.js +17 -0
- package/test/factories/verification-factory.js +15 -0
- package/test/factories/verification-offer-factory.js +20 -0
- package/test/feedback-controller.test.js +225 -0
- package/test/helpers/.env.test +39 -0
- package/test/helpers/access-token.js +59 -0
- package/test/helpers/careerwallet-build-fastify.js +20 -0
- package/test/helpers/yoti.js +96 -0
- package/test/id-verification-controller.test.js +27 -0
- package/test/jwt-controller.test.js +1519 -0
- package/test/oauth-controller.test.js +639 -0
- package/test/push-controller.test.js +733 -0
- package/test/push-gateway-auth.test.js +208 -0
- package/test/reference-countries-controller.test.js +45 -0
- package/test/reference-personas-controller.test.js +179 -0
- package/test/root.test.js +21 -0
- package/test/swagger.test.js +21 -0
- package/test/verification-controller.test.js +1372 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const createError = require('http-errors');
|
|
2
|
+
const {
|
|
3
|
+
getCountries,
|
|
4
|
+
isLanguageCodeValid,
|
|
5
|
+
isLanguageSupported,
|
|
6
|
+
} = require('@velocitycareerlabs/country-data');
|
|
7
|
+
const { CachingConstants } = require('../../../helpers');
|
|
8
|
+
|
|
9
|
+
const DEFAULT_LANGUAGE_CODE_FALLBACK = 'en';
|
|
10
|
+
|
|
11
|
+
const countriesController = async (fastify) => {
|
|
12
|
+
fastify.get(
|
|
13
|
+
'/',
|
|
14
|
+
{
|
|
15
|
+
schema: fastify.autoSchema({
|
|
16
|
+
querystring: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
lge: { type: 'string', description: 'Language' },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
response: {
|
|
23
|
+
200: {
|
|
24
|
+
type: 'array',
|
|
25
|
+
items: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
name: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description:
|
|
31
|
+
'The name of the country in the language of the "lge" query parameter',
|
|
32
|
+
},
|
|
33
|
+
code: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'The ISO 3166-1 country code',
|
|
36
|
+
},
|
|
37
|
+
regions: {
|
|
38
|
+
type: 'array',
|
|
39
|
+
items: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
name: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description:
|
|
45
|
+
'The name of the subdivision in the language of the "lge" query parameter',
|
|
46
|
+
},
|
|
47
|
+
code: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'The ISO 3166-2 subdivision code',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ['name', 'code'],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
required: ['name', 'code', 'regions'],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
async ({ query: { lge } }, reply) => {
|
|
63
|
+
if (lge != null && !isLanguageCodeValid(lge)) {
|
|
64
|
+
throw createError(400, '"lge" query parameter is malformed');
|
|
65
|
+
}
|
|
66
|
+
const selectedLge =
|
|
67
|
+
lge != null && isLanguageSupported(lge)
|
|
68
|
+
? lge
|
|
69
|
+
: DEFAULT_LANGUAGE_CODE_FALLBACK;
|
|
70
|
+
const countries = await getCountries(selectedLge);
|
|
71
|
+
return reply
|
|
72
|
+
.header(
|
|
73
|
+
CachingConstants.CACHE_CONTROL_HEADER,
|
|
74
|
+
CachingConstants.MAX_AGE_CACHE_CONTROL
|
|
75
|
+
)
|
|
76
|
+
.send(countries);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
module.exports = countriesController;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const {
|
|
2
|
+
first,
|
|
3
|
+
flow,
|
|
4
|
+
flatMap,
|
|
5
|
+
isEmpty,
|
|
6
|
+
keyBy,
|
|
7
|
+
map,
|
|
8
|
+
uniq,
|
|
9
|
+
} = require('lodash/fp');
|
|
10
|
+
const {
|
|
11
|
+
getCredentialTypeDescriptor,
|
|
12
|
+
} = require('@velocitycareerlabs/common-fetchers');
|
|
13
|
+
const { personaSchema } = require('./schemas');
|
|
14
|
+
|
|
15
|
+
const getCredentialTypeDescriptors = async (credentialTypes, context) => {
|
|
16
|
+
const credentialTypeDescriptors = await Promise.all(
|
|
17
|
+
map(
|
|
18
|
+
(credentialType) =>
|
|
19
|
+
getCredentialTypeDescriptor(
|
|
20
|
+
{ type: credentialType, includeDisplay: true },
|
|
21
|
+
context
|
|
22
|
+
),
|
|
23
|
+
credentialTypes
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
return keyBy('id', credentialTypeDescriptors);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const countriesController = async (fastify) => {
|
|
30
|
+
fastify.addSchema(personaSchema);
|
|
31
|
+
|
|
32
|
+
fastify.get(
|
|
33
|
+
'/',
|
|
34
|
+
{
|
|
35
|
+
schema: fastify.autoSchema({
|
|
36
|
+
response: {
|
|
37
|
+
200: {
|
|
38
|
+
type: 'array',
|
|
39
|
+
items: {
|
|
40
|
+
$ref: 'https://velocitycareerlabs.io/persona',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
async (req) => {
|
|
47
|
+
const { repos } = req;
|
|
48
|
+
const personas = await repos.personas.find({});
|
|
49
|
+
if (isEmpty(personas)) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// load credential types
|
|
54
|
+
const credentialTypes = flow(
|
|
55
|
+
flatMap('vcs'),
|
|
56
|
+
flatMap('type'),
|
|
57
|
+
uniq
|
|
58
|
+
)(personas);
|
|
59
|
+
|
|
60
|
+
// load display descriptors
|
|
61
|
+
const credentialTypeDescriptors = await getCredentialTypeDescriptors(
|
|
62
|
+
credentialTypes,
|
|
63
|
+
req
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
// Return result
|
|
67
|
+
const result = map(
|
|
68
|
+
(persona) => ({
|
|
69
|
+
...persona,
|
|
70
|
+
vcs: map(
|
|
71
|
+
(vc) => ({
|
|
72
|
+
...vc,
|
|
73
|
+
output_descriptors: [
|
|
74
|
+
{
|
|
75
|
+
id: first(vc.type),
|
|
76
|
+
display: credentialTypeDescriptors[first(vc.type)]?.display,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
}),
|
|
80
|
+
persona.vcs
|
|
81
|
+
),
|
|
82
|
+
}),
|
|
83
|
+
personas
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
module.exports = countriesController;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const {
|
|
2
|
+
repoFactory,
|
|
3
|
+
autoboxIdsExtension,
|
|
4
|
+
} = require('@spencejs/spence-mongo-repos');
|
|
5
|
+
|
|
6
|
+
module.exports = (app, options, next = () => {}) => {
|
|
7
|
+
next();
|
|
8
|
+
return repoFactory(
|
|
9
|
+
{
|
|
10
|
+
name: 'personas',
|
|
11
|
+
entityName: 'persona',
|
|
12
|
+
defaultProjection: {
|
|
13
|
+
_id: 1,
|
|
14
|
+
name: 1,
|
|
15
|
+
email: 1,
|
|
16
|
+
image: 1,
|
|
17
|
+
vcs: 1,
|
|
18
|
+
did: 1,
|
|
19
|
+
kid: 1,
|
|
20
|
+
keyId: 1,
|
|
21
|
+
publicJwk: 1,
|
|
22
|
+
createdAt: 1,
|
|
23
|
+
updatedAt: 1,
|
|
24
|
+
},
|
|
25
|
+
extensions: [autoboxIdsExtension],
|
|
26
|
+
},
|
|
27
|
+
app
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "persona",
|
|
3
|
+
"$id": "https://velocitycareerlabs.io/persona",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"name": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "The name persona"
|
|
9
|
+
},
|
|
10
|
+
"email": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "email of the persona"
|
|
13
|
+
},
|
|
14
|
+
"image": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"format": "uri",
|
|
17
|
+
"description": "uri of the persona's image"
|
|
18
|
+
},
|
|
19
|
+
"vcs": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"items": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"jwt_vc": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "The verifiable credential encoded as a jwt"
|
|
27
|
+
},
|
|
28
|
+
"type": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"items": { "type": "string" },
|
|
31
|
+
"description": "The list of credential types"
|
|
32
|
+
},
|
|
33
|
+
"output_descriptors": {
|
|
34
|
+
"type": "array",
|
|
35
|
+
"items": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"id": {
|
|
39
|
+
"type": "string"
|
|
40
|
+
},
|
|
41
|
+
"schema": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"properties": {
|
|
46
|
+
"uri": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"format": "uri"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"display": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"additionalProperties": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"required": ["id"]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"required": ["type", "jwt_vc"]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"did": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "The did of the persona"
|
|
68
|
+
},
|
|
69
|
+
"kid": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"description": "The kid of the persona"
|
|
72
|
+
},
|
|
73
|
+
"keyId": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "The keyId of the persona"
|
|
76
|
+
},
|
|
77
|
+
"publicJwk": {
|
|
78
|
+
"description": "The public jwk",
|
|
79
|
+
"type": "object",
|
|
80
|
+
"properties": {
|
|
81
|
+
"crv": {
|
|
82
|
+
"type": "string"
|
|
83
|
+
},
|
|
84
|
+
"kid": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
},
|
|
87
|
+
"kty": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"x": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
},
|
|
93
|
+
"y": {
|
|
94
|
+
"type": "string"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"createdAt": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"format": "date-time"
|
|
101
|
+
},
|
|
102
|
+
"updatedAt": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"format": "date-time"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"required": ["name", "email", "vcs"]
|
|
108
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const rootRoutes = async (fastify) => {
|
|
2
|
+
fastify.get(
|
|
3
|
+
'/',
|
|
4
|
+
{
|
|
5
|
+
schema: {
|
|
6
|
+
description: 'Healthcheck and version info',
|
|
7
|
+
responses: {
|
|
8
|
+
200: {
|
|
9
|
+
description: 'Successful response',
|
|
10
|
+
content: { 'text/plain': { schema: { type: 'string' } } },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
tags: ['healthchecks'],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
async (_res, reply) => {
|
|
17
|
+
reply
|
|
18
|
+
.status(200)
|
|
19
|
+
.send(`Welcome to Career Wallet\nVersion: ${fastify.config.version}\n`);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line better-mutation/no-mutation
|
|
25
|
+
rootRoutes.prefixOverride = '';
|
|
26
|
+
|
|
27
|
+
module.exports = rootRoutes;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const accountTypes = ['perm', 'temp'];
|
|
2
|
+
|
|
3
|
+
const accountScopes = {
|
|
4
|
+
keyCreate: 'key:create',
|
|
5
|
+
account: 'account',
|
|
6
|
+
inbox: 'inbox',
|
|
7
|
+
jwt: 'jwt',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const adminScopes = {
|
|
11
|
+
adminClient: 'admin:client',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
accountTypes,
|
|
16
|
+
accountScopes,
|
|
17
|
+
adminScopes,
|
|
18
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const {
|
|
2
|
+
autoboxIdsExtension,
|
|
3
|
+
repoFactory,
|
|
4
|
+
} = require('@spencejs/spence-mongo-repos');
|
|
5
|
+
const { hashAndEncodeHex } = require('@velocitycareerlabs/crypto');
|
|
6
|
+
const {
|
|
7
|
+
refreshTokenExtension,
|
|
8
|
+
hashRefreshTokenField,
|
|
9
|
+
} = require('@velocitycareerlabs/spencer-mongo-extensions');
|
|
10
|
+
const { idTokenClaimsExtension } = require('./id-token-claims-extension');
|
|
11
|
+
|
|
12
|
+
module.exports = (app, _, next = () => {}) => {
|
|
13
|
+
next();
|
|
14
|
+
return repoFactory(
|
|
15
|
+
{
|
|
16
|
+
name: 'accounts',
|
|
17
|
+
entityName: 'accounts',
|
|
18
|
+
defaultProjection,
|
|
19
|
+
extensions: [
|
|
20
|
+
autoboxIdsExtension,
|
|
21
|
+
refreshTokenExtension,
|
|
22
|
+
idTokenClaimsExtension,
|
|
23
|
+
accountExtensions,
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
app
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const defaultProjection = {
|
|
31
|
+
_id: 1,
|
|
32
|
+
accountType: 1,
|
|
33
|
+
userId: 1,
|
|
34
|
+
idTokenClaims: 1,
|
|
35
|
+
scope: 1,
|
|
36
|
+
refreshToken: 1,
|
|
37
|
+
createdAt: 1,
|
|
38
|
+
updatedAt: 1,
|
|
39
|
+
didKeyMetadatum: 1,
|
|
40
|
+
pushTokens: 1,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const accountExtensions = (parent) => {
|
|
44
|
+
return {
|
|
45
|
+
findAccountAndSetRefreshToken: (filter, newRefreshToken) => {
|
|
46
|
+
return parent
|
|
47
|
+
.collection()
|
|
48
|
+
.findOneAndUpdate(
|
|
49
|
+
hashRefreshTokenField(filter),
|
|
50
|
+
{
|
|
51
|
+
$set: {
|
|
52
|
+
refreshToken: hashAndEncodeHex(newRefreshToken),
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
returnDocument: 'after',
|
|
57
|
+
includeResultMetadata: true,
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
.then(({ value }) => value);
|
|
61
|
+
},
|
|
62
|
+
extensions: parent.extensions.concat(['findAccountAndSetRefreshToken']),
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { encrypt } = require('@velocitycareerlabs/crypto');
|
|
2
|
+
|
|
3
|
+
const idTokenClaimsExtension = (parent, context) => {
|
|
4
|
+
return {
|
|
5
|
+
prepModification: (account, modificationType, ...args) => {
|
|
6
|
+
if (modificationType === 'insert') {
|
|
7
|
+
return parent.prepModification(
|
|
8
|
+
{
|
|
9
|
+
...account,
|
|
10
|
+
...(account.idTokenClaims
|
|
11
|
+
? {
|
|
12
|
+
idTokenClaims: encrypt(
|
|
13
|
+
JSON.stringify(account.idTokenClaims),
|
|
14
|
+
context.config.mongoSecret
|
|
15
|
+
),
|
|
16
|
+
}
|
|
17
|
+
: {}),
|
|
18
|
+
},
|
|
19
|
+
modificationType,
|
|
20
|
+
...args
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return parent.prepModification(account, modificationType, ...args);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
idTokenClaimsExtension,
|
|
31
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const noReplyEmail = 'no-reply@velocitynetwork.foundation';
|
|
2
|
+
|
|
3
|
+
const generateFeedbackEmail = (feedback, { config }) => ({
|
|
4
|
+
subject: `${config.nodeEnv.toUpperCase()}: Support Request - Account Feedback.`,
|
|
5
|
+
message: `
|
|
6
|
+
Support Request - Account Feedback.
|
|
7
|
+
User Information:
|
|
8
|
+
Account ID: ${feedback.accountId}
|
|
9
|
+
Feedback: ${feedback.feedback}
|
|
10
|
+
Error Code (if applicable): ${feedback.errorCode}
|
|
11
|
+
App Version: ${feedback.appVersion}
|
|
12
|
+
Device Manufacturer: ${feedback.deviceManufacturer}
|
|
13
|
+
Device Model: ${feedback.deviceModel}
|
|
14
|
+
Device OS: ${feedback.deviceOS}
|
|
15
|
+
IP Address: ${feedback.ip}
|
|
16
|
+
`,
|
|
17
|
+
sender: noReplyEmail,
|
|
18
|
+
recipients: [config.careerwalletSupportEmail],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
generateFeedbackEmail,
|
|
23
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { generateKeyPair } = require('@velocitycareerlabs/crypto');
|
|
2
|
+
const { stringifyJwk } = require('@velocitycareerlabs/jwt');
|
|
3
|
+
|
|
4
|
+
const generateJwk = async (curve, context) => {
|
|
5
|
+
const { awsKmsClient, repos, config } = context;
|
|
6
|
+
const { managedAccountsKeyId } = config;
|
|
7
|
+
|
|
8
|
+
const { privateKey, publicKey } = generateKeyPair({
|
|
9
|
+
curve,
|
|
10
|
+
format: 'jwk',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const { CiphertextBlob } = await awsKmsClient.encrypt(
|
|
14
|
+
managedAccountsKeyId,
|
|
15
|
+
stringifyJwk(privateKey)
|
|
16
|
+
);
|
|
17
|
+
const inserted = await repos.keyPairs.insert({
|
|
18
|
+
encryptedPrivateKey: CiphertextBlob,
|
|
19
|
+
publicKey,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
publicKey,
|
|
24
|
+
keyId: inserted._id,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = { generateJwk };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const { isEmpty, find, equals } = require('lodash/fp');
|
|
2
|
+
const newError = require('http-errors');
|
|
3
|
+
const { getJwkFromDidUri } = require('@velocitycareerlabs/did-doc');
|
|
4
|
+
const { ObjectId } = require('mongodb');
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line complexity
|
|
7
|
+
const getKeyPair = async ({ kid, keyId }, context) => {
|
|
8
|
+
const { repos } = context;
|
|
9
|
+
|
|
10
|
+
await isKeyAuthorized({ kid, keyId }, context);
|
|
11
|
+
let filter;
|
|
12
|
+
if (!isEmpty(kid)) {
|
|
13
|
+
const parsedKid = getJwkFromDidUri(kid);
|
|
14
|
+
filter = {
|
|
15
|
+
'publicKey.kty': parsedKid.kty,
|
|
16
|
+
'publicKey.x': parsedKid.x,
|
|
17
|
+
'publicKey.y': parsedKid.y,
|
|
18
|
+
'publicKey.crv': parsedKid.crv,
|
|
19
|
+
};
|
|
20
|
+
} else if (!isEmpty(keyId)) {
|
|
21
|
+
filter = { _id: keyId };
|
|
22
|
+
} else {
|
|
23
|
+
throwKeyPairNotFoundError(kid);
|
|
24
|
+
}
|
|
25
|
+
const keyPair = await repos.keyPairs.findOne({
|
|
26
|
+
filter,
|
|
27
|
+
});
|
|
28
|
+
if (isEmpty(keyPair)) {
|
|
29
|
+
throwKeyPairNotFoundError(kid);
|
|
30
|
+
}
|
|
31
|
+
return keyPair;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isKeyAuthorized = async ({ kid, keyId }, ctx) => {
|
|
35
|
+
const { repos, user, verifyUserAdminScope } = ctx;
|
|
36
|
+
if (verifyUserAdminScope(user)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const account = await repos.accounts.findOne({ filter: { _id: user?.sub } });
|
|
40
|
+
let accountFind;
|
|
41
|
+
if (!isEmpty(keyId)) {
|
|
42
|
+
accountFind = find((keyInfo) => equals(new ObjectId(keyId), keyInfo.keyId));
|
|
43
|
+
} else if (!isEmpty(kid)) {
|
|
44
|
+
accountFind = find({ kid });
|
|
45
|
+
}
|
|
46
|
+
if (accountFind == null || accountFind(account?.didKeyMetadatum) == null) {
|
|
47
|
+
throwKeyPairNotFoundError(kid);
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const throwKeyPairNotFoundError = (kid) => {
|
|
53
|
+
throw newError(400, 'Key pair not found', {
|
|
54
|
+
errorCode: `invalid_${!isEmpty(kid) ? 'kid' : 'key_id'}`,
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = { getKeyPair };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const {
|
|
2
|
+
repoFactory,
|
|
3
|
+
autoboxIdsExtension,
|
|
4
|
+
} = require('@spencejs/spence-mongo-repos');
|
|
5
|
+
|
|
6
|
+
module.exports = (app, options, next = () => {}) => {
|
|
7
|
+
next();
|
|
8
|
+
return repoFactory(
|
|
9
|
+
{
|
|
10
|
+
name: 'keyPairs',
|
|
11
|
+
entityName: 'keyPairs',
|
|
12
|
+
defaultProjection: {
|
|
13
|
+
_id: 1,
|
|
14
|
+
encryptedPrivateKey: 1,
|
|
15
|
+
publicKey: 1,
|
|
16
|
+
createdAt: 1,
|
|
17
|
+
updatedAt: 1,
|
|
18
|
+
},
|
|
19
|
+
extensions: [autoboxIdsExtension],
|
|
20
|
+
},
|
|
21
|
+
app
|
|
22
|
+
);
|
|
23
|
+
};
|