cilantro-sdk 0.0.45 → 0.0.46

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 CHANGED
@@ -94,8 +94,8 @@ const authResult = await login({
94
94
  password: 'password123'
95
95
  });
96
96
 
97
- // Manually set authentication
98
- setAuth({ jwt: authResult.data.jwt });
97
+ // Manually set authentication (API returns accessToken)
98
+ setAuth({ jwt: authResult.data.accessToken });
99
99
 
100
100
  // Make authenticated requests
101
101
  const result = await sendSOL('wallet-id', {
@@ -310,14 +310,15 @@ configure({
310
310
  });
311
311
  ```
312
312
 
313
- ### `setAuth(auth: { jwt?: string; apiKey?: string }): void`
313
+ ### `setAuth(auth: { jwt?: string; apiKey?: string; platformApiKey?: string }): void`
314
314
 
315
- Update authentication credentials after initialization. Useful when credentials change (e.g., after login or token refresh).
315
+ Update authentication credentials after initialization. Useful when credentials change (e.g., after login or token refresh). The API key is set from `apiKey` or `platformApiKey` (whichever is provided).
316
316
 
317
317
  **Parameters:**
318
318
  - `auth` (`object`): Authentication credentials
319
- - `jwt?` (`string`): JWT token to set
319
+ - `jwt?` (`string`): JWT access token to set (from login/social/Discord)
320
320
  - `apiKey?` (`string`): API key to set
321
+ - `platformApiKey?` (`string`): Platform API key (alternative to `apiKey`)
321
322
 
322
323
  **Returns:** `void`
323
324
 
@@ -332,7 +333,7 @@ const result = await login({
332
333
  password: 'password123'
333
334
  });
334
335
 
335
- setAuth({ jwt: result.data.jwt });
336
+ setAuth({ jwt: result.data.accessToken });
336
337
  ```
337
338
 
338
339
  ### `clearAuth(): void`
@@ -429,14 +430,15 @@ configure({
429
430
  });
430
431
  ```
431
432
 
432
- #### `setAuth(auth: { jwt?: string; apiKey?: string }): void`
433
+ #### `setAuth(auth: { jwt?: string; apiKey?: string; platformApiKey?: string }): void`
433
434
 
434
- Update authentication credentials after initialization.
435
+ Update authentication credentials after initialization. API key is set from `apiKey` or `platformApiKey`.
435
436
 
436
437
  **Parameters:**
437
438
  - `auth` (`object`): Authentication credentials
438
- - `jwt?` (`string`): JWT token
439
+ - `jwt?` (`string`): JWT access token
439
440
  - `apiKey?` (`string`): API key
441
+ - `platformApiKey?` (`string`): Platform API key (alternative to `apiKey`)
440
442
 
441
443
  **Returns:** `void`
442
444
 
@@ -5,12 +5,13 @@
5
5
  * API documentation for Cilantro Smart API - A Solana wallet management system
6
6
  * OpenAPI spec version: 1.0
7
7
  */
8
- import type { AuthControllerGetDiscordAuthorizeUrl200, AuthControllerGetDiscordAuthorizeUrlParams, AuthSuccessResponseDto, CommonLoginDto, DiscordCallbackDto, LoginResponseDto, PasswordResetConfirmDto, PasswordResetRequestDto, RefreshTokenDto, SocialLoginDto, TokenResponseDto, VerifyEmailDto } from "../../models";
8
+ import type { AuthControllerDiscordCallbackGetParams, AuthControllerGetDiscordAuthorizeUrl200, AuthControllerGetDiscordAuthorizeUrlParams, AuthSuccessResponseDto, CommonLoginDto, DiscordCallbackDto, LoginResponseDto, PasswordResetConfirmDto, PasswordResetRequestDto, RefreshTokenDto, SocialLoginDto, TokenResponseDto, VerifyEmailDto } 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 getAuth: () => {
12
12
  authControllerLogin: (commonLoginDto: CommonLoginDto, options?: SecondParameter<typeof customInstance<LoginResponseDto>>) => Promise<LoginResponseDto>;
13
13
  authControllerGetDiscordAuthorizeUrl: (params: AuthControllerGetDiscordAuthorizeUrlParams, options?: SecondParameter<typeof customInstance<AuthControllerGetDiscordAuthorizeUrl200>>) => Promise<AuthControllerGetDiscordAuthorizeUrl200>;
14
+ authControllerDiscordCallbackGet: (params: AuthControllerDiscordCallbackGetParams, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
14
15
  authControllerDiscordCallback: (discordCallbackDto: DiscordCallbackDto, options?: SecondParameter<typeof customInstance<LoginResponseDto>>) => Promise<LoginResponseDto>;
15
16
  authControllerSocialLogin: (socialLoginDto: SocialLoginDto, options?: SecondParameter<typeof customInstance<LoginResponseDto>>) => Promise<LoginResponseDto>;
16
17
  authControllerRefreshToken: (refreshTokenDto: RefreshTokenDto, options?: SecondParameter<typeof customInstance<TokenResponseDto>>) => Promise<TokenResponseDto>;
@@ -22,6 +23,7 @@ export declare const getAuth: () => {
22
23
  };
23
24
  export type AuthControllerLoginResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getAuth>["authControllerLogin"]>>>;
24
25
  export type AuthControllerGetDiscordAuthorizeUrlResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getAuth>["authControllerGetDiscordAuthorizeUrl"]>>>;
26
+ export type AuthControllerDiscordCallbackGetResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getAuth>["authControllerDiscordCallbackGet"]>>>;
25
27
  export type AuthControllerDiscordCallbackResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getAuth>["authControllerDiscordCallback"]>>>;
26
28
  export type AuthControllerSocialLoginResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getAuth>["authControllerSocialLogin"]>>>;
27
29
  export type AuthControllerRefreshTokenResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getAuth>["authControllerRefreshToken"]>>>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/api/auth/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,uCAAuC,EACvC,0CAA0C,EAC1C,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,KAAK,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAA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CAAC,CAAC,CAAC,CAC7E,CAAC;AACF,MAAM,MAAM,sCAAsC,GAAG,WAAW,CAC9D,OAAO,CACL,UAAU,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAC3E,CACF,CAAC"}
package/dist/auth.cjs CHANGED
@@ -34,8 +34,10 @@ __export(auth_exports, {
34
34
  discordCallback: () => discordCallback,
35
35
  discordCallbackAndSetAuth: () => discordCallbackAndSetAuth,
36
36
  getDiscordAuthorizeUrl: () => getDiscordAuthorizeUrl,
37
+ getTokensFromFragment: () => getTokensFromFragment,
37
38
  login: () => login,
38
39
  loginAndSetAuth: () => loginAndSetAuth,
40
+ setAuthFromFragment: () => setAuthFromFragment,
39
41
  socialLogin: () => socialLogin,
40
42
  socialLoginAndSetAuth: () => socialLoginAndSetAuth
41
43
  });
@@ -130,6 +132,12 @@ var getAuth = () => {
130
132
  options
131
133
  );
132
134
  };
135
+ const authControllerDiscordCallbackGet = (params, options) => {
136
+ return customInstance(
137
+ { url: `/auth/discord/callback`, method: "GET", params },
138
+ options
139
+ );
140
+ };
133
141
  const authControllerDiscordCallback = (discordCallbackDto, options) => {
134
142
  return customInstance(
135
143
  {
@@ -221,6 +229,7 @@ var getAuth = () => {
221
229
  return {
222
230
  authControllerLogin,
223
231
  authControllerGetDiscordAuthorizeUrl,
232
+ authControllerDiscordCallbackGet,
224
233
  authControllerDiscordCallback,
225
234
  authControllerSocialLogin,
226
235
  authControllerRefreshToken,
@@ -274,13 +283,37 @@ async function getDiscordAuthorizeUrl(params) {
274
283
  "Platform API key required for Discord auth. Pass platformApiKey or set it via setAuth({ apiKey }) or configure({ apiKey })."
275
284
  );
276
285
  }
277
- return auth.authControllerGetDiscordAuthorizeUrl(
278
- {
279
- redirect_uri: params.redirectUri,
280
- platformApiKey
281
- },
282
- params.state !== void 0 ? { params: { state: params.state } } : void 0
283
- );
286
+ return auth.authControllerGetDiscordAuthorizeUrl({
287
+ client_redirect_uri: params.clientRedirectUri,
288
+ platformApiKey
289
+ });
290
+ }
291
+ function getTokensFromFragment(hash) {
292
+ const raw = hash ?? (typeof window !== "undefined" ? window.location.hash.slice(1) : void 0);
293
+ if (!raw)
294
+ return null;
295
+ const params = new URLSearchParams(raw);
296
+ const accessToken = params.get("access_token");
297
+ const refreshToken = params.get("refresh_token");
298
+ if (!accessToken || !refreshToken)
299
+ return null;
300
+ return {
301
+ accessToken,
302
+ refreshToken,
303
+ expiresIn: params.get("expires_in") ?? void 0,
304
+ tokenType: params.get("token_type") ?? void 0
305
+ };
306
+ }
307
+ function setAuthFromFragment(options) {
308
+ const hash = (options == null ? void 0 : options.hash) ?? (typeof window !== "undefined" ? window.location.hash.slice(1) : void 0);
309
+ const tokens = getTokensFromFragment(hash ?? void 0);
310
+ if (!tokens)
311
+ return null;
312
+ setAuth({ jwt: tokens.accessToken });
313
+ if ((options == null ? void 0 : options.clearHash) !== false && typeof window !== "undefined" && window.history.replaceState) {
314
+ window.history.replaceState(null, "", window.location.pathname + window.location.search);
315
+ }
316
+ return tokens;
284
317
  }
285
318
  async function discordCallbackAndSetAuth(params) {
286
319
  var _a, _b;
@@ -306,8 +339,10 @@ async function discordCallbackAndSetAuth(params) {
306
339
  discordCallback,
307
340
  discordCallbackAndSetAuth,
308
341
  getDiscordAuthorizeUrl,
342
+ getTokensFromFragment,
309
343
  login,
310
344
  loginAndSetAuth,
345
+ setAuthFromFragment,
311
346
  socialLogin,
312
347
  socialLoginAndSetAuth
313
348
  });
package/dist/auth.cjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/auth.ts", "../src/config.ts", "../src/api-client.ts", "../src/api/auth/auth.ts", "../src/models/socialLoginDtoProvider.ts"],
4
- "sourcesContent": ["/**\r\n * Auth module - Simplified exports for authentication-related API functions\r\n */\r\n\r\nimport { getConfig, setAuth } from './config';\r\nimport { getAuth } from './api/auth/auth';\r\nimport type { CommonLoginDto, SocialLoginDto } from './models';\r\nimport type {\r\n AuthControllerLoginResult,\r\n AuthControllerSocialLoginResult,\r\n AuthControllerGetDiscordAuthorizeUrlResult,\r\n AuthControllerDiscordCallbackResult,\r\n} from './api/auth/auth';\r\n\r\nconst auth = getAuth();\r\n\r\n// Export auth functions with simplified names\r\nexport const login = auth.authControllerLogin;\r\nexport const socialLogin = auth.authControllerSocialLogin;\r\n\r\n/** Exchange Discord authorization code for Cilantro tokens (Step 3). Use discordCallbackAndSetAuth() to also set SDK auth. */\r\nexport const discordCallback = auth.authControllerDiscordCallback;\r\n\r\ntype AuthRequestOptions = Parameters<\r\n ReturnType<typeof getAuth>['authControllerLogin']\r\n>[1];\r\n\r\ntype SocialAuthRequestOptions = Parameters<\r\n ReturnType<typeof getAuth>['authControllerSocialLogin']\r\n>[1];\r\n\r\ntype DiscordCallbackOptions = Parameters<\r\n ReturnType<typeof getAuth>['authControllerDiscordCallback']\r\n>[1];\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?: AuthRequestOptions\r\n): Promise<AuthControllerLoginResult> {\r\n const result = await login(credentials, options);\r\n \r\n // Automatically set auth from login response (API uses accessToken, we store as jwt)\r\n if (result.data?.accessToken) {\r\n setAuth({ jwt: result.data.accessToken });\r\n }\r\n if (result.data?.apiKey !== undefined) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Authenticate with Google or Apple id_token and automatically set authentication credentials.\r\n * Use after the user signs in with Google/Apple OAuth and you receive the id_token.\r\n *\r\n * @param credentials - Social login credentials (provider + id_token)\r\n * @returns Login result with user information\r\n *\r\n * @example\r\n * ```typescript\r\n * import { socialLoginAndSetAuth } from 'cilantro-sdk/auth';\r\n *\r\n * // After user signs in with Google Sign-In\r\n * await socialLoginAndSetAuth({\r\n * provider: 'google',\r\n * id_token: googleUser.credential.id_token,\r\n * });\r\n *\r\n * // After user signs in with Apple\r\n * await socialLoginAndSetAuth({\r\n * provider: 'apple',\r\n * id_token: appleIdToken,\r\n * platformApiKey: 'your-api-key', // optional if sent via X-API-Key header\r\n * });\r\n * ```\r\n */\r\nexport async function socialLoginAndSetAuth(\r\n credentials: SocialLoginDto,\r\n options?: SocialAuthRequestOptions\r\n): Promise<AuthControllerSocialLoginResult> {\r\n const result = await socialLogin(credentials, options);\r\n\r\n if (result.data?.accessToken) {\r\n setAuth({ jwt: result.data.accessToken });\r\n }\r\n if (result.data?.apiKey !== undefined) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Discord OAuth2 login \u2013 Step 1: get the authorize URL and redirect the user.\r\n * Uses platform API key from config (setAuth/configure) if platformApiKey is not passed.\r\n *\r\n * @param params.redirectUri - Where Discord will redirect after auth (e.g. https://myapp.com/auth/discord/callback). Must match exactly in Step 3.\r\n * @param params.state - Optional CSRF token; store (e.g. sessionStorage) and verify on callback.\r\n * @param params.platformApiKey - Platform API key (optional if already set via setAuth/configure).\r\n * @returns Promise with { authorizeUrl }. Redirect the user to authorizeUrl.\r\n *\r\n * @example\r\n * ```ts\r\n * const state = crypto.randomUUID();\r\n * sessionStorage.setItem('discord_oauth_state', state);\r\n * const { authorizeUrl } = await getDiscordAuthorizeUrl({\r\n * redirectUri: 'https://myapp.com/auth/discord/callback',\r\n * state,\r\n * });\r\n * window.location.href = authorizeUrl;\r\n * ```\r\n */\r\nexport async function getDiscordAuthorizeUrl(params: {\r\n redirectUri: string;\r\n state?: string;\r\n platformApiKey?: string;\r\n}): Promise<AuthControllerGetDiscordAuthorizeUrlResult> {\r\n const config = getConfig();\r\n const platformApiKey = params.platformApiKey ?? config.apiKey;\r\n if (!platformApiKey) {\r\n throw new Error(\r\n 'Platform API key required for Discord auth. Pass platformApiKey or set it via setAuth({ apiKey }) or configure({ apiKey }).'\r\n );\r\n }\r\n return auth.authControllerGetDiscordAuthorizeUrl(\r\n {\r\n redirect_uri: params.redirectUri,\r\n platformApiKey,\r\n },\r\n params.state !== undefined ? { params: { state: params.state } as Record<string, string> } : undefined\r\n );\r\n}\r\n\r\n/**\r\n * Discord OAuth2 login \u2013 Step 3: exchange code for Cilantro tokens and set auth.\r\n * Call this on your callback page after verifying the `state` and reading `code` from the query.\r\n *\r\n * @param params.code - The `code` query parameter from Discord's redirect.\r\n * @param params.redirectUri - Must match exactly the redirectUri used in Step 1.\r\n * @param params.platformApiKey - Optional if already set via setAuth/configure.\r\n * @returns Login result; also sets JWT and API key in SDK config for subsequent requests.\r\n */\r\nexport async function discordCallbackAndSetAuth(params: {\r\n code: string;\r\n redirectUri: string;\r\n platformApiKey?: string;\r\n options?: DiscordCallbackOptions;\r\n}): Promise<AuthControllerDiscordCallbackResult> {\r\n const result = await auth.authControllerDiscordCallback(\r\n {\r\n code: params.code,\r\n redirect_uri: params.redirectUri,\r\n ...(params.platformApiKey !== undefined && { platformApiKey: params.platformApiKey }),\r\n },\r\n params.options\r\n );\r\n if (result.data?.accessToken) {\r\n setAuth({ jwt: result.data.accessToken });\r\n }\r\n if (result.data?.apiKey !== undefined) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n return result;\r\n}\r\n\r\n// Export types\r\nexport type {\r\n AuthControllerLoginResult,\r\n AuthControllerSocialLoginResult,\r\n AuthControllerGetDiscordAuthorizeUrlResult,\r\n AuthControllerDiscordCallbackResult,\r\n AuthControllerRequestPasswordResetResult,\r\n AuthControllerConfirmPasswordResetResult,\r\n AuthControllerVerifyEmailResult,\r\n AuthControllerResendVerificationResult,\r\n} from './api/auth/auth';\r\n\r\nexport type {\r\n CommonLoginDto,\r\n SocialLoginDto,\r\n AuthControllerLogin200,\r\n AuthControllerLogin200Data,\r\n DiscordCallbackDto,\r\n AuthControllerGetDiscordAuthorizeUrlParams,\r\n AuthControllerGetDiscordAuthorizeUrl200,\r\n} from './models';\r\n\r\nexport { SocialLoginDtoProvider } from './models';\r\n\r\nexport type LoginParams = CommonLoginDto;\r\nexport type LoginResult = AuthControllerLoginResult;\r\nexport type LoginOptions = AuthRequestOptions;\r\nexport type LoginAndSetAuthParams = CommonLoginDto;\r\nexport type LoginAndSetAuthOptions = AuthRequestOptions | undefined;\r\nexport type LoginAndSetAuthResult = AuthControllerLoginResult;\r\nexport type SocialLoginAndSetAuthParams = SocialLoginDto;\r\nexport type SocialLoginAndSetAuthOptions = SocialAuthRequestOptions | undefined;\r\nexport type SocialLoginAndSetAuthResult = AuthControllerSocialLoginResult;\r\n/** Response from getDiscordAuthorizeUrl(); redirect the user to authorizeUrl. */\r\nexport type DiscordAuthorizeUrlResponse = { authorizeUrl: string };\r\n\r\nexport type GetDiscordAuthorizeUrlParams = {\r\n redirectUri: string;\r\n state?: string;\r\n platformApiKey?: string;\r\n};\r\nexport type DiscordCallbackAndSetAuthParams = {\r\n code: string;\r\n redirectUri: string;\r\n platformApiKey?: string;\r\n options?: DiscordCallbackOptions;\r\n};\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; platformApiKey?: 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 currentConfig.apiKey = auth.apiKey ?? auth.platformApiKey;\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", "/**\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", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API\n * API documentation for Cilantro Smart API - A Solana wallet management system\n * OpenAPI spec version: 1.0\n */\nimport type {\n AuthControllerGetDiscordAuthorizeUrl200,\n AuthControllerGetDiscordAuthorizeUrlParams,\n AuthSuccessResponseDto,\n CommonLoginDto,\n DiscordCallbackDto,\n LoginResponseDto,\n PasswordResetConfirmDto,\n PasswordResetRequestDto,\n RefreshTokenDto,\n SocialLoginDto,\n TokenResponseDto,\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 access token (1h expiry) and refresh token (7d expiry).\n * @summary Universal login endpoint\n */\n const authControllerLogin = (\n commonLoginDto: CommonLoginDto,\n options?: SecondParameter<typeof customInstance<LoginResponseDto>>,\n ) => {\n return customInstance<LoginResponseDto>(\n {\n url: `/auth/login`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: commonLoginDto,\n },\n options,\n );\n };\n /**\n * Returns the Discord authorization URL. Your app redirects the user there; after Discord redirects back with a code, call POST /auth/social/discord/callback with the code and same redirect_uri. Requires DISCORD_CLIENT_ID and DISCORD_CLIENT_SECRET on the server.\n * @summary Get Discord OAuth2 authorize URL (SDK / backend-handled flow)\n */\n const authControllerGetDiscordAuthorizeUrl = (\n params: AuthControllerGetDiscordAuthorizeUrlParams,\n options?: SecondParameter<\n typeof customInstance<AuthControllerGetDiscordAuthorizeUrl200>\n >,\n ) => {\n return customInstance<AuthControllerGetDiscordAuthorizeUrl200>(\n { url: `/auth/discord/authorize`, method: \"GET\", params },\n options,\n );\n };\n /**\n * Send the authorization code and redirect_uri from your Discord callback page. Backend exchanges the code for a Discord access_token, then finds or creates the user and returns Cilantro access and refresh tokens (same shape as POST /auth/login).\n * @summary Discord OAuth2 callback (SDK / backend-handled flow)\n */\n const authControllerDiscordCallback = (\n discordCallbackDto: DiscordCallbackDto,\n options?: SecondParameter<typeof customInstance<LoginResponseDto>>,\n ) => {\n return customInstance<LoginResponseDto>(\n {\n url: `/auth/social/discord/callback`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: discordCallbackDto,\n },\n options,\n );\n };\n /**\n * Authenticate with Google (id_token), Apple (id_token), or Discord (access_token). Send platformApiKey in body or X-API-Key header. Returns same access and refresh tokens as POST /auth/login. For Discord SDK flow use GET /auth/discord/authorize and POST /auth/social/discord/callback instead.\n * @summary Social login (Web3Auth-style)\n */\n const authControllerSocialLogin = (\n socialLoginDto: SocialLoginDto,\n options?: SecondParameter<typeof customInstance<LoginResponseDto>>,\n ) => {\n return customInstance<LoginResponseDto>(\n {\n url: `/auth/social`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: socialLoginDto,\n },\n options,\n );\n };\n /**\n * Use a valid refresh token to obtain a new access token. The old refresh token is revoked and a new one is issued (token rotation).\n * @summary Refresh access token\n */\n const authControllerRefreshToken = (\n refreshTokenDto: RefreshTokenDto,\n options?: SecondParameter<typeof customInstance<TokenResponseDto>>,\n ) => {\n return customInstance<TokenResponseDto>(\n {\n url: `/auth/refresh`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: refreshTokenDto,\n },\n options,\n );\n };\n /**\n * Revoke the provided refresh token to logout the current session.\n * @summary Logout (revoke refresh token)\n */\n const authControllerLogout = (\n refreshTokenDto: RefreshTokenDto,\n options?: SecondParameter<typeof customInstance<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\n {\n url: `/auth/logout`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: refreshTokenDto,\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<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\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<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\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<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\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<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\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 authControllerGetDiscordAuthorizeUrl,\n authControllerDiscordCallback,\n authControllerSocialLogin,\n authControllerRefreshToken,\n authControllerLogout,\n authControllerRequestPasswordReset,\n authControllerConfirmPasswordReset,\n authControllerVerifyEmail,\n authControllerResendVerification,\n };\n};\nexport type AuthControllerLoginResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerLogin\"]>>\n>;\nexport type AuthControllerGetDiscordAuthorizeUrlResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<typeof getAuth>[\"authControllerGetDiscordAuthorizeUrl\"]\n >\n >\n>;\nexport type AuthControllerDiscordCallbackResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerDiscordCallback\"]>\n >\n>;\nexport type AuthControllerSocialLoginResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerSocialLogin\"]>>\n>;\nexport type AuthControllerRefreshTokenResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerRefreshToken\"]>>\n>;\nexport type AuthControllerLogoutResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerLogout\"]>>\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", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API\n * API documentation for Cilantro Smart API - A Solana wallet management system\n * OpenAPI spec version: 1.0\n */\n\n/**\n * OAuth provider used for social login\n */\nexport type SocialLoginDtoProvider =\n (typeof SocialLoginDtoProvider)[keyof typeof SocialLoginDtoProvider];\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport const SocialLoginDtoProvider = {\n google: \"google\",\n apple: \"apple\",\n discord: \"discord\",\n} as const;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqBA,IAAM,oBAAoB;AAQ1B,SAAS,kBAA6B;AACpC,QAAM,gBAA2B;AAAA,IAC/B,SAAS,QAAQ,IAAI,oBAAoB;AAAA,EAC3C;AAEA,MAAI,OAAO,eAAW,aAAa;AACjC,QAAI,CAAC,WAAO,yBAAyB;AACnC,iBAAO,0BAA0B;AAAA,IACnC;AACA,WAAO,WAAO;AAAA,EAChB,WAAW,OAAQ,WAAmB,WAAW,aAAa;AAC5D,UAAM,MAAO,WAAmB;AAChC,QAAI,CAAC,I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\r\n * Auth module - Simplified exports for authentication-related API functions\r\n */\r\n\r\nimport { getConfig, setAuth } from './config';\r\nimport { getAuth } from './api/auth/auth';\r\nimport type { CommonLoginDto, SocialLoginDto } from './models';\r\nimport type {\r\n AuthControllerLoginResult,\r\n AuthControllerSocialLoginResult,\r\n AuthControllerGetDiscordAuthorizeUrlResult,\r\n AuthControllerDiscordCallbackResult,\r\n} from './api/auth/auth';\r\n\r\nconst auth = getAuth();\r\n\r\n// Export auth functions with simplified names\r\nexport const login = auth.authControllerLogin;\r\nexport const socialLogin = auth.authControllerSocialLogin;\r\n\r\n/**\r\n * Legacy: exchange Discord code for tokens when your app receives the code (your URL in Discord redirects).\r\n * Recommended flow is getDiscordAuthorizeUrl + setAuthFromFragment (backend-only callback).\r\n */\r\nexport const discordCallback = auth.authControllerDiscordCallback;\r\n\r\ntype AuthRequestOptions = Parameters<\r\n ReturnType<typeof getAuth>['authControllerLogin']\r\n>[1];\r\n\r\ntype SocialAuthRequestOptions = Parameters<\r\n ReturnType<typeof getAuth>['authControllerSocialLogin']\r\n>[1];\r\n\r\ntype DiscordCallbackOptions = Parameters<\r\n ReturnType<typeof getAuth>['authControllerDiscordCallback']\r\n>[1];\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?: AuthRequestOptions\r\n): Promise<AuthControllerLoginResult> {\r\n const result = await login(credentials, options);\r\n \r\n // Automatically set auth from login response (API uses accessToken, we store as jwt)\r\n if (result.data?.accessToken) {\r\n setAuth({ jwt: result.data.accessToken });\r\n }\r\n if (result.data?.apiKey !== undefined) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Authenticate with Google or Apple id_token and automatically set authentication credentials.\r\n * Use after the user signs in with Google/Apple OAuth and you receive the id_token.\r\n *\r\n * @param credentials - Social login credentials (provider + id_token)\r\n * @returns Login result with user information\r\n *\r\n * @example\r\n * ```typescript\r\n * import { socialLoginAndSetAuth } from 'cilantro-sdk/auth';\r\n *\r\n * // After user signs in with Google Sign-In\r\n * await socialLoginAndSetAuth({\r\n * provider: 'google',\r\n * id_token: googleUser.credential.id_token,\r\n * });\r\n *\r\n * // After user signs in with Apple\r\n * await socialLoginAndSetAuth({\r\n * provider: 'apple',\r\n * id_token: appleIdToken,\r\n * platformApiKey: 'your-api-key', // optional if sent via X-API-Key header\r\n * });\r\n * ```\r\n */\r\nexport async function socialLoginAndSetAuth(\r\n credentials: SocialLoginDto,\r\n options?: SocialAuthRequestOptions\r\n): Promise<AuthControllerSocialLoginResult> {\r\n const result = await socialLogin(credentials, options);\r\n\r\n if (result.data?.accessToken) {\r\n setAuth({ jwt: result.data.accessToken });\r\n }\r\n if (result.data?.apiKey !== undefined) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Discord OAuth2 login \u2013 Step 1: get the authorize URL and redirect the user.\r\n * Discord redirects only to the backend; the backend then redirects to your clientRedirectUri with\r\n * tokens in the URL fragment (#access_token=...&refresh_token=...). Use setAuthFromFragment() on\r\n * the page at clientRedirectUri to parse and set auth.\r\n *\r\n * @param params.clientRedirectUri - Where the user should land after login (e.g. https://myapp.com/dashboard or /auth/callback). Backend redirects here with tokens in the fragment.\r\n * @param params.platformApiKey - Platform API key (optional if already set via setAuth/configure).\r\n * @returns Promise with { authorizeUrl }. Redirect the user to authorizeUrl.\r\n *\r\n * @example\r\n * ```ts\r\n * const { authorizeUrl } = await getDiscordAuthorizeUrl({\r\n * clientRedirectUri: 'https://myapp.com/dashboard',\r\n * });\r\n * window.location.href = authorizeUrl;\r\n * ```\r\n */\r\nexport async function getDiscordAuthorizeUrl(params: {\r\n clientRedirectUri: string;\r\n platformApiKey?: string;\r\n}): Promise<AuthControllerGetDiscordAuthorizeUrlResult> {\r\n const config = getConfig();\r\n const platformApiKey = params.platformApiKey ?? config.apiKey;\r\n if (!platformApiKey) {\r\n throw new Error(\r\n 'Platform API key required for Discord auth. Pass platformApiKey or set it via setAuth({ apiKey }) or configure({ apiKey }).'\r\n );\r\n }\r\n return auth.authControllerGetDiscordAuthorizeUrl({\r\n client_redirect_uri: params.clientRedirectUri,\r\n platformApiKey,\r\n });\r\n}\r\n\r\n/**\r\n * Parses the URL fragment from the Discord redirect (backend sends tokens in the fragment).\r\n * Use on the page at client_redirect_uri after the user returns from Discord login.\r\n *\r\n * @param hash - Fragment string (e.g. window.location.hash.slice(1)). If omitted, returns null (for non-browser or no hash).\r\n * @returns Parsed tokens or null if hash is empty/invalid.\r\n */\r\nexport function getTokensFromFragment(\r\n hash?: string\r\n): { accessToken: string; refreshToken: string; expiresIn?: string; tokenType?: string } | null {\r\n const raw = hash ?? (typeof window !== 'undefined' ? window.location.hash.slice(1) : undefined);\r\n if (!raw) return null;\r\n const params = new URLSearchParams(raw);\r\n const accessToken = params.get('access_token');\r\n const refreshToken = params.get('refresh_token');\r\n if (!accessToken || !refreshToken) return null;\r\n return {\r\n accessToken,\r\n refreshToken,\r\n expiresIn: params.get('expires_in') ?? undefined,\r\n tokenType: params.get('token_type') ?? undefined,\r\n };\r\n}\r\n\r\n/**\r\n * Discord OAuth2 \u2013 Step 2: read tokens from the URL fragment and set SDK auth.\r\n * Call this on the page at client_redirect_uri (the URL you passed to getDiscordAuthorizeUrl).\r\n *\r\n * @param options.hash - Fragment to parse (defaults to window.location.hash if in browser).\r\n * @param options.clearHash - If true (default), removes the fragment from the URL after reading.\r\n * @returns The parsed tokens, or null if no valid tokens in fragment.\r\n *\r\n * @example\r\n * ```ts\r\n * // On your dashboard or /auth/callback page\r\n * const tokens = setAuthFromFragment({ clearHash: true });\r\n * if (tokens) redirectToApp();\r\n * ```\r\n */\r\nexport function setAuthFromFragment(options?: {\r\n hash?: string;\r\n clearHash?: boolean;\r\n}): { accessToken: string; refreshToken: string; expiresIn?: string; tokenType?: string } | null {\r\n const hash = options?.hash ?? (typeof window !== 'undefined' ? window.location.hash.slice(1) : undefined);\r\n const tokens = getTokensFromFragment(hash ?? undefined);\r\n if (!tokens) return null;\r\n setAuth({ jwt: tokens.accessToken });\r\n if (options?.clearHash !== false && typeof window !== 'undefined' && window.history.replaceState) {\r\n window.history.replaceState(null, '', window.location.pathname + window.location.search);\r\n }\r\n return tokens;\r\n}\r\n\r\n/**\r\n * Legacy: exchange Discord code for Cilantro tokens and set auth.\r\n * Use only when your app receives the code from Discord (your URL in Discord redirects).\r\n * Recommended flow is getDiscordAuthorizeUrl + setAuthFromFragment.\r\n */\r\nexport async function discordCallbackAndSetAuth(params: {\r\n code: string;\r\n redirectUri: string;\r\n platformApiKey?: string;\r\n options?: DiscordCallbackOptions;\r\n}): Promise<AuthControllerDiscordCallbackResult> {\r\n const result = await auth.authControllerDiscordCallback(\r\n {\r\n code: params.code,\r\n redirect_uri: params.redirectUri,\r\n ...(params.platformApiKey !== undefined && { platformApiKey: params.platformApiKey }),\r\n },\r\n params.options\r\n );\r\n if (result.data?.accessToken) {\r\n setAuth({ jwt: result.data.accessToken });\r\n }\r\n if (result.data?.apiKey !== undefined) {\r\n setAuth({ apiKey: result.data.apiKey });\r\n }\r\n return result;\r\n}\r\n\r\n// Export types\r\nexport type {\r\n AuthControllerLoginResult,\r\n AuthControllerSocialLoginResult,\r\n AuthControllerGetDiscordAuthorizeUrlResult,\r\n AuthControllerDiscordCallbackResult,\r\n AuthControllerRequestPasswordResetResult,\r\n AuthControllerConfirmPasswordResetResult,\r\n AuthControllerVerifyEmailResult,\r\n AuthControllerResendVerificationResult,\r\n} from './api/auth/auth';\r\n\r\nexport type {\r\n CommonLoginDto,\r\n SocialLoginDto,\r\n AuthControllerLogin200,\r\n AuthControllerLogin200Data,\r\n DiscordCallbackDto,\r\n AuthControllerGetDiscordAuthorizeUrlParams,\r\n AuthControllerGetDiscordAuthorizeUrl200,\r\n} from './models';\r\n\r\nexport { SocialLoginDtoProvider } from './models';\r\n\r\nexport type LoginParams = CommonLoginDto;\r\nexport type LoginResult = AuthControllerLoginResult;\r\nexport type LoginOptions = AuthRequestOptions;\r\nexport type LoginAndSetAuthParams = CommonLoginDto;\r\nexport type LoginAndSetAuthOptions = AuthRequestOptions | undefined;\r\nexport type LoginAndSetAuthResult = AuthControllerLoginResult;\r\nexport type SocialLoginAndSetAuthParams = SocialLoginDto;\r\nexport type SocialLoginAndSetAuthOptions = SocialAuthRequestOptions | undefined;\r\nexport type SocialLoginAndSetAuthResult = AuthControllerSocialLoginResult;\r\n/** Response from getDiscordAuthorizeUrl(); redirect the user to authorizeUrl. */\r\nexport type DiscordAuthorizeUrlResponse = { authorizeUrl: string };\r\n\r\nexport type GetDiscordAuthorizeUrlParams = {\r\n clientRedirectUri: string;\r\n platformApiKey?: string;\r\n};\r\n\r\n/** Tokens parsed from the URL fragment after Discord redirect (Step 2). */\r\nexport type DiscordFragmentTokens = {\r\n accessToken: string;\r\n refreshToken: string;\r\n expiresIn?: string;\r\n tokenType?: string;\r\n};\r\nexport type DiscordCallbackAndSetAuthParams = {\r\n code: string;\r\n redirectUri: string;\r\n platformApiKey?: string;\r\n options?: DiscordCallbackOptions;\r\n};\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; platformApiKey?: 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 currentConfig.apiKey = auth.apiKey ?? auth.platformApiKey;\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", "/**\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", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API\n * API documentation for Cilantro Smart API - A Solana wallet management system\n * OpenAPI spec version: 1.0\n */\nimport type {\n AuthControllerDiscordCallbackGetParams,\n AuthControllerGetDiscordAuthorizeUrl200,\n AuthControllerGetDiscordAuthorizeUrlParams,\n AuthSuccessResponseDto,\n CommonLoginDto,\n DiscordCallbackDto,\n LoginResponseDto,\n PasswordResetConfirmDto,\n PasswordResetRequestDto,\n RefreshTokenDto,\n SocialLoginDto,\n TokenResponseDto,\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 access token (1h expiry) and refresh token (7d expiry).\n * @summary Universal login endpoint\n */\n const authControllerLogin = (\n commonLoginDto: CommonLoginDto,\n options?: SecondParameter<typeof customInstance<LoginResponseDto>>,\n ) => {\n return customInstance<LoginResponseDto>(\n {\n url: `/auth/login`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: commonLoginDto,\n },\n options,\n );\n };\n /**\n * Returns the Discord authorization URL. Your app redirects the user there. Discord redirects to the backend callback; the backend then redirects the browser to client_redirect_uri with tokens in the URL fragment. Set only the backend URL in Discord Developer Portal (e.g. https://api.cilantro.gg/auth/discord/callback).\n * @summary Get Discord OAuth2 authorize URL (backend-handled callback)\n */\n const authControllerGetDiscordAuthorizeUrl = (\n params: AuthControllerGetDiscordAuthorizeUrlParams,\n options?: SecondParameter<\n typeof customInstance<AuthControllerGetDiscordAuthorizeUrl200>\n >,\n ) => {\n return customInstance<AuthControllerGetDiscordAuthorizeUrl200>(\n { url: `/auth/discord/authorize`, method: \"GET\", params },\n options,\n );\n };\n /**\n * Discord redirects here with code and state. Backend exchanges the code, issues tokens, then redirects the browser to the client URL with tokens in the fragment.\n * @summary Discord OAuth2 callback (backend redirect target)\n */\n const authControllerDiscordCallbackGet = (\n params: AuthControllerDiscordCallbackGetParams,\n options?: SecondParameter<typeof customInstance<void>>,\n ) => {\n return customInstance<void>(\n { url: `/auth/discord/callback`, method: \"GET\", params },\n options,\n );\n };\n /**\n * Send the authorization code and redirect_uri from your Discord callback page. Backend exchanges the code for a Discord access_token, then finds or creates the user and returns Cilantro access and refresh tokens (same shape as POST /auth/login).\n * @summary Discord OAuth2 callback (SDK / backend-handled flow)\n */\n const authControllerDiscordCallback = (\n discordCallbackDto: DiscordCallbackDto,\n options?: SecondParameter<typeof customInstance<LoginResponseDto>>,\n ) => {\n return customInstance<LoginResponseDto>(\n {\n url: `/auth/social/discord/callback`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: discordCallbackDto,\n },\n options,\n );\n };\n /**\n * Authenticate with Google (id_token), Apple (id_token), or Discord (access_token). Send platformApiKey in body or X-API-Key header. Returns same access and refresh tokens as POST /auth/login. For Discord SDK flow use GET /auth/discord/authorize and POST /auth/social/discord/callback instead.\n * @summary Social login (Web3Auth-style)\n */\n const authControllerSocialLogin = (\n socialLoginDto: SocialLoginDto,\n options?: SecondParameter<typeof customInstance<LoginResponseDto>>,\n ) => {\n return customInstance<LoginResponseDto>(\n {\n url: `/auth/social`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: socialLoginDto,\n },\n options,\n );\n };\n /**\n * Use a valid refresh token to obtain a new access token. The old refresh token is revoked and a new one is issued (token rotation).\n * @summary Refresh access token\n */\n const authControllerRefreshToken = (\n refreshTokenDto: RefreshTokenDto,\n options?: SecondParameter<typeof customInstance<TokenResponseDto>>,\n ) => {\n return customInstance<TokenResponseDto>(\n {\n url: `/auth/refresh`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: refreshTokenDto,\n },\n options,\n );\n };\n /**\n * Revoke the provided refresh token to logout the current session.\n * @summary Logout (revoke refresh token)\n */\n const authControllerLogout = (\n refreshTokenDto: RefreshTokenDto,\n options?: SecondParameter<typeof customInstance<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\n {\n url: `/auth/logout`,\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n data: refreshTokenDto,\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<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\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<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\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<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\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<AuthSuccessResponseDto>>,\n ) => {\n return customInstance<AuthSuccessResponseDto>(\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 authControllerGetDiscordAuthorizeUrl,\n authControllerDiscordCallbackGet,\n authControllerDiscordCallback,\n authControllerSocialLogin,\n authControllerRefreshToken,\n authControllerLogout,\n authControllerRequestPasswordReset,\n authControllerConfirmPasswordReset,\n authControllerVerifyEmail,\n authControllerResendVerification,\n };\n};\nexport type AuthControllerLoginResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerLogin\"]>>\n>;\nexport type AuthControllerGetDiscordAuthorizeUrlResult = NonNullable<\n Awaited<\n ReturnType<\n ReturnType<typeof getAuth>[\"authControllerGetDiscordAuthorizeUrl\"]\n >\n >\n>;\nexport type AuthControllerDiscordCallbackGetResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerDiscordCallbackGet\"]>\n >\n>;\nexport type AuthControllerDiscordCallbackResult = NonNullable<\n Awaited<\n ReturnType<ReturnType<typeof getAuth>[\"authControllerDiscordCallback\"]>\n >\n>;\nexport type AuthControllerSocialLoginResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerSocialLogin\"]>>\n>;\nexport type AuthControllerRefreshTokenResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerRefreshToken\"]>>\n>;\nexport type AuthControllerLogoutResult = NonNullable<\n Awaited<ReturnType<ReturnType<typeof getAuth>[\"authControllerLogout\"]>>\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", "/**\n * Generated by orval v7.17.0 \uD83C\uDF7A\n * Do not edit manually.\n * Cilantro Smart API\n * API documentation for Cilantro Smart API - A Solana wallet management system\n * OpenAPI spec version: 1.0\n */\n\n/**\n * OAuth provider used for social login\n */\nexport type SocialLoginDtoProvider =\n (typeof SocialLoginDtoProvider)[keyof typeof SocialLoginDtoProvider];\n\n// eslint-disable-next-line @typescript-eslint/no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AE,KAAK,OAAO,KAAK,YAAY,CAAC;AAAA,EAC1C;AACA,QAAI,YAAO,SAAP,mBAAa,YAAW,QAAW;AACrC,YAAQ,EAAE,QAAQ,OAAO,KAAK,OAAO,CAAC;AAAA,EACxC;AACA,SAAO;AACT;",
6
6
  "names": ["auth", "axios"]
7
7
  }
package/dist/auth.d.ts CHANGED
@@ -6,7 +6,10 @@ import type { CommonLoginDto, SocialLoginDto } from './models';
6
6
  import type { AuthControllerLoginResult, AuthControllerSocialLoginResult, AuthControllerGetDiscordAuthorizeUrlResult, AuthControllerDiscordCallbackResult } from './api/auth/auth';
7
7
  export declare const login: (commonLoginDto: CommonLoginDto, options?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("./models").LoginResponseDto>;
8
8
  export declare const socialLogin: (socialLoginDto: SocialLoginDto, options?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("./models").LoginResponseDto>;
9
- /** Exchange Discord authorization code for Cilantro tokens (Step 3). Use discordCallbackAndSetAuth() to also set SDK auth. */
9
+ /**
10
+ * Legacy: exchange Discord code for tokens when your app receives the code (your URL in Discord redirects).
11
+ * Recommended flow is getDiscordAuthorizeUrl + setAuthFromFragment (backend-only callback).
12
+ */
10
13
  export declare const discordCallback: (discordCallbackDto: import("./models").DiscordCallbackDto, options?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("./models").LoginResponseDto>;
11
14
  type AuthRequestOptions = Parameters<ReturnType<typeof getAuth>['authControllerLogin']>[1];
12
15
  type SocialAuthRequestOptions = Parameters<ReturnType<typeof getAuth>['authControllerSocialLogin']>[1];
@@ -62,37 +65,67 @@ export declare function loginAndSetAuth(credentials: CommonLoginDto, options?: A
62
65
  export declare function socialLoginAndSetAuth(credentials: SocialLoginDto, options?: SocialAuthRequestOptions): Promise<AuthControllerSocialLoginResult>;
63
66
  /**
64
67
  * Discord OAuth2 login – Step 1: get the authorize URL and redirect the user.
65
- * Uses platform API key from config (setAuth/configure) if platformApiKey is not passed.
68
+ * Discord redirects only to the backend; the backend then redirects to your clientRedirectUri with
69
+ * tokens in the URL fragment (#access_token=...&refresh_token=...). Use setAuthFromFragment() on
70
+ * the page at clientRedirectUri to parse and set auth.
66
71
  *
67
- * @param params.redirectUri - Where Discord will redirect after auth (e.g. https://myapp.com/auth/discord/callback). Must match exactly in Step 3.
68
- * @param params.state - Optional CSRF token; store (e.g. sessionStorage) and verify on callback.
72
+ * @param params.clientRedirectUri - Where the user should land after login (e.g. https://myapp.com/dashboard or /auth/callback). Backend redirects here with tokens in the fragment.
69
73
  * @param params.platformApiKey - Platform API key (optional if already set via setAuth/configure).
70
74
  * @returns Promise with { authorizeUrl }. Redirect the user to authorizeUrl.
71
75
  *
72
76
  * @example
73
77
  * ```ts
74
- * const state = crypto.randomUUID();
75
- * sessionStorage.setItem('discord_oauth_state', state);
76
78
  * const { authorizeUrl } = await getDiscordAuthorizeUrl({
77
- * redirectUri: 'https://myapp.com/auth/discord/callback',
78
- * state,
79
+ * clientRedirectUri: 'https://myapp.com/dashboard',
79
80
  * });
80
81
  * window.location.href = authorizeUrl;
81
82
  * ```
82
83
  */
83
84
  export declare function getDiscordAuthorizeUrl(params: {
84
- redirectUri: string;
85
- state?: string;
85
+ clientRedirectUri: string;
86
86
  platformApiKey?: string;
87
87
  }): Promise<AuthControllerGetDiscordAuthorizeUrlResult>;
88
88
  /**
89
- * Discord OAuth2 login Step 3: exchange code for Cilantro tokens and set auth.
90
- * Call this on your callback page after verifying the `state` and reading `code` from the query.
89
+ * Parses the URL fragment from the Discord redirect (backend sends tokens in the fragment).
90
+ * Use on the page at client_redirect_uri after the user returns from Discord login.
91
+ *
92
+ * @param hash - Fragment string (e.g. window.location.hash.slice(1)). If omitted, returns null (for non-browser or no hash).
93
+ * @returns Parsed tokens or null if hash is empty/invalid.
94
+ */
95
+ export declare function getTokensFromFragment(hash?: string): {
96
+ accessToken: string;
97
+ refreshToken: string;
98
+ expiresIn?: string;
99
+ tokenType?: string;
100
+ } | null;
101
+ /**
102
+ * Discord OAuth2 – Step 2: read tokens from the URL fragment and set SDK auth.
103
+ * Call this on the page at client_redirect_uri (the URL you passed to getDiscordAuthorizeUrl).
104
+ *
105
+ * @param options.hash - Fragment to parse (defaults to window.location.hash if in browser).
106
+ * @param options.clearHash - If true (default), removes the fragment from the URL after reading.
107
+ * @returns The parsed tokens, or null if no valid tokens in fragment.
91
108
  *
92
- * @param params.code - The `code` query parameter from Discord's redirect.
93
- * @param params.redirectUri - Must match exactly the redirectUri used in Step 1.
94
- * @param params.platformApiKey - Optional if already set via setAuth/configure.
95
- * @returns Login result; also sets JWT and API key in SDK config for subsequent requests.
109
+ * @example
110
+ * ```ts
111
+ * // On your dashboard or /auth/callback page
112
+ * const tokens = setAuthFromFragment({ clearHash: true });
113
+ * if (tokens) redirectToApp();
114
+ * ```
115
+ */
116
+ export declare function setAuthFromFragment(options?: {
117
+ hash?: string;
118
+ clearHash?: boolean;
119
+ }): {
120
+ accessToken: string;
121
+ refreshToken: string;
122
+ expiresIn?: string;
123
+ tokenType?: string;
124
+ } | null;
125
+ /**
126
+ * Legacy: exchange Discord code for Cilantro tokens and set auth.
127
+ * Use only when your app receives the code from Discord (your URL in Discord redirects).
128
+ * Recommended flow is getDiscordAuthorizeUrl + setAuthFromFragment.
96
129
  */
97
130
  export declare function discordCallbackAndSetAuth(params: {
98
131
  code: string;
@@ -117,10 +150,16 @@ export type DiscordAuthorizeUrlResponse = {
117
150
  authorizeUrl: string;
118
151
  };
119
152
  export type GetDiscordAuthorizeUrlParams = {
120
- redirectUri: string;
121
- state?: string;
153
+ clientRedirectUri: string;
122
154
  platformApiKey?: string;
123
155
  };
156
+ /** Tokens parsed from the URL fragment after Discord redirect (Step 2). */
157
+ export type DiscordFragmentTokens = {
158
+ accessToken: string;
159
+ refreshToken: string;
160
+ expiresIn?: string;
161
+ tokenType?: string;
162
+ };
124
163
  export type DiscordCallbackAndSetAuthParams = {
125
164
  code: string;
126
165
  redirectUri: string;
@@ -1 +1 @@
1
- {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,CAAC;CAClC,CAAC"}
package/dist/auth.mjs CHANGED
@@ -87,6 +87,12 @@ var getAuth = () => {
87
87
  options
88
88
  );
89
89
  };
90
+ const authControllerDiscordCallbackGet = (params, options) => {
91
+ return customInstance(
92
+ { url: `/auth/discord/callback`, method: "GET", params },
93
+ options
94
+ );
95
+ };
90
96
  const authControllerDiscordCallback = (discordCallbackDto, options) => {
91
97
  return customInstance(
92
98
  {
@@ -178,6 +184,7 @@ var getAuth = () => {
178
184
  return {
179
185
  authControllerLogin,
180
186
  authControllerGetDiscordAuthorizeUrl,
187
+ authControllerDiscordCallbackGet,
181
188
  authControllerDiscordCallback,
182
189
  authControllerSocialLogin,
183
190
  authControllerRefreshToken,
@@ -231,13 +238,37 @@ async function getDiscordAuthorizeUrl(params) {
231
238
  "Platform API key required for Discord auth. Pass platformApiKey or set it via setAuth({ apiKey }) or configure({ apiKey })."
232
239
  );
233
240
  }
234
- return auth.authControllerGetDiscordAuthorizeUrl(
235
- {
236
- redirect_uri: params.redirectUri,
237
- platformApiKey
238
- },
239
- params.state !== void 0 ? { params: { state: params.state } } : void 0
240
- );
241
+ return auth.authControllerGetDiscordAuthorizeUrl({
242
+ client_redirect_uri: params.clientRedirectUri,
243
+ platformApiKey
244
+ });
245
+ }
246
+ function getTokensFromFragment(hash) {
247
+ const raw = hash ?? (typeof window !== "undefined" ? window.location.hash.slice(1) : void 0);
248
+ if (!raw)
249
+ return null;
250
+ const params = new URLSearchParams(raw);
251
+ const accessToken = params.get("access_token");
252
+ const refreshToken = params.get("refresh_token");
253
+ if (!accessToken || !refreshToken)
254
+ return null;
255
+ return {
256
+ accessToken,
257
+ refreshToken,
258
+ expiresIn: params.get("expires_in") ?? void 0,
259
+ tokenType: params.get("token_type") ?? void 0
260
+ };
261
+ }
262
+ function setAuthFromFragment(options) {
263
+ const hash = (options == null ? void 0 : options.hash) ?? (typeof window !== "undefined" ? window.location.hash.slice(1) : void 0);
264
+ const tokens = getTokensFromFragment(hash ?? void 0);
265
+ if (!tokens)
266
+ return null;
267
+ setAuth({ jwt: tokens.accessToken });
268
+ if ((options == null ? void 0 : options.clearHash) !== false && typeof window !== "undefined" && window.history.replaceState) {
269
+ window.history.replaceState(null, "", window.location.pathname + window.location.search);
270
+ }
271
+ return tokens;
241
272
  }
242
273
  async function discordCallbackAndSetAuth(params) {
243
274
  var _a, _b;
@@ -262,8 +293,10 @@ export {
262
293
  discordCallback,
263
294
  discordCallbackAndSetAuth,
264
295
  getDiscordAuthorizeUrl,
296
+ getTokensFromFragment,
265
297
  login,
266
298
  loginAndSetAuth,
299
+ setAuthFromFragment,
267
300
  socialLogin,
268
301
  socialLoginAndSetAuth
269
302
  };