jsgar 4.4.0 → 4.5.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/dist/gar.umd.js CHANGED
@@ -72,6 +72,7 @@
72
72
  this.serverKeyNameToId = new Map();
73
73
  this.localTopicMap = new Map();
74
74
  this.localKeyMap = new Map();
75
+ this.invalidatedKeyIds = new Set();
75
76
  this.recordMap = new Map();
76
77
 
77
78
  this.running = false;
@@ -137,6 +138,7 @@
137
138
  this.localKeyCounter = 1;
138
139
  this.localTopicMap.clear();
139
140
  this.localKeyMap.clear();
141
+ this.invalidatedKeyIds.clear();
140
142
 
141
143
  // Heartbeat grace period flags
142
144
  this._initialGracePeriod = false;
@@ -753,6 +755,8 @@
753
755
  if (!('name' in message.value)) message.value.name = null;
754
756
  }
755
757
  this.serverKeyIdToName.delete(keyId);
758
+ } else if (msgType === 'ClientIntroducedKeyInvalidated') {
759
+ this.invalidatedKeyIds.add(message.value.client_introduced_key_id);
756
760
  } else if (msgType === 'Heartbeat') {
757
761
  this.lastHeartbeatTime = Date.now() / 1000;
758
762
  if (this._initialGracePeriod) {
@@ -1138,6 +1142,11 @@
1138
1142
  * @returns {number} Local key ID
1139
1143
  */
1140
1144
  getAndPossiblyIntroduceKeyId(name, className = null, { forceWrite = false, noAcquire = false } = {}) {
1145
+ const existingId = this.localKeyMap.get(name);
1146
+ if (existingId !== undefined && this.invalidatedKeyIds.has(existingId)) {
1147
+ this.invalidatedKeyIds.delete(existingId);
1148
+ this.localKeyMap.delete(name);
1149
+ }
1141
1150
  if (!this.localKeyMap.has(name)) {
1142
1151
  const keyId = this.localKeyCounter++;
1143
1152
  this.localKeyMap.set(name, keyId);
package/gar.js CHANGED
@@ -66,6 +66,7 @@ class GARClient {
66
66
  this.serverKeyNameToId = new Map();
67
67
  this.localTopicMap = new Map();
68
68
  this.localKeyMap = new Map();
69
+ this.invalidatedKeyIds = new Set();
69
70
  this.recordMap = new Map();
70
71
 
71
72
  this.running = false;
@@ -131,6 +132,7 @@ class GARClient {
131
132
  this.localKeyCounter = 1;
132
133
  this.localTopicMap.clear();
133
134
  this.localKeyMap.clear();
135
+ this.invalidatedKeyIds.clear();
134
136
 
135
137
  // Heartbeat grace period flags
136
138
  this._initialGracePeriod = false;
@@ -747,6 +749,8 @@ class GARClient {
747
749
  if (!('name' in message.value)) message.value.name = null;
748
750
  }
749
751
  this.serverKeyIdToName.delete(keyId);
752
+ } else if (msgType === 'ClientIntroducedKeyInvalidated') {
753
+ this.invalidatedKeyIds.add(message.value.client_introduced_key_id);
750
754
  } else if (msgType === 'Heartbeat') {
751
755
  this.lastHeartbeatTime = Date.now() / 1000;
752
756
  if (this._initialGracePeriod) {
@@ -1132,6 +1136,11 @@ class GARClient {
1132
1136
  * @returns {number} Local key ID
1133
1137
  */
1134
1138
  getAndPossiblyIntroduceKeyId(name, className = null, { forceWrite = false, noAcquire = false } = {}) {
1139
+ const existingId = this.localKeyMap.get(name);
1140
+ if (existingId !== undefined && this.invalidatedKeyIds.has(existingId)) {
1141
+ this.invalidatedKeyIds.delete(existingId);
1142
+ this.localKeyMap.delete(name);
1143
+ }
1135
1144
  if (!this.localKeyMap.has(name)) {
1136
1145
  const keyId = this.localKeyCounter++;
1137
1146
  this.localKeyMap.set(name, keyId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgar",
3
- "version": "4.4.0",
3
+ "version": "4.5.1",
4
4
  "description": "A Javascript client for the GAR protocol",
5
5
  "type": "module",
6
6
  "main": "dist/gar.umd.js",