@sphereon/ssi-types 0.32.0 → 0.32.1-next.12
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.
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { AsyncHasher } from './sd-jwt-vc';
|
|
2
1
|
/**
|
|
3
2
|
* Represents the metadata associated with a specific SD-JWT VC type.
|
|
4
3
|
*/
|
|
5
|
-
interface SdJwtTypeMetadata {
|
|
4
|
+
export interface SdJwtTypeMetadata {
|
|
6
5
|
/**
|
|
7
6
|
* REQUIRED. The VC type URI.
|
|
8
7
|
*/
|
|
@@ -38,12 +37,50 @@ interface SdJwtTypeMetadata {
|
|
|
38
37
|
/**
|
|
39
38
|
* OPTIONAL. Metadata for the claims within the VC.
|
|
40
39
|
*/
|
|
41
|
-
claims?: Array<
|
|
40
|
+
claims?: Array<SdJwtClaimMetadata>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Represents the metadata associated with a specific SD-JWT claim.
|
|
44
|
+
*/
|
|
45
|
+
export interface SdJwtClaimMetadata {
|
|
46
|
+
/**
|
|
47
|
+
* REQUIRED. An array indicating the claim or claims that are being addressed.
|
|
48
|
+
*/
|
|
49
|
+
path: Array<SdJwtClaimPath>;
|
|
50
|
+
/**
|
|
51
|
+
* OPTIONAL. Display information for the claim.
|
|
52
|
+
*/
|
|
53
|
+
display?: Array<SdJwtClaimDisplayMetadata>;
|
|
54
|
+
/**
|
|
55
|
+
* OPTIONAL. A string indicating whether the claim is selectively disclosable.
|
|
56
|
+
*/
|
|
57
|
+
sd?: SdJwtClaimSelectiveDisclosure;
|
|
58
|
+
/**
|
|
59
|
+
* OPTIONAL. A string defining the ID of the claim for reference in the SVG template.
|
|
60
|
+
*/
|
|
61
|
+
svg_id?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Represents claim display metadata for a specific language.
|
|
65
|
+
*/
|
|
66
|
+
export interface SdJwtClaimDisplayMetadata {
|
|
67
|
+
/**
|
|
68
|
+
* REQUIRED. Language tag for the display information.
|
|
69
|
+
*/
|
|
70
|
+
lang: string;
|
|
71
|
+
/**
|
|
72
|
+
* REQUIRED. A human-readable label for the claim, intended for end users.
|
|
73
|
+
*/
|
|
74
|
+
label: string;
|
|
75
|
+
/**
|
|
76
|
+
* REQUIRED. A human-readable description for the claim, intended for end users.
|
|
77
|
+
*/
|
|
78
|
+
description?: string;
|
|
42
79
|
}
|
|
43
80
|
/**
|
|
44
81
|
* Represents display metadata for a specific language.
|
|
45
82
|
*/
|
|
46
|
-
interface SdJwtTypeDisplayMetadata {
|
|
83
|
+
export interface SdJwtTypeDisplayMetadata {
|
|
47
84
|
/**
|
|
48
85
|
* REQUIRED. Language tag for the display information.
|
|
49
86
|
*/
|
|
@@ -64,7 +101,7 @@ interface SdJwtTypeDisplayMetadata {
|
|
|
64
101
|
/**
|
|
65
102
|
* Contains rendering metadata for different methods.
|
|
66
103
|
*/
|
|
67
|
-
interface SdJwtTypeRenderingMetadata {
|
|
104
|
+
export interface SdJwtTypeRenderingMetadata {
|
|
68
105
|
/**
|
|
69
106
|
* OPTIONAL. Simple rendering method metadata.
|
|
70
107
|
*/
|
|
@@ -77,7 +114,7 @@ interface SdJwtTypeRenderingMetadata {
|
|
|
77
114
|
/**
|
|
78
115
|
* Represents metadata for simple rendering.
|
|
79
116
|
*/
|
|
80
|
-
interface SdJwtSimpleRenderingMetadata {
|
|
117
|
+
export interface SdJwtSimpleRenderingMetadata {
|
|
81
118
|
/**
|
|
82
119
|
* OPTIONAL. Metadata for the logo image.
|
|
83
120
|
*/
|
|
@@ -94,7 +131,7 @@ interface SdJwtSimpleRenderingMetadata {
|
|
|
94
131
|
/**
|
|
95
132
|
* Represents metadata for a logo.
|
|
96
133
|
*/
|
|
97
|
-
interface SdJwtLogoMetadata {
|
|
134
|
+
export interface SdJwtLogoMetadata {
|
|
98
135
|
/**
|
|
99
136
|
* REQUIRED. URI pointing to the logo image.
|
|
100
137
|
*/
|
|
@@ -111,7 +148,7 @@ interface SdJwtLogoMetadata {
|
|
|
111
148
|
/**
|
|
112
149
|
* Represents metadata for SVG templates.
|
|
113
150
|
*/
|
|
114
|
-
interface SdJwtSVGTemplateMetadata {
|
|
151
|
+
export interface SdJwtSVGTemplateMetadata {
|
|
115
152
|
/**
|
|
116
153
|
* REQUIRED. URI pointing to the SVG template.
|
|
117
154
|
*/
|
|
@@ -128,7 +165,7 @@ interface SdJwtSVGTemplateMetadata {
|
|
|
128
165
|
/**
|
|
129
166
|
* Contains properties for SVG templates.
|
|
130
167
|
*/
|
|
131
|
-
interface SdJwtSVGTemplateProperties {
|
|
168
|
+
export interface SdJwtSVGTemplateProperties {
|
|
132
169
|
/**
|
|
133
170
|
* OPTIONAL. The orientation for which the SVG template is optimized.
|
|
134
171
|
*/
|
|
@@ -138,10 +175,17 @@ interface SdJwtSVGTemplateProperties {
|
|
|
138
175
|
*/
|
|
139
176
|
color_scheme?: string;
|
|
140
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* A string indicates that the respective key is to be selected.
|
|
180
|
+
* A null value indicates that all elements of the currently selected array(s) are to be selected.
|
|
181
|
+
* A non-negative integer indicates that the respective index in an array is to be selected.
|
|
182
|
+
*/
|
|
183
|
+
export type SdJwtClaimPath = string | null | number;
|
|
184
|
+
/**
|
|
185
|
+
* always: The Issuer MUST make the claim selectively disclosable.
|
|
186
|
+
* allowed: The Issuer MAY make the claim selectively disclosable.
|
|
187
|
+
* never: The Issuer MUST NOT make the claim selectively disclosable.
|
|
188
|
+
*/
|
|
189
|
+
export type SdJwtClaimSelectiveDisclosure = 'always' | 'allowed' | 'never';
|
|
141
190
|
export type SdJwtTypeHasher = (input: any, alg?: string) => string;
|
|
142
|
-
export declare function fetchSdJwtTypeMetadataFromVctUrl(vct: string, opts?: {
|
|
143
|
-
hasher?: AsyncHasher;
|
|
144
|
-
integrity?: string;
|
|
145
|
-
}): Promise<SdJwtTypeMetadata>;
|
|
146
|
-
export {};
|
|
147
191
|
//# sourceMappingURL=sd-jwt-type-metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-jwt-type-metadata.d.ts","sourceRoot":"","sources":["../../src/types/sd-jwt-type-metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sd-jwt-type-metadata.d.ts","sourceRoot":"","sources":["../../src/types/sd-jwt-type-metadata.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,84 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.fetchSdJwtTypeMetadataFromVctUrl = fetchSdJwtTypeMetadataFromVctUrl;
|
|
36
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
37
|
-
// Helper function to fetch API with error handling
|
|
38
|
-
function fetchUrlWithErrorHandling(url) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const response = yield fetch(url);
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
throw new Error(`${response.status}: ${response.statusText}`);
|
|
43
|
-
}
|
|
44
|
-
return response;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function validateIntegrity(input, integrityValue, hasher, alg) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const hash = yield hasher(input, alg !== null && alg !== void 0 ? alg : 'sha256');
|
|
50
|
-
return u8a.toString(hash, 'utf-8') === integrityValue;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
// Fetch and validate Type Metadata
|
|
54
|
-
function fetchSdJwtTypeMetadataFromVctUrl(vct, opts) {
|
|
55
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const url = new URL(vct);
|
|
57
|
-
const wellKnownUrl = `${url.origin}/.well-known/vct${url.pathname}`;
|
|
58
|
-
const response = yield fetchUrlWithErrorHandling(wellKnownUrl);
|
|
59
|
-
const metadata = yield response.json();
|
|
60
|
-
assertValidTypeMetadata(metadata, vct);
|
|
61
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.integrity) && opts.hasher) {
|
|
62
|
-
if (!(yield validateIntegrity(metadata, opts.integrity, opts.hasher))) {
|
|
63
|
-
throw new Error('Integrity check failed');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return metadata;
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function assertValidTypeMetadata(metadata, vct) {
|
|
70
|
-
if (metadata.vct !== vct) {
|
|
71
|
-
throw new Error('VCT mismatch in metadata and credential');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/*
|
|
75
|
-
// Example usage
|
|
76
|
-
try {
|
|
77
|
-
const vct = 'https://betelgeuse.example.com/education_credential'
|
|
78
|
-
const typeMetadata = await fetchSdJwtTypeMetadataFromVctUrl(vct)
|
|
79
|
-
console.log('Type Metadata retrieved successfully:', typeMetadata)
|
|
80
|
-
} catch (error) {
|
|
81
|
-
console.error('Error fetching type metadata:', error.message)
|
|
82
|
-
}
|
|
83
|
-
*/
|
|
84
3
|
//# sourceMappingURL=sd-jwt-type-metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-jwt-type-metadata.js","sourceRoot":"","sources":["../../src/types/sd-jwt-type-metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sd-jwt-type-metadata.js","sourceRoot":"","sources":["../../src/types/sd-jwt-type-metadata.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-types",
|
|
3
3
|
"description": "SSI Common Types",
|
|
4
|
-
"version": "0.32.
|
|
4
|
+
"version": "0.32.1-next.12+cd321acb",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"DIDs"
|
|
48
48
|
],
|
|
49
49
|
"nx": {},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "cd321acb679d70af853b7bad5548baa2345a4291"
|
|
51
51
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import * as u8a from 'uint8arrays'
|
|
2
|
-
import { AsyncHasher } from './sd-jwt-vc'
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Represents the metadata associated with a specific SD-JWT VC type.
|
|
6
3
|
*/
|
|
7
|
-
interface SdJwtTypeMetadata {
|
|
4
|
+
export interface SdJwtTypeMetadata {
|
|
8
5
|
/**
|
|
9
6
|
* REQUIRED. The VC type URI.
|
|
10
7
|
*/
|
|
@@ -48,14 +45,58 @@ interface SdJwtTypeMetadata {
|
|
|
48
45
|
/**
|
|
49
46
|
* OPTIONAL. Metadata for the claims within the VC.
|
|
50
47
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
claims?: Array<SdJwtClaimMetadata>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Represents the metadata associated with a specific SD-JWT claim.
|
|
53
|
+
*/
|
|
54
|
+
export interface SdJwtClaimMetadata {
|
|
55
|
+
/**
|
|
56
|
+
* REQUIRED. An array indicating the claim or claims that are being addressed.
|
|
57
|
+
*/
|
|
58
|
+
path: Array<SdJwtClaimPath>
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* OPTIONAL. Display information for the claim.
|
|
62
|
+
*/
|
|
63
|
+
display?: Array<SdJwtClaimDisplayMetadata>
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* OPTIONAL. A string indicating whether the claim is selectively disclosable.
|
|
67
|
+
*/
|
|
68
|
+
sd?: SdJwtClaimSelectiveDisclosure
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* OPTIONAL. A string defining the ID of the claim for reference in the SVG template.
|
|
72
|
+
*/
|
|
73
|
+
svg_id?: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Represents claim display metadata for a specific language.
|
|
78
|
+
*/
|
|
79
|
+
export interface SdJwtClaimDisplayMetadata {
|
|
80
|
+
/**
|
|
81
|
+
* REQUIRED. Language tag for the display information.
|
|
82
|
+
*/
|
|
83
|
+
lang: string
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* REQUIRED. A human-readable label for the claim, intended for end users.
|
|
87
|
+
*/
|
|
88
|
+
label: string
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* REQUIRED. A human-readable description for the claim, intended for end users.
|
|
92
|
+
*/
|
|
93
|
+
description?: string
|
|
53
94
|
}
|
|
54
95
|
|
|
55
96
|
/**
|
|
56
97
|
* Represents display metadata for a specific language.
|
|
57
98
|
*/
|
|
58
|
-
interface SdJwtTypeDisplayMetadata {
|
|
99
|
+
export interface SdJwtTypeDisplayMetadata {
|
|
59
100
|
/**
|
|
60
101
|
* REQUIRED. Language tag for the display information.
|
|
61
102
|
*/
|
|
@@ -80,7 +121,7 @@ interface SdJwtTypeDisplayMetadata {
|
|
|
80
121
|
/**
|
|
81
122
|
* Contains rendering metadata for different methods.
|
|
82
123
|
*/
|
|
83
|
-
interface SdJwtTypeRenderingMetadata {
|
|
124
|
+
export interface SdJwtTypeRenderingMetadata {
|
|
84
125
|
/**
|
|
85
126
|
* OPTIONAL. Simple rendering method metadata.
|
|
86
127
|
*/
|
|
@@ -95,7 +136,7 @@ interface SdJwtTypeRenderingMetadata {
|
|
|
95
136
|
/**
|
|
96
137
|
* Represents metadata for simple rendering.
|
|
97
138
|
*/
|
|
98
|
-
interface SdJwtSimpleRenderingMetadata {
|
|
139
|
+
export interface SdJwtSimpleRenderingMetadata {
|
|
99
140
|
/**
|
|
100
141
|
* OPTIONAL. Metadata for the logo image.
|
|
101
142
|
*/
|
|
@@ -115,7 +156,7 @@ interface SdJwtSimpleRenderingMetadata {
|
|
|
115
156
|
/**
|
|
116
157
|
* Represents metadata for a logo.
|
|
117
158
|
*/
|
|
118
|
-
interface SdJwtLogoMetadata {
|
|
159
|
+
export interface SdJwtLogoMetadata {
|
|
119
160
|
/**
|
|
120
161
|
* REQUIRED. URI pointing to the logo image.
|
|
121
162
|
*/
|
|
@@ -135,7 +176,7 @@ interface SdJwtLogoMetadata {
|
|
|
135
176
|
/**
|
|
136
177
|
* Represents metadata for SVG templates.
|
|
137
178
|
*/
|
|
138
|
-
interface SdJwtSVGTemplateMetadata {
|
|
179
|
+
export interface SdJwtSVGTemplateMetadata {
|
|
139
180
|
/**
|
|
140
181
|
* REQUIRED. URI pointing to the SVG template.
|
|
141
182
|
*/
|
|
@@ -155,7 +196,7 @@ interface SdJwtSVGTemplateMetadata {
|
|
|
155
196
|
/**
|
|
156
197
|
* Contains properties for SVG templates.
|
|
157
198
|
*/
|
|
158
|
-
interface SdJwtSVGTemplateProperties {
|
|
199
|
+
export interface SdJwtSVGTemplateProperties {
|
|
159
200
|
/**
|
|
160
201
|
* OPTIONAL. The orientation for which the SVG template is optimized.
|
|
161
202
|
*/
|
|
@@ -167,51 +208,18 @@ interface SdJwtSVGTemplateProperties {
|
|
|
167
208
|
color_scheme?: string
|
|
168
209
|
}
|
|
169
210
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return response
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export type SdJwtTypeHasher = (input: any, alg?: string) => string
|
|
180
|
-
|
|
181
|
-
async function validateIntegrity(input: any, integrityValue: string, hasher: AsyncHasher, alg?: string): Promise<boolean> {
|
|
182
|
-
const hash = await hasher(input, alg ?? 'sha256')
|
|
183
|
-
return u8a.toString(hash, 'utf-8') === integrityValue
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Fetch and validate Type Metadata
|
|
187
|
-
export async function fetchSdJwtTypeMetadataFromVctUrl(vct: string, opts?: { hasher?: AsyncHasher; integrity?: string }): Promise<SdJwtTypeMetadata> {
|
|
188
|
-
const url = new URL(vct)
|
|
189
|
-
const wellKnownUrl = `${url.origin}/.well-known/vct${url.pathname}`
|
|
190
|
-
|
|
191
|
-
const response = await fetchUrlWithErrorHandling(wellKnownUrl)
|
|
192
|
-
const metadata: SdJwtTypeMetadata = await response.json()
|
|
193
|
-
assertValidTypeMetadata(metadata, vct)
|
|
194
|
-
if (opts?.integrity && opts.hasher) {
|
|
195
|
-
if (!(await validateIntegrity(metadata, opts.integrity, opts.hasher))) {
|
|
196
|
-
throw new Error('Integrity check failed')
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return metadata
|
|
200
|
-
}
|
|
211
|
+
/**
|
|
212
|
+
* A string indicates that the respective key is to be selected.
|
|
213
|
+
* A null value indicates that all elements of the currently selected array(s) are to be selected.
|
|
214
|
+
* A non-negative integer indicates that the respective index in an array is to be selected.
|
|
215
|
+
*/
|
|
216
|
+
export type SdJwtClaimPath = string | null | number
|
|
201
217
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
218
|
+
/**
|
|
219
|
+
* always: The Issuer MUST make the claim selectively disclosable.
|
|
220
|
+
* allowed: The Issuer MAY make the claim selectively disclosable.
|
|
221
|
+
* never: The Issuer MUST NOT make the claim selectively disclosable.
|
|
222
|
+
*/
|
|
223
|
+
export type SdJwtClaimSelectiveDisclosure = 'always' | 'allowed' | 'never'
|
|
207
224
|
|
|
208
|
-
|
|
209
|
-
// Example usage
|
|
210
|
-
try {
|
|
211
|
-
const vct = 'https://betelgeuse.example.com/education_credential'
|
|
212
|
-
const typeMetadata = await fetchSdJwtTypeMetadataFromVctUrl(vct)
|
|
213
|
-
console.log('Type Metadata retrieved successfully:', typeMetadata)
|
|
214
|
-
} catch (error) {
|
|
215
|
-
console.error('Error fetching type metadata:', error.message)
|
|
216
|
-
}
|
|
217
|
-
*/
|
|
225
|
+
export type SdJwtTypeHasher = (input: any, alg?: string) => string
|