@mitralab.io/platform-sdk 1.1.2 → 1.1.3
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/CHANGELOG.md +39 -0
- package/README.md +71 -3
- package/dist/index.cjs +209 -59
- package/dist/index.d.cts +62 -11
- package/dist/index.d.ts +62 -11
- package/dist/index.js +209 -59
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, CredentialStatus, AgentModel as AgentModel$1, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
|
|
2
|
-
export { AgentQueueItem, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AuthenticationResult, CredentialStatus, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, ListTemplateConfigsOptions, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, Page, PageOptions, ProxyInput, ProxyResult, PublicFunctionAsyncResult, PublicFunctionResult, PublicFunctionsModule, QueryResult, TemplateConfigPage } from '@mitralab.io/sdk-core';
|
|
2
|
+
export { AgentQueueItem, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AuthenticationResult, CredentialStatus, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, ListTemplateConfigsOptions, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, Page, PageOptions, ProxyInput, ProxyResult, PublicFunctionAsyncResult, PublicFunctionResult, PublicFunctionsModule, QueryResult, TemplateConfigPage } from '@mitralab.io/sdk-core';
|
|
3
3
|
import * as LegacyTypes from 'mitra-interactions-sdk';
|
|
4
4
|
import { exchangeSsoCodeMitra as exchangeSsoCodeMitra$1, loginMitra as loginMitra$1, loginWithGoogleMitra as loginWithGoogleMitra$1, loginWithMicrosoftMitra as loginWithMicrosoftMitra$1 } from 'mitra-interactions-sdk';
|
|
5
5
|
export { callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra } from 'mitra-interactions-sdk';
|
|
@@ -203,13 +203,20 @@ interface AuthSession {
|
|
|
203
203
|
accessToken: string;
|
|
204
204
|
refreshToken?: string | null;
|
|
205
205
|
}
|
|
206
|
-
/** Options for
|
|
207
|
-
interface
|
|
206
|
+
/** Options for a sign-in that runs through the brand auth page. */
|
|
207
|
+
interface AuthPageSignInOptions {
|
|
208
208
|
/** Opens a popup by default. Redirect mode navigates the current page. */
|
|
209
209
|
mode?: 'popup' | 'redirect';
|
|
210
210
|
}
|
|
211
|
+
/** Options for Google SSO. */
|
|
212
|
+
type GoogleSignInOptions = AuthPageSignInOptions;
|
|
211
213
|
/** Options for Microsoft SSO. Same handshake as Google, through the brand auth page. */
|
|
212
|
-
type MicrosoftSignInOptions =
|
|
214
|
+
type MicrosoftSignInOptions = AuthPageSignInOptions;
|
|
215
|
+
/**
|
|
216
|
+
* Options for email sign-in. Same handshake as SSO, through the brand auth page,
|
|
217
|
+
* which collects the address and the one-time code.
|
|
218
|
+
*/
|
|
219
|
+
type EmailSignInOptions = AuthPageSignInOptions;
|
|
213
220
|
/** Callback for auth state changes. Receives the user on login, null on logout. */
|
|
214
221
|
type AuthStateChangeCallback = (user: User | null) => void;
|
|
215
222
|
|
|
@@ -222,7 +229,8 @@ interface AuthModuleOptions {
|
|
|
222
229
|
/**
|
|
223
230
|
* Authentication module for managing user sessions.
|
|
224
231
|
*
|
|
225
|
-
* Handles Google SSO, trusted session adoption, sign-out,
|
|
232
|
+
* Handles Google and Microsoft SSO, email sign-in, trusted session adoption, sign-out,
|
|
233
|
+
* and automatic token refresh.
|
|
226
234
|
* Auth state is persisted to localStorage with key `mitra_auth_{appId}`
|
|
227
235
|
* and restored on page reload.
|
|
228
236
|
*
|
|
@@ -248,6 +256,7 @@ declare class AuthModule {
|
|
|
248
256
|
private readonly currentUserApi;
|
|
249
257
|
private readonly googleAuth;
|
|
250
258
|
private readonly microsoftAuth;
|
|
259
|
+
private readonly emailAuth;
|
|
251
260
|
constructor(appId: string, iamBaseUrl: string, options?: AuthModuleOptions);
|
|
252
261
|
/** The currently authenticated user, or null. */
|
|
253
262
|
get currentUser(): User | null;
|
|
@@ -255,7 +264,7 @@ declare class AuthModule {
|
|
|
255
264
|
get accessToken(): string | null;
|
|
256
265
|
/** Whether a user is currently authenticated (local check, not server-validated). */
|
|
257
266
|
get isAuthenticated(): boolean;
|
|
258
|
-
/** @deprecated Email/password authentication is not implemented by IAM. Use
|
|
267
|
+
/** @deprecated Email/password authentication is not implemented by IAM. Use signInWithEmail() or SSO. */
|
|
259
268
|
signIn(_credentials: SignInCredentials): Promise<User>;
|
|
260
269
|
/**
|
|
261
270
|
* Signs in with Google SSO.
|
|
@@ -316,8 +325,10 @@ declare class AuthModule {
|
|
|
316
325
|
*
|
|
317
326
|
* The method consumes and clears the fragment and stored CSRF context, sends
|
|
318
327
|
* the single-use code directly to IAM, persists both tokens, calls `auth.me()`,
|
|
319
|
-
* and notifies auth-state listeners. It returns `null` when the current URL
|
|
320
|
-
*
|
|
328
|
+
* and notifies auth-state listeners. It returns `null` when the current URL
|
|
329
|
+
* carries no redirect result, and also when it carries one this flow never
|
|
330
|
+
* started, so an application that offers several methods can call every
|
|
331
|
+
* completion at startup. Redirect errors must carry the same `stateMitra`
|
|
321
332
|
* stored at the start of the flow before their message is exposed or consumed.
|
|
322
333
|
*
|
|
323
334
|
* @returns The authenticated user, or `null` when no redirect result is present.
|
|
@@ -345,7 +356,46 @@ declare class AuthModule {
|
|
|
345
356
|
* URL is not a Microsoft SSO redirect.
|
|
346
357
|
*/
|
|
347
358
|
completeMicrosoftSignInRedirect(): Promise<User | null>;
|
|
348
|
-
/**
|
|
359
|
+
/**
|
|
360
|
+
* Signs in with a one-time code sent by email: the same auth-page handshake as
|
|
361
|
+
* SSO, where the platform page collects the address and the code, and IAM
|
|
362
|
+
* hands back a single-use exchange code redeemed at `/auth/magic-link/exchange`.
|
|
363
|
+
* Popup by default; redirect mode navigates away.
|
|
364
|
+
*
|
|
365
|
+
* The message also carries a link. Because that link opens a new tab, the
|
|
366
|
+
* pending request is kept in `localStorage` for 10 minutes - the one-time state
|
|
367
|
+
* and the auth page URL, never a token - so
|
|
368
|
+
* {@link completeEmailSignInRedirect} can finish the flow in that tab.
|
|
369
|
+
*
|
|
370
|
+
* @param options - Popup or redirect mode.
|
|
371
|
+
* @returns The authenticated and hydrated user in popup mode.
|
|
372
|
+
* @throws {MitraApiError} When IAM rejects the exchange code.
|
|
373
|
+
* @throws {Error} When the browser blocks or cancels the popup, the flow times
|
|
374
|
+
* out, or the response fails origin, source, state, or shape validation. A
|
|
375
|
+
* person who finishes through the link instead of the popup leaves this call
|
|
376
|
+
* to time out, which the application should treat as a cancelled popup.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const user = await mitra.auth.signInWithEmail();
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
signInWithEmail(options?: EmailSignInOptions): Promise<User>;
|
|
384
|
+
/**
|
|
385
|
+
* Completes an email sign-in from `#codeMitra` and `#stateMitra`, during
|
|
386
|
+
* application startup like {@link completeGoogleSignInRedirect}.
|
|
387
|
+
*
|
|
388
|
+
* It covers both ways the flow comes back, and they are the same check: a
|
|
389
|
+
* redirect in the tab that started it, and the tab the link in the message
|
|
390
|
+
* opened. Both carry the one-time state this SDK generated, which the second
|
|
391
|
+
* tab matches against the pending request kept in `localStorage`. A request
|
|
392
|
+
* older than 10 minutes is discarded instead of completed.
|
|
393
|
+
*
|
|
394
|
+
* @returns The authenticated user, or `null` when the URL carries no result or
|
|
395
|
+
* carries one that belongs to another sign-in method's flow.
|
|
396
|
+
*/
|
|
397
|
+
completeEmailSignInRedirect(): Promise<User | null>;
|
|
398
|
+
/** @deprecated Email/password registration is not implemented by IAM. Use signInWithEmail() or SSO. */
|
|
349
399
|
signUp(_data: SignUpData): Promise<User>;
|
|
350
400
|
/**
|
|
351
401
|
* Signs out the current user, clearing all auth state and localStorage.
|
|
@@ -708,7 +758,8 @@ interface MitraClient {
|
|
|
708
758
|
/**
|
|
709
759
|
* Authentication module for managing user sessions.
|
|
710
760
|
*
|
|
711
|
-
* Handles Google SSO, trusted preview sessions,
|
|
761
|
+
* Handles Google and Microsoft SSO, email sign-in, trusted preview sessions,
|
|
762
|
+
* and session lifecycle.
|
|
712
763
|
*
|
|
713
764
|
* @example
|
|
714
765
|
* ```typescript
|
|
@@ -996,4 +1047,4 @@ type StopServerFunctionExecutionResponse = LegacyTypes.StopServerFunctionExecuti
|
|
|
996
1047
|
/** @deprecated Legacy compatibility type. */
|
|
997
1048
|
type UpdateRecordOptions = LegacyTypes.UpdateRecordOptions;
|
|
998
1049
|
|
|
999
|
-
export { type AgentChat, type AgentCredentialProvider, type AgentCredentialStatus, type AgentCredentialsModule, type AgentDeltaEvent, type AgentDeviceProvider, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentOAuthProvider, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialResult, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GoogleSignInOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type MicrosoftSignInOptions, MitraApiError, type MitraClient, type MitraClientConfig, type MitraConfig, type MitraInstance, type PatchRecordOptions, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|
|
1050
|
+
export { type AgentChat, type AgentCredentialProvider, type AgentCredentialStatus, type AgentCredentialsModule, type AgentDeltaEvent, type AgentDeviceProvider, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentOAuthProvider, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialResult, type AuthPageSignInOptions, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type EmailSignInOptions, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GoogleSignInOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type MicrosoftSignInOptions, MitraApiError, type MitraClient, type MitraClientConfig, type MitraConfig, type MitraInstance, type PatchRecordOptions, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, CredentialStatus, AgentModel as AgentModel$1, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
|
|
2
|
-
export { AgentQueueItem, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AuthenticationResult, CredentialStatus, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, ListTemplateConfigsOptions, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, Page, PageOptions, ProxyInput, ProxyResult, PublicFunctionAsyncResult, PublicFunctionResult, PublicFunctionsModule, QueryResult, TemplateConfigPage } from '@mitralab.io/sdk-core';
|
|
2
|
+
export { AgentQueueItem, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AuthenticationResult, CredentialStatus, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, ListTemplateConfigsOptions, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, Page, PageOptions, ProxyInput, ProxyResult, PublicFunctionAsyncResult, PublicFunctionResult, PublicFunctionsModule, QueryResult, TemplateConfigPage } from '@mitralab.io/sdk-core';
|
|
3
3
|
import * as LegacyTypes from 'mitra-interactions-sdk';
|
|
4
4
|
import { exchangeSsoCodeMitra as exchangeSsoCodeMitra$1, loginMitra as loginMitra$1, loginWithGoogleMitra as loginWithGoogleMitra$1, loginWithMicrosoftMitra as loginWithMicrosoftMitra$1 } from 'mitra-interactions-sdk';
|
|
5
5
|
export { callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra } from 'mitra-interactions-sdk';
|
|
@@ -203,13 +203,20 @@ interface AuthSession {
|
|
|
203
203
|
accessToken: string;
|
|
204
204
|
refreshToken?: string | null;
|
|
205
205
|
}
|
|
206
|
-
/** Options for
|
|
207
|
-
interface
|
|
206
|
+
/** Options for a sign-in that runs through the brand auth page. */
|
|
207
|
+
interface AuthPageSignInOptions {
|
|
208
208
|
/** Opens a popup by default. Redirect mode navigates the current page. */
|
|
209
209
|
mode?: 'popup' | 'redirect';
|
|
210
210
|
}
|
|
211
|
+
/** Options for Google SSO. */
|
|
212
|
+
type GoogleSignInOptions = AuthPageSignInOptions;
|
|
211
213
|
/** Options for Microsoft SSO. Same handshake as Google, through the brand auth page. */
|
|
212
|
-
type MicrosoftSignInOptions =
|
|
214
|
+
type MicrosoftSignInOptions = AuthPageSignInOptions;
|
|
215
|
+
/**
|
|
216
|
+
* Options for email sign-in. Same handshake as SSO, through the brand auth page,
|
|
217
|
+
* which collects the address and the one-time code.
|
|
218
|
+
*/
|
|
219
|
+
type EmailSignInOptions = AuthPageSignInOptions;
|
|
213
220
|
/** Callback for auth state changes. Receives the user on login, null on logout. */
|
|
214
221
|
type AuthStateChangeCallback = (user: User | null) => void;
|
|
215
222
|
|
|
@@ -222,7 +229,8 @@ interface AuthModuleOptions {
|
|
|
222
229
|
/**
|
|
223
230
|
* Authentication module for managing user sessions.
|
|
224
231
|
*
|
|
225
|
-
* Handles Google SSO, trusted session adoption, sign-out,
|
|
232
|
+
* Handles Google and Microsoft SSO, email sign-in, trusted session adoption, sign-out,
|
|
233
|
+
* and automatic token refresh.
|
|
226
234
|
* Auth state is persisted to localStorage with key `mitra_auth_{appId}`
|
|
227
235
|
* and restored on page reload.
|
|
228
236
|
*
|
|
@@ -248,6 +256,7 @@ declare class AuthModule {
|
|
|
248
256
|
private readonly currentUserApi;
|
|
249
257
|
private readonly googleAuth;
|
|
250
258
|
private readonly microsoftAuth;
|
|
259
|
+
private readonly emailAuth;
|
|
251
260
|
constructor(appId: string, iamBaseUrl: string, options?: AuthModuleOptions);
|
|
252
261
|
/** The currently authenticated user, or null. */
|
|
253
262
|
get currentUser(): User | null;
|
|
@@ -255,7 +264,7 @@ declare class AuthModule {
|
|
|
255
264
|
get accessToken(): string | null;
|
|
256
265
|
/** Whether a user is currently authenticated (local check, not server-validated). */
|
|
257
266
|
get isAuthenticated(): boolean;
|
|
258
|
-
/** @deprecated Email/password authentication is not implemented by IAM. Use
|
|
267
|
+
/** @deprecated Email/password authentication is not implemented by IAM. Use signInWithEmail() or SSO. */
|
|
259
268
|
signIn(_credentials: SignInCredentials): Promise<User>;
|
|
260
269
|
/**
|
|
261
270
|
* Signs in with Google SSO.
|
|
@@ -316,8 +325,10 @@ declare class AuthModule {
|
|
|
316
325
|
*
|
|
317
326
|
* The method consumes and clears the fragment and stored CSRF context, sends
|
|
318
327
|
* the single-use code directly to IAM, persists both tokens, calls `auth.me()`,
|
|
319
|
-
* and notifies auth-state listeners. It returns `null` when the current URL
|
|
320
|
-
*
|
|
328
|
+
* and notifies auth-state listeners. It returns `null` when the current URL
|
|
329
|
+
* carries no redirect result, and also when it carries one this flow never
|
|
330
|
+
* started, so an application that offers several methods can call every
|
|
331
|
+
* completion at startup. Redirect errors must carry the same `stateMitra`
|
|
321
332
|
* stored at the start of the flow before their message is exposed or consumed.
|
|
322
333
|
*
|
|
323
334
|
* @returns The authenticated user, or `null` when no redirect result is present.
|
|
@@ -345,7 +356,46 @@ declare class AuthModule {
|
|
|
345
356
|
* URL is not a Microsoft SSO redirect.
|
|
346
357
|
*/
|
|
347
358
|
completeMicrosoftSignInRedirect(): Promise<User | null>;
|
|
348
|
-
/**
|
|
359
|
+
/**
|
|
360
|
+
* Signs in with a one-time code sent by email: the same auth-page handshake as
|
|
361
|
+
* SSO, where the platform page collects the address and the code, and IAM
|
|
362
|
+
* hands back a single-use exchange code redeemed at `/auth/magic-link/exchange`.
|
|
363
|
+
* Popup by default; redirect mode navigates away.
|
|
364
|
+
*
|
|
365
|
+
* The message also carries a link. Because that link opens a new tab, the
|
|
366
|
+
* pending request is kept in `localStorage` for 10 minutes - the one-time state
|
|
367
|
+
* and the auth page URL, never a token - so
|
|
368
|
+
* {@link completeEmailSignInRedirect} can finish the flow in that tab.
|
|
369
|
+
*
|
|
370
|
+
* @param options - Popup or redirect mode.
|
|
371
|
+
* @returns The authenticated and hydrated user in popup mode.
|
|
372
|
+
* @throws {MitraApiError} When IAM rejects the exchange code.
|
|
373
|
+
* @throws {Error} When the browser blocks or cancels the popup, the flow times
|
|
374
|
+
* out, or the response fails origin, source, state, or shape validation. A
|
|
375
|
+
* person who finishes through the link instead of the popup leaves this call
|
|
376
|
+
* to time out, which the application should treat as a cancelled popup.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const user = await mitra.auth.signInWithEmail();
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
signInWithEmail(options?: EmailSignInOptions): Promise<User>;
|
|
384
|
+
/**
|
|
385
|
+
* Completes an email sign-in from `#codeMitra` and `#stateMitra`, during
|
|
386
|
+
* application startup like {@link completeGoogleSignInRedirect}.
|
|
387
|
+
*
|
|
388
|
+
* It covers both ways the flow comes back, and they are the same check: a
|
|
389
|
+
* redirect in the tab that started it, and the tab the link in the message
|
|
390
|
+
* opened. Both carry the one-time state this SDK generated, which the second
|
|
391
|
+
* tab matches against the pending request kept in `localStorage`. A request
|
|
392
|
+
* older than 10 minutes is discarded instead of completed.
|
|
393
|
+
*
|
|
394
|
+
* @returns The authenticated user, or `null` when the URL carries no result or
|
|
395
|
+
* carries one that belongs to another sign-in method's flow.
|
|
396
|
+
*/
|
|
397
|
+
completeEmailSignInRedirect(): Promise<User | null>;
|
|
398
|
+
/** @deprecated Email/password registration is not implemented by IAM. Use signInWithEmail() or SSO. */
|
|
349
399
|
signUp(_data: SignUpData): Promise<User>;
|
|
350
400
|
/**
|
|
351
401
|
* Signs out the current user, clearing all auth state and localStorage.
|
|
@@ -708,7 +758,8 @@ interface MitraClient {
|
|
|
708
758
|
/**
|
|
709
759
|
* Authentication module for managing user sessions.
|
|
710
760
|
*
|
|
711
|
-
* Handles Google SSO, trusted preview sessions,
|
|
761
|
+
* Handles Google and Microsoft SSO, email sign-in, trusted preview sessions,
|
|
762
|
+
* and session lifecycle.
|
|
712
763
|
*
|
|
713
764
|
* @example
|
|
714
765
|
* ```typescript
|
|
@@ -996,4 +1047,4 @@ type StopServerFunctionExecutionResponse = LegacyTypes.StopServerFunctionExecuti
|
|
|
996
1047
|
/** @deprecated Legacy compatibility type. */
|
|
997
1048
|
type UpdateRecordOptions = LegacyTypes.UpdateRecordOptions;
|
|
998
1049
|
|
|
999
|
-
export { type AgentChat, type AgentCredentialProvider, type AgentCredentialStatus, type AgentCredentialsModule, type AgentDeltaEvent, type AgentDeviceProvider, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentOAuthProvider, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialResult, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GoogleSignInOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type MicrosoftSignInOptions, MitraApiError, type MitraClient, type MitraClientConfig, type MitraConfig, type MitraInstance, type PatchRecordOptions, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|
|
1050
|
+
export { type AgentChat, type AgentCredentialProvider, type AgentCredentialStatus, type AgentCredentialsModule, type AgentDeltaEvent, type AgentDeviceProvider, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentOAuthProvider, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialResult, type AuthPageSignInOptions, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type EmailSignInOptions, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GoogleSignInOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type MicrosoftSignInOptions, MitraApiError, type MitraClient, type MitraClientConfig, type MitraConfig, type MitraInstance, type PatchRecordOptions, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|