@fonderie/client 0.19.0 → 0.20.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/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -90,10 +90,14 @@ var FonderieApiError = class extends Error {
|
|
|
90
90
|
details;
|
|
91
91
|
requestId;
|
|
92
92
|
};
|
|
93
|
-
function
|
|
93
|
+
function randHex(bytes) {
|
|
94
94
|
const c = globalThis.crypto;
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const arr = new Uint8Array(bytes);
|
|
96
|
+
if (c?.getRandomValues) c.getRandomValues(arr);
|
|
97
|
+
else for (let i = 0; i < bytes; i++) arr[i] = Math.floor(Math.random() * 256);
|
|
98
|
+
let out = "";
|
|
99
|
+
for (const b of arr) out += b.toString(16).padStart(2, "0");
|
|
100
|
+
return out;
|
|
97
101
|
}
|
|
98
102
|
var HttpClient = class {
|
|
99
103
|
constructor(baseUrl, deps = {}) {
|
|
@@ -142,9 +146,11 @@ var HttpClient = class {
|
|
|
142
146
|
return data;
|
|
143
147
|
}
|
|
144
148
|
async exec(opts, retried = false) {
|
|
145
|
-
const
|
|
149
|
+
const traceId = randHex(16);
|
|
150
|
+
const requestId = traceId;
|
|
146
151
|
const headers = {
|
|
147
152
|
"Content-Type": "application/json",
|
|
153
|
+
traceparent: `00-${traceId}-${randHex(8)}-01`,
|
|
148
154
|
"X-Request-ID": requestId
|
|
149
155
|
};
|
|
150
156
|
if (opts.token) headers["Authorization"] = `Bearer ${opts.token}`;
|