@verii/verii-issuing 1.1.0-pre.1761078749 → 1.1.0-pre.1761568887
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": "@verii/verii-issuing",
|
|
3
|
-
"version": "1.1.0-pre.
|
|
3
|
+
"version": "1.1.0-pre.1761568887",
|
|
4
4
|
"description": "Verii Issuing Package",
|
|
5
5
|
"repository": "https://github.com/LFDT-Verii/core",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -18,23 +18,23 @@
|
|
|
18
18
|
"author": "Andres Olave",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@verii/blockchain-functions": "1.1.0-pre.
|
|
22
|
-
"@verii/common-functions": "1.1.0-pre.
|
|
23
|
-
"@verii/crypto": "1.1.0-pre.
|
|
24
|
-
"@verii/did-doc": "1.1.0-pre.
|
|
25
|
-
"@verii/jwt": "1.1.0-pre.
|
|
26
|
-
"@verii/metadata-registration": "1.1.0-pre.
|
|
27
|
-
"@verii/vc-checks": "1.1.0-pre.
|
|
21
|
+
"@verii/blockchain-functions": "1.1.0-pre.1761568887",
|
|
22
|
+
"@verii/common-functions": "1.1.0-pre.1761568887",
|
|
23
|
+
"@verii/crypto": "1.1.0-pre.1761568887",
|
|
24
|
+
"@verii/did-doc": "1.1.0-pre.1761568887",
|
|
25
|
+
"@verii/jwt": "1.1.0-pre.1761568887",
|
|
26
|
+
"@verii/metadata-registration": "1.1.0-pre.1761568887",
|
|
27
|
+
"@verii/vc-checks": "1.1.0-pre.1761568887",
|
|
28
28
|
"canonicalize": "2.1.0",
|
|
29
29
|
"eth-url-parser": "1.0.4",
|
|
30
30
|
"fast-shuffle": "6.1.1",
|
|
31
31
|
"lodash": "^4.17.21"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@verii/contract-permissions": "1.1.0-pre.
|
|
35
|
-
"@verii/http-client": "1.1.0-pre.
|
|
36
|
-
"@verii/test-regexes": "1.1.0-pre.
|
|
37
|
-
"@verii/tests-helpers": "1.1.0-pre.
|
|
34
|
+
"@verii/contract-permissions": "1.1.0-pre.1761568887",
|
|
35
|
+
"@verii/http-client": "1.1.0-pre.1761568887",
|
|
36
|
+
"@verii/test-regexes": "1.1.0-pre.1761568887",
|
|
37
|
+
"@verii/tests-helpers": "1.1.0-pre.1761568887",
|
|
38
38
|
"eslint": "8.57.1",
|
|
39
39
|
"eslint-config-airbnb-base": "14.2.1",
|
|
40
40
|
"eslint-config-prettier": "8.10.2",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"lib"
|
|
57
57
|
]
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "6dc96130d21ad629626e8ef1881dee3c3bb1b477"
|
|
60
60
|
}
|
|
@@ -34,7 +34,7 @@ const { VelocityRevocationListType } = require('@verii/vc-checks');
|
|
|
34
34
|
* @param {Context} context context
|
|
35
35
|
* @returns {JsonLdCredential} a json-ld formatted unsigned credential
|
|
36
36
|
*/
|
|
37
|
-
const
|
|
37
|
+
const buildJsonLdCredential = (
|
|
38
38
|
issuer,
|
|
39
39
|
credentialSubjectId,
|
|
40
40
|
offer,
|
|
@@ -215,5 +215,5 @@ const buildCredentialTypeJsonLdContext = (credentialTypeMetadata) =>
|
|
|
215
215
|
: [];
|
|
216
216
|
|
|
217
217
|
module.exports = {
|
|
218
|
-
|
|
218
|
+
buildJsonLdCredential,
|
|
219
219
|
};
|
|
@@ -26,9 +26,10 @@ const { jsonLdToUnsignedVcJwtContent, jwtSign } = require('@verii/jwt');
|
|
|
26
26
|
const { extractCredentialType } = require('@verii/vc-checks');
|
|
27
27
|
const { hashOffer } = require('./hash-offer');
|
|
28
28
|
const { buildRevocationUrl } = require('../adapters/build-revocation-url');
|
|
29
|
-
const {
|
|
29
|
+
const { buildJsonLdCredential } = require('./build-jsonld-credential');
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// eslint-disable-next-line max-len
|
|
32
|
+
/** @import { Issuer, AllocationListEntry, CredentialOffer, CredentialMetadata, CredentialTypeMetadata, Context, JsonLdCredential } from "../types/types" */
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Builds the VCs
|
|
@@ -39,9 +40,9 @@ const { prepareJsonLdCredential } = require('./prepare-jsonld-credential');
|
|
|
39
40
|
* @param {AllocationListEntry[]} revocationListEntries revocation list entries
|
|
40
41
|
* @param {{[Name: string]: CredentialTypeMetadata}} credentialTypesMap the credential types
|
|
41
42
|
* @param {Context} context the context
|
|
42
|
-
* @returns {Promise<{
|
|
43
|
+
* @returns {Promise<{vcJwt: string, jsonLdCredential: JsonLdCredential, metadata: CredentialMetadata}[]>} the vc and its metadata
|
|
43
44
|
*/
|
|
44
|
-
const
|
|
45
|
+
const prepareJwtVcs = async (
|
|
45
46
|
offers,
|
|
46
47
|
credentialSubjectId,
|
|
47
48
|
issuer,
|
|
@@ -78,7 +79,7 @@ const buildVerifiableCredentials = async (
|
|
|
78
79
|
issuer,
|
|
79
80
|
context
|
|
80
81
|
);
|
|
81
|
-
const jsonLdCredential =
|
|
82
|
+
const jsonLdCredential = buildJsonLdCredential(
|
|
82
83
|
issuer,
|
|
83
84
|
credentialSubjectId,
|
|
84
85
|
offer,
|
|
@@ -113,4 +114,4 @@ const buildVelocityCredentialMetadataDID = (entry, issuer, contentHash) =>
|
|
|
113
114
|
entry.index
|
|
114
115
|
}:${contentHash}`;
|
|
115
116
|
|
|
116
|
-
module.exports = {
|
|
117
|
+
module.exports = { prepareJwtVcs };
|
|
@@ -20,9 +20,7 @@ const {
|
|
|
20
20
|
initCredentialMetadataContract,
|
|
21
21
|
} = require('./adapters/init-credential-metadata-contract');
|
|
22
22
|
const { createRevocationList } = require('./adapters/create-revocation-list');
|
|
23
|
-
const {
|
|
24
|
-
buildVerifiableCredentials,
|
|
25
|
-
} = require('./domain/build-verifiable-credentials');
|
|
23
|
+
const { prepareJwtVcs } = require('./domain/prepare-jwt-vcs');
|
|
26
24
|
|
|
27
25
|
const REVOCATION_LIST_SIZE = 10240;
|
|
28
26
|
const METADATA_LIST_SIZE = 10000;
|
|
@@ -30,31 +28,51 @@ const METADATA_LIST_SIZE = 10000;
|
|
|
30
28
|
/** @import { Issuer, AllocationListEntry, CredentialOffer, CredentialMetadata, CredentialTypeMetadata, Context } from "../types/types" */
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
|
-
* Prepares
|
|
34
|
-
* Current assumption is that offers contain all required fields including @context, type, contentHash
|
|
31
|
+
* Prepares, signs and anchors a verifiable credential from a credential offer.
|
|
35
32
|
* @param {CredentialOffer[]} offers array of offers
|
|
36
33
|
* @param {string} credentialSubjectId optional field if credential subject needs to be bound into the offer
|
|
37
34
|
* @param {{[Name: string]: CredentialTypeMetadata}} credentialTypesMap the credential types metadata
|
|
38
35
|
* @param {Issuer} issuer the issuer
|
|
39
36
|
* @param {Context} context the context
|
|
40
|
-
* @returns {Promise<
|
|
37
|
+
* @returns {Promise<string[]>} Returns signed credentials for each offer in vc-jwt format
|
|
41
38
|
*/
|
|
42
|
-
const
|
|
39
|
+
const issueVeriiCredentials = async (
|
|
43
40
|
offers,
|
|
44
41
|
credentialSubjectId,
|
|
45
42
|
credentialTypesMap,
|
|
46
43
|
issuer,
|
|
47
44
|
context
|
|
48
45
|
) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const vcs = await signVeriiCredentials(
|
|
47
|
+
offers,
|
|
48
|
+
credentialSubjectId,
|
|
49
|
+
credentialTypesMap,
|
|
52
50
|
issuer,
|
|
53
|
-
'revocationListAllocations',
|
|
54
|
-
REVOCATION_LIST_SIZE,
|
|
55
51
|
context
|
|
56
52
|
);
|
|
57
53
|
|
|
54
|
+
await anchorVeriiCredentials(map('metadata', vcs), issuer, context);
|
|
55
|
+
|
|
56
|
+
return map('vcJwt', vcs);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Prepares and signs verifiable credentials from local offers without anchoring them to the blockchain.
|
|
61
|
+
* Assumption is that credential offers contain all required fields including @context, type, contentHash
|
|
62
|
+
* @param {CredentialOffer[]} offers array of offers
|
|
63
|
+
* @param {string} credentialSubjectId optional field if credential subject needs to be bound into the offer
|
|
64
|
+
* @param {{[Name: string]: CredentialTypeMetadata}} credentialTypesMap the credential types metadata
|
|
65
|
+
* @param {Issuer} issuer the issuer
|
|
66
|
+
* @param {Context} context the context
|
|
67
|
+
* @returns {Promise<{vcJwt: string, metadata: CredentialMetadata}[]>} Returns array of signed vcs (in jwt format) and their metadata
|
|
68
|
+
*/
|
|
69
|
+
const signVeriiCredentials = async (
|
|
70
|
+
offers,
|
|
71
|
+
credentialSubjectId,
|
|
72
|
+
credentialTypesMap,
|
|
73
|
+
issuer,
|
|
74
|
+
context
|
|
75
|
+
) => {
|
|
58
76
|
const metadataEntries = await allocateListEntries(
|
|
59
77
|
offers.length,
|
|
60
78
|
issuer,
|
|
@@ -63,8 +81,23 @@ const prepareVeriiVerifiableCredentials = async (
|
|
|
63
81
|
context
|
|
64
82
|
);
|
|
65
83
|
|
|
66
|
-
//
|
|
67
|
-
const
|
|
84
|
+
// pre-allocate list entries using internal tables/collections
|
|
85
|
+
const revocationListEntries = await allocateListEntries(
|
|
86
|
+
offers.length,
|
|
87
|
+
issuer,
|
|
88
|
+
'revocationListAllocations',
|
|
89
|
+
REVOCATION_LIST_SIZE,
|
|
90
|
+
context
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
await Promise.all(
|
|
94
|
+
flow(
|
|
95
|
+
filter({ isNewList: true }),
|
|
96
|
+
map((entry) => createRevocationList(entry.listId, issuer, context))
|
|
97
|
+
)(revocationListEntries)
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
return prepareJwtVcs(
|
|
68
101
|
offers,
|
|
69
102
|
credentialSubjectId,
|
|
70
103
|
issuer,
|
|
@@ -73,32 +106,15 @@ const prepareVeriiVerifiableCredentials = async (
|
|
|
73
106
|
credentialTypesMap,
|
|
74
107
|
context
|
|
75
108
|
);
|
|
76
|
-
|
|
77
|
-
return { vcs, revocationListEntries };
|
|
78
109
|
};
|
|
79
110
|
|
|
80
111
|
/**
|
|
81
|
-
* Anchors prepared verifiable credentials to the blockchain.
|
|
82
|
-
* @param {
|
|
83
|
-
* @param {object[]} revocationListEntries array of revocation list entries
|
|
112
|
+
* Anchors prepared verifiable credentials to the blockchain using their credential metadata.
|
|
113
|
+
* @param {CredentialMetadata[]} credentialMetadatas array of verifiable credential metadata
|
|
84
114
|
* @param {Issuer} issuer the issuer
|
|
85
115
|
* @param {Context} context the context
|
|
86
|
-
* @returns {Promise<string[]>} Returns signed credentials for each offer in vc-jwt format
|
|
87
116
|
*/
|
|
88
|
-
const
|
|
89
|
-
vcs,
|
|
90
|
-
revocationListEntries,
|
|
91
|
-
issuer,
|
|
92
|
-
context
|
|
93
|
-
) => {
|
|
94
|
-
// create any necessary revocation lists on dlt
|
|
95
|
-
await Promise.all(
|
|
96
|
-
flow(
|
|
97
|
-
filter({ isNewList: true }),
|
|
98
|
-
map((entry) => createRevocationList(entry.listId, issuer, context))
|
|
99
|
-
)(revocationListEntries)
|
|
100
|
-
);
|
|
101
|
-
|
|
117
|
+
const anchorVeriiCredentials = async (credentialMetadatas, issuer, context) => {
|
|
102
118
|
const { addEntry, createList } = await initCredentialMetadataContract(
|
|
103
119
|
issuer,
|
|
104
120
|
context
|
|
@@ -107,51 +123,17 @@ const anchorVeriiVerifiableCredentials = async (
|
|
|
107
123
|
// create any necessary metadata lists on dlt
|
|
108
124
|
await Promise.all(
|
|
109
125
|
flow(
|
|
110
|
-
filter({
|
|
111
|
-
map(({
|
|
112
|
-
)(
|
|
126
|
+
filter({ isNewList: true }),
|
|
127
|
+
map(({ listId }) => createList(listId, issuer, context))
|
|
128
|
+
)(credentialMetadatas)
|
|
113
129
|
);
|
|
114
130
|
|
|
115
131
|
// create credential metadata entries on dlt
|
|
116
|
-
await Promise.all(map((
|
|
117
|
-
|
|
118
|
-
return map('vcJwt', vcs);
|
|
132
|
+
await Promise.all(map((metadata) => addEntry(metadata), credentialMetadatas));
|
|
119
133
|
};
|
|
120
134
|
|
|
121
|
-
/**
|
|
122
|
-
* Creates verifiable credential from a local offer. Current assumption is that offers contain all required fields
|
|
123
|
-
* including @context, type, contentHash
|
|
124
|
-
* @param {CredentialOffer[]} offers array of offers
|
|
125
|
-
* @param {string} credentialSubjectId optional field if credential subject needs to be bound into the offer
|
|
126
|
-
* @param {{[Name: string]: CredentialTypeMetadata}} credentialTypesMap the credential types metadata
|
|
127
|
-
* @param {Issuer} issuer the issuer
|
|
128
|
-
* @param {Context} context the context
|
|
129
|
-
* @returns {Promise<string[]>} Returns signed credentials for each offer in vc-jwt format
|
|
130
|
-
*/
|
|
131
|
-
const issueVeriiCredentials = async (
|
|
132
|
-
offers,
|
|
133
|
-
credentialSubjectId,
|
|
134
|
-
credentialTypesMap,
|
|
135
|
-
issuer,
|
|
136
|
-
context
|
|
137
|
-
) => {
|
|
138
|
-
const { vcs, revocationListEntries } =
|
|
139
|
-
await prepareVeriiVerifiableCredentials(
|
|
140
|
-
offers,
|
|
141
|
-
credentialSubjectId,
|
|
142
|
-
credentialTypesMap,
|
|
143
|
-
issuer,
|
|
144
|
-
context
|
|
145
|
-
);
|
|
146
|
-
return anchorVeriiVerifiableCredentials(
|
|
147
|
-
vcs,
|
|
148
|
-
revocationListEntries,
|
|
149
|
-
issuer,
|
|
150
|
-
context
|
|
151
|
-
);
|
|
152
|
-
};
|
|
153
135
|
module.exports = {
|
|
154
|
-
|
|
136
|
+
anchorVeriiCredentials,
|
|
155
137
|
issueVeriiCredentials,
|
|
156
|
-
|
|
138
|
+
signVeriiCredentials,
|
|
157
139
|
};
|