cilantro-sdk 0.0.20 → 0.0.22
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/dist/api/wallets/wallets.d.ts +2 -2
- package/dist/api/wallets/wallets.d.ts.map +1 -1
- package/dist/auth.cjs.map +2 -2
- package/dist/auth.d.ts +4 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.mjs.map +2 -2
- package/dist/helpers.cjs +128 -3
- package/dist/helpers.cjs.map +3 -3
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.mjs +125 -3
- package/dist/helpers.mjs.map +3 -3
- package/dist/index.cjs +123 -3
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +123 -3
- package/dist/index.mjs.map +3 -3
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/startPasskeyAuthenticationDto.d.ts +12 -0
- package/dist/models/startPasskeyAuthenticationDto.d.ts.map +1 -0
- package/dist/signers/index.d.ts +1 -1
- package/dist/signers/index.d.ts.map +1 -1
- package/dist/signers/passkeyHelpers.d.ts +66 -0
- package/dist/signers/passkeyHelpers.d.ts.map +1 -1
- package/dist/utils.cjs.map +2 -2
- package/dist/utils.mjs.map +2 -2
- package/dist/wallet.cjs +7 -2
- package/dist/wallet.cjs.map +2 -2
- package/dist/wallet.d.ts +2 -2
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.mjs +7 -2
- package/dist/wallet.mjs.map +2 -2
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* API documentation for Cilantro Smart API v2 - A Solana wallet management system
|
|
6
6
|
* OpenAPI spec version: 2.0
|
|
7
7
|
*/
|
|
8
|
-
import type { AddSignerDto, BatchCreateWalletDto, BatchSendSolDto, BatchSendSplDto, CreateApiKeySignerDto, CreateEmailSignerDto, CreateExternalWalletSignerDto, CreatePhoneSignerDto, CreateWalletDto, MintNftDto, MintNftSimpleDto, MintTokenDto, PasskeyAuthenticationDto, PasskeyRegistrationDto, PrepareTransactionDto, SendSolDto, SendSplDto, SendTransactionDto, SignMessageDto, SimulateTransactionDto, SubmitTransactionDto, UpdateAdminSignerDto, UpdateDeviceIdentityDto, UpdateSignerDto, UpdateSignerPermissionsDto, UpdateWalletDto, WalletAssetResponseDto, WalletControllerFindAllParams, WalletControllerGetDeviceEncryptedSecretParams, WalletControllerGetWalletAssetsParams, WalletControllerMintNFT200, WalletControllerMintNFTSimple200, WalletControllerMintToken200, WalletControllerPrepareTransaction200, WalletControllerSendSOL200, WalletControllerSendSPL200, WalletControllerSendTransaction200, WalletControllerSignMessage200, WalletControllerSubmitTransaction200 } from "../../models";
|
|
8
|
+
import type { AddSignerDto, BatchCreateWalletDto, BatchSendSolDto, BatchSendSplDto, CreateApiKeySignerDto, CreateEmailSignerDto, CreateExternalWalletSignerDto, CreatePhoneSignerDto, CreateWalletDto, MintNftDto, MintNftSimpleDto, MintTokenDto, PasskeyAuthenticationDto, PasskeyRegistrationDto, PrepareTransactionDto, SendSolDto, SendSplDto, SendTransactionDto, SignMessageDto, SimulateTransactionDto, StartPasskeyAuthenticationDto, SubmitTransactionDto, UpdateAdminSignerDto, UpdateDeviceIdentityDto, UpdateSignerDto, UpdateSignerPermissionsDto, UpdateWalletDto, WalletAssetResponseDto, WalletControllerFindAllParams, WalletControllerGetDeviceEncryptedSecretParams, WalletControllerGetWalletAssetsParams, WalletControllerMintNFT200, WalletControllerMintNFTSimple200, WalletControllerMintToken200, WalletControllerPrepareTransaction200, WalletControllerSendSOL200, WalletControllerSendSPL200, WalletControllerSendTransaction200, WalletControllerSignMessage200, WalletControllerSubmitTransaction200 } from "../../models";
|
|
9
9
|
import { customInstance } from "../../api-client";
|
|
10
10
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
11
11
|
export declare const getWallets: () => {
|
|
@@ -35,7 +35,7 @@ export declare const getWallets: () => {
|
|
|
35
35
|
walletControllerCreatePhoneSigner: (id: string, createPhoneSignerDto: CreatePhoneSignerDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
36
36
|
walletControllerStartPasskeyRegistration: (id: string, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
37
37
|
walletControllerVerifyPasskeyRegistration: (id: string, passkeyRegistrationDto: PasskeyRegistrationDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
38
|
-
walletControllerStartPasskeyAuthentication: (id: string, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
38
|
+
walletControllerStartPasskeyAuthentication: (id: string, startPasskeyAuthenticationDto: StartPasskeyAuthenticationDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
39
39
|
walletControllerVerifyPasskeyAuthentication: (id: string, passkeyAuthenticationDto: PasskeyAuthenticationDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
40
40
|
walletControllerCreateExternalWalletSigner: (id: string, createExternalWalletSignerDto: CreateExternalWalletSignerDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
41
41
|
walletControllerCreateApiKeySigner: (id: string, createApiKeySignerDto: CreateApiKeySignerDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../../src/api/wallets/wallets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,uB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M,uCAAuC,GAAG,WAAW,CAC/D,OAAO,CACL,UAAU,CACR,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,mCAAmC,CAAC,CACnE,CACF,CACF,CAAC;AACF,MAAM,MAAM,wCAAwC,GAAG,WAAW,CAChE,OAAO,CACL,UAAU,CACR,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,oCAAoC,CAAC,CACpE,CACF,CACF,CAAC;AACF,MAAM,MAAM,uCAAuC,GAAG,WAAW,CAC/D,OAAO,CACL,UAAU,CACR,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,mCAAmC,CAAC,CACnE,CACF,CACF,CAAC;AACF,MAAM,MAAM,iCAAiC,GAAG,WAAW,CACzD,OAAO,CACL,UAAU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,6BAA6B,CAAC,CAAC,CACzE,CACF,CAAC"}
|
package/dist/auth.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/auth.ts", "../src/api-client.ts", "../src/config.ts", "../src/api/auth/auth.ts"],
|
|
4
|
-
"sourcesContent": ["/**\r\n * Auth module - Simplified exports for authentication-related API functions\r\n */\r\n\r\nimport { getAuth } from './api/auth/auth';\r\nimport { setAuth } from './config';\r\n\r\nconst { authControllerLogin } = getAuth();\r\n\r\n// Export auth functions with simplified names\r\nexport const login = authControllerLogin;\r\n\r\n/**\r\n * Login and automatically set authentication credentials\r\n * This is a convenience function that calls login() and setAuth() automatically\r\n * \r\n * @param credentials - Login credentials\r\n * @returns Login result with user information\r\n * \r\n * @example\r\n * ```typescript\r\n * import { loginAndSetAuth } from 'cilantro-smart-sdk/auth';\r\n * import { sendSOL } from 'cilantro-smart-sdk/wallet';\r\n * \r\n * // Login and set auth in one step\r\n * const result = await loginAndSetAuth({\r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123'\r\n * });\r\n * \r\n * // Now you can make authenticated requests\r\n * await sendSOL('wallet-id', { ... });\r\n * ```\r\n */\r\nexport async function loginAndSetAuth(\r\n credentials: import('./models').CommonLoginDto,\r\n options?: any\r\n): Promise<import('./api/auth/auth').AuthControllerLoginResult> {\r\n const result = await login(credentials, options);\r\n \r\n // Automatically set auth from login response\r\n if (result.data?.jwt) {\r\n setAuth({ jwt: result.data.jwt });\r\n }\r\n if (result.data?.apiKey) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n \r\n return result;\r\n}\r\n\r\n// Export types\r\nexport type {\r\n AuthControllerLoginResult,\r\n} from './api/auth/auth';\r\n\r\nexport type {\r\n CommonLoginDto,\r\n AuthControllerLogin200,\r\n AuthControllerLogin200Data,\r\n} from './models';\r\n\r\n", "/**\r\n * Custom API client instance for Cilantro Smart SDK\r\n * Handles authentication (JWT tokens and API keys) automatically\r\n * @internal\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\r\nimport { getConfig } from './config';\r\n\r\n// Create axios instance with dynamic baseURL\r\nconst axiosInstance: AxiosInstance = axios.create();\r\n\r\n// Request interceptor to add authentication headers and dynamic baseURL\r\naxiosInstance.interceptors.request.use(\r\n (config) => {\r\n const sdkConfig = getConfig();\r\n \r\n // Set baseURL dynamically from config\r\n config.baseURL = sdkConfig.baseURL || 'https://api.cilantro.gg';\r\n \r\n // Add JWT token if available\r\n if (sdkConfig.jwt) {\r\n config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;\r\n }\r\n \r\n // Add API key if available (for platform/user authentication)\r\n if (sdkConfig.apiKey) {\r\n config.headers['X-API-Key'] = sdkConfig.apiKey;\r\n }\r\n \r\n return config;\r\n },\r\n (error) => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\n/**\r\n * Custom instance wrapper for orval\r\n * @internal\r\n */\r\nexport const customInstance = <T>(\r\n config: AxiosRequestConfig,\r\n options?: AxiosRequestConfig,\r\n): Promise<T> => {\r\n const source = axios.CancelToken.source();\r\n const promise = axiosInstance({\r\n ...config,\r\n ...options,\r\n cancelToken: source.token,\r\n }).then(({ data }: AxiosResponse<T>) => data);\r\n\r\n // @ts-ignore\r\n promise.cancel = () => {\r\n source.cancel('Query was cancelled');\r\n };\r\n\r\n return promise;\r\n};\r\n\r\nexport default customInstance;\r\n", "/**\r\n * SDK Configuration Management\r\n * Centralized configuration for authentication and API settings\r\n */\r\n\r\n/**\r\n * SDK Configuration interface\r\n */\r\nexport interface SDKConfig {\r\n /** JWT token for authentication */\r\n jwt?: string;\r\n /** API key for authentication (alternative to JWT) */\r\n apiKey?: string;\r\n /** Base URL for the API (defaults to https://api.cilantro.gg) */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * Internal configuration state\r\n * Uses global variable to share state across bundled modules\r\n */\r\nconst GLOBAL_CONFIG_KEY = '__CILANTRO_SDK_CONFIG__';\r\n\r\n// Extend global types\r\ndeclare global {\r\n var __CILANTRO_SDK_CONFIG__: SDKConfig | undefined;\r\n}\r\n\r\n// Get or create global config\r\nfunction getGlobalConfig(): SDKConfig {\r\n const defaultConfig: SDKConfig = {\r\n baseURL: process.env.CILANTRO_API_URL || 'https://api.cilantro.gg',\r\n };\r\n \r\n if (typeof global !== 'undefined') {\r\n if (!global.__CILANTRO_SDK_CONFIG__) {\r\n global.__CILANTRO_SDK_CONFIG__ = defaultConfig;\r\n }\r\n return global.__CILANTRO_SDK_CONFIG__;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n const win = (globalThis as any).window;\r\n if (!win[GLOBAL_CONFIG_KEY]) {\r\n win[GLOBAL_CONFIG_KEY] = defaultConfig;\r\n }\r\n return win[GLOBAL_CONFIG_KEY];\r\n }\r\n \r\n // Fallback for environments without global/window\r\n return defaultConfig;\r\n}\r\n\r\nlet currentConfig: SDKConfig = getGlobalConfig();\r\n\r\n/**\r\n * Configure the SDK with authentication credentials and settings\r\n * \r\n * @param config - Configuration options\r\n * @example\r\n * ```typescript\r\n * import { configure } from 'cilantro-smart-sdk';\r\n * \r\n * // Configure with API key\r\n * configure({ \r\n * apiKey: 'your-api-key',\r\n * baseURL: 'https://api.cilantro.gg' \r\n * });\r\n * \r\n * // Configure with JWT token\r\n * configure({ \r\n * jwt: 'your-jwt-token' \r\n * });\r\n * ```\r\n */\r\nexport function configure(config: SDKConfig): void {\r\n currentConfig = {\r\n ...currentConfig,\r\n ...config,\r\n };\r\n // Also update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Set or update authentication credentials\r\n * \r\n * @param auth - Authentication credentials (JWT and/or API key)\r\n * @example\r\n * ```typescript\r\n * import { setAuth } from 'cilantro-smart-sdk';\r\n * import { login } from 'cilantro-smart-sdk/auth';\r\n * \r\n * const result = await login({ \r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123' \r\n * });\r\n * \r\n * setAuth({ jwt: result.data.jwt });\r\n * ```\r\n */\r\nexport function setAuth(auth: { jwt?: string; apiKey?: string }): void {\r\n // Refresh from global first\r\n currentConfig = getGlobalConfig();\r\n \r\n if (auth.jwt !== undefined) {\r\n currentConfig.jwt = auth.jwt;\r\n }\r\n if (auth.apiKey !== undefined) {\r\n currentConfig.apiKey = auth.apiKey;\r\n }\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Clear all authentication credentials\r\n * \r\n * @example\r\n * ```typescript\r\n * import { clearAuth } from 'cilantro-smart-sdk';\r\n * \r\n * clearAuth();\r\n * ```\r\n */\r\nexport function clearAuth(): void {\r\n currentConfig = getGlobalConfig();\r\n currentConfig.jwt = undefined;\r\n currentConfig.apiKey = undefined;\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Get current SDK configuration (internal use only)\r\n * @internal\r\n */\r\nexport function getConfig(): Readonly<SDKConfig> {\r\n // Always get fresh from global to ensure we have the latest config\r\n currentConfig = getGlobalConfig();\r\n return currentConfig;\r\n}\r\n", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API v2\n * API documentation for Cilantro Smart API v2 - A Solana wallet management system\n * OpenAPI spec version: 2.0\n */\nimport type {\n AuthControllerLogin200,\n CommonLoginDto,\n PasswordResetConfirmDto,\n PasswordResetRequestDto,\n VerifyEmailDto,\n} from \"../../models\";\n\nimport { customInstance } from \"../../api-client\";\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\nexport const getAuth = () => {\n /**\n * Authenticate as admin, platform, or user. Returns user type and appropriate JWT token.\n * @summary Universal login endpoint\n */\n const authControllerLogin = (\n commonLoginDto: CommonLoginDto,\n options?: SecondParameter<typeof customInstance<AuthControllerLogin200>>,\n ) => {\n return customInstance<AuthControllerLogin200>(\n {\n url: `/auth/login`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: commonLoginDto,\n },\n options,\n );\n };\n /**\n * Request a password reset link to be sent to the provided email address. Works for both platform and user accounts.\n * @summary Request password reset\n */\n const authControllerRequestPasswordReset = (\n passwordResetRequestDto: PasswordResetRequestDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/password-reset/request`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetRequestDto,\n },\n options,\n );\n };\n /**\n * Reset password using the token received via email.\n * @summary Confirm password reset\n */\n const authControllerConfirmPasswordReset = (\n passwordResetConfirmDto: PasswordResetConfirmDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/password-reset/confirm`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetConfirmDto,\n },\n options,\n );\n };\n /**\n * Verify email address using the token received via email.\n * @summary Verify email address\n */\n const authControllerVerifyEmail = (\n verifyEmailDto: VerifyEmailDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/verify-email`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: verifyEmailDto,\n },\n options,\n );\n };\n /**\n * Resend email verification link to the provided email address.\n * @summary Resend verification email\n */\n const authControllerResendVerification = (\n passwordResetRequestDto: PasswordResetRequestDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/resend-verification`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetRequestDto,\n },\n options,\n );\n };\n return {\n authControllerLogin,\n authControllerRequestPasswordReset,\n authControllerConfirmPasswordReset,\n authControllerVerifyEmail,\n authControllerResendVerification,\n };\n};\nexport type AuthControllerLoginResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerLogin\"]>>\n>;\nexport type AuthControllerRequestPasswordResetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerRequestPasswordReset\"]>\n >\n>;\nexport type AuthControllerConfirmPasswordResetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerConfirmPasswordReset\"]>\n >\n>;\nexport type AuthControllerVerifyEmailResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerVerifyEmail\"]>>\n>;\nexport type AuthControllerResendVerificationResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerResendVerification\"]>\n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9C,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAKA,QAAM,mCAAmC,CACvC,yBACA,YACG;AACH,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,QAC9C,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL,qBAAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;
|
|
4
|
+
"sourcesContent": ["/**\r\n * Auth module - Simplified exports for authentication-related API functions\r\n */\r\n\r\nimport { getAuth } from './api/auth/auth';\r\nimport { setAuth } from './config';\r\nimport type { CommonLoginDto } from './models';\r\nimport type { AuthControllerLoginResult } from './api/auth/auth';\r\n\r\nconst { authControllerLogin } = getAuth();\r\n\r\n// Export auth functions with simplified names\r\nexport const login = authControllerLogin;\r\n\r\n/**\r\n * Login and automatically set authentication credentials\r\n * This is a convenience function that calls login() and setAuth() automatically\r\n * \r\n * @param credentials - Login credentials\r\n * @returns Login result with user information\r\n * \r\n * @example\r\n * ```typescript\r\n * import { loginAndSetAuth } from 'cilantro-smart-sdk/auth';\r\n * import { sendSOL } from 'cilantro-smart-sdk/wallet';\r\n * \r\n * // Login and set auth in one step\r\n * const result = await loginAndSetAuth({\r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123'\r\n * });\r\n * \r\n * // Now you can make authenticated requests\r\n * await sendSOL('wallet-id', { ... });\r\n * ```\r\n */\r\nexport async function loginAndSetAuth(\r\n credentials: CommonLoginDto,\r\n options?: any\r\n): Promise<AuthControllerLoginResult> {\r\n const result = await login(credentials, options);\r\n \r\n // Automatically set auth from login response\r\n if (result.data?.jwt) {\r\n setAuth({ jwt: result.data.jwt });\r\n }\r\n if (result.data?.apiKey) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n \r\n return result;\r\n}\r\n\r\n// Export types\r\nexport type {\r\n AuthControllerLoginResult,\r\n} from './api/auth/auth';\r\n\r\nexport type {\r\n CommonLoginDto,\r\n AuthControllerLogin200,\r\n AuthControllerLogin200Data,\r\n} from './models';\r\n\r\n", "/**\r\n * Custom API client instance for Cilantro Smart SDK\r\n * Handles authentication (JWT tokens and API keys) automatically\r\n * @internal\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\r\nimport { getConfig } from './config';\r\n\r\n// Create axios instance with dynamic baseURL\r\nconst axiosInstance: AxiosInstance = axios.create();\r\n\r\n// Request interceptor to add authentication headers and dynamic baseURL\r\naxiosInstance.interceptors.request.use(\r\n (config) => {\r\n const sdkConfig = getConfig();\r\n \r\n // Set baseURL dynamically from config\r\n config.baseURL = sdkConfig.baseURL || 'https://api.cilantro.gg';\r\n \r\n // Add JWT token if available\r\n if (sdkConfig.jwt) {\r\n config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;\r\n }\r\n \r\n // Add API key if available (for platform/user authentication)\r\n if (sdkConfig.apiKey) {\r\n config.headers['X-API-Key'] = sdkConfig.apiKey;\r\n }\r\n \r\n return config;\r\n },\r\n (error) => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\n/**\r\n * Custom instance wrapper for orval\r\n * @internal\r\n */\r\nexport const customInstance = <T>(\r\n config: AxiosRequestConfig,\r\n options?: AxiosRequestConfig,\r\n): Promise<T> => {\r\n const source = axios.CancelToken.source();\r\n const promise = axiosInstance({\r\n ...config,\r\n ...options,\r\n cancelToken: source.token,\r\n }).then(({ data }: AxiosResponse<T>) => data);\r\n\r\n // @ts-ignore\r\n promise.cancel = () => {\r\n source.cancel('Query was cancelled');\r\n };\r\n\r\n return promise;\r\n};\r\n\r\nexport default customInstance;\r\n", "/**\r\n * SDK Configuration Management\r\n * Centralized configuration for authentication and API settings\r\n */\r\n\r\n/**\r\n * SDK Configuration interface\r\n */\r\nexport interface SDKConfig {\r\n /** JWT token for authentication */\r\n jwt?: string;\r\n /** API key for authentication (alternative to JWT) */\r\n apiKey?: string;\r\n /** Base URL for the API (defaults to https://api.cilantro.gg) */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * Internal configuration state\r\n * Uses global variable to share state across bundled modules\r\n */\r\nconst GLOBAL_CONFIG_KEY = '__CILANTRO_SDK_CONFIG__';\r\n\r\n// Extend global types\r\ndeclare global {\r\n var __CILANTRO_SDK_CONFIG__: SDKConfig | undefined;\r\n}\r\n\r\n// Get or create global config\r\nfunction getGlobalConfig(): SDKConfig {\r\n const defaultConfig: SDKConfig = {\r\n baseURL: process.env.CILANTRO_API_URL || 'https://api.cilantro.gg',\r\n };\r\n \r\n if (typeof global !== 'undefined') {\r\n if (!global.__CILANTRO_SDK_CONFIG__) {\r\n global.__CILANTRO_SDK_CONFIG__ = defaultConfig;\r\n }\r\n return global.__CILANTRO_SDK_CONFIG__;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n const win = (globalThis as any).window;\r\n if (!win[GLOBAL_CONFIG_KEY]) {\r\n win[GLOBAL_CONFIG_KEY] = defaultConfig;\r\n }\r\n return win[GLOBAL_CONFIG_KEY];\r\n }\r\n \r\n // Fallback for environments without global/window\r\n return defaultConfig;\r\n}\r\n\r\nlet currentConfig: SDKConfig = getGlobalConfig();\r\n\r\n/**\r\n * Configure the SDK with authentication credentials and settings\r\n * \r\n * @param config - Configuration options\r\n * @example\r\n * ```typescript\r\n * import { configure } from 'cilantro-smart-sdk';\r\n * \r\n * // Configure with API key\r\n * configure({ \r\n * apiKey: 'your-api-key',\r\n * baseURL: 'https://api.cilantro.gg' \r\n * });\r\n * \r\n * // Configure with JWT token\r\n * configure({ \r\n * jwt: 'your-jwt-token' \r\n * });\r\n * ```\r\n */\r\nexport function configure(config: SDKConfig): void {\r\n currentConfig = {\r\n ...currentConfig,\r\n ...config,\r\n };\r\n // Also update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Set or update authentication credentials\r\n * \r\n * @param auth - Authentication credentials (JWT and/or API key)\r\n * @example\r\n * ```typescript\r\n * import { setAuth } from 'cilantro-smart-sdk';\r\n * import { login } from 'cilantro-smart-sdk/auth';\r\n * \r\n * const result = await login({ \r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123' \r\n * });\r\n * \r\n * setAuth({ jwt: result.data.jwt });\r\n * ```\r\n */\r\nexport function setAuth(auth: { jwt?: string; apiKey?: string }): void {\r\n // Refresh from global first\r\n currentConfig = getGlobalConfig();\r\n \r\n if (auth.jwt !== undefined) {\r\n currentConfig.jwt = auth.jwt;\r\n }\r\n if (auth.apiKey !== undefined) {\r\n currentConfig.apiKey = auth.apiKey;\r\n }\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Clear all authentication credentials\r\n * \r\n * @example\r\n * ```typescript\r\n * import { clearAuth } from 'cilantro-smart-sdk';\r\n * \r\n * clearAuth();\r\n * ```\r\n */\r\nexport function clearAuth(): void {\r\n currentConfig = getGlobalConfig();\r\n currentConfig.jwt = undefined;\r\n currentConfig.apiKey = undefined;\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Get current SDK configuration (internal use only)\r\n * @internal\r\n */\r\nexport function getConfig(): Readonly<SDKConfig> {\r\n // Always get fresh from global to ensure we have the latest config\r\n currentConfig = getGlobalConfig();\r\n return currentConfig;\r\n}\r\n", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API v2\n * API documentation for Cilantro Smart API v2 - A Solana wallet management system\n * OpenAPI spec version: 2.0\n */\nimport type {\n AuthControllerLogin200,\n CommonLoginDto,\n PasswordResetConfirmDto,\n PasswordResetRequestDto,\n VerifyEmailDto,\n} from \"../../models\";\n\nimport { customInstance } from \"../../api-client\";\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\nexport const getAuth = () => {\n /**\n * Authenticate as admin, platform, or user. Returns user type and appropriate JWT token.\n * @summary Universal login endpoint\n */\n const authControllerLogin = (\n commonLoginDto: CommonLoginDto,\n options?: SecondParameter<typeof customInstance<AuthControllerLogin200>>,\n ) => {\n return customInstance<AuthControllerLogin200>(\n {\n url: `/auth/login`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: commonLoginDto,\n },\n options,\n );\n };\n /**\n * Request a password reset link to be sent to the provided email address. Works for both platform and user accounts.\n * @summary Request password reset\n */\n const authControllerRequestPasswordReset = (\n passwordResetRequestDto: PasswordResetRequestDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/password-reset/request`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetRequestDto,\n },\n options,\n );\n };\n /**\n * Reset password using the token received via email.\n * @summary Confirm password reset\n */\n const authControllerConfirmPasswordReset = (\n passwordResetConfirmDto: PasswordResetConfirmDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/password-reset/confirm`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetConfirmDto,\n },\n options,\n );\n };\n /**\n * Verify email address using the token received via email.\n * @summary Verify email address\n */\n const authControllerVerifyEmail = (\n verifyEmailDto: VerifyEmailDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/verify-email`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: verifyEmailDto,\n },\n options,\n );\n };\n /**\n * Resend email verification link to the provided email address.\n * @summary Resend verification email\n */\n const authControllerResendVerification = (\n passwordResetRequestDto: PasswordResetRequestDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/resend-verification`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetRequestDto,\n },\n options,\n );\n };\n return {\n authControllerLogin,\n authControllerRequestPasswordReset,\n authControllerConfirmPasswordReset,\n authControllerVerifyEmail,\n authControllerResendVerification,\n };\n};\nexport type AuthControllerLoginResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerLogin\"]>>\n>;\nexport type AuthControllerRequestPasswordResetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerRequestPasswordReset\"]>\n >\n>;\nexport type AuthControllerConfirmPasswordResetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerConfirmPasswordReset\"]>\n >\n>;\nexport type AuthControllerVerifyEmailResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerVerifyEmail\"]>>\n>;\nexport type AuthControllerResendVerificationResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerResendVerification\"]>\n >\n>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,mBAAwE;;;ACexE,IAAM,oBAAoB;AAQ1B,SAAS,kBAA6B;AACpC,QAAM,gBAA2B;AAAA,IAC/B,SAAS,QAAQ,IAAI,oBAAoB;AAAA,EAC3C;AAEA,MAAI,OAAO,WAAW,aAAa;AACjC,QAAI,CAAC,OAAO,yBAAyB;AACnC,aAAO,0B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IACA;AAAA,EACF;AACF;;;AH5GA,IAAM,EAAE,oBAAoB,IAAI,QAAQ;AAGjC,IAAM,QAAQ;AAwBrB,eAAsB,gBACpB,aACA,SACoC;AAvCtC;AAwCE,QAAM,SAAS,MAAM,MAAM,aAAa,OAAO;AAG/C,OAAI,YAAO,SAAP,mBAAa,KAAK;AACpB,YAAQ,EAAE,KAAK,OAAO,KAAK,IAAI,CAAC;AAAA,EAClC;AACA,OAAI,YAAO,SAAP,mBAAa,QAAQ;AACvB,YAAQ,EAAE,QAAQ,OAAO,KAAK,OAAO,CAAC;AAAA,EACxC;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": ["axios", "authControllerLogin"]
|
|
7
7
|
}
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auth module - Simplified exports for authentication-related API functions
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import type { CommonLoginDto } from './models';
|
|
5
|
+
import type { AuthControllerLoginResult } from './api/auth/auth';
|
|
6
|
+
export declare const login: (commonLoginDto: CommonLoginDto, options?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("./models").AuthControllerLogin200>;
|
|
5
7
|
/**
|
|
6
8
|
* Login and automatically set authentication credentials
|
|
7
9
|
* This is a convenience function that calls login() and setAuth() automatically
|
|
@@ -24,7 +26,7 @@ export declare const login: (commonLoginDto: import("./models").CommonLoginDto,
|
|
|
24
26
|
* await sendSOL('wallet-id', { ... });
|
|
25
27
|
* ```
|
|
26
28
|
*/
|
|
27
|
-
export declare function loginAndSetAuth(credentials:
|
|
29
|
+
export declare function loginAndSetAuth(credentials: CommonLoginDto, options?: any): Promise<AuthControllerLoginResult>;
|
|
28
30
|
export type { AuthControllerLoginResult, } from './api/auth/auth';
|
|
29
31
|
export type { CommonLoginDto, AuthControllerLogin200, AuthControllerLogin200Data, } from './models';
|
|
30
32
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAKjE,eAAO,MAAM,KAAK,uJAAsB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,cAAc,EAC3B,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAAC,yBAAyB,CAAC,CAYpC;AAGD,YAAY,EACV,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,UAAU,CAAC"}
|
package/dist/auth.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/api-client.ts", "../src/config.ts", "../src/api/auth/auth.ts", "../src/auth.ts"],
|
|
4
|
-
"sourcesContent": ["/**\r\n * Custom API client instance for Cilantro Smart SDK\r\n * Handles authentication (JWT tokens and API keys) automatically\r\n * @internal\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\r\nimport { getConfig } from './config';\r\n\r\n// Create axios instance with dynamic baseURL\r\nconst axiosInstance: AxiosInstance = axios.create();\r\n\r\n// Request interceptor to add authentication headers and dynamic baseURL\r\naxiosInstance.interceptors.request.use(\r\n (config) => {\r\n const sdkConfig = getConfig();\r\n \r\n // Set baseURL dynamically from config\r\n config.baseURL = sdkConfig.baseURL || 'https://api.cilantro.gg';\r\n \r\n // Add JWT token if available\r\n if (sdkConfig.jwt) {\r\n config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;\r\n }\r\n \r\n // Add API key if available (for platform/user authentication)\r\n if (sdkConfig.apiKey) {\r\n config.headers['X-API-Key'] = sdkConfig.apiKey;\r\n }\r\n \r\n return config;\r\n },\r\n (error) => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\n/**\r\n * Custom instance wrapper for orval\r\n * @internal\r\n */\r\nexport const customInstance = <T>(\r\n config: AxiosRequestConfig,\r\n options?: AxiosRequestConfig,\r\n): Promise<T> => {\r\n const source = axios.CancelToken.source();\r\n const promise = axiosInstance({\r\n ...config,\r\n ...options,\r\n cancelToken: source.token,\r\n }).then(({ data }: AxiosResponse<T>) => data);\r\n\r\n // @ts-ignore\r\n promise.cancel = () => {\r\n source.cancel('Query was cancelled');\r\n };\r\n\r\n return promise;\r\n};\r\n\r\nexport default customInstance;\r\n", "/**\r\n * SDK Configuration Management\r\n * Centralized configuration for authentication and API settings\r\n */\r\n\r\n/**\r\n * SDK Configuration interface\r\n */\r\nexport interface SDKConfig {\r\n /** JWT token for authentication */\r\n jwt?: string;\r\n /** API key for authentication (alternative to JWT) */\r\n apiKey?: string;\r\n /** Base URL for the API (defaults to https://api.cilantro.gg) */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * Internal configuration state\r\n * Uses global variable to share state across bundled modules\r\n */\r\nconst GLOBAL_CONFIG_KEY = '__CILANTRO_SDK_CONFIG__';\r\n\r\n// Extend global types\r\ndeclare global {\r\n var __CILANTRO_SDK_CONFIG__: SDKConfig | undefined;\r\n}\r\n\r\n// Get or create global config\r\nfunction getGlobalConfig(): SDKConfig {\r\n const defaultConfig: SDKConfig = {\r\n baseURL: process.env.CILANTRO_API_URL || 'https://api.cilantro.gg',\r\n };\r\n \r\n if (typeof global !== 'undefined') {\r\n if (!global.__CILANTRO_SDK_CONFIG__) {\r\n global.__CILANTRO_SDK_CONFIG__ = defaultConfig;\r\n }\r\n return global.__CILANTRO_SDK_CONFIG__;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n const win = (globalThis as any).window;\r\n if (!win[GLOBAL_CONFIG_KEY]) {\r\n win[GLOBAL_CONFIG_KEY] = defaultConfig;\r\n }\r\n return win[GLOBAL_CONFIG_KEY];\r\n }\r\n \r\n // Fallback for environments without global/window\r\n return defaultConfig;\r\n}\r\n\r\nlet currentConfig: SDKConfig = getGlobalConfig();\r\n\r\n/**\r\n * Configure the SDK with authentication credentials and settings\r\n * \r\n * @param config - Configuration options\r\n * @example\r\n * ```typescript\r\n * import { configure } from 'cilantro-smart-sdk';\r\n * \r\n * // Configure with API key\r\n * configure({ \r\n * apiKey: 'your-api-key',\r\n * baseURL: 'https://api.cilantro.gg' \r\n * });\r\n * \r\n * // Configure with JWT token\r\n * configure({ \r\n * jwt: 'your-jwt-token' \r\n * });\r\n * ```\r\n */\r\nexport function configure(config: SDKConfig): void {\r\n currentConfig = {\r\n ...currentConfig,\r\n ...config,\r\n };\r\n // Also update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Set or update authentication credentials\r\n * \r\n * @param auth - Authentication credentials (JWT and/or API key)\r\n * @example\r\n * ```typescript\r\n * import { setAuth } from 'cilantro-smart-sdk';\r\n * import { login } from 'cilantro-smart-sdk/auth';\r\n * \r\n * const result = await login({ \r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123' \r\n * });\r\n * \r\n * setAuth({ jwt: result.data.jwt });\r\n * ```\r\n */\r\nexport function setAuth(auth: { jwt?: string; apiKey?: string }): void {\r\n // Refresh from global first\r\n currentConfig = getGlobalConfig();\r\n \r\n if (auth.jwt !== undefined) {\r\n currentConfig.jwt = auth.jwt;\r\n }\r\n if (auth.apiKey !== undefined) {\r\n currentConfig.apiKey = auth.apiKey;\r\n }\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Clear all authentication credentials\r\n * \r\n * @example\r\n * ```typescript\r\n * import { clearAuth } from 'cilantro-smart-sdk';\r\n * \r\n * clearAuth();\r\n * ```\r\n */\r\nexport function clearAuth(): void {\r\n currentConfig = getGlobalConfig();\r\n currentConfig.jwt = undefined;\r\n currentConfig.apiKey = undefined;\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Get current SDK configuration (internal use only)\r\n * @internal\r\n */\r\nexport function getConfig(): Readonly<SDKConfig> {\r\n // Always get fresh from global to ensure we have the latest config\r\n currentConfig = getGlobalConfig();\r\n return currentConfig;\r\n}\r\n", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API v2\n * API documentation for Cilantro Smart API v2 - A Solana wallet management system\n * OpenAPI spec version: 2.0\n */\nimport type {\n AuthControllerLogin200,\n CommonLoginDto,\n PasswordResetConfirmDto,\n PasswordResetRequestDto,\n VerifyEmailDto,\n} from \"../../models\";\n\nimport { customInstance } from \"../../api-client\";\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\nexport const getAuth = () => {\n /**\n * Authenticate as admin, platform, or user. Returns user type and appropriate JWT token.\n * @summary Universal login endpoint\n */\n const authControllerLogin = (\n commonLoginDto: CommonLoginDto,\n options?: SecondParameter<typeof customInstance<AuthControllerLogin200>>,\n ) => {\n return customInstance<AuthControllerLogin200>(\n {\n url: `/auth/login`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: commonLoginDto,\n },\n options,\n );\n };\n /**\n * Request a password reset link to be sent to the provided email address. Works for both platform and user accounts.\n * @summary Request password reset\n */\n const authControllerRequestPasswordReset = (\n passwordResetRequestDto: PasswordResetRequestDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/password-reset/request`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetRequestDto,\n },\n options,\n );\n };\n /**\n * Reset password using the token received via email.\n * @summary Confirm password reset\n */\n const authControllerConfirmPasswordReset = (\n passwordResetConfirmDto: PasswordResetConfirmDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/password-reset/confirm`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetConfirmDto,\n },\n options,\n );\n };\n /**\n * Verify email address using the token received via email.\n * @summary Verify email address\n */\n const authControllerVerifyEmail = (\n verifyEmailDto: VerifyEmailDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/verify-email`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: verifyEmailDto,\n },\n options,\n );\n };\n /**\n * Resend email verification link to the provided email address.\n * @summary Resend verification email\n */\n const authControllerResendVerification = (\n passwordResetRequestDto: PasswordResetRequestDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/resend-verification`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetRequestDto,\n },\n options,\n );\n };\n return {\n authControllerLogin,\n authControllerRequestPasswordReset,\n authControllerConfirmPasswordReset,\n authControllerVerifyEmail,\n authControllerResendVerification,\n };\n};\nexport type AuthControllerLoginResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerLogin\"]>>\n>;\nexport type AuthControllerRequestPasswordResetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerRequestPasswordReset\"]>\n >\n>;\nexport type AuthControllerConfirmPasswordResetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerConfirmPasswordReset\"]>\n >\n>;\nexport type AuthControllerVerifyEmailResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerVerifyEmail\"]>>\n>;\nexport type AuthControllerResendVerificationResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerResendVerification\"]>\n >\n>;\n", "/**\r\n * Auth module - Simplified exports for authentication-related API functions\r\n */\r\n\r\nimport { getAuth } from './api/auth/auth';\r\nimport { setAuth } from './config';\r\n\r\nconst { authControllerLogin } = getAuth();\r\n\r\n// Export auth functions with simplified names\r\nexport const login = authControllerLogin;\r\n\r\n/**\r\n * Login and automatically set authentication credentials\r\n * This is a convenience function that calls login() and setAuth() automatically\r\n * \r\n * @param credentials - Login credentials\r\n * @returns Login result with user information\r\n * \r\n * @example\r\n * ```typescript\r\n * import { loginAndSetAuth } from 'cilantro-smart-sdk/auth';\r\n * import { sendSOL } from 'cilantro-smart-sdk/wallet';\r\n * \r\n * // Login and set auth in one step\r\n * const result = await loginAndSetAuth({\r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123'\r\n * });\r\n * \r\n * // Now you can make authenticated requests\r\n * await sendSOL('wallet-id', { ... });\r\n * ```\r\n */\r\nexport async function loginAndSetAuth(\r\n credentials: import('./models').CommonLoginDto,\r\n options?: any\r\n): Promise<import('./api/auth/auth').AuthControllerLoginResult> {\r\n const result = await login(credentials, options);\r\n \r\n // Automatically set auth from login response\r\n if (result.data?.jwt) {\r\n setAuth({ jwt: result.data.jwt });\r\n }\r\n if (result.data?.apiKey) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n \r\n return result;\r\n}\r\n\r\n// Export types\r\nexport type {\r\n AuthControllerLoginRes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mBAAmB;AAAA,QAC9C,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAKA,QAAM,mCAAmC,CACvC,yBACA,YACG;AACH,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,QAC9C,MAAM;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL,qBAAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;
|
|
4
|
+
"sourcesContent": ["/**\r\n * Custom API client instance for Cilantro Smart SDK\r\n * Handles authentication (JWT tokens and API keys) automatically\r\n * @internal\r\n */\r\n\r\nimport axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';\r\nimport { getConfig } from './config';\r\n\r\n// Create axios instance with dynamic baseURL\r\nconst axiosInstance: AxiosInstance = axios.create();\r\n\r\n// Request interceptor to add authentication headers and dynamic baseURL\r\naxiosInstance.interceptors.request.use(\r\n (config) => {\r\n const sdkConfig = getConfig();\r\n \r\n // Set baseURL dynamically from config\r\n config.baseURL = sdkConfig.baseURL || 'https://api.cilantro.gg';\r\n \r\n // Add JWT token if available\r\n if (sdkConfig.jwt) {\r\n config.headers.Authorization = `Bearer ${sdkConfig.jwt}`;\r\n }\r\n \r\n // Add API key if available (for platform/user authentication)\r\n if (sdkConfig.apiKey) {\r\n config.headers['X-API-Key'] = sdkConfig.apiKey;\r\n }\r\n \r\n return config;\r\n },\r\n (error) => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\n/**\r\n * Custom instance wrapper for orval\r\n * @internal\r\n */\r\nexport const customInstance = <T>(\r\n config: AxiosRequestConfig,\r\n options?: AxiosRequestConfig,\r\n): Promise<T> => {\r\n const source = axios.CancelToken.source();\r\n const promise = axiosInstance({\r\n ...config,\r\n ...options,\r\n cancelToken: source.token,\r\n }).then(({ data }: AxiosResponse<T>) => data);\r\n\r\n // @ts-ignore\r\n promise.cancel = () => {\r\n source.cancel('Query was cancelled');\r\n };\r\n\r\n return promise;\r\n};\r\n\r\nexport default customInstance;\r\n", "/**\r\n * SDK Configuration Management\r\n * Centralized configuration for authentication and API settings\r\n */\r\n\r\n/**\r\n * SDK Configuration interface\r\n */\r\nexport interface SDKConfig {\r\n /** JWT token for authentication */\r\n jwt?: string;\r\n /** API key for authentication (alternative to JWT) */\r\n apiKey?: string;\r\n /** Base URL for the API (defaults to https://api.cilantro.gg) */\r\n baseURL?: string;\r\n}\r\n\r\n/**\r\n * Internal configuration state\r\n * Uses global variable to share state across bundled modules\r\n */\r\nconst GLOBAL_CONFIG_KEY = '__CILANTRO_SDK_CONFIG__';\r\n\r\n// Extend global types\r\ndeclare global {\r\n var __CILANTRO_SDK_CONFIG__: SDKConfig | undefined;\r\n}\r\n\r\n// Get or create global config\r\nfunction getGlobalConfig(): SDKConfig {\r\n const defaultConfig: SDKConfig = {\r\n baseURL: process.env.CILANTRO_API_URL || 'https://api.cilantro.gg',\r\n };\r\n \r\n if (typeof global !== 'undefined') {\r\n if (!global.__CILANTRO_SDK_CONFIG__) {\r\n global.__CILANTRO_SDK_CONFIG__ = defaultConfig;\r\n }\r\n return global.__CILANTRO_SDK_CONFIG__;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n const win = (globalThis as any).window;\r\n if (!win[GLOBAL_CONFIG_KEY]) {\r\n win[GLOBAL_CONFIG_KEY] = defaultConfig;\r\n }\r\n return win[GLOBAL_CONFIG_KEY];\r\n }\r\n \r\n // Fallback for environments without global/window\r\n return defaultConfig;\r\n}\r\n\r\nlet currentConfig: SDKConfig = getGlobalConfig();\r\n\r\n/**\r\n * Configure the SDK with authentication credentials and settings\r\n * \r\n * @param config - Configuration options\r\n * @example\r\n * ```typescript\r\n * import { configure } from 'cilantro-smart-sdk';\r\n * \r\n * // Configure with API key\r\n * configure({ \r\n * apiKey: 'your-api-key',\r\n * baseURL: 'https://api.cilantro.gg' \r\n * });\r\n * \r\n * // Configure with JWT token\r\n * configure({ \r\n * jwt: 'your-jwt-token' \r\n * });\r\n * ```\r\n */\r\nexport function configure(config: SDKConfig): void {\r\n currentConfig = {\r\n ...currentConfig,\r\n ...config,\r\n };\r\n // Also update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Set or update authentication credentials\r\n * \r\n * @param auth - Authentication credentials (JWT and/or API key)\r\n * @example\r\n * ```typescript\r\n * import { setAuth } from 'cilantro-smart-sdk';\r\n * import { login } from 'cilantro-smart-sdk/auth';\r\n * \r\n * const result = await login({ \r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123' \r\n * });\r\n * \r\n * setAuth({ jwt: result.data.jwt });\r\n * ```\r\n */\r\nexport function setAuth(auth: { jwt?: string; apiKey?: string }): void {\r\n // Refresh from global first\r\n currentConfig = getGlobalConfig();\r\n \r\n if (auth.jwt !== undefined) {\r\n currentConfig.jwt = auth.jwt;\r\n }\r\n if (auth.apiKey !== undefined) {\r\n currentConfig.apiKey = auth.apiKey;\r\n }\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Clear all authentication credentials\r\n * \r\n * @example\r\n * ```typescript\r\n * import { clearAuth } from 'cilantro-smart-sdk';\r\n * \r\n * clearAuth();\r\n * ```\r\n */\r\nexport function clearAuth(): void {\r\n currentConfig = getGlobalConfig();\r\n currentConfig.jwt = undefined;\r\n currentConfig.apiKey = undefined;\r\n \r\n // Update global config\r\n if (typeof global !== 'undefined') {\r\n global.__CILANTRO_SDK_CONFIG__ = currentConfig;\r\n } else if (typeof (globalThis as any).window !== 'undefined') {\r\n ((globalThis as any).window as any)[GLOBAL_CONFIG_KEY] = currentConfig;\r\n }\r\n}\r\n\r\n/**\r\n * Get current SDK configuration (internal use only)\r\n * @internal\r\n */\r\nexport function getConfig(): Readonly<SDKConfig> {\r\n // Always get fresh from global to ensure we have the latest config\r\n currentConfig = getGlobalConfig();\r\n return currentConfig;\r\n}\r\n", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API v2\n * API documentation for Cilantro Smart API v2 - A Solana wallet management system\n * OpenAPI spec version: 2.0\n */\nimport type {\n AuthControllerLogin200,\n CommonLoginDto,\n PasswordResetConfirmDto,\n PasswordResetRequestDto,\n VerifyEmailDto,\n} from \"../../models\";\n\nimport { customInstance } from \"../../api-client\";\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\nexport const getAuth = () => {\n /**\n * Authenticate as admin, platform, or user. Returns user type and appropriate JWT token.\n * @summary Universal login endpoint\n */\n const authControllerLogin = (\n commonLoginDto: CommonLoginDto,\n options?: SecondParameter<typeof customInstance<AuthControllerLogin200>>,\n ) => {\n return customInstance<AuthControllerLogin200>(\n {\n url: `/auth/login`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: commonLoginDto,\n },\n options,\n );\n };\n /**\n * Request a password reset link to be sent to the provided email address. Works for both platform and user accounts.\n * @summary Request password reset\n */\n const authControllerRequestPasswordReset = (\n passwordResetRequestDto: PasswordResetRequestDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/password-reset/request`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetRequestDto,\n },\n options,\n );\n };\n /**\n * Reset password using the token received via email.\n * @summary Confirm password reset\n */\n const authControllerConfirmPasswordReset = (\n passwordResetConfirmDto: PasswordResetConfirmDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/password-reset/confirm`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetConfirmDto,\n },\n options,\n );\n };\n /**\n * Verify email address using the token received via email.\n * @summary Verify email address\n */\n const authControllerVerifyEmail = (\n verifyEmailDto: VerifyEmailDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/verify-email`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: verifyEmailDto,\n },\n options,\n );\n };\n /**\n * Resend email verification link to the provided email address.\n * @summary Resend verification email\n */\n const authControllerResendVerification = (\n passwordResetRequestDto: PasswordResetRequestDto,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n {\n url: `/auth/resend-verification`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: passwordResetRequestDto,\n },\n options,\n );\n };\n return {\n authControllerLogin,\n authControllerRequestPasswordReset,\n authControllerConfirmPasswordReset,\n authControllerVerifyEmail,\n authControllerResendVerification,\n };\n};\nexport type AuthControllerLoginResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerLogin\"]>>\n>;\nexport type AuthControllerRequestPasswordResetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerRequestPasswordReset\"]>\n >\n>;\nexport type AuthControllerConfirmPasswordResetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerConfirmPasswordReset\"]>\n >\n>;\nexport type AuthControllerVerifyEmailResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerVerifyEmail\"]>>\n>;\nexport type AuthControllerResendVerificationResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerResendVerification\"]>\n >\n>;\n", "/**\r\n * Auth module - Simplified exports for authentication-related API functions\r\n */\r\n\r\nimport { getAuth } from './api/auth/auth';\r\nimport { setAuth } from './config';\r\nimport type { CommonLoginDto } from './models';\r\nimport type { AuthControllerLoginResult } from './api/auth/auth';\r\n\r\nconst { authControllerLogin } = getAuth();\r\n\r\n// Export auth functions with simplified names\r\nexport const login = authControllerLogin;\r\n\r\n/**\r\n * Login and automatically set authentication credentials\r\n * This is a convenience function that calls login() and setAuth() automatically\r\n * \r\n * @param credentials - Login credentials\r\n * @returns Login result with user information\r\n * \r\n * @example\r\n * ```typescript\r\n * import { loginAndSetAuth } from 'cilantro-smart-sdk/auth';\r\n * import { sendSOL } from 'cilantro-smart-sdk/wallet';\r\n * \r\n * // Login and set auth in one step\r\n * const result = await loginAndSetAuth({\r\n * usernameOrEmail: 'user@example.com',\r\n * password: 'password123'\r\n * });\r\n * \r\n * // Now you can make authenticated requests\r\n * await sendSOL('wallet-id', { ... });\r\n * ```\r\n */\r\nexport async function loginAndSetAuth(\r\n credentials: CommonLoginDto,\r\n options?: any\r\n): Promise<AuthControllerLoginResult> {\r\n const result = await login(credentials, options);\r\n \r\n // Automatically set auth from login response\r\n if (result.data?.jwt) {\r\n setAuth({ jwt: result.data.jwt });\r\n }\r\n if (result.data?.apiKey) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n \r\n return result;\r\n}\r\n\r\n// Export types\r\nexport type {\r\n AuthControllerLoginResult,\r\n} from './api/auth/auth';\r\n\r\nexport type {\r\n CommonLoginDto,\r\n AuthControllerLogin200,\r\n AuthControllerLogin200Data,\r\n} from './models';\r\n\r\n"],
|
|
5
|
+
"mappings": ";AAMA,OAAO,WAAiE;;;ACexE,IAAM,oBAAoB;AAQ1B,SAAS,kBAA6B;AACpC,QAAM,gBAA2B;AAAA,IAC/B,SAAS,QAAQ,IAAI,oBAAoB;AAAA,EAC3C;AAEA,MAAI,OAAO,WAAW,aAAa;AACjC,QAAI,CAAC,OAAO,yBAAyB;AACnC,aAAO,0BAA0B;AAAA,IACnC;AACA,WAAO,OAAO;AAAA,EAChB,WAA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AGjC,IAAM,QAAQ;AAwBrB,eAAsB,gBACpB,aACA,SACoC;AAvCtC;AAwCE,QAAM,SAAS,MAAM,MAAM,aAAa,OAAO;AAG/C,OAAI,YAAO,SAAP,mBAAa,KAAK;AACpB,YAAQ,EAAE,KAAK,OAAO,KAAK,IAAI,CAAC;AAAA,EAClC;AACA,OAAI,YAAO,SAAP,mBAAa,QAAQ;AACvB,YAAQ,EAAE,QAAQ,OAAO,KAAK,OAAO,CAAC;AAAA,EACxC;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": ["authControllerLogin"]
|
|
7
7
|
}
|
package/dist/helpers.cjs
CHANGED
|
@@ -68,6 +68,8 @@ __export(helpers_exports, {
|
|
|
68
68
|
exportToSPKI: () => exportToSPKI,
|
|
69
69
|
findAndValidateDeviceKey: () => findAndValidateDeviceKey,
|
|
70
70
|
findDeviceKeyByPublicKey: () => findDeviceKeyByPublicKey,
|
|
71
|
+
findExistingPasskeySigner: () => findExistingPasskeySigner,
|
|
72
|
+
formatAuthenticationForVerification: () => formatAuthenticationForVerification,
|
|
71
73
|
formatAuthenticationResponse: () => formatAuthenticationResponse,
|
|
72
74
|
formatRegistrationResponse: () => formatRegistrationResponse,
|
|
73
75
|
generateDeviceKeyPair: () => generateDeviceKeyPair,
|
|
@@ -98,6 +100,7 @@ __export(helpers_exports, {
|
|
|
98
100
|
parseSignerResponse: () => parseSignerResponse,
|
|
99
101
|
pemToBase64: () => pemToBase64,
|
|
100
102
|
registerPasskey: () => registerPasskey,
|
|
103
|
+
registerPasskeyComplete: () => registerPasskeyComplete,
|
|
101
104
|
replaceDevice: () => replaceDevice,
|
|
102
105
|
replaceDeviceIdentity: () => replaceDeviceIdentity,
|
|
103
106
|
resolveDeviceKey: () => resolveDeviceKey,
|
|
@@ -980,9 +983,14 @@ var getWallets = () => {
|
|
|
980
983
|
options
|
|
981
984
|
);
|
|
982
985
|
};
|
|
983
|
-
const walletControllerStartPasskeyAuthentication2 = (id, options) => {
|
|
986
|
+
const walletControllerStartPasskeyAuthentication2 = (id, startPasskeyAuthenticationDto, options) => {
|
|
984
987
|
return customInstance(
|
|
985
|
-
{
|
|
988
|
+
{
|
|
989
|
+
url: `/wallets/${id}/signers/passkey/authenticate`,
|
|
990
|
+
method: "POST",
|
|
991
|
+
headers: { "Content-Type": "application/json" },
|
|
992
|
+
data: startPasskeyAuthenticationDto
|
|
993
|
+
},
|
|
986
994
|
options
|
|
987
995
|
);
|
|
988
996
|
};
|
|
@@ -1233,6 +1241,8 @@ var {
|
|
|
1233
1241
|
} = getWallets();
|
|
1234
1242
|
var createEmailSigner = walletControllerCreateEmailSigner;
|
|
1235
1243
|
var createPhoneSigner = walletControllerCreatePhoneSigner;
|
|
1244
|
+
var startPasskeyRegistration = walletControllerStartPasskeyRegistration;
|
|
1245
|
+
var verifyPasskeyRegistration = walletControllerVerifyPasskeyRegistration;
|
|
1236
1246
|
var getSignerById = walletControllerGetSignerById;
|
|
1237
1247
|
var deleteSigner = walletControllerDeleteSigner;
|
|
1238
1248
|
var getDeviceEncryptedSecret = walletControllerGetDeviceEncryptedSecret;
|
|
@@ -3804,12 +3814,42 @@ async function registerPasskey(options) {
|
|
|
3804
3814
|
}
|
|
3805
3815
|
async function authenticateWithPasskey(options) {
|
|
3806
3816
|
if (!isWebAuthnSupported()) {
|
|
3807
|
-
throw new SDKError(
|
|
3817
|
+
throw new SDKError(
|
|
3818
|
+
"WebAuthn is not supported in this browser. Please use a modern browser that supports WebAuthn.",
|
|
3819
|
+
"WEBAUTHN_NOT_SUPPORTED"
|
|
3820
|
+
);
|
|
3821
|
+
}
|
|
3822
|
+
if (!options || !options.challenge) {
|
|
3823
|
+
throw new SDKError(
|
|
3824
|
+
"Invalid authentication options: challenge is required. Make sure you call startPasskeyAuthentication first to get valid options.",
|
|
3825
|
+
"INVALID_AUTHENTICATION_OPTIONS"
|
|
3826
|
+
);
|
|
3808
3827
|
}
|
|
3809
3828
|
try {
|
|
3810
3829
|
const response = await startAuthentication(options);
|
|
3811
3830
|
return formatAuthenticationResponse(response);
|
|
3812
3831
|
} catch (error) {
|
|
3832
|
+
if (error instanceof Error) {
|
|
3833
|
+
if (error.name === "NotAllowedError") {
|
|
3834
|
+
throw new SDKError(
|
|
3835
|
+
"Passkey authentication was cancelled or not allowed by the user.",
|
|
3836
|
+
"PASSKEY_AUTHENTICATION_CANCELLED",
|
|
3837
|
+
{ error }
|
|
3838
|
+
);
|
|
3839
|
+
} else if (error.name === "InvalidStateError") {
|
|
3840
|
+
throw new SDKError(
|
|
3841
|
+
"Passkey authentication failed: The authenticator was already used or is invalid. You may need to re-register your passkey.",
|
|
3842
|
+
"PASSKEY_INVALID_STATE",
|
|
3843
|
+
{ error }
|
|
3844
|
+
);
|
|
3845
|
+
} else if (error.name === "NotSupportedError") {
|
|
3846
|
+
throw new SDKError(
|
|
3847
|
+
"Passkey authentication is not supported on this device or browser.",
|
|
3848
|
+
"PASSKEY_NOT_SUPPORTED",
|
|
3849
|
+
{ error }
|
|
3850
|
+
);
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3813
3853
|
throw new SDKError(
|
|
3814
3854
|
`Passkey authentication failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
3815
3855
|
"PASSKEY_AUTHENTICATION_FAILED",
|
|
@@ -3817,6 +3857,88 @@ async function authenticateWithPasskey(options) {
|
|
|
3817
3857
|
);
|
|
3818
3858
|
}
|
|
3819
3859
|
}
|
|
3860
|
+
function formatAuthenticationForVerification(challenge, credential) {
|
|
3861
|
+
return {
|
|
3862
|
+
challenge,
|
|
3863
|
+
credential
|
|
3864
|
+
};
|
|
3865
|
+
}
|
|
3866
|
+
async function findExistingPasskeySigner(walletId, credentialId) {
|
|
3867
|
+
var _a, _b;
|
|
3868
|
+
try {
|
|
3869
|
+
const signers = await listSigners(walletId);
|
|
3870
|
+
const signerResponse = signers;
|
|
3871
|
+
const signerList = Array.isArray(signerResponse) ? signerResponse : Array.isArray(signerResponse.data) ? signerResponse.data : [];
|
|
3872
|
+
const passkeySigners = signerList.filter(
|
|
3873
|
+
(s) => (s.type === "passkey" || s.signerType === "passkey") && (s.isActive ?? s.active ?? true)
|
|
3874
|
+
);
|
|
3875
|
+
if (credentialId) {
|
|
3876
|
+
const matching = passkeySigners.find((s) => {
|
|
3877
|
+
var _a2, _b2;
|
|
3878
|
+
const credId = ((_a2 = s.credential) == null ? void 0 : _a2.id) || ((_b2 = s.passkey) == null ? void 0 : _b2.id);
|
|
3879
|
+
return credId === credentialId;
|
|
3880
|
+
});
|
|
3881
|
+
if (matching) {
|
|
3882
|
+
return {
|
|
3883
|
+
signerId: matching.id || matching.signerId || "",
|
|
3884
|
+
credentialId
|
|
3885
|
+
};
|
|
3886
|
+
}
|
|
3887
|
+
} else if (passkeySigners.length > 0) {
|
|
3888
|
+
const first = passkeySigners[0];
|
|
3889
|
+
return {
|
|
3890
|
+
signerId: first.id || first.signerId || "",
|
|
3891
|
+
credentialId: ((_a = first.credential) == null ? void 0 : _a.id) || ((_b = first.passkey) == null ? void 0 : _b.id)
|
|
3892
|
+
};
|
|
3893
|
+
}
|
|
3894
|
+
return null;
|
|
3895
|
+
} catch (error) {
|
|
3896
|
+
return null;
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
async function registerPasskeyComplete(walletId, options) {
|
|
3900
|
+
if (!isWebAuthnSupported()) {
|
|
3901
|
+
throw new SDKError("WebAuthn not supported", "WEBAUTHN_NOT_SUPPORTED");
|
|
3902
|
+
}
|
|
3903
|
+
if (!(options == null ? void 0 : options.skipDuplicateCheck)) {
|
|
3904
|
+
const existing = await findExistingPasskeySigner(walletId, options == null ? void 0 : options.credentialId);
|
|
3905
|
+
if (existing) {
|
|
3906
|
+
return {
|
|
3907
|
+
signerId: existing.signerId,
|
|
3908
|
+
isNew: false,
|
|
3909
|
+
credentialId: existing.credentialId
|
|
3910
|
+
};
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
const registrationOptionsResponse = await startPasskeyRegistration(walletId);
|
|
3914
|
+
const registrationOptions = (registrationOptionsResponse == null ? void 0 : registrationOptionsResponse.data) || registrationOptionsResponse;
|
|
3915
|
+
const credential = await registerPasskey(registrationOptions);
|
|
3916
|
+
const challenge = registrationOptions.challenge;
|
|
3917
|
+
await verifyPasskeyRegistration(walletId, {
|
|
3918
|
+
challenge,
|
|
3919
|
+
credential
|
|
3920
|
+
});
|
|
3921
|
+
const signers = await listSigners(walletId);
|
|
3922
|
+
const signerResponse = signers;
|
|
3923
|
+
const signerList = Array.isArray(signerResponse) ? signerResponse : Array.isArray(signerResponse.data) ? signerResponse.data : [];
|
|
3924
|
+
const credentialId = credential.id;
|
|
3925
|
+
const newSigner = signerList.find((s) => {
|
|
3926
|
+
var _a, _b;
|
|
3927
|
+
const credId = ((_a = s.credential) == null ? void 0 : _a.id) || ((_b = s.passkey) == null ? void 0 : _b.id);
|
|
3928
|
+
return credId === credentialId && (s.type === "passkey" || s.signerType === "passkey");
|
|
3929
|
+
});
|
|
3930
|
+
if (!newSigner) {
|
|
3931
|
+
throw new SDKError(
|
|
3932
|
+
"Passkey signer was created but could not be retrieved",
|
|
3933
|
+
"PASSKEY_SIGNER_NOT_FOUND"
|
|
3934
|
+
);
|
|
3935
|
+
}
|
|
3936
|
+
return {
|
|
3937
|
+
signerId: newSigner.id || newSigner.signerId || "",
|
|
3938
|
+
isNew: true,
|
|
3939
|
+
credentialId
|
|
3940
|
+
};
|
|
3941
|
+
}
|
|
3820
3942
|
|
|
3821
3943
|
// src/signers/signerLifecycle.ts
|
|
3822
3944
|
async function createSigner(walletId, type, params) {
|
|
@@ -4054,6 +4176,8 @@ async function signMessage2(wallet, message) {
|
|
|
4054
4176
|
exportToSPKI,
|
|
4055
4177
|
findAndValidateDeviceKey,
|
|
4056
4178
|
findDeviceKeyByPublicKey,
|
|
4179
|
+
findExistingPasskeySigner,
|
|
4180
|
+
formatAuthenticationForVerification,
|
|
4057
4181
|
formatAuthenticationResponse,
|
|
4058
4182
|
formatRegistrationResponse,
|
|
4059
4183
|
generateDeviceKeyPair,
|
|
@@ -4084,6 +4208,7 @@ async function signMessage2(wallet, message) {
|
|
|
4084
4208
|
parseSignerResponse,
|
|
4085
4209
|
pemToBase64,
|
|
4086
4210
|
registerPasskey,
|
|
4211
|
+
registerPasskeyComplete,
|
|
4087
4212
|
replaceDevice,
|
|
4088
4213
|
replaceDeviceIdentity,
|
|
4089
4214
|
resolveDeviceKey,
|