@velocitycareerlabs/server-webwallet 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 +57 -0
- package/.standalone.env +22 -0
- package/LICENSE +248 -0
- package/README.md +11 -0
- package/jest.config.js +20 -0
- package/migrate-mongo.config.js +23 -0
- package/package.json +72 -0
- package/src/config/config.js +74 -0
- package/src/controllers/accounts/autohooks.js +28 -0
- package/src/controllers/accounts/controller.js +209 -0
- package/src/controllers/accounts/schemas/index.js +6 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-request.schema.js +25 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-response.schema.js +72 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-update-request.schema.js +23 -0
- package/src/controllers/accounts/schemas/webwallet-test-personas-response.schema.js +110 -0
- package/src/controllers/consent/autohooks.js +14 -0
- package/src/controllers/consent/controller.js +91 -0
- package/src/controllers/consent/schemas/index.js +3 -0
- package/src/controllers/consent/schemas/webwallet-consent-response.schema.js +23 -0
- package/src/controllers/credentials/autohooks.js +36 -0
- package/src/controllers/credentials/controller.js +92 -0
- package/src/controllers/credentials/schemas/index.js +4 -0
- package/src/controllers/credentials/schemas/webwallet-credential-categories-response.schema.js +21 -0
- package/src/controllers/credentials/schemas/webwallet-credentials-response.schema.js +29 -0
- package/src/controllers/disclosures/autohooks.js +21 -0
- package/src/controllers/disclosures/controller.js +168 -0
- package/src/controllers/disclosures/schemas/index.js +7 -0
- package/src/controllers/disclosures/schemas/webwallet-accept-presentation-request-body.schema.js +28 -0
- package/src/controllers/disclosures/schemas/webwallet-accept-presentation-response.schema.js +16 -0
- package/src/controllers/disclosures/schemas/webwallet-get-disclosures-response.schema.js +18 -0
- package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-query.schema.js +21 -0
- package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-response.schema.js +16 -0
- package/src/controllers/feedback/autohooks.js +11 -0
- package/src/controllers/feedback/controller.js +48 -0
- package/src/controllers/issuing/common-schemas/index.js +10 -0
- package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-query.schema.js +27 -0
- package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-response.schema.js +31 -0
- package/src/controllers/issuing/deep-link/autohooks.js +51 -0
- package/src/controllers/issuing/deep-link/controller.js +192 -0
- package/src/controllers/issuing/deep-link/schemas/index.js +6 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-accept-offers-request.schema.js +30 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-accept-offers-response.schema.js +36 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-offers-request.schema.js +28 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-offers-response.schema.js +48 -0
- package/src/controllers/issuing/identity-credentials/autohooks.js +42 -0
- package/src/controllers/issuing/identity-credentials/controller.js +188 -0
- package/src/controllers/issuing/identity-credentials/schemas/index.js +6 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-confirm-body.schema.js +20 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-confirm-response.schema.js +37 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-request-code-body.schema.js +14 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-request-code-params.schema.js +19 -0
- package/src/controllers/linkedin/autohooks.js +16 -0
- package/src/controllers/linkedin/controller.js +276 -0
- package/src/controllers/linkedin/schemas/index.js +3 -0
- package/src/controllers/linkedin/schemas/webwallet-linkedin-me-response.schema.js +14 -0
- package/src/controllers/root/controller.js +29 -0
- package/src/entities/.gitkeep +0 -0
- package/src/entities/accounts/constants.js +5 -0
- package/src/entities/accounts/domains/extract-auth0-id-token-or-access-token.js +22 -0
- package/src/entities/accounts/domains/index.js +5 -0
- package/src/entities/accounts/domains/validate-account-permissions.js +36 -0
- package/src/entities/accounts/domains/validate-logo-size.js +25 -0
- package/src/entities/accounts/index.js +5 -0
- package/src/entities/accounts/repos/accounts.repo.js +63 -0
- package/src/entities/credentials/domains/index.js +3 -0
- package/src/entities/credentials/domains/offer-to-credential-mongo-dto.js +43 -0
- package/src/entities/credentials/index.js +6 -0
- package/src/entities/credentials/orchestrators/index.js +3 -0
- package/src/entities/credentials/orchestrators/load-additional-render-info.js +65 -0
- package/src/entities/credentials/repos/credentials.repo.js +132 -0
- package/src/entities/credentials/schemas/index.js +4 -0
- package/src/entities/credentials/schemas/webwallet-credential-response.schema.js +138 -0
- package/src/entities/credentials/schemas/webwallet-credentials-response.schemas.js +95 -0
- package/src/entities/credentials/schemas/webwallet-display-descriptor-response.schema.js +106 -0
- package/src/entities/disclosures/index.js +4 -0
- package/src/entities/disclosures/repos/disclosures.repo.js +31 -0
- package/src/entities/disclosures/schemas/index.js +10 -0
- package/src/entities/disclosures/schemas/webwallet-disclosure.schema.js +39 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-field.schema.js +45 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-filter.schema.js +30 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-format.schema.js +36 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-input-descriptors.schema.js +111 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-schema.schema.js +14 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-submission-requirements.schema.js +37 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request.schema.js +79 -0
- package/src/entities/index.js +6 -0
- package/src/entities/issuing/domain/constants.js +8 -0
- package/src/entities/issuing/domain/does-user-have-fresh-pending-verification.js +26 -0
- package/src/entities/issuing/domain/get-credentials-from-offers.js +18 -0
- package/src/entities/issuing/domain/index.js +5 -0
- package/src/entities/issuing/index.js +5 -0
- package/src/entities/issuing/orchestrators/build-issuing-input-credentials.js +35 -0
- package/src/entities/issuing/orchestrators/generate-offers-by-deep-link.js +74 -0
- package/src/entities/issuing/orchestrators/get-identity-issuer.js +35 -0
- package/src/entities/issuing/orchestrators/get-identity-offers-by-deeplink.js +74 -0
- package/src/entities/issuing/orchestrators/index.js +6 -0
- package/src/entities/issuing/schemas/index.js +9 -0
- package/src/entities/issuing/schemas/webwallet-credential-manifest.schema.js +198 -0
- package/src/errors/error-codes.js +12 -0
- package/src/fetchers/career-wallet/create-account-fetcher.js +7 -0
- package/src/fetchers/career-wallet/create-did-fetcher.js +17 -0
- package/src/fetchers/career-wallet/get-app-config.js +11 -0
- package/src/fetchers/career-wallet/get-consents.js +13 -0
- package/src/fetchers/career-wallet/get-credential-categories.js +7 -0
- package/src/fetchers/career-wallet/get-personas.js +7 -0
- package/src/fetchers/career-wallet/index.js +12 -0
- package/src/fetchers/career-wallet/post-consent.js +9 -0
- package/src/fetchers/career-wallet/send-feedback.js +14 -0
- package/src/fetchers/career-wallet/sign-fetcher.js +14 -0
- package/src/fetchers/career-wallet/verify-id-credential-confirm-code.js +19 -0
- package/src/fetchers/career-wallet/verify-id-credential-request-code.js +20 -0
- package/src/fetchers/index.js +4 -0
- package/src/fetchers/lib-api/get-credential-display-schema.js +12 -0
- package/src/fetchers/lib-api/index.js +3 -0
- package/src/fetchers/linkedin/create-linkedin-post.js +45 -0
- package/src/fetchers/linkedin/get-access-token.js +26 -0
- package/src/fetchers/linkedin/get-linkedin-user-email.js +13 -0
- package/src/fetchers/linkedin/get-linkedin-user-id.js +16 -0
- package/src/fetchers/linkedin/index.js +9 -0
- package/src/fetchers/linkedin/register-image-to-upload.js +30 -0
- package/src/fetchers/linkedin/revoke-linkedin-access.js +20 -0
- package/src/fetchers/linkedin/upload-image-to-linkedin.js +16 -0
- package/src/index.js +15 -0
- package/src/init-server.js +108 -0
- package/src/plugins/crypto-services/index.js +5 -0
- package/src/plugins/crypto-services/jwt-sign-service-impl.js +72 -0
- package/src/plugins/crypto-services/jwt-verify-service-impl.js +21 -0
- package/src/plugins/crypto-services/key-service-impl.js +28 -0
- package/src/plugins/fetch-errors-handler-plugin.js +64 -0
- package/src/plugins/index.js +4 -0
- package/src/plugins/vnf-sdk-plugin.js +53 -0
- package/src/standalone.js +8 -0
- package/test/accounts-controller.test.js +618 -0
- package/test/consent-controller.test.js +185 -0
- package/test/credentials-controller.test.js +307 -0
- package/test/crypro-services/jwt-sign-service-impl.test.js +83 -0
- package/test/crypro-services/jwt-verify-service-impl.test.js +27 -0
- package/test/crypro-services/key-service-impl.test.js +76 -0
- package/test/crypro-services/mocks/index.js +4 -0
- package/test/crypro-services/mocks/jwt-mock.js +15 -0
- package/test/crypro-services/mocks/public-jwk.js +14 -0
- package/test/disclosures-controller/disclosure-credentials.test.js +428 -0
- package/test/disclosures-controller/get-disclosures.test.js +169 -0
- package/test/disclosures-controller/mocks/get-credential-manifest.js +20 -0
- package/test/disclosures-controller/mocks/index.js +6 -0
- package/test/disclosures-controller/mocks/presentation-request.js +32 -0
- package/test/disclosures-controller/mocks/presentation-submission.js +21 -0
- package/test/disclosures-controller/mocks/submission-result.js +19 -0
- package/test/factories/accounts.js +25 -0
- package/test/factories/credentials.js +66 -0
- package/test/factories/disclosures.js +106 -0
- package/test/feedback-controller.test.js +125 -0
- package/test/fetch-errors-handler-plugin.test.js +97 -0
- package/test/filter-deleted-credentials-extension.test.js +82 -0
- package/test/helpers/.env.test +10 -0
- package/test/helpers/nock-consent-add.js +16 -0
- package/test/helpers/nock-consents-get.js +15 -0
- package/test/helpers/nock-feedback.js +9 -0
- package/test/helpers/nock-linkedin-access-token.js +9 -0
- package/test/helpers/nock-linkedin-email.js +15 -0
- package/test/helpers/nock-linkedin-image-register.js +28 -0
- package/test/helpers/nock-linkedin-me.js +13 -0
- package/test/helpers/nock-linkedin-post.js +37 -0
- package/test/helpers/nock-linkedin-revoke.js +9 -0
- package/test/helpers/nock-test-personas.js +13 -0
- package/test/helpers/webwallet-build-fastify.js +17 -0
- package/test/issuing-controller/issuing-by-deeplink-empty-offers.test.js +142 -0
- package/test/issuing-controller/issuing-by-deeplink-failed-offers.test.js +142 -0
- package/test/issuing-controller/issuing-by-deeplink.test.js +492 -0
- package/test/issuing-controller/issuing-identity-credentials.test.js +377 -0
- package/test/issuing-controller/mocks/accept-offers-response.js +90 -0
- package/test/issuing-controller/mocks/accepted-credentials.js +47 -0
- package/test/issuing-controller/mocks/credential-manifest-presentation.js +72 -0
- package/test/issuing-controller/mocks/credential-manifest.js +45 -0
- package/test/issuing-controller/mocks/identity-issuing/accept-offers.js +22 -0
- package/test/issuing-controller/mocks/identity-issuing/confirm-verification-code.js +5 -0
- package/test/issuing-controller/mocks/identity-issuing/get-app-config.js +52 -0
- package/test/issuing-controller/mocks/identity-issuing/get-organization.js +118 -0
- package/test/issuing-controller/mocks/identity-issuing/index.js +6 -0
- package/test/issuing-controller/mocks/index.js +6 -0
- package/test/issuing-controller/mocks/issuers.js +126 -0
- package/test/issuing-controller/mocks/offers.js +48 -0
- package/test/issuing-controller/mocks/schema.js +107 -0
- package/test/linkedin-controller.test.js +452 -0
- package/test/mocks/credential-categories.js +115 -0
- package/test/mocks/credentials.js +15 -0
- package/test/mocks/didjwk.js +25 -0
- package/test/mocks/index.js +7 -0
- package/test/mocks/issuers.js +88 -0
- package/test/mocks/jwk.js +53 -0
- package/test/mocks/schema.js +107 -0
- package/test/root.test.js +42 -0
- package/test/vcl-sdk-plugin.test.js +86 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
const {
|
|
3
|
+
VCLPresentationSubmission,
|
|
4
|
+
} = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
|
|
5
|
+
const { CredentialMocks } = require('../../mocks/credentials');
|
|
6
|
+
const { presentationRequestMock } = require('./presentation-request');
|
|
7
|
+
|
|
8
|
+
const presentationSubmissionMock = new VCLPresentationSubmission(
|
|
9
|
+
presentationRequestMock,
|
|
10
|
+
[
|
|
11
|
+
{
|
|
12
|
+
id: 'credential_id',
|
|
13
|
+
inputDescriptor: 'EducationDegreeGraduationV1.1',
|
|
14
|
+
jwtVc: CredentialMocks.JwtCredentialEmail,
|
|
15
|
+
},
|
|
16
|
+
]
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
presentationSubmissionMock,
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
const {
|
|
3
|
+
VCLSubmissionResult,
|
|
4
|
+
VCLExchange,
|
|
5
|
+
VCLToken,
|
|
6
|
+
} = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
|
|
7
|
+
|
|
8
|
+
const submissionResultMock = new VCLSubmissionResult(
|
|
9
|
+
new VCLToken(
|
|
10
|
+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
|
|
11
|
+
),
|
|
12
|
+
new VCLExchange('65788639770790a0fdff7c8e', 'DISCLOSURE', true, true),
|
|
13
|
+
'6362860a-9be2-4357-a7da-599dc62136da',
|
|
14
|
+
'352e0967-03ad-4dd5-81d8-5d2b45b516dc'
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
submissionResultMock,
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { register } = require('@spencejs/spence-factories');
|
|
2
|
+
const { accountsRepoPlugin } = require('../../src/entities');
|
|
3
|
+
|
|
4
|
+
module.exports = (app) => {
|
|
5
|
+
return register(
|
|
6
|
+
'accounts',
|
|
7
|
+
accountsRepoPlugin(app)({ config: app.config }),
|
|
8
|
+
async (overrides) => {
|
|
9
|
+
return {
|
|
10
|
+
userId: '1234567890',
|
|
11
|
+
did: 'did:example:123',
|
|
12
|
+
profileName: 'Test Profile',
|
|
13
|
+
verificationInfo: {
|
|
14
|
+
email: {
|
|
15
|
+
status: 'verified',
|
|
16
|
+
},
|
|
17
|
+
phone: {
|
|
18
|
+
status: 'verified',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
...overrides(),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const { register } = require('@spencejs/spence-factories');
|
|
2
|
+
const { VelocityRevocationListType } = require('@velocitycareerlabs/vc-checks');
|
|
3
|
+
const { credentialsRepoPlugin } = require('../../src/entities');
|
|
4
|
+
|
|
5
|
+
module.exports = (app) => {
|
|
6
|
+
return register(
|
|
7
|
+
'credentials',
|
|
8
|
+
credentialsRepoPlugin(app)({ config: app.config }),
|
|
9
|
+
async (overrides) => {
|
|
10
|
+
return {
|
|
11
|
+
auth0UserId: '1234567890',
|
|
12
|
+
did: 'did:test:1',
|
|
13
|
+
userDid: 'did:test:2',
|
|
14
|
+
type: ['OpenBadgeV2.0'],
|
|
15
|
+
issuer: {
|
|
16
|
+
id: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
|
|
17
|
+
},
|
|
18
|
+
contentHash: {
|
|
19
|
+
type: 'VelocityContentHash2020',
|
|
20
|
+
value:
|
|
21
|
+
'e6111d72559b84448ee3c844d4d3dafaa63cf97091ee203c68e257fab9cf0337',
|
|
22
|
+
},
|
|
23
|
+
context: [
|
|
24
|
+
'https://www.w3.org/2018/credentials/v1',
|
|
25
|
+
'https://devlib.velocitynetwork.foundation/contexts/credential-extensions-2022.jsonld.json',
|
|
26
|
+
],
|
|
27
|
+
credentialSchema: {
|
|
28
|
+
id: 'https://devregistrar.velocitynetwork.foundation/schemas/open-badge-v2.0.schema.json',
|
|
29
|
+
type: 'JsonSchemaValidator2018',
|
|
30
|
+
},
|
|
31
|
+
credentialStatus: {
|
|
32
|
+
// eslint-disable-next-line max-len
|
|
33
|
+
id: 'ethereum:0xD890F2D60B429f9e257FC0Bc58Ef2237776DD91B/getRevokedStatus?address=0xa27F300621a7474A68fd5a417D9560d24f9d9F74&listId=255664421176378&index=3270',
|
|
34
|
+
statusListCredential:
|
|
35
|
+
// eslint-disable-next-line max-len
|
|
36
|
+
'ethereum:0xD890F2D60B429f9e257FC0Bc58Ef2237776DD91B/getRevokedStatus?address=0xa27F300621a7474A68fd5a417D9560d24f9d9F74&listId=255664421176378',
|
|
37
|
+
statusListIndex: 3270,
|
|
38
|
+
type: VelocityRevocationListType,
|
|
39
|
+
},
|
|
40
|
+
credentialSubject: {
|
|
41
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
42
|
+
hasCredential: {
|
|
43
|
+
criteria: 'https://example.com/velocity-badge.html',
|
|
44
|
+
description: 'For issuing a Badge on the Velocity Network',
|
|
45
|
+
id: 'https://example.com/velocity-badge.json',
|
|
46
|
+
image:
|
|
47
|
+
'https://www.velocitynetwork.foundation/wp-content/uploads/2020/02/fb.jpg',
|
|
48
|
+
issuer: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
|
|
49
|
+
name: 'Velocity Badge',
|
|
50
|
+
type: 'BadgeClass',
|
|
51
|
+
},
|
|
52
|
+
type: 'Badge',
|
|
53
|
+
},
|
|
54
|
+
iss: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
|
|
55
|
+
jti: 'did:velocity:v2:0xa27f300621a7474a68fd5a417d9560d24f9d9f74:56898051534679:2985',
|
|
56
|
+
linkCodeCommitment: {
|
|
57
|
+
type: 'VelocityCredentialLinkCodeCommitment2022',
|
|
58
|
+
value: 'EiBYXN+pEkLCGjtMvZGBMj6mQQeNtS6iaD6E6ZdhtC98Ng==',
|
|
59
|
+
},
|
|
60
|
+
encodedCredential: 'mockedEncodedCredential',
|
|
61
|
+
vnfProtocolVersion: 1,
|
|
62
|
+
...overrides(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const { register } = require('@spencejs/spence-factories');
|
|
2
|
+
const { disclosuresRepoPlugin } = require('../../src/entities/disclosures');
|
|
3
|
+
|
|
4
|
+
module.exports = (app) => {
|
|
5
|
+
return register(
|
|
6
|
+
'disclosures',
|
|
7
|
+
disclosuresRepoPlugin(app)({ config: app.config }),
|
|
8
|
+
async (overrides) => {
|
|
9
|
+
return {
|
|
10
|
+
auth0UserId: '1234567890',
|
|
11
|
+
userDid: 'did:test-user:1',
|
|
12
|
+
jti: '8b67c34b-5920-4527-a86f-e9e8ac359341',
|
|
13
|
+
submissionId: 'a46e7063-8d2d-4e21-b9f0-66229c3fe028',
|
|
14
|
+
presentationDefinitionId:
|
|
15
|
+
'657b15a1b4de9ac4f06b63ee.6576d7de30b7cd12f669d900',
|
|
16
|
+
encodedJwt:
|
|
17
|
+
// eslint-disable-next-line max-len
|
|
18
|
+
'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksiLCJraWQiOiJkaWQ6aW9uOkVpQXBNTGRNYjROUGI4c2FlOS1oWEdIUDc5VzFnaXNBcFZTRTgwVVNQRWJ0SkEjZXhjaGFuZ2Uta2V5LTEifQ.eyJleGNoYW5nZV9pZCI6IjY1N2IxNWExYjRkZTlhYzRmMDZiNjNlZSIsIm1ldGFkYXRhIjp7ImNsaWVudF9uYW1lIjoiVW5pdmVyc2l0eSBvZiBNYXNzYWNodXNldHRzIEFtaGVyc3QiLCJsb2dvX3VyaSI6Imh0dHBzOi8vdXBsb2FkLndpa2ltZWRpYS5vcmcvd2lraXBlZGlhL2NvbW1vbnMvNC80Zi9VTWFzc19TZWFsX01lZGl1bV9QTVNfMjAyLnBuZyIsInRvc191cmkiOiJodHRwczovL3d3dy52ZWxvY2l0eWV4cGVyaWVuY2VjZW50ZXIuY29tL3Rlcm1zLWFuZC1jb25kaXRpb25zLXZuZiIsIm1heF9yZXRlbnRpb25fcGVyaW9kIjoiNm0iLCJwcm9ncmVzc191cmkiOiJodHRwczovL2RldmFnZW50LnZlbG9jaXR5Y2FyZWVybGFicy5pby9hcGkvaG9sZGVyL3YwLjYvb3JnL2RpZDppb246RWlBcE1MZE1iNE5QYjhzYWU5LWhYR0hQNzlXMWdpc0FwVlNFODBVU1BFYnRKQS9nZXQtZXhjaGFuZ2UtcHJvZ3Jlc3MiLCJzdWJtaXRfcHJlc2VudGF0aW9uX3VyaSI6Imh0dHBzOi8vZGV2YWdlbnQudmVsb2NpdHljYXJlZXJsYWJzLmlvL2FwaS9ob2xkZXIvdjAuNi9vcmcvZGlkOmlvbjpFaUFwTUxkTWI0TlBiOHNhZTktaFhHSFA3OVcxZ2lzQXBWU0U4MFVTUEVidEpBL2luc3BlY3Qvc3VibWl0LXByZXNlbnRhdGlvbiJ9LCJwcmVzZW50YXRpb25fZGVmaW5pdGlvbiI6eyJpZCI6IjY1N2IxNWExYjRkZTlhYzRmMDZiNjNlZS42NTc2ZDdkZTMwYjdjZDEyZjY2OWQ5MDAiLCJwdXJwb3NlIjoiSm9iIEFwcGxpY2F0aW9uIiwiZm9ybWF0Ijp7Imp3dF92cCI6eyJhbGciOlsic2VjcDI1NmsxIl19fSwiaW5wdXRfZGVzY3JpcHRvcnMiOlt7ImlkIjoiQXNzZXNzbWVudFYxLjEiLCJuYW1lIjoiQXNzZXNzbWVudCIsInNjaGVtYSI6W3sidXJpIjoiaHR0cHM6Ly9kZXZsaWIudmVsb2NpdHluZXR3b3JrLmZvdW5kYXRpb24vc2NoZW1hcy9hc3Nlc3NtZW50LXYxLjEuc2NoZW1hLmpzb24ifV0sImdyb3VwIjpbIkEiXX0seyJpZCI6IkNlcnRpZmljYXRpb25WMS4xIiwibmFtZSI6IkNlcnRpZmljYXRpb24iLCJzY2hlbWEiOlt7InVyaSI6Imh0dHBzOi8vZGV2bGliLnZlbG9jaXR5bmV0d29yay5mb3VuZGF0aW9uL3NjaGVtYXMvY2VydGlmaWNhdGlvbi12MS4xLnNjaGVtYS5qc29uIn1dLCJncm91cCI6WyJBIl19LHsiaWQiOiJFZHVjYXRpb25EZWdyZWVHcmFkdWF0aW9uVjEuMSIsIm5hbWUiOiJFZHVjYXRpb24gZGVncmVlIGdyYWR1YXRpb24iLCJzY2hlbWEiOlt7InVyaSI6Imh0dHBzOi8vZGV2bGliLnZlbG9jaXR5bmV0d29yay5mb3VuZGF0aW9uL3NjaGVtYXMvZWR1Y2F0aW9uLWRlZ3JlZS1ncmFkdWF0aW9uLXYxLjEuc2NoZW1hLmpzb24ifV0sImdyb3VwIjpbIkEiXX1dLCJzdWJtaXNzaW9uX3JlcXVpcmVtZW50cyI6W3sicnVsZSI6InBpY2siLCJmcm9tIjoiQSIsIm1pbiI6MX1dfSwibmJmIjoxNzAyNTY1MjgyLCJpc3MiOiJkaWQ6aW9uOkVpQXBNTGRNYjROUGI4c2FlOS1oWEdIUDc5VzFnaXNBcFZTRTgwVVNQRWJ0SkEiLCJleHAiOjE3MDMxNzAwODIsImlhdCI6MTcwMjU2NTI4Mn0.AKj5uBWdATTZOEyA4Qla4FhVxQTiqrNG5-NKsfHUMcQAFAAo-QKR466To2m3e4t_rEI_QJNdYZJtgKe49xUDYQ',
|
|
19
|
+
presentation: {
|
|
20
|
+
exp: 1703170082,
|
|
21
|
+
iat: 1702565282,
|
|
22
|
+
iss: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
|
|
23
|
+
nbf: 1702565282,
|
|
24
|
+
presentation_definition: {
|
|
25
|
+
id: '657b15a1b4de9ac4f06b63ee.6576d7de30b7cd12f669d900',
|
|
26
|
+
purpose: 'Job Application',
|
|
27
|
+
format: {
|
|
28
|
+
jwt_vp: {
|
|
29
|
+
alg: ['secp256k1'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
submission_requirements: [
|
|
33
|
+
{
|
|
34
|
+
rule: 'pick',
|
|
35
|
+
min: 1,
|
|
36
|
+
from: 'A',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
input_descriptors: [
|
|
40
|
+
{
|
|
41
|
+
id: 'AssessmentV1.1',
|
|
42
|
+
name: 'Assessment',
|
|
43
|
+
group: ['A'],
|
|
44
|
+
schema: [
|
|
45
|
+
{
|
|
46
|
+
uri: 'https://devlib.velocitynetwork.foundation/schemas/assessment-v1.1.schema.json',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'CertificationV1.1',
|
|
52
|
+
name: 'Certification',
|
|
53
|
+
group: ['A'],
|
|
54
|
+
schema: [
|
|
55
|
+
{
|
|
56
|
+
uri: 'https://devlib.velocitynetwork.foundation/schemas/certification-v1.1.schema.json',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'EducationDegreeGraduationV1.1',
|
|
62
|
+
name: 'Education degree graduation',
|
|
63
|
+
group: ['A'],
|
|
64
|
+
schema: [
|
|
65
|
+
{
|
|
66
|
+
uri: 'https://devlib.velocitynetwork.foundation/schemas/education-degree-graduation-v1.1.schema.json',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
metadata: {
|
|
73
|
+
client_name: 'University of Massachusetts Amherst',
|
|
74
|
+
logo_uri:
|
|
75
|
+
'https://upload.wikimedia.org/wikipedia/commons/4/4f/UMass_Seal_Medium_PMS_202.png',
|
|
76
|
+
tos_uri:
|
|
77
|
+
'https://www.velocityexperiencecenter.com/terms-and-conditions-vnf',
|
|
78
|
+
max_retention_period: '6m',
|
|
79
|
+
progress_uri:
|
|
80
|
+
// eslint-disable-next-line max-len
|
|
81
|
+
'https://devagent.velocitycareerlabs.io/api/holder/v0.6/org/did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA/get-exchange-progress',
|
|
82
|
+
submit_presentation_uri:
|
|
83
|
+
// eslint-disable-next-line max-len
|
|
84
|
+
'https://devagent.velocitycareerlabs.io/api/holder/v0.6/org/did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA/inspect/submit-presentation',
|
|
85
|
+
},
|
|
86
|
+
exchange_id: '657b15a1b4de9ac4f06b63ee',
|
|
87
|
+
},
|
|
88
|
+
token:
|
|
89
|
+
// eslint-disable-next-line max-len
|
|
90
|
+
'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJqdGkiOiI2NTdiMTVhMWI0ZGU5YWM0ZjA2YjYzZWUiLCJpc3MiOiJkaWQ6aW9uOkVpQXBNTGRNYjROUGI4c2FlOS1oWEdIUDc5VzFnaXNBcFZTRTgwVVNQRWJ0SkEiLCJhdWQiOiJkaWQ6aW9uOkVpQXBNTGRNYjROUGI4c2FlOS1oWEdIUDc5VzFnaXNBcFZTRTgwVVNQRWJ0SkEiLCJleHAiOjE3MDMxNzAwODMsInN1YiI6IjY1N2IxNWEzZTU5YTFjN2FhMjg5MmFiMSIsImlhdCI6MTcwMjU2NTI4M30.hvr5tOgiZfejREm3cIr0n30ngK7iVQUkCBNNQ4eIQinuhSCwmL9K05TC1G2jX8574kR6nKLcnTjm_eqWndt6wA',
|
|
91
|
+
sharedCredentials: [
|
|
92
|
+
'654caa98663bd9cd0b080337',
|
|
93
|
+
'654ca958663bd9cd0b080335',
|
|
94
|
+
'6548fb8a28ab164c786baacd',
|
|
95
|
+
'6548fb8a28ab164c786baace',
|
|
96
|
+
'6548d2c628ab164c786baacb',
|
|
97
|
+
'6548d2c628ab164c786baacc',
|
|
98
|
+
'6548d05828ab164c786baac8',
|
|
99
|
+
],
|
|
100
|
+
createdAt: '2023-12-14T14:48:03.767Z',
|
|
101
|
+
updatedAt: '2023-12-14T14:48:03.767Z',
|
|
102
|
+
...overrides(),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
|
+
const nock = require('nock');
|
|
3
|
+
const buildFastify = require('./helpers/webwallet-build-fastify');
|
|
4
|
+
|
|
5
|
+
const initAccountsFactory = require('./factories/accounts');
|
|
6
|
+
const { nockFeedback } = require('./helpers/nock-feedback');
|
|
7
|
+
|
|
8
|
+
const auth0Token =
|
|
9
|
+
// eslint-disable-next-line max-len
|
|
10
|
+
'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IktFWSJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0LyIsImF1ZCI6ImZvbyIsInNjb3BlIjoicmVhZDp1c2VycyJ9.VwIIUqx9T-AxqbfL_FyNRAeOxTwiC2JpcwtrqnEWN3DdF07ijUkF1WYy8Ahfr_p4R3KnoPbiefZnIbVANCt-lt0ej32rfil2yHhQEsvFxSOjcrx6ARmPp0YAfWlN-5Sotzkxy29jaOZMEDkmRFZg3jkdC7wosPW_S6M-olC4g3HHfylpZI8O3Jdd87Qr9wD_QtUzANwnPbl2Q-9NEyxVjAZIWg_HWK9JAAaf_2IY5VwHBvyp0oeQSEHKi4hogcM59EOc4FxdR5WH45B_PenVa6W4mHFBkH8sAXxt2Zs9s2efujkfWYfyXvgL_lN7vT-TEADlAPP2L6CpWpDISOMsQWUSgGHcN_KwRh_E7qJwahR6mv4QHY6ReEoyjkmSS3swrD1l74jNs7QLAdsMywvzCMDsHabs7DYcEMGQBdP14PJ_ucLFnkivZeBDAc6sS445ocbyrpyO40XMaMorD5khRd9ej89SxR7d_v0W6Ne2Nn4XgW3pAZzu5Rdc4JvqfzLFxkp95jxy1MTAddjWISPmNOYYyXHM9SSqSpqVECOFS0f4z2zycHRqXUcOytWrvED6VGo9x7-IVCgu8vFzj0zToIWQmsDs3UoH9RnV12z0PMwGXQzca1lT_zGwJxBF3e4zJjmcJ05OMF2JgZ2_G48O3M4Dtb0jlgWbKLd0kWlIFzQ;';
|
|
11
|
+
|
|
12
|
+
const auth0userId = '1234567890';
|
|
13
|
+
const usersDid = 'did:example:123';
|
|
14
|
+
|
|
15
|
+
jest.mock('@velocitycareerlabs/vnf-nodejs-wallet-sdk', () => {
|
|
16
|
+
const originalModule = jest.requireActual(
|
|
17
|
+
'@velocitycareerlabs/vnf-nodejs-wallet-sdk'
|
|
18
|
+
);
|
|
19
|
+
return {
|
|
20
|
+
...originalModule,
|
|
21
|
+
VCLProvider: {
|
|
22
|
+
getInstance: jest.fn().mockReturnValue({
|
|
23
|
+
initialize: jest.fn().mockResolvedValue(null),
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
describe('feedback-controller', () => {
|
|
29
|
+
let fastify;
|
|
30
|
+
let persistAccounts;
|
|
31
|
+
|
|
32
|
+
beforeAll(async () => {
|
|
33
|
+
fastify = buildFastify();
|
|
34
|
+
nock('https://localhost/')
|
|
35
|
+
.persist()
|
|
36
|
+
.get('/.well-known/jwks.json')
|
|
37
|
+
.reply(200, jwks);
|
|
38
|
+
await fastify.ready();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterEach(async () => {
|
|
42
|
+
nock.cleanAll();
|
|
43
|
+
await mongoDb().collection('accounts').deleteMany({});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterAll(async () => {
|
|
47
|
+
nock.restore();
|
|
48
|
+
await fastify.close();
|
|
49
|
+
});
|
|
50
|
+
describe('POST feedback', () => {
|
|
51
|
+
it('should return 204 and send a user feedback', async () => {
|
|
52
|
+
({ persistAccounts } = initAccountsFactory(fastify));
|
|
53
|
+
|
|
54
|
+
await persistAccounts({
|
|
55
|
+
auth0userId,
|
|
56
|
+
usersDid,
|
|
57
|
+
careerWalletAccountId: 'mocked-user-id',
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const feedback = {
|
|
61
|
+
feedback: 'test',
|
|
62
|
+
deviceOS: 'test',
|
|
63
|
+
errorCode: 'test_error_code',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const nockInstance = nock(fastify.config.careerWalletUrl);
|
|
67
|
+
nockFeedback(nockInstance);
|
|
68
|
+
|
|
69
|
+
const response = await fastify.inject({
|
|
70
|
+
method: 'POST',
|
|
71
|
+
url: '/feedback',
|
|
72
|
+
headers: {
|
|
73
|
+
authorization: `Bearer ${auth0Token}`,
|
|
74
|
+
},
|
|
75
|
+
body: feedback,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(response.statusCode).toBe(204);
|
|
79
|
+
expect(response.body).toEqual('');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const jwks = {
|
|
85
|
+
keys: [
|
|
86
|
+
{
|
|
87
|
+
alg: 'RS512',
|
|
88
|
+
kid: 'KEY',
|
|
89
|
+
x5c: ['UNUSED'],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
alg: 'RS256',
|
|
93
|
+
kid: 'KEY',
|
|
94
|
+
x5c: [
|
|
95
|
+
`
|
|
96
|
+
MIIEnjCCAoYCCQDmnGII6qzGlTANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDDAZ1
|
|
97
|
+
bnVzZWQwHhcNMjEwOTE5MDcxODQ2WhcNMjExMDE5MDcxODQ2WjARMQ8wDQYDVQQD
|
|
98
|
+
DAZ1bnVzZWQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDY2acJ8JAH
|
|
99
|
+
XjK8j3sAXOokSWwvaEg65UJS0C7KdnfbLTeaeYFHBRY0v9Jkk/PJSXv9hMWw1aD3
|
|
100
|
+
n7NrhVwXeRXi/7VZuW/S4ek+hK+IMDvpKqzn+XeCpaMoRpAgloADeNY0qhYKxpr2
|
|
101
|
+
L0SmRQDwVy1r/g31ECewD2WpEiRSmXsQ2Q2uYT3V60BmbhUw31KGEr4SLXL9pzmb
|
|
102
|
+
arOH/5Rhqg+YFMywNY6i01S3UdOlUtAyWT/mVRAkVTsUEou9tBw61zputPdMrl7p
|
|
103
|
+
d4InmlfCmXNTPFh9EDczPQiAVPq8MDyEdRGP134+HM9+YgQUZjy+WsxmGEvplJIf
|
|
104
|
+
KrYtlWe11//oAXC3690LUYtvg49lNY4+H0/nngjnCDXkZo6f+PEvnBZfYl596VTV
|
|
105
|
+
Fx4FGNOqLwg4bAyE5j5jXtEGW1oKo1pxBg7Oe3MteQUDwMrONB3CbxdxDiN3YH94
|
|
106
|
+
2nWGW9Le+CeA1QUhfjQqSoZRJURGYGoztVuIXOElnkrgwcJreX4b8y+Uo5kpp2By
|
|
107
|
+
6UUaD/mMj9XQ+Ygp/J8DlJlqDXOIp6JUJ75aSK5ZIjRtWq/Go5RUjW9IW0ldEehh
|
|
108
|
+
/4j0ZWC0vR1/le2UmAE6tXhkH4sdx9JM84V+qRzjiGqQx3Wn00uwMiHHhte17t41
|
|
109
|
+
vk+b75wuHbfiq9R8irL6wqWeeuzvCC37NwIDAQABMA0GCSqGSIb3DQEBCwUAA4IC
|
|
110
|
+
AQCZOT6S5HLUp0gBtWK6Fxyzb9lWPE+AJipjJ80lS3OnaOIyVtyJexJ2BjTKWldJ
|
|
111
|
+
48zkzLNIRsTEGEipNS6NkrkElfmoaNBpdbDch2WBkME3UYlFIR9GgbXPMlACQlwJ
|
|
112
|
+
f4qT3iIZ9zjpVMP8F63TzRRr7KEYW2PGHEtVQktMPprGEfU4Sz0OIa9RRV+BLsfh
|
|
113
|
+
x8he2pimJEzoEaWPgyJXV1S+tLUif8A/CEkZVRZ2vADA7WMGl2ZTdbmsTjXh4bf2
|
|
114
|
+
A4l4Zec+jwOjUPiEk5lLJwv1KeYos9wuUczAk7ku8wRzyZbrjwgRam9VQA5qmRzJ
|
|
115
|
+
PegEQwJaKMRu8PPK0L4KFN4v3ma7Ux6D719nko8mZ0kA2oUs6phsFmoWQfsbRbsD
|
|
116
|
+
CdUGnM2fPp6V285r9w9Y6+1nVdtJpbAPFJR3SxIpfYVfx3tI6C3BR9bIMr8uCf81
|
|
117
|
+
G+Ebvo4qTuY6Cg/mTpPLZ4cKpwSvB6cE+xeSHvKIRYm6QUYEReRxQ3b4aUKBSNwl
|
|
118
|
+
FEQufVGhGzeblNC3fjP+mMtqbyC8c1zkHc6tjJYO5yesKf8bjO71by2jgSced7nN
|
|
119
|
+
5JvJawfEcabgHJ1aAFLj0tlPMrViFzu6y8/A5aZLc5UMISXAZXfB4wIEdyUUXJh4
|
|
120
|
+
rJKE/ZCb2+W8g29N5cv2P6nhahT3mYatMiQ0U/gfaIrA0A==
|
|
121
|
+
`.trim(),
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const buildFastify = require('fastify');
|
|
2
|
+
const nock = require('nock');
|
|
3
|
+
const got = require('got');
|
|
4
|
+
const { fetchErrorsHandlerPlugin } = require('../src/plugins');
|
|
5
|
+
|
|
6
|
+
describe('Test fetchErrorsHandlerPlugin', () => {
|
|
7
|
+
let fastify;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
fastify = buildFastify({});
|
|
11
|
+
fastify.register(fetchErrorsHandlerPlugin);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('Should return the same HTTPError as the nested fetch request', async () => {
|
|
15
|
+
fastify.get('/test', () =>
|
|
16
|
+
got.get('https://test/endpoint_that_returns_error')
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const nockedRequest = nock('https://test')
|
|
20
|
+
.get('/endpoint_that_returns_error')
|
|
21
|
+
.reply(401, {
|
|
22
|
+
code: 'FST_JWT_AUTHORIZATION_TOKEN_INVALID',
|
|
23
|
+
error: 'Unauthorized',
|
|
24
|
+
message:
|
|
25
|
+
'Authorization token is invalid: The token signature is invalid.',
|
|
26
|
+
statusCode: 401,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const response = await fastify.inject({
|
|
30
|
+
method: 'GET',
|
|
31
|
+
url: '/test',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
expect(response.statusCode).toBe(401);
|
|
35
|
+
|
|
36
|
+
expect(response.json()).toEqual({
|
|
37
|
+
code: 'FST_JWT_AUTHORIZATION_TOKEN_INVALID',
|
|
38
|
+
error: 'Unauthorized',
|
|
39
|
+
message:
|
|
40
|
+
'Authorization token is invalid: The token signature is invalid.',
|
|
41
|
+
statusCode: 401,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
expect(nockedRequest.isDone()).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('Should return correct error when nested fetch request returns fatal error', async () => {
|
|
48
|
+
fastify.get('/test', () =>
|
|
49
|
+
got.get('https://test/endpoint_that_throws_fatal_error')
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const nockedRequest = nock('https://test')
|
|
53
|
+
.get('/endpoint_that_throws_fatal_error')
|
|
54
|
+
.replyWithError('Unknown fatal error');
|
|
55
|
+
|
|
56
|
+
const response = await fastify.inject({
|
|
57
|
+
method: 'GET',
|
|
58
|
+
url: '/test',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(response.statusCode).toBe(500);
|
|
62
|
+
|
|
63
|
+
expect(response.json()).toEqual({
|
|
64
|
+
code: 'ERR_GOT_REQUEST_ERROR',
|
|
65
|
+
error: 'Internal Server Error',
|
|
66
|
+
message: 'Unknown fatal error',
|
|
67
|
+
statusCode: 500,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(nockedRequest.isDone()).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('Should return correct error when nested fetch request returns string error', async () => {
|
|
74
|
+
fastify.get('/test', () =>
|
|
75
|
+
got.get('https://test/endpoint_that_returns_error')
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const nockedRequest = nock('https://test')
|
|
79
|
+
.get('/endpoint_that_returns_error')
|
|
80
|
+
.reply(400, 'Unknown error');
|
|
81
|
+
|
|
82
|
+
const response = await fastify.inject({
|
|
83
|
+
method: 'GET',
|
|
84
|
+
url: '/test',
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
expect(response.statusCode).toBe(400);
|
|
88
|
+
|
|
89
|
+
expect(response.json()).toEqual({
|
|
90
|
+
error: 'Bad Request',
|
|
91
|
+
message: 'Unknown error',
|
|
92
|
+
statusCode: 400,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(nockedRequest.isDone()).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
|
+
const webwalletBuildFastify = require('./helpers/webwallet-build-fastify');
|
|
3
|
+
const { credentialsRepoPlugin } = require('../src/entities');
|
|
4
|
+
const initCredentialsFactory = require('./factories/credentials');
|
|
5
|
+
|
|
6
|
+
jest.mock('@velocitycareerlabs/vnf-nodejs-wallet-sdk', () => {
|
|
7
|
+
const originalModule = jest.requireActual(
|
|
8
|
+
'@velocitycareerlabs/vnf-nodejs-wallet-sdk'
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
...originalModule,
|
|
13
|
+
VCLProvider: {
|
|
14
|
+
getInstance: jest.fn().mockReturnValue({
|
|
15
|
+
initialize: jest.fn().mockResolvedValue(null),
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('Test filterDeletedCredentialsExtension', () => {
|
|
22
|
+
let fastify;
|
|
23
|
+
let credentialsRepo;
|
|
24
|
+
let persistCredentials;
|
|
25
|
+
|
|
26
|
+
beforeAll(async () => {
|
|
27
|
+
fastify = webwalletBuildFastify();
|
|
28
|
+
await fastify.ready();
|
|
29
|
+
|
|
30
|
+
({ persistCredentials } = initCredentialsFactory(fastify));
|
|
31
|
+
|
|
32
|
+
credentialsRepo = await credentialsRepoPlugin(fastify)({
|
|
33
|
+
config: fastify.config,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(async () => {
|
|
38
|
+
await mongoDb().collection('credentials').deleteMany({});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterAll(async () => {
|
|
42
|
+
await fastify.close();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Credentials with deletedAt field shouldn`t be visible for find requests', async () => {
|
|
46
|
+
const [credential] = await Promise.all([
|
|
47
|
+
persistCredentials(),
|
|
48
|
+
persistCredentials(),
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
await credentialsRepo.update(credential._id, {
|
|
52
|
+
deletedAt: new Date(),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(await credentialsRepo.find()).toHaveLength(1);
|
|
56
|
+
|
|
57
|
+
expect(
|
|
58
|
+
await credentialsRepo.findOne({ filter: { _id: credential._id } })
|
|
59
|
+
).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('It should still be possible to retrieve deleted credentials if deletedAt is explicitly passed', async () => {
|
|
63
|
+
const [credential] = await Promise.all([
|
|
64
|
+
persistCredentials(),
|
|
65
|
+
persistCredentials(),
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
await credentialsRepo.update(credential._id, {
|
|
69
|
+
deletedAt: new Date(),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(
|
|
73
|
+
await credentialsRepo.find({ deletedAt: { $exists: true } })
|
|
74
|
+
).toHaveLength(1);
|
|
75
|
+
|
|
76
|
+
expect(
|
|
77
|
+
await credentialsRepo.findOne({
|
|
78
|
+
filter: { _id: credential._id, deletedAt: { $exists: true } },
|
|
79
|
+
})
|
|
80
|
+
).toBeTruthy();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
HOST_URL=http://localhost.test
|
|
2
|
+
CAREER_WALLET_URL=http://careerwallet.localhost.test
|
|
3
|
+
OAUTH0_DOMAIN=https://localhost/
|
|
4
|
+
OAUTH0_WEBAPP_CLIENT_ID=foo
|
|
5
|
+
AUTH0_WEB_WALLET_AUDIENCE=foo
|
|
6
|
+
LIB_URL=http://lib.localhost.test
|
|
7
|
+
VCL_SDK_ENVIRONMENT=dev
|
|
8
|
+
VCL_SDK_VNF_PROTOCOL_VERSION=2.0
|
|
9
|
+
WEB_WALLET_BASE_URL=localhost:3000
|
|
10
|
+
DEEP_LINK_PROTOCOL=velocity-network-devnet://
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const nockConsentAdd = (nockInstance) => {
|
|
2
|
+
nockInstance
|
|
3
|
+
.post('/api/v0.6/careerwallet/consents/add', () => true, {
|
|
4
|
+
'Content-Type': 'application/json',
|
|
5
|
+
})
|
|
6
|
+
.reply(204, {
|
|
7
|
+
consent: {
|
|
8
|
+
version: '1.0',
|
|
9
|
+
accountId: 'mocked-user-id',
|
|
10
|
+
createdAt: new Date().toISOString(),
|
|
11
|
+
id: 'mocked-consent-id',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = { nockConsentAdd };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const nockConsentGetLatest = (nockInstance) => {
|
|
2
|
+
nockInstance
|
|
3
|
+
.get('/api/v0.6/careerwallet/consents/latest')
|
|
4
|
+
.query({ accountId: '1111' })
|
|
5
|
+
.reply(204, {
|
|
6
|
+
consent: {
|
|
7
|
+
id: '1',
|
|
8
|
+
version: '1.0',
|
|
9
|
+
accountId: '1111',
|
|
10
|
+
createdAt: new Date().toISOString(),
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = { nockConsentGetLatest };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const nockLinkedinAccess = (nockInstance, statusCode = 204) => {
|
|
2
|
+
nockInstance
|
|
3
|
+
.post('/accessToken', () => true, {
|
|
4
|
+
'Content-Type': ' application/x-www-form-urlencoded',
|
|
5
|
+
})
|
|
6
|
+
.reply(statusCode, { expires_in: 5184000, access_token: 'access_token' });
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
module.exports = { nockLinkedinAccess };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const nockLinkedinEmail = (nockInstance) => {
|
|
2
|
+
nockInstance
|
|
3
|
+
.get('/emailAddress?q=members&projection=(elements*(handle~))')
|
|
4
|
+
.reply(200, {
|
|
5
|
+
elements: [
|
|
6
|
+
{
|
|
7
|
+
'handle~': {
|
|
8
|
+
emailAddress: 'LINKEDIN_USER_EMAIL',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = { nockLinkedinEmail };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const nockLinkedinImageRegister = (nockInstance) => {
|
|
2
|
+
nockInstance
|
|
3
|
+
.post('/assets?action=registerUpload', () => true, {
|
|
4
|
+
'Content-Type': 'application/json',
|
|
5
|
+
'X-Restli-Protocol-Version': '2.0.0',
|
|
6
|
+
Authorization: 'Bearer 12345',
|
|
7
|
+
})
|
|
8
|
+
.reply(
|
|
9
|
+
200,
|
|
10
|
+
JSON.stringify({
|
|
11
|
+
value: {
|
|
12
|
+
uploadMechanism: {
|
|
13
|
+
'com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest': {
|
|
14
|
+
uploadUrl:
|
|
15
|
+
// eslint-disable-next-line max-len
|
|
16
|
+
'https://www.linkedin.com/dms-uploads/C5622AQHdBDflPp0pEg/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&sync=1&v=beta&ut=1lrKqjt4fYuqw1',
|
|
17
|
+
headers: {
|
|
18
|
+
'media-type-family': 'STILLIMAGE',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
asset: 'urn:li:digitalmediaAsset:C5622AQHdBDflPp0pEg',
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = { nockLinkedinImageRegister };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const nockLinkedinMe = (nockInstance, statusCode = 200) => {
|
|
2
|
+
nockInstance
|
|
3
|
+
.get(
|
|
4
|
+
'/me?projection=(id,localizedFirstName,localizedLastName,profilePicture(displayImage~digitalmediaAsset:playableStreams))'
|
|
5
|
+
)
|
|
6
|
+
.reply(statusCode, {
|
|
7
|
+
id: 'LINKEDIN_USER_ID',
|
|
8
|
+
localizedLastName: 'LAST',
|
|
9
|
+
localizedFirstName: 'FIRST',
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = { nockLinkedinMe };
|