@bsv/sdk 1.3.26 → 1.3.27
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/cjs/package.json +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js +18 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +18 -1
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/package.json +1 -1
- package/src/auth/clients/AuthFetch.ts +19 -1
package/package.json
CHANGED
|
@@ -329,6 +329,19 @@ export class AuthFetch {
|
|
|
329
329
|
writer.write(headerValueAsArray)
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
+
// If method typically carries a body and body is undefined, default it
|
|
333
|
+
// This prevents signature verification errors due to mismatch default body types with express
|
|
334
|
+
const methodsThatTypicallyHaveBody = ['POST', 'PUT', 'PATCH', 'DELETE']
|
|
335
|
+
if (methodsThatTypicallyHaveBody.includes(method.toUpperCase()) && body === undefined) {
|
|
336
|
+
// Check if content-type is application/json
|
|
337
|
+
const contentTypeHeader = includedHeaders.find(([k]) => k === 'content-type')
|
|
338
|
+
if (contentTypeHeader && contentTypeHeader[1].includes('application/json')) {
|
|
339
|
+
body = '{}'
|
|
340
|
+
} else {
|
|
341
|
+
body = ''
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
332
345
|
// Handle body
|
|
333
346
|
if (body) {
|
|
334
347
|
const reqBody = await this.normalizeBodyToNumberArray(body) // Use the utility function
|
|
@@ -431,11 +444,16 @@ export class AuthFetch {
|
|
|
431
444
|
}
|
|
432
445
|
|
|
433
446
|
private async normalizeBodyToNumberArray(body: BodyInit | null | undefined): Promise<number[]> {
|
|
434
|
-
//
|
|
447
|
+
// 0. Null / undefined
|
|
435
448
|
if (body == null) {
|
|
436
449
|
return []
|
|
437
450
|
}
|
|
438
451
|
|
|
452
|
+
// 1. object
|
|
453
|
+
if (typeof body === 'object') {
|
|
454
|
+
return Utils.toArray(JSON.stringify(body, 'utf8'))
|
|
455
|
+
}
|
|
456
|
+
|
|
439
457
|
// 2. number[]
|
|
440
458
|
if (Array.isArray(body) && body.every((item) => typeof item === 'number')) {
|
|
441
459
|
return body // Return the array as is
|