@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,208 @@
|
|
|
1
|
+
const {
|
|
2
|
+
generateKeyPair,
|
|
3
|
+
createCommitment,
|
|
4
|
+
} = require('@velocitycareerlabs/crypto');
|
|
5
|
+
const nock = require('nock');
|
|
6
|
+
const { generateDocJwt } = require('@velocitycareerlabs/jwt');
|
|
7
|
+
const initRequest = require('@velocitycareerlabs/request');
|
|
8
|
+
const canonicalize = require('canonicalize');
|
|
9
|
+
const {
|
|
10
|
+
CredentialCheckResultValue,
|
|
11
|
+
} = require('@velocitycareerlabs/verifiable-credentials');
|
|
12
|
+
const {
|
|
13
|
+
pushGatewayAuth,
|
|
14
|
+
} = require('../src/controllers/api/v0.6/push/push-gateway-auth');
|
|
15
|
+
|
|
16
|
+
describe('Validate authorization token for the push gateway', () => {
|
|
17
|
+
const { privateKey: rootPrivateKey } = generateKeyPair();
|
|
18
|
+
const hostUrl = 'https://oracle.vnf';
|
|
19
|
+
const traceId = '123b';
|
|
20
|
+
const exchangeId = '234a';
|
|
21
|
+
const did = 'did:velocity:123';
|
|
22
|
+
const kid = `${did}#key-1`;
|
|
23
|
+
|
|
24
|
+
const verifiedProfile = ({
|
|
25
|
+
permittedVelocityServiceCategory = ['Issuer'],
|
|
26
|
+
credentialChecks = {},
|
|
27
|
+
} = {}) => ({
|
|
28
|
+
credentialChecks: {
|
|
29
|
+
TRUSTED_ISSUER: 'PASS',
|
|
30
|
+
UNEXPIRED: 'NOT_APPLICABLE',
|
|
31
|
+
UNREVOKED: 'NOT_CHECKED',
|
|
32
|
+
UNTAMPERED: 'PASS',
|
|
33
|
+
checked: new Date(),
|
|
34
|
+
...credentialChecks,
|
|
35
|
+
},
|
|
36
|
+
credentialSubject: {
|
|
37
|
+
supportsSecureMessages: false,
|
|
38
|
+
id: did,
|
|
39
|
+
permittedVelocityServiceCategory,
|
|
40
|
+
},
|
|
41
|
+
id: did,
|
|
42
|
+
issuanceDate: new Date(),
|
|
43
|
+
issuer: {
|
|
44
|
+
id: 'did:ion:root-did',
|
|
45
|
+
},
|
|
46
|
+
type: ['OrganizationBasicProfile-v1.0', 'VerifiableCredential'],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const { publicKey, privateKey } = generateKeyPair({ format: 'jwk' });
|
|
50
|
+
|
|
51
|
+
const body = {
|
|
52
|
+
testUndefined: undefined,
|
|
53
|
+
data: { exchangeId },
|
|
54
|
+
};
|
|
55
|
+
const bodyHash = createCommitment(canonicalize(body));
|
|
56
|
+
|
|
57
|
+
let authHeader;
|
|
58
|
+
let context;
|
|
59
|
+
|
|
60
|
+
beforeEach(async () => {
|
|
61
|
+
nock.cleanAll();
|
|
62
|
+
|
|
63
|
+
const authToken = await generateDocJwt({ hash: bodyHash }, privateKey, {
|
|
64
|
+
issuer: did,
|
|
65
|
+
kid,
|
|
66
|
+
subject: exchangeId,
|
|
67
|
+
audience: 'https://oracle.vnf',
|
|
68
|
+
});
|
|
69
|
+
authHeader = `Bearer ${authToken}`;
|
|
70
|
+
context = {
|
|
71
|
+
traceId,
|
|
72
|
+
config: { hostUrl, rootPrivateKey },
|
|
73
|
+
body,
|
|
74
|
+
headers: { authorization: authHeader },
|
|
75
|
+
registrarFetch: initRequest({
|
|
76
|
+
prefixUrl: 'http://registrar.localhost.test',
|
|
77
|
+
})({ log: console }),
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('Should confirm a valid auth token', async () => {
|
|
82
|
+
nock('http://registrar.localhost.test')
|
|
83
|
+
.get(`/api/v0.6/resolve-kid/${encodeURIComponent(kid)}?format=jwk`)
|
|
84
|
+
.reply(200, publicKey);
|
|
85
|
+
nock('http://registrar.localhost.test')
|
|
86
|
+
.get(
|
|
87
|
+
`/api/v0.6/organizations/${encodeURIComponent(did)}/verified-profile`
|
|
88
|
+
)
|
|
89
|
+
.reply(200, verifiedProfile());
|
|
90
|
+
await pushGatewayAuth(context);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('Should throw an error if invalid hash', async () => {
|
|
94
|
+
nock('http://registrar.localhost.test')
|
|
95
|
+
.get(`/api/v0.6/resolve-kid/${encodeURIComponent(kid)}?format=jwk`)
|
|
96
|
+
.reply(200, publicKey);
|
|
97
|
+
|
|
98
|
+
await expect(
|
|
99
|
+
pushGatewayAuth({
|
|
100
|
+
...context,
|
|
101
|
+
body: { ...body, newKey: 'the initial parameters was changed' },
|
|
102
|
+
})
|
|
103
|
+
).rejects.toMatchObject({
|
|
104
|
+
message: 'Invalid hash',
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('Should throw an error if kid cannot be resolved', async () => {
|
|
109
|
+
nock('http://registrar.localhost.test')
|
|
110
|
+
.get(`/api/v0.6/resolve-kid/${encodeURIComponent(kid)}?format=jwk`)
|
|
111
|
+
.reply(404, publicKey);
|
|
112
|
+
|
|
113
|
+
await expect(pushGatewayAuth(context)).rejects.toMatchObject({
|
|
114
|
+
message: 'kid_not_found',
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('Should throw an error if kid resolution encounters an error', async () => {
|
|
119
|
+
nock('http://registrar.localhost.test')
|
|
120
|
+
.get(`/api/v0.6/resolve-kid/${encodeURIComponent(kid)}?format=jwk`)
|
|
121
|
+
.reply(500);
|
|
122
|
+
|
|
123
|
+
await expect(pushGatewayAuth(context)).rejects.toMatchObject({
|
|
124
|
+
message: 'kid_resolution_error',
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('Should throw an error if did cannot be found', async () => {
|
|
129
|
+
nock('http://registrar.localhost.test')
|
|
130
|
+
.get(`/api/v0.6/resolve-kid/${encodeURIComponent(kid)}?format=jwk`)
|
|
131
|
+
.reply(200, publicKey);
|
|
132
|
+
nock('http://registrar.localhost.test')
|
|
133
|
+
.get(
|
|
134
|
+
`/api/v0.6/organizations/${encodeURIComponent(did)}/verified-profile`
|
|
135
|
+
)
|
|
136
|
+
.reply(404);
|
|
137
|
+
|
|
138
|
+
await expect(pushGatewayAuth(context)).rejects.toMatchObject({
|
|
139
|
+
message: 'issuer_not_found',
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('Should throw an error if did cannot be resolved', async () => {
|
|
144
|
+
nock('http://registrar.localhost.test')
|
|
145
|
+
.get(`/api/v0.6/resolve-kid/${encodeURIComponent(kid)}?format=jwk`)
|
|
146
|
+
.reply(200, publicKey);
|
|
147
|
+
nock('http://registrar.localhost.test')
|
|
148
|
+
.get(
|
|
149
|
+
`/api/v0.6/organizations/${encodeURIComponent(did)}/verified-profile`
|
|
150
|
+
)
|
|
151
|
+
.reply(500);
|
|
152
|
+
|
|
153
|
+
await expect(pushGatewayAuth(context)).rejects.toMatchObject({
|
|
154
|
+
message: 'issuer_resolution_error',
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
it('Should throw an error if invalid permittedVelocityServiceCategory', async () => {
|
|
158
|
+
nock('http://registrar.localhost.test')
|
|
159
|
+
.get(`/api/v0.6/resolve-kid/${encodeURIComponent(kid)}?format=jwk`)
|
|
160
|
+
.reply(200, publicKey);
|
|
161
|
+
nock('http://registrar.localhost.test')
|
|
162
|
+
.get(
|
|
163
|
+
`/api/v0.6/organizations/${encodeURIComponent(did)}/verified-profile`
|
|
164
|
+
)
|
|
165
|
+
.reply(200, verifiedProfile({ permittedVelocityServiceCategory: [] }));
|
|
166
|
+
|
|
167
|
+
await expect(pushGatewayAuth(context)).rejects.toMatchObject({
|
|
168
|
+
message:
|
|
169
|
+
// eslint-disable-next-line max-len
|
|
170
|
+
'Invalid organization profile due to permitted service categories do not include one of IdentityIssuer,IdDocumentIssuer,NotaryIdDocumentIssuer,ContactIssuer,NotaryContactIssuer,NotaryIssuer,Issuer,Inspector',
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('Should throw an error if verify organisation not pass', async () => {
|
|
175
|
+
const failedChecks = [
|
|
176
|
+
{
|
|
177
|
+
check: { UNEXPIRED: CredentialCheckResultValue.FAIL },
|
|
178
|
+
message: 'Invalid organization profile due to expired_credential',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
check: { UNTAMPERED: CredentialCheckResultValue.FAIL },
|
|
182
|
+
message: 'Invalid organization profile due to tampered_credential',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
check: { TRUSTED_ISSUER: CredentialCheckResultValue.FAIL },
|
|
186
|
+
message: 'Invalid organization profile due to untrusted_issuer',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
check: { UNREVOKED: CredentialCheckResultValue.FAIL },
|
|
190
|
+
message: 'Invalid organization profile due to revoked_credential',
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
for (const { check, message } of failedChecks) {
|
|
195
|
+
nock('http://registrar.localhost.test')
|
|
196
|
+
.get(`/api/v0.6/resolve-kid/${encodeURIComponent(kid)}?format=jwk`)
|
|
197
|
+
.reply(200, publicKey);
|
|
198
|
+
nock('http://registrar.localhost.test')
|
|
199
|
+
.get(
|
|
200
|
+
`/api/v0.6/organizations/${encodeURIComponent(did)}/verified-profile`
|
|
201
|
+
)
|
|
202
|
+
.reply(200, verifiedProfile({ credentialChecks: { ...check } }));
|
|
203
|
+
|
|
204
|
+
// eslint-disable-next-line no-await-in-loop
|
|
205
|
+
await expect(pushGatewayAuth(context)).rejects.toThrowError(message);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
|
+
|
|
3
|
+
const url = '/reference/countries';
|
|
4
|
+
|
|
5
|
+
describe('Reference countries Test Suite', () => {
|
|
6
|
+
let fastify;
|
|
7
|
+
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
fastify = buildFastify();
|
|
10
|
+
await fastify.ready();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
beforeEach(async () => {});
|
|
14
|
+
|
|
15
|
+
afterAll(async () => {
|
|
16
|
+
await fastify.close();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('Should 400 with malformatted "lge" query parameter', async () => {
|
|
20
|
+
const response = await fastify.injectJson({
|
|
21
|
+
method: 'GET',
|
|
22
|
+
url: `${url}?lge=foo`,
|
|
23
|
+
});
|
|
24
|
+
expect(response.statusCode).toEqual(400);
|
|
25
|
+
expect(response.json.message).toEqual('"lge" query parameter is malformed');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('Should 200 fallback to english with an unsupported "lge" query parameter', async () => {
|
|
29
|
+
const response = await fastify.injectJson({
|
|
30
|
+
method: 'GET',
|
|
31
|
+
url: `${url}?lge=zz`,
|
|
32
|
+
});
|
|
33
|
+
expect(response.statusCode).toEqual(200);
|
|
34
|
+
expect(response.json[1].name).toEqual('Albania');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('Should 200 default to english version without "lge" query parameter', async () => {
|
|
38
|
+
const response = await fastify.injectJson({
|
|
39
|
+
method: 'GET',
|
|
40
|
+
url,
|
|
41
|
+
});
|
|
42
|
+
expect(response.statusCode).toEqual(200);
|
|
43
|
+
expect(response.json[1].name).toEqual('Albania');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
const { first, map, omit } = require('lodash/fp');
|
|
2
|
+
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
3
|
+
const nock = require('nock');
|
|
4
|
+
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
5
|
+
const initPersonaFactory = require('./factories/persona-factory');
|
|
6
|
+
|
|
7
|
+
const url = '/reference/personas';
|
|
8
|
+
|
|
9
|
+
describe('Reference personas', () => {
|
|
10
|
+
let fastify;
|
|
11
|
+
let persistPersona;
|
|
12
|
+
|
|
13
|
+
beforeAll(async () => {
|
|
14
|
+
fastify = buildFastify();
|
|
15
|
+
await fastify.ready();
|
|
16
|
+
({ persistPersona } = initPersonaFactory(fastify));
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
nock.cleanAll();
|
|
21
|
+
mongoDb().collection('personas').deleteMany({});
|
|
22
|
+
mongoDb().collection('credentialSchemas').deleteMany({});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterAll(async () => {
|
|
26
|
+
await fastify.close();
|
|
27
|
+
nock.cleanAll();
|
|
28
|
+
nock.restore();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('Should 200 with empty array if no personas setup', async () => {
|
|
32
|
+
const response = await fastify.injectJson({
|
|
33
|
+
method: 'GET',
|
|
34
|
+
url,
|
|
35
|
+
});
|
|
36
|
+
expect(response.statusCode).toEqual(200);
|
|
37
|
+
expect(response.json).toEqual([]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should 200 personas even if the credential descriptor doesnt exist', async () => {
|
|
41
|
+
nock('http://registrar.localhost.test')
|
|
42
|
+
.get(
|
|
43
|
+
'/api/v0.6/credential-type-descriptors/NoManifestType?includeDisplay=true'
|
|
44
|
+
)
|
|
45
|
+
.reply(404);
|
|
46
|
+
|
|
47
|
+
const personas = await Promise.all([
|
|
48
|
+
persistPersona({
|
|
49
|
+
vcs: [
|
|
50
|
+
{
|
|
51
|
+
type: ['NoManifestType'],
|
|
52
|
+
jwt_vc: 'eyesdklfsdkkljsd456',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
}),
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
const response = await fastify.injectJson({
|
|
59
|
+
method: 'GET',
|
|
60
|
+
url,
|
|
61
|
+
});
|
|
62
|
+
expect(response.statusCode).toEqual(200);
|
|
63
|
+
expect(response.json).toEqual(
|
|
64
|
+
map(
|
|
65
|
+
(persona) => ({
|
|
66
|
+
...omit(['_id'], persona),
|
|
67
|
+
vcs: map(
|
|
68
|
+
(vc) => ({
|
|
69
|
+
...vc,
|
|
70
|
+
output_descriptors: [
|
|
71
|
+
{
|
|
72
|
+
id: first(vc.type),
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
}),
|
|
76
|
+
persona.vcs
|
|
77
|
+
),
|
|
78
|
+
}),
|
|
79
|
+
personas
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
expect(response.json).toHaveLength(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('Should 200 personas if persona setup', async () => {
|
|
86
|
+
nock('http://registrar.localhost.test')
|
|
87
|
+
.get(
|
|
88
|
+
'/api/v0.6/credential-type-descriptors/EducationDegreeGraduationV1.0?includeDisplay=true'
|
|
89
|
+
)
|
|
90
|
+
.reply(200, {
|
|
91
|
+
id: 'EducationDegreeGraduationV1.0',
|
|
92
|
+
display: { title: { text: 'Education Degree' } },
|
|
93
|
+
});
|
|
94
|
+
nock('http://registrar.localhost.test')
|
|
95
|
+
.get(
|
|
96
|
+
'/api/v0.6/credential-type-descriptors/EmailV1.0?includeDisplay=true'
|
|
97
|
+
)
|
|
98
|
+
.reply(200, {
|
|
99
|
+
id: 'EmailV1.0',
|
|
100
|
+
display: { title: { text: 'Email' } },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const didKeyMetadatum = {
|
|
104
|
+
did: 'did:example:123456789abcdefghi',
|
|
105
|
+
kid: 'did:example:123456789abcdefghi#0',
|
|
106
|
+
keyId: '65ba702ac8670c687d3b066f',
|
|
107
|
+
publicJwk: {
|
|
108
|
+
crv: 'secp256k1',
|
|
109
|
+
kty: 'EC',
|
|
110
|
+
x: 'e907f5476c57e73423f1c9b393bc1d0a4d56280ac155396cc879f2441a523cdc',
|
|
111
|
+
y: '89d4dcc86d540c6eea39d178eedc30213e782f251e03b76f4273106808dd0d4f',
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const [personaWithoutDid, personaWithDid] = await Promise.all([
|
|
116
|
+
persistPersona({
|
|
117
|
+
vcs: [
|
|
118
|
+
{
|
|
119
|
+
type: ['EducationDegreeGraduationV1.0'],
|
|
120
|
+
jwt_vc: 'eyesdklfsdkkljsd456',
|
|
121
|
+
},
|
|
122
|
+
{ type: ['EmailV1.0'], jwt_vc: 'caccacacaacacaca123' },
|
|
123
|
+
],
|
|
124
|
+
}),
|
|
125
|
+
persistPersona({
|
|
126
|
+
name: 'Jane Foobar',
|
|
127
|
+
email: 'jane.foobar@example.com',
|
|
128
|
+
vcs: [{ type: ['EmailV1.0'], jwt_vc: 'caccacacaacacaca123' }],
|
|
129
|
+
...didKeyMetadatum,
|
|
130
|
+
}),
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
const response = await fastify.injectJson({
|
|
134
|
+
method: 'GET',
|
|
135
|
+
url,
|
|
136
|
+
});
|
|
137
|
+
expect(response.statusCode).toEqual(200);
|
|
138
|
+
expect(response.json).toEqual(
|
|
139
|
+
expect.arrayContaining([
|
|
140
|
+
{
|
|
141
|
+
...omit(['_id'], personaWithoutDid),
|
|
142
|
+
vcs: map(
|
|
143
|
+
(vc) => ({
|
|
144
|
+
...vc,
|
|
145
|
+
output_descriptors: [
|
|
146
|
+
{
|
|
147
|
+
id: first(vc.type),
|
|
148
|
+
display: expect.objectContaining({
|
|
149
|
+
title: expect.any(Object),
|
|
150
|
+
}),
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
}),
|
|
154
|
+
personaWithoutDid.vcs
|
|
155
|
+
),
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
...omit(['_id'], personaWithDid),
|
|
159
|
+
...didKeyMetadatum,
|
|
160
|
+
vcs: map(
|
|
161
|
+
(vc) => ({
|
|
162
|
+
...vc,
|
|
163
|
+
output_descriptors: [
|
|
164
|
+
{
|
|
165
|
+
id: first(vc.type),
|
|
166
|
+
display: expect.objectContaining({
|
|
167
|
+
title: expect.any(Object),
|
|
168
|
+
}),
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
}),
|
|
172
|
+
personaWithDid.vcs
|
|
173
|
+
),
|
|
174
|
+
},
|
|
175
|
+
])
|
|
176
|
+
);
|
|
177
|
+
expect(response.json).toHaveLength(2);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
|
+
|
|
3
|
+
describe('root healthcheck', () => {
|
|
4
|
+
let fastify;
|
|
5
|
+
beforeAll(async () => {
|
|
6
|
+
fastify = buildFastify();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
afterAll(async () => {
|
|
10
|
+
await fastify.close();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should generate text', async () => {
|
|
14
|
+
const result = await fastify.inject({
|
|
15
|
+
method: 'GET',
|
|
16
|
+
url: '/',
|
|
17
|
+
});
|
|
18
|
+
expect(result.statusCode).toEqual(200);
|
|
19
|
+
expect(result.body).not.toBe(null);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
|
+
|
|
3
|
+
describe('swagger json', () => {
|
|
4
|
+
let fastify;
|
|
5
|
+
beforeAll(async () => {
|
|
6
|
+
fastify = buildFastify();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
afterAll(async () => {
|
|
10
|
+
await fastify.close();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should generate json', async () => {
|
|
14
|
+
const result = await fastify.injectJson({
|
|
15
|
+
method: 'GET',
|
|
16
|
+
url: 'documentation/json',
|
|
17
|
+
});
|
|
18
|
+
expect(result.statusCode).toEqual(200);
|
|
19
|
+
expect(result.json).not.toBe(null);
|
|
20
|
+
});
|
|
21
|
+
});
|