import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'; import { ProxyRoutesAdapter, ActionsAdapter, ActionExecutionsAdapter, ActionVersionsAdapter, TenantsDataAdapter, UserDataAdapter, SessionsAdapter, PasswordsAdapter, CodesAdapter, ClientsAdapter, ClientGrantsAdapter, ClientConnectionsAdapter, ConnectionsAdapter, LoginSessionsAdapter, BrandingAdapter, HooksAdapter, KeysAdapter, CustomDomainsAdapter, LogsDataAdapter, ThemesAdapter, PromptSettingsAdapter, EmailProvidersAdapter, RefreshTokensAdapter, FormsAdapter, ResourceServersAdapter, RolesAdapter, RolePermissionsAdapter, UserPermissionsAdapter, UserRolesAdapter, OrganizationsAdapter, OrganizationConnectionsAdapter, UserOrganizationsAdapter, InvitesAdapter, FlowsAdapter, AuthenticationMethodsAdapter, ListParams, DataAdapters } from '@authhero/adapter-interfaces'; import { ProxyDataAdapter } from '@authhero/proxy'; interface DynamoDBConfig { tableName: string; } interface DynamoDBContext { client: DynamoDBDocumentClient; tableName: string; } /** * Entity types for single-table design */ type EntityType = "FLOW" | "TENANT" | "USER" | "SESSION" | "LOGIN_SESSION" | "CLIENT" | "CLIENT_GRANT" | "CONNECTION" | "CODE" | "PASSWORD" | "BRANDING" | "THEME" | "HOOK" | "KEY" | "CUSTOM_DOMAIN" | "LOG" | "EMAIL_PROVIDER" | "EMAIL_TEMPLATE" | "PROMPT_SETTING" | "REFRESH_TOKEN" | "FORM" | "RESOURCE_SERVER" | "ROLE" | "ROLE_PERMISSION" | "USER_PERMISSION" | "USER_ROLE" | "ORGANIZATION" | "ORGANIZATION_CONNECTION" | "USER_ORGANIZATION" | "INVITE" | "LEGACY_CLIENT" | "CLIENT_CONNECTION" | "UNIVERSAL_LOGIN_TEMPLATE" | "CUSTOM_TEXT" | "AUTHENTICATION_METHOD" | "HOOK_CODE" | "CLIENT_REGISTRATION_TOKEN" | "PROXY_ROUTE"; /** * Base DynamoDB item structure for single-table design */ interface DynamoDBBaseItem { PK: string; SK: string; entityType: EntityType; GSI1PK?: string; GSI1SK?: string; GSI2PK?: string; GSI2SK?: string; created_at: string; updated_at: string; ttl?: number; } declare function createProxyRoutesAdapter(ctx: DynamoDBContext): ProxyRoutesAdapter; declare function createProxyDataAdapter(ctx: DynamoDBContext): ProxyDataAdapter; /** * Stub actions adapter for the DynamoDB backend. * * The Actions feature has not yet been implemented for DynamoDB. Any attempt * to read or write actions on this backend throws at runtime so the gap is * obvious rather than silently returning empty results. */ declare function createActionsAdapter(): ActionsAdapter; /** * Stub action-executions adapter for the DynamoDB backend. * * Mirrors the actions/actionVersions adapters — the Actions feature is not * implemented in AWS. Any call throws so the gap is obvious rather than * silently returning empty results. */ declare function createActionExecutionsAdapter(): ActionExecutionsAdapter; /** * Stub action-versions adapter for the DynamoDB backend. * * Mirrors the actions adapter — both are unimplemented in AWS. Any call * throws so the gap is obvious rather than silently returning empty results. */ declare function createActionVersionsAdapter(): ActionVersionsAdapter; declare function createTenantsAdapter(ctx: DynamoDBContext): TenantsDataAdapter; declare function createUsersAdapter(ctx: DynamoDBContext): UserDataAdapter; declare function createSessionsAdapter(ctx: DynamoDBContext): SessionsAdapter; declare function createPasswordsAdapter(ctx: DynamoDBContext): PasswordsAdapter; declare function createCodesAdapter(ctx: DynamoDBContext): CodesAdapter; declare function createClientsAdapter(ctx: DynamoDBContext): ClientsAdapter; declare function createClientGrantsAdapter(ctx: DynamoDBContext): ClientGrantsAdapter; declare function createClientConnectionsAdapter(ctx: DynamoDBContext): ClientConnectionsAdapter; declare function createConnectionsAdapter(ctx: DynamoDBContext): ConnectionsAdapter; declare function createLoginSessionsAdapter(ctx: DynamoDBContext): LoginSessionsAdapter; declare function createBrandingAdapter(ctx: DynamoDBContext): BrandingAdapter; declare function createHooksAdapter(ctx: DynamoDBContext): HooksAdapter; declare function createKeysAdapter(ctx: DynamoDBContext): KeysAdapter; declare function createCustomDomainsAdapter(ctx: DynamoDBContext): CustomDomainsAdapter; declare function createLogsAdapter(ctx: DynamoDBContext): LogsDataAdapter; declare function createThemesAdapter(ctx: DynamoDBContext): ThemesAdapter; declare function createPromptSettingsAdapter(ctx: DynamoDBContext): PromptSettingsAdapter; declare function createEmailProvidersAdapter(ctx: DynamoDBContext): EmailProvidersAdapter; declare function createRefreshTokensAdapter(ctx: DynamoDBContext): RefreshTokensAdapter; declare function createFormsAdapter(ctx: DynamoDBContext): FormsAdapter; declare function createResourceServersAdapter(ctx: DynamoDBContext): ResourceServersAdapter; declare function createRolesAdapter(ctx: DynamoDBContext): RolesAdapter; declare function createRolePermissionsAdapter(ctx: DynamoDBContext): RolePermissionsAdapter; declare function createUserPermissionsAdapter(ctx: DynamoDBContext): UserPermissionsAdapter; declare function createUserRolesAdapter(ctx: DynamoDBContext): UserRolesAdapter; declare function createOrganizationsAdapter(ctx: DynamoDBContext): OrganizationsAdapter; declare function createOrganizationConnectionsAdapter(ctx: DynamoDBContext): OrganizationConnectionsAdapter; declare function createUserOrganizationsAdapter(ctx: DynamoDBContext): UserOrganizationsAdapter; declare function createInvitesAdapter(ctx: DynamoDBContext): InvitesAdapter; declare function createFlowsAdapter(ctx: DynamoDBContext): FlowsAdapter; declare function createAuthenticationMethodsAdapter(ctx: DynamoDBContext): AuthenticationMethodsAdapter; /** * Key generation utilities for single-table DynamoDB design */ declare const tenantKeys: { pk: (tenantId: string) => string; sk: () => string; gsi1pk: () => string; gsi1sk: (tenantId: string) => string; }; declare const userKeys: { pk: (tenantId: string) => string; sk: (userId: string) => string; gsi1pk: (tenantId: string, email: string) => string; gsi1sk: () => string; gsi2pk: (tenantId: string, connection: string) => string; gsi2sk: (userId: string) => string; }; declare const sessionKeys: { pk: (tenantId: string) => string; sk: (sessionId: string) => string; gsi1pk: (tenantId: string, userId: string) => string; gsi1sk: (sessionId: string) => string; }; declare const loginSessionKeys: { pk: (tenantId: string) => string; sk: (loginSessionId: string) => string; }; declare const clientKeys: { pk: (tenantId: string) => string; sk: (clientId: string) => string; }; declare const clientGrantKeys: { pk: (tenantId: string) => string; sk: (clientGrantId: string) => string; gsi1pk: (tenantId: string, clientId: string) => string; gsi1sk: (audience: string) => string; }; declare const connectionKeys: { pk: (tenantId: string) => string; sk: (connectionId: string) => string; gsi1pk: (tenantId: string, connectionName: string) => string; gsi1sk: () => string; }; declare const codeKeys: { pk: (tenantId: string) => string; sk: (codeId: string, codeType: string) => string; skPrefixByCodeId: (codeId: string) => string; }; declare const passwordKeys: { pk: (tenantId: string, userId: string) => string; sk: (passwordId: string) => string; skPrefix: () => string; }; declare const brandingKeys: { pk: (tenantId: string) => string; sk: () => string; }; declare const universalLoginTemplateKeys: { pk: (tenantId: string) => string; sk: () => string; }; declare const themeKeys: { pk: (tenantId: string) => string; sk: (themeId: string) => string; }; declare const hookKeys: { pk: (tenantId: string) => string; sk: (hookId: string) => string; }; declare const keyKeys: { pk: () => string; sk: (kid: string) => string; }; declare const customDomainKeys: { pk: (tenantId: string) => string; sk: (customDomainId: string) => string; gsi1pk: (domain: string) => string; gsi1sk: () => string; }; declare const proxyRouteKeys: { pk: (tenantId: string) => string; sk: (proxyRouteId: string) => string; gsi1pk: (tenantId: string, customDomainId: string) => string; gsi1sk: (proxyRouteId: string) => string; }; declare const logKeys: { pk: (tenantId: string) => string; sk: (logId: string) => string; gsi1pk: (tenantId: string, date: string) => string; gsi1sk: (logId: string) => string; }; declare const emailProviderKeys: { pk: (tenantId: string) => string; sk: () => string; }; declare const emailTemplateKeys: { pk: (tenantId: string) => string; sk: (templateName: string) => string; skPrefix: () => string; }; declare const promptSettingsKeys: { pk: (tenantId: string) => string; sk: () => string; }; declare const refreshTokenKeys: { pk: (tenantId: string) => string; sk: (tokenId: string) => string; gsi1pk: (tenantId: string, userId: string) => string; gsi1sk: (tokenId: string) => string; gsi2pk: (tenantId: string, tokenLookup: string) => string; gsi2sk: () => string; }; declare const formKeys: { pk: (tenantId: string) => string; sk: (formId: string) => string; }; declare const flowKeys: { pk: (tenantId: string) => string; sk: (flowId: string) => string; }; declare const resourceServerKeys: { pk: (tenantId: string) => string; sk: (resourceServerId: string) => string; gsi1pk: (tenantId: string, identifier: string) => string; gsi1sk: () => string; }; declare const roleKeys: { pk: (tenantId: string) => string; sk: (roleId: string) => string; }; declare const rolePermissionKeys: { pk: (tenantId: string, roleId: string) => string; sk: (resourceServerIdentifier: string, permissionName: string) => string; skPrefix: () => string; }; declare const userPermissionKeys: { pk: (tenantId: string, userId: string, organizationId?: string) => string; sk: (resourceServerIdentifier: string, permissionName: string) => string; skPrefix: () => string; }; declare const userRoleKeys: { pk: (tenantId: string, userId: string, organizationId?: string) => string; sk: (roleId: string) => string; skPrefix: () => string; }; declare const organizationKeys: { pk: (tenantId: string) => string; sk: (organizationId: string) => string; gsi1pk: (tenantId: string, organizationName: string) => string; gsi1sk: () => string; }; declare const userOrganizationKeys: { pk: (tenantId: string) => string; sk: (userOrganizationId: string) => string; gsi1pk: (tenantId: string, userId: string) => string; gsi1sk: (organizationId: string) => string; gsi2pk: (tenantId: string, organizationId: string) => string; gsi2sk: (userId: string) => string; }; declare const organizationConnectionKeys: { pk: (tenantId: string, organizationId: string) => string; sk: (connectionId: string) => string; skPrefix: () => string; }; declare const inviteKeys: { pk: (tenantId: string) => string; sk: (inviteId: string) => string; gsi1pk: (tenantId: string, organizationId: string) => string; gsi1sk: (inviteId: string) => string; }; declare const legacyClientKeys: { pk: () => string; sk: (clientId: string) => string; }; declare const clientConnectionKeys: { pk: (tenantId: string, clientId: string) => string; sk: (connectionId: string, order: number) => string; skPrefix: () => string; gsi1pk: (tenantId: string, connectionId: string) => string; gsi1sk: (clientId: string) => string; }; declare const authenticationMethodKeys: { pk: (tenantId: string) => string; sk: (methodId: string) => string; gsi1pk: (tenantId: string, userId: string) => string; gsi1sk: (methodId: string) => string; gsi1skPrefix: () => string; }; declare const clientRegistrationTokenKeys: { pk: (tenantId: string) => string; sk: (tokenId: string) => string; skPrefix: () => string; gsi1pk: (tenantId: string, tokenHash: string) => string; gsi1sk: () => string; gsi2pk: (tenantId: string, clientId: string) => string; gsi2sk: (tokenId: string) => string; }; declare const customTextKeys: { pk: (tenantId: string) => string; sk: (prompt: string, language: string) => string; skPrefix: () => string; }; /** * Transactional write operation for DynamoDB * Allows multiple put/delete operations to be atomic */ declare function transactWriteItems(ctx: DynamoDBContext, items: Array<{ type: "put" | "delete"; item?: DynamoDBBaseItem; pk?: string; sk?: string; conditionExpression?: string; }>): Promise; /** * Generic get operation for DynamoDB */ declare function getItem(ctx: DynamoDBContext, pk: string, sk: string): Promise; /** * Generic put operation for DynamoDB * @param dynamoItem - The DynamoDB item with PK, SK, etc. * @param options - Optional settings including condition expression */ declare function putItem(ctx: DynamoDBContext, dynamoItem: DynamoDBBaseItem, options?: { conditionExpression?: string; }): Promise; /** * Generic delete operation for DynamoDB */ declare function deleteItem(ctx: DynamoDBContext, pk: string, sk: string): Promise; /** * Generic query operation for DynamoDB */ declare function queryItems(ctx: DynamoDBContext, pk: string, options?: { skPrefix?: string; skValue?: string; indexName?: string; limit?: number; startKey?: Record; scanIndexForward?: boolean; }): Promise<{ items: T[]; lastKey?: Record; }>; /** True when the caller asked for keyset (checkpoint) pagination. */ declare function isKeysetRequest(params?: ListParams): boolean; /** * Query with pagination support. * * Two modes, picked by which parameters the caller supplied: * * - **Keyset (checkpoint)** — `from`/`take`. `from` is an OPAQUE cursor (see * `encodeDynamoCursor`) wrapping DynamoDB's own `LastEvaluatedKey`, so a page * resumes natively via `ExclusiveStartKey` with no scanning of skipped rows. * Returns `next` when a further page may exist, and no `total` — matching * Auth0's checkpoint responses and the SQL adapters. * - **Offset** — `page`/`per_page`. Unchanged, including the read-and-discard * loop DynamoDB forces on us (it has no native offset). The admin UI uses * this, and it is what `include_totals` is for. */ declare function queryWithPagination(ctx: DynamoDBContext, pk: string, params?: ListParams, options?: { skPrefix?: string; indexName?: string; scanIndexForward?: boolean; }): Promise<{ items: T[]; start: number; limit: number; length: number; total?: number; /** Opaque cursor for the next page; keyset mode only, absent on the last. */ next?: string; }>; /** * Generic update operation for DynamoDB */ declare function updateItem(ctx: DynamoDBContext, pk: string, sk: string, updates: Record): Promise; /** * Remove DynamoDB metadata fields from an item */ declare function stripDynamoDBFields(item: T): Omit; /** * Remove null/undefined properties from an object */ declare function removeNullProperties(obj: T): T; /** * Create all DynamoDB adapters for AuthHero * * @param client - DynamoDB Document Client instance * @param config - Configuration options including table name * @returns DataAdapters object with all adapter implementations * * @example * ```typescript * import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; * import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb"; * import createAdapters from "@authhero/aws-adapter"; * * const client = new DynamoDBClient({}); * const docClient = DynamoDBDocumentClient.from(client); * * const adapters = createAdapters(docClient, { * tableName: "authhero", * }); * ``` */ declare function createAdapters(client: DynamoDBDocumentClient, config: DynamoDBConfig): DataAdapters; export { authenticationMethodKeys, brandingKeys, clientConnectionKeys, clientGrantKeys, clientKeys, clientRegistrationTokenKeys, codeKeys, connectionKeys, createActionExecutionsAdapter, createActionVersionsAdapter, createActionsAdapter, createAuthenticationMethodsAdapter, createBrandingAdapter, createClientConnectionsAdapter, createClientGrantsAdapter, createClientsAdapter, createCodesAdapter, createConnectionsAdapter, createCustomDomainsAdapter, createEmailProvidersAdapter, createFlowsAdapter, createFormsAdapter, createHooksAdapter, createInvitesAdapter, createKeysAdapter, createLoginSessionsAdapter, createLogsAdapter, createOrganizationConnectionsAdapter, createOrganizationsAdapter, createPasswordsAdapter, createPromptSettingsAdapter, createProxyDataAdapter, createProxyRoutesAdapter, createRefreshTokensAdapter, createResourceServersAdapter, createRolePermissionsAdapter, createRolesAdapter, createSessionsAdapter, createTenantsAdapter, createThemesAdapter, createUserOrganizationsAdapter, createUserPermissionsAdapter, createUserRolesAdapter, createUsersAdapter, customDomainKeys, customTextKeys, createAdapters as default, deleteItem, emailProviderKeys, emailTemplateKeys, flowKeys, formKeys, getItem, hookKeys, inviteKeys, isKeysetRequest, keyKeys, legacyClientKeys, logKeys, loginSessionKeys, organizationConnectionKeys, organizationKeys, passwordKeys, promptSettingsKeys, proxyRouteKeys, putItem, queryItems, queryWithPagination, refreshTokenKeys, removeNullProperties, resourceServerKeys, roleKeys, rolePermissionKeys, sessionKeys, stripDynamoDBFields, tenantKeys, themeKeys, transactWriteItems, universalLoginTemplateKeys, updateItem, userKeys, userOrganizationKeys, userPermissionKeys, userRoleKeys }; export type { DynamoDBConfig, DynamoDBContext };