jsgar 4.5.0 → 4.5.2

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
  this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
77
78
 
@@ -138,6 +139,7 @@
138
139
  this.localKeyCounter = 1;
139
140
  this.localTopicMap.clear();
140
141
  this.localKeyMap.clear();
142
+ this.invalidatedKeyIds.clear();
141
143
 
142
144
  // Active ownership state
143
145
  this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
@@ -757,6 +759,8 @@
757
759
  if (!('name' in message.value)) message.value.name = null;
758
760
  }
759
761
  this.serverKeyIdToName.delete(keyId);
762
+ } else if (msgType === 'ClientIntroducedKeyInvalidated') {
763
+ this.invalidatedKeyIds.add(message.value.client_introduced_key_id);
760
764
  } else if (msgType === 'Heartbeat') {
761
765
  this.lastHeartbeatTime = Date.now() / 1000;
762
766
  if (this._initialGracePeriod) {
@@ -1159,6 +1163,11 @@
1159
1163
  * @returns {number} Local key ID
1160
1164
  */
1161
1165
  getAndPossiblyIntroduceKeyId(name, className = null) {
1166
+ const existingId = this.localKeyMap.get(name);
1167
+ if (existingId !== undefined && this.invalidatedKeyIds.has(existingId)) {
1168
+ this.invalidatedKeyIds.delete(existingId);
1169
+ this.localKeyMap.delete(name);
1170
+ }
1162
1171
  if (!this.localKeyMap.has(name)) {
1163
1172
  const keyId = this.localKeyCounter++;
1164
1173
  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
  this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
71
72
 
@@ -132,6 +133,7 @@ class GARClient {
132
133
  this.localKeyCounter = 1;
133
134
  this.localTopicMap.clear();
134
135
  this.localKeyMap.clear();
136
+ this.invalidatedKeyIds.clear();
135
137
 
136
138
  // Active ownership state
137
139
  this._activeOwnership = { msg_ref: 0, ownership_action: 'None', skip_ownership_checks: false, client_key_id: 0 };
@@ -751,6 +753,8 @@ class GARClient {
751
753
  if (!('name' in message.value)) message.value.name = null;
752
754
  }
753
755
  this.serverKeyIdToName.delete(keyId);
756
+ } else if (msgType === 'ClientIntroducedKeyInvalidated') {
757
+ this.invalidatedKeyIds.add(message.value.client_introduced_key_id);
754
758
  } else if (msgType === 'Heartbeat') {
755
759
  this.lastHeartbeatTime = Date.now() / 1000;
756
760
  if (this._initialGracePeriod) {
@@ -1153,6 +1157,11 @@ class GARClient {
1153
1157
  * @returns {number} Local key ID
1154
1158
  */
1155
1159
  getAndPossiblyIntroduceKeyId(name, className = null) {
1160
+ const existingId = this.localKeyMap.get(name);
1161
+ if (existingId !== undefined && this.invalidatedKeyIds.has(existingId)) {
1162
+ this.invalidatedKeyIds.delete(existingId);
1163
+ this.localKeyMap.delete(name);
1164
+ }
1156
1165
  if (!this.localKeyMap.has(name)) {
1157
1166
  const keyId = this.localKeyCounter++;
1158
1167
  this.localKeyMap.set(name, keyId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsgar",
3
- "version": "4.5.0",
3
+ "version": "4.5.2",
4
4
  "description": "A Javascript client for the GAR protocol",
5
5
  "type": "module",
6
6
  "main": "dist/gar.umd.js",