@sd-jwt/sd-jwt-vc 0.9.2-next.2 → 0.9.2-next.6
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -2
- package/dist/index.mjs +14 -2
- package/package.json +7 -7
- package/src/sd-jwt-vc-config.ts +2 -0
- package/src/sd-jwt-vc-instance.ts +16 -3
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -178,17 +178,29 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends import_core.SDJwtInstance {
|
|
|
178
178
|
*/
|
|
179
179
|
fetch(url, integrity) {
|
|
180
180
|
return __async(this, null, function* () {
|
|
181
|
+
var _a;
|
|
181
182
|
const controller = new AbortController();
|
|
182
|
-
const timeoutId = setTimeout(
|
|
183
|
+
const timeoutId = setTimeout(
|
|
184
|
+
() => controller.abort(),
|
|
185
|
+
(_a = this.userConfig.timeout) != null ? _a : 1e4
|
|
186
|
+
);
|
|
183
187
|
try {
|
|
184
188
|
const response = yield fetch(url, {
|
|
185
189
|
signal: controller.signal
|
|
186
190
|
});
|
|
187
191
|
if (!response.ok) {
|
|
188
|
-
|
|
192
|
+
const errorText = yield response.text();
|
|
193
|
+
throw new Error(
|
|
194
|
+
`Error fetching ${url}: ${response.status} ${response.statusText} - ${errorText}`
|
|
195
|
+
);
|
|
189
196
|
}
|
|
190
197
|
yield this.validateIntegrity(response.clone(), url, integrity);
|
|
191
198
|
return response.json();
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
201
|
+
throw new Error(`Request to ${url} timed out`);
|
|
202
|
+
}
|
|
203
|
+
throw error;
|
|
192
204
|
} finally {
|
|
193
205
|
clearTimeout(timeoutId);
|
|
194
206
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -146,17 +146,29 @@ var SDJwtVcInstance = class _SDJwtVcInstance extends SDJwtInstance {
|
|
|
146
146
|
*/
|
|
147
147
|
fetch(url, integrity) {
|
|
148
148
|
return __async(this, null, function* () {
|
|
149
|
+
var _a;
|
|
149
150
|
const controller = new AbortController();
|
|
150
|
-
const timeoutId = setTimeout(
|
|
151
|
+
const timeoutId = setTimeout(
|
|
152
|
+
() => controller.abort(),
|
|
153
|
+
(_a = this.userConfig.timeout) != null ? _a : 1e4
|
|
154
|
+
);
|
|
151
155
|
try {
|
|
152
156
|
const response = yield fetch(url, {
|
|
153
157
|
signal: controller.signal
|
|
154
158
|
});
|
|
155
159
|
if (!response.ok) {
|
|
156
|
-
|
|
160
|
+
const errorText = yield response.text();
|
|
161
|
+
throw new Error(
|
|
162
|
+
`Error fetching ${url}: ${response.status} ${response.statusText} - ${errorText}`
|
|
163
|
+
);
|
|
157
164
|
}
|
|
158
165
|
yield this.validateIntegrity(response.clone(), url, integrity);
|
|
159
166
|
return response.json();
|
|
167
|
+
} catch (error) {
|
|
168
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
169
|
+
throw new Error(`Request to ${url} timed out`);
|
|
170
|
+
}
|
|
171
|
+
throw error;
|
|
160
172
|
} finally {
|
|
161
173
|
clearTimeout(timeoutId);
|
|
162
174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sd-jwt/sd-jwt-vc",
|
|
3
|
-
"version": "0.9.2-next.
|
|
3
|
+
"version": "0.9.2-next.6+5e64551",
|
|
4
4
|
"description": "sd-jwt draft 7 implementation in typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
},
|
|
40
40
|
"license": "Apache-2.0",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sd-jwt/core": "0.9.2-next.
|
|
43
|
-
"@sd-jwt/jwt-status-list": "0.9.2-next.
|
|
44
|
-
"@sd-jwt/utils": "0.9.2-next.
|
|
42
|
+
"@sd-jwt/core": "0.9.2-next.6+5e64551",
|
|
43
|
+
"@sd-jwt/jwt-status-list": "0.9.2-next.6+5e64551",
|
|
44
|
+
"@sd-jwt/utils": "0.9.2-next.6+5e64551",
|
|
45
45
|
"ajv": "^8.17.1",
|
|
46
46
|
"ajv-formats": "^3.0.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@sd-jwt/crypto-nodejs": "0.9.2-next.
|
|
50
|
-
"@sd-jwt/types": "0.9.2-next.
|
|
49
|
+
"@sd-jwt/crypto-nodejs": "0.9.2-next.6+5e64551",
|
|
50
|
+
"@sd-jwt/types": "0.9.2-next.6+5e64551",
|
|
51
51
|
"jose": "^5.2.2",
|
|
52
52
|
"msw": "^2.3.5"
|
|
53
53
|
},
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"esm"
|
|
68
68
|
]
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "5e6455158648525d09320dd562422d9f9f33ffaa"
|
|
71
71
|
}
|
package/src/sd-jwt-vc-config.ts
CHANGED
|
@@ -16,4 +16,6 @@ export type SDJWTVCConfig = SDJWTConfig & {
|
|
|
16
16
|
vctFetcher?: VcTFetcher;
|
|
17
17
|
// if set to true, it will load the metadata format based on the vct value. If not provided, it will default to false.
|
|
18
18
|
loadTypeMetadataFormat?: boolean;
|
|
19
|
+
// timeout value in milliseconds when to abort the fetch request. If not provided, it will default to 10000.
|
|
20
|
+
timeout?: number;
|
|
19
21
|
};
|
|
@@ -166,18 +166,31 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> {
|
|
|
166
166
|
* @param url
|
|
167
167
|
* @returns
|
|
168
168
|
*/
|
|
169
|
-
private async fetch<T>(url: string, integrity?: string) {
|
|
169
|
+
private async fetch<T>(url: string, integrity?: string): Promise<T> {
|
|
170
170
|
const controller = new AbortController();
|
|
171
|
-
const timeoutId = setTimeout(
|
|
171
|
+
const timeoutId = setTimeout(
|
|
172
|
+
() => controller.abort(),
|
|
173
|
+
this.userConfig.timeout ?? 10000,
|
|
174
|
+
);
|
|
175
|
+
|
|
172
176
|
try {
|
|
173
177
|
const response = await fetch(url, {
|
|
174
178
|
signal: controller.signal,
|
|
175
179
|
});
|
|
180
|
+
|
|
176
181
|
if (!response.ok) {
|
|
177
|
-
|
|
182
|
+
const errorText = await response.text();
|
|
183
|
+
throw new Error(
|
|
184
|
+
`Error fetching ${url}: ${response.status} ${response.statusText} - ${errorText}`,
|
|
185
|
+
);
|
|
178
186
|
}
|
|
179
187
|
await this.validateIntegrity(response.clone(), url, integrity);
|
|
180
188
|
return response.json() as Promise<T>;
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
191
|
+
throw new Error(`Request to ${url} timed out`);
|
|
192
|
+
}
|
|
193
|
+
throw error;
|
|
181
194
|
} finally {
|
|
182
195
|
clearTimeout(timeoutId);
|
|
183
196
|
}
|