@velocitycareerlabs/tests-helpers 1.24.0-dev-build.1f35ffba7 → 1.24.0-dev-build.13c3cf035

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/index.js CHANGED
@@ -26,7 +26,6 @@ module.exports = {
26
26
  ...require('./src/mongoify'),
27
27
  ...require('./src/generate-key-pair-in-hex-and-jwk'),
28
28
  ...require('./src/jwk-matchers'),
29
- ...require('./src/generate-ion-operations'),
30
29
  ...require('./src/generate-organization-key-matcher'),
31
30
  ...require('./src/test-oauth-user'),
32
31
  ...require('./src/s3-utils'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/tests-helpers",
3
- "version": "1.24.0-dev-build.1f35ffba7",
3
+ "version": "1.24.0-dev-build.13c3cf035",
4
4
  "description": "Generic helpers for tests",
5
5
  "repository": "https://github.com/velocitycareerlabs/packages",
6
6
  "main": "index.js",
@@ -16,10 +16,10 @@
16
16
  "license": "Apache-2.0",
17
17
  "dependencies": {
18
18
  "@spencejs/spence-mongo-repos": "^0.10.2",
19
- "@velocitycareerlabs/common-functions": "1.24.0-dev-build.1f35ffba7",
20
- "@velocitycareerlabs/crypto": "1.24.0-dev-build.1f35ffba7",
21
- "@velocitycareerlabs/jwt": "1.24.0-dev-build.1f35ffba7",
22
- "@velocitycareerlabs/test-regexes": "1.24.0-dev-build.1f35ffba7",
19
+ "@velocitycareerlabs/common-functions": "1.24.0-dev-build.13c3cf035",
20
+ "@velocitycareerlabs/crypto": "1.24.0-dev-build.13c3cf035",
21
+ "@velocitycareerlabs/jwt": "1.24.0-dev-build.13c3cf035",
22
+ "@velocitycareerlabs/test-regexes": "1.24.0-dev-build.13c3cf035",
23
23
  "dotenv": "^16.0.0",
24
24
  "env-var": "^7.0.0",
25
25
  "lodash": "~4.17.21",
@@ -40,5 +40,5 @@
40
40
  "nanoid": "3.3.8",
41
41
  "prettier": "2.8.8"
42
42
  },
43
- "gitHead": "45998d8cc2f32072ec890ef7dcdf7ca9585898a6"
43
+ "gitHead": "409008ec524d654a064172d8b57d0189126efaf0"
44
44
  }
@@ -16,7 +16,7 @@
16
16
  const { nanoid } = require('nanoid');
17
17
 
18
18
  const VNF_GROUP_ID_CLAIM = 'http://velocitynetwork.foundation/groupId';
19
- const DEFAULT_GROUP_ID = 'did:ion:1234';
19
+ const DEFAULT_GROUP_ID = 'did:test:1234';
20
20
 
21
21
  const testRegistrarSuperUser = {
22
22
  sub: `auth0|${nanoid()}`,
@@ -1,120 +0,0 @@
1
- /**
2
- * Copyright 2023 Velocity Team
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- const { last, map, reduce } = require('lodash/fp');
18
- const { privateJwkMatcher, publicJwkMatcher } = require('./jwk-matchers');
19
-
20
- const generateDidKeyMatcher = (kid) => ({
21
- id: last(kid.split('#')),
22
- type: 'EcdsaSecp256k1VerificationKey2019',
23
- publicKeyJwk: publicJwkMatcher,
24
- purposes: ['assertionMethod'],
25
- });
26
-
27
- const createInitOp = (services, keys) => ({
28
- operation: 'create',
29
- content: {
30
- publicKeys: map(generateDidKeyMatcher, keys),
31
- services: map(formatService, services),
32
- },
33
- recovery: {
34
- publicJwk: publicJwkMatcher,
35
- privateJwk: privateJwkMatcher,
36
- },
37
- update: {
38
- publicJwk: publicJwkMatcher,
39
- privateJwk: privateJwkMatcher,
40
- },
41
- });
42
-
43
- const addServiceOp = (service, previous, options) => {
44
- const content = {};
45
- if (!options.remove) {
46
- content.addServices = [formatService(service)];
47
- }
48
- if (options.replace || options.remove) {
49
- content.removeServices = [service.id.slice(1)];
50
- }
51
-
52
- return {
53
- operation: 'update',
54
- content,
55
- previous,
56
- update: {
57
- publicJwk: publicJwkMatcher,
58
- privateJwk: privateJwkMatcher,
59
- },
60
- };
61
- };
62
-
63
- const addPublicKeyOp = (publicKey, previous, options) => {
64
- const content = {};
65
- if (!options.remove) {
66
- content.addPublicKeys = [generateDidKeyMatcher(publicKey.id)];
67
- }
68
- if (options.replace || options.remove) {
69
- content.removePublicKeys = [publicKey.id.slice(1)];
70
- }
71
-
72
- return {
73
- operation: 'update',
74
- content,
75
- previous,
76
- update: {
77
- publicJwk: publicJwkMatcher,
78
- privateJwk: privateJwkMatcher,
79
- },
80
- };
81
- };
82
-
83
- const formatService = (service) => ({
84
- id: service.id.slice(1),
85
- serviceEndpoint: service.serviceEndpoint,
86
- type: service.type,
87
- });
88
-
89
- // Should really also include initialKeys. See thread at:
90
- // https://github.com/velocitycareerlabs/monorepo/pull/1271#discussion_r714185994
91
- const generateIonOperations = (
92
- initialServices = [],
93
- additionalServices = [],
94
- kids = ['vc-signing-key-1', 'eth-account-key-1', 'exchange-key-1'],
95
- options = {}
96
- ) => {
97
- const op0 = createInitOp(initialServices, kids.slice(0, 2));
98
- const initialOps = reduce(
99
- (acc, kid) => {
100
- acc.push(addPublicKeyOp({ id: kid }, last(acc), {}));
101
- return acc;
102
- },
103
- [op0],
104
- kids.slice(2)
105
- );
106
- return reduce(
107
- (acc, service) => {
108
- acc.push(addServiceOp(service, last(acc), options));
109
- return acc;
110
- },
111
- initialOps,
112
- additionalServices
113
- );
114
- };
115
-
116
- module.exports = {
117
- generateIonOperations,
118
- generateDidKeyMatcher,
119
- addPublicKeyOp,
120
- };