@verii/verifgen 1.0.0 → 1.0.2
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/verifgen",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A tool for creating verifiable credentials and verifiable presentations.",
|
|
5
5
|
"repository": "https://github.com/LFDT-Verii/core",
|
|
6
6
|
"main": "index.js",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"prettier": "2.8.8"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@verii/blockchain-functions": "1.0.
|
|
34
|
-
"@verii/common-functions": "1.0.
|
|
35
|
-
"@verii/crypto": "1.0.
|
|
36
|
-
"@verii/did-doc": "1.0.
|
|
37
|
-
"@verii/jwt": "1.0.
|
|
38
|
-
"@verii/vc-checks": "1.0.
|
|
39
|
-
"@verii/verii-verification": "1.0.
|
|
33
|
+
"@verii/blockchain-functions": "1.0.2",
|
|
34
|
+
"@verii/common-functions": "1.0.2",
|
|
35
|
+
"@verii/crypto": "1.0.2",
|
|
36
|
+
"@verii/did-doc": "1.0.2",
|
|
37
|
+
"@verii/jwt": "1.0.2",
|
|
38
|
+
"@verii/vc-checks": "1.0.2",
|
|
39
|
+
"@verii/verii-verification": "1.0.2",
|
|
40
40
|
"bs58": "~6.0.0",
|
|
41
41
|
"chalk": "~4.1.2",
|
|
42
42
|
"commander": "~13.1.0",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"lodash": "^4.17.21",
|
|
45
45
|
"nanoid": "~3.3.4"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "1a5a2e5c5983278f9f2a107adb13cade1bfae501"
|
|
48
48
|
}
|
|
@@ -14,6 +14,7 @@ const generateProof = async (options) => {
|
|
|
14
14
|
publicKey,
|
|
15
15
|
privateKey: personaInfo.privateKey,
|
|
16
16
|
},
|
|
17
|
+
typ: options.openid4vci ? 'openid4vci-proof+jwt' : 'JWT',
|
|
17
18
|
options,
|
|
18
19
|
});
|
|
19
20
|
common.printInfo(`\nGenerated proof jwt:\n${proofJwt}\n`);
|
|
@@ -36,13 +37,14 @@ const loadNonce = (options) => {
|
|
|
36
37
|
return response.challenge;
|
|
37
38
|
};
|
|
38
39
|
|
|
39
|
-
const buildProofJwt = async ({ nonce, keyPair, options }) => {
|
|
40
|
+
const buildProofJwt = async ({ nonce, keyPair, typ, options }) => {
|
|
40
41
|
const kid = getDidUriFromJwk(toJwk(keyPair.publicKey, false));
|
|
41
42
|
const jwt = await jwtSign(
|
|
42
43
|
{ aud: options.audience, nonce, iss: kid },
|
|
43
44
|
toJwk(keyPair.privateKey),
|
|
44
45
|
{
|
|
45
46
|
kid: `${kid}#0`,
|
|
47
|
+
typ,
|
|
46
48
|
}
|
|
47
49
|
);
|
|
48
50
|
return jwt;
|
package/test/proof.test.js
CHANGED
|
@@ -110,4 +110,36 @@ describe('Test proof cli tool', () => {
|
|
|
110
110
|
},
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
|
+
|
|
114
|
+
it('should generate an openid4vci proof by a prv.key.json', async () => {
|
|
115
|
+
const persona2Keypair = await generateKeyPair({ format: 'jwk' });
|
|
116
|
+
const name = 'persona2';
|
|
117
|
+
await fs.writeFile(
|
|
118
|
+
`${currentDir}/${name}.prv.key.json`,
|
|
119
|
+
JSON.stringify(persona2Keypair.privateKey)
|
|
120
|
+
);
|
|
121
|
+
await fs.writeFile(`${currentDir}/${name}.did`, JSON.stringify({}));
|
|
122
|
+
const proof = await generateProof({
|
|
123
|
+
challenge: 'abc',
|
|
124
|
+
persona: 'persona2',
|
|
125
|
+
audience: 'http://test.com',
|
|
126
|
+
openid4vci: true,
|
|
127
|
+
});
|
|
128
|
+
expect(proof).toBeDefined();
|
|
129
|
+
const parsedJwt = await jwtVerify(proof, persona2Keypair.publicKey);
|
|
130
|
+
const expectedKid = getDidUriFromJwk(persona2Keypair.publicKey);
|
|
131
|
+
expect(parsedJwt).toStrictEqual({
|
|
132
|
+
header: {
|
|
133
|
+
alg: 'ES256K',
|
|
134
|
+
typ: 'openid4vci-proof+jwt',
|
|
135
|
+
kid: `${expectedKid}#0`,
|
|
136
|
+
},
|
|
137
|
+
payload: {
|
|
138
|
+
aud: 'http://test.com',
|
|
139
|
+
iat: expect.any(Number),
|
|
140
|
+
iss: expectedKid,
|
|
141
|
+
nonce: 'abc',
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
});
|
|
113
145
|
});
|