@bsv/sdk 1.6.2 → 1.6.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/sdk",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "type": "module",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "main": "dist/cjs/mod.js",
@@ -240,7 +240,6 @@ export class AuthFetch {
240
240
  reject(e)
241
241
  }
242
242
  }) as Function)
243
-
244
243
  // Check if server requires payment to access the requested route
245
244
  if (response.status === 402) {
246
245
  // Create and attach a payment, then retry
@@ -17,6 +17,7 @@ export class SimplifiedFetchTransport implements Transport {
17
17
  fetchClient: typeof fetch
18
18
  baseUrl: string
19
19
 
20
+
20
21
  /**
21
22
  * Constructs a new instance of SimplifiedFetchTransport.
22
23
  * @param baseUrl - The base URL for all HTTP requests made by this transport.
@@ -53,11 +54,11 @@ export class SimplifiedFetchTransport implements Transport {
53
54
  body: JSON.stringify(message)
54
55
  })
55
56
 
57
+ // For initialRequest message, mark connection as established and start pool.
56
58
  if (message.messageType !== "initialRequest") {
57
59
  resolve()
58
60
  }
59
61
  const response = await responsePromise
60
-
61
62
  // Handle the response if data is received and callback is set
62
63
  if (response.ok && this.onDataCallback) {
63
64
  const responseMessage = await response.json()
@@ -126,7 +127,8 @@ export class SimplifiedFetchTransport implements Transport {
126
127
  })
127
128
 
128
129
  // Check for an acceptable status
129
- if (response.status === 500 && !response.headers.get('x-bsv-auth-request-id')) {
130
+ if (response.status === 500 && (response.headers.get('x-bsv-auth-request-id') == null &&
131
+ response.headers.get('x-bsv-auth-requested-certificates') == null)) {
130
132
  // Try parsing JSON error
131
133
  const errorInfo = await response.json()
132
134
  // Otherwise just throw whatever we got
@@ -135,7 +137,10 @@ export class SimplifiedFetchTransport implements Transport {
135
137
 
136
138
  const parsedBody = await response.arrayBuffer()
137
139
  const payloadWriter = new Utils.Writer()
138
- payloadWriter.write(Utils.toArray(response.headers.get('x-bsv-auth-request-id'), 'base64'))
140
+ if(response.headers.get('x-bsv-auth-request-id') != null)
141
+ {
142
+ payloadWriter.write(Utils.toArray(response.headers.get('x-bsv-auth-request-id'), 'base64'));
143
+ }
139
144
  payloadWriter.writeVarIntNum(response.status)
140
145
 
141
146
  // PARSE RESPONSE HEADERS FROM SERVER --------------------------------
@@ -6,3 +6,4 @@ export { default as Spend } from './Spend.js'
6
6
  export type { default as ScriptTemplateUnlock } from './ScriptTemplateUnlock.js'
7
7
  export type { default as ScriptTemplate } from './ScriptTemplate.js'
8
8
  export * from './templates/index.js'
9
+ export type { default as ScriptChunk } from './ScriptChunk.js'