@coinlist-co/react 0.0.1
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/README.md +7 -0
- package/dist/chunk-5E3P7AMH.js +20 -0
- package/dist/chunk-5E3P7AMH.js.map +1 -0
- package/dist/chunk-F56RBKNS.js +63 -0
- package/dist/chunk-F56RBKNS.js.map +1 -0
- package/dist/chunk-NLJMUHOG.js +253 -0
- package/dist/chunk-NLJMUHOG.js.map +1 -0
- package/dist/chunk-OETRTIQ4.js +274 -0
- package/dist/chunk-OETRTIQ4.js.map +1 -0
- package/dist/chunk-YJQMJFA7.js +16 -0
- package/dist/chunk-YJQMJFA7.js.map +1 -0
- package/dist/client/components/index.cjs +445 -0
- package/dist/client/components/index.cjs.map +1 -0
- package/dist/client/components/index.d.cts +19 -0
- package/dist/client/components/index.d.ts +19 -0
- package/dist/client/components/index.js +399 -0
- package/dist/client/components/index.js.map +1 -0
- package/dist/client/core/index.cjs +566 -0
- package/dist/client/core/index.cjs.map +1 -0
- package/dist/client/core/index.d.cts +22 -0
- package/dist/client/core/index.d.ts +22 -0
- package/dist/client/core/index.js +35 -0
- package/dist/client/core/index.js.map +1 -0
- package/dist/client/hooks/index.cjs +56 -0
- package/dist/client/hooks/index.cjs.map +1 -0
- package/dist/client/hooks/index.d.cts +14 -0
- package/dist/client/hooks/index.d.ts +14 -0
- package/dist/client/hooks/index.js +9 -0
- package/dist/client/hooks/index.js.map +1 -0
- package/dist/client/index.cjs +621 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +18 -0
- package/dist/client/index.d.ts +18 -0
- package/dist/client/index.js +41 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/styles.css +2 -0
- package/dist/coinlist-client-BH_Cn_7u.d.cts +71 -0
- package/dist/coinlist-client-fkB3J-2a.d.ts +71 -0
- package/dist/oauth-session-g0OPJNKn.d.cts +59 -0
- package/dist/oauth-session-g0OPJNKn.d.ts +59 -0
- package/dist/server/index.cjs +405 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +37 -0
- package/dist/server/index.d.ts +37 -0
- package/dist/server/index.js +142 -0
- package/dist/server/index.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts","../../src/client/CoinListProvider.tsx","../../src/shared/api/http-attributes.ts","../../src/client/core/api/middleware/attach-session-middleware.ts","../../src/shared/api/http.ts","../../src/client/core/api/middleware/session-renewal.ts","../../src/shared/utils.ts","../../src/client/core/api/middleware/device-id.ts","../../src/shared/api/frontline.ts","../../src/client/core/api/middleware/user-agent.ts","../../src/shared/api/http-client.ts","../../src/shared/api/middleware/idempotency-key.ts","../../src/shared/api/middleware/request-retry.ts","../../src/client/core/api/api-client.ts","../../src/shared/types/oauth.ts","../../src/client/core/coinlist-client.ts","../../src/client/hooks/useCoinList.ts","../../src/shared/types/oauth-session.ts","../../src/shared/types/user.ts"],"sourcesContent":["export {\n CoinListProvider,\n type CoinListProviderProps,\n} from '@/client/CoinListProvider';\nexport {\n type ClientConfig,\n type CoinListClient,\n createCoinListClient,\n} from '@/client/core/coinlist-client';\nexport * from '@/client/core/types/client-types';\nexport { useCoinList } from '@/client/hooks/useCoinList';\nexport * from '@/shared/types/oauth';\nexport * from '@/shared/types/oauth-session';\nexport * from '@/shared/types/user';\n","/**\n * Global CoinList initialization for React apps.\n * Wrap your app once at the root; use useCoinList() anywhere below.\n */\n\nimport {\n createContext,\n type ReactNode,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport {\n type ClientConfig,\n type CoinListClient,\n createCoinListClient,\n} from '@/client/core/coinlist-client';\n\nexport type CoinListContextValue = {\n coinlist: CoinListClient;\n isReady: boolean;\n};\n\nexport const CoinListContext = createContext<CoinListContextValue | null>(null);\n\nexport type CoinListProviderProps = {\n config: ClientConfig;\n children: ReactNode;\n};\n\n/**\n * Provide CoinList (api + config) to the tree. Initialize once at app root with your config.\n */\nexport function CoinListProvider({ config, children }: CoinListProviderProps) {\n const [isReady, setIsReady] = useState(false);\n const coinlist = useMemo(() => createCoinListClient(config), [config]);\n\n useEffect(() => {\n let isCancelled = false;\n if (coinlist.getAuthState() === 'unknown') {\n coinlist\n .init()\n .then(() => {\n if (!isCancelled) {\n setIsReady(true);\n }\n })\n .catch(() => {\n if (!isCancelled) {\n setIsReady(true);\n }\n });\n } else {\n setIsReady(true);\n }\n\n return () => {\n isCancelled = true;\n };\n }, [coinlist]);\n\n const value = useMemo(() => ({ coinlist, isReady }), [coinlist, isReady]);\n\n return (\n <CoinListContext.Provider value={value}>\n {children}\n </CoinListContext.Provider>\n );\n}\n","export type HttpRequestAttributes = {\n protected?: boolean;\n userAgent?: boolean;\n idempotencyKey?: boolean;\n /** Zero-based attempt index: 0 = first request, 1 = first retry, etc. */\n retryAttempt?: number;\n renewAttempted?: boolean;\n};\n\nexport type Attributes = Readonly<HttpRequestAttributes>;\n\nconst empty: Attributes = {};\n\nconst concat = (left: Attributes, right: Attributes): Attributes => ({\n ...left,\n ...right,\n});\n\nconst concatAll = (...items: Attributes[]): Attributes => {\n let result = empty;\n for (const item of items) {\n result = concat(result, item);\n }\n return result;\n};\n\nconst protectedRequest = (): Attributes => ({ protected: true });\nconst userAgent = (): Attributes => ({ userAgent: true });\nconst idempotencyKey = (): Attributes => ({\n idempotencyKey: true,\n});\n\n/** Returns attributes with the given retry attempt (zero-based). */\nconst retryAttempt = (attempt: number): Attributes => ({\n retryAttempt: attempt,\n});\nconst renewAttempted = (value: boolean): Attributes => ({\n renewAttempted: value,\n});\n\nconst isProtected = (attrs?: HttpRequestAttributes): boolean =>\n attrs?.protected === true;\nconst needUserAgent = (attrs?: HttpRequestAttributes): boolean =>\n attrs?.userAgent === true;\nconst isIdempotent = (attrs?: HttpRequestAttributes): boolean =>\n attrs?.idempotencyKey === true;\nconst getRetryAttempt = (attrs?: HttpRequestAttributes): number =>\n attrs?.retryAttempt ?? 0;\nconst wasRenewAttempted = (attrs?: HttpRequestAttributes): boolean =>\n attrs?.renewAttempted === true;\n\nexport const Attributes = {\n empty,\n concat,\n concatAll,\n protected: protectedRequest,\n isProtected,\n userAgent,\n needUserAgent,\n idempotencyKey,\n isIdempotent,\n retryAttempt,\n getRetryAttempt,\n renewAttempted,\n wasRenewAttempted,\n} as const;\n","import type { HttpRequest } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\nexport function attachSessionMiddleware(\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>\n): BeforeRequestMiddleware {\n return async (request: HttpRequest): Promise<HttpRequest> => {\n if (!Attributes.isProtected(request.attributes)) {\n return request;\n }\n\n const accessToken = await fetchAccessToken(false);\n if (accessToken === null) {\n return request;\n }\n\n return {\n ...request,\n headers: {\n ...(request.headers ?? {}),\n Authorization: `Bearer ${accessToken.value}`,\n },\n };\n };\n}\n","import {\n Attributes,\n type HttpRequestAttributes,\n} from '@/shared/api/http-attributes';\n\nexport type HttpClientConfig = {\n baseUrl: string;\n xApiVersion: string;\n};\n\nexport type HttpRequest<TBody = unknown> =\n | {\n method: 'GET';\n url: string;\n headers?: Record<string, string>;\n attributes?: HttpRequestAttributes;\n redirect?: RequestRedirect;\n }\n | {\n method: 'POST';\n url: string;\n headers?: Record<string, string>;\n body: TBody;\n attributes?: HttpRequestAttributes;\n redirect?: RequestRedirect;\n };\nexport type HttpResponse<TBody = unknown> = {\n status: number;\n headers?: Record<string, string>;\n body: TBody | null;\n};\n\nexport class HttpError<TBody = unknown> extends Error {\n readonly response: HttpResponse<TBody>;\n\n constructor(response: HttpResponse<TBody>) {\n super(`Request failed with ${response.status} status`);\n this.name = 'HttpError';\n this.response = response;\n }\n}\n\nexport async function makeRequest<TResponse = unknown>(\n request: HttpRequest\n): Promise<HttpResponse<TResponse>> {\n const headers: Record<string, string> = {\n Accept: 'application/json',\n ...(request.method === 'POST' && request.body !== undefined\n ? { 'Content-Type': 'application/json' }\n : {}),\n ...(request.headers ?? {}),\n };\n\n const init: RequestInit = {\n method: request.method,\n headers,\n ...(request.redirect !== undefined ? { redirect: request.redirect } : {}),\n };\n\n if (request.method === 'POST' && request.body !== undefined) {\n init.body = JSON.stringify(request.body);\n }\n\n const response = await fetch(request.url, init);\n const responseHeaders = headersToRecord(response.headers);\n\n if (response.status === 204 || response.status === 205) {\n return {\n status: response.status,\n body: null,\n headers: responseHeaders,\n };\n }\n\n if (response.status >= 300 && response.status < 400) {\n await response.text();\n return {\n status: response.status,\n body: null,\n headers: responseHeaders,\n };\n }\n\n const text = await response.text();\n const body = text ? (JSON.parse(text) as TResponse) : null;\n\n return {\n status: response.status,\n body,\n headers: responseHeaders,\n };\n}\n\nfunction headersToRecord(headers: Headers): Record<string, string> {\n const record: Record<string, string> = {};\n headers.forEach((value, key) => {\n record[key.toLowerCase()] = value;\n });\n return record;\n}\n\nfunction concatAttributes(\n request: HttpRequest,\n attrs: Attributes\n): HttpRequest {\n const nextAttributes = Attributes.concat(\n request.attributes ?? Attributes.empty,\n attrs\n );\n const nextRequest: typeof request = {\n ...request,\n attributes: nextAttributes,\n };\n return nextRequest;\n}\n\nexport const Request = {\n concatAttributes,\n};\n","import { Request } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { AfterRequestMiddleware } from '@/shared/api/http-client';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\nexport function renewSessionMiddleware(\n fetchAccessToken: (refresh: boolean) => Promise<OAuthAccessToken | null>\n): AfterRequestMiddleware {\n return async ({ request, response, retry }) => {\n if (response.status !== 401) {\n return response;\n }\n if (!Attributes.isProtected(request.attributes)) {\n return response;\n }\n if (Attributes.wasRenewAttempted(request.attributes)) {\n return response;\n }\n\n const newToken = await fetchAccessToken(true);\n if (newToken) {\n const nextRequest = Request.concatAttributes(\n request,\n Attributes.renewAttempted(true)\n );\n return retry(nextRequest);\n } else {\n return response;\n }\n };\n}\n","/**\n * Computes SHA-256 digest of the input (UTF-8 string or raw bytes).\n * Uses the Web Crypto API.\n */\nexport async function sha256(data: string | Uint8Array): Promise<ArrayBuffer> {\n const bytes =\n typeof data === 'string' ? new TextEncoder().encode(data) : data;\n const buffer = bytes.buffer.slice(\n bytes.byteOffset,\n bytes.byteOffset + bytes.byteLength\n ) as ArrayBuffer;\n return crypto.subtle.digest('SHA-256', buffer);\n}\n\n/**\n * Converts an ArrayBuffer to Base64-URL encoding (RFC 4648).\n * @param padding - If false, omits trailing '=' padding (e.g. for PKCE).\n */\nexport function arrayBufferToBase64Url(\n buffer: ArrayBuffer,\n padding: boolean = true\n): string {\n const bytes = new Uint8Array(buffer);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n let base64 = btoa(binary);\n base64 = base64.replace(/\\+/g, '-').replace(/\\//g, '_');\n if (!padding) {\n base64 = base64.replace(/=+$/, '');\n }\n return base64;\n}\n\n/**\n * Securely generates random bytes and returns them as Base64-URL (no padding).\n * Suitable for PKCE code_verifier and OAuth state.\n * @param byteLength - Number of random bytes (e.g. 32 for PKCE).\n */\nexport function generateSecureRandomBase64Url(byteLength: number): string {\n const bytes = new Uint8Array(byteLength);\n crypto.getRandomValues(bytes);\n const buffer = bytes.buffer;\n return arrayBufferToBase64Url(buffer, false);\n}\n\n/**\n * Generate a UUID v4 using the standard Web Crypto API (crypto.randomUUID).\n * Falls back to RFC 4122–compliant generation via crypto.getRandomValues in old browsers.\n */\nexport function getUUIDv4(): string {\n if (\n typeof crypto !== 'undefined' &&\n typeof crypto.randomUUID === 'function'\n ) {\n return crypto.randomUUID();\n }\n\n if (\n typeof crypto !== 'undefined' &&\n typeof crypto.getRandomValues === 'function'\n ) {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0'));\n return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${hex.slice(6, 8).join('')}-${hex.slice(8, 10).join('')}-${hex.slice(10, 16).join('')}`;\n }\n\n return `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;\n}\n","'use client';\n\nimport { getUUIDv4 } from '@/shared/utils';\n\nconst DEVICE_ID_KEY = 'coinlist.device_id';\n\n/**\n * Get or create a device ID stored in localStorage.\n * Uses a crypto UUID that persists across sessions.\n */\nexport function getDeviceId(): string {\n let deviceId = localStorage.getItem(DEVICE_ID_KEY);\n\n if (!deviceId) {\n deviceId = getUUIDv4();\n localStorage.setItem(DEVICE_ID_KEY, deviceId);\n }\n\n return deviceId;\n}\n\n/**\n * Clear the stored device ID (useful for testing or logout).\n */\nexport function clearDeviceId(): void {\n localStorage.removeItem(DEVICE_ID_KEY);\n}\n","export const BASE_URL = 'https://mobile-api.coinlist.co';\nexport const HEADER_API_VERSION = 'X-API-Version';\nexport const HEADER_USER_AGENT = 'User-Agent';\nexport const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';\nexport const API_VERSION = '2025-10-17';\n\nexport const COINLIST_OAUTH_URL = 'https://coinlist.co/oauth/authorize';\n","'use client';\n\nimport { getDeviceId } from '@/client/core/api/middleware/device-id';\nimport { HEADER_USER_AGENT } from '@/shared/api/frontline';\nimport type { HttpRequest } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\n\nexport const userAgentMiddleware: BeforeRequestMiddleware = async (\n request: HttpRequest\n): Promise<HttpRequest> => {\n if (!Attributes.needUserAgent(request.attributes)) {\n return request;\n }\n\n const userAgent = generateUserAgent();\n return {\n ...request,\n headers: {\n ...(request.headers ?? {}),\n [HEADER_USER_AGENT]: userAgent,\n },\n };\n};\n\n// Generate User-Agent in the required format for Frontline API\n// Format: <app-info> (<device-info>; DevicePlatform <device-platform>; DeviceAppID <device-app-id>; DeviceID <device-id>)\nfunction generateUserAgent(): string {\n const appInfo = `CoinList/1.0`;\n const deviceInfo = 'Web Browser';\n const devicePlatform = 'DevicePlatform web'; // Must be 'web' for validation\n\n const deviceAppId = 'DeviceAppID co.coinlist.sdk'; // SDK app ID\n\n const deviceId = getDeviceId();\n const finalDeviceId = `DeviceID ${deviceId}`;\n\n return `${appInfo} (${deviceInfo}; ${devicePlatform}; ${deviceAppId}; ${finalDeviceId})`;\n}\n","import { HEADER_API_VERSION } from '@/shared/api/frontline';\nimport type {\n HttpClientConfig,\n HttpRequest,\n HttpResponse,\n} from '@/shared/api/http';\nimport { makeRequest } from '@/shared/api/http';\n\nexport type BeforeRequestMiddleware = (\n request: HttpRequest\n) => Promise<HttpRequest>;\n\nexport type AfterRequestMiddleware = (args: {\n request: HttpRequest;\n response: HttpResponse<unknown>;\n retry: (request?: HttpRequest) => Promise<HttpResponse<unknown>>;\n}) => Promise<HttpResponse<unknown>>;\n\nexport type HttpClientMiddleware = {\n beforeRequest?: BeforeRequestMiddleware[];\n afterRequest?: AfterRequestMiddleware[];\n};\n\nexport class HttpClient {\n constructor(\n readonly config: HttpClientConfig,\n readonly middleware: HttpClientMiddleware = {}\n ) {}\n\n async send<TResponse = unknown>(\n request: HttpRequest\n ): Promise<HttpResponse<TResponse>> {\n return this.runRequestWithAfterMiddleware<TResponse>(request);\n }\n\n /**\n * Runs beforeRequest, executeRequest, then the full afterRequest middleware\n * chain. Used by send() and by the retry() callback so that when a\n * middleware calls retry(), the retried response also goes through all\n * afterRequest middleware (e.g. session renewal, retry). Middleware\n * must use request.attributes.retryAttempt (or similar) to avoid infinite\n * recursion when they trigger retries.\n */\n private async runRequestWithAfterMiddleware<TResponse = unknown>(\n request: HttpRequest\n ): Promise<HttpResponse<TResponse>> {\n const preparedRequest = await this.runBeforeRequestMiddleware(\n this.withClientDefaults(request)\n );\n let response = await this.executeRequest<TResponse>(preparedRequest);\n\n for (const middleware of this.middleware.afterRequest ?? []) {\n response = (await middleware({\n request: preparedRequest,\n response,\n retry: (nextRequest = preparedRequest) =>\n this.runRequestWithAfterMiddleware(nextRequest) as Promise<\n HttpResponse<TResponse>\n >,\n })) as HttpResponse<TResponse>;\n }\n\n return response;\n }\n\n private withClientDefaults(request: HttpRequest): HttpRequest {\n const url = this.resolveUrl(request.url);\n const headers = {\n ...(request.headers ?? {}),\n [HEADER_API_VERSION]: this.config.xApiVersion,\n };\n\n return {\n ...request,\n url,\n headers,\n };\n }\n\n /**\n * Resolves a request URL against the client's baseUrl.\n *\n * @internal Public only for testing. Do not use in application code; use\n * {@link HttpClient.send} with a path and the client will resolve the URL.\n */\n resolveUrl(url: string): string {\n // If already absolute, use as-is.\n if (url.startsWith('http://') || url.startsWith('https://')) {\n return url;\n }\n // Otherwise append path to baseUrl so base path (e.g. /api) is preserved.\n const base = this.config.baseUrl.replace(/\\/$/, '');\n const path = url.startsWith('/') ? url : `/${url}`;\n return base + path;\n }\n\n private async runBeforeRequestMiddleware(\n initialRequest: HttpRequest\n ): Promise<HttpRequest> {\n let request = initialRequest;\n for (const middleware of this.middleware.beforeRequest ?? []) {\n request = await middleware(request);\n }\n\n return request;\n }\n\n private executeRequest<TResponse = unknown>(\n request: HttpRequest\n ): Promise<HttpResponse<TResponse>> {\n return makeRequest<TResponse>(request);\n }\n}\n","import { HEADER_IDEMPOTENCY_KEY } from '@/shared/api/frontline';\nimport type { HttpRequest } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { BeforeRequestMiddleware } from '@/shared/api/http-client';\nimport { getUUIDv4 } from '@/shared/utils';\n\nexport const idempotencyKeyMiddleware: BeforeRequestMiddleware = async (\n request: HttpRequest\n): Promise<HttpRequest> => {\n if (!Attributes.isIdempotent(request.attributes)) {\n return request;\n }\n\n const existingHeaders = request.headers ?? {};\n if (existingHeaders[HEADER_IDEMPOTENCY_KEY]) {\n return request;\n }\n\n return {\n ...request,\n headers: {\n ...existingHeaders,\n [HEADER_IDEMPOTENCY_KEY]: getUUIDv4(),\n },\n };\n};\n","import { Request } from '@/shared/api/http';\nimport { Attributes } from '@/shared/api/http-attributes';\nimport type { AfterRequestMiddleware } from '@/shared/api/http-client';\n\nconst MAX_ATTEMPTS = 3;\nconst INITIAL_DELAY_MS = 300;\nconst MAX_DELAY_MS = 2000;\n\nconst RETRYABLE_4XX = new Set([408, 409, 429]);\n\nexport function isRetryableStatus(status: number): boolean {\n return (status >= 500 && status < 600) || RETRYABLE_4XX.has(status);\n}\n\nfunction getRetryDelayMs(attempt: number): number {\n return Math.min(INITIAL_DELAY_MS * 2 ** (attempt - 1), MAX_DELAY_MS);\n}\n\nexport type RequestRetryMiddlewareOptions = {\n /**\n * Optional delay function. Defaults to real setTimeout-based delay.\n * Use a no-op (e.g. () => Promise.resolve()) in tests to avoid slow tests.\n */\n delayFn?: (ms: number) => Promise<void>;\n};\n\n/**\n * Creates the request retry after-request middleware. Inject a no-op delayFn\n * in tests to avoid real delays (unit testing best practice).\n */\nexport function createRequestRetryMiddleware(\n options: RequestRetryMiddlewareOptions = {}\n): AfterRequestMiddleware {\n const delayFn = options.delayFn ?? defaultDelay;\n\n return async ({ request, response, retry }) => {\n if (!isRetryableStatus(response.status)) {\n return response;\n }\n\n const currentAttempt = Attributes.getRetryAttempt(request.attributes);\n if (currentAttempt >= MAX_ATTEMPTS - 1) {\n return response;\n }\n\n const nextAttempt = currentAttempt + 1;\n await delayFn(getRetryDelayMs(nextAttempt));\n\n const nextRequest = Request.concatAttributes(\n request,\n Attributes.retryAttempt(nextAttempt)\n );\n return retry(nextRequest);\n };\n}\n\nfunction defaultDelay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Retries the request up to 3 times with exponential backoff when the response\n * has a retryable status (5xx server errors). Uses request.attributes.retryAttempt\n * to decide delay and whether to retry, so the middleware does not loop when\n * retry() runs the full HTTP middleware chain again.\n */\nexport const requestRetryMiddleware: AfterRequestMiddleware =\n createRequestRetryMiddleware();\n","'use client';\n\nimport { attachSessionMiddleware } from '@/client/core/api/middleware/attach-session-middleware';\nimport { renewSessionMiddleware } from '@/client/core/api/middleware/session-renewal';\nimport { userAgentMiddleware } from '@/client/core/api/middleware/user-agent';\nimport {\n type HttpClientConfig,\n HttpError,\n type HttpRequest,\n} from '@/shared/api/http';\nimport { HttpClient } from '@/shared/api/http-client';\nimport { idempotencyKeyMiddleware } from '@/shared/api/middleware/idempotency-key';\nimport { requestRetryMiddleware } from '@/shared/api/middleware/request-retry';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\n\nexport class ApiClient {\n private readonly httpClient: HttpClient;\n\n constructor(\n readonly config: HttpClientConfig,\n readonly fetchAccessToken: (\n refresh: boolean\n ) => Promise<OAuthAccessToken | null>\n ) {\n this.httpClient = new HttpClient(this.config, {\n beforeRequest: [\n attachSessionMiddleware(this.fetchAccessToken),\n userAgentMiddleware,\n idempotencyKeyMiddleware,\n ],\n afterRequest: [\n renewSessionMiddleware(this.fetchAccessToken),\n requestRetryMiddleware,\n ],\n });\n }\n\n async send<TResponse>(request: HttpRequest): Promise<TResponse> {\n const response = await this.httpClient.send<TResponse>(request);\n if (response.status >= 200 && response.status < 300) {\n return response.body as TResponse;\n } else {\n throw new HttpError(response);\n }\n }\n}\n","import type { Newtype } from '@/shared/types/newtype';\n\nexport type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;\nexport const AuthorizationCode = (value: string): AuthorizationCode =>\n value as AuthorizationCode;\n\nexport type CodeVerifier = Newtype<string, 'CodeVerifier'>;\nexport const CodeVerifier = (value: string): CodeVerifier =>\n value as CodeVerifier;\n\nexport type CodeChallenge = Newtype<string, 'CodeChallenge'>;\nexport const CodeChallenge = (value: string): CodeChallenge =>\n value as CodeChallenge;\n\nexport type RedirectUri = Newtype<string, 'RedirectUri'>;\nexport const RedirectUri = (value: string): RedirectUri => value as RedirectUri;\n\nexport type ClientId = Newtype<string, 'ClientId'>;\nexport const ClientId = (value: string): ClientId => value as ClientId;\n\nexport type ClientSecret = Newtype<string, 'ClientSecret'>;\nexport const ClientSecret = (value: string): ClientSecret =>\n value as ClientSecret;\n","'use client';\n\nimport { ApiClient } from '@/client/core/api/api-client';\nimport type {\n AuthState,\n OauthClientResult,\n} from '@/client/core/types/client-types';\nimport {\n API_VERSION,\n BASE_URL,\n COINLIST_OAUTH_URL,\n} from '@/shared/api/frontline';\nimport type { Config } from '@/shared/types/config';\nimport { AuthorizationCode, CodeVerifier } from '@/shared/types/oauth';\nimport type { OAuthAccessToken } from '@/shared/types/oauth-session';\nimport {\n arrayBufferToBase64Url,\n generateSecureRandomBase64Url,\n sha256,\n} from '@/shared/utils';\n\n/** Session storage keys for OAuth PKCE (used by startOauth and completeOauth). */\nexport const OAUTH_STATE_KEY = 'coinlist.oauth_state';\nexport const OAUTH_CODE_VERIFIER_KEY = 'coinlist.oauth_code_verifier';\n\nexport interface ClientConfig extends Config {\n /**\n * The SDK user must provide this function. It is responsible for fetching a\n * valid {@link OAuthAccessToken}, or **null** for logged-out users. If your\n * backend is in TypeScript, it is recommended to use\n * {@link CoinListServer#accessToken} from `@/server/coinlist.server`.\n */\n getAccessToken: () => Promise<OAuthAccessToken | null>;\n}\n\nexport interface CoinListClient {\n /**\n * Calls the provided {@link ClientConfig.getAccessToken} lambda to determine\n * the user's {@link AuthState}. This is called automatically by {@link CoinListProvider};\n * you typically do not need to call it yourself unless you are using the client\n * outside of the provider.\n */\n init(): Promise<AuthState>;\n /**\n * Returns the current auth state: `'logged-in'`, `'logged-out'`, or `'unknown'`.\n * Returns **unknown** until {@link CoinListClient.init} has completed. It is\n * recommended to use the `const { isReady, coinlist } = useCoinList()` hook to know when\n * the SDK has initialized, or to manually await {@link CoinListClient.init}\n * before relying on this value.\n */\n getAuthState(): AuthState;\n /**\n * Starts the OAuth flow with PKCE. Generates a random `state` and `code_verifier`,\n * stores them in sessionStorage (for validation in {@link CoinListClient.completeOAuth}\n * on redirect), then redirects the user to the CoinList authorization page. After\n * the user authorizes, they are sent back to your application's redirect URI; call\n * {@link CoinListClient.completeOAuth} on that page to finish the flow.\n */\n startOAuth(): Promise<void>;\n /**\n * Completes the OAuth flow on the FE with PKCE and state validation. Parses the\n * redirect URL (state, code) and validates them against sessionStorage\n * (state, code_verifier). The state check protects against CSRF (cross-site\n * request forgery). Call this on the frontend page the user is redirected\n * to after authorizing.\n *\n * On `ok`: Call your backend to exchange the short-lived `authorizationCode`\n * (and the returned `codeVerifier`) for a long-lived session. If your backend\n * is in TypeScript, you can use {@link CoinListServer#completeOAuth} from\n * `@/server/coinlist.server` (CoinListServer) to perform that exchange.\n *\n * On `error`: `reason` is an {@link OauthClientErrorReason} (e.g. `'missing_state'`, `'invalid_state'`) so you can switch on it and surface a message to the user.\n */\n completeOAuth(): OauthClientResult;\n /**\n * Clears the in-memory access token. Note: you need to manually\n * also logout on the backend via CoinListServer#logout to clear the session cookie.\n */\n logout(): void;\n}\n\nclass CoinListClientImpl implements CoinListClient {\n /** Cached access token: undefined = loading, null = no token, AccessToken = logged in */\n private _accessToken: OAuthAccessToken | null | undefined = undefined;\n // biome-ignore lint/correctness/noUnusedPrivateClassMembers: we'll need it\n private readonly _api: ApiClient;\n\n constructor(readonly _config: ClientConfig) {\n this._api = new ApiClient(\n {\n baseUrl: _config.baseUrl || BASE_URL,\n xApiVersion: API_VERSION,\n },\n this.fetchAccessToken.bind(this)\n );\n }\n\n async init(): Promise<AuthState> {\n await this.fetchAccessToken(true);\n return this.getAuthState();\n }\n\n async fetchAccessToken(refresh: boolean): Promise<OAuthAccessToken | null> {\n if (!refresh && this._accessToken !== undefined) return this._accessToken;\n\n try {\n const accessToken = await this._config.getAccessToken();\n this._accessToken = accessToken;\n return accessToken;\n } catch (_) {\n this._accessToken = null;\n return null;\n }\n }\n\n getAuthState(): AuthState {\n if (this._accessToken === undefined) {\n return 'unknown';\n }\n return this._accessToken !== null ? 'logged-in' : 'logged-out';\n }\n\n async startOAuth(): Promise<void> {\n const state = generateSecureRandomBase64Url(32);\n const codeVerifier = generateSecureRandomBase64Url(32);\n\n const codeChallengeRaw = await sha256(codeVerifier);\n const codeChallenge = arrayBufferToBase64Url(codeChallengeRaw, false);\n\n sessionStorage.setItem(OAUTH_STATE_KEY, state);\n sessionStorage.setItem(OAUTH_CODE_VERIFIER_KEY, codeVerifier);\n\n const params = new URLSearchParams({\n client_id: this._config.clientId,\n response_type: 'code',\n redirect_uri: this._config.redirectUri,\n code_challenge: codeChallenge,\n code_challenge_method: 'S256',\n state,\n });\n const url = `${COINLIST_OAUTH_URL}?${params.toString()}`;\n window.location.href = url;\n }\n\n completeOAuth(): OauthClientResult {\n const params = new URLSearchParams(window.location.search);\n\n const stateParam = params.get('state');\n if (!stateParam) {\n return { type: 'error', reason: 'missing_state' };\n }\n const storedState = sessionStorage.getItem(OAUTH_STATE_KEY);\n if (storedState === null || storedState !== stateParam) {\n return { type: 'error', reason: 'invalid_state' };\n }\n\n const codeParam = params.get('code');\n if (!codeParam) {\n return { type: 'error', reason: 'missing_code' };\n }\n\n const codeVerifierValue = sessionStorage.getItem(OAUTH_CODE_VERIFIER_KEY);\n if (!codeVerifierValue) {\n return { type: 'error', reason: 'missing_code_verifier' };\n }\n\n return {\n type: 'ok',\n code: AuthorizationCode(codeParam),\n codeVerifier: CodeVerifier(codeVerifierValue),\n };\n }\n\n logout(): void {\n this._accessToken = null;\n }\n}\n\nexport function createCoinListClient(config: ClientConfig): CoinListClient {\n return new CoinListClientImpl(config);\n}\n","import { useContext } from 'react';\nimport { CoinListContext } from '@/client/CoinListProvider';\nimport type { CoinListClient } from '@/client/core/coinlist-client';\n\nexport interface UseCoinListResult {\n /**\n * Indicates whether the CoinList client has been initialized and ready to use.\n * While isReady is false, then the current user state will be `unknown`.\n */\n isReady: boolean;\n coinlist: CoinListClient;\n}\n\nexport function useCoinList(): UseCoinListResult {\n const context = useContext(CoinListContext);\n if (context === null) {\n throw new CoinListClientInitializationError();\n }\n\n return {\n isReady: context.isReady,\n coinlist: context.coinlist,\n };\n}\n\nexport class CoinListClientInitializationError extends Error {\n constructor(\n message = 'useCoinList() must be used within CoinListProvider. Wrap your app with <CoinListProvider config={...}>.'\n ) {\n super(message);\n this.name = 'CoinListClientInitializationError';\n }\n}\n","import type { OAuthSessionDto } from '@/shared/types/dto/oauth-session';\nimport type { Newtype } from '@/shared/types/newtype';\n\nexport type OAuthAccessToken = {\n value: string;\n expiresAt: Date;\n};\n\nexport type OAuthRefreshToken = Newtype<string, 'OAuthRefreshToken'>;\nexport const OAuthRefreshToken = (value: string) => value as OAuthRefreshToken;\n\nexport type OAuthSession = {\n accessToken: OAuthAccessToken;\n refreshToken?: OAuthRefreshToken;\n};\n\nexport const OAuthSession = {\n fromDto: (dto: OAuthSessionDto): OAuthSession => {\n const expiresAt = new Date(Date.now() + dto.expires_in * 1000);\n return {\n accessToken: {\n value: dto.access_token,\n expiresAt,\n },\n ...(dto.refresh_token != null && dto.refresh_token !== ''\n ? { refreshToken: OAuthRefreshToken(dto.refresh_token) }\n : undefined),\n };\n },\n};\n","import type { UserDto } from '@/shared/types/dto/user';\nimport type { Newtype } from '@/shared/types/newtype';\n\nexport type UserId = Newtype<string, 'UserId'>;\nexport const UserId = (value: string) => value as UserId;\nexport type UserEmail = Newtype<string, 'UserEmail'>;\nexport const UserEmail = (value: string) => value as UserEmail;\n\nexport type User = {\n id: UserId;\n email: UserEmail;\n};\n\nexport const User = {\n fromDto: (dto: UserDto): User => ({\n id: UserId(dto.id),\n email: UserEmail(dto.email),\n }),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,mBAMO;;;ACAP,IAAM,QAAoB,CAAC;AAE3B,IAAM,SAAS,CAAC,MAAkB,WAAmC;AAAA,EACnE,GAAG;AAAA,EACH,GAAG;AACL;AAEA,IAAM,YAAY,IAAI,U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AO,IAAI;AAAA,QACX;AAAA,MACF;AAAA,MACA,GAAI,IAAI,iBAAiB,QAAQ,IAAI,kBAAkB,KACnD,EAAE,cAAc,kBAAkB,IAAI,aAAa,EAAE,IACrD;AAAA,IACN;AAAA,EACF;AACF;;;ACzBO,IAAM,SAAS,CAAC,UAAkB;AAElC,IAAM,YAAY,CAAC,UAAkB;AAOrC,IAAM,OAAO;AAAA,EAClB,SAAS,CAAC,SAAwB;AAAA,IAChC,IAAI,OAAO,IAAI,EAAE;AAAA,IACjB,OAAO,UAAU,IAAI,KAAK;AAAA,EAC5B;AACF;","names":["userAgent","import_react"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { C as ClientConfig } from '../coinlist-client-BH_Cn_7u.cjs';
|
|
4
|
+
export { A as AuthState, a as CoinListClient, O as OauthClientErrorReason, b as OauthClientResult, c as createCoinListClient } from '../coinlist-client-BH_Cn_7u.cjs';
|
|
5
|
+
export { useCoinList } from './hooks/index.cjs';
|
|
6
|
+
export { A as AuthorizationCode, C as ClientId, a as ClientSecret, b as CodeChallenge, c as CodeVerifier, O as OAuthAccessToken, d as OAuthRefreshToken, e as OAuthSession, R as RedirectUri } from '../oauth-session-g0OPJNKn.cjs';
|
|
7
|
+
export { User, UserEmail, UserId } from './core/index.cjs';
|
|
8
|
+
|
|
9
|
+
type CoinListProviderProps = {
|
|
10
|
+
config: ClientConfig;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Provide CoinList (api + config) to the tree. Initialize once at app root with your config.
|
|
15
|
+
*/
|
|
16
|
+
declare function CoinListProvider({ config, children }: CoinListProviderProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { ClientConfig, CoinListProvider, type CoinListProviderProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { C as ClientConfig } from '../coinlist-client-fkB3J-2a.js';
|
|
4
|
+
export { A as AuthState, a as CoinListClient, O as OauthClientErrorReason, b as OauthClientResult, c as createCoinListClient } from '../coinlist-client-fkB3J-2a.js';
|
|
5
|
+
export { useCoinList } from './hooks/index.js';
|
|
6
|
+
export { A as AuthorizationCode, C as ClientId, a as ClientSecret, b as CodeChallenge, c as CodeVerifier, O as OAuthAccessToken, d as OAuthRefreshToken, e as OAuthSession, R as RedirectUri } from '../oauth-session-g0OPJNKn.js';
|
|
7
|
+
export { User, UserEmail, UserId } from './core/index.js';
|
|
8
|
+
|
|
9
|
+
type CoinListProviderProps = {
|
|
10
|
+
config: ClientConfig;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Provide CoinList (api + config) to the tree. Initialize once at app root with your config.
|
|
15
|
+
*/
|
|
16
|
+
declare function CoinListProvider({ config, children }: CoinListProviderProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { ClientConfig, CoinListProvider, type CoinListProviderProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CoinListProvider,
|
|
3
|
+
useCoinList
|
|
4
|
+
} from "../chunk-F56RBKNS.js";
|
|
5
|
+
import {
|
|
6
|
+
User,
|
|
7
|
+
UserEmail,
|
|
8
|
+
UserId
|
|
9
|
+
} from "../chunk-YJQMJFA7.js";
|
|
10
|
+
import {
|
|
11
|
+
createCoinListClient
|
|
12
|
+
} from "../chunk-OETRTIQ4.js";
|
|
13
|
+
import {
|
|
14
|
+
OAuthRefreshToken,
|
|
15
|
+
OAuthSession
|
|
16
|
+
} from "../chunk-5E3P7AMH.js";
|
|
17
|
+
import {
|
|
18
|
+
AuthorizationCode,
|
|
19
|
+
ClientId,
|
|
20
|
+
ClientSecret,
|
|
21
|
+
CodeChallenge,
|
|
22
|
+
CodeVerifier,
|
|
23
|
+
RedirectUri
|
|
24
|
+
} from "../chunk-NLJMUHOG.js";
|
|
25
|
+
export {
|
|
26
|
+
AuthorizationCode,
|
|
27
|
+
ClientId,
|
|
28
|
+
ClientSecret,
|
|
29
|
+
CodeChallenge,
|
|
30
|
+
CodeVerifier,
|
|
31
|
+
CoinListProvider,
|
|
32
|
+
OAuthRefreshToken,
|
|
33
|
+
OAuthSession,
|
|
34
|
+
RedirectUri,
|
|
35
|
+
User,
|
|
36
|
+
UserEmail,
|
|
37
|
+
UserId,
|
|
38
|
+
createCoinListClient,
|
|
39
|
+
useCoinList
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */
|
|
2
|
+
@import "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap";@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}:root{--color-brand-primary:#171717;--color-brand-primary-hover:#000;--color-brand-primary-active:#262626;--color-accent:#2b3a67;--color-accent-hover:#243057;--color-accent-active:#1d2647;--color-accent-focus:#c7d2fe;--color-accent-subtle:#eef1f8;--color-text-primary:#171717;--color-text-secondary:#8c8c8c;--color-text-disabled:#d1d1d1;--color-text-inverse:#fff;--color-background:#fff;--color-surface:#fafafa;--color-section:#f3f3f3;--color-border:#e5e5e5;--color-divider:#ececec;--color-overlay:#00000080;--color-positive:#15803d;--color-positive-subtle:#dcfce7;--color-negative:#dc2626;--color-negative-subtle:#fee2e2;--color-success:#2c8c5e;--color-success-subtle:#e6f4ec;--color-success-border:#cfe9db;--color-warning:#e08a1a;--color-warning-subtle:#fff7ed;--color-warning-border:#fdead7;--color-error:#b42318;--color-error-subtle:#feeceb;--color-error-border:#fbd5d2}.dark{--color-brand-primary:#f4f4f5;--color-brand-primary-hover:#fff;--color-brand-primary-active:#e4e4e7;--color-accent:#6f82c9;--color-accent-hover:#8799e4;--color-accent-active:#5b6fcf;--color-accent-focus:#6f82c959;--color-accent-subtle:#6f82c91f;--color-text-primary:#f4f4f5;--color-text-secondary:#a1a1aa;--color-text-disabled:#71717a;--color-text-inverse:#171717;--color-background:#0f1115;--color-surface:#161a20;--color-section:#20242c;--color-border:#2a2e35;--color-divider:#323741;--color-overlay:#000000b3;--color-positive:#22c55e;--color-positive-subtle:#22c55e1f;--color-negative:#ef4444;--color-negative-subtle:#ef44441f;--color-success:#34d399;--color-success-subtle:#34d3991f;--color-success-border:#34d39940;--color-warning:#f59e0b;--color-warning-subtle:#f59e0b1f;--color-warning-border:#f59e0b40;--color-error:#f87171;--color-error-subtle:#f871711f;--color-error-border:#f8717140}*{box-sizing:border-box}body{background-color:var(--color-background);color:var(--color-text-primary);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,sans-serif}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-amber-500:oklch(76.9% .188 70.08);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--spacing:.25rem;--container-md:28rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--radius-md:.375rem;--radius-lg:.5rem;--radius-2xl:1rem;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-brand-primary:var(--color-brand-primary);--color-brand-primary-hover:var(--color-brand-primary-hover);--color-brand-primary-active:var(--color-brand-primary-active);--color-accent:var(--color-accent);--color-accent-hover:var(--color-accent-hover);--color-accent-active:var(--color-accent-active);--color-accent-focus:var(--color-accent-focus);--color-accent-subtle:var(--color-accent-subtle);--color-text-primary:var(--color-text-primary);--color-text-secondary:var(--color-text-secondary);--color-text-disabled:var(--color-text-disabled);--color-text-inverse:var(--color-text-inverse);--color-background:var(--color-background);--color-surface:var(--color-surface);--color-section:var(--color-section);--color-border:var(--color-border);--color-divider:var(--color-divider);--color-overlay:var(--color-overlay);--color-positive:var(--color-positive);--color-positive-subtle:var(--color-positive-subtle);--color-negative:var(--color-negative);--color-negative-subtle:var(--color-negative-subtle);--color-success:var(--color-success);--color-success-subtle:var(--color-success-subtle);--color-success-border:var(--color-success-border);--color-warning:var(--color-warning);--color-warning-subtle:var(--color-warning-subtle);--color-warning-border:var(--color-warning-border);--color-error:var(--color-error);--color-error-subtle:var(--color-error-subtle);--color-error-border:var(--color-error-border);--radius-card:24px;--radius-btn:12px}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.collapse{visibility:collapse}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.top-4{top:calc(var(--spacing) * 4)}.right-4{right:calc(var(--spacing) * 4)}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.mt-4{margin-top:calc(var(--spacing) * 4)}.contents{display:contents}.flex{display:flex}.grid{display:grid}.inline{display:inline}.inline-flex{display:inline-flex}.h-3{height:calc(var(--spacing) * 3)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-9{height:calc(var(--spacing) * 9)}.h-11{height:calc(var(--spacing) * 11)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-\[18px\]{height:18px}.h-auto{height:auto}.min-h-0{min-height:calc(var(--spacing) * 0)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-28{width:calc(var(--spacing) * 28)}.w-80{width:calc(var(--spacing) * 80)}.w-96{width:calc(var(--spacing) * 96)}.w-\[16px\]{width:16px}.w-\[448px\]{width:448px}.w-auto{width:auto}.w-full{width:100%}.max-w-md{max-width:var(--container-md)}.shrink-0{flex-shrink:0}.rotate-90{rotate:90deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.grid-rows-\[0fr\]{grid-template-rows:0fr}.grid-rows-\[1fr\]{grid-template-rows:1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-\[5px\]{gap:5px}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:var(--color-border)}:where(.divide-divider>:not(:last-child)){border-color:var(--color-divider)}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-btn{border-radius:var(--radius-btn)}.rounded-card{border-radius:var(--radius-card)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-amber-500{border-color:var(--color-amber-500)}.border-border{border-color:var(--color-border)}.border-current{border-color:currentColor}.border-error-border{border-color:var(--color-error-border)}.border-success-border{border-color:var(--color-success-border)}.border-warning-border{border-color:var(--color-warning-border)}.border-t-transparent{border-top-color:#0000}.bg-background{background-color:var(--color-background)}.bg-brand-primary{background-color:var(--color-brand-primary)}.bg-error-subtle{background-color:var(--color-error-subtle)}.bg-section{background-color:var(--color-section)}.bg-success-subtle{background-color:var(--color-success-subtle)}.bg-surface{background-color:var(--color-surface)}.bg-transparent{background-color:#0000}.bg-warning-subtle{background-color:var(--color-warning-subtle)}.p-0{padding:calc(var(--spacing) * 0)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-3{padding:calc(var(--spacing) * 3)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[14px\]{font-size:14px}.text-\[16px\]{font-size:16px}.text-\[18px\]{font-size:18px}.text-\[22px\]{font-size:22px}.text-\[28px\]{font-size:28px}.text-\[36px\]{font-size:36px}.text-\[48px\]{font-size:48px}.text-\[64px\]{font-size:64px}.leading-\[110\%\]{--tw-leading:110%;line-height:110%}.leading-\[120\%\]{--tw-leading:120%;line-height:120%}.leading-\[125\%\]{--tw-leading:125%;line-height:125%}.leading-\[130\%\]{--tw-leading:130%;line-height:130%}.leading-\[135\%\]{--tw-leading:135%;line-height:135%}.leading-\[140\%\]{--tw-leading:140%;line-height:140%}.leading-\[150\%\]{--tw-leading:150%;line-height:150%}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[0\.12px\]{--tw-tracking:.12px;letter-spacing:.12px}.tracking-\[0\.28px\]{--tw-tracking:.28px;letter-spacing:.28px}.whitespace-nowrap{white-space:nowrap}.text-error{color:var(--color-error)}.text-success{color:var(--color-success)}.text-text-inverse{color:var(--color-text-inverse)}.text-text-primary{color:var(--color-text-primary)}.text-text-secondary{color:var(--color-text-secondary)}.text-warning{color:var(--color-warning)}.capitalize{text-transform:capitalize}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.opacity-60{opacity:.6}.shadow-card{--tw-shadow:0px 4px 6px -2px var(--tw-shadow-color,#0000000d), 0px 12px 24px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition-\[grid-template-rows\]{transition-property:grid-template-rows;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}@media (hover:hover){.hover\:bg-\[\#fcdcd8\]:hover{background-color:#fcdcd8}.hover\:bg-border:hover{background-color:var(--color-border)}.hover\:bg-brand-primary-hover:hover{background-color:var(--color-brand-primary-hover)}.hover\:bg-section:hover{background-color:var(--color-section)}.hover\:bg-surface:hover{background-color:var(--color-surface)}.hover\:text-\[\#8b1a13\]:hover{color:#8b1a13}.hover\:text-text-primary:hover{color:var(--color-text-primary)}.hover\:underline:hover{text-decoration-line:underline}}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus-visible\:ring-gray-400:focus-visible{--tw-ring-color:var(--color-gray-400)}.focus-visible\:ring-gray-500:focus-visible{--tw-ring-color:var(--color-gray-500)}.focus-visible\:ring-red-400:focus-visible{--tw-ring-color:var(--color-red-400)}.focus-visible\:ring-red-500:focus-visible{--tw-ring-color:var(--color-red-500)}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\:bg-\[\#d9d9d9\]:active{background-color:#d9d9d9}.active\:bg-\[\#f9c9c4\]:active{background-color:#f9c9c4}.active\:bg-border:active{background-color:var(--color-border)}.active\:bg-brand-primary-active:active{background-color:var(--color-brand-primary-active)}.active\:text-\[\#6d1510\]:active{color:#6d1510}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:opacity-40:disabled{opacity:.4}@media (prefers-color-scheme:dark){@media (hover:hover){.dark\:hover\:bg-\[rgba\(248\,113\,113\,0\.20\)\]:hover{background-color:#f8717133}.dark\:hover\:text-\[\#fca5a5\]:hover{color:#fca5a5}}.dark\:active\:bg-\[rgba\(248\,113\,113\,0\.30\)\]:active{background-color:#f871714d}.dark\:active\:bg-divider:active{background-color:var(--color-divider)}.dark\:active\:text-\[\#f87171\]:active{color:#f87171}}.\[\&_circle\]\:fill-error-subtle circle{fill:var(--color-error-subtle)}.\[\&_circle\]\:fill-success-subtle circle{fill:var(--color-success-subtle)}.\[\&_circle\]\:fill-warning-subtle circle{fill:var(--color-warning-subtle)}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { A as AuthorizationCode, c as CodeVerifier, f as Config, O as OAuthAccessToken } from './oauth-session-g0OPJNKn.cjs';
|
|
2
|
+
|
|
3
|
+
type AuthState = 'unknown' | 'logged-in' | 'logged-out';
|
|
4
|
+
/** Discriminated error reasons from {@link CoinListClient.completeOauth}. */
|
|
5
|
+
type OauthClientErrorReason = 'missing_state' | 'invalid_state' | 'missing_code' | 'missing_code_verifier';
|
|
6
|
+
type OauthClientResult = {
|
|
7
|
+
type: 'ok';
|
|
8
|
+
code: AuthorizationCode;
|
|
9
|
+
codeVerifier: CodeVerifier;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'error';
|
|
12
|
+
reason: OauthClientErrorReason;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface ClientConfig extends Config {
|
|
16
|
+
/**
|
|
17
|
+
* The SDK user must provide this function. It is responsible for fetching a
|
|
18
|
+
* valid {@link OAuthAccessToken}, or **null** for logged-out users. If your
|
|
19
|
+
* backend is in TypeScript, it is recommended to use
|
|
20
|
+
* {@link CoinListServer#accessToken} from `@/server/coinlist.server`.
|
|
21
|
+
*/
|
|
22
|
+
getAccessToken: () => Promise<OAuthAccessToken | null>;
|
|
23
|
+
}
|
|
24
|
+
interface CoinListClient {
|
|
25
|
+
/**
|
|
26
|
+
* Calls the provided {@link ClientConfig.getAccessToken} lambda to determine
|
|
27
|
+
* the user's {@link AuthState}. This is called automatically by {@link CoinListProvider};
|
|
28
|
+
* you typically do not need to call it yourself unless you are using the client
|
|
29
|
+
* outside of the provider.
|
|
30
|
+
*/
|
|
31
|
+
init(): Promise<AuthState>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the current auth state: `'logged-in'`, `'logged-out'`, or `'unknown'`.
|
|
34
|
+
* Returns **unknown** until {@link CoinListClient.init} has completed. It is
|
|
35
|
+
* recommended to use the `const { isReady, coinlist } = useCoinList()` hook to know when
|
|
36
|
+
* the SDK has initialized, or to manually await {@link CoinListClient.init}
|
|
37
|
+
* before relying on this value.
|
|
38
|
+
*/
|
|
39
|
+
getAuthState(): AuthState;
|
|
40
|
+
/**
|
|
41
|
+
* Starts the OAuth flow with PKCE. Generates a random `state` and `code_verifier`,
|
|
42
|
+
* stores them in sessionStorage (for validation in {@link CoinListClient.completeOAuth}
|
|
43
|
+
* on redirect), then redirects the user to the CoinList authorization page. After
|
|
44
|
+
* the user authorizes, they are sent back to your application's redirect URI; call
|
|
45
|
+
* {@link CoinListClient.completeOAuth} on that page to finish the flow.
|
|
46
|
+
*/
|
|
47
|
+
startOAuth(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Completes the OAuth flow on the FE with PKCE and state validation. Parses the
|
|
50
|
+
* redirect URL (state, code) and validates them against sessionStorage
|
|
51
|
+
* (state, code_verifier). The state check protects against CSRF (cross-site
|
|
52
|
+
* request forgery). Call this on the frontend page the user is redirected
|
|
53
|
+
* to after authorizing.
|
|
54
|
+
*
|
|
55
|
+
* On `ok`: Call your backend to exchange the short-lived `authorizationCode`
|
|
56
|
+
* (and the returned `codeVerifier`) for a long-lived session. If your backend
|
|
57
|
+
* is in TypeScript, you can use {@link CoinListServer#completeOAuth} from
|
|
58
|
+
* `@/server/coinlist.server` (CoinListServer) to perform that exchange.
|
|
59
|
+
*
|
|
60
|
+
* On `error`: `reason` is an {@link OauthClientErrorReason} (e.g. `'missing_state'`, `'invalid_state'`) so you can switch on it and surface a message to the user.
|
|
61
|
+
*/
|
|
62
|
+
completeOAuth(): OauthClientResult;
|
|
63
|
+
/**
|
|
64
|
+
* Clears the in-memory access token. Note: you need to manually
|
|
65
|
+
* also logout on the backend via CoinListServer#logout to clear the session cookie.
|
|
66
|
+
*/
|
|
67
|
+
logout(): void;
|
|
68
|
+
}
|
|
69
|
+
declare function createCoinListClient(config: ClientConfig): CoinListClient;
|
|
70
|
+
|
|
71
|
+
export { type AuthState as A, type ClientConfig as C, type OauthClientErrorReason as O, type CoinListClient as a, type OauthClientResult as b, createCoinListClient as c };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { A as AuthorizationCode, c as CodeVerifier, f as Config, O as OAuthAccessToken } from './oauth-session-g0OPJNKn.js';
|
|
2
|
+
|
|
3
|
+
type AuthState = 'unknown' | 'logged-in' | 'logged-out';
|
|
4
|
+
/** Discriminated error reasons from {@link CoinListClient.completeOauth}. */
|
|
5
|
+
type OauthClientErrorReason = 'missing_state' | 'invalid_state' | 'missing_code' | 'missing_code_verifier';
|
|
6
|
+
type OauthClientResult = {
|
|
7
|
+
type: 'ok';
|
|
8
|
+
code: AuthorizationCode;
|
|
9
|
+
codeVerifier: CodeVerifier;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'error';
|
|
12
|
+
reason: OauthClientErrorReason;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface ClientConfig extends Config {
|
|
16
|
+
/**
|
|
17
|
+
* The SDK user must provide this function. It is responsible for fetching a
|
|
18
|
+
* valid {@link OAuthAccessToken}, or **null** for logged-out users. If your
|
|
19
|
+
* backend is in TypeScript, it is recommended to use
|
|
20
|
+
* {@link CoinListServer#accessToken} from `@/server/coinlist.server`.
|
|
21
|
+
*/
|
|
22
|
+
getAccessToken: () => Promise<OAuthAccessToken | null>;
|
|
23
|
+
}
|
|
24
|
+
interface CoinListClient {
|
|
25
|
+
/**
|
|
26
|
+
* Calls the provided {@link ClientConfig.getAccessToken} lambda to determine
|
|
27
|
+
* the user's {@link AuthState}. This is called automatically by {@link CoinListProvider};
|
|
28
|
+
* you typically do not need to call it yourself unless you are using the client
|
|
29
|
+
* outside of the provider.
|
|
30
|
+
*/
|
|
31
|
+
init(): Promise<AuthState>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the current auth state: `'logged-in'`, `'logged-out'`, or `'unknown'`.
|
|
34
|
+
* Returns **unknown** until {@link CoinListClient.init} has completed. It is
|
|
35
|
+
* recommended to use the `const { isReady, coinlist } = useCoinList()` hook to know when
|
|
36
|
+
* the SDK has initialized, or to manually await {@link CoinListClient.init}
|
|
37
|
+
* before relying on this value.
|
|
38
|
+
*/
|
|
39
|
+
getAuthState(): AuthState;
|
|
40
|
+
/**
|
|
41
|
+
* Starts the OAuth flow with PKCE. Generates a random `state` and `code_verifier`,
|
|
42
|
+
* stores them in sessionStorage (for validation in {@link CoinListClient.completeOAuth}
|
|
43
|
+
* on redirect), then redirects the user to the CoinList authorization page. After
|
|
44
|
+
* the user authorizes, they are sent back to your application's redirect URI; call
|
|
45
|
+
* {@link CoinListClient.completeOAuth} on that page to finish the flow.
|
|
46
|
+
*/
|
|
47
|
+
startOAuth(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Completes the OAuth flow on the FE with PKCE and state validation. Parses the
|
|
50
|
+
* redirect URL (state, code) and validates them against sessionStorage
|
|
51
|
+
* (state, code_verifier). The state check protects against CSRF (cross-site
|
|
52
|
+
* request forgery). Call this on the frontend page the user is redirected
|
|
53
|
+
* to after authorizing.
|
|
54
|
+
*
|
|
55
|
+
* On `ok`: Call your backend to exchange the short-lived `authorizationCode`
|
|
56
|
+
* (and the returned `codeVerifier`) for a long-lived session. If your backend
|
|
57
|
+
* is in TypeScript, you can use {@link CoinListServer#completeOAuth} from
|
|
58
|
+
* `@/server/coinlist.server` (CoinListServer) to perform that exchange.
|
|
59
|
+
*
|
|
60
|
+
* On `error`: `reason` is an {@link OauthClientErrorReason} (e.g. `'missing_state'`, `'invalid_state'`) so you can switch on it and surface a message to the user.
|
|
61
|
+
*/
|
|
62
|
+
completeOAuth(): OauthClientResult;
|
|
63
|
+
/**
|
|
64
|
+
* Clears the in-memory access token. Note: you need to manually
|
|
65
|
+
* also logout on the backend via CoinListServer#logout to clear the session cookie.
|
|
66
|
+
*/
|
|
67
|
+
logout(): void;
|
|
68
|
+
}
|
|
69
|
+
declare function createCoinListClient(config: ClientConfig): CoinListClient;
|
|
70
|
+
|
|
71
|
+
export { type AuthState as A, type ClientConfig as C, type OauthClientErrorReason as O, type CoinListClient as a, type OauthClientResult as b, createCoinListClient as c };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
declare const __brand: unique symbol;
|
|
2
|
+
type Newtype<Base, Branding> = Base & {
|
|
3
|
+
readonly [__brand]: Branding;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;
|
|
7
|
+
declare const AuthorizationCode: (value: string) => AuthorizationCode;
|
|
8
|
+
type CodeVerifier = Newtype<string, 'CodeVerifier'>;
|
|
9
|
+
declare const CodeVerifier: (value: string) => CodeVerifier;
|
|
10
|
+
type CodeChallenge = Newtype<string, 'CodeChallenge'>;
|
|
11
|
+
declare const CodeChallenge: (value: string) => CodeChallenge;
|
|
12
|
+
type RedirectUri = Newtype<string, 'RedirectUri'>;
|
|
13
|
+
declare const RedirectUri: (value: string) => RedirectUri;
|
|
14
|
+
type ClientId = Newtype<string, 'ClientId'>;
|
|
15
|
+
declare const ClientId: (value: string) => ClientId;
|
|
16
|
+
type ClientSecret = Newtype<string, 'ClientSecret'>;
|
|
17
|
+
declare const ClientSecret: (value: string) => ClientSecret;
|
|
18
|
+
|
|
19
|
+
interface Config {
|
|
20
|
+
/** OAuth2 public identifier. */
|
|
21
|
+
readonly clientId: ClientId;
|
|
22
|
+
/**
|
|
23
|
+
* OAuth2 redirect URI. Recommended to point to a frontend page where
|
|
24
|
+
* {@link CoinListClient#completeOauth} can be called to complete the PKCE
|
|
25
|
+
* flow on the client side.
|
|
26
|
+
*/
|
|
27
|
+
readonly redirectUri: RedirectUri;
|
|
28
|
+
/**
|
|
29
|
+
* Recommended to leave undefined. Used to change the CoinList environment;
|
|
30
|
+
* default is production.
|
|
31
|
+
*/
|
|
32
|
+
readonly baseUrl?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* OAuth 2.0 token response (RFC 6749 §5.1).
|
|
37
|
+
* Maps to OpenAPI schema OauthToken.
|
|
38
|
+
*/
|
|
39
|
+
type OAuthSessionDto = {
|
|
40
|
+
access_token: string;
|
|
41
|
+
expires_in: number;
|
|
42
|
+
refresh_token?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type OAuthAccessToken = {
|
|
46
|
+
value: string;
|
|
47
|
+
expiresAt: Date;
|
|
48
|
+
};
|
|
49
|
+
type OAuthRefreshToken = Newtype<string, 'OAuthRefreshToken'>;
|
|
50
|
+
declare const OAuthRefreshToken: (value: string) => OAuthRefreshToken;
|
|
51
|
+
type OAuthSession = {
|
|
52
|
+
accessToken: OAuthAccessToken;
|
|
53
|
+
refreshToken?: OAuthRefreshToken;
|
|
54
|
+
};
|
|
55
|
+
declare const OAuthSession: {
|
|
56
|
+
fromDto: (dto: OAuthSessionDto) => OAuthSession;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { AuthorizationCode as A, ClientId as C, type Newtype as N, type OAuthAccessToken as O, RedirectUri as R, ClientSecret as a, CodeChallenge as b, CodeVerifier as c, OAuthRefreshToken as d, OAuthSession as e, type Config as f };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
declare const __brand: unique symbol;
|
|
2
|
+
type Newtype<Base, Branding> = Base & {
|
|
3
|
+
readonly [__brand]: Branding;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;
|
|
7
|
+
declare const AuthorizationCode: (value: string) => AuthorizationCode;
|
|
8
|
+
type CodeVerifier = Newtype<string, 'CodeVerifier'>;
|
|
9
|
+
declare const CodeVerifier: (value: string) => CodeVerifier;
|
|
10
|
+
type CodeChallenge = Newtype<string, 'CodeChallenge'>;
|
|
11
|
+
declare const CodeChallenge: (value: string) => CodeChallenge;
|
|
12
|
+
type RedirectUri = Newtype<string, 'RedirectUri'>;
|
|
13
|
+
declare const RedirectUri: (value: string) => RedirectUri;
|
|
14
|
+
type ClientId = Newtype<string, 'ClientId'>;
|
|
15
|
+
declare const ClientId: (value: string) => ClientId;
|
|
16
|
+
type ClientSecret = Newtype<string, 'ClientSecret'>;
|
|
17
|
+
declare const ClientSecret: (value: string) => ClientSecret;
|
|
18
|
+
|
|
19
|
+
interface Config {
|
|
20
|
+
/** OAuth2 public identifier. */
|
|
21
|
+
readonly clientId: ClientId;
|
|
22
|
+
/**
|
|
23
|
+
* OAuth2 redirect URI. Recommended to point to a frontend page where
|
|
24
|
+
* {@link CoinListClient#completeOauth} can be called to complete the PKCE
|
|
25
|
+
* flow on the client side.
|
|
26
|
+
*/
|
|
27
|
+
readonly redirectUri: RedirectUri;
|
|
28
|
+
/**
|
|
29
|
+
* Recommended to leave undefined. Used to change the CoinList environment;
|
|
30
|
+
* default is production.
|
|
31
|
+
*/
|
|
32
|
+
readonly baseUrl?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* OAuth 2.0 token response (RFC 6749 §5.1).
|
|
37
|
+
* Maps to OpenAPI schema OauthToken.
|
|
38
|
+
*/
|
|
39
|
+
type OAuthSessionDto = {
|
|
40
|
+
access_token: string;
|
|
41
|
+
expires_in: number;
|
|
42
|
+
refresh_token?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type OAuthAccessToken = {
|
|
46
|
+
value: string;
|
|
47
|
+
expiresAt: Date;
|
|
48
|
+
};
|
|
49
|
+
type OAuthRefreshToken = Newtype<string, 'OAuthRefreshToken'>;
|
|
50
|
+
declare const OAuthRefreshToken: (value: string) => OAuthRefreshToken;
|
|
51
|
+
type OAuthSession = {
|
|
52
|
+
accessToken: OAuthAccessToken;
|
|
53
|
+
refreshToken?: OAuthRefreshToken;
|
|
54
|
+
};
|
|
55
|
+
declare const OAuthSession: {
|
|
56
|
+
fromDto: (dto: OAuthSessionDto) => OAuthSession;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { AuthorizationCode as A, ClientId as C, type Newtype as N, type OAuthAccessToken as O, RedirectUri as R, ClientSecret as a, CodeChallenge as b, CodeVerifier as c, OAuthRefreshToken as d, OAuthSession as e, type Config as f };
|