studiocms
Version:
Astro Native CMS for AstroDB. Built from the ground up by the Astro community.
92 lines (91 loc) • 8.45 kB
TypeScript
import { Effect } from '../../effect.js';
/**
* Extracts and exports the `Encryption`, `Password`, `Session`, and `User` modules
* from the result of running an effectful computation that provides an authentication kit.
*
* The effect is constructed using `Effect.gen` to yield the `AuthKit`, omitting its `_tag` property,
* and then providing the merged configuration using `Layer.provideMerge` with `AuthKit.Default`
* and `authKitConfig`.
*
* @remarks
* This allows consumers to access core authentication utilities (encryption, password management,
* session handling, and user management) as top-level exports.
*
* @see AuthKit
* @see Effect.gen
* @see Layer.provideMerge
*
* @example
* ```typescript
* import { Encryption, Password, Session, User } from './core';
* ```
*/
export declare const Encryption: Effect.Effect<{
readonly encrypt: (data: Uint8Array<ArrayBufferLike>) => Effect.Effect.AsEffect<Effect.Effect<Uint8Array<ArrayBufferLike>, import("@withstudiocms/auth-kit/errors").EncryptionError, never>>;
readonly encryptToString: (data: string) => Effect.Effect<Uint8Array<ArrayBufferLike>, import("@withstudiocms/auth-kit/errors").EncryptionError, never>;
readonly decrypt: (data: Uint8Array<ArrayBufferLike>) => Effect.Effect.AsEffect<Effect.Effect<Uint8Array<ArrayBufferLike>, import("@withstudiocms/auth-kit/errors").DecryptionError, never>>;
readonly decryptToString: (data: Uint8Array<ArrayBufferLike>) => Effect.Effect<string, import("@withstudiocms/auth-kit/errors").DecryptionError, never>;
}, import("@withstudiocms/auth-kit/errors").EncryptionError, never>, Password: Effect.Effect<{
readonly hashPassword: (password: string, _salt?: string | undefined) => Effect.Effect<string, import("@withstudiocms/effect/scrypt").ScryptError, never>;
readonly verifyPasswordHash: (hash: string, password: string) => Effect.Effect<boolean, import("@withstudiocms/effect/scrypt").ScryptError | import("@withstudiocms/auth-kit/errors").PasswordError, never>;
readonly verifyPasswordStrength: (pass: string) => Effect.Effect<string | true, import("@withstudiocms/auth-kit/errors").PasswordError | import("@withstudiocms/auth-kit/errors").CheckIfUnsafeError | import("@effect/platform/HttpClientError").ResponseError, never>;
}, never, never>, Session: Effect.Effect<{
readonly generateSessionToken: () => Effect.Effect.AsEffect<Effect.Effect<string, import("@withstudiocms/auth-kit/errors").SessionError, never>>;
readonly createSession: (token: string, userId: string) => Effect.Effect<import("@withstudiocms/auth-kit/types").UserSession, import("@withstudiocms/auth-kit/errors").SessionError, never>;
readonly validateSessionToken: (token: string) => Effect.Effect<import("@withstudiocms/auth-kit/types").SessionValidationResult, import("@withstudiocms/auth-kit/errors").SessionError, never>;
readonly invalidateSession: (sessionId: string) => Effect.Effect.AsEffect<Effect.Effect<void, import("@withstudiocms/auth-kit/errors").SessionError, never>>;
readonly setSessionTokenCookie: (context: import("astro").APIContext<Record<string, any>, Record<string, string | undefined>> | import("astro").AstroGlobal<Record<string, any>, import("astro/runtime/server/index.js").AstroComponentFactory, Record<string, string | undefined>>, token: string, expiresAt: Date, secure?: boolean | undefined) => Effect.Effect.AsEffect<Effect.Effect<void, import("@withstudiocms/auth-kit/errors").SessionError, never>>;
readonly deleteSessionTokenCookie: (context: import("astro").APIContext<Record<string, any>, Record<string, string | undefined>> | import("astro").AstroGlobal<Record<string, any>, import("astro/runtime/server/index.js").AstroComponentFactory, Record<string, string | undefined>>, secure?: boolean | undefined) => Effect.Effect.AsEffect<Effect.Effect<void, import("@withstudiocms/auth-kit/errors").SessionError, never>>;
readonly setOAuthSessionTokenCookie: (context: import("astro").APIContext<Record<string, any>, Record<string, string | undefined>> | import("astro").AstroGlobal<Record<string, any>, import("astro/runtime/server/index.js").AstroComponentFactory, Record<string, string | undefined>>, key: string, value: string, secure?: boolean | undefined) => Effect.Effect.AsEffect<Effect.Effect<void, import("@withstudiocms/auth-kit/errors").SessionError, never>>;
readonly createUserSession: (userId: string, context: import("astro").APIContext<Record<string, any>, Record<string, string | undefined>> | import("astro").AstroGlobal<Record<string, any>, import("astro/runtime/server/index.js").AstroComponentFactory, Record<string, string | undefined>>, secure?: boolean | undefined) => Effect.Effect<void, import("@withstudiocms/auth-kit/errors").SessionError, never>;
}, import("@withstudiocms/auth-kit/errors").SessionError, never>, User: Effect.Effect<{
readonly verifyUsernameInput: (username: string) => Effect.Effect<string | true, import("@withstudiocms/auth-kit/errors").CheckIfUnsafeError | import("@withstudiocms/auth-kit/errors").UserError, never>;
readonly createUserAvatar: (email: string) => Effect.Effect.AsEffect<Effect.Effect<string, import("@withstudiocms/auth-kit/errors").UserError, never>>;
readonly createLocalUser: (name: string, username: string, email: string, password: string) => Effect.Effect<{
name: string;
username: string;
id: string;
url: string | null;
email: string | null;
avatar: string | null;
password: string | null;
updatedAt: Date | null;
createdAt: Date | null;
emailVerified: boolean;
notifications: string | null;
}, import("@withstudiocms/effect/scrypt").ScryptError | import("@withstudiocms/auth-kit/errors").UserError, never>;
readonly createOAuthUser: (data: import("@withstudiocms/auth-kit/types").UserData, oAuthFields: {
provider: string;
providerUserId: string;
}) => Effect.Effect<{
name: string;
username: string;
id: string;
url: string | null;
email: string | null;
avatar: string | null;
password: string | null;
updatedAt: Date | null;
createdAt: Date | null;
emailVerified: boolean;
notifications: string | null;
}, import("@withstudiocms/auth-kit/errors").UserError, never>;
readonly updateUserPassword: (userId: string, password: string) => Effect.Effect<{
name: string;
username: string;
id: string;
url: string | null;
email: string | null;
avatar: string | null;
password: string | null;
updatedAt: Date | null;
createdAt: Date | null;
emailVerified: boolean;
notifications: string | null;
}, import("@withstudiocms/effect/scrypt").ScryptError | import("@withstudiocms/auth-kit/errors").UserError, never>;
readonly getUserPasswordHash: (userId: string) => Effect.Effect<string, import("@withstudiocms/auth-kit/errors").UserError, never>;
readonly getUserFromEmail: (email: string) => Effect.Effect.AsEffect<Effect.Effect<import("@withstudiocms/auth-kit/types").CombinedUserData | null | undefined, import("@withstudiocms/auth-kit/errors").UserError, never>>;
readonly getUserData: (context: import("astro").APIContext<Record<string, any>, Record<string, string | undefined>> | import("astro").AstroGlobal<Record<string, any>, import("astro/runtime/server/index.js").AstroComponentFactory, Record<string, string | undefined>>) => Effect.Effect<import("@withstudiocms/auth-kit/types").UserSessionData, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, never>;
readonly getUserPermissionLevel: (userData: import("@withstudiocms/auth-kit/types").UserSessionData | import("@withstudiocms/auth-kit/types").CombinedUserData | null) => Effect.Effect<import("@withstudiocms/auth-kit/types").UserPermissionLevel, import("@withstudiocms/auth-kit/errors").UserError, never>;
readonly isUserAllowed: (userData: import("@withstudiocms/auth-kit/types").UserSessionData | import("@withstudiocms/auth-kit/types").CombinedUserData | null, requiredPerms: "owner" | "admin" | "editor" | "visitor" | "unknown") => Effect.Effect<boolean, import("@withstudiocms/auth-kit/errors").UserError, never>;
}, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, never>;