@korajs/auth 1.0.0-beta.11 → 1.0.0-beta.13
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 +52 -47
- package/dist/{create-org-session-RsDj9cl4.d.cts → create-org-session-ChFdulEM.d.cts} +211 -17
- package/dist/{create-org-session-RsDj9cl4.d.ts → create-org-session-ChFdulEM.d.ts} +211 -17
- package/dist/index.cjs +645 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -9
- package/dist/index.d.ts +27 -9
- package/dist/index.js +644 -150
- package/dist/index.js.map +1 -1
- package/dist/{operation-encryptor-DRmKNWpF.d.cts → operation-encryptor-DDdlb9bm.d.cts} +16 -0
- package/dist/{operation-encryptor-DRmKNWpF.d.ts → operation-encryptor-DDdlb9bm.d.ts} +16 -0
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/server.cjs +2852 -1675
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +779 -168
- package/dist/server.d.ts +779 -168
- package/dist/server.js +2831 -1665
- package/dist/server.js.map +1 -1
- package/dist/svelte.cjs +2 -2
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.d.cts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +2 -2
- package/dist/svelte.js.map +1 -1
- package/dist/vue.d.cts +1 -1
- package/dist/vue.d.ts +1 -1
- package/package.json +7 -7
- package/src/admin/admin-api.ts +327 -0
- package/src/admin/audit-log.ts +324 -0
- package/src/admin/webhooks.ts +576 -0
- package/src/bindings/create-auth-session.ts +184 -0
- package/src/bindings/create-org-session.ts +130 -0
- package/src/client/auth-client.ts +1592 -0
- package/src/client/auth-sync.ts +213 -0
- package/src/client/device-session.ts +104 -0
- package/src/client/org-client.ts +399 -0
- package/src/client/quickstart.ts +108 -0
- package/src/client/storage.ts +94 -0
- package/src/device/device-identity.ts +330 -0
- package/src/device/device-store.ts +379 -0
- package/src/encryption/auto-lock.ts +170 -0
- package/src/encryption/database-encryption.ts +265 -0
- package/src/encryption/key-derivation.ts +149 -0
- package/src/encryption/operation-encryptor.ts +361 -0
- package/src/index.ts +132 -0
- package/src/mfa/totp.ts +826 -0
- package/src/org/org-routes.ts +758 -0
- package/src/org/org-store.ts +490 -0
- package/src/org/org-types.ts +230 -0
- package/src/passkey/passkey-client.ts +597 -0
- package/src/passkey/passkey-server.ts +779 -0
- package/src/postgres/ensure-schema.ts +65 -0
- package/src/provider/adapter.ts +246 -0
- package/src/provider/built-in/auth-routes.ts +1313 -0
- package/src/provider/built-in/email-verification.ts +303 -0
- package/src/provider/built-in/password-hash.ts +118 -0
- package/src/provider/built-in/password-reset.ts +416 -0
- package/src/provider/built-in/postgres-user-store.ts +328 -0
- package/src/provider/built-in/quickstart-server.ts +760 -0
- package/src/provider/built-in/sqlite-user-store.ts +322 -0
- package/src/provider/built-in/sync-scopes.ts +85 -0
- package/src/provider/built-in/user-store.ts +465 -0
- package/src/provider/external/clerk-adapter.ts +157 -0
- package/src/provider/external/external-jwt-provider.ts +491 -0
- package/src/provider/external/supabase-adapter.ts +163 -0
- package/src/provider/oauth/linked-identity-store.ts +108 -0
- package/src/provider/oauth/oauth-flow.ts +550 -0
- package/src/provider/oauth/oauth-types.ts +184 -0
- package/src/provider/oauth/postgres-oauth-store.ts +296 -0
- package/src/provider/oauth/sqlite-oauth-store.ts +272 -0
- package/src/rbac/rbac-engine.ts +323 -0
- package/src/rbac/rbac-types.ts +210 -0
- package/src/rbac/scope-resolver.ts +140 -0
- package/src/react/AuthProvider.tsx +97 -0
- package/src/react/OrgProvider.tsx +41 -0
- package/src/react/auth-context.ts +26 -0
- package/src/react/hooks.ts +110 -0
- package/src/react/org-hooks.ts +214 -0
- package/src/react.ts +26 -0
- package/src/server.ts +334 -0
- package/src/session/session.ts +401 -0
- package/src/svelte/auth-context.ts +50 -0
- package/src/svelte/org-context.ts +32 -0
- package/src/svelte/org-hooks.ts +201 -0
- package/src/svelte/use-auth.ts +115 -0
- package/src/svelte.ts +25 -0
- package/src/tokens/encrypted-token-store.ts +360 -0
- package/src/tokens/jwt.ts +236 -0
- package/src/tokens/postgres-token-revocation-store.ts +140 -0
- package/src/tokens/sqlite-token-revocation-store.ts +121 -0
- package/src/tokens/token-manager.ts +821 -0
- package/src/tokens/token-store.ts +192 -0
- package/src/types.ts +394 -0
- package/src/vue/auth-context.ts +10 -0
- package/src/vue/auth-provider-types.ts +5 -0
- package/src/vue/auth-provider.ts +76 -0
- package/src/vue/org-hooks.ts +193 -0
- package/src/vue/org-provider.ts +49 -0
- package/src/vue/use-auth.ts +139 -0
- package/src/vue.ts +10 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
useSyncExternalStore,
|
|
9
|
+
} from 'react'
|
|
10
|
+
import {
|
|
11
|
+
type OrgSession,
|
|
12
|
+
type OrgSnapshot,
|
|
13
|
+
checkOrgPermission,
|
|
14
|
+
createOrgMembersActions,
|
|
15
|
+
createOrgSession,
|
|
16
|
+
loadOrgMembers,
|
|
17
|
+
} from '../bindings/create-org-session'
|
|
18
|
+
import type {
|
|
19
|
+
ClientInvitation,
|
|
20
|
+
ClientMembership,
|
|
21
|
+
ClientOrganization,
|
|
22
|
+
OrgClient,
|
|
23
|
+
} from '../client/org-client'
|
|
24
|
+
|
|
25
|
+
export interface OrgContextValue {
|
|
26
|
+
client: OrgClient
|
|
27
|
+
session: OrgSession
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const OrgContext = createContext<OrgContextValue | null>(null)
|
|
31
|
+
|
|
32
|
+
function useOrgContext(): OrgContextValue {
|
|
33
|
+
const ctx = useContext(OrgContext)
|
|
34
|
+
if (ctx === null) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
'useOrg / useOrgMembers / usePermission must be used within an <OrgProvider>. ' +
|
|
37
|
+
'Wrap your component tree with <OrgProvider client={orgClient}>.',
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
return ctx
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function useOrgSnapshot(session: OrgSession): OrgSnapshot {
|
|
44
|
+
const snapshotRef = useRef(session.getSnapshot())
|
|
45
|
+
|
|
46
|
+
const subscribe = useCallback(
|
|
47
|
+
(onStoreChange: () => void): (() => void) => {
|
|
48
|
+
return session.subscribe(() => {
|
|
49
|
+
snapshotRef.current = session.getSnapshot()
|
|
50
|
+
onStoreChange()
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
[session],
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const getSnapshot = useCallback(() => snapshotRef.current, [])
|
|
57
|
+
|
|
58
|
+
return useSyncExternalStore(subscribe, getSnapshot)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface UseOrgResult {
|
|
62
|
+
org: ClientOrganization | null
|
|
63
|
+
role: string | null
|
|
64
|
+
orgId: string | null
|
|
65
|
+
switchOrg: (orgId: string) => Promise<void>
|
|
66
|
+
createOrg: (params: { name: string; slug?: string }) => Promise<ClientOrganization>
|
|
67
|
+
leaveOrg: () => Promise<void>
|
|
68
|
+
clearOrg: () => void
|
|
69
|
+
listOrgs: () => Promise<ClientOrganization[]>
|
|
70
|
+
error: string | null
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function useOrg(): UseOrgResult {
|
|
74
|
+
const { client, session } = useOrgContext()
|
|
75
|
+
const { orgId, org, role } = useOrgSnapshot(session)
|
|
76
|
+
const [error, setError] = useState<string | null>(null)
|
|
77
|
+
|
|
78
|
+
const switchOrg = useCallback(
|
|
79
|
+
async (newOrgId: string): Promise<void> => {
|
|
80
|
+
setError(null)
|
|
81
|
+
try {
|
|
82
|
+
await client.switchOrg(newOrgId)
|
|
83
|
+
} catch (err) {
|
|
84
|
+
setError(err instanceof Error ? err.message : String(err))
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
[client],
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
const createOrg = useCallback(
|
|
91
|
+
async (params: { name: string; slug?: string }): Promise<ClientOrganization> => {
|
|
92
|
+
setError(null)
|
|
93
|
+
try {
|
|
94
|
+
return await client.createOrg(params)
|
|
95
|
+
} catch (err) {
|
|
96
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
97
|
+
setError(msg)
|
|
98
|
+
throw err
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
[client],
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
const leaveOrg = useCallback(async (): Promise<void> => {
|
|
105
|
+
if (!orgId) return
|
|
106
|
+
setError(null)
|
|
107
|
+
try {
|
|
108
|
+
await client.leaveOrg(orgId)
|
|
109
|
+
} catch (err) {
|
|
110
|
+
setError(err instanceof Error ? err.message : String(err))
|
|
111
|
+
}
|
|
112
|
+
}, [client, orgId])
|
|
113
|
+
|
|
114
|
+
const clearOrg = useCallback((): void => {
|
|
115
|
+
client.clearActiveOrg()
|
|
116
|
+
}, [client])
|
|
117
|
+
|
|
118
|
+
const listOrgs = useCallback(async (): Promise<ClientOrganization[]> => {
|
|
119
|
+
try {
|
|
120
|
+
return await client.listOrgs()
|
|
121
|
+
} catch (err) {
|
|
122
|
+
setError(err instanceof Error ? err.message : String(err))
|
|
123
|
+
return []
|
|
124
|
+
}
|
|
125
|
+
}, [client])
|
|
126
|
+
|
|
127
|
+
return { org, role, orgId, switchOrg, createOrg, leaveOrg, clearOrg, listOrgs, error }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface UseOrgMembersResult {
|
|
131
|
+
members: ClientMembership[]
|
|
132
|
+
isLoading: boolean
|
|
133
|
+
refresh: () => Promise<void>
|
|
134
|
+
invite: (email: string, role: string) => Promise<ClientInvitation>
|
|
135
|
+
removeMember: (userId: string) => Promise<void>
|
|
136
|
+
updateRole: (userId: string, role: string) => Promise<void>
|
|
137
|
+
error: string | null
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function useOrgMembers(orgId: string): UseOrgMembersResult {
|
|
141
|
+
const { client } = useOrgContext()
|
|
142
|
+
const [members, setMembers] = useState<ClientMembership[]>([])
|
|
143
|
+
const [isLoading, setIsLoading] = useState(true)
|
|
144
|
+
const [error, setError] = useState<string | null>(null)
|
|
145
|
+
|
|
146
|
+
const refresh = useCallback(async () => {
|
|
147
|
+
setIsLoading(true)
|
|
148
|
+
setError(null)
|
|
149
|
+
try {
|
|
150
|
+
setMembers(await loadOrgMembers(client, orgId))
|
|
151
|
+
} catch (err) {
|
|
152
|
+
setError(err instanceof Error ? err.message : String(err))
|
|
153
|
+
} finally {
|
|
154
|
+
setIsLoading(false)
|
|
155
|
+
}
|
|
156
|
+
}, [client, orgId])
|
|
157
|
+
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
void refresh()
|
|
160
|
+
}, [refresh])
|
|
161
|
+
|
|
162
|
+
const actions = createOrgMembersActions(client, orgId, setError)
|
|
163
|
+
|
|
164
|
+
const invite = useCallback(
|
|
165
|
+
async (email: string, role: string): Promise<ClientInvitation> => {
|
|
166
|
+
const result = await actions.invite(email, role)
|
|
167
|
+
await refresh()
|
|
168
|
+
return result
|
|
169
|
+
},
|
|
170
|
+
[actions, refresh],
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
const removeMember = useCallback(
|
|
174
|
+
async (userId: string): Promise<void> => {
|
|
175
|
+
await actions.removeMember(userId)
|
|
176
|
+
await refresh()
|
|
177
|
+
},
|
|
178
|
+
[actions, refresh],
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
const updateRole = useCallback(
|
|
182
|
+
async (userId: string, role: string): Promise<void> => {
|
|
183
|
+
await actions.updateRole(userId, role)
|
|
184
|
+
await refresh()
|
|
185
|
+
},
|
|
186
|
+
[actions, refresh],
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
return { members, isLoading, refresh, invite, removeMember, updateRole, error }
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function usePermission(requiredRole: string): boolean {
|
|
193
|
+
const { session } = useOrgContext()
|
|
194
|
+
const snapshotRef = useRef(session.checkPermission(requiredRole))
|
|
195
|
+
|
|
196
|
+
const subscribe = useCallback(
|
|
197
|
+
(onStoreChange: () => void): (() => void) => {
|
|
198
|
+
return session.subscribe(() => {
|
|
199
|
+
const next = session.checkPermission(requiredRole)
|
|
200
|
+
if (next !== snapshotRef.current) {
|
|
201
|
+
snapshotRef.current = next
|
|
202
|
+
onStoreChange()
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
},
|
|
206
|
+
[session, requiredRole],
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
const getSnapshot = useCallback(() => snapshotRef.current, [])
|
|
210
|
+
|
|
211
|
+
return useSyncExternalStore(subscribe, getSnapshot)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export { checkOrgPermission }
|
package/src/react.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @korajs/auth/react — React-specific public API
|
|
2
|
+
// Every export here is a public API commitment. Be explicit.
|
|
3
|
+
|
|
4
|
+
// === Provider ===
|
|
5
|
+
export { AuthProvider } from './react/AuthProvider'
|
|
6
|
+
export type { AuthProviderProps } from './react/AuthProvider'
|
|
7
|
+
|
|
8
|
+
// === Hooks ===
|
|
9
|
+
export { useAuth, useCurrentUser, useAuthStatus } from './react/hooks'
|
|
10
|
+
export type { UseAuthResult, AuthStatus } from './react/hooks'
|
|
11
|
+
|
|
12
|
+
// === Context (for advanced use cases) ===
|
|
13
|
+
export { AuthContext } from './react/auth-context'
|
|
14
|
+
export type { AuthContextValue } from './react/auth-context'
|
|
15
|
+
|
|
16
|
+
// === Organization Hooks ===
|
|
17
|
+
export { OrgProvider } from './react/OrgProvider'
|
|
18
|
+
export type { OrgProviderProps } from './react/OrgProvider'
|
|
19
|
+
export {
|
|
20
|
+
OrgContext,
|
|
21
|
+
useOrg,
|
|
22
|
+
useOrgMembers,
|
|
23
|
+
usePermission,
|
|
24
|
+
checkOrgPermission,
|
|
25
|
+
} from './react/org-hooks'
|
|
26
|
+
export type { OrgContextValue, UseOrgResult, UseOrgMembersResult } from './react/org-hooks'
|
package/src/server.ts
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
// @korajs/auth/server — Server-side public API
|
|
2
|
+
// Every export here is a public API commitment. Be explicit.
|
|
3
|
+
|
|
4
|
+
// === Auth Routes (built-in email/password provider) ===
|
|
5
|
+
export {
|
|
6
|
+
BuiltInAuthRoutes,
|
|
7
|
+
InMemoryChallengeStore,
|
|
8
|
+
InMemoryRateLimiter,
|
|
9
|
+
} from './provider/built-in/auth-routes'
|
|
10
|
+
export type {
|
|
11
|
+
AuthenticatedAccess,
|
|
12
|
+
AuthRevocationEvent,
|
|
13
|
+
MfaChallenge,
|
|
14
|
+
MfaVerifier,
|
|
15
|
+
SignInResult,
|
|
16
|
+
AuthRoutesConfig,
|
|
17
|
+
AuthRouteResponse,
|
|
18
|
+
ChallengeStore,
|
|
19
|
+
RateLimiter,
|
|
20
|
+
} from './provider/built-in/auth-routes'
|
|
21
|
+
export {
|
|
22
|
+
createKoraAuthServer,
|
|
23
|
+
InMemoryAuthStoreError,
|
|
24
|
+
} from './provider/built-in/quickstart-server'
|
|
25
|
+
export type {
|
|
26
|
+
CreateKoraAuthServerOptions,
|
|
27
|
+
KoraAuthHttpRequest,
|
|
28
|
+
KoraAuthServer,
|
|
29
|
+
OAuthServerConfig,
|
|
30
|
+
SyncSessionTerminator,
|
|
31
|
+
} from './provider/built-in/quickstart-server'
|
|
32
|
+
export type {
|
|
33
|
+
SyncAuthContext,
|
|
34
|
+
SyncAuthProvider,
|
|
35
|
+
SyncScopeOptions,
|
|
36
|
+
VerifiedSyncClaims,
|
|
37
|
+
} from './provider/built-in/sync-scopes'
|
|
38
|
+
|
|
39
|
+
// === Token Manager ===
|
|
40
|
+
export {
|
|
41
|
+
DEFAULT_REFRESH_REUSE_GRACE_MS,
|
|
42
|
+
InMemoryTokenRevocationStore,
|
|
43
|
+
TokenManager,
|
|
44
|
+
} from './tokens/token-manager'
|
|
45
|
+
export type {
|
|
46
|
+
ConsumeResult,
|
|
47
|
+
MfaPendingPayload,
|
|
48
|
+
IssueTokenOptions,
|
|
49
|
+
RefreshFailureReason,
|
|
50
|
+
RefreshResult,
|
|
51
|
+
TokenManagerConfig,
|
|
52
|
+
TokenRevocationStore,
|
|
53
|
+
} from './tokens/token-manager'
|
|
54
|
+
export { SqliteTokenRevocationStore } from './tokens/sqlite-token-revocation-store'
|
|
55
|
+
export type { SqliteRevocationDatabase } from './tokens/sqlite-token-revocation-store'
|
|
56
|
+
export { PostgresTokenRevocationStore } from './tokens/postgres-token-revocation-store'
|
|
57
|
+
export type { PostgresRevocationClient } from './tokens/postgres-token-revocation-store'
|
|
58
|
+
|
|
59
|
+
// === JWT Utilities ===
|
|
60
|
+
export { encodeJwt, decodeJwt, verifyJwt, isExpired } from './tokens/jwt'
|
|
61
|
+
|
|
62
|
+
// === Password Hashing ===
|
|
63
|
+
export { hashPassword, verifyPassword } from './provider/built-in/password-hash'
|
|
64
|
+
|
|
65
|
+
// === Password Reset ===
|
|
66
|
+
export {
|
|
67
|
+
PasswordResetManager,
|
|
68
|
+
InMemoryPasswordResetStore,
|
|
69
|
+
PasswordResetError,
|
|
70
|
+
ResetTokenExpiredError,
|
|
71
|
+
ResetTokenNotFoundError,
|
|
72
|
+
ResetRateLimitedError,
|
|
73
|
+
} from './provider/built-in/password-reset'
|
|
74
|
+
export type {
|
|
75
|
+
PasswordResetToken,
|
|
76
|
+
PasswordResetStore,
|
|
77
|
+
PasswordResetConfig,
|
|
78
|
+
} from './provider/built-in/password-reset'
|
|
79
|
+
|
|
80
|
+
// === Email Verification ===
|
|
81
|
+
export {
|
|
82
|
+
EmailVerificationManager,
|
|
83
|
+
InMemoryEmailVerificationStore,
|
|
84
|
+
EmailVerificationError,
|
|
85
|
+
VerificationTokenExpiredError,
|
|
86
|
+
VerificationTokenNotFoundError,
|
|
87
|
+
} from './provider/built-in/email-verification'
|
|
88
|
+
export type {
|
|
89
|
+
EmailVerificationToken,
|
|
90
|
+
EmailVerificationStore,
|
|
91
|
+
EmailVerificationConfig,
|
|
92
|
+
} from './provider/built-in/email-verification'
|
|
93
|
+
|
|
94
|
+
// === User Store ===
|
|
95
|
+
export {
|
|
96
|
+
InMemoryUserStore,
|
|
97
|
+
DeviceOwnershipError,
|
|
98
|
+
DuplicateEmailError,
|
|
99
|
+
} from './provider/built-in/user-store'
|
|
100
|
+
export type { UserStore, AuthUser, StoredUser, AuthDevice } from './provider/built-in/user-store'
|
|
101
|
+
|
|
102
|
+
// === SQLite User Store ===
|
|
103
|
+
export { SqliteUserStore, createSqliteUserStore } from './provider/built-in/sqlite-user-store'
|
|
104
|
+
|
|
105
|
+
// === PostgreSQL User Store ===
|
|
106
|
+
export { PostgresUserStore, createPostgresUserStore } from './provider/built-in/postgres-user-store'
|
|
107
|
+
|
|
108
|
+
// === Provider Adapter ===
|
|
109
|
+
export { BuiltInProvider, AuthProviderError } from './provider/adapter'
|
|
110
|
+
export type { AuthProviderAdapter, SignUpParams, SignInParams } from './provider/adapter'
|
|
111
|
+
|
|
112
|
+
// === External Auth Provider Adapters ===
|
|
113
|
+
export {
|
|
114
|
+
ExternalJwtProvider,
|
|
115
|
+
ExternalAuthOperationNotSupportedError,
|
|
116
|
+
ExternalTokenValidationError,
|
|
117
|
+
} from './provider/external/external-jwt-provider'
|
|
118
|
+
export type {
|
|
119
|
+
ExternalJwtProviderConfig,
|
|
120
|
+
ExternalUserInfo,
|
|
121
|
+
} from './provider/external/external-jwt-provider'
|
|
122
|
+
|
|
123
|
+
export { createClerkAdapter } from './provider/external/clerk-adapter'
|
|
124
|
+
export type { ClerkAdapterConfig } from './provider/external/clerk-adapter'
|
|
125
|
+
|
|
126
|
+
export { createSupabaseAdapter } from './provider/external/supabase-adapter'
|
|
127
|
+
export type { SupabaseAdapterConfig } from './provider/external/supabase-adapter'
|
|
128
|
+
|
|
129
|
+
// === Passkey / WebAuthn (server-side verification) ===
|
|
130
|
+
export {
|
|
131
|
+
generateRegistrationOptions,
|
|
132
|
+
verifyRegistrationResponse,
|
|
133
|
+
generateAuthenticationOptions,
|
|
134
|
+
verifyAuthenticationResponse,
|
|
135
|
+
PasskeyVerificationError,
|
|
136
|
+
} from './passkey/passkey-server'
|
|
137
|
+
export type {
|
|
138
|
+
RegistrationOptions,
|
|
139
|
+
RegistrationVerificationResult,
|
|
140
|
+
AuthenticationOptions,
|
|
141
|
+
AuthenticationVerificationResult,
|
|
142
|
+
} from './passkey/passkey-server'
|
|
143
|
+
|
|
144
|
+
// === E2E Operation Encryption (server-side: detect encrypted fields) ===
|
|
145
|
+
export {
|
|
146
|
+
OperationEncryptor,
|
|
147
|
+
OperationEncryptionError,
|
|
148
|
+
isEncryptedField,
|
|
149
|
+
} from './encryption/operation-encryptor'
|
|
150
|
+
export type { OperationEncryptorConfig } from './encryption/operation-encryptor'
|
|
151
|
+
|
|
152
|
+
// === Organizations & Memberships ===
|
|
153
|
+
export { OrgRoutes } from './org/org-routes'
|
|
154
|
+
export type { OrgRouteResponse, OrgRoutesConfig } from './org/org-routes'
|
|
155
|
+
export { InMemoryOrgStore } from './org/org-store'
|
|
156
|
+
export type { OrgStore } from './org/org-store'
|
|
157
|
+
export {
|
|
158
|
+
OrgError,
|
|
159
|
+
OrgNotFoundError,
|
|
160
|
+
OrgSlugTakenError,
|
|
161
|
+
MembershipNotFoundError,
|
|
162
|
+
MemberAlreadyExistsError,
|
|
163
|
+
InsufficientRoleError,
|
|
164
|
+
CannotRemoveOwnerError,
|
|
165
|
+
InvitationNotFoundError,
|
|
166
|
+
InvitationExpiredError,
|
|
167
|
+
hasRoleLevel,
|
|
168
|
+
ROLE_HIERARCHY,
|
|
169
|
+
ORG_ROLES,
|
|
170
|
+
INVITATION_STATUSES,
|
|
171
|
+
} from './org/org-types'
|
|
172
|
+
export type {
|
|
173
|
+
Organization,
|
|
174
|
+
CreateOrgParams,
|
|
175
|
+
UpdateOrgParams,
|
|
176
|
+
Membership,
|
|
177
|
+
OrgRole,
|
|
178
|
+
OrgInvitation,
|
|
179
|
+
CreateInvitationParams,
|
|
180
|
+
InvitationStatus,
|
|
181
|
+
} from './org/org-types'
|
|
182
|
+
|
|
183
|
+
// === RBAC (Role-Based Access Control) ===
|
|
184
|
+
export { RbacEngine, defineRoles } from './rbac/rbac-engine'
|
|
185
|
+
export {
|
|
186
|
+
BUILT_IN_ROLES,
|
|
187
|
+
parsePermission,
|
|
188
|
+
permissionCovers,
|
|
189
|
+
RbacError,
|
|
190
|
+
InvalidPermissionError,
|
|
191
|
+
RoleNotFoundError,
|
|
192
|
+
CircularInheritanceError,
|
|
193
|
+
} from './rbac/rbac-types'
|
|
194
|
+
export type {
|
|
195
|
+
Permission,
|
|
196
|
+
RoleDefinition,
|
|
197
|
+
RbacConfig,
|
|
198
|
+
SyncScopes,
|
|
199
|
+
ScopeFilter,
|
|
200
|
+
ScopeContext,
|
|
201
|
+
CollectionScopeResolver,
|
|
202
|
+
} from './rbac/rbac-types'
|
|
203
|
+
|
|
204
|
+
// === Org Scope Resolver ===
|
|
205
|
+
export { OrgScopeResolver } from './rbac/scope-resolver'
|
|
206
|
+
|
|
207
|
+
// === OAuth / Social Login ===
|
|
208
|
+
export {
|
|
209
|
+
OAuthManager,
|
|
210
|
+
InMemoryOAuthStateStore,
|
|
211
|
+
googleProvider,
|
|
212
|
+
githubProvider,
|
|
213
|
+
microsoftProvider,
|
|
214
|
+
} from './provider/oauth/oauth-flow'
|
|
215
|
+
export type { OAuthManagerConfig } from './provider/oauth/oauth-flow'
|
|
216
|
+
export {
|
|
217
|
+
DuplicateLinkedIdentityError,
|
|
218
|
+
InMemoryLinkedIdentityStore,
|
|
219
|
+
} from './provider/oauth/linked-identity-store'
|
|
220
|
+
export type { LinkedIdentityStore } from './provider/oauth/linked-identity-store'
|
|
221
|
+
export {
|
|
222
|
+
SqliteLinkedIdentityStore,
|
|
223
|
+
SqliteOAuthStateStore,
|
|
224
|
+
createSqliteLinkedIdentityStore,
|
|
225
|
+
createSqliteOAuthStateStore,
|
|
226
|
+
createSqliteOAuthStores,
|
|
227
|
+
} from './provider/oauth/sqlite-oauth-store'
|
|
228
|
+
export {
|
|
229
|
+
PostgresLinkedIdentityStore,
|
|
230
|
+
PostgresOAuthStateStore,
|
|
231
|
+
createPostgresLinkedIdentityStore,
|
|
232
|
+
createPostgresOAuthStateStore,
|
|
233
|
+
createPostgresOAuthStores,
|
|
234
|
+
} from './provider/oauth/postgres-oauth-store'
|
|
235
|
+
export {
|
|
236
|
+
OAuthError,
|
|
237
|
+
OAuthStateMismatchError,
|
|
238
|
+
OAuthCodeExchangeError,
|
|
239
|
+
OAuthUserInfoError,
|
|
240
|
+
OAuthProviderNotFoundError,
|
|
241
|
+
} from './provider/oauth/oauth-types'
|
|
242
|
+
export type {
|
|
243
|
+
OAuthProviderConfig,
|
|
244
|
+
OAuthTokens,
|
|
245
|
+
OAuthUserInfo,
|
|
246
|
+
OAuthState,
|
|
247
|
+
OAuthStateStore,
|
|
248
|
+
LinkedIdentity,
|
|
249
|
+
} from './provider/oauth/oauth-types'
|
|
250
|
+
|
|
251
|
+
// === Session Management ===
|
|
252
|
+
export {
|
|
253
|
+
SessionManager,
|
|
254
|
+
InMemorySessionStore,
|
|
255
|
+
SessionError,
|
|
256
|
+
SessionNotFoundError,
|
|
257
|
+
SessionExpiredError,
|
|
258
|
+
SessionLimitExceededError,
|
|
259
|
+
SessionMfaRequiredError,
|
|
260
|
+
} from './session/session'
|
|
261
|
+
export type {
|
|
262
|
+
Session,
|
|
263
|
+
SessionManagerConfig,
|
|
264
|
+
CreateSessionParams,
|
|
265
|
+
SessionStore,
|
|
266
|
+
} from './session/session'
|
|
267
|
+
|
|
268
|
+
// === TOTP MFA ===
|
|
269
|
+
export {
|
|
270
|
+
TotpManager,
|
|
271
|
+
InMemoryTotpStore,
|
|
272
|
+
base32Encode,
|
|
273
|
+
base32Decode,
|
|
274
|
+
TotpError,
|
|
275
|
+
TotpInvalidCodeError,
|
|
276
|
+
TotpLockedError,
|
|
277
|
+
TotpNotEnabledError,
|
|
278
|
+
TotpAlreadyEnabledError,
|
|
279
|
+
TotpNotVerifiedError,
|
|
280
|
+
TotpRecoveryExhaustedError,
|
|
281
|
+
} from './mfa/totp'
|
|
282
|
+
export type {
|
|
283
|
+
TotpConfig,
|
|
284
|
+
TotpSecret,
|
|
285
|
+
TotpSetupResult,
|
|
286
|
+
TotpStore,
|
|
287
|
+
} from './mfa/totp'
|
|
288
|
+
|
|
289
|
+
// === Admin API ===
|
|
290
|
+
export {
|
|
291
|
+
AdminApi,
|
|
292
|
+
AdminApiError,
|
|
293
|
+
AdminUserNotFoundError,
|
|
294
|
+
AdminUnauthorizedError,
|
|
295
|
+
} from './admin/admin-api'
|
|
296
|
+
export type {
|
|
297
|
+
AdminApiConfig,
|
|
298
|
+
PaginatedResult,
|
|
299
|
+
UserListQuery,
|
|
300
|
+
AdminUserUpdate,
|
|
301
|
+
} from './admin/admin-api'
|
|
302
|
+
|
|
303
|
+
// === Audit Logging ===
|
|
304
|
+
export {
|
|
305
|
+
AuditLogger,
|
|
306
|
+
InMemoryAuditLogStore,
|
|
307
|
+
AuditLogError,
|
|
308
|
+
} from './admin/audit-log'
|
|
309
|
+
export type {
|
|
310
|
+
AuditAction,
|
|
311
|
+
AuditEntry,
|
|
312
|
+
AuditLogQuery,
|
|
313
|
+
AuditLogStore,
|
|
314
|
+
} from './admin/audit-log'
|
|
315
|
+
|
|
316
|
+
// === Webhooks ===
|
|
317
|
+
export {
|
|
318
|
+
WebhookManager,
|
|
319
|
+
InMemoryWebhookStore,
|
|
320
|
+
verifyWebhookSignature,
|
|
321
|
+
WebhookError,
|
|
322
|
+
WebhookEndpointNotFoundError,
|
|
323
|
+
WebhookTargetError,
|
|
324
|
+
} from './admin/webhooks'
|
|
325
|
+
export type {
|
|
326
|
+
WebhookEvent,
|
|
327
|
+
WebhookEndpoint,
|
|
328
|
+
WebhookDelivery,
|
|
329
|
+
WebhookPayload,
|
|
330
|
+
WebhookStore,
|
|
331
|
+
} from './admin/webhooks'
|
|
332
|
+
|
|
333
|
+
// === Device Identity (verification on server) ===
|
|
334
|
+
export { verifyChallenge, computePublicKeyThumbprint } from './device/device-identity'
|