@inixiative/signet 0.4.0 → 0.4.1
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 +2 -2
- package/src/client.ts +8 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inixiative/signet",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Present Kingdom Signets: the wire contracts, DPoP proofs, device pairing and a renewing client shared by Kingdom, Archive, Foundry and Oracle.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@biomejs/biome": "2.5.2",
|
|
37
|
-
"@inixiative/config": "^0.5.
|
|
37
|
+
"@inixiative/config": "^0.5.86",
|
|
38
38
|
"@types/bun": "1.4.2",
|
|
39
39
|
"lefthook": "2.1.9",
|
|
40
40
|
"typescript": "6.0.3",
|
package/src/client.ts
CHANGED
|
@@ -111,17 +111,16 @@ function abortable<T>(pending: Promise<T>, signal: AbortSignal): Promise<T> {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/** Kingdom's JSON reason, else the start of the raw body (a proxy's page). */
|
|
114
115
|
const errorDetail = async (response: Response) => {
|
|
116
|
+
const text = (await response.text().catch(() => '')).slice(0, 65_536).trim();
|
|
115
117
|
try {
|
|
116
|
-
const body = JSON.parse(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} catch {
|
|
123
|
-
return undefined;
|
|
124
|
-
}
|
|
118
|
+
const body = JSON.parse(text) as { message?: unknown; error?: unknown };
|
|
119
|
+
const error = body.error as { message?: unknown } | string | undefined;
|
|
120
|
+
const message = typeof error === 'string' ? error : (error?.message ?? body.message);
|
|
121
|
+
if (typeof message === 'string') return message.slice(0, 500);
|
|
122
|
+
} catch {}
|
|
123
|
+
return text.replace(/\s+/g, ' ').slice(0, 500) || undefined;
|
|
125
124
|
};
|
|
126
125
|
|
|
127
126
|
/** POST to Kingdom's access API and return the response's `data`. */
|