@versini/auth0-auth-js-stub 1.1.0 → 1.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/README.md CHANGED
@@ -10,7 +10,9 @@ your app uses only basic Auth0 login (`loginWithRedirect`, `getAccessTokenSilent
10
10
  This stub satisfies the symbols `@auth0/auth0-spa-js` imports or re-exports at runtime.
11
11
  `AuthClient` constructs without throwing (it runs on every login). Any MFA, Passkey, or
12
12
  anonymous-session method call throws a clear, actionable error, and `isFederatedDomain`
13
- returns a promise that rejects with one.
13
+ returns a promise that rejects with one. The exception is `anonymous.mintTransferToken`:
14
+ it resolves `null`. spa-js 2.28 calls it at login whenever a stored anonymous session token
15
+ exists (one left by an earlier non-thin deployment), and the stub never has a session to link.
14
16
 
15
17
  > ⚠️ Do not set `createAnonymousSessionOnFailedSilentAuth` with this stub. spa-js 2.27
16
18
  > calls the anonymous client from `checkSession` when that option is on and swallows the
package/index.cjs CHANGED
@@ -7,17 +7,28 @@ const notSupported = feature => () => {
7
7
  );
8
8
  };
9
9
 
10
- const throwingClient = label =>
10
+ // `methods` are the few sub-client calls spa-js makes on a core path; every
11
+ // other property is a throwing function.
12
+ const throwingClient = (label, methods = {}) =>
11
13
  new Proxy(
12
14
  {},
13
- { get: (_t, prop) => notSupported(`${label}.${String(prop)}`) }
15
+ {
16
+ get: (_t, prop) =>
17
+ Object.prototype.hasOwnProperty.call(methods, prop)
18
+ ? methods[prop]
19
+ : notSupported(`${label}.${String(prop)}`)
20
+ }
14
21
  );
15
22
 
16
23
  class AuthClient {
17
24
  constructor(_options) {
18
25
  this.mfa = throwingClient('mfa');
19
26
  this.passkey = throwingClient('passkey');
20
- this.anonymous = throwingClient('anonymous');
27
+ // On every login spa-js 2.28 asks its anonymous wrapper for a transfer token,
28
+ // and the wrapper calls this whenever a stored anonymous session token exists
29
+ // (one left by an earlier non-thin deployment). This stub can never create
30
+ // such a session, so there is nothing to link: resolve null, never throw.
31
+ this.anonymous = throwingClient('anonymous', { mintTransferToken: async () => null });
21
32
  }
22
33
  }
23
34
 
package/index.js CHANGED
@@ -18,17 +18,28 @@ const notSupported = feature => () => {
18
18
  );
19
19
  };
20
20
 
21
- const throwingClient = label =>
21
+ // `methods` are the few sub-client calls spa-js makes on a core path; every
22
+ // other property is a throwing function.
23
+ const throwingClient = (label, methods = {}) =>
22
24
  new Proxy(
23
25
  {},
24
- { get: (_t, prop) => notSupported(`${label}.${String(prop)}`) }
26
+ {
27
+ get: (_t, prop) =>
28
+ Object.prototype.hasOwnProperty.call(methods, prop)
29
+ ? methods[prop]
30
+ : notSupported(`${label}.${String(prop)}`)
31
+ }
25
32
  );
26
33
 
27
34
  export class AuthClient {
28
35
  constructor(_options) {
29
36
  this.mfa = throwingClient('mfa');
30
37
  this.passkey = throwingClient('passkey');
31
- this.anonymous = throwingClient('anonymous');
38
+ // On every login spa-js 2.28 asks its anonymous wrapper for a transfer token,
39
+ // and the wrapper calls this whenever a stored anonymous session token exists
40
+ // (one left by an earlier non-thin deployment). This stub can never create
41
+ // such a session, so there is nothing to link: resolve null, never throw.
42
+ this.anonymous = throwingClient('anonymous', { mintTransferToken: async () => null });
32
43
  }
33
44
  }
34
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/auth0-auth-js-stub",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Featherweight no-op stub of @auth0/auth0-auth-js for apps that use only basic Auth0 login (no MFA/Passkey/anonymous sessions/MyAccount/DPoP). Consumed via a pnpm `npm:` alias override to drop ~26KB gzip (openid-client + oauth4webapi + jose) from first paint. See @versini/auth0-thin.",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",