/** * Public, **unauthenticated** client for the Tagada onboarding endpoints. * * This is intentionally *not* a `Resource` on the main `Tagada` class because * `Tagada` requires an API key in its constructor — but the whole point of * onboarding is to *get* an API key. So we ship this as a standalone client * that bypasses {@link HttpClient} entirely and uses `fetch` directly. * * Hits: * - `POST {baseUrl}/api/public/onboarding/start` * - `POST {baseUrl}/api/public/onboarding/verify` * * For a turn-key interactive flow, prefer the bundled `tagada-init` CLI: * `npx -p @tagadapay/node-sdk tagada-init you@example.com` * * @example * ```ts * import Tagada from '@tagadapay/node-sdk'; * * const client = Tagada.public(); * * await client.start({ email: 'you@example.com', source: 'cli' }); * // ...prompt the user for the 6-digit code from their inbox... * const { apiKey, storeId } = await client.verify({ * email: 'you@example.com', * code: '384921', * source: 'cli', * }); * * // Now build a regular Tagada client with the new key: * const tagada = new Tagada(apiKey); * ``` */ export interface OnboardingClientOptions { /** * Base URL of the TagadaPay API (no path suffix). Default: * `https://api.tagada.io`. Override for local development: * `http://localhost:3000`. */ baseUrl?: string; /** Per-request timeout, default 30s. */ timeout?: number; } export interface OnboardingStartInput { /** Email that will receive the 6-digit code. */ email: string; /** Free-form source tag (e.g. `'cli'`, `'docs'`, `'partner_xyz'`). */ source?: string; /** Optional acquisition payload. Kept opaque so we can add fields later. */ utm?: Record; } export interface OnboardingStartResult { ok: true; /** ISO-8601 timestamp at which the issued code stops working. */ expiresAt: string; } export interface OnboardingVerifyInput extends OnboardingStartInput { /** Exactly 6 digits. */ code: string; } export interface OnboardingVerifyResult { ok: true; /** Use this immediately as `new Tagada(apiKey)`. */ apiKey: string; accountId: string; storeId: string; clerkUserId: string; clerkOrgId: string; /** Slug of the auto-created Clerk org (used by the CRM URL scheme). */ orgSlug: string | null; /** * Products / payment flow / funnel are seeded asynchronously via Inngest. * Poll `tagada.stores.retrieve(storeId).config.demoSeeding` if you need * to wait for it before running an end-to-end test. */ demoSeeding: 'pending'; } export type OnboardingErrorCode = 'invalid_request' | 'invalid_code' | 'expired' | 'no_pending_code' | 'too_many_attempts' | 'rate_limited' | 'email_send_failed' | 'provisioning_failed' | 'network_error' | 'unknown'; export declare class OnboardingError extends Error { readonly code: OnboardingErrorCode; readonly statusCode: number | null; readonly resetAt: Date | null; readonly raw: unknown; constructor(opts: { message: string; code: OnboardingErrorCode; statusCode?: number | null; resetAt?: Date | null; raw?: unknown; }); } export declare class OnboardingClient { private readonly baseUrl; private readonly timeout; constructor(opts?: OnboardingClientOptions); /** * Issue a fresh 6-digit verification code to the supplied email. Returns * once the code has been queued for delivery — typically lands in the * inbox within a few seconds. * * @throws {OnboardingError} `rate_limited` (429), `email_send_failed` * (502), `invalid_request` (400), `network_error`, or `unknown`. */ start(input: OnboardingStartInput): Promise; /** * Verify the code; on success provisions a fresh sandbox account and * returns its API key + IDs. * * @throws {OnboardingError} `invalid_code` (401), `expired` (410), * `no_pending_code` (410), `too_many_attempts` (429), * `rate_limited` (429), `provisioning_failed` (5xx), * `invalid_request` (400), `network_error`, or `unknown`. */ verify(input: OnboardingVerifyInput): Promise; private post; } //# sourceMappingURL=OnboardingClient.d.ts.map