@extantape/payload-plugin-hats 0.6.0 → 0.6.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Linked accounts and role hats for Payload. One person links their accounts and switches between them, and an account with several roles acts in one at a time. Switching up into a sensitive role asks for a second factor.
4
4
 
5
- **Status:** early, 0.x. All 222 tests pass. The server ones run against a real Payload 3.92 and MongoDB, with made-up roles and a fake second factor. The redesigned switch has unit tests for its order, gating, button markup, code screen and focus targets, and was run in a browser at 390 and 1280 px wide on a local copy of a site with made-up accounts: keyboard open, Escape, the focus trap, Cancel back to the hat, a one-tap switch and the note after it (that browser run was before the button and note changes below, and wasn't repeated). A real authenticator code wasn't tried with the new switch; the server refused the made-up code, as it should. It isn't in use on any site yet.
5
+ **Status:** early, 0.x. All 836 tests pass. The server ones run against a real Payload 3.92 and MongoDB, with made-up roles and a fake second factor. The redesigned switch has unit tests for its order, gating, button markup, code screen and focus targets, and was run in a browser at 390 and 1280 px wide on a local copy of a site with made-up accounts: keyboard open, Escape, the focus trap, Cancel back to the hat, a one-tap switch and the note after it (that browser run was before the button and note changes below, and wasn't repeated). A real authenticator code wasn't tried with the new switch; the server refused the made-up code, as it should. It isn't in use on any site yet.
6
6
 
7
7
  ## What it does
8
8
 
package/dist/state.js CHANGED
@@ -50,11 +50,27 @@ export const ownHook = (fn) => {
50
50
  own.add(fn);
51
51
  return fn;
52
52
  };
53
+ /** Symbol key on a wrapper that points at the hook it wraps (the root original), so other plugins can tell their own hooks. */
54
+ const ORIGINAL = Symbol.for('extantape.hook.original');
55
+ const rootOf = (fn) => {
56
+ let h = fn;
57
+ const seen = new Set();
58
+ // Stops at the first repeat, so a marker that loops back on itself can't hang startup.
59
+ while (typeof h === 'function' && !seen.has(h)) {
60
+ seen.add(h);
61
+ const next = h[ORIGINAL];
62
+ if (typeof next !== 'function')
63
+ break;
64
+ h = next;
65
+ }
66
+ return h;
67
+ };
53
68
  function unmarkHook(fn) {
54
69
  if (typeof fn !== 'function' || own.has(fn) || plain.has(fn))
55
70
  return fn;
56
71
  const wrapped = (...args) => marks.exit(() => fn(...args));
57
72
  plain.add(wrapped);
73
+ wrapped[ORIGINAL] = rootOf(fn);
58
74
  return wrapped;
59
75
  }
60
76
  function unmarkHookLists(hooks) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extantape/payload-plugin-hats",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Linked accounts and role hats for Payload: one person switches between their approved accounts, and acts in one role at a time, with a second factor before switching up.",
5
5
  "keywords": [
6
6
  "payload",