createNativeUserIdentifierResolver (utils/native-user-identifier.ts)

AFFiNE · packages/frontend/core/src/mobile/utils/native-user-identifier.ts · typescript · MIT
auth, tag:embed-classified

Resolves native user identifiers with session revalidation logic.

// Source: https://github.com/toeverything/AFFiNE | License: MIT | Copyright 2022-present TOEVERYTHING PTE. LTD. and its affiliates
// Provided via justclaw.it.com; keep this notice with the code.
import type { AuthService } from '../../modules/cloud/services/auth';

export interface NativeUserIdentifierAuthService {
  session: Pick<AuthService['session'], 'account$' | 'waitForRevalidation'>;
}

interface NativeUserIdentifierResolverOptions {
  revalidationTimeoutMs?: number;
  revalidationCooldownMs?: number;
}

const getAccountIdentifier = (identifier: string | null | undefined) => {
  const trimmedIdentifier = identifier?.trim();
  return trimmedIdentifier ? trimmedIdentifier : null;
};

export const createNativeUserIdentifierResolver = ({
  revalidationTimeoutMs = 1500,
  revalidationC

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key