@sd-jwt/types 0.3.2-next.99 → 0.4.0
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/CHANGELOG.md +22 -0
- package/dist/index.d.mts +73 -1
- package/dist/index.d.ts +73 -1
- package/package.json +2 -2
- package/src/test/type.spec.ts +58 -0
- package/src/type.ts +83 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 0.4.0 (2024-03-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* add publish config ([#93](https://github.com/openwallet-foundation-labs/sd-jwt-js/issues/93)) ([2e4c5c1](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/2e4c5c176dc88e58e49d06783b7658d8ad872313))
|
|
12
|
+
* format file ([28202b2](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/28202b20daf80225cea0f5415a14b623276c6188))
|
|
13
|
+
* implement kbverify function ([#127](https://github.com/openwallet-foundation-labs/sd-jwt-js/issues/127)) ([e5609f2](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/e5609f26fab8c4991d3bd6c36066a95a30cfb972))
|
|
14
|
+
* update type of credential ([63d5ebb](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/63d5ebb4e3e5dd34ae8f82b2ef890a9b2647654f))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add jwk type ([#130](https://github.com/openwallet-foundation-labs/sd-jwt-js/issues/130)) ([8ce255a](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/8ce255a64b0940e92e647aa544bf5990b48279b7))
|
|
20
|
+
* add new package for sd-jwt-vc ([ed99188](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/ed99188f13184d58db64b4211e39fb67f3f78cb5))
|
|
21
|
+
* calcuate sd_hash in kb JWT ([#117](https://github.com/openwallet-foundation-labs/sd-jwt-js/issues/117)) ([3415550](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/3415550fbcd99f97babff442a4928cc827c5c9cc))
|
|
22
|
+
* restore rsa type in JWK ([#137](https://github.com/openwallet-foundation-labs/sd-jwt-js/issues/137)) ([fe0d8f6](https://github.com/openwallet-foundation-labs/sd-jwt-js/commit/fe0d8f6a3249dfea27b08f82165555de389efe1d))
|
package/dist/index.d.mts
CHANGED
|
@@ -31,6 +31,31 @@ type kbPayload = {
|
|
|
31
31
|
type KBOptions = {
|
|
32
32
|
payload: Omit<kbPayload, 'sd_hash'>;
|
|
33
33
|
};
|
|
34
|
+
interface RsaOtherPrimesInfo {
|
|
35
|
+
d?: string;
|
|
36
|
+
r?: string;
|
|
37
|
+
t?: string;
|
|
38
|
+
}
|
|
39
|
+
interface JsonWebKey {
|
|
40
|
+
alg?: string;
|
|
41
|
+
crv?: string;
|
|
42
|
+
d?: string;
|
|
43
|
+
dp?: string;
|
|
44
|
+
dq?: string;
|
|
45
|
+
e?: string;
|
|
46
|
+
ext?: boolean;
|
|
47
|
+
k?: string;
|
|
48
|
+
key_ops?: string[];
|
|
49
|
+
kty?: string;
|
|
50
|
+
n?: string;
|
|
51
|
+
oth?: RsaOtherPrimesInfo[];
|
|
52
|
+
p?: string;
|
|
53
|
+
q?: string;
|
|
54
|
+
qi?: string;
|
|
55
|
+
use?: string;
|
|
56
|
+
x?: string;
|
|
57
|
+
y?: string;
|
|
58
|
+
}
|
|
34
59
|
interface JwtPayload {
|
|
35
60
|
cnf?: {
|
|
36
61
|
jwk: JsonWebKey;
|
|
@@ -104,5 +129,52 @@ type Frame<Payload> = Payload extends Array<infer U> ? U extends object ? Record
|
|
|
104
129
|
[K in keyof Payload]?: Payload[K] extends object ? Frame<Payload[K]> : never;
|
|
105
130
|
} & SD<Payload> & DECOY> : SD<Payload> & DECOY;
|
|
106
131
|
type DisclosureFrame<T extends object> = Frame<T>;
|
|
132
|
+
/**
|
|
133
|
+
* This is a presentationFrame type that is used to represent the structure of what is being presented.
|
|
134
|
+
* PresentationFrame is made from the payload type.
|
|
135
|
+
* const claims = {
|
|
136
|
+
firstname: 'John',
|
|
137
|
+
lastname: 'Doe',
|
|
138
|
+
ssn: '123-45-6789',
|
|
139
|
+
id: '1234',
|
|
140
|
+
data: {
|
|
141
|
+
firstname: 'John',
|
|
142
|
+
lastname: 'Doe',
|
|
143
|
+
ssn: '123-45-6789',
|
|
144
|
+
list: [{ r: 'd' }, 'b', 'c'],
|
|
145
|
+
list2: ['1', '2', '3'],
|
|
146
|
+
list3: ['1', null, 2],
|
|
147
|
+
},
|
|
148
|
+
data2: {
|
|
149
|
+
hi: 'bye',
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
Example of a presentationFrame:
|
|
154
|
+
const presentationFrame: PresentationFrame<typeof claims> = {
|
|
155
|
+
firstname: true,
|
|
156
|
+
lastname: true,
|
|
157
|
+
ssn: true,
|
|
158
|
+
id: 'true',
|
|
159
|
+
data: {
|
|
160
|
+
firstname: true,
|
|
161
|
+
list: {
|
|
162
|
+
1: true,
|
|
163
|
+
0: {
|
|
164
|
+
r: true,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
list2: {
|
|
168
|
+
1: true,
|
|
169
|
+
},
|
|
170
|
+
list3: true,
|
|
171
|
+
},
|
|
172
|
+
data2: true,
|
|
173
|
+
};
|
|
174
|
+
*/
|
|
175
|
+
type PFrame<Payload> = Payload extends Array<infer U> ? U extends object ? Record<number, PFrame<U> | boolean> | boolean : Record<number, boolean> | boolean : {
|
|
176
|
+
[K in keyof Payload]?: Payload[K] extends object ? PFrame<Payload[K]> | boolean : boolean;
|
|
177
|
+
};
|
|
178
|
+
type PresentationFrame<T extends object> = PFrame<T>;
|
|
107
179
|
|
|
108
|
-
export { type Base64urlString, type DECOY, type DisclosureData, type DisclosureFrame, type Hasher, type HasherAndAlg, type HasherAndAlgSync, type HasherSync, type JwtPayload, type KBOptions, KB_JWT_TYP, type KbVerifier, type OrPromise, type SD, type SDJWTCompact, type SDJWTConfig, SD_DECOY, SD_DIGEST, SD_LIST_KEY, SD_SEPARATOR, type SaltGenerator, type SaltGeneratorSync, type Signer, type SignerSync, type Verifier, type VerifierSync, type kbHeader, type kbPayload };
|
|
180
|
+
export { type Base64urlString, type DECOY, type DisclosureData, type DisclosureFrame, type Hasher, type HasherAndAlg, type HasherAndAlgSync, type HasherSync, type JwtPayload, type KBOptions, KB_JWT_TYP, type KbVerifier, type OrPromise, type PresentationFrame, type SD, type SDJWTCompact, type SDJWTConfig, SD_DECOY, SD_DIGEST, SD_LIST_KEY, SD_SEPARATOR, type SaltGenerator, type SaltGeneratorSync, type Signer, type SignerSync, type Verifier, type VerifierSync, type kbHeader, type kbPayload };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,31 @@ type kbPayload = {
|
|
|
31
31
|
type KBOptions = {
|
|
32
32
|
payload: Omit<kbPayload, 'sd_hash'>;
|
|
33
33
|
};
|
|
34
|
+
interface RsaOtherPrimesInfo {
|
|
35
|
+
d?: string;
|
|
36
|
+
r?: string;
|
|
37
|
+
t?: string;
|
|
38
|
+
}
|
|
39
|
+
interface JsonWebKey {
|
|
40
|
+
alg?: string;
|
|
41
|
+
crv?: string;
|
|
42
|
+
d?: string;
|
|
43
|
+
dp?: string;
|
|
44
|
+
dq?: string;
|
|
45
|
+
e?: string;
|
|
46
|
+
ext?: boolean;
|
|
47
|
+
k?: string;
|
|
48
|
+
key_ops?: string[];
|
|
49
|
+
kty?: string;
|
|
50
|
+
n?: string;
|
|
51
|
+
oth?: RsaOtherPrimesInfo[];
|
|
52
|
+
p?: string;
|
|
53
|
+
q?: string;
|
|
54
|
+
qi?: string;
|
|
55
|
+
use?: string;
|
|
56
|
+
x?: string;
|
|
57
|
+
y?: string;
|
|
58
|
+
}
|
|
34
59
|
interface JwtPayload {
|
|
35
60
|
cnf?: {
|
|
36
61
|
jwk: JsonWebKey;
|
|
@@ -104,5 +129,52 @@ type Frame<Payload> = Payload extends Array<infer U> ? U extends object ? Record
|
|
|
104
129
|
[K in keyof Payload]?: Payload[K] extends object ? Frame<Payload[K]> : never;
|
|
105
130
|
} & SD<Payload> & DECOY> : SD<Payload> & DECOY;
|
|
106
131
|
type DisclosureFrame<T extends object> = Frame<T>;
|
|
132
|
+
/**
|
|
133
|
+
* This is a presentationFrame type that is used to represent the structure of what is being presented.
|
|
134
|
+
* PresentationFrame is made from the payload type.
|
|
135
|
+
* const claims = {
|
|
136
|
+
firstname: 'John',
|
|
137
|
+
lastname: 'Doe',
|
|
138
|
+
ssn: '123-45-6789',
|
|
139
|
+
id: '1234',
|
|
140
|
+
data: {
|
|
141
|
+
firstname: 'John',
|
|
142
|
+
lastname: 'Doe',
|
|
143
|
+
ssn: '123-45-6789',
|
|
144
|
+
list: [{ r: 'd' }, 'b', 'c'],
|
|
145
|
+
list2: ['1', '2', '3'],
|
|
146
|
+
list3: ['1', null, 2],
|
|
147
|
+
},
|
|
148
|
+
data2: {
|
|
149
|
+
hi: 'bye',
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
Example of a presentationFrame:
|
|
154
|
+
const presentationFrame: PresentationFrame<typeof claims> = {
|
|
155
|
+
firstname: true,
|
|
156
|
+
lastname: true,
|
|
157
|
+
ssn: true,
|
|
158
|
+
id: 'true',
|
|
159
|
+
data: {
|
|
160
|
+
firstname: true,
|
|
161
|
+
list: {
|
|
162
|
+
1: true,
|
|
163
|
+
0: {
|
|
164
|
+
r: true,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
list2: {
|
|
168
|
+
1: true,
|
|
169
|
+
},
|
|
170
|
+
list3: true,
|
|
171
|
+
},
|
|
172
|
+
data2: true,
|
|
173
|
+
};
|
|
174
|
+
*/
|
|
175
|
+
type PFrame<Payload> = Payload extends Array<infer U> ? U extends object ? Record<number, PFrame<U> | boolean> | boolean : Record<number, boolean> | boolean : {
|
|
176
|
+
[K in keyof Payload]?: Payload[K] extends object ? PFrame<Payload[K]> | boolean : boolean;
|
|
177
|
+
};
|
|
178
|
+
type PresentationFrame<T extends object> = PFrame<T>;
|
|
107
179
|
|
|
108
|
-
export { type Base64urlString, type DECOY, type DisclosureData, type DisclosureFrame, type Hasher, type HasherAndAlg, type HasherAndAlgSync, type HasherSync, type JwtPayload, type KBOptions, KB_JWT_TYP, type KbVerifier, type OrPromise, type SD, type SDJWTCompact, type SDJWTConfig, SD_DECOY, SD_DIGEST, SD_LIST_KEY, SD_SEPARATOR, type SaltGenerator, type SaltGeneratorSync, type Signer, type SignerSync, type Verifier, type VerifierSync, type kbHeader, type kbPayload };
|
|
180
|
+
export { type Base64urlString, type DECOY, type DisclosureData, type DisclosureFrame, type Hasher, type HasherAndAlg, type HasherAndAlgSync, type HasherSync, type JwtPayload, type KBOptions, KB_JWT_TYP, type KbVerifier, type OrPromise, type PresentationFrame, type SD, type SDJWTCompact, type SDJWTConfig, SD_DECOY, SD_DIGEST, SD_LIST_KEY, SD_SEPARATOR, type SaltGenerator, type SaltGeneratorSync, type Signer, type SignerSync, type Verifier, type VerifierSync, type kbHeader, type kbPayload };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "sd-jwt draft 7 implementation in typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"esm"
|
|
54
54
|
]
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "391a36550a66833b3d393ff0deb699b1b72cca59"
|
|
57
57
|
}
|
package/src/test/type.spec.ts
CHANGED
|
@@ -5,8 +5,28 @@ import {
|
|
|
5
5
|
SD_DIGEST,
|
|
6
6
|
SD_DECOY,
|
|
7
7
|
KB_JWT_TYP,
|
|
8
|
+
DisclosureFrame,
|
|
9
|
+
PresentationFrame,
|
|
8
10
|
} from '../index';
|
|
9
11
|
|
|
12
|
+
const claims = {
|
|
13
|
+
firstname: 'John',
|
|
14
|
+
lastname: 'Doe',
|
|
15
|
+
ssn: '123-45-6789',
|
|
16
|
+
id: '1234',
|
|
17
|
+
data: {
|
|
18
|
+
firstname: 'John',
|
|
19
|
+
lastname: 'Doe',
|
|
20
|
+
ssn: '123-45-6789',
|
|
21
|
+
list: [{ r: 'd' }, 'b', 'c'],
|
|
22
|
+
list2: ['1', '2', '3'],
|
|
23
|
+
list3: ['1', null, 2],
|
|
24
|
+
},
|
|
25
|
+
data2: {
|
|
26
|
+
hi: 'bye',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
10
30
|
describe('Variable tests', () => {
|
|
11
31
|
test('SD_SEPARATOR', () => {
|
|
12
32
|
expect(SD_SEPARATOR).toBe('~');
|
|
@@ -27,4 +47,42 @@ describe('Variable tests', () => {
|
|
|
27
47
|
test('KB_JWT_TYP', () => {
|
|
28
48
|
expect(KB_JWT_TYP).toBe('kb+jwt');
|
|
29
49
|
});
|
|
50
|
+
|
|
51
|
+
test('DisclosureFrameType test', () => {
|
|
52
|
+
const disclosureFrame: DisclosureFrame<typeof claims> = {
|
|
53
|
+
_sd: ['data', 'firstname', 'data2'],
|
|
54
|
+
data: {
|
|
55
|
+
_sd: ['list', 'ssn'],
|
|
56
|
+
_sd_decoy: 2,
|
|
57
|
+
list: {
|
|
58
|
+
_sd: [0, 2],
|
|
59
|
+
0: {
|
|
60
|
+
_sd: ['r'],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
expect(disclosureFrame).toBeDefined();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('PresentationFrameType test', () => {
|
|
69
|
+
const presentationFrame: PresentationFrame<typeof claims> = {
|
|
70
|
+
firstname: true,
|
|
71
|
+
data: {
|
|
72
|
+
firstname: true,
|
|
73
|
+
list: {
|
|
74
|
+
1: true,
|
|
75
|
+
0: {
|
|
76
|
+
r: true,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
list2: {
|
|
80
|
+
1: true,
|
|
81
|
+
},
|
|
82
|
+
list3: true,
|
|
83
|
+
},
|
|
84
|
+
data2: true,
|
|
85
|
+
};
|
|
86
|
+
expect(presentationFrame).toBeDefined();
|
|
87
|
+
});
|
|
30
88
|
});
|
package/src/type.ts
CHANGED
|
@@ -34,6 +34,34 @@ export type KBOptions = {
|
|
|
34
34
|
payload: Omit<kbPayload, 'sd_hash'>;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
// This type declaration is from lib.dom.ts
|
|
38
|
+
interface RsaOtherPrimesInfo {
|
|
39
|
+
d?: string;
|
|
40
|
+
r?: string;
|
|
41
|
+
t?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface JsonWebKey {
|
|
45
|
+
alg?: string;
|
|
46
|
+
crv?: string;
|
|
47
|
+
d?: string;
|
|
48
|
+
dp?: string;
|
|
49
|
+
dq?: string;
|
|
50
|
+
e?: string;
|
|
51
|
+
ext?: boolean;
|
|
52
|
+
k?: string;
|
|
53
|
+
key_ops?: string[];
|
|
54
|
+
kty?: string;
|
|
55
|
+
n?: string;
|
|
56
|
+
oth?: RsaOtherPrimesInfo[];
|
|
57
|
+
p?: string;
|
|
58
|
+
q?: string;
|
|
59
|
+
qi?: string;
|
|
60
|
+
use?: string;
|
|
61
|
+
x?: string;
|
|
62
|
+
y?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
37
65
|
export interface JwtPayload {
|
|
38
66
|
cnf?: {
|
|
39
67
|
jwk: JsonWebKey;
|
|
@@ -126,3 +154,58 @@ type Frame<Payload> = Payload extends Array<infer U>
|
|
|
126
154
|
: SD<Payload> & DECOY;
|
|
127
155
|
|
|
128
156
|
export type DisclosureFrame<T extends object> = Frame<T>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* This is a presentationFrame type that is used to represent the structure of what is being presented.
|
|
160
|
+
* PresentationFrame is made from the payload type.
|
|
161
|
+
* const claims = {
|
|
162
|
+
firstname: 'John',
|
|
163
|
+
lastname: 'Doe',
|
|
164
|
+
ssn: '123-45-6789',
|
|
165
|
+
id: '1234',
|
|
166
|
+
data: {
|
|
167
|
+
firstname: 'John',
|
|
168
|
+
lastname: 'Doe',
|
|
169
|
+
ssn: '123-45-6789',
|
|
170
|
+
list: [{ r: 'd' }, 'b', 'c'],
|
|
171
|
+
list2: ['1', '2', '3'],
|
|
172
|
+
list3: ['1', null, 2],
|
|
173
|
+
},
|
|
174
|
+
data2: {
|
|
175
|
+
hi: 'bye',
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
Example of a presentationFrame:
|
|
180
|
+
const presentationFrame: PresentationFrame<typeof claims> = {
|
|
181
|
+
firstname: true,
|
|
182
|
+
lastname: true,
|
|
183
|
+
ssn: true,
|
|
184
|
+
id: 'true',
|
|
185
|
+
data: {
|
|
186
|
+
firstname: true,
|
|
187
|
+
list: {
|
|
188
|
+
1: true,
|
|
189
|
+
0: {
|
|
190
|
+
r: true,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
list2: {
|
|
194
|
+
1: true,
|
|
195
|
+
},
|
|
196
|
+
list3: true,
|
|
197
|
+
},
|
|
198
|
+
data2: true,
|
|
199
|
+
};
|
|
200
|
+
*/
|
|
201
|
+
type PFrame<Payload> = Payload extends Array<infer U>
|
|
202
|
+
? U extends object
|
|
203
|
+
? Record<number, PFrame<U> | boolean> | boolean
|
|
204
|
+
: Record<number, boolean> | boolean
|
|
205
|
+
: {
|
|
206
|
+
[K in keyof Payload]?: Payload[K] extends object
|
|
207
|
+
? PFrame<Payload[K]> | boolean
|
|
208
|
+
: boolean;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export type PresentationFrame<T extends object> = PFrame<T>;
|