@versini/auth0-auth-js-stub 1.0.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/LICENSE +28 -0
- package/README.md +34 -0
- package/index.cjs +78 -0
- package/index.d.ts +39 -0
- package/index.js +76 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arno V
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
----------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
The published @versini/auth0-react-thin and @versini/auth0-spa-js-no-authjs
|
|
26
|
+
packages are builds of Auth0's @auth0/auth0-react and @auth0/auth0-spa-js
|
|
27
|
+
(also MIT, Copyright (c) Auth0, Inc.), modified only by a one-line Rollup
|
|
28
|
+
`external` change. Their published tarballs carry Auth0's original LICENSE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @versini/auth0-auth-js-stub
|
|
2
|
+
|
|
3
|
+
A featherweight, no-op stub of [`@auth0/auth0-auth-js`](https://www.npmjs.com/package/@auth0/auth0-auth-js).
|
|
4
|
+
|
|
5
|
+
The real package pulls in `openid-client` + `oauth4webapi` + `jose` (~26 KB gzip of
|
|
6
|
+
first-paint weight) and powers only the **MFA / Passkey / MyAccount / DPoP** APIs. If
|
|
7
|
+
your app uses only basic Auth0 login (`loginWithRedirect`, `getAccessTokenSilently`,
|
|
8
|
+
`logout`, `isAuthenticated`, `user`), that weight is dead code.
|
|
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.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Don't depend on this directly. It is installed in place of `@auth0/auth0-auth-js` via a
|
|
17
|
+
pnpm `npm:` alias override, together with the slimmed `@auth0/auth0-react` and
|
|
18
|
+
`@auth0/auth0-spa-js` forks. See **[@versini/auth0-thin](https://www.npmjs.com/package/@versini/auth0-thin)**
|
|
19
|
+
for the full setup and the CI verifier.
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
# pnpm-workspace.yaml
|
|
23
|
+
overrides:
|
|
24
|
+
"@auth0/auth0-react": "npm:@versini/auth0-react-thin@<version>"
|
|
25
|
+
"@auth0/auth0-spa-js": "npm:@versini/auth0-spa-js-no-authjs@<version>"
|
|
26
|
+
"@auth0/auth0-auth-js": "npm:@versini/auth0-auth-js-stub@<version>"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> ⚠️ Only safe if your app never uses Auth0 MFA, Passkey, MyAccount, or DPoP. Run
|
|
30
|
+
> `npx auth0-thin verify` in CI to enforce that the assumption still holds.
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT. This stub is original code; it contains no Auth0 source.
|
package/index.cjs
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Featherweight stub of @auth0/auth0-auth-js (CommonJS). See index.js for rationale.
|
|
2
|
+
|
|
3
|
+
const notSupported = feature => () => {
|
|
4
|
+
throw new Error(
|
|
5
|
+
`@auth0/auth0-auth-js is stubbed in this app; "${feature}" is unavailable. ` +
|
|
6
|
+
`Remove the pnpm override for @auth0/auth0-auth-js (and the spa-js fork) to restore it.`
|
|
7
|
+
);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const throwingClient = label =>
|
|
11
|
+
new Proxy(
|
|
12
|
+
{},
|
|
13
|
+
{ get: (_t, prop) => notSupported(`${label}.${String(prop)}`) }
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
class AuthClient {
|
|
17
|
+
constructor(_options) {
|
|
18
|
+
this.mfa = throwingClient('mfa');
|
|
19
|
+
this.passkey = throwingClient('passkey');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class MfaClient {}
|
|
24
|
+
|
|
25
|
+
class StubError extends Error {
|
|
26
|
+
constructor(code, message) {
|
|
27
|
+
super(message ?? code);
|
|
28
|
+
this.code = code;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
class MfaListAuthenticatorsError extends StubError {
|
|
33
|
+
constructor(c, m) {
|
|
34
|
+
super(c, m);
|
|
35
|
+
this.name = 'MfaListAuthenticatorsError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
class MfaEnrollmentError extends StubError {
|
|
39
|
+
constructor(c, m) {
|
|
40
|
+
super(c, m);
|
|
41
|
+
this.name = 'MfaEnrollmentError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class MfaChallengeError extends StubError {
|
|
45
|
+
constructor(c, m) {
|
|
46
|
+
super(c, m);
|
|
47
|
+
this.name = 'MfaChallengeError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class PasskeyRegisterError extends StubError {
|
|
51
|
+
constructor(c, m) {
|
|
52
|
+
super(c, m);
|
|
53
|
+
this.name = 'PasskeyRegisterError';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class PasskeyChallengeError extends StubError {
|
|
57
|
+
constructor(c, m) {
|
|
58
|
+
super(c, m);
|
|
59
|
+
this.name = 'PasskeyChallengeError';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class PasskeyGetTokenError extends StubError {
|
|
63
|
+
constructor(c, m) {
|
|
64
|
+
super(c, m);
|
|
65
|
+
this.name = 'PasskeyGetTokenError';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = {
|
|
70
|
+
AuthClient,
|
|
71
|
+
MfaClient,
|
|
72
|
+
MfaListAuthenticatorsError,
|
|
73
|
+
MfaEnrollmentError,
|
|
74
|
+
MfaChallengeError,
|
|
75
|
+
PasskeyRegisterError,
|
|
76
|
+
PasskeyChallengeError,
|
|
77
|
+
PasskeyGetTokenError
|
|
78
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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.
|
|
3
|
+
|
|
4
|
+
export declare class AuthClient {
|
|
5
|
+
constructor(options?: unknown);
|
|
6
|
+
mfa: any;
|
|
7
|
+
passkey: any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare class MfaClient {}
|
|
11
|
+
export declare class PasskeyClient {}
|
|
12
|
+
|
|
13
|
+
export declare class MfaListAuthenticatorsError extends Error {
|
|
14
|
+
code?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class MfaEnrollmentError extends Error {
|
|
17
|
+
code?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class MfaChallengeError extends Error {
|
|
20
|
+
code?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class PasskeyRegisterError extends Error {
|
|
23
|
+
code?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class PasskeyChallengeError extends Error {
|
|
26
|
+
code?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class PasskeyGetTokenError extends Error {
|
|
29
|
+
code?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type MfaApiErrorResponse = any;
|
|
33
|
+
export type PasskeyCreationOptions = any;
|
|
34
|
+
export type PasskeyCredentialResponse = any;
|
|
35
|
+
export type PasskeyLoginChallengeOptions = any;
|
|
36
|
+
export type PasskeyLoginChallengeResponse = any;
|
|
37
|
+
export type PasskeyRequestOptions = any;
|
|
38
|
+
export type PasskeySignupChallengeOptions = any;
|
|
39
|
+
export type PasskeySignupChallengeResponse = any;
|
package/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Featherweight stub of @auth0/auth0-auth-js (ESM).
|
|
2
|
+
//
|
|
3
|
+
// This app does not use Auth0 MFA or Passkey flows. The real package pulls in
|
|
4
|
+
// openid-client + oauth4webapi + jose (~26KB gzip of first-paint weight). It is
|
|
5
|
+
// swapped for this stub via pnpm overrides so that weight never ships.
|
|
6
|
+
//
|
|
7
|
+
// 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
|
+
// `new AuthClient()` runs on every Auth0Client construction, so it must not throw
|
|
10
|
+
// — only the (unused) MFA/Passkey method calls do.
|
|
11
|
+
|
|
12
|
+
const notSupported = feature => () => {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`@auth0/auth0-auth-js is stubbed in this app; "${feature}" is unavailable. ` +
|
|
15
|
+
`Remove the pnpm override for @auth0/auth0-auth-js (and the spa-js fork) to restore it.`
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const throwingClient = label =>
|
|
20
|
+
new Proxy(
|
|
21
|
+
{},
|
|
22
|
+
{ get: (_t, prop) => notSupported(`${label}.${String(prop)}`) }
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export class AuthClient {
|
|
26
|
+
constructor(_options) {
|
|
27
|
+
this.mfa = throwingClient('mfa');
|
|
28
|
+
this.passkey = throwingClient('passkey');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class MfaClient {}
|
|
33
|
+
|
|
34
|
+
class StubError extends Error {
|
|
35
|
+
constructor(code, message) {
|
|
36
|
+
super(message ?? code);
|
|
37
|
+
this.code = code;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class MfaListAuthenticatorsError extends StubError {
|
|
42
|
+
constructor(c, m) {
|
|
43
|
+
super(c, m);
|
|
44
|
+
this.name = 'MfaListAuthenticatorsError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class MfaEnrollmentError extends StubError {
|
|
48
|
+
constructor(c, m) {
|
|
49
|
+
super(c, m);
|
|
50
|
+
this.name = 'MfaEnrollmentError';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export class MfaChallengeError extends StubError {
|
|
54
|
+
constructor(c, m) {
|
|
55
|
+
super(c, m);
|
|
56
|
+
this.name = 'MfaChallengeError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export class PasskeyRegisterError extends StubError {
|
|
60
|
+
constructor(c, m) {
|
|
61
|
+
super(c, m);
|
|
62
|
+
this.name = 'PasskeyRegisterError';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export class PasskeyChallengeError extends StubError {
|
|
66
|
+
constructor(c, m) {
|
|
67
|
+
super(c, m);
|
|
68
|
+
this.name = 'PasskeyChallengeError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export class PasskeyGetTokenError extends StubError {
|
|
72
|
+
constructor(c, m) {
|
|
73
|
+
super(c, m);
|
|
74
|
+
this.name = 'PasskeyGetTokenError';
|
|
75
|
+
}
|
|
76
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
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.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.cjs",
|
|
7
|
+
"module": "./index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"import": "./index.js",
|
|
13
|
+
"require": "./index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"index.js",
|
|
19
|
+
"index.cjs",
|
|
20
|
+
"index.d.ts"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"keywords": [
|
|
24
|
+
"auth0",
|
|
25
|
+
"auth0-auth-js",
|
|
26
|
+
"stub",
|
|
27
|
+
"bundle-size",
|
|
28
|
+
"tree-shaking"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/versini-org/auth0-thin.git",
|
|
33
|
+
"directory": "packages/auth0-auth-js-stub"
|
|
34
|
+
},
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
39
|
+
}
|