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