@velocitycareerlabs/server-careerwallet 1.25.0-dev-build.1a3bc076a → 1.25.0-dev-build.13b0fa707

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/server-careerwallet",
3
- "version": "1.25.0-dev-build.1a3bc076a",
3
+ "version": "1.25.0-dev-build.13b0fa707",
4
4
  "description": "Career Wallet application",
5
5
  "repository": "https://github.com/velocitycareerlabs/packages",
6
6
  "engines": {
@@ -40,13 +40,13 @@
40
40
  "@velocitycareerlabs/did-doc": "1.25.0-dev-build.1c2d6340d",
41
41
  "@velocitycareerlabs/fastify-plugins": "1.25.0-dev-build.1c2d6340d",
42
42
  "@velocitycareerlabs/jwt": "1.25.0-dev-build.1c2d6340d",
43
- "@velocitycareerlabs/migrations": "1.25.0-dev-build.1a3bc076a",
43
+ "@velocitycareerlabs/migrations": "1.25.0-dev-build.13b0fa707",
44
44
  "@velocitycareerlabs/organizations-registry": "1.25.0-dev-build.1c2d6340d",
45
45
  "@velocitycareerlabs/request": "1.25.0-dev-build.1c2d6340d",
46
46
  "@velocitycareerlabs/server-provider": "1.25.0-dev-build.1c2d6340d",
47
47
  "@velocitycareerlabs/spencer-mongo-extensions": "1.25.0-dev-build.1c2d6340d",
48
48
  "@velocitycareerlabs/verifiable-credentials": "1.25.0-dev-build.1c2d6340d",
49
- "@velocitycareerlabs/yoti-integration-plugin": "1.25.0-dev-build.1a3bc076a",
49
+ "@velocitycareerlabs/yoti-integration-plugin": "1.25.0-dev-build.13b0fa707",
50
50
  "aws-sdk": "2.1692.0",
51
51
  "canonicalize": "^2.0.0",
52
52
  "date-fns": "^3.0.0",
@@ -62,6 +62,7 @@
62
62
  "uuid": "11.0.5"
63
63
  },
64
64
  "devDependencies": {
65
+ "@aws-sdk/client-kms": "3.774.0",
65
66
  "@aws-sdk/client-ses": "3.758.0",
66
67
  "@aws-sdk/client-sns": "3.758.0",
67
68
  "@spencejs/spence-factories": "0.10.2",
@@ -82,5 +83,5 @@
82
83
  "nodemon": "3.1.9",
83
84
  "prettier": "2.8.8"
84
85
  },
85
- "gitHead": "278e4f6733604772cf68501a4d4b01db7ecfda56"
86
+ "gitHead": "f5b5a15174feab9d1de5263508b5fc66e3c52f1e"
86
87
  }
@@ -51,6 +51,7 @@ const sharedConfig = {
51
51
  enableSentryDebug: env.get('ENABLE_SENTRY_DEBUG').default('false').asBool(),
52
52
  customFastifyOptions: {
53
53
  http2: false,
54
+ bodyLimit: env.get('BODY_LIMIT').default('8388608').asIntPositive(),
54
55
  },
55
56
  version: packageJson.version,
56
57
  allowedCorsOrigins: env.get('ALLOWED_CORS_ORIGINS').default('').asArray(),
@@ -1,4 +1,10 @@
1
- const AWS = require('aws-sdk');
1
+ const {
2
+ KMSClient,
3
+ CreateKeyCommand,
4
+ CreateAliasCommand,
5
+ DeleteAliasCommand,
6
+ DecryptCommand,
7
+ } = require('@aws-sdk/client-kms');
2
8
  const { ObjectId } = require('mongodb');
3
9
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
4
10
  const { generateKeyPair } = require('@velocitycareerlabs/crypto');
@@ -22,17 +28,21 @@ describe('create_did_key controller test suite', () => {
22
28
  let accountId;
23
29
 
24
30
  beforeAll(async () => {
25
- testClient = new AWS.KMS({
26
- credentials: new AWS.Credentials('tests-kei-id', 'tests-key'),
31
+ testClient = new KMSClient({
32
+ credentials: {
33
+ accessKeyId: 'tests-key-id',
34
+ secretAccessKey: 'tests-key',
35
+ },
27
36
  region: 'us-west-1',
28
37
  endpoint: 'http://localhost:4566',
29
38
  });
30
- const createKeyResponse = await testClient.createKey().promise();
31
- const createAliasParams = {
32
- AliasName: aliasName,
33
- TargetKeyId: createKeyResponse.KeyMetadata.Arn,
34
- };
35
- await testClient.createAlias(createAliasParams).promise();
39
+ const createKeyResponse = await testClient.send(new CreateKeyCommand());
40
+ await testClient.send(
41
+ new CreateAliasCommand({
42
+ AliasName: aliasName,
43
+ TargetKeyId: createKeyResponse.KeyMetadata.Arn,
44
+ })
45
+ );
36
46
  const { publicKey, privateKey: pk } = generateKeyPair({ format: 'jwk' });
37
47
  privateKey = pk;
38
48
  fastify = await buildFastify({
@@ -73,7 +83,7 @@ describe('create_did_key controller test suite', () => {
73
83
  });
74
84
 
75
85
  afterAll(async () => {
76
- await testClient.deleteAlias({ AliasName: aliasName }).promise();
86
+ await testClient.send(new DeleteAliasCommand({ AliasName: aliasName }));
77
87
 
78
88
  await mongoDb().collection('keyPair').deleteMany({});
79
89
  await mongoDb().collection('accounts').deleteMany({});
@@ -266,11 +276,11 @@ describe('create_did_key controller test suite', () => {
266
276
  updatedAt: expect.anything(),
267
277
  });
268
278
 
269
- const decryptResult = await testClient
270
- .decrypt({
279
+ const decryptResult = await testClient.send(
280
+ new DecryptCommand({
271
281
  CiphertextBlob: keyPair.encryptedPrivateKey.buffer,
272
282
  })
273
- .promise();
283
+ );
274
284
  expect(decryptResult.Plaintext).toBeDefined();
275
285
 
276
286
  const accounts = await accountRepo.findOne({
@@ -1,4 +1,10 @@
1
- const AWS = require('aws-sdk');
1
+ const {
2
+ KMSClient,
3
+ CreateKeyCommand,
4
+ CreateAliasCommand,
5
+ DeleteAliasCommand,
6
+ DecryptCommand,
7
+ } = require('@aws-sdk/client-kms');
2
8
  const { ObjectId } = require('mongodb');
3
9
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
4
10
  const { generateKeyPair } = require('@velocitycareerlabs/crypto');
@@ -16,17 +22,21 @@ describe('create_jwk controller test suite', () => {
16
22
  let testClient;
17
23
 
18
24
  beforeAll(async () => {
19
- testClient = new AWS.KMS({
20
- credentials: new AWS.Credentials('tests-kei-id', 'tests-key'),
25
+ testClient = new KMSClient({
26
+ credentials: {
27
+ accessKeyId: 'tests-key-id',
28
+ secretAccessKey: 'tests-key',
29
+ },
21
30
  region: 'us-west-1',
22
31
  endpoint: 'http://localhost:4566',
23
32
  });
24
- const createKeyResponse = await testClient.createKey().promise();
25
- const createAliasParams = {
26
- AliasName: aliasName,
27
- TargetKeyId: createKeyResponse.KeyMetadata.Arn,
28
- };
29
- await testClient.createAlias(createAliasParams).promise();
33
+ const createKeyResponse = await testClient.send(new CreateKeyCommand());
34
+ await testClient.send(
35
+ new CreateAliasCommand({
36
+ AliasName: aliasName,
37
+ TargetKeyId: createKeyResponse.KeyMetadata.Arn,
38
+ })
39
+ );
30
40
  const { publicKey, privateKey } = generateKeyPair({ format: 'jwk' });
31
41
  fastify = await buildFastify({
32
42
  holderAppServerAccessTokenPublicKey: publicKey,
@@ -59,7 +69,7 @@ describe('create_jwk controller test suite', () => {
59
69
  });
60
70
 
61
71
  afterAll(async () => {
62
- await testClient.deleteAlias({ AliasName: aliasName }).promise();
72
+ await testClient.send(new DeleteAliasCommand({ AliasName: aliasName }));
63
73
  await fastify.close();
64
74
  });
65
75
 
@@ -178,11 +188,11 @@ describe('create_jwk controller test suite', () => {
178
188
  updatedAt: expect.anything(),
179
189
  });
180
190
 
181
- const decryptResult = await testClient
182
- .decrypt({
191
+ const decryptResult = await testClient.send(
192
+ new DecryptCommand({
183
193
  CiphertextBlob: keyPair.encryptedPrivateKey.buffer,
184
194
  })
185
- .promise();
195
+ );
186
196
  expect(decryptResult.Plaintext).toBeDefined();
187
197
  });
188
198
  });
@@ -1,4 +1,3 @@
1
- require('aws-sdk');
2
1
  const { errorResponseMatcher } = require('@velocitycareerlabs/tests-helpers');
3
2
  const buildFastify = require('./helpers/careerwallet-build-fastify');
4
3
 
@@ -1,4 +1,11 @@
1
- const AWS = require('aws-sdk');
1
+ const {
2
+ KMSClient,
3
+ CreateKeyCommand,
4
+ CreateAliasCommand,
5
+ DeleteAliasCommand,
6
+ DecryptCommand,
7
+ EncryptCommand,
8
+ } = require('@aws-sdk/client-kms');
2
9
  const { ObjectId } = require('mongodb');
3
10
  const { omit } = require('lodash/fp');
4
11
  const { nanoid } = require('nanoid');
@@ -74,18 +81,21 @@ describe('JWT Controller Test Suite', () => {
74
81
  let publicKey;
75
82
 
76
83
  beforeAll(async () => {
77
- testClient = new AWS.KMS({
78
- credentials: new AWS.Credentials('tests-kei-id', 'tests-key'),
84
+ testClient = new KMSClient({
85
+ credentials: {
86
+ accessKeyId: 'tests-key-id',
87
+ secretAccessKey: 'tests-key',
88
+ },
79
89
  region: 'us-west-1',
80
90
  endpoint: 'http://localhost:4566',
81
91
  });
82
-
83
- const createKeyResponse = await testClient.createKey().promise();
84
- const createAliasParams = {
85
- AliasName: aliasName,
86
- TargetKeyId: createKeyResponse.KeyMetadata.Arn,
87
- };
88
- await testClient.createAlias(createAliasParams).promise();
92
+ const createKeyResponse = await testClient.send(new CreateKeyCommand());
93
+ await testClient.send(
94
+ new CreateAliasCommand({
95
+ AliasName: aliasName,
96
+ TargetKeyId: createKeyResponse.KeyMetadata.Arn,
97
+ })
98
+ );
89
99
  ({ publicKey, privateKey: privk } = generateKeyPair({ format: 'jwk' }));
90
100
  fastify = await buildFastify({
91
101
  holderAppServerAccessTokenPublicKey: publicKey,
@@ -125,7 +135,7 @@ describe('JWT Controller Test Suite', () => {
125
135
  });
126
136
 
127
137
  afterAll(async () => {
128
- await testClient.deleteAlias({ AliasName: aliasName }).promise();
138
+ await testClient.send(new DeleteAliasCommand({ AliasName: aliasName }));
129
139
  await fastify.close();
130
140
  });
131
141
 
@@ -744,11 +754,12 @@ describe('JWT Controller Test Suite', () => {
744
754
  curve: 'P-256',
745
755
  format: 'jwk',
746
756
  });
747
- const params = {
748
- KeyId: fastify.config.managedAccountsKeyId,
749
- Plaintext: stringifyJwk(pk),
750
- };
751
- const { CiphertextBlob } = await testClient.encrypt(params).promise();
757
+ const { CiphertextBlob } = await testClient.send(
758
+ new EncryptCommand({
759
+ KeyId: fastify.config.managedAccountsKeyId,
760
+ Plaintext: stringifyJwk(pk),
761
+ })
762
+ );
752
763
  const keyPairDb = await persistKeyPairs({
753
764
  encryptedPrivateKey: CiphertextBlob,
754
765
  publicKey: pubK,
@@ -817,11 +828,12 @@ describe('JWT Controller Test Suite', () => {
817
828
  curve: 'P-256',
818
829
  format: 'jwk',
819
830
  });
820
- const params = {
821
- KeyId: fastify.config.managedAccountsKeyId,
822
- Plaintext: stringifyJwk(pk),
823
- };
824
- const { CiphertextBlob } = await testClient.encrypt(params).promise();
831
+ const { CiphertextBlob } = await testClient.send(
832
+ new EncryptCommand({
833
+ KeyId: fastify.config.managedAccountsKeyId,
834
+ Plaintext: Buffer.from(stringifyJwk(pk), 'utf8'),
835
+ })
836
+ );
825
837
  const keyPairDb = await persistKeyPairs({
826
838
  encryptedPrivateKey: CiphertextBlob,
827
839
  publicKey: pubK,
@@ -863,15 +875,17 @@ describe('JWT Controller Test Suite', () => {
863
875
  _id: keyPairDb._id,
864
876
  },
865
877
  });
866
- const decryptedPrivateKey = await testClient
867
- .decrypt({
878
+ const decryptedPrivateKey = await testClient.send(
879
+ new DecryptCommand({
868
880
  CiphertextBlob: Buffer.from(keyPair.encryptedPrivateKey.buffer),
869
881
  })
870
- .promise();
882
+ );
871
883
 
872
884
  const { payload } = await jwtVerify(
873
885
  response.json.compactJwt,
874
- jwkFromStringified(decryptedPrivateKey.Plaintext.toString())
886
+ jwkFromStringified(
887
+ Buffer.from(decryptedPrivateKey.Plaintext).toString('utf8')
888
+ )
875
889
  );
876
890
  expect(payload.abc).toEqual('abv');
877
891
  });
@@ -881,11 +895,13 @@ describe('JWT Controller Test Suite', () => {
881
895
  curve: 'P-256',
882
896
  format: 'jwk',
883
897
  });
884
- const params = {
885
- KeyId: fastify.config.managedAccountsKeyId,
886
- Plaintext: stringifyJwk(pk),
887
- };
888
- const { CiphertextBlob } = await testClient.encrypt(params).promise();
898
+ const { CiphertextBlob } = await testClient.send(
899
+ new EncryptCommand({
900
+ KeyId: fastify.config.managedAccountsKeyId,
901
+ Plaintext: Buffer.from(stringifyJwk(pk)),
902
+ })
903
+ );
904
+
889
905
  const keyPairDb = await persistKeyPairs({
890
906
  encryptedPrivateKey: CiphertextBlob,
891
907
  publicKey: pubK,
@@ -927,15 +943,17 @@ describe('JWT Controller Test Suite', () => {
927
943
  _id: keyPairDb._id,
928
944
  },
929
945
  });
930
- const decryptedPrivateKey = await testClient
931
- .decrypt({
946
+ const decryptedPrivateKey = await testClient.send(
947
+ new DecryptCommand({
932
948
  CiphertextBlob: Buffer.from(keyPair.encryptedPrivateKey.buffer),
933
949
  })
934
- .promise();
950
+ );
935
951
 
936
952
  const { payload } = await jwtVerify(
937
953
  response.json.compactJwt,
938
- jwkFromStringified(decryptedPrivateKey.Plaintext.toString())
954
+ jwkFromStringified(
955
+ Buffer.from(decryptedPrivateKey.Plaintext).toString()
956
+ )
939
957
  );
940
958
  expect(payload.abc).toEqual('abv');
941
959
  });
@@ -955,11 +973,12 @@ describe('JWT Controller Test Suite', () => {
955
973
  curve: 'P-256',
956
974
  format: 'jwk',
957
975
  });
958
- const params = {
959
- KeyId: fastify.config.managedAccountsKeyId,
960
- Plaintext: stringifyJwk(pk),
961
- };
962
- const { CiphertextBlob } = await testClient.encrypt(params).promise();
976
+ const { CiphertextBlob } = await testClient.send(
977
+ new EncryptCommand({
978
+ KeyId: fastify.config.managedAccountsKeyId,
979
+ Plaintext: stringifyJwk(pk),
980
+ })
981
+ );
963
982
  const keyPairDb = await persistKeyPairs({
964
983
  encryptedPrivateKey: CiphertextBlob,
965
984
  publicKey: pubK,
@@ -1019,11 +1038,12 @@ describe('JWT Controller Test Suite', () => {
1019
1038
  curve: 'secp256k1',
1020
1039
  format: 'jwk',
1021
1040
  });
1022
- const params = {
1023
- KeyId: fastify.config.managedAccountsKeyId,
1024
- Plaintext: stringifyJwk(pk),
1025
- };
1026
- const { CiphertextBlob } = await testClient.encrypt(params).promise();
1041
+ const { CiphertextBlob } = await testClient.send(
1042
+ new EncryptCommand({
1043
+ KeyId: fastify.config.managedAccountsKeyId,
1044
+ Plaintext: stringifyJwk(pk),
1045
+ })
1046
+ );
1027
1047
  const keyPairDb = await persistKeyPairs({
1028
1048
  encryptedPrivateKey: CiphertextBlob,
1029
1049
  publicKey: pubK,
@@ -1073,11 +1093,12 @@ describe('JWT Controller Test Suite', () => {
1073
1093
  curve: 'P-256',
1074
1094
  format: 'jwk',
1075
1095
  });
1076
- const params = {
1077
- KeyId: fastify.config.managedAccountsKeyId,
1078
- Plaintext: stringifyJwk(pk),
1079
- };
1080
- const { CiphertextBlob } = await testClient.encrypt(params).promise();
1096
+ const { CiphertextBlob } = await testClient.send(
1097
+ new EncryptCommand({
1098
+ KeyId: fastify.config.managedAccountsKeyId,
1099
+ Plaintext: Buffer.from(stringifyJwk(pk)),
1100
+ })
1101
+ );
1081
1102
  const keyPairDb = await persistKeyPairs({
1082
1103
  encryptedPrivateKey: CiphertextBlob,
1083
1104
  publicKey: pubK,
@@ -1122,14 +1143,16 @@ describe('JWT Controller Test Suite', () => {
1122
1143
  _id: keyPairDb._id,
1123
1144
  },
1124
1145
  });
1125
- const decryptedPrivateKey = await testClient
1126
- .decrypt({
1146
+ const decryptedPrivateKey = await testClient.send(
1147
+ new DecryptCommand({
1127
1148
  CiphertextBlob: Buffer.from(keyPair.encryptedPrivateKey.buffer),
1128
1149
  })
1129
- .promise();
1150
+ );
1130
1151
  const { payload } = await jwtVerify(
1131
1152
  response.json.compactJwt,
1132
- jwkFromStringified(decryptedPrivateKey.Plaintext.toString())
1153
+ jwkFromStringified(
1154
+ Buffer.from(decryptedPrivateKey.Plaintext).toString()
1155
+ )
1133
1156
  );
1134
1157
  expect(payload.abc).toEqual('abv');
1135
1158
  });