@audius/sdk 0.0.13 → 0.0.14

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/types.d.ts CHANGED
@@ -9275,6 +9275,7 @@ declare class CreatorNode {
9275
9275
  passList: Set<string> | null;
9276
9276
  blockList: Set<string> | null;
9277
9277
  monitoringCallbacks: MonitoringCallbacks;
9278
+ writeQuorumEnabled: boolean;
9278
9279
  connected: boolean;
9279
9280
  connecting: boolean;
9280
9281
  authToken: null;
@@ -9290,8 +9291,9 @@ declare class CreatorNode {
9290
9291
  * @param passList whether or not to include only specified nodes (default null)
9291
9292
  * @param blockList whether or not to exclude any nodes (default null)
9292
9293
  * @param monitoringCallbacks callbacks to be invoked with metrics from requests sent to a service
9294
+ * @param writeQuorumEnabled whether or not to enforce waiting for replication to 2/3 nodes when writing data
9293
9295
  */
9294
- constructor(web3Manager: Web3Manager, creatorNodeEndpoint: string, isServer: boolean, userStateManager: UserStateManager, lazyConnect: boolean, schemas: Schemas, passList?: Set<string> | null, blockList?: Set<string> | null, monitoringCallbacks?: MonitoringCallbacks);
9296
+ constructor(web3Manager: Web3Manager, creatorNodeEndpoint: string, isServer: boolean, userStateManager: UserStateManager, lazyConnect: boolean, schemas: Schemas, passList?: Set<string> | null, blockList?: Set<string> | null, monitoringCallbacks?: MonitoringCallbacks, writeQuorumEnabled?: boolean);
9295
9297
  init(): Promise<void>;
9296
9298
  /** Establishes a connection to a content node endpoint */
9297
9299
  connect(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audius/sdk",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types.d.ts",
package/src/libs.js CHANGED
@@ -63,20 +63,23 @@ class AudiusLibs {
63
63
  * @param {object?} monitoringCallbacks callbacks to be invoked with metrics from requests sent to a service
64
64
  * @param {function} monitoringCallbacks.request
65
65
  * @param {function} monitoringCallbacks.healthCheck
66
+ * @param {boolean} writeQuorumEnabled whether or not to enforce waiting for replication to 2/3 nodes when writing data
66
67
  */
67
68
  static configCreatorNode (
68
69
  fallbackUrl,
69
70
  lazyConnect = false,
70
71
  passList = null,
71
72
  blockList = null,
72
- monitoringCallbacks = {}
73
+ monitoringCallbacks = {},
74
+ writeQuorumEnabled = false
73
75
  ) {
74
76
  return {
75
77
  fallbackUrl,
76
78
  lazyConnect,
77
79
  passList,
78
80
  blockList,
79
- monitoringCallbacks
81
+ monitoringCallbacks,
82
+ writeQuorumEnabled
80
83
  }
81
84
  }
82
85
 
@@ -515,7 +518,8 @@ class AudiusLibs {
515
518
  this.schemas,
516
519
  this.creatorNodeConfig.passList,
517
520
  this.creatorNodeConfig.blockList,
518
- this.creatorNodeConfig.monitoringCallbacks
521
+ this.creatorNodeConfig.monitoringCallbacks,
522
+ this.creatorNodeConfig.writeQuorumEnabled
519
523
  )
520
524
  await this.creatorNode.init()
521
525
  }
@@ -148,6 +148,7 @@ export class CreatorNode {
148
148
  passList: Set<string> | null
149
149
  blockList: Set<string> | null
150
150
  monitoringCallbacks: MonitoringCallbacks
151
+ writeQuorumEnabled: boolean
151
152
  connected: boolean
152
153
  connecting: boolean
153
154
  authToken: null
@@ -164,6 +165,7 @@ export class CreatorNode {
164
165
  * @param passList whether or not to include only specified nodes (default null)
165
166
  * @param blockList whether or not to exclude any nodes (default null)
166
167
  * @param monitoringCallbacks callbacks to be invoked with metrics from requests sent to a service
168
+ * @param writeQuorumEnabled whether or not to enforce waiting for replication to 2/3 nodes when writing data
167
169
  */
168
170
  constructor(
169
171
  web3Manager: Web3Manager,
@@ -174,7 +176,8 @@ export class CreatorNode {
174
176
  schemas: Schemas,
175
177
  passList: Set<string> | null = null,
176
178
  blockList: Set<string> | null = null,
177
- monitoringCallbacks: MonitoringCallbacks = {}
179
+ monitoringCallbacks: MonitoringCallbacks = {},
180
+ writeQuorumEnabled = false
178
181
  ) {
179
182
  this.web3Manager = web3Manager
180
183
  // This is just 1 endpoint (primary), unlike the creator_node_endpoint field in user metadata
@@ -192,6 +195,7 @@ export class CreatorNode {
192
195
  this.passList = passList
193
196
  this.blockList = blockList
194
197
  this.monitoringCallbacks = monitoringCallbacks
198
+ this.writeQuorumEnabled = writeQuorumEnabled
195
199
  }
196
200
 
197
201
  async init() {
@@ -765,6 +769,8 @@ export class CreatorNode {
765
769
 
766
770
  axiosRequestObj.headers = axiosRequestObj.headers || {}
767
771
 
772
+ axiosRequestObj.headers['Enforce-Write-Quorum'] = this.writeQuorumEnabled
773
+
768
774
  if (this.authToken) {
769
775
  axiosRequestObj.headers['X-Session-ID'] = this.authToken
770
776
  }