@authowl/core 0.10.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 +21 -0
- package/README.md +231 -0
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/dist/chunk-KPXCQZUX.js +2 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +1282 -0
- package/dist/index.d.ts +1282 -0
- package/dist/index.js +3 -0
- package/dist/server.cjs +2 -0
- package/dist/server.d.cts +2757 -0
- package/dist/server.d.ts +2757 -0
- package/dist/server.js +1 -0
- package/dist/transport-BObDKlIh.d.cts +131 -0
- package/dist/transport-BObDKlIh.d.ts +131 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AuthOwl
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# @authowl/core
|
|
2
|
+
|
|
3
|
+
Framework-agnostic client for [AuthOwl](https://authowl.dev), the multi-tenant
|
|
4
|
+
auth service. Validates publishable keys, enforces HTTPS off localhost, and
|
|
5
|
+
exposes typed errors. Most apps use [`@authowl/react`](https://www.npmjs.com/package/@authowl/react)
|
|
6
|
+
or [`@authowl/next`](https://www.npmjs.com/package/@authowl/next) instead of this
|
|
7
|
+
directly.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @authowl/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Framework-neutral session state
|
|
14
|
+
|
|
15
|
+
Core has no React dependency. It exposes a standard external store for custom
|
|
16
|
+
framework bindings and headless clients:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const unsubscribe = authowl.sessionStore.subscribe(() => {
|
|
20
|
+
const session = authowl.sessionStore.getSnapshot();
|
|
21
|
+
renderSession(session);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const initial = authowl.sessionStore.getSnapshot();
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
React applications should use `useSession()` from `@authowl/react`, which binds
|
|
28
|
+
this store with React's external-store API and remains safe during SSR.
|
|
29
|
+
|
|
30
|
+
## Generated server-only Admin API client
|
|
31
|
+
|
|
32
|
+
The `@authowl/core/server` entrypoint accepts a **secret key** (`sk_live_…`) for
|
|
33
|
+
server-side admin calls. It refuses to run in a browser. Never import it from
|
|
34
|
+
client code.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { createAdminClient } from '@authowl/core/server';
|
|
38
|
+
|
|
39
|
+
const admin = createAdminClient({
|
|
40
|
+
secretKey: process.env.AUTHOWL_SECRET_KEY!,
|
|
41
|
+
apiUrl: 'https://auth.yourdomain.com',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const users = await admin.listUsers({ query: { limit: 50 } });
|
|
45
|
+
const user = await admin.getUser({ path: { userId: 'user_123' } });
|
|
46
|
+
await admin.updateUser({
|
|
47
|
+
path: { userId: user.id },
|
|
48
|
+
body: { name: 'Mona' },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await admin.updateUserMetadata({
|
|
52
|
+
path: { userId: user.id },
|
|
53
|
+
body: {
|
|
54
|
+
expected_version: user.metadata_version,
|
|
55
|
+
public_metadata: { locale: 'ar' },
|
|
56
|
+
private_metadata: { billingTier: 'pro' },
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Publishable keys (`pk_test_…` in development, `pk_live_…` in production) are
|
|
62
|
+
safe to embed in client code; secret keys (`sk_test_…` / `sk_live_…`) are bearer
|
|
63
|
+
credentials and must stay server-side.
|
|
64
|
+
|
|
65
|
+
The operation names, path/query/body inputs, and result types are generated from
|
|
66
|
+
AuthOwl's versioned OpenAPI contract. Failed API responses throw
|
|
67
|
+
`AuthOwlAdminApiError`, which exposes `status`, `code`, `requestId`, `problem`,
|
|
68
|
+
and `retryAfter`. Network and response-contract failures throw
|
|
69
|
+
`AuthOwlAdminNetworkError` with a stable `kind` (`aborted`, `timeout`,
|
|
70
|
+
`network`, `response_too_large`, or `invalid_response`).
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { AuthOwlAdminApiError } from '@authowl/core/server';
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
await admin.getUser({ path: { userId: 'missing' } });
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error instanceof AuthOwlAdminApiError && error.code === 'NOT_FOUND') {
|
|
79
|
+
// Cross-project and missing resources both intentionally appear as 404.
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
See the full [Admin API reference](https://github.com/mstfash/authowl-sdk/blob/main/docs/admin-api.md)
|
|
85
|
+
and [webhook signature guide](https://github.com/mstfash/authowl-sdk/blob/main/docs/webhooks.md).
|
|
86
|
+
Webhook receivers import `verifyWebhook` from `@authowl/core/server`; it works
|
|
87
|
+
in Node and worker Web Crypto runtimes.
|
|
88
|
+
|
|
89
|
+
## Stateless backend token verification
|
|
90
|
+
|
|
91
|
+
Import verification from the server-only subpath. The derived form validates
|
|
92
|
+
the publishable key and API origin, then derives the exact AuthOwl issuer,
|
|
93
|
+
audience, and JWKS route:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { verifyToken } from '@authowl/core/server';
|
|
97
|
+
|
|
98
|
+
const identity = await verifyToken(bearerToken, {
|
|
99
|
+
publishableKey: process.env.AUTHOWL_PUBLISHABLE_KEY!,
|
|
100
|
+
apiUrl: process.env.AUTHOWL_API_URL!,
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
A fully custom deployment may instead pass all three explicit values:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
const identity = await verifyToken(bearerToken, {
|
|
108
|
+
issuer: 'https://issuer.example.com/custom',
|
|
109
|
+
jwksUri: 'https://keys.example.net/v1/jwks',
|
|
110
|
+
audience: 'my-application',
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Do not mix the two forms or provide only part of one form. URLs must be
|
|
115
|
+
canonical absolute HTTPS URLs without credentials, query strings, fragments,
|
|
116
|
+
or encoded paths. A `pk_test_` key may use HTTP only on exact loopback
|
|
117
|
+
development hosts (`localhost`, `*.localhost`, `127.0.0.1`, or `[::1]`);
|
|
118
|
+
`pk_live_` always requires HTTPS.
|
|
119
|
+
|
|
120
|
+
Verification accepts only app-shaped ES256 public keys. JWKS requests refuse
|
|
121
|
+
redirects, abort after five seconds, stream at most 64 KiB, and accept at most
|
|
122
|
+
64 unique keys. Failures throw `TokenVerificationError` with a stable typed
|
|
123
|
+
`code`; authorization helpers `has()` and `hasPermission()` continue to fail
|
|
124
|
+
closed for token failures while surfacing configuration failures.
|
|
125
|
+
|
|
126
|
+
## Headless account and organization management
|
|
127
|
+
|
|
128
|
+
Use the AuthOwl-owned `account` and `organization` namespaces when you are
|
|
129
|
+
building custom UI. Their public types do not depend on the underlying auth
|
|
130
|
+
engine.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { createAuthOwlClient, getPublicConfig, resolveConfig } from '@authowl/core';
|
|
134
|
+
|
|
135
|
+
const config = resolveConfig({ publishableKey, apiUrl });
|
|
136
|
+
const authowl = createAuthOwlClient(config);
|
|
137
|
+
const capabilities = await getPublicConfig(config);
|
|
138
|
+
|
|
139
|
+
await authowl.account.updateProfile({ name: 'Mona' });
|
|
140
|
+
const sessions = await authowl.account.listSessions();
|
|
141
|
+
const otherSession = sessions.data?.[0];
|
|
142
|
+
if (otherSession) {
|
|
143
|
+
await authowl.account.revokeSession({ sessionId: otherSession.id });
|
|
144
|
+
}
|
|
145
|
+
const metadata = await authowl.account.getMetadata();
|
|
146
|
+
if (metadata.data) {
|
|
147
|
+
await authowl.account.updateUnsafeMetadata({
|
|
148
|
+
expectedVersion: metadata.data.metadataVersion,
|
|
149
|
+
unsafeMetadata: { onboarding: { step: 2 } },
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (capabilities.organizations) {
|
|
154
|
+
const organizations = await authowl.organization.list();
|
|
155
|
+
const firstOrganization = organizations.data?.[0];
|
|
156
|
+
if (firstOrganization) {
|
|
157
|
+
await authowl.organization.setActive({ organizationId: firstOrganization.id });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (capabilities.userModel?.accountDeletion ?? capabilities.accountDeletion) {
|
|
162
|
+
await authowl.account.delete();
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The additive `authentication`, `emailVerification`, `userModel`, and `mfa`
|
|
167
|
+
objects distinguish sign-in capability from account or credential creation.
|
|
168
|
+
For example, a custom UI may call `authowl.signIn.username(...)` only when
|
|
169
|
+
`capabilities.authentication?.username.signIn` is true, and may offer passkey
|
|
170
|
+
registration only when `capabilities.authentication?.passkey.add` is true.
|
|
171
|
+
|
|
172
|
+
Sensitive mutations can return `SESSION_NOT_FRESH` with HTTP 403. Ask the user
|
|
173
|
+
to sign in again and retry the action. Organization ownership conflicts return
|
|
174
|
+
`ORGANIZATION_LAST_OWNER`. Disabled and cross-project resources return 404.
|
|
175
|
+
Public metadata is server-authored. Unsafe metadata is end-user-owned and must
|
|
176
|
+
be treated as untrusted. Private metadata has no browser SDK surface.
|
|
177
|
+
Durable browser session tokens stay in HttpOnly cookies and never appear in
|
|
178
|
+
`@authowl/react`'s `useSession()`, action results, or `listSessions()`. Core
|
|
179
|
+
exposes only the framework-neutral `client.sessionStore`. Session management uses
|
|
180
|
+
stable session ids. This is distinct from `getToken()`, which intentionally
|
|
181
|
+
mints a short-lived backend JWT and caches it in memory only.
|
|
182
|
+
|
|
183
|
+
## Protected public-auth actions
|
|
184
|
+
|
|
185
|
+
When broad bot protection is enabled, obtain a fresh Turnstile token with the
|
|
186
|
+
endpoint's exact action and pass it through `authChallengeToken`. The SDK sends
|
|
187
|
+
the token only in `x-authowl-turnstile-token`; it never adds it to the JSON body.
|
|
188
|
+
Tokens are single-use, so mint a new token for every attempt, including retries.
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
await authowl.signIn.email(
|
|
192
|
+
{ email, password },
|
|
193
|
+
{ authChallengeToken: turnstileToken },
|
|
194
|
+
);
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
| Client action | Turnstile action |
|
|
198
|
+
| --- | --- |
|
|
199
|
+
| `signUp.email` | `auth_signup` |
|
|
200
|
+
| `signIn.email` | `auth_signin` |
|
|
201
|
+
| `signIn.magicLink`, `emailOtp.sendVerificationOtp` | `auth_passwordless` |
|
|
202
|
+
| `requestPasswordReset` | `auth_reset` |
|
|
203
|
+
| `sendVerificationEmail` | `auth_verify_email` |
|
|
204
|
+
|
|
205
|
+
Drop-in React components read the public site key and manage this lifecycle
|
|
206
|
+
automatically. Headless clients must still render Turnstile and bind the exact
|
|
207
|
+
action themselves.
|
|
208
|
+
|
|
209
|
+
## Named backend JWTs
|
|
210
|
+
|
|
211
|
+
Create a named template in the AuthOwl dashboard, then mint it from the signed-in
|
|
212
|
+
browser session:
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
const token = await authowl.getToken({ template: 'supabase' });
|
|
216
|
+
const freshToken = await authowl.getToken({
|
|
217
|
+
template: 'supabase',
|
|
218
|
+
forceRefresh: true,
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Template names are normalized to lowercase. Tokens stay memory-only and are
|
|
223
|
+
cached separately by environment, user, active organization, template, and
|
|
224
|
+
server policy version. A forced refresh bypasses only the selected template.
|
|
225
|
+
Plain `getToken()` keeps the original unnamed-token contract.
|
|
226
|
+
|
|
227
|
+
See the full integration guide in the AuthOwl app repo (`INTEGRATION.md`).
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
`@authowl/core` bundles third-party components into its published `dist/`. Each
|
|
4
|
+
is redistributed under its own license, with the required copyright and
|
|
5
|
+
permission notices reproduced in full below, grouped by copyright holder. This
|
|
6
|
+
file is generated by `scripts/gen-notices.mjs`; do not edit by hand.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Matthew Miller
|
|
11
|
+
|
|
12
|
+
License: MIT
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
MIT License
|
|
16
|
+
|
|
17
|
+
Copyright (c) 2020 Matthew Miller
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
20
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
21
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
22
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
23
|
+
furnished to do so, subject to the following conditions:
|
|
24
|
+
|
|
25
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
26
|
+
portions of the Software.
|
|
27
|
+
|
|
28
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
29
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
30
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
31
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
32
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
33
|
+
```
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var $=/^(pk_(live|test))_([0-9a-f-]{36})_([A-Za-z0-9]{20,})$/i,V=/^sk_/i;function j(e){if(typeof e!="string"||e.length===0)throw new Error("publishableKey is required");if(V.test(e))throw new Error("A secret key was passed where a publishable key was expected. Never embed secret keys in client code.");let t=$.exec(e);if(!t)throw new Error("publishableKey is malformed; expected pk_(live|test)_<uuid>_<base62>");return {prefix:t[1],env:t[2],projectId:t[3]}}function pe(e,t){let n=`p_${e.replace(/-/g,"")}`;return `${t?.secure?"__Secure-":""}${n}.session_token`}var U=/^http:\/\/(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*localhost|127\.0\.0\.1|\[::1\])(?::\d+)?(?:\/|$)/i;function u(e,t){throw new Error(`${e}: ${t}`)}function v(e){return /^https?:\/\/[^/?#]*(\/[^?#]*)?$/i.exec(e)?.[1]??""}function S(e,{label:t,allowHttpLoopback:n}){(typeof e!="string"||e.length===0)&&u(t,"required"),e!==e.trim()&&u(t,"surrounding whitespace"),(e.includes("?")||e.includes("#"))&&u(t,"query or fragment forbidden"),(e.includes("\\")||/%[0-9a-f]{2}/i.test(e))&&u(t,"path must be unencoded");let r;try{r=new URL(e);}catch{u(t,"absolute URL required");}return (r.username||r.password)&&u(t,"credentials forbidden"),r.protocol!=="https:"&&r.protocol!=="http:"&&u(t,"HTTPS required"),r.protocol==="http:"&&(!n||!U.test(e))&&u(t,"HTTPS required except exact loopback"),r}function H(e,t){let n;try{n=new URL(String(e));}catch{throw new TypeError("Transport URL must be absolute.")}if(n.username||n.password||n.hash)throw new TypeError("Transport URL must not contain credentials or a fragment.");let r=n.toString();if(n.protocol!=="https:"&&!(n.protocol==="http:"&&t.allowHttpLoopback&&U.test(r)))throw new TypeError("Transport URL must use HTTPS except on approved loopback.");return n}function K(e,t,n){let r=v(e);(r.includes("//")||r.split("/").some(o=>o==="."||o==="..")||r!==""&&r!==t.pathname)&&u(n,"path traversal or duplicate separator");}function J(e,t){(typeof e!="string"||!/^https?:\/\/[^/?#@\\\s]+\/?$/i.test(e))&&u("apiUrl","origin required");let n;try{n=new URL(e);}catch{u("apiUrl","origin required");}return n.protocol==="http:"&&(!t.allowHttpLoopback||!U.test(e))&&u("apiUrl","HTTPS required except exact loopback"),n.origin}function fe(e,t,n={allowHttpLoopback:false}){let r=S(e,{label:"issuer",allowHttpLoopback:n.allowHttpLoopback}),o=S(t,{label:"jwksUri",allowHttpLoopback:n.allowHttpLoopback});return K(e,r,"issuer"),K(t,o,"jwksUri"),r.pathname!=="/"&&r.pathname.endsWith("/")&&u("issuer","trailing slash forbidden"),{issuer:r.toString().replace(/\/$/,""),jwksUri:o.toString()}}function ye(e){if(!e||typeof e!="object")throw new Error("AuthConfig is required");let t=j(e.publishableKey),n=J(e.apiUrl,{allowHttpLoopback:t.env==="test"}),r=`${n}/api/projects/${t.projectId}/auth`;return {...e,apiUrl:n,decoded:t,projectBaseURL:r}}var F=1e4,W=1024*1024,A=class extends Error{kind;requestId;constructor(t,n){super(ne(t)),this.name="TransportError",this.kind=t,this.requestId=n;}},q=new WeakSet;function i(e,t){let n=new A(e,t);return q.add(n),n}async function ke({fetchImpl:e,url:t,init:n={},timeoutMs:r=F,maxResponseBytes:o=W,allowHttpLoopback:y=false,decode:l}){z(r,"timeoutMs"),z(o,"maxResponseBytes");let f=H(t,{allowHttpLoopback:y}),b=n.signal,m=new AbortController,p=null,k,d=new Promise(a=>{k=a;}),T=a=>{p===null&&(p=a,k({type:"abort",kind:a}),m.abort());},g=()=>T("aborted");b?.addEventListener("abort",g,{once:true});let D=setTimeout(()=>T("timeout"),r);b?.aborted&&g();try{if(p!==null)throw i(p);let a;try{a=await Promise.race([e(f.toString(),{...n,redirect:"error",signal:m.signal}).then(I=>({type:"response",response:I})),d]);}catch{throw i(p??"network")}if(a.type==="abort")throw i(a.kind);if(!Y(a.response))throw i("invalid_response");let w=a.response,R=te(w.headers),M=await Z(w,o,d,()=>p,R),E=Q(w,M,R),P;try{P=w.ok&&l?l(E,Object.freeze({status:w.status})):E;}catch{throw i("invalid_response",R)}return {response:w,data:P,...R===void 0?{}:{requestId:R}}}catch(a){throw a instanceof A&&q.has(a)?a:i(p??"network")}finally{clearTimeout(D),b?.removeEventListener("abort",g);}}function Y(e){if(!e||typeof e!="object")return false;let t=e;return Number.isInteger(t.status)&&t.status>=0&&t.status<=599&&typeof t.statusText=="string"&&typeof t.ok=="boolean"&&typeof t.headers?.get=="function"&&(t.body===null||typeof t.body=="object"&&typeof t.body?.getReader=="function"&&typeof t.body.cancel=="function")}async function Z(e,t,n,r,o){let y=e.headers.get("content-length");if(y!==null){if(!/^\d+$/.test(y))throw N(e.body),i("invalid_response",o);if(Number(y)>t)throw N(e.body),i("response_too_large",o)}if(!e.body)return "";let l;try{l=e.body.getReader();}catch{throw i("network",o)}let f=[],b=0,m=null;try{for(;;){let d;try{d=await Promise.race([l.read(),n]);}catch{m=i(r()??"network",o);break}if(G(d)){m=i(d.kind,o);break}let{done:T,value:g}=d;if(T)break;if(g.byteLength!==0){if(b+=g.byteLength,b>t){m=i("response_too_large",o);break}f.push(g);}}}finally{m&&X(l);try{l.releaseLock();}catch{}}if(m)throw m;let p=new Uint8Array(b),k=0;for(let d of f)p.set(d,k),k+=d.byteLength;try{return new TextDecoder("utf-8",{fatal:!0}).decode(p)}catch{throw i("invalid_response",o)}}function G(e){return "type"in e&&e.type==="abort"}function N(e){if(e)try{e.cancel().catch(()=>{});}catch{}}function X(e){try{e.cancel().catch(()=>{});}catch{}}function Q(e,t,n){if(e.status===204||e.status===205)return null;let r=ee(e.headers.get("content-type"));if(!e.ok&&(!r||t.length===0))return null;if(!r||t.length===0)throw i("invalid_response",n);try{return JSON.parse(t)}catch{if(!e.ok)return null;throw i("invalid_response",n)}}function ee(e){if(e===null)return false;let t=e.split(";",1)[0]?.trim().toLowerCase();return t==="application/json"||t?.endsWith("+json")===true}function te(e){let t=e.get("x-request-id")?.trim();if(!(!t||t.length>256||!/^[A-Za-z0-9._:-]+$/.test(t)))return t}function z(e,t){if(!Number.isInteger(e)||e<=0)throw new TypeError(`${t} must be a positive integer.`)}function ne(e){switch(e){case "aborted":return "The request was cancelled.";case "timeout":return "The request timed out.";case "response_too_large":return "The response exceeded the allowed size.";case "invalid_response":return "The service returned an invalid response.";case "network":return "The network request could not be completed."}}function re(e,t){return !e||!t?false:e.permissions.includes(t)}function oe(e,t){return !e||!t?false:e.teams?.includes(t)??false}function ie(e,t){if(!e)return false;let{role:n,permission:r,teamId:o}=t;return !(n===void 0&&r===void 0&&o===void 0||n!==void 0&&e.role!==n||r!==void 0&&!e.permissions.includes(r)||o!==void 0&&!oe(e,o))}function Te(e){return {has:t=>ie(e,t),hasPermission:t=>re(e,t.permission)}}var se=new Set(["__proto__","constructor","prototype"]);function L(e){(!e||typeof e!="object"||Array.isArray(e))&&s();let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null&&s(),e}function x(e){return typeof e!="string"&&s(),e}function ae(e){return typeof e!="boolean"&&s(),e}function O(e){return (!(e instanceof Date)||Number.isNaN(e.getTime()))&&s(),e}function B(e){return (!Array.isArray(e)||!e.every(t=>typeof t=="string"))&&s(),[...e]}function h(e,t){let n=e[t];return n==null||typeof n=="string"?n:s()}function C(e,t){let n=e[t];return n==null||typeof n=="boolean"?n:s()}function xe(e){let t=L(e),n=t.email;return n!==null&&typeof n!="string"&&s(),{id:x(t.id),email:n,emailVerified:ae(t.emailVerified),createdAt:O(t.createdAt),updatedAt:O(t.updatedAt),...c("phoneNumber",h(t,"phoneNumber")),...c("username",h(t,"username")),...c("displayUsername",h(t,"displayUsername")),...c("firstName",h(t,"firstName")),...c("lastName",h(t,"lastName")),...c("name",h(t,"name")),...c("image",h(t,"image")),...c("twoFactorEnabled",C(t,"twoFactorEnabled"))}}function Ue(e){let t=L(e),n=t.membership;return {id:x(t.id),userId:x(t.userId),expiresAt:O(t.expiresAt),...c("activeOrganizationId",h(t,"activeOrganizationId")),...c("activeTeamId",h(t,"activeTeamId")),...c("membership",n==null?n:ce(n)),...c("pendingMfaEnrollment",C(t,"pendingMfaEnrollment"))}}function s(){throw new TypeError("AuthOwl response does not match its runtime contract.")}function Oe(e,t=20,n=1e4){return (!e||typeof e!="object"||Array.isArray(e))&&s(),ue(e,t,n)}function ue(e,t=20,n=1e4){return _(e,0,{nodes:0},t,n)}function ce(e){let t=L(e);return {role:x(t.role),permissions:B(t.permissions),...t.teams===void 0?{}:{teams:B(t.teams)}}}function _(e,t,n,r,o){if(n.nodes+=1,(t>r||n.nodes>o)&&s(),e===null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)||s(),e;if(Array.isArray(e))return e.map(f=>_(f,t+1,n,r,o));(!e||typeof e!="object")&&s();let y=Object.getPrototypeOf(e);y!==Object.prototype&&y!==null&&s();let l={};for(let[f,b]of Object.entries(e))se.has(f)&&s(),l[f]=_(b,t+1,n,r,o);return l}function c(e,t){return t===void 0?{}:{[e]:t}}
|
|
2
|
+
export{j as a,pe as b,H as c,fe as d,ye as e,A as f,ke as g,L as h,x as i,ae as j,O as k,B as l,h as m,xe as n,Ue as o,s as p,Oe as q,ue as r,re as s,oe as t,ie as u,Te as v};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var Fn=/^(pk_(live|test))_([0-9a-f-]{36})_([A-Za-z0-9]{20,})$/i,Vn=/^sk_/i;function ke(e){if(typeof e!="string"||e.length===0)throw new Error("publishableKey is required");if(Vn.test(e))throw new Error("A secret key was passed where a publishable key was expected. Never embed secret keys in client code.");let t=Fn.exec(e);if(!t)throw new Error("publishableKey is malformed; expected pk_(live|test)_<uuid>_<base62>");return {prefix:t[1],env:t[2],projectId:t[3]}}function qn(e,t){let n=`p_${e.replace(/-/g,"")}`;return `${t?.secure?"__Secure-":""}${n}.session_token`}var Xe=/^http:\/\/(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*localhost|127\.0\.0\.1|\[::1\])(?::\d+)?(?:\/|$)/i;function Se(e,t){throw new Error(`${e}: ${t}`)}function Qe(e,t){let n;try{n=new URL(String(e));}catch{throw new TypeError("Transport URL must be absolute.")}if(n.username||n.password||n.hash)throw new TypeError("Transport URL must not contain credentials or a fragment.");let o=n.toString();if(n.protocol!=="https:"&&!(n.protocol==="http:"&&t.allowHttpLoopback&&Xe.test(o)))throw new TypeError("Transport URL must use HTTPS except on approved loopback.");return n}function Ze(e,t){(typeof e!="string"||!/^https?:\/\/[^/?#@\\\s]+\/?$/i.test(e))&&Se("apiUrl","origin required");let n;try{n=new URL(e);}catch{Se("apiUrl","origin required");}return n.protocol==="http:"&&(!t.allowHttpLoopback||!Xe.test(e))&&Se("apiUrl","HTTPS required except exact loopback"),n.origin}function Kn(e){if(!e||typeof e!="object")throw new Error("AuthConfig is required");let t=ke(e.publishableKey),n=Ze(e.apiUrl,{allowHttpLoopback:t.env==="test"}),o=`${n}/api/projects/${t.projectId}/auth`;return {...e,apiUrl:n,decoded:t,projectBaseURL:o}}var Hn=1e4,Bn=1024*1024,T=class extends Error{kind;requestId;constructor(t,n){super(Qn(t)),this.name="TransportError",this.kind=t,this.requestId=n;}},nt=new WeakSet;function E(e,t){let n=new T(e,t);return nt.add(n),n}async function ne({fetchImpl:e,url:t,init:n={},timeoutMs:o=Hn,maxResponseBytes:i=Bn,allowHttpLoopback:a=false,decode:r}){tt(o,"timeoutMs"),tt(i,"maxResponseBytes");let s=Qe(t,{allowHttpLoopback:a}),c=n.signal,l=new AbortController,u=null,f,m=new Promise(A=>{f=A;}),h=A=>{u===null&&(u=A,f({type:"abort",kind:A}),l.abort());},g=()=>h("aborted");c?.addEventListener("abort",g,{once:true});let U=setTimeout(()=>h("timeout"),o);c?.aborted&&g();try{if(u!==null)throw E(u);let A;try{A=await Promise.race([e(s.toString(),{...n,redirect:"error",signal:l.signal}).then(Re=>({type:"response",response:Re})),m]);}catch{throw E(u??"network")}if(A.type==="abort")throw E(A.kind);if(!jn(A.response))throw E("invalid_response");let v=A.response,z=Xn(v.headers),V=await Jn(v,i,m,()=>u,z),X=$n(v,V,z),q;try{q=v.ok&&r?r(X,Object.freeze({status:v.status})):X;}catch{throw E("invalid_response",z)}return {response:v,data:q,...z===void 0?{}:{requestId:z}}}catch(A){throw A instanceof T&&nt.has(A)?A:E(u??"network")}finally{clearTimeout(U),c?.removeEventListener("abort",g);}}function jn(e){if(!e||typeof e!="object")return false;let t=e;return Number.isInteger(t.status)&&t.status>=0&&t.status<=599&&typeof t.statusText=="string"&&typeof t.ok=="boolean"&&typeof t.headers?.get=="function"&&(t.body===null||typeof t.body=="object"&&typeof t.body?.getReader=="function"&&typeof t.body.cancel=="function")}async function Jn(e,t,n,o,i){let a=e.headers.get("content-length");if(a!==null){if(!/^\d+$/.test(a))throw et(e.body),E("invalid_response",i);if(Number(a)>t)throw et(e.body),E("response_too_large",i)}if(!e.body)return "";let r;try{r=e.body.getReader();}catch{throw E("network",i)}let s=[],c=0,l=null;try{for(;;){let m;try{m=await Promise.race([r.read(),n]);}catch{l=E(o()??"network",i);break}if(Gn(m)){l=E(m.kind,i);break}let{done:h,value:g}=m;if(h)break;if(g.byteLength!==0){if(c+=g.byteLength,c>t){l=E("response_too_large",i);break}s.push(g);}}}finally{l&&Wn(r);try{r.releaseLock();}catch{}}if(l)throw l;let u=new Uint8Array(c),f=0;for(let m of s)u.set(m,f),f+=m.byteLength;try{return new TextDecoder("utf-8",{fatal:!0}).decode(u)}catch{throw E("invalid_response",i)}}function Gn(e){return "type"in e&&e.type==="abort"}function et(e){if(e)try{e.cancel().catch(()=>{});}catch{}}function Wn(e){try{e.cancel().catch(()=>{});}catch{}}function $n(e,t,n){if(e.status===204||e.status===205)return null;let o=Yn(e.headers.get("content-type"));if(!e.ok&&(!o||t.length===0))return null;if(!o||t.length===0)throw E("invalid_response",n);try{return JSON.parse(t)}catch{if(!e.ok)return null;throw E("invalid_response",n)}}function Yn(e){if(e===null)return false;let t=e.split(";",1)[0]?.trim().toLowerCase();return t==="application/json"||t?.endsWith("+json")===true}function Xn(e){let t=e.get("x-request-id")?.trim();if(!(!t||t.length>256||!/^[A-Za-z0-9._:-]+$/.test(t)))return t}function tt(e,t){if(!Number.isInteger(e)||e<=0)throw new TypeError(`${t} must be a positive integer.`)}function Qn(e){switch(e){case "aborted":return "The request was cancelled.";case "timeout":return "The request timed out.";case "response_too_large":return "The response exceeded the allowed size.";case "invalid_response":return "The service returned an invalid response.";case "network":return "The network request could not be completed."}}var rt="x-authowl-turnstile-token",Zn=1e4,eo=32,to=2e4;function J(e,t){return {post:(n,o,i,a)=>e.request(n,{method:"POST",body:o,fetchOptions:i,decode:a}),mutation:async(n,o)=>{let i=await n;return i.error===null&&(o===void 0||i.data!==null&&o(i.data))&&t(),i}}}function oe(e,t=e.projectBaseURL){return {async request(n,o={}){let i=io(t,n,o.query),a=o.method??(o.body===void 0?"GET":"POST"),r=new Headers(o.fetchOptions?.headers);r.set("x-publishable-key",e.publishableKey),o.fetchOptions?.authChallengeToken&&r.set(rt,o.fetchOptions.authChallengeToken),o.body!==void 0&&r.set("content-type","application/json");let s={method:a,headers:r,credentials:o.credentials??"include",...o.body===void 0?{}:{body:JSON.stringify(o.body)}},c=Object.freeze({method:a,path:n});await o.fetchOptions?.onRequest?.(c);let l=oo(a,o.fetchOptions),u;try{u=await no(e,i,{...s,signal:o.fetchOptions?.signal},l);}catch(A){let v=it(A);return await o.fetchOptions?.onError?.(Te(c,v,so(A))),{data:null,error:v}}let{response:f,requestId:m}=u,h=lo(n,u.data),g=h;if(f.ok)try{g=xe(h),o.decode&&(g=o.decode(g));}catch{let A=it(new T("invalid_response",m));return await o.fetchOptions?.onError?.(Te(c,A,"invalid_response")),{data:null,error:A}}let U=Object.freeze({...c,status:f.status,...m===void 0?{}:{requestId:m}});if(await o.fetchOptions?.onResponse?.(U),!f.ok){let A=ro(f,h,m);return await o.fetchOptions?.onError?.(Te(c,A,"api")),{data:null,error:A}}return await o.fetchOptions?.onSuccess?.(U),{data:g,error:null}}}}async function no(e,t,n,o){let i=Date.now()+Zn;for(let a=0;a<o;a+=1){let r=i-Date.now();if(r<=0)throw new T("timeout");try{let s=await ne({fetchImpl:e.fetch??fetch,url:t,init:n,timeoutMs:Math.max(1,Math.ceil(r)),allowHttpLoopback:e.decoded.env==="test"});if(s.response.status<500||a===o-1)return s}catch(s){if(a===o-1||!(s instanceof T)||s.kind!=="network")throw s}await co(50*2**a,n.signal,i);}throw new T("network")}function oo(e,t){if(e!=="GET"||t?.authChallengeToken)return 1;let n=t?.retry;return typeof n!="number"||!Number.isFinite(n)?1:Math.min(Math.max(Math.trunc(n),0),3)+1}function io(e,t,n){let o=new URL(`${e}${t.startsWith("/")?t:`/${t}`}`);for(let[i,a]of Object.entries(n??{}))a!==void 0&&o.searchParams.set(i,String(a));return o.toString()}function ro(e,t,n){let o=Q(t)?t:{},i=ao(o,e.headers);return {status:e.status,statusText:e.statusText,code:typeof o.code=="string"?o.code:void 0,...n===void 0?{}:{requestId:n},...typeof o.current_version=="number"?{currentVersion:o.current_version}:{},...i!==void 0?{retryAfterSeconds:i}:{},message:typeof o.message=="string"?o.message:typeof o.error=="string"?o.error:typeof o.detail=="string"?o.detail:e.statusText||"Request failed"}}function ao(e,t){let n=(typeof e.retryAfterSeconds=="number"&&Number.isFinite(e.retryAfterSeconds)?e.retryAfterSeconds:void 0)??ot(t.get("retry-after"))??ot(t.get("x-retry-after"));if(n!==void 0)return Math.min(Math.max(Math.trunc(n),1),86400)}function ot(e){if(!e)return;let t=e.trim();if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isFinite(n)?n:void 0}function it(e){let t=e instanceof T?e.kind:"network";return {status:0,...{aborted:{statusText:"ABORTED",code:"REQUEST_ABORTED",message:"The request was cancelled."},timeout:{statusText:"TIMEOUT",code:"REQUEST_TIMEOUT",message:"The request timed out."},response_too_large:{statusText:"INVALID_RESPONSE",code:"RESPONSE_TOO_LARGE",message:"The service response was too large."},invalid_response:{statusText:"INVALID_RESPONSE",code:"INVALID_RESPONSE",message:"The service returned an invalid response."},network:{statusText:"FETCH_ERROR",code:"FETCH_ERROR",message:"Network request failed."}}[t],...e instanceof T&&e.requestId?{requestId:e.requestId}:{}}}function Te(e,t,n){return Object.freeze({...e,status:t.status??0,...t.requestId===void 0?{}:{requestId:t.requestId},failure:n})}function so(e){return e instanceof T?e.kind:"network"}function co(e,t,n){return new Promise((o,i)=>{if(t?.aborted){i(new T("aborted"));return}let a=n-Date.now();if(a<=0){i(new T("timeout"));return}let r=Math.min(e,a),s=()=>{clearTimeout(c),i(new T("aborted"));},c=setTimeout(()=>{t?.removeEventListener("abort",s),Date.now()>=n?i(new T("timeout")):o();},r);t?.addEventListener("abort",s,{once:true}),t?.aborted&&s();})}function xe(e,t="",n=0,o={nodes:0}){if(o.nodes+=1,n>eo||o.nodes>to)throw new Error("response traversal limit exceeded");if(typeof e=="string"&&/^(?:createdAt|updatedAt|expiresAt)$/.test(t)){let i=new Date(e);return Number.isNaN(i.getTime())?e:i}return Array.isArray(e)?e.map(i=>xe(i,"",n+1,o)):Q(e)?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,uo(i)?a:xe(a,i,n+1,o)])):e}function uo(e){return e==="metadata"||e==="public_metadata"||e==="unsafe_metadata"||e==="private_metadata"||e==="publicMetadata"||e==="unsafeMetadata"||e==="privateMetadata"}function lo(e,t){if(e==="/list-sessions"&&Array.isArray(t))return t.map(i=>Q(i)?Ee(i):i);if(!Q(t))return t;let o=e==="/change-password"||e==="/passkey/verify-authentication"||e==="/phone-otp/verify"||e==="/sign-up/email"||e.startsWith("/sign-in/")||e.startsWith("/two-factor/verify-")?Ee(t):t;return e==="/sign-up/email"&&!("sessionCreated"in o)&&(o={...o,sessionCreated:typeof t.token=="string"&&t.token.length>0}),(e==="/get-session"||e==="/passkey/verify-authentication")&&Q(o.session)&&(o={...o,session:Ee(o.session)}),o}function Ee(e){if(!Object.hasOwn(e,"token"))return e;let t={...e};return delete t.token,t}function Q(e){return !!e&&typeof e=="object"&&!Array.isArray(e)}function I(e){let t=new Uint8Array(e),n="";for(let i of t)n+=String.fromCharCode(i);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function K(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,o=t.padEnd(t.length+n,"="),i=atob(o),a=new ArrayBuffer(i.length),r=new Uint8Array(a);for(let s=0;s<i.length;s++)r[s]=i.charCodeAt(s);return a}function H(){return po.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential=="function")}var po={stubThis:e=>e};function ie(e){let{id:t}=e;return {...e,id:K(t),transports:e.transports}}function re(e){return e==="localhost"||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var y=class extends Error{constructor({message:t,code:n,cause:o,name:i}){super(t,{cause:o}),Object.defineProperty(this,"code",{enumerable:true,configurable:true,writable:true,value:void 0}),this.name=i??o.name,this.code=n;}};function at({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new y({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if(e.name==="ConstraintError"){if(n.authenticatorSelection?.requireResidentKey===true)return new y({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if(t.mediation==="conditional"&&n.authenticatorSelection?.userVerification==="required")return new y({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if(n.authenticatorSelection?.userVerification==="required")return new y({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else {if(e.name==="InvalidStateError")return new y({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if(e.name==="NotAllowedError")return new y({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="NotSupportedError")return n.pubKeyCredParams.filter(i=>i.type==="public-key").length===0?new y({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new y({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if(e.name==="SecurityError"){let o=globalThis.location.hostname;if(re(o)){if(n.rp.id!==o)return new y({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new y({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="TypeError"){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new y({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if(e.name==="UnknownError")return new y({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}var Ie=class{constructor(){Object.defineProperty(this,"controller",{enumerable:true,configurable:true,writable:true,value:void 0});}createNewAbortSignal(){if(this.controller){let n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n);}let t=new AbortController;return this.controller=t,t.signal}cancelCeremony(){if(this.controller){let t=new Error("Manually cancelling existing WebAuthn API call");t.name="AbortError",this.controller.abort(t),this.controller=void 0;}}},ae=new Ie;var fo=["cross-platform","platform"];function se(e){if(e&&!(fo.indexOf(e)<0))return e}async function st(e){!e.optionsJSON&&e.challenge&&(console.warn("startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=false}=e;if(!H())throw new Error("WebAuthn is not supported in this browser");let o={...t,challenge:K(t.challenge),user:{...t.user,id:K(t.user.id)},excludeCredentials:t.excludeCredentials?.map(ie)},i={};n&&(i.mediation="conditional"),i.publicKey=o,i.signal=ae.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i);}catch(g){throw at({error:g,options:i})}if(!a)throw new Error("Registration was not completed");let{id:r,rawId:s,response:c,type:l}=a,u;typeof c.getTransports=="function"&&(u=c.getTransports());let f;if(typeof c.getPublicKeyAlgorithm=="function")try{f=c.getPublicKeyAlgorithm();}catch(g){Pe("getPublicKeyAlgorithm()",g);}let m;if(typeof c.getPublicKey=="function")try{let g=c.getPublicKey();g!==null&&(m=I(g));}catch(g){Pe("getPublicKey()",g);}let h;if(typeof c.getAuthenticatorData=="function")try{h=I(c.getAuthenticatorData());}catch(g){Pe("getAuthenticatorData()",g);}return {id:r,rawId:I(s),response:{attestationObject:I(c.attestationObject),clientDataJSON:I(c.clientDataJSON),transports:u,publicKeyAlgorithm:f,publicKey:m,authenticatorData:h},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:se(a.authenticatorAttachment)}}function Pe(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.
|
|
2
|
+
`,t);}function ct(){if(!H())return De.stubThis(new Promise(t=>t(false)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?De.stubThis(new Promise(t=>t(false))):De.stubThis(e.isConditionalMediationAvailable())}var De={stubThis:e=>e};function ut({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new y({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else {if(e.name==="NotAllowedError")return new y({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){let o=globalThis.location.hostname;if(re(o)){if(n.rpId!==o)return new y({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new y({message:`${globalThis.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new y({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}async function lt(e){!e.optionsJSON&&e.challenge&&(console.warn("startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information."),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=false,verifyBrowserAutofillInput:o=true}=e;if(!H())throw new Error("WebAuthn is not supported in this browser");let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(ie));let a={...t,challenge:K(t.challenge),allowCredentials:i},r={};if(n){if(!await ct())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete$='webauthn']").length<1&&o)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');r.mediation="conditional",a.allowCredentials=[];}r.publicKey=a,r.signal=ae.createNewAbortSignal();let s;try{s=await navigator.credentials.get(r);}catch(h){throw ut({error:h,options:r})}if(!s)throw new Error("Authentication was not completed");let{id:c,rawId:l,response:u,type:f}=s,m;return u.userHandle&&(m=I(u.userHandle)),{id:c,rawId:I(l),response:{authenticatorData:I(u.authenticatorData),clientDataJSON:I(u.clientDataJSON),signature:I(u.signature),userHandle:m},type:f,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:se(s.authenticatorAttachment)}}var mo=new Set(["__proto__","constructor","prototype"]);function p(e){(!e||typeof e!="object"||Array.isArray(e))&&d();let t=Object.getPrototypeOf(e);return t!==Object.prototype&&t!==null&&d(),e}function w(e){return typeof e!="string"&&d(),e}function b(e){return typeof e!="boolean"&&d(),e}function k(e){return (!(e instanceof Date)||Number.isNaN(e.getTime()))&&d(),e}function ce(e){return (!Array.isArray(e)||!e.every(t=>typeof t=="string"))&&d(),[...e]}function R(e,t){let n=e[t];return n==null||typeof n=="string"?n:d()}function dt(e,t){let n=e[t];return n==null||typeof n=="boolean"?n:d()}function D(e){let t=p(e),n=t.email;return n!==null&&typeof n!="string"&&d(),{id:w(t.id),email:n,emailVerified:b(t.emailVerified),createdAt:k(t.createdAt),updatedAt:k(t.updatedAt),...P("phoneNumber",R(t,"phoneNumber")),...P("username",R(t,"username")),...P("displayUsername",R(t,"displayUsername")),...P("firstName",R(t,"firstName")),...P("lastName",R(t,"lastName")),...P("name",R(t,"name")),...P("image",R(t,"image")),...P("twoFactorEnabled",dt(t,"twoFactorEnabled"))}}function ue(e){let t=p(e),n=t.membership;return {id:w(t.id),userId:w(t.userId),expiresAt:k(t.expiresAt),...P("activeOrganizationId",R(t,"activeOrganizationId")),...P("activeTeamId",R(t,"activeTeamId")),...P("membership",n==null?n:go(n)),...P("pendingMfaEnrollment",dt(t,"pendingMfaEnrollment"))}}function d(){throw new TypeError("AuthOwl response does not match its runtime contract.")}function _(e,t=20,n=1e4){return (!e||typeof e!="object"||Array.isArray(e))&&d(),ve(e,t,n)}function ve(e,t=20,n=1e4){return Ce(e,0,{nodes:0},t,n)}function go(e){let t=p(e);return {role:w(t.role),permissions:ce(t.permissions),...t.teams===void 0?{}:{teams:ce(t.teams)}}}function Ce(e,t,n,o,i){if(n.nodes+=1,(t>o||n.nodes>i)&&d(),e===null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)||d(),e;if(Array.isArray(e))return e.map(s=>Ce(s,t+1,n,o,i));(!e||typeof e!="object")&&d();let a=Object.getPrototypeOf(e);a!==Object.prototype&&a!==null&&d();let r={};for(let[s,c]of Object.entries(e))mo.has(s)&&d(),r[s]=Ce(c,t+1,n,o,i);return r}function P(e,t){return t===void 0?{}:{[e]:t}}var pt=new Set([1564,8206,8207,8234,8235,8236,8237,8238,8294,8295,8296,8297]),le=new Set([9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288,65279]);function de(e){if(e===void 0)return {valid:true,value:void 0};for(let n of e){let o=n.codePointAt(0);if(o===void 0||mt(n,o)||ft(o)||pt.has(o))return {valid:false}}let t=ho(e);return Ue(t)?{valid:true,value:t}:{valid:false}}function Ue(e){let t=0,n,o;for(let i of e){if(t+=1,t>256)return false;let a=i.codePointAt(0);if(a===void 0||mt(i,a)||ft(a)||pt.has(a))return false;n??=a,o=a;}return t>0&&n!==void 0&&o!==void 0&&!le.has(n)&&!le.has(o)}function pe(){return {data:null,error:{status:400,statusText:"BAD_REQUEST",code:"INVALID_PASSKEY_NAME",message:"Passkey names must contain 1 to 256 safe Unicode characters."}}}function ho(e){let t=0,n=e.length;for(;t<n;){let o=e.codePointAt(t);if(o===void 0||!le.has(o))break;t+=o>65535?2:1;}for(;n>t;){let o=e.codePointAt(n-1);if(o===void 0)break;let a=o>=56320&&o<=57343?n-2:n-1,r=e.codePointAt(a);if(r===void 0||!le.has(r))break;n=a;}return e.slice(t,n)}function ft(e){return e>=0&&e<=31||e>=127&&e<=159}function mt(e,t){return e.length===1&&t>=55296&&t<=57343}var At=12,Ot=5e3,Ao=8,Oo=1e3,yo=16,gt=512,yt=100,bt=8192,bo=32768,ze=1024,ht=256,Ne=64,wo=6e5,Ro=/^[A-Za-z0-9_-]+$/u,ko=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u,So=/[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/u,To=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/u,Eo=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu,wt=new Set(["discouraged","preferred","required"]),xo=new Set(["singleDevice","multiDevice"]),Rt=new Set(["ble","cable","hybrid","internal","nfc","smart-card","usb"]),kt=new Set(["hybrid","security-key","client-device"]),Io=new Set(["none","indirect","direct","enterprise"]),Po=new Set(["fido-u2f","packed","android-safetynet","android-key","tpm","apple","none"]),Do=new Set(["platform","cross-platform"]),Co=new Set(["discouraged","preferred","required"]),vo=new Set([-8,-7,-257]);function St(e){let t=_(e,At,Ot);return {challenge:zt(t.challenge),...S("timeout",vt(t.timeout)),...S("rpId",_t(t.rpId)),...S("allowCredentials",Ct(t.allowCredentials)),...S("userVerification",Z(t.userVerification,wt)),...S("hints",fe(t.hints,kt)),...S("extensions",Ut(t.extensions))}}function Tt(e){let t=_(e,At,Ot);return {challenge:zt(t.challenge),rp:Uo(t.rp),user:zo(t.user),pubKeyCredParams:_o(t.pubKeyCredParams),...S("timeout",vt(t.timeout)),...S("excludeCredentials",Ct(t.excludeCredentials)),...S("authenticatorSelection",No(t.authenticatorSelection)),...S("attestation",Z(t.attestation,Io)),...S("attestationFormats",fe(t.attestationFormats,Po)),...S("hints",fe(t.hints,kt)),...S("extensions",Ut(t.extensions))}}function Et(e){let t=p(e),n=ue(t.session),o=D(t.user);return n.userId!==o.id&&d(),{session:n,user:o}}function Le(e){let t=p(e),n=t.counter;(!Number.isSafeInteger(n)||n<0)&&d();let o=Me(t.deviceType,xo),i=b(t.backedUp);return i&&o!=="multiDevice"&&d(),{id:G(t.id,ht),...Fo(t),publicKey:Lo(t.publicKey,bo),userId:G(t.userId,ht),credentialID:ge(t.credentialID,bt),counter:n,deviceType:o,backedUp:i,...Vo(t),createdAt:k(t.createdAt),...qo(t)}}function xt(e,t,n){let o=Le(e);return (o.credentialID!==t||(n===void 0?o.name!==void 0&&o.name!==null:o.name!==n))&&d(),o}function It(e){(!Array.isArray(e)||e.length>yt)&&d();let t=e.map(Le);return me(t.map(n=>n.id)),me(t.map(n=>n.credentialID)),t.length>1&&t.some(n=>n.userId!==t[0]?.userId)&&d(),t}function Pt(e,t,n){let o=p(e),i=Le(o.passkey);return (i.id!==t||i.name!==n)&&d(),{passkey:i}}function Dt(e){return p(e).status!==true&&d(),{status:true}}function Uo(e){let t=p(e);return {name:_e(t.name,ze),...S("id",_t(t.id))}}function zo(e){let t=p(e);return {id:ge(t.id,128,1,64),name:_e(t.name,ze),displayName:_e(t.displayName,ze)}}function _o(e){(!Array.isArray(e)||e.length===0||e.length>Ne)&&d();let t=e.map(n=>{let o=p(n);return (o.type!=="public-key"||!Number.isSafeInteger(o.alg)||!vo.has(o.alg))&&d(),{type:"public-key",alg:o.alg}});return Ko(t.map(n=>n.alg)),t}function Ct(e){if(e===void 0)return;(!Array.isArray(e)||e.length>yt)&&d();let t=e.map(n=>{let o=p(n);return o.type!=="public-key"&&d(),{type:"public-key",id:ge(o.id,bt),...S("transports",fe(o.transports,Rt))}});return me(t.map(n=>n.id)),t}function No(e){if(e===void 0)return;let t=p(e);t.requireResidentKey!==void 0&&typeof t.requireResidentKey!="boolean"&&d();let n=Z(t.residentKey,Co);return t.requireResidentKey!==void 0&&n!==void 0&&t.requireResidentKey!==(n==="required")&&d(),{...S("authenticatorAttachment",Z(t.authenticatorAttachment,Do)),...S("residentKey",n),...S("requireResidentKey",t.requireResidentKey),...S("userVerification",Z(t.userVerification,wt))}}function vt(e){return e!==void 0&&(typeof e!="number"||!Number.isFinite(e)||e<0||e>wo)&&d(),e}function Ut(e){return e===void 0?void 0:_(e,Ao,Oo)}function fe(e,t){if(e===void 0)return;(!Array.isArray(e)||e.length>Ne)&&d();let n=e.map(o=>Me(o,t));return me(n),n}function Z(e,t){if(e!==void 0)return Me(e,t)}function zt(e){return ge(e,Math.ceil(gt*4/3),yo,gt)}function ge(e,t,n=1,o=Number.POSITIVE_INFINITY){let i=G(e,t),a=i.length%4,r=Mo(i.at(-1)??""),s=Math.floor(i.length*3/4);return (!Ro.test(i)||a===1||a===2&&(r&15)!==0||a===3&&(r&3)!==0||s<n||s>o)&&d(),i}function G(e,t){let n=w(e);return (n.length===0||n.length>t)&&d(),n}function _e(e,t){let n=G(e,t);return So.test(n)&&d(),n}function _t(e){if(e===void 0)return;let t=G(e,253);return t!=="localhost"&&(t.endsWith(".")||!t.includes(".")||t.split(".").some(n=>!To.test(n)))&&d(),t}function Lo(e,t){let n=G(e,t),o=n.endsWith("=="),i=!o&&n.endsWith("="),a=n.at(o?-3:i?-2:-1)??"",r=Nt(a);return (n.length%4!==0||!ko.test(n)||o&&(r&15)!==0||i&&(r&3)!==0)&&d(),n}function Mo(e){return Nt(e,true)}function Nt(e,t=false){return (t?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").indexOf(e)}function Fo(e){let t=R(e,"name");return t===void 0?{}:(t!==null&&!Ue(t)&&d(),{name:t})}function Vo(e){let t=R(e,"transports");if(t==null||t==="")return t===void 0?{}:{transports:t};let n=t.split(",");return (n.length>Ne||n.some(o=>!Rt.has(o))||new Set(n).size!==n.length)&&d(),{transports:t}}function qo(e){let t=R(e,"aaguid");return t==null?t===void 0?{}:{aaguid:null}:(Eo.test(t)||d(),{aaguid:t})}function Me(e,t){let n=w(e);return t.has(n)||d(),n}function S(e,t){return t===void 0?{}:{[e]:t}}function me(e){new Set(e).size!==e.length&&d();}function Ko(e){new Set(e).size!==e.length&&d();}function Vt(e,t){let n=new Map;return {async signIn(o={},i){let a=await e.request("/passkey/generate-authenticate-options");if(!a.data)return Mt(a.error);let r;try{r=St(a.data);}catch{return Lt()}let s;try{s=await lt({optionsJSON:r,useBrowserAutofill:o.autoFill});}catch(m){return Ft(m,"AUTH_CANCELLED","Passkey authentication was cancelled.")}let{clientExtensionResults:c,...l}=s,u=n.get(s.id);if(u)return u;let f=(async()=>{let m=await e.request("/passkey/verify-authentication",{method:"POST",body:{response:l},fetchOptions:i,decode:Et});return m.data&&t(),m})();n.set(s.id,f);try{return await f}finally{n.get(s.id)===f&&n.delete(s.id);}},async add(o={},i){let a=de(o.name);if(!a.valid)return pe();let r=await e.request("/passkey/generate-register-options",{query:{name:a.value,authenticatorAttachment:o.authenticatorAttachment}});if(!r.data)return Mt(r.error);let s;try{s=Tt(r.data);}catch{return Lt()}let c;try{c=await st({optionsJSON:s});}catch(m){return Ft(m,"REGISTRATION_CANCELLED","Passkey registration was cancelled.")}let{clientExtensionResults:l,...u}=c,f=await e.request("/passkey/verify-registration",{method:"POST",body:{response:u,name:a.value},fetchOptions:i,decode:m=>xt(m,c.id,a.value)});return f.data&&t(),f}}}function Lt(){return {data:null,error:{status:502,statusText:"BAD_GATEWAY",code:"INVALID_WEBAUTHN_OPTIONS",message:"The server returned invalid WebAuthn options."}}}function Mt(e){return {data:null,error:e??{status:502,statusText:"BAD_GATEWAY",code:"INVALID_WEBAUTHN_OPTIONS",message:"The server returned no WebAuthn options."}}}function Ft(e,t,n){let o=Bo(e,"page does not have focus"),i=e instanceof y?e.code==="ERROR_CEREMONY_ABORTED":Ho(e)==="AbortError",a=t==="AUTH_CANCELLED"?"Passkey authentication could not be completed by this browser.":"Passkey registration could not be completed by this browser.";return {data:null,error:{status:400,statusText:"BAD_REQUEST",code:o?"PASSKEY_PAGE_NOT_FOCUSED":i?t:e instanceof y?e.code:"PASSKEY_BROWSER_ERROR",message:o?"Keep this page focused while completing the passkey prompt.":i?n:a}}}function Ho(e){return e&&typeof e=="object"&&"name"in e&&typeof e.name=="string"?e.name:void 0}function Bo(e,t){let n=t.toLowerCase(),o=new Set,i=e;for(;i&&typeof i=="object"&&!o.has(i);){if(o.add(i),"message"in i&&typeof i.message=="string"&&i.message.toLowerCase().includes(n))return true;i="cause"in i?i.cause:void 0;}return false}function Kt(e,t){let n=new Set,o=null,i=null,a=null,r,s=h=>{u(h);};r={data:null,isPending:true,isRefetching:false,error:null,refetch:s};function c(h){r=h;for(let g of n)g();}async function l(h){return e.request("/get-session",{query:h?.query,decode:qt})}async function u(h){a?.abort();let g=new AbortController;a=g,c({...r,isPending:r.data===null&&r.error===null,isRefetching:r.data!==null});let U=await e.request("/get-session",{query:h?.query,fetchOptions:{signal:g.signal},decode:qt});a===g&&(a=null,c({data:U.data,error:U.error,isPending:false,isRefetching:false,refetch:s}));}function f(){if(typeof window>"u"||i)return;let h=()=>{u();},g=()=>{document.visibilityState==="visible"&&u();};window.addEventListener("focus",h),document.addEventListener("visibilitychange",g),typeof BroadcastChannel<"u"&&(o=new BroadcastChannel(`authowl:${t}`),o.addEventListener("message",h)),i=()=>{window.removeEventListener("focus",h),document.removeEventListener("visibilitychange",g),o?.close(),o=null,i=null;};}function m(h){return n.add(h),n.size===1&&(f(),u()),()=>{n.delete(h),n.size===0&&(a?.abort(),a=null,i?.());}}return {store:{subscribe:m,getSnapshot:()=>r},getSession:l,notifyMutation(){o?.postMessage({type:"session-changed"}),n.size>0&&u({query:{disableCookieCache:true}});}}}function qt(e){if(e===null)return null;let t=p(e);return (t.session===void 0||t.user===void 0)&&d(),{session:ue(t.session),user:D(t.user)}}function Fe(){let e=globalThis.crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return `${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}async function Ht(e,t){return e.request("/user/metadata",{fetchOptions:t,decode:jt})}async function Bt(e,t,n){return e.request("/user/metadata",{method:"PATCH",body:{expected_version:t.expectedVersion,unsafe_metadata:t.unsafeMetadata},fetchOptions:n,decode:jt})}function jt(e){let t=p(e),n=_(t.public_metadata),o=_(t.unsafe_metadata);if(!Number.isSafeInteger(t.metadata_version)||t.metadata_version<0)throw new TypeError("Invalid AuthOwl metadata response");return {publicMetadata:n,unsafeMetadata:o,metadataVersion:t.metadata_version}}function Gt(e,t){let{post:n,mutation:o}=J(e,t);return {getMetadata:i=>Ht(e,i),updateUnsafeMetadata:(i,a)=>Bt(e,i,a),updateProfile:(i,a)=>o(n("/update-user",i,a,ee)),changeEmail:(i,a)=>o(n("/change-email",i,a,ee)),changePassword:(i,a)=>o(n("/change-password",i,a,jo)),listSessions:i=>e.request("/list-sessions",{fetchOptions:i,decode:Jo}),revokeSession:({sessionId:i},a)=>o(n("/revoke-session",{sessionId:i},a,ee)),revokeOtherSessions:i=>o(n("/revoke-other-sessions",{},i,ee)),listSocialAccounts:async i=>{let a=await e.request("/list-accounts",{fetchOptions:i,decode:Go});if(!a.data)return {data:null,error:a.error};let r=a.data.length>1;return {...a,data:a.data.filter(s=>s.providerId!=="credential").map(s=>({...s,canUnlink:r}))}},linkSocial:(i,a)=>n("/link-social",i,a,Wo),unlinkSocial:(i,a)=>o(n("/unlink-account",i,a,ee)),delete:(i={},a)=>o(n("/delete-user",i,a,$o))}}function ee(e){let t=p(e);return {status:b(t.status)}}function jo(e){let t=p(e);return {user:D(t.user)}}function Jo(e){return Array.isArray(e)||d(),e.map(t=>{let n=p(t);return {id:w(n.id),userId:w(n.userId),createdAt:k(n.createdAt),updatedAt:k(n.updatedAt),expiresAt:k(n.expiresAt),...Jt("ipAddress",R(n,"ipAddress")),...Jt("userAgent",R(n,"userAgent"))}})}function Go(e){return Array.isArray(e)||d(),e.map(t=>{let n=p(t);return {id:w(n.id),userId:w(n.userId),providerId:w(n.providerId),accountId:w(n.accountId),scopes:ce(n.scopes),createdAt:k(n.createdAt),updatedAt:k(n.updatedAt)}})}function Wo(e){let t=p(e);return {url:w(t.url),redirect:b(t.redirect)}}function $o(e){let t=p(e);return {success:b(t.success),message:w(t.message)}}function Jt(e,t){return t===void 0?{}:{[e]:t}}function he(e,t){return !e||!t?false:e.permissions.includes(t)}function Wt(e,t){return !e||!t?false:e.teams?.includes(t)??false}function Ae(e,t){if(!e)return false;let{role:n,permission:o,teamId:i}=t;return !(n===void 0&&o===void 0&&i===void 0||n!==void 0&&e.role!==n||o!==void 0&&!e.permissions.includes(o)||i!==void 0&&!Wt(e,i))}function Yo(e){return {has:t=>Ae(e,t),hasPermission:t=>he(e,t.permission)}}var Xo=new Set(["pending","accepted","rejected","canceled"]),$t=1e4;function W(e,t,n){let o=p(e),i={id:O(o.id),name:O(o.name),slug:O(o.slug),createdAt:k(o.createdAt),...Oe("logo",R(o,"logo")),...Oe("metadata",o.metadata===void 0?void 0:ve(o.metadata))};return M(i.id,t),M(i.slug,n),i}function Yt(e){return F(e,W)}function Ve(e,t,n){return e===null?null:(t===null&&d(),W(e,t,n))}function Xt(e,t,n){if(e===null)return null;let o=p(e),i=W(o,t,n);return {...i,members:F(o.members,a=>dn(a,i.id)),invitations:F(o.invitations,a=>N(a,void 0,i.id))}}function Qt(e,t){let n=F(e,o=>ln(o));return ye(n.map(o=>o.organizationId),t),n}function Zt(e,t,n){return e===null?null:(t===null&&d(),ln(e,t,n))}function en(e,t){let n=p(e);return (!Number.isSafeInteger(n.total)||n.total<0)&&d(),{members:Qo(n.members,t),total:n.total}}function N(e,t,n){let o=p(e),i=O(o.status);Xo.has(i)||d();let a={id:O(o.id),organizationId:O(o.organizationId),email:O(o.email),role:O(o.role),status:i,inviterId:O(o.inviterId),expiresAt:k(o.expiresAt),createdAt:k(o.createdAt)};return M(a.id,t),M(a.organizationId,n),a}function tn(e,t){let n=F(e,o=>N(o));return ye(n.map(o=>o.organizationId),t),n}function nn(e){return F(e,t=>{let n=p(t);return {...N(n),organizationName:O(n.organizationName)}})}function on(e,t){let n=p(e);return {...N(n,t),organizationName:O(n.organizationName),organizationSlug:O(n.organizationSlug),inviterEmail:O(n.inviterEmail)}}function rn(e,t){let n=p(e),o=N(n.invitation,t);return {invitation:o,member:$(n.member,void 0,o.organizationId)}}function an(e,t){let n=p(e);return n.member!==null&&d(),{invitation:n.invitation===null?null:N(n.invitation,t),member:null}}function sn(e,t){return e===null?null:N(e,t)}function cn(e,t,n){let o=p(e);return {member:$(o.member,n,t)}}function $(e,t,n){let o=p(e),i={id:O(o.id),organizationId:O(o.organizationId),userId:O(o.userId),role:O(o.role),createdAt:k(o.createdAt),...o.user===void 0?{}:{user:pn(o.user)}};return M(i.id,t),M(i.organizationId,n),i}function un(e,t){let n=F(e,o=>{let i=p(o);return {organizationId:O(i.organizationId),data:{role:O(i.role),...Oe("permission",i.permission===void 0?void 0:Zo(i.permission))}}});return ye(n.map(o=>o.organizationId),t),n.map(o=>o.data)}function ln(e,t,n){let o=p(e),i=o.updatedAt,a={id:O(o.id),name:O(o.name),organizationId:O(o.organizationId),createdAt:k(o.createdAt),...i===void 0?{}:{updatedAt:k(i)}};return M(a.id,t),M(a.organizationId,n),a}function dn(e,t){let n=p(e);return {...$(n,void 0,t),user:pn(n.user)}}function Qo(e,t){let n=F(e,o=>dn(o));return ye(n.map(o=>o.organizationId),t),n}function Zo(e){let t=p(e),n={};for(let[o,i]of Object.entries(t))(o==="__proto__"||o==="constructor"||o==="prototype"||o.length===0||o.length>$t||!Array.isArray(i))&&d(),n[o]=i.map(a=>O(a));return n}function O(e){let t=w(e);return (t.length===0||t.length>$t)&&d(),t}function M(e,t){t!==void 0&&e!==t&&d();}function ye(e,t){let n=t??e[0];n!==void 0&&e.some(o=>o!==n)&&d();}function pn(e){let t=p(e);return {id:O(t.id),name:O(t.name),email:O(t.email),...Oe("image",R(t,"image"))}}function F(e,t){return Array.isArray(e)||d(),e.map(n=>t(n))}function Oe(e,t){return t===void 0?{}:{[e]:t}}function fn(e,t,n=()=>null){let{post:o,mutation:i}=J(e,t),a=(r,s,c,l)=>e.request(r,{query:s,fetchOptions:c,decode:l});return {create:(r,s)=>i(o("/organization/create",r,s,W)),list:r=>a("/organization/list",void 0,r,Yt),get:(r={},s)=>a("/organization/get-full-organization",{organizationId:r.organizationId,organizationSlug:r.organizationSlug,membersLimit:r.membersLimit},s,c=>Xt(c,r.organizationId,r.organizationSlug)),setActive:(r,s)=>i(o("/organization/set-active",r,s,c=>Ve(c,r.organizationId,r.organizationSlug))),listTeams:(r={},s)=>a("/organization/list-teams",{organizationId:r.organizationId},s,c=>Qt(c,r.organizationId)),setActiveTeam:(r,s)=>i(o("/organization/set-active-team",r,s,c=>Zt(c,r.teamId))),update:(r,s)=>i(o("/organization/update",r,s,c=>Ve(c,r.organizationId))),delete:(r,s)=>i(o("/organization/delete",r,s,c=>W(c,r.organizationId))),listMembers:(r={},s)=>a("/organization/list-members",{organizationId:r.organizationId,organizationSlug:r.organizationSlug,limit:r.limit,offset:r.offset,sortBy:r.sortBy,sortDirection:r.sortDirection,filterField:r.filterField,filterValue:r.filterValue,filterOperator:r.filterOperator},s,c=>en(c,r.organizationId)),inviteMember:(r,s)=>i(o("/organization/invite-member",r,s,c=>N(c,void 0,r.organizationId))),listInvitations:(r={},s)=>a("/organization/list-invitations",{organizationId:r.organizationId},s,c=>tn(c,r.organizationId)),listUserInvitations:r=>a("/organization/list-user-invitations",void 0,r,nn),getInvitation:(r,s)=>a("/organization/get-invitation",{id:r.id},s,c=>on(c,r.id)),acceptInvitation:(r,s)=>i(o("/organization/accept-invitation",r,s,c=>rn(c,r.invitationId))),rejectInvitation:(r,s)=>i(o("/organization/reject-invitation",r,s,c=>an(c,r.invitationId))),cancelInvitation:(r,s)=>i(o("/organization/cancel-invitation",r,s,c=>sn(c,r.invitationId))),removeMember:(r,s)=>i(o("/organization/remove-member",r,s,c=>cn(c,r.organizationId,r.memberIdOrEmail.includes("@")?void 0:r.memberIdOrEmail))),updateMemberRole:(r,s)=>i(o("/organization/update-member-role",r,s,c=>$(c,r.memberId,r.organizationId))),leave:(r,s)=>i(o("/organization/leave",r,s,c=>$(c,void 0,r.organizationId))),listRoles:(r={},s)=>a("/organization/list-roles",{organizationId:r.organizationId},s,c=>un(c,r.organizationId)),has:r=>Ae(n(),r),hasPermission:r=>he(n(),r.permission)}}var mn=4096,ei=4096,ti=100,ni=256,oi=16,ii=64;function Ke(e){let t=p(e);return t.twoFactorRedirect===true?((t.user!==void 0||t.redirect!==void 0||t.url!==void 0)&&d(),{twoFactorRedirect:true,...t.twoFactorMethods===void 0?{}:{twoFactorMethods:Cn(t.twoFactorMethods,oi,ii)}}):(t.twoFactorRedirect!==void 0&&d(),{redirect:b(t.redirect),...ci(t,"url"),user:D(t.user)})}function gn(e){let t=p(e);return {user:D(t.user)}}function hn(e){let t=p(e);return {sessionCreated:b(t.sessionCreated),user:D(t.user)}}function An(e,t){let n=p(e),o=b(n.redirect);n.user===null&&d();let i=n.user!==void 0&&n.user!==null,a=n.url!==void 0&&n.url!==null;return o?((i||!a)&&d(),{redirect:true,url:qe(n.url,t)}):(i===a&&d(),i?{redirect:false,user:D(n.user)}:{redirect:false,url:qe(n.url,t)})}function On(e,t){let n=p(e);return (n.redirect!==true||n.user!==void 0)&&d(),{redirect:true,url:qe(n.url,t)}}function yn(e){return {status:b(p(e).status)}}function bn(e){return {success:b(p(e).success)}}function wn(e){return p(e).status!=="pending"&&d(),{status:"pending"}}function Rn(e){let t=p(e);return (t.status!==true||t.sessionCreated!==true)&&d(),{status:true,sessionCreated:true,user:ri(t.user)}}function He(e){return {status:b(p(e).status)}}function kn(e){return {status:b(p(e).status)}}function Sn(e){let t=p(e);return {status:b(t.status),user:D(t.user)}}function Tn(e){return {success:b(p(e).success)}}function En(e){let t=p(e);return {totpURI:si(t.totpURI),backupCodes:Dn(t.backupCodes)}}function xn(e){return {status:b(p(e).status)}}function be(e){return p(e).status!==true&&d(),{status:true}}function In(e){return {status:b(p(e).status)}}function Pn(e){let t=p(e);return t.status!==void 0&&t.status!==true&&d(),{backupCodes:Dn(t.backupCodes)}}function ri(e){let t=p(e);return {id:Y(t.id,512),...ui(t,"name",1024),phoneNumber:Y(t.phoneNumber,64),phoneNumberVerified:b(t.phoneNumberVerified),...t.createdAt===void 0?{}:{createdAt:k(t.createdAt)},...t.updatedAt===void 0?{}:{updatedAt:k(t.updatedAt)}}}function qe(e,t){let n=Y(e,mn);/[\u0000-\u0020\u007f]/u.test(n)&&d();let o;try{o=new URL(n);}catch{return d()}return (o.username||o.password)&&d(),o.protocol==="https:"||t&&o.protocol==="http:"&&ai(o.hostname)?o.href:d()}function ai(e){let t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="[::1]"}function si(e){let t=Y(e,ei),n;try{n=new URL(t);}catch{return d()}let o=n.searchParams.get("secret");return (n.protocol!=="otpauth:"||n.hostname.toLowerCase()!=="totp"||n.username||n.password||n.hash||o===null||o.length===0||o.length>512||/\s/u.test(o))&&d(),t}function Dn(e){return Cn(e,ti,ni)}function Cn(e,t,n){(!Array.isArray(e)||e.length===0||e.length>t)&&d();let o=e.map(i=>Y(i,n));return o.some(i=>i.trim().length===0)&&d(),new Set(o).size!==o.length&&d(),o}function Y(e,t){let n=w(e);return (n.length===0||n.length>t)&&d(),n}function ci(e,t){let n=e[t];return n==null?{}:{[t]:Y(n,mn)}}function ui(e,t,n){let o=R(e,t);return o===void 0?{}:(o!==null&&o.length>n&&d(),{[t]:o})}function vn(e,t=()=>{}){let n=oe(e),o=Kt(n,e.decoded.projectId),i=Vt(n,o.notifyMutation),a=()=>{o.notifyMutation(),t();},{post:r,mutation:s}=J(n,a),c=e.decoded.env==="test";return {sessionStore:o.store,getSession:o.getSession,account:Gt(n,a),organization:fn(n,a,()=>o.store.getSnapshot().data?.session.membership??null),signIn:{email:(l,u)=>s(r("/sign-in/email",l,u,Ke),f=>!("twoFactorRedirect"in f)),username:(l,u)=>s(r("/sign-in/username",l,u,Ke),f=>!("twoFactorRedirect"in f)),social:async(l,u)=>{let f=await s(r("/sign-in/social",l,u,m=>An(m,c)),m=>"user"in m);return f.error!==null||f.data===null||"url"in f.data&&f.data.redirect&&!l.disableRedirect&&typeof window<"u"&&window.location.assign(f.data.url),f},sso:async(l,u)=>{let f=await r("/sign-in/sso",l,u,m=>On(m,c));return f.error!==null||f.data===null||typeof window<"u"&&window.location.assign(f.data.url),f},magicLink:(l,u)=>r("/sign-in/magic-link",l,u,yn),emailOtp:(l,u)=>s(r("/sign-in/email-otp",l,u,gn)),passkey:(l,u)=>i.signIn(l,u)},signUp:{email:(l,u)=>s(r("/sign-up/email",l,u,hn),f=>f.sessionCreated)},emailOtp:{sendVerificationOtp:(l,u)=>r("/email-otp/send-verification-otp",l,u,bn),verifyEmail:(l,u)=>s(r("/email-otp/verify-email",l,u,Sn))},phoneOtp:{start:(l,u)=>r("/phone-otp/start",{...l,idempotencyKey:l.idempotencyKey??Fe()},u,wn),verify:(l,u)=>s(r("/phone-otp/verify",l,u,Rn))},requestPasswordReset:(l,u)=>r("/request-password-reset",l,u,He),resetPassword:(l,u)=>r("/reset-password",l,u,He),sendVerificationEmail:(l,u)=>r("/send-verification-email",l,u,kn),passkey:{addPasskey:(l,u)=>i.add(l,u),listUserPasskeys:()=>n.request("/passkey/list-user-passkeys",{decode:It}),updatePasskey:async(l,u)=>{let f=de(l.name);if(!f.valid||f.value===void 0)return pe();let m=f.value;return r("/passkey/update-passkey",{...l,name:m},u,h=>Pt(h,l.id,m))},deletePasskey:(l,u)=>r("/passkey/delete-passkey",l,u,Dt)},twoFactor:{enable:(l,u)=>r("/two-factor/enable",l,u,En),disable:(l,u)=>s(r("/two-factor/disable",l,u,xn),f=>f.status),verifyTotp:(l,u)=>s(r("/two-factor/verify-totp",l,u,be)),verifyBackupCode:(l,u)=>s(r("/two-factor/verify-backup-code",l,u,be)),sendOtp:(l={},u)=>r("/two-factor/send-otp",l,u,In),verifyOtp:(l,u)=>s(r("/two-factor/verify-otp",l,u,be)),generateBackupCodes:(l,u)=>r("/two-factor/generate-backup-codes",l,u,Pn)},signOut:l=>s(n.request("/sign-out",{method:"POST",body:{},fetchOptions:l,decode:Tn}),u=>u.success)}}var we=class extends Error{status;requestId;constructor(t,n,o){super(`${t} request failed with status ${n.status}.`),this.name="AuthOwlHttpError",this.status=n.status,this.requestId=o;}};function B(e,t,n={}){let o=new Headers(n.init?.headers);return o.set("x-publishable-key",e.publishableKey),ne({fetchImpl:e.fetch??fetch,url:t,init:{...n.init,headers:o},allowHttpLoopback:e.decoded.env==="test",...n.timeoutMs===void 0?{}:{timeoutMs:n.timeoutMs},...n.maxResponseBytes===void 0?{}:{maxResponseBytes:n.maxResponseBytes},...n.decode===void 0?{}:{decode:n.decode}})}function j(e,t){if(!e.response.ok)throw new we(t,e.response,e.requestId);return e.data}function zn(e){return `${new URL(e.apiUrl).origin}/api/projects/${e.decoded.projectId}/consent`}async function Be(e){let t=await B(e,zn(e),{init:{method:"GET",credentials:"include"},maxResponseBytes:65536,decode:li});return t.response.status===401?{required:false}:j(t,"consent status")}async function je(e,t){if(!Number.isSafeInteger(t)||t<1)throw new TypeError("Consent version must be a positive integer.");return j(await B(e,zn(e),{init:{method:"POST",headers:{"content-type":"application/json"},credentials:"include",body:JSON.stringify({version:t})},maxResponseBytes:64*1024,decode:di}),"consent accept")}function li(e){let t=p(e),n=b(t.required),o=pi(t.needsConsent),i=_n(t.version),a=Un(t.termsUrl),r=Un(t.privacyUrl);return {required:n,...o===void 0?{}:{needsConsent:o},...i===void 0?{}:{version:i},...a===void 0?{}:{termsUrl:a},...r===void 0?{}:{privacyUrl:r}}}function di(e){let t=p(e),n=_n(t.version);return {ok:b(t.ok),...n===void 0?{}:{version:n}}}function pi(e){if(e===void 0||typeof e=="boolean")return e;throw new TypeError("Invalid consent response.")}function _n(e){if(e===void 0||Number.isSafeInteger(e)&&e>=1)return e;throw new TypeError("Invalid consent response.")}function Un(e){if(e===void 0||typeof e=="string"&&e.length<=4096)return e;throw new TypeError("Invalid consent response.")}var fi=30;function mi(e){return typeof e?.exp=="number"?e.exp:null}function gi(e){let t=e.split(".")[1];if(!t)return null;try{let n=t.replace(/-/g,"+").replace(/_/g,"/"),o=JSON.parse(atob(n));return typeof o=="object"&&o!==null?o:null}catch{return null}}function Je(e){let t=new Map;async function n(a={}){let r=a.template===void 0?null:a.template.trim().toLowerCase();if(r==="")throw new TypeError("Template missing");let s=r??"",c=t.get(s);c||(c={activeKey:null,cachedByKey:new Map,inflight:null,sequence:0},t.set(s,c));let l=a.forceRefresh===true;if(!l){let g=c.activeKey?c.cachedByKey.get(c.activeKey):null;if(g&&g.exp-Date.now()/1e3>fi)return g.token;if(c.inflight)return c.inflight}let u=++c.sequence,f=()=>t.get(s)===c&&c.sequence===u,m=(async()=>{let g=r?`${e.projectBaseURL}/token/${encodeURIComponent(r)}`:`${e.projectBaseURL}/token`,U=await B(e,g,{init:{method:"GET",credentials:"include"},maxResponseBytes:64*1024,decode:q=>hi(q,r!==null)});if(U.response.status===401)return f()&&o(),null;let A=j(U,"token"),v=A.policyVersion,z=A.token,V=gi(z),X=mi(V);if(f())if(X!==null){let q=typeof V?.sub=="string"?V.sub:null,Re=typeof V?.org_id=="string"?V.org_id:null;if(!r||q){let Ye=JSON.stringify([e.projectBaseURL,q,Re,r,v]);c.cachedByKey.clear(),c.cachedByKey.set(Ye,{token:z,exp:X}),c.activeKey=Ye;}else i(c);}else i(c);return z})();if(l)return m;let h=m.finally(()=>{c.inflight===h&&(c.inflight=null);});return c.inflight=h,h}function o(){t.clear();}function i(a){a.cachedByKey.clear(),a.activeKey=null;}return {getToken:n,clear:o}}function hi(e,t){let n=p(e),o=w(n.token);if(o.length===0||o.length>32*1024)throw new TypeError("Invalid token response.");if(!t)return {token:o,policyVersion:0};let i=p(n.template);if(!Number.isSafeInteger(i.policyVersion)||i.policyVersion<1)throw new TypeError("Invalid token response.");return {token:o,policyVersion:i.policyVersion}}function Ai(e){let t=Je(e),n=vn(e,t.clear),o=oe(e,`${new URL(e.apiUrl).origin}/api/projects/${e.decoded.projectId}`),i=r=>(...s)=>(t.clear(),r(...s)),a={getConsentStatus:()=>Be(e),acceptConsent:r=>je(e,r),getToken:t.getToken,waitlist:{join:(r,s)=>o.request("/waitlist",{method:"POST",body:r,fetchOptions:s,credentials:"omit"})},account:{...n.account,updateUnsafeMetadata:i(n.account.updateUnsafeMetadata),updateProfile:i(n.account.updateProfile),changeEmail:i(n.account.changeEmail),changePassword:i(n.account.changePassword),revokeSession:i(n.account.revokeSession),delete:i(n.account.delete)},signIn:{email:i(n.signIn.email),username:i(n.signIn.username),social:i(n.signIn.social),sso:n.signIn.sso,magicLink:n.signIn.magicLink,emailOtp:i(n.signIn.emailOtp),passkey:i(n.signIn.passkey)},signUp:{email:i(n.signUp.email)},emailOtp:{...n.emailOtp,verifyEmail:i(n.emailOtp.verifyEmail)},twoFactor:{enable:n.twoFactor.enable,disable:i(n.twoFactor.disable),verifyTotp:i(n.twoFactor.verifyTotp),verifyBackupCode:i(n.twoFactor.verifyBackupCode),sendOtp:n.twoFactor.sendOtp,verifyOtp:i(n.twoFactor.verifyOtp),generateBackupCodes:n.twoFactor.generateBackupCodes},phoneOtp:{start:n.phoneOtp.start,verify:i(n.phoneOtp.verify)},signOut:i(n.signOut)};return {...n,...a}}async function Oi(e){let n=`${new URL(e.apiUrl).origin}/api/projects/${e.decoded.projectId}/public-config`;return j(await B(e,n,{init:{method:"GET",credentials:"omit"},maxResponseBytes:256*1024,decode:o=>yi(o,e)}),"public-config")}function yi(e,t){let n=_(e),o=n.environmentId,i=n.environmentType,a=`${new URL(t.apiUrl).origin}/api/projects/${t.decoded.projectId}/auth`;if(typeof n.applicationId!="string"||!bi(n.applicationId)||o!==t.decoded.projectId||i!=="development"&&i!=="production"||n.authBaseUrl!==a)throw C();let r=x(n.branding),s=x(n.legal);if(!Ge(n.enabledMethods,64)||!Ge(n.socialProviders,64)||!Ln(r,["appName","logoUrl","primaryColor"])||r.theme!==void 0&&r.theme!=="light"&&r.theme!=="dark"&&r.theme!=="system"||!Ln(s,["termsUrl","privacyUrl"])||!Number.isSafeInteger(s.version)||s.version<0||typeof s.required!="boolean")throw C();if(n.socialProviderClientIds!==void 0){let c=x(n.socialProviderClientIds);if(Object.keys(c).length>64||Object.values(c).some(l=>typeof l!="string"||l.length>2048))throw C()}if(!L(n,["requireEmailVerification","twoFactor","mfaRequired","accountDeletion","organizations","sso","badge"])||!Nn(n.turnstileSiteKey)||!Nn(n.authTurnstileSiteKey)||typeof n.locale!="string"||n.locale.length===0||n.locale.length>64||!Number.isSafeInteger(n.configVersion)||n.configVersion<0)throw C();if(n.jwtIssuer!==null){let c=x(n.jwtIssuer);if(c.issuer!==a||c.jwksUrl!==`${a}/jwks`||c.aud!==t.decoded.projectId)throw C()}if(n.signUp!==void 0){let c=x(n.signUp).mode;if(typeof c!="string"||!["open","restricted","allowlist","waitlist"].includes(c))throw C()}if(n.authentication!==void 0&&wi(n.authentication),n.emailVerification!==void 0){let c=x(n.emailVerification);if(!L(c,["required"])||c.method!=="link"&&c.method!=="code")throw C()}if(n.userModel!==void 0&&!L(x(n.userModel),["requireEmail","firstLastName","emailChange","accountDeletion"]))throw C();if(n.mfa!==void 0){let c=x(n.mfa);if(!L(c,["totp","required","backupCodes"])||(c.required===true||c.backupCodes===true)&&c.totp!==true)throw C()}return n}function bi(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function C(){return new TypeError("public-config returned an invalid response")}function x(e){if(!e||typeof e!="object"||Array.isArray(e))throw C();return e}function Nn(e){return e===null||typeof e=="string"&&e.length<=4096}function wi(e){let t=x(e),n=x(t.email),o=x(t.password),i=o.minLength!==void 0||o.maxLength!==void 0;if(!L(n,["signUp"])||!Ge(n.signIn,3)||n.signIn.some(a=>a!=="password"&&a!=="magic_link"&&a!=="email_otp")||!L(x(t.phone),["signUp","signIn"])||!L(o,["signUp","add"])||i&&(!Number.isSafeInteger(o.minLength)||!Number.isSafeInteger(o.maxLength)||o.minLength<1||o.maxLength>4096||o.minLength>o.maxLength)||!L(x(t.passkey),["signIn","add"])||!L(x(t.username),["collectOnSignUp","signIn"]))throw C()}function L(e,t){return t.every(n=>typeof e[n]=="boolean")}function Ln(e,t){return t.every(n=>e[n]===void 0||typeof e[n]=="string"&&e[n].length<=4096)}function Ge(e,t){return Array.isArray(e)&&e.length<=t&&e.every(n=>typeof n=="string"&&n.length<=128)&&new Set(e).size===e.length}var te=class extends Error{constructor(n,o){super(n);this.cause=o;this.name="AuthOwlError";}cause},We=class extends te{constructor(n,o){super(`Rate limited. Retry after ${n}s.`,o);this.retryAfterSeconds=n;this.name="RateLimitedError";}retryAfterSeconds},$e=class extends te{constructor(t="invalid publishable key",n){super(t,n),this.name="InvalidKeyError";}};var Mn=["en","ar"];function Ri(e){return e==="ar"?"rtl":"ltr"}function ki(e){return typeof e=="string"&&Mn.includes(e)}
|
|
3
|
+
exports.AUTH_CHALLENGE_HEADER=rt;exports.AuthOwlError=te;exports.AuthOwlHttpError=we;exports.InvalidKeyError=$e;exports.LOCALES=Mn;exports.RateLimitedError=We;exports.TransportError=T;exports.acceptConsent=je;exports.createAuthOwlClient=Ai;exports.createIdempotencyKey=Fe;exports.createMembershipHas=Yo;exports.createTokenClient=Je;exports.decodePublishableKey=ke;exports.directionFor=Ri;exports.getConsentStatus=Be;exports.getPublicConfig=Oi;exports.isLocale=ki;exports.membershipHas=Ae;exports.membershipHasPermission=he;exports.membershipHasTeam=Wt;exports.resolveConfig=Kn;exports.sessionCookieName=qn;
|