@korajs/auth 1.0.0-beta.13 → 1.0.0-beta.14
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/dist/server.cjs +38 -2
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +32 -2
- package/dist/server.d.ts +32 -2
- package/dist/server.js +38 -2
- package/dist/server.js.map +1 -1
- package/package.json +5 -5
- package/src/provider/built-in/postgres-user-store.ts +39 -2
- package/src/provider/built-in/sqlite-user-store.ts +13 -0
- package/src/provider/oauth/sqlite-oauth-store.ts +13 -0
- package/src/server.ts +5 -1
package/dist/server.d.cts
CHANGED
|
@@ -2177,6 +2177,19 @@ declare function createSqliteUserStore(options: {
|
|
|
2177
2177
|
interface PostgresClient$1 {
|
|
2178
2178
|
begin<T>(fn: (sql: PostgresClient$1) => Promise<T>): Promise<T>;
|
|
2179
2179
|
(template: TemplateStringsArray, ...args: unknown[]): Promise<Record<string, unknown>[]>;
|
|
2180
|
+
/** postgres-js: close every connection of the pool (optional in this subset). */
|
|
2181
|
+
end?(options?: {
|
|
2182
|
+
timeout?: number;
|
|
2183
|
+
}): Promise<void>;
|
|
2184
|
+
}
|
|
2185
|
+
/** Options for {@link PostgresUserStore}. */
|
|
2186
|
+
interface PostgresUserStoreOptions {
|
|
2187
|
+
/**
|
|
2188
|
+
* Whether {@link PostgresUserStore.close} ends the client's connections. True for
|
|
2189
|
+
* a store made by `createPostgresUserStore` (it opened the client); false by
|
|
2190
|
+
* default for a client you pass in, which you end yourself.
|
|
2191
|
+
*/
|
|
2192
|
+
ownsClient?: boolean;
|
|
2180
2193
|
}
|
|
2181
2194
|
/**
|
|
2182
2195
|
* PostgreSQL-backed user and device store using postgres-js.
|
|
@@ -2196,13 +2209,30 @@ interface PostgresClient$1 {
|
|
|
2196
2209
|
* connectionString: 'postgres://user:pass@localhost:5432/mydb',
|
|
2197
2210
|
* })
|
|
2198
2211
|
* const routes = new BuiltInAuthRoutes({ userStore, tokenManager })
|
|
2212
|
+
* // On shutdown (or at the end of a script):
|
|
2213
|
+
* await userStore.close()
|
|
2199
2214
|
* ```
|
|
2200
2215
|
*/
|
|
2201
2216
|
declare class PostgresUserStore implements UserStore {
|
|
2202
2217
|
private readonly sql;
|
|
2203
2218
|
private readonly ready;
|
|
2204
2219
|
private revocationStore;
|
|
2205
|
-
|
|
2220
|
+
private readonly ownsClient;
|
|
2221
|
+
private closed;
|
|
2222
|
+
constructor(sql: PostgresClient$1, options?: PostgresUserStoreOptions);
|
|
2223
|
+
/**
|
|
2224
|
+
* Release the store's database connections, so a script using it can exit. Waits
|
|
2225
|
+
* for table creation to settle first. A client passed to the constructor is left
|
|
2226
|
+
* open unless `ownsClient` was set (end it yourself). Idempotent.
|
|
2227
|
+
*
|
|
2228
|
+
* @example
|
|
2229
|
+
* ```typescript
|
|
2230
|
+
* const users = await createPostgresUserStore({ connectionString })
|
|
2231
|
+
* const device = await users.findDevice(nodeId)
|
|
2232
|
+
* await users.close()
|
|
2233
|
+
* ```
|
|
2234
|
+
*/
|
|
2235
|
+
close(): Promise<void>;
|
|
2206
2236
|
/** Token revocations stored in the same Postgres database as the users. */
|
|
2207
2237
|
getTokenRevocationStore(): TokenRevocationStore;
|
|
2208
2238
|
private ensureTables;
|
|
@@ -4810,4 +4840,4 @@ declare function verifyWebhookSignature(payload: string, signature: string, secr
|
|
|
4810
4840
|
toleranceSeconds?: number;
|
|
4811
4841
|
}): Promise<boolean>;
|
|
4812
4842
|
|
|
4813
|
-
export { AdminApi, type AdminApiConfig, AdminApiError, AdminUnauthorizedError, AdminUserNotFoundError, type AdminUserUpdate, type AuditAction, type AuditEntry, AuditLogError, type AuditLogQuery, type AuditLogStore, AuditLogger, type AuthDevice, type AuthProviderAdapter, AuthProviderError, type AuthRevocationEvent, type AuthRouteResponse, type AuthRoutesConfig, type AuthUser, type AuthenticatedAccess, type AuthenticationOptions, type AuthenticationVerificationResult, BUILT_IN_ROLES, BuiltInAuthRoutes, BuiltInProvider, CannotRemoveOwnerError, type ChallengeStore, CircularInheritanceError, type ClerkAdapterConfig, type CollectionScopeResolver, type ConsumeResult, type CreateInvitationParams, type CreateKoraAuthServerOptions, type CreateOrgParams, type CreateSessionParams, DEFAULT_REFRESH_REUSE_GRACE_MS, DeviceOwnershipError, DuplicateEmailError, DuplicateLinkedIdentityError, type EmailVerificationConfig, EmailVerificationError, EmailVerificationManager, type EmailVerificationStore, type EmailVerificationToken, ExternalAuthOperationNotSupportedError, ExternalJwtProvider, type ExternalJwtProviderConfig, ExternalTokenValidationError, type ExternalUserInfo, INVITATION_STATUSES, InMemoryAuditLogStore, InMemoryAuthStoreError, InMemoryChallengeStore, InMemoryEmailVerificationStore, InMemoryLinkedIdentityStore, InMemoryOAuthStateStore, InMemoryOrgStore, InMemoryPasswordResetStore, InMemoryRateLimiter, InMemorySessionStore, InMemoryTokenRevocationStore, InMemoryTotpStore, InMemoryUserStore, InMemoryWebhookStore, InsufficientRoleError, InvalidPermissionError, InvitationExpiredError, InvitationNotFoundError, type InvitationStatus, type IssueTokenOptions, type KoraAuthHttpRequest, type KoraAuthServer, type LinkedIdentity, type LinkedIdentityStore, MemberAlreadyExistsError, type Membership, MembershipNotFoundError, type MfaChallenge, type MfaPendingPayload, type MfaVerifier, OAuthCodeExchangeError, OAuthError, OAuthManager, type OAuthManagerConfig, type OAuthProviderConfig, OAuthProviderNotFoundError, type OAuthServerConfig, type OAuthState, OAuthStateMismatchError, type OAuthStateStore, type OAuthTokens, type OAuthUserInfo, OAuthUserInfoError, ORG_ROLES, OrgError, type OrgInvitation, OrgNotFoundError, type OrgRole, type OrgRouteResponse, OrgRoutes, type OrgRoutesConfig, OrgScopeResolver, OrgSlugTakenError, type OrgStore, type Organization, type PaginatedResult, PasskeyVerificationError, type PasswordResetConfig, PasswordResetError, PasswordResetManager, type PasswordResetStore, type PasswordResetToken, type Permission, PostgresLinkedIdentityStore, PostgresOAuthStateStore, type PostgresRevocationClient, PostgresTokenRevocationStore, PostgresUserStore, ROLE_HIERARCHY, type RateLimiter, type RbacConfig, RbacEngine, RbacError, type RefreshFailureReason, type RefreshResult, type RegistrationOptions, type RegistrationVerificationResult, ResetRateLimitedError, ResetTokenExpiredError, ResetTokenNotFoundError, type RoleDefinition, RoleNotFoundError, type ScopeContext, type ScopeFilter, type Session, SessionError, SessionExpiredError, SessionLimitExceededError, SessionManager, type SessionManagerConfig, SessionMfaRequiredError, SessionNotFoundError, type SessionStore, type SignInParams, type SignInResult, type SignUpParams, SqliteLinkedIdentityStore, SqliteOAuthStateStore, type SqliteRevocationDatabase, SqliteTokenRevocationStore, SqliteUserStore, type StoredUser, type SupabaseAdapterConfig, type SyncAuthContext, type SyncAuthProvider, type SyncScopeOptions, type SyncScopes, type SyncSessionTerminator, TokenManager, type TokenManagerConfig, type TokenRevocationStore, TotpAlreadyEnabledError, type TotpConfig, TotpError, TotpInvalidCodeError, TotpLockedError, TotpManager, TotpNotEnabledError, TotpNotVerifiedError, TotpRecoveryExhaustedError, type TotpSecret, type TotpSetupResult, type TotpStore, type UpdateOrgParams, type UserListQuery, type UserStore, VerificationTokenExpiredError, VerificationTokenNotFoundError, type VerifiedSyncClaims, type WebhookDelivery, type WebhookEndpoint, WebhookEndpointNotFoundError, WebhookError, type WebhookEvent, WebhookManager, type WebhookPayload, type WebhookStore, WebhookTargetError, base32Decode, base32Encode, createClerkAdapter, createKoraAuthServer, createPostgresLinkedIdentityStore, createPostgresOAuthStateStore, createPostgresOAuthStores, createPostgresUserStore, createSqliteLinkedIdentityStore, createSqliteOAuthStateStore, createSqliteOAuthStores, createSqliteUserStore, createSupabaseAdapter, decodeJwt, defineRoles, encodeJwt, generateAuthenticationOptions, generateRegistrationOptions, githubProvider, googleProvider, hasRoleLevel, hashPassword, isExpired, microsoftProvider, parsePermission, permissionCovers, verifyAuthenticationResponse, verifyJwt, verifyPassword, verifyRegistrationResponse, verifyWebhookSignature };
|
|
4843
|
+
export { AdminApi, type AdminApiConfig, AdminApiError, AdminUnauthorizedError, AdminUserNotFoundError, type AdminUserUpdate, type AuditAction, type AuditEntry, AuditLogError, type AuditLogQuery, type AuditLogStore, AuditLogger, type AuthDevice, type AuthProviderAdapter, AuthProviderError, type AuthRevocationEvent, type AuthRouteResponse, type AuthRoutesConfig, type AuthUser, type AuthenticatedAccess, type AuthenticationOptions, type AuthenticationVerificationResult, BUILT_IN_ROLES, BuiltInAuthRoutes, BuiltInProvider, CannotRemoveOwnerError, type ChallengeStore, CircularInheritanceError, type ClerkAdapterConfig, type CollectionScopeResolver, type ConsumeResult, type CreateInvitationParams, type CreateKoraAuthServerOptions, type CreateOrgParams, type CreateSessionParams, DEFAULT_REFRESH_REUSE_GRACE_MS, DeviceOwnershipError, DuplicateEmailError, DuplicateLinkedIdentityError, type EmailVerificationConfig, EmailVerificationError, EmailVerificationManager, type EmailVerificationStore, type EmailVerificationToken, ExternalAuthOperationNotSupportedError, ExternalJwtProvider, type ExternalJwtProviderConfig, ExternalTokenValidationError, type ExternalUserInfo, INVITATION_STATUSES, InMemoryAuditLogStore, InMemoryAuthStoreError, InMemoryChallengeStore, InMemoryEmailVerificationStore, InMemoryLinkedIdentityStore, InMemoryOAuthStateStore, InMemoryOrgStore, InMemoryPasswordResetStore, InMemoryRateLimiter, InMemorySessionStore, InMemoryTokenRevocationStore, InMemoryTotpStore, InMemoryUserStore, InMemoryWebhookStore, InsufficientRoleError, InvalidPermissionError, InvitationExpiredError, InvitationNotFoundError, type InvitationStatus, type IssueTokenOptions, type KoraAuthHttpRequest, type KoraAuthServer, type LinkedIdentity, type LinkedIdentityStore, MemberAlreadyExistsError, type Membership, MembershipNotFoundError, type MfaChallenge, type MfaPendingPayload, type MfaVerifier, OAuthCodeExchangeError, OAuthError, OAuthManager, type OAuthManagerConfig, type OAuthProviderConfig, OAuthProviderNotFoundError, type OAuthServerConfig, type OAuthState, OAuthStateMismatchError, type OAuthStateStore, type OAuthTokens, type OAuthUserInfo, OAuthUserInfoError, ORG_ROLES, OrgError, type OrgInvitation, OrgNotFoundError, type OrgRole, type OrgRouteResponse, OrgRoutes, type OrgRoutesConfig, OrgScopeResolver, OrgSlugTakenError, type OrgStore, type Organization, type PaginatedResult, PasskeyVerificationError, type PasswordResetConfig, PasswordResetError, PasswordResetManager, type PasswordResetStore, type PasswordResetToken, type Permission, PostgresLinkedIdentityStore, PostgresOAuthStateStore, type PostgresRevocationClient, PostgresTokenRevocationStore, PostgresUserStore, type PostgresUserStoreOptions, ROLE_HIERARCHY, type RateLimiter, type RbacConfig, RbacEngine, RbacError, type RefreshFailureReason, type RefreshResult, type RegistrationOptions, type RegistrationVerificationResult, ResetRateLimitedError, ResetTokenExpiredError, ResetTokenNotFoundError, type RoleDefinition, RoleNotFoundError, type ScopeContext, type ScopeFilter, type Session, SessionError, SessionExpiredError, SessionLimitExceededError, SessionManager, type SessionManagerConfig, SessionMfaRequiredError, SessionNotFoundError, type SessionStore, type SignInParams, type SignInResult, type SignUpParams, SqliteLinkedIdentityStore, SqliteOAuthStateStore, type SqliteRevocationDatabase, SqliteTokenRevocationStore, SqliteUserStore, type StoredUser, type SupabaseAdapterConfig, type SyncAuthContext, type SyncAuthProvider, type SyncScopeOptions, type SyncScopes, type SyncSessionTerminator, TokenManager, type TokenManagerConfig, type TokenRevocationStore, TotpAlreadyEnabledError, type TotpConfig, TotpError, TotpInvalidCodeError, TotpLockedError, TotpManager, TotpNotEnabledError, TotpNotVerifiedError, TotpRecoveryExhaustedError, type TotpSecret, type TotpSetupResult, type TotpStore, type UpdateOrgParams, type UserListQuery, type UserStore, VerificationTokenExpiredError, VerificationTokenNotFoundError, type VerifiedSyncClaims, type WebhookDelivery, type WebhookEndpoint, WebhookEndpointNotFoundError, WebhookError, type WebhookEvent, WebhookManager, type WebhookPayload, type WebhookStore, WebhookTargetError, base32Decode, base32Encode, createClerkAdapter, createKoraAuthServer, createPostgresLinkedIdentityStore, createPostgresOAuthStateStore, createPostgresOAuthStores, createPostgresUserStore, createSqliteLinkedIdentityStore, createSqliteOAuthStateStore, createSqliteOAuthStores, createSqliteUserStore, createSupabaseAdapter, decodeJwt, defineRoles, encodeJwt, generateAuthenticationOptions, generateRegistrationOptions, githubProvider, googleProvider, hasRoleLevel, hashPassword, isExpired, microsoftProvider, parsePermission, permissionCovers, verifyAuthenticationResponse, verifyJwt, verifyPassword, verifyRegistrationResponse, verifyWebhookSignature };
|
package/dist/server.d.ts
CHANGED
|
@@ -2177,6 +2177,19 @@ declare function createSqliteUserStore(options: {
|
|
|
2177
2177
|
interface PostgresClient$1 {
|
|
2178
2178
|
begin<T>(fn: (sql: PostgresClient$1) => Promise<T>): Promise<T>;
|
|
2179
2179
|
(template: TemplateStringsArray, ...args: unknown[]): Promise<Record<string, unknown>[]>;
|
|
2180
|
+
/** postgres-js: close every connection of the pool (optional in this subset). */
|
|
2181
|
+
end?(options?: {
|
|
2182
|
+
timeout?: number;
|
|
2183
|
+
}): Promise<void>;
|
|
2184
|
+
}
|
|
2185
|
+
/** Options for {@link PostgresUserStore}. */
|
|
2186
|
+
interface PostgresUserStoreOptions {
|
|
2187
|
+
/**
|
|
2188
|
+
* Whether {@link PostgresUserStore.close} ends the client's connections. True for
|
|
2189
|
+
* a store made by `createPostgresUserStore` (it opened the client); false by
|
|
2190
|
+
* default for a client you pass in, which you end yourself.
|
|
2191
|
+
*/
|
|
2192
|
+
ownsClient?: boolean;
|
|
2180
2193
|
}
|
|
2181
2194
|
/**
|
|
2182
2195
|
* PostgreSQL-backed user and device store using postgres-js.
|
|
@@ -2196,13 +2209,30 @@ interface PostgresClient$1 {
|
|
|
2196
2209
|
* connectionString: 'postgres://user:pass@localhost:5432/mydb',
|
|
2197
2210
|
* })
|
|
2198
2211
|
* const routes = new BuiltInAuthRoutes({ userStore, tokenManager })
|
|
2212
|
+
* // On shutdown (or at the end of a script):
|
|
2213
|
+
* await userStore.close()
|
|
2199
2214
|
* ```
|
|
2200
2215
|
*/
|
|
2201
2216
|
declare class PostgresUserStore implements UserStore {
|
|
2202
2217
|
private readonly sql;
|
|
2203
2218
|
private readonly ready;
|
|
2204
2219
|
private revocationStore;
|
|
2205
|
-
|
|
2220
|
+
private readonly ownsClient;
|
|
2221
|
+
private closed;
|
|
2222
|
+
constructor(sql: PostgresClient$1, options?: PostgresUserStoreOptions);
|
|
2223
|
+
/**
|
|
2224
|
+
* Release the store's database connections, so a script using it can exit. Waits
|
|
2225
|
+
* for table creation to settle first. A client passed to the constructor is left
|
|
2226
|
+
* open unless `ownsClient` was set (end it yourself). Idempotent.
|
|
2227
|
+
*
|
|
2228
|
+
* @example
|
|
2229
|
+
* ```typescript
|
|
2230
|
+
* const users = await createPostgresUserStore({ connectionString })
|
|
2231
|
+
* const device = await users.findDevice(nodeId)
|
|
2232
|
+
* await users.close()
|
|
2233
|
+
* ```
|
|
2234
|
+
*/
|
|
2235
|
+
close(): Promise<void>;
|
|
2206
2236
|
/** Token revocations stored in the same Postgres database as the users. */
|
|
2207
2237
|
getTokenRevocationStore(): TokenRevocationStore;
|
|
2208
2238
|
private ensureTables;
|
|
@@ -4810,4 +4840,4 @@ declare function verifyWebhookSignature(payload: string, signature: string, secr
|
|
|
4810
4840
|
toleranceSeconds?: number;
|
|
4811
4841
|
}): Promise<boolean>;
|
|
4812
4842
|
|
|
4813
|
-
export { AdminApi, type AdminApiConfig, AdminApiError, AdminUnauthorizedError, AdminUserNotFoundError, type AdminUserUpdate, type AuditAction, type AuditEntry, AuditLogError, type AuditLogQuery, type AuditLogStore, AuditLogger, type AuthDevice, type AuthProviderAdapter, AuthProviderError, type AuthRevocationEvent, type AuthRouteResponse, type AuthRoutesConfig, type AuthUser, type AuthenticatedAccess, type AuthenticationOptions, type AuthenticationVerificationResult, BUILT_IN_ROLES, BuiltInAuthRoutes, BuiltInProvider, CannotRemoveOwnerError, type ChallengeStore, CircularInheritanceError, type ClerkAdapterConfig, type CollectionScopeResolver, type ConsumeResult, type CreateInvitationParams, type CreateKoraAuthServerOptions, type CreateOrgParams, type CreateSessionParams, DEFAULT_REFRESH_REUSE_GRACE_MS, DeviceOwnershipError, DuplicateEmailError, DuplicateLinkedIdentityError, type EmailVerificationConfig, EmailVerificationError, EmailVerificationManager, type EmailVerificationStore, type EmailVerificationToken, ExternalAuthOperationNotSupportedError, ExternalJwtProvider, type ExternalJwtProviderConfig, ExternalTokenValidationError, type ExternalUserInfo, INVITATION_STATUSES, InMemoryAuditLogStore, InMemoryAuthStoreError, InMemoryChallengeStore, InMemoryEmailVerificationStore, InMemoryLinkedIdentityStore, InMemoryOAuthStateStore, InMemoryOrgStore, InMemoryPasswordResetStore, InMemoryRateLimiter, InMemorySessionStore, InMemoryTokenRevocationStore, InMemoryTotpStore, InMemoryUserStore, InMemoryWebhookStore, InsufficientRoleError, InvalidPermissionError, InvitationExpiredError, InvitationNotFoundError, type InvitationStatus, type IssueTokenOptions, type KoraAuthHttpRequest, type KoraAuthServer, type LinkedIdentity, type LinkedIdentityStore, MemberAlreadyExistsError, type Membership, MembershipNotFoundError, type MfaChallenge, type MfaPendingPayload, type MfaVerifier, OAuthCodeExchangeError, OAuthError, OAuthManager, type OAuthManagerConfig, type OAuthProviderConfig, OAuthProviderNotFoundError, type OAuthServerConfig, type OAuthState, OAuthStateMismatchError, type OAuthStateStore, type OAuthTokens, type OAuthUserInfo, OAuthUserInfoError, ORG_ROLES, OrgError, type OrgInvitation, OrgNotFoundError, type OrgRole, type OrgRouteResponse, OrgRoutes, type OrgRoutesConfig, OrgScopeResolver, OrgSlugTakenError, type OrgStore, type Organization, type PaginatedResult, PasskeyVerificationError, type PasswordResetConfig, PasswordResetError, PasswordResetManager, type PasswordResetStore, type PasswordResetToken, type Permission, PostgresLinkedIdentityStore, PostgresOAuthStateStore, type PostgresRevocationClient, PostgresTokenRevocationStore, PostgresUserStore, ROLE_HIERARCHY, type RateLimiter, type RbacConfig, RbacEngine, RbacError, type RefreshFailureReason, type RefreshResult, type RegistrationOptions, type RegistrationVerificationResult, ResetRateLimitedError, ResetTokenExpiredError, ResetTokenNotFoundError, type RoleDefinition, RoleNotFoundError, type ScopeContext, type ScopeFilter, type Session, SessionError, SessionExpiredError, SessionLimitExceededError, SessionManager, type SessionManagerConfig, SessionMfaRequiredError, SessionNotFoundError, type SessionStore, type SignInParams, type SignInResult, type SignUpParams, SqliteLinkedIdentityStore, SqliteOAuthStateStore, type SqliteRevocationDatabase, SqliteTokenRevocationStore, SqliteUserStore, type StoredUser, type SupabaseAdapterConfig, type SyncAuthContext, type SyncAuthProvider, type SyncScopeOptions, type SyncScopes, type SyncSessionTerminator, TokenManager, type TokenManagerConfig, type TokenRevocationStore, TotpAlreadyEnabledError, type TotpConfig, TotpError, TotpInvalidCodeError, TotpLockedError, TotpManager, TotpNotEnabledError, TotpNotVerifiedError, TotpRecoveryExhaustedError, type TotpSecret, type TotpSetupResult, type TotpStore, type UpdateOrgParams, type UserListQuery, type UserStore, VerificationTokenExpiredError, VerificationTokenNotFoundError, type VerifiedSyncClaims, type WebhookDelivery, type WebhookEndpoint, WebhookEndpointNotFoundError, WebhookError, type WebhookEvent, WebhookManager, type WebhookPayload, type WebhookStore, WebhookTargetError, base32Decode, base32Encode, createClerkAdapter, createKoraAuthServer, createPostgresLinkedIdentityStore, createPostgresOAuthStateStore, createPostgresOAuthStores, createPostgresUserStore, createSqliteLinkedIdentityStore, createSqliteOAuthStateStore, createSqliteOAuthStores, createSqliteUserStore, createSupabaseAdapter, decodeJwt, defineRoles, encodeJwt, generateAuthenticationOptions, generateRegistrationOptions, githubProvider, googleProvider, hasRoleLevel, hashPassword, isExpired, microsoftProvider, parsePermission, permissionCovers, verifyAuthenticationResponse, verifyJwt, verifyPassword, verifyRegistrationResponse, verifyWebhookSignature };
|
|
4843
|
+
export { AdminApi, type AdminApiConfig, AdminApiError, AdminUnauthorizedError, AdminUserNotFoundError, type AdminUserUpdate, type AuditAction, type AuditEntry, AuditLogError, type AuditLogQuery, type AuditLogStore, AuditLogger, type AuthDevice, type AuthProviderAdapter, AuthProviderError, type AuthRevocationEvent, type AuthRouteResponse, type AuthRoutesConfig, type AuthUser, type AuthenticatedAccess, type AuthenticationOptions, type AuthenticationVerificationResult, BUILT_IN_ROLES, BuiltInAuthRoutes, BuiltInProvider, CannotRemoveOwnerError, type ChallengeStore, CircularInheritanceError, type ClerkAdapterConfig, type CollectionScopeResolver, type ConsumeResult, type CreateInvitationParams, type CreateKoraAuthServerOptions, type CreateOrgParams, type CreateSessionParams, DEFAULT_REFRESH_REUSE_GRACE_MS, DeviceOwnershipError, DuplicateEmailError, DuplicateLinkedIdentityError, type EmailVerificationConfig, EmailVerificationError, EmailVerificationManager, type EmailVerificationStore, type EmailVerificationToken, ExternalAuthOperationNotSupportedError, ExternalJwtProvider, type ExternalJwtProviderConfig, ExternalTokenValidationError, type ExternalUserInfo, INVITATION_STATUSES, InMemoryAuditLogStore, InMemoryAuthStoreError, InMemoryChallengeStore, InMemoryEmailVerificationStore, InMemoryLinkedIdentityStore, InMemoryOAuthStateStore, InMemoryOrgStore, InMemoryPasswordResetStore, InMemoryRateLimiter, InMemorySessionStore, InMemoryTokenRevocationStore, InMemoryTotpStore, InMemoryUserStore, InMemoryWebhookStore, InsufficientRoleError, InvalidPermissionError, InvitationExpiredError, InvitationNotFoundError, type InvitationStatus, type IssueTokenOptions, type KoraAuthHttpRequest, type KoraAuthServer, type LinkedIdentity, type LinkedIdentityStore, MemberAlreadyExistsError, type Membership, MembershipNotFoundError, type MfaChallenge, type MfaPendingPayload, type MfaVerifier, OAuthCodeExchangeError, OAuthError, OAuthManager, type OAuthManagerConfig, type OAuthProviderConfig, OAuthProviderNotFoundError, type OAuthServerConfig, type OAuthState, OAuthStateMismatchError, type OAuthStateStore, type OAuthTokens, type OAuthUserInfo, OAuthUserInfoError, ORG_ROLES, OrgError, type OrgInvitation, OrgNotFoundError, type OrgRole, type OrgRouteResponse, OrgRoutes, type OrgRoutesConfig, OrgScopeResolver, OrgSlugTakenError, type OrgStore, type Organization, type PaginatedResult, PasskeyVerificationError, type PasswordResetConfig, PasswordResetError, PasswordResetManager, type PasswordResetStore, type PasswordResetToken, type Permission, PostgresLinkedIdentityStore, PostgresOAuthStateStore, type PostgresRevocationClient, PostgresTokenRevocationStore, PostgresUserStore, type PostgresUserStoreOptions, ROLE_HIERARCHY, type RateLimiter, type RbacConfig, RbacEngine, RbacError, type RefreshFailureReason, type RefreshResult, type RegistrationOptions, type RegistrationVerificationResult, ResetRateLimitedError, ResetTokenExpiredError, ResetTokenNotFoundError, type RoleDefinition, RoleNotFoundError, type ScopeContext, type ScopeFilter, type Session, SessionError, SessionExpiredError, SessionLimitExceededError, SessionManager, type SessionManagerConfig, SessionMfaRequiredError, SessionNotFoundError, type SessionStore, type SignInParams, type SignInResult, type SignUpParams, SqliteLinkedIdentityStore, SqliteOAuthStateStore, type SqliteRevocationDatabase, SqliteTokenRevocationStore, SqliteUserStore, type StoredUser, type SupabaseAdapterConfig, type SyncAuthContext, type SyncAuthProvider, type SyncScopeOptions, type SyncScopes, type SyncSessionTerminator, TokenManager, type TokenManagerConfig, type TokenRevocationStore, TotpAlreadyEnabledError, type TotpConfig, TotpError, TotpInvalidCodeError, TotpLockedError, TotpManager, TotpNotEnabledError, TotpNotVerifiedError, TotpRecoveryExhaustedError, type TotpSecret, type TotpSetupResult, type TotpStore, type UpdateOrgParams, type UserListQuery, type UserStore, VerificationTokenExpiredError, VerificationTokenNotFoundError, type VerifiedSyncClaims, type WebhookDelivery, type WebhookEndpoint, WebhookEndpointNotFoundError, WebhookError, type WebhookEvent, WebhookManager, type WebhookPayload, type WebhookStore, WebhookTargetError, base32Decode, base32Encode, createClerkAdapter, createKoraAuthServer, createPostgresLinkedIdentityStore, createPostgresOAuthStateStore, createPostgresOAuthStores, createPostgresUserStore, createSqliteLinkedIdentityStore, createSqliteOAuthStateStore, createSqliteOAuthStores, createSqliteUserStore, createSupabaseAdapter, decodeJwt, defineRoles, encodeJwt, generateAuthenticationOptions, generateRegistrationOptions, githubProvider, googleProvider, hasRoleLevel, hashPassword, isExpired, microsoftProvider, parsePermission, permissionCovers, verifyAuthenticationResponse, verifyJwt, verifyPassword, verifyRegistrationResponse, verifyWebhookSignature };
|
package/dist/server.js
CHANGED
|
@@ -3260,6 +3260,8 @@ function generateSecureToken2() {
|
|
|
3260
3260
|
|
|
3261
3261
|
// src/provider/built-in/sqlite-user-store.ts
|
|
3262
3262
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
3263
|
+
import { mkdirSync } from "fs";
|
|
3264
|
+
import { dirname } from "path";
|
|
3263
3265
|
var SqliteUserStore = class {
|
|
3264
3266
|
db;
|
|
3265
3267
|
revocationStore = null;
|
|
@@ -3399,6 +3401,7 @@ var SqliteUserStore = class {
|
|
|
3399
3401
|
};
|
|
3400
3402
|
async function createSqliteUserStore(options) {
|
|
3401
3403
|
const Database = await loadBetterSqlite3();
|
|
3404
|
+
ensureDatabaseDirectory(options.filename);
|
|
3402
3405
|
const db = new Database(options.filename);
|
|
3403
3406
|
return new SqliteUserStore(db);
|
|
3404
3407
|
}
|
|
@@ -3435,6 +3438,10 @@ function rowToDevice(row) {
|
|
|
3435
3438
|
lastSeenAt: row.last_seen_at
|
|
3436
3439
|
};
|
|
3437
3440
|
}
|
|
3441
|
+
function ensureDatabaseDirectory(filename) {
|
|
3442
|
+
if (filename === "" || filename === ":memory:" || filename.startsWith("file:")) return;
|
|
3443
|
+
mkdirSync(dirname(filename), { recursive: true });
|
|
3444
|
+
}
|
|
3438
3445
|
|
|
3439
3446
|
// src/provider/built-in/postgres-user-store.ts
|
|
3440
3447
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
@@ -3442,10 +3449,32 @@ var PostgresUserStore = class {
|
|
|
3442
3449
|
sql;
|
|
3443
3450
|
ready;
|
|
3444
3451
|
revocationStore = null;
|
|
3445
|
-
|
|
3452
|
+
ownsClient;
|
|
3453
|
+
closed = false;
|
|
3454
|
+
constructor(sql, options = {}) {
|
|
3446
3455
|
this.sql = sql;
|
|
3456
|
+
this.ownsClient = options.ownsClient ?? false;
|
|
3447
3457
|
this.ready = this.ensureTables();
|
|
3448
3458
|
}
|
|
3459
|
+
/**
|
|
3460
|
+
* Release the store's database connections, so a script using it can exit. Waits
|
|
3461
|
+
* for table creation to settle first. A client passed to the constructor is left
|
|
3462
|
+
* open unless `ownsClient` was set (end it yourself). Idempotent.
|
|
3463
|
+
*
|
|
3464
|
+
* @example
|
|
3465
|
+
* ```typescript
|
|
3466
|
+
* const users = await createPostgresUserStore({ connectionString })
|
|
3467
|
+
* const device = await users.findDevice(nodeId)
|
|
3468
|
+
* await users.close()
|
|
3469
|
+
* ```
|
|
3470
|
+
*/
|
|
3471
|
+
async close() {
|
|
3472
|
+
if (this.closed) return;
|
|
3473
|
+
this.closed = true;
|
|
3474
|
+
await this.ready.catch(() => {
|
|
3475
|
+
});
|
|
3476
|
+
if (this.ownsClient) await this.sql.end?.({ timeout: 5 });
|
|
3477
|
+
}
|
|
3449
3478
|
/** Token revocations stored in the same Postgres database as the users. */
|
|
3450
3479
|
getTokenRevocationStore() {
|
|
3451
3480
|
if (!this.revocationStore) {
|
|
@@ -3610,7 +3639,7 @@ var PostgresUserStore = class {
|
|
|
3610
3639
|
async function createPostgresUserStore(options) {
|
|
3611
3640
|
const postgresClient = await loadPostgresDeps();
|
|
3612
3641
|
const sql = postgresClient(options.connectionString);
|
|
3613
|
-
return new PostgresUserStore(sql);
|
|
3642
|
+
return new PostgresUserStore(sql, { ownsClient: true });
|
|
3614
3643
|
}
|
|
3615
3644
|
async function loadPostgresDeps() {
|
|
3616
3645
|
try {
|
|
@@ -5617,6 +5646,8 @@ var OrgScopeResolver = class {
|
|
|
5617
5646
|
|
|
5618
5647
|
// src/provider/oauth/sqlite-oauth-store.ts
|
|
5619
5648
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
5649
|
+
import { mkdirSync as mkdirSync2 } from "fs";
|
|
5650
|
+
import { dirname as dirname2 } from "path";
|
|
5620
5651
|
var SqliteOAuthStateStore = class {
|
|
5621
5652
|
db;
|
|
5622
5653
|
constructor(db) {
|
|
@@ -5755,6 +5786,7 @@ async function createSqliteLinkedIdentityStore(options) {
|
|
|
5755
5786
|
}
|
|
5756
5787
|
async function createSqliteOAuthStores(options) {
|
|
5757
5788
|
const Database = await loadBetterSqlite32();
|
|
5789
|
+
ensureDatabaseDirectory2(options.filename);
|
|
5758
5790
|
const db = new Database(options.filename);
|
|
5759
5791
|
return {
|
|
5760
5792
|
stateStore: new SqliteOAuthStateStore(db),
|
|
@@ -5798,6 +5830,10 @@ function rowToLinkedIdentity(row) {
|
|
|
5798
5830
|
linkedAt: row.linked_at
|
|
5799
5831
|
};
|
|
5800
5832
|
}
|
|
5833
|
+
function ensureDatabaseDirectory2(filename) {
|
|
5834
|
+
if (filename === "" || filename === ":memory:" || filename.startsWith("file:")) return;
|
|
5835
|
+
mkdirSync2(dirname2(filename), { recursive: true });
|
|
5836
|
+
}
|
|
5801
5837
|
|
|
5802
5838
|
// src/provider/oauth/postgres-oauth-store.ts
|
|
5803
5839
|
import { randomUUID as randomUUID9 } from "crypto";
|