@canopy-io/node 0.1.1 → 0.2.0

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/index.js CHANGED
@@ -872,10 +872,30 @@ var LocalAuthorizer = class {
872
872
  return { ...this.stats };
873
873
  }
874
874
  /**
875
- * Drop everything held. Not needed in normal operation, where entries expire
876
- * on their own; useful in tests and after a known change.
875
+ * Drop what is held so the next evaluate refetches.
876
+ *
877
+ * With an `identityId`, only that identity's grants are dropped — the
878
+ * cached hierarchy and every other identity's entries stay warm. This is
879
+ * the shape an assignment webhook wants: the event names the identity
880
+ * whose authority moved, and nothing else needs to pay a refetch for it.
881
+ *
882
+ * With no argument, everything goes: grants and the hierarchy tree. Not
883
+ * needed in normal operation, where entries expire on their own; useful in
884
+ * tests and after a change whose reach you cannot name (a role's
885
+ * permissions edited, a node moved).
886
+ *
887
+ * Multi-instance honesty: an invalidation reaches THIS process only. A
888
+ * webhook lands on one instance behind a load balancer; the others serve
889
+ * their cached grants until their own TTL expires. Unless the app fans the
890
+ * event out over its own pub/sub, the fleet-wide revocation guarantee is
891
+ * the TTL, and webhook-driven invalidation is a latency optimization on
892
+ * top of it — size the TTL to the revocation latency you can promise.
877
893
  */
878
- invalidate() {
894
+ invalidate(identityId) {
895
+ if (identityId !== void 0) {
896
+ this.grants.delete(identityId);
897
+ return;
898
+ }
879
899
  this.grants.clear();
880
900
  this.tree = void 0;
881
901
  }