@sd-jwt/sd-jwt-vc 0.6.2-next.2 → 0.6.2-next.26
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/README.md +7 -4
- package/package.json +6 -6
- package/src/test/index.spec.ts +19 -2
- package/test/app-e2e.spec.ts +1 -1
package/README.md
CHANGED
|
@@ -38,13 +38,13 @@ Here's a basic example of how to use this library:
|
|
|
38
38
|
import { DisclosureFrame } from '@sd-jwt/sd-jwt-vc';
|
|
39
39
|
|
|
40
40
|
// identifier of the issuer
|
|
41
|
-
const iss =
|
|
41
|
+
const iss = 'University';
|
|
42
42
|
|
|
43
43
|
// issuance time
|
|
44
44
|
const iat = new Date().getTime() / 1000;
|
|
45
45
|
|
|
46
46
|
//unique identifier of the schema
|
|
47
|
-
const vct =
|
|
47
|
+
const vct = 'University-Degree';
|
|
48
48
|
|
|
49
49
|
// Issuer defines the claims object with the user's information
|
|
50
50
|
const claims = {
|
|
@@ -61,7 +61,10 @@ const disclosureFrame: DisclosureFrame<typeof claims> = {
|
|
|
61
61
|
|
|
62
62
|
// Issuer issues a signed JWT credential with the specified claims and disclosure frame
|
|
63
63
|
// returns an encoded JWT
|
|
64
|
-
const credential = await sdjwt.issue(
|
|
64
|
+
const credential = await sdjwt.issue(
|
|
65
|
+
{ iss, iat, vct, ...claims },
|
|
66
|
+
disclosureFrame,
|
|
67
|
+
);
|
|
65
68
|
|
|
66
69
|
// Holder may validate the credential from the issuer
|
|
67
70
|
const valid = await sdjwt.validate(credential);
|
|
@@ -78,7 +81,7 @@ const presentation = await sdjwt.present(credential, presentationFrame);
|
|
|
78
81
|
const verified = await sdjwt.verify(presentation);
|
|
79
82
|
```
|
|
80
83
|
|
|
81
|
-
Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/
|
|
84
|
+
Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/main/docs) or [examples](https://github.com/openwallet-foundation-labs/sd-jwt-js/tree/main/examples)
|
|
82
85
|
|
|
83
86
|
### Dependencies
|
|
84
87
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/sd-jwt-vc",
|
|
3
|
-
"version": "0.6.2-next.
|
|
3
|
+
"version": "0.6.2-next.26+5a6db52",
|
|
4
4
|
"description": "sd-jwt draft 7 implementation in typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"sd-jwt-vc"
|
|
27
27
|
],
|
|
28
28
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
29
|
+
"node": ">=18"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
},
|
|
40
40
|
"license": "Apache-2.0",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sd-jwt/core": "0.6.2-next.
|
|
42
|
+
"@sd-jwt/core": "0.6.2-next.26+5a6db52"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@sd-jwt/crypto-nodejs": "0.6.2-next.
|
|
46
|
-
"@sd-jwt/types": "0.6.2-next.
|
|
45
|
+
"@sd-jwt/crypto-nodejs": "0.6.2-next.26+5a6db52",
|
|
46
|
+
"@sd-jwt/types": "0.6.2-next.26+5a6db52"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"esm"
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "5a6db529b8e7d81027ee97c09ad3c68cde8a995e"
|
|
65
65
|
}
|
package/src/test/index.spec.ts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import { digest, generateSalt } from '@sd-jwt/crypto-nodejs';
|
|
2
|
-
import type { DisclosureFrame } from '@sd-jwt/types';
|
|
2
|
+
import type { DisclosureFrame, Signer, Verifier } from '@sd-jwt/types';
|
|
3
3
|
import { describe, test, expect } from 'vitest';
|
|
4
4
|
import { SDJwtVcInstance } from '..';
|
|
5
|
-
import { createSignerVerifier } from '../../test/app-e2e.spec';
|
|
6
5
|
import type { SdJwtVcPayload } from '../sd-jwt-vc-payload';
|
|
6
|
+
import Crypto from 'node:crypto';
|
|
7
7
|
|
|
8
8
|
const iss = 'ExampleIssuer';
|
|
9
9
|
const vct = 'https://example.com/schema/1';
|
|
10
10
|
const iat = new Date().getTime() / 1000;
|
|
11
11
|
|
|
12
|
+
const createSignerVerifier = () => {
|
|
13
|
+
const { privateKey, publicKey } = Crypto.generateKeyPairSync('ed25519');
|
|
14
|
+
const signer: Signer = async (data: string) => {
|
|
15
|
+
const sig = Crypto.sign(null, Buffer.from(data), privateKey);
|
|
16
|
+
return Buffer.from(sig).toString('base64url');
|
|
17
|
+
};
|
|
18
|
+
const verifier: Verifier = async (data: string, sig: string) => {
|
|
19
|
+
return Crypto.verify(
|
|
20
|
+
null,
|
|
21
|
+
Buffer.from(data),
|
|
22
|
+
publicKey,
|
|
23
|
+
Buffer.from(sig, 'base64url'),
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
return { signer, verifier };
|
|
27
|
+
};
|
|
28
|
+
|
|
12
29
|
describe('App', () => {
|
|
13
30
|
test('Example', async () => {
|
|
14
31
|
const { signer, verifier } = createSignerVerifier();
|
package/test/app-e2e.spec.ts
CHANGED
|
@@ -11,7 +11,7 @@ import path from 'node:path';
|
|
|
11
11
|
import { describe, expect, test } from 'vitest';
|
|
12
12
|
import { digest, generateSalt } from '@sd-jwt/crypto-nodejs';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const createSignerVerifier = () => {
|
|
15
15
|
const { privateKey, publicKey } = Crypto.generateKeyPairSync('ed25519');
|
|
16
16
|
const signer: Signer = async (data: string) => {
|
|
17
17
|
const sig = Crypto.sign(null, Buffer.from(data), privateKey);
|