@versini/auth0-auth-js-stub 1.0.0 → 1.1.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
@@ -7,9 +7,14 @@ first-paint weight) and powers only the **MFA / Passkey / MyAccount / DPoP** API
7
7
  your app uses only basic Auth0 login (`loginWithRedirect`, `getAccessTokenSilently`,
8
8
  `logout`, `isAuthenticated`, `user`), that weight is dead code.
9
9
 
10
- This stub satisfies the symbols `@auth0/auth0-spa-js` imports at runtime. `AuthClient`
11
- constructs without throwing (it runs on every login), and any MFA/Passkey method call
12
- throws a clear, actionable error.
10
+ This stub satisfies the symbols `@auth0/auth0-spa-js` imports or re-exports at runtime.
11
+ `AuthClient` constructs without throwing (it runs on every login). Any MFA, Passkey, or
12
+ anonymous-session method call throws a clear, actionable error, and `isFederatedDomain`
13
+ returns a promise that rejects with one.
14
+
15
+ > ⚠️ Do not set `createAnonymousSessionOnFailedSilentAuth` with this stub. spa-js 2.27
16
+ > calls the anonymous client from `checkSession` when that option is on and swallows the
17
+ > stub's error in a `try/catch`, so the fallback silently does nothing.
13
18
 
14
19
  ## Usage
15
20
 
package/index.cjs CHANGED
@@ -17,10 +17,17 @@ class AuthClient {
17
17
  constructor(_options) {
18
18
  this.mfa = throwingClient('mfa');
19
19
  this.passkey = throwingClient('passkey');
20
+ this.anonymous = throwingClient('anonymous');
20
21
  }
21
22
  }
22
23
 
23
24
  class MfaClient {}
25
+ class AnonymousSessionClient {}
26
+
27
+ // Enterprise Connect domain discovery. spa-js wraps it in its own exported
28
+ // isFederatedDomain, which only the app calls. Async upstream, so reject
29
+ // rather than throw.
30
+ const isFederatedDomain = async (..._args) => notSupported('isFederatedDomain')();
24
31
 
25
32
  class StubError extends Error {
26
33
  constructor(code, message) {
@@ -65,14 +72,23 @@ class PasskeyGetTokenError extends StubError {
65
72
  this.name = 'PasskeyGetTokenError';
66
73
  }
67
74
  }
75
+ class AnonymousSessionError extends StubError {
76
+ constructor(c, m) {
77
+ super(c, m);
78
+ this.name = 'AnonymousSessionError';
79
+ }
80
+ }
68
81
 
69
82
  module.exports = {
70
83
  AuthClient,
71
84
  MfaClient,
85
+ AnonymousSessionClient,
86
+ isFederatedDomain,
72
87
  MfaListAuthenticatorsError,
73
88
  MfaEnrollmentError,
74
89
  MfaChallengeError,
75
90
  PasskeyRegisterError,
76
91
  PasskeyChallengeError,
77
- PasskeyGetTokenError
92
+ PasskeyGetTokenError,
93
+ AnonymousSessionError
78
94
  };
package/index.d.ts CHANGED
@@ -1,14 +1,23 @@
1
1
  // Type stub for @auth0/auth0-auth-js — permissive shapes for the symbols the
2
- // @auth0/auth0-spa-js typings reference. MFA/Passkey are not used in this app.
2
+ // @auth0/auth0-spa-js typings reference. MFA/Passkey/anonymous sessions and
3
+ // Enterprise Connect domain discovery are not used in this app.
3
4
 
4
5
  export declare class AuthClient {
5
6
  constructor(options?: unknown);
6
7
  mfa: any;
7
8
  passkey: any;
9
+ anonymous: any;
8
10
  }
9
11
 
10
12
  export declare class MfaClient {}
11
13
  export declare class PasskeyClient {}
14
+ export declare class AnonymousSessionClient {}
15
+
16
+ export declare function isFederatedDomain(
17
+ auth0Domain: string,
18
+ emailDomain: string,
19
+ options?: unknown
20
+ ): Promise<boolean>;
12
21
 
13
22
  export declare class MfaListAuthenticatorsError extends Error {
14
23
  code?: string;
@@ -28,6 +37,9 @@ export declare class PasskeyChallengeError extends Error {
28
37
  export declare class PasskeyGetTokenError extends Error {
29
38
  code?: string;
30
39
  }
40
+ export declare class AnonymousSessionError extends Error {
41
+ code?: string;
42
+ }
31
43
 
32
44
  export type MfaApiErrorResponse = any;
33
45
  export type PasskeyCreationOptions = any;
@@ -37,3 +49,9 @@ export type PasskeyLoginChallengeResponse = any;
37
49
  export type PasskeyRequestOptions = any;
38
50
  export type PasskeySignupChallengeOptions = any;
39
51
  export type PasskeySignupChallengeResponse = any;
52
+ export type AnonymousSession = any;
53
+ export type AnonymousSessionClaims = any;
54
+ export type AnonymousSessionErrorCode = any;
55
+ export type CreateAnonymousSessionOptions = any;
56
+ export type GetAnonymousAccessTokenOptions = any;
57
+ export type IsFederatedDomainOptions = any;
package/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  // Featherweight stub of @auth0/auth0-auth-js (ESM).
2
2
  //
3
- // This app does not use Auth0 MFA or Passkey flows. The real package pulls in
3
+ // This app does not use Auth0 MFA, Passkey, anonymous-session or Enterprise
4
+ // Connect domain-discovery flows. The real package pulls in
4
5
  // openid-client + oauth4webapi + jose (~26KB gzip of first-paint weight). It is
5
6
  // swapped for this stub via pnpm overrides so that weight never ships.
6
7
  //
7
8
  // The forked @auth0/auth0-spa-js build (external: ['@auth0/auth0-auth-js'])
8
- // statically imports exactly these symbols; this stub satisfies them at runtime.
9
+ // statically imports or re-exports exactly these symbols; this stub satisfies
10
+ // them at runtime.
9
11
  // `new AuthClient()` runs on every Auth0Client construction, so it must not throw
10
- // — only the (unused) MFA/Passkey method calls do.
12
+ // — only the (unused) MFA/Passkey/anonymous-session method calls do.
11
13
 
12
14
  const notSupported = feature => () => {
13
15
  throw new Error(
@@ -26,10 +28,17 @@ export class AuthClient {
26
28
  constructor(_options) {
27
29
  this.mfa = throwingClient('mfa');
28
30
  this.passkey = throwingClient('passkey');
31
+ this.anonymous = throwingClient('anonymous');
29
32
  }
30
33
  }
31
34
 
32
35
  export class MfaClient {}
36
+ export class AnonymousSessionClient {}
37
+
38
+ // Enterprise Connect domain discovery. spa-js wraps it in its own exported
39
+ // isFederatedDomain, which only the app calls. Async upstream, so reject
40
+ // rather than throw.
41
+ export const isFederatedDomain = async (..._args) => notSupported('isFederatedDomain')();
33
42
 
34
43
  class StubError extends Error {
35
44
  constructor(code, message) {
@@ -74,3 +83,9 @@ export class PasskeyGetTokenError extends StubError {
74
83
  this.name = 'PasskeyGetTokenError';
75
84
  }
76
85
  }
86
+ export class AnonymousSessionError extends StubError {
87
+ constructor(c, m) {
88
+ super(c, m);
89
+ this.name = 'AnonymousSessionError';
90
+ }
91
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@versini/auth0-auth-js-stub",
3
- "version": "1.0.0",
4
- "description": "Featherweight no-op stub of @auth0/auth0-auth-js for apps that use only basic Auth0 login (no MFA/Passkey/MyAccount/DPoP). Consumed via a pnpm `npm:` alias override to drop ~26KB gzip (openid-client + oauth4webapi + jose) from first paint. See @versini/auth0-thin.",
3
+ "version": "1.1.0",
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",
7
7
  "module": "./index.js",