@mitralab.io/platform-sdk 1.8.6 → 1.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -0
- package/README.md +42 -4
- package/dist/index.cjs +521 -33
- package/dist/index.d.cts +89 -6
- package/dist/index.d.ts +89 -6
- package/dist/index.js +522 -33
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, AgentCredentialOptions, CredentialStatus, AgentModel as AgentModel$1, AgentReadyProvider, CredentialUsage, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
|
|
2
|
-
export { AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, AgentCredentialOptions, AgentCredentialScope, AgentProviderUsage, AgentQueueItem, AgentReadyProvider, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AgentTurnUsage, AgentTurnUsageRequest, AuthenticationResult, CredentialStatus, CredentialUsage, CredentialUsageWindow, 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';
|
|
1
|
+
import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, AgentCredentialOptions, CredentialStatus, AgentModel as AgentModel$1, AgentReadyProvider, CredentialUsage, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, PublicFunctionsModule, AgentTasksWithSessions, AiProvidersModule } from '@mitralab.io/sdk-core';
|
|
2
|
+
export { AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, AgentCredentialOptions, AgentCredentialScope, AgentProviderUsage, AgentQueueItem, AgentReadyProvider, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AgentTurnUsage, AgentTurnUsageRequest, AiProviders, AiProvidersModule, AuthenticationResult, CredentialStatus, CredentialUsage, CredentialUsageWindow, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, IncludedAiQuota, IncludedAiQuotaWindow, ListTemplateConfigsOptions, ManagedAiProfile, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, OpencodeAiProvider, 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';
|
|
@@ -233,6 +233,19 @@ type MicrosoftSignInOptions = AuthPageSignInOptions;
|
|
|
233
233
|
type EmailSignInOptions = AuthPageSignInOptions;
|
|
234
234
|
/** Language of the message IAM sends. The platform writes it in these two. */
|
|
235
235
|
type EmailCodeLanguage = 'pt-BR' | 'en';
|
|
236
|
+
/** Options for `auth.signInWithIdentityConnection()`. */
|
|
237
|
+
interface IdentityConnectionSignInOptions {
|
|
238
|
+
/** Navigates the current page to the identity provider of the connection. */
|
|
239
|
+
mode: 'redirect';
|
|
240
|
+
/**
|
|
241
|
+
* Where the identity provider sends the browser back. Defaults to the
|
|
242
|
+
* current origin and path, without query or fragment. It has to be one of
|
|
243
|
+
* the redirect URIs the connection client accepts.
|
|
244
|
+
*/
|
|
245
|
+
redirectUri?: string;
|
|
246
|
+
/** Defaults to the browser language, and to `pt-BR` when that is neither. */
|
|
247
|
+
language?: EmailCodeLanguage;
|
|
248
|
+
}
|
|
236
249
|
/** The address to send a one-time code to, and the language to write it in. */
|
|
237
250
|
interface EmailCodeRequest {
|
|
238
251
|
email: string;
|
|
@@ -352,7 +365,8 @@ interface AuthModuleOptions {
|
|
|
352
365
|
* Handles Google and Microsoft SSO, email and password sign-in, trusted session adoption, sign-out,
|
|
353
366
|
* and automatic token refresh.
|
|
354
367
|
* Auth state is persisted to localStorage with key `mitra_auth_{appId}`
|
|
355
|
-
* and restored on page reload
|
|
368
|
+
* and restored on page reload; a session from an identity connection is kept
|
|
369
|
+
* in sessionStorage under the same key instead, so it lives in its tab only.
|
|
356
370
|
*
|
|
357
371
|
* @example
|
|
358
372
|
* ```typescript
|
|
@@ -380,7 +394,11 @@ declare class AuthModule {
|
|
|
380
394
|
private readonly passwordAuth;
|
|
381
395
|
private readonly emailCode;
|
|
382
396
|
private readonly passwordForm;
|
|
397
|
+
private readonly identityConnection;
|
|
398
|
+
private readonly identityConnectionRedirect;
|
|
383
399
|
private brand;
|
|
400
|
+
/** Session kept in sessionStorage: an identity connection opens one app per host account, and sharing localStorage would hand one account's session to another tab's reload. */
|
|
401
|
+
private sessionScoped;
|
|
384
402
|
constructor(appId: string, iamBaseUrl: string, options?: AuthModuleOptions);
|
|
385
403
|
/** The currently authenticated user, or null. */
|
|
386
404
|
get currentUser(): User | null;
|
|
@@ -603,6 +621,58 @@ declare class AuthModule {
|
|
|
603
621
|
* `MAGIC_LINK_INVALID` when the link belongs here but cannot be used.
|
|
604
622
|
*/
|
|
605
623
|
completeEmailSignInRedirect(): Promise<User | null>;
|
|
624
|
+
/**
|
|
625
|
+
* Completes a sign-in made through an identity connection, such as Sankhya
|
|
626
|
+
* Pass, from the single-use code the platform bridge page leaves in the
|
|
627
|
+
* fragment (`#codeMitra`, `#stateMitra=connection.*`, `#connectionMitra`).
|
|
628
|
+
*
|
|
629
|
+
* `init()` already calls it, so an application only calls it itself when it
|
|
630
|
+
* does not call `init()`. The session is kept in `sessionStorage`, not
|
|
631
|
+
* `localStorage`, and so lives only as long as its tab.
|
|
632
|
+
*
|
|
633
|
+
* @returns The authenticated user, or `null` when the URL carries no
|
|
634
|
+
* identity connection result. A fragment of another sign-in method is left
|
|
635
|
+
* untouched.
|
|
636
|
+
* @throws When the fragment belongs to an identity connection but cannot be
|
|
637
|
+
* redeemed: outside an iframe, with an invalid connection, an error from the
|
|
638
|
+
* bridge, no code, or a code IAM refuses. The fragment is removed first, and
|
|
639
|
+
* the session this page held is dropped from memory, though not from storage.
|
|
640
|
+
*/
|
|
641
|
+
completeIdentityConnectionSignInRedirect(): Promise<User | null>;
|
|
642
|
+
/**
|
|
643
|
+
* Signs in through an identity connection, such as Sankhya Pass, outside a
|
|
644
|
+
* host system iframe: the page is sent to the connection's identity provider
|
|
645
|
+
* (Authorization Code with PKCE) and comes back to `redirectUri` with a code.
|
|
646
|
+
* `init()` finishes it on the way back, or {@link completeIdentityConnectionRedirect}
|
|
647
|
+
* when the app does not call `init()`. The returned promise never resolves,
|
|
648
|
+
* because the page navigates away.
|
|
649
|
+
*
|
|
650
|
+
* @param slug - The connection, such as `sankhya-pass`.
|
|
651
|
+
* @throws When the slug is invalid, the connection is unknown or does not
|
|
652
|
+
* support redirect sign-in, or `sessionStorage` is unavailable.
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* ```typescript
|
|
656
|
+
* await mitra.auth.signInWithIdentityConnection('sankhya-pass', { mode: 'redirect' });
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
signInWithIdentityConnection(slug: string, options: IdentityConnectionSignInOptions): Promise<User>;
|
|
660
|
+
/**
|
|
661
|
+
* Completes a redirect started by {@link signInWithIdentityConnection} from
|
|
662
|
+
* the query the identity provider sent back (`?code=...&state=connection.*`).
|
|
663
|
+
*
|
|
664
|
+
* `init()` already calls it. The session is kept in `sessionStorage`, like
|
|
665
|
+
* the one from the host system iframe, and lives only as long as its tab.
|
|
666
|
+
*
|
|
667
|
+
* @returns The authenticated user, or `null` when the query carries no
|
|
668
|
+
* identity connection redirect. Another query is left untouched.
|
|
669
|
+
* @throws When the query belongs to this flow but no pending request in this
|
|
670
|
+
* tab matches its state, the provider reports an error, or the provider or
|
|
671
|
+
* IAM refuses the code. The query is removed first. When a sign-in was
|
|
672
|
+
* pending in this tab, the session this page held is dropped from memory,
|
|
673
|
+
* though not from storage; a callback with no pending sign-in leaves it.
|
|
674
|
+
*/
|
|
675
|
+
completeIdentityConnectionRedirect(): Promise<User | null>;
|
|
606
676
|
/**
|
|
607
677
|
* @deprecated Use signUpWithPassword(), which opens the Mitra auth page,
|
|
608
678
|
* startPasswordSignUp() in an app with the form mode on, signInWithEmail() or SSO.
|
|
@@ -876,7 +946,7 @@ declare class AuthModule {
|
|
|
876
946
|
*/
|
|
877
947
|
confirmPasswordReset(confirmation: PasswordResetConfirmation): Promise<void>;
|
|
878
948
|
/**
|
|
879
|
-
* Signs out the current user, clearing all auth state and
|
|
949
|
+
* Signs out the current user, clearing all auth state and the stored session.
|
|
880
950
|
*
|
|
881
951
|
* In an app whose accounts are its own, the session also ends on the server:
|
|
882
952
|
* the refresh token is sent to IAM's logout, so it can no longer be renewed.
|
|
@@ -953,6 +1023,9 @@ declare class AuthModule {
|
|
|
953
1023
|
*
|
|
954
1024
|
* Call `me()` afterwards to fetch the associated user data. {@link allTokens}
|
|
955
1025
|
* goes back to `null`, because it belongs to the session being replaced.
|
|
1026
|
+
* The token starts a session of its own, so it is kept in `localStorage`
|
|
1027
|
+
* even when the one it replaces lived in its tab, and that tab copy is
|
|
1028
|
+
* removed in any case.
|
|
956
1029
|
*
|
|
957
1030
|
* @param token - JWT access token.
|
|
958
1031
|
* @param saveToStorage - Whether to persist to localStorage (default: true).
|
|
@@ -1116,6 +1189,8 @@ declare class AuthModule {
|
|
|
1116
1189
|
private notifyListeners;
|
|
1117
1190
|
private saveToStorage;
|
|
1118
1191
|
private loadFromStorage;
|
|
1192
|
+
/** An unusable entry is removed from this storage only, so a broken tab session does not take the shared one with it. */
|
|
1193
|
+
private restoreFrom;
|
|
1119
1194
|
private removeFromStorage;
|
|
1120
1195
|
}
|
|
1121
1196
|
|
|
@@ -1290,7 +1365,14 @@ interface MitraClient {
|
|
|
1290
1365
|
* passwordLoginEnabled, and the brand `requestEmailCode()` sends with, from
|
|
1291
1366
|
* the public app info endpoint.
|
|
1292
1367
|
*
|
|
1293
|
-
*
|
|
1368
|
+
* In a browser it also finishes a sign-in through an identity connection
|
|
1369
|
+
* (see `auth.completeIdentityConnectionSignInRedirect()` and
|
|
1370
|
+
* `auth.completeIdentityConnectionRedirect()`) when the URL carries one, and
|
|
1371
|
+
* rejects when that sign-in fails. Without such a fragment or query it makes
|
|
1372
|
+
* no extra request.
|
|
1373
|
+
*
|
|
1374
|
+
* Safe to call multiple times. A call made while another runs waits for it;
|
|
1375
|
+
* once the app info is read, later calls are no-ops.
|
|
1294
1376
|
*
|
|
1295
1377
|
* @example
|
|
1296
1378
|
* ```typescript
|
|
@@ -1343,6 +1425,7 @@ interface MitraClient {
|
|
|
1343
1425
|
agentTasks: AgentTasksWithSessions;
|
|
1344
1426
|
/** Browser-safe credential status, model discovery, and provider auth flows. */
|
|
1345
1427
|
agentCredentials: AgentCredentialsModule;
|
|
1428
|
+
readonly aiProviders: AiProvidersModule;
|
|
1346
1429
|
/**
|
|
1347
1430
|
* Integration module for proxying HTTP requests to external APIs.
|
|
1348
1431
|
*
|
|
@@ -1609,4 +1692,4 @@ type StopServerFunctionExecutionResponse = LegacyTypes.StopServerFunctionExecuti
|
|
|
1609
1692
|
/** @deprecated Legacy compatibility type. */
|
|
1610
1693
|
type UpdateRecordOptions = LegacyTypes.UpdateRecordOptions;
|
|
1611
1694
|
|
|
1612
|
-
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 AllTokens, type AuthAgentCredentialResult, type AuthPageSignInOptions, type BackofficeToken, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type EmailCodeLanguage, type EmailCodeRequest, type EmailCodeRequestResult, type EmailCodeVerification, 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 MitraSpaceToken, type PasswordChange, type PasswordResetConfirmation, type PasswordResetOptions, type PasswordResetRequestResult, type PasswordSignUpCompletion, type PasswordSignUpRequest, type PasswordSignUpRequestResult, type PatchRecordOptions, type PlatformSessionTokens, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|
|
1695
|
+
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 AllTokens, type AuthAgentCredentialResult, type AuthPageSignInOptions, type BackofficeToken, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type EmailCodeLanguage, type EmailCodeRequest, type EmailCodeRequestResult, type EmailCodeVerification, 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 IdentityConnectionSignInOptions, 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 MitraSpaceToken, type PasswordChange, type PasswordResetConfirmation, type PasswordResetOptions, type PasswordResetRequestResult, type PasswordSignUpCompletion, type PasswordSignUpRequest, type PasswordSignUpRequestResult, type PatchRecordOptions, type PlatformSessionTokens, 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
|
-
import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, AgentCredentialOptions, CredentialStatus, AgentModel as AgentModel$1, AgentReadyProvider, CredentialUsage, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
|
|
2
|
-
export { AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, AgentCredentialOptions, AgentCredentialScope, AgentProviderUsage, AgentQueueItem, AgentReadyProvider, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AgentTurnUsage, AgentTurnUsageRequest, AuthenticationResult, CredentialStatus, CredentialUsage, CredentialUsageWindow, 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';
|
|
1
|
+
import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, AgentCredentialOptions, CredentialStatus, AgentModel as AgentModel$1, AgentReadyProvider, CredentialUsage, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, PublicFunctionsModule, AgentTasksWithSessions, AiProvidersModule } from '@mitralab.io/sdk-core';
|
|
2
|
+
export { AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, AgentCredentialOptions, AgentCredentialScope, AgentProviderUsage, AgentQueueItem, AgentReadyProvider, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AgentTurnUsage, AgentTurnUsageRequest, AiProviders, AiProvidersModule, AuthenticationResult, CredentialStatus, CredentialUsage, CredentialUsageWindow, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, IncludedAiQuota, IncludedAiQuotaWindow, ListTemplateConfigsOptions, ManagedAiProfile, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, OpencodeAiProvider, 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';
|
|
@@ -233,6 +233,19 @@ type MicrosoftSignInOptions = AuthPageSignInOptions;
|
|
|
233
233
|
type EmailSignInOptions = AuthPageSignInOptions;
|
|
234
234
|
/** Language of the message IAM sends. The platform writes it in these two. */
|
|
235
235
|
type EmailCodeLanguage = 'pt-BR' | 'en';
|
|
236
|
+
/** Options for `auth.signInWithIdentityConnection()`. */
|
|
237
|
+
interface IdentityConnectionSignInOptions {
|
|
238
|
+
/** Navigates the current page to the identity provider of the connection. */
|
|
239
|
+
mode: 'redirect';
|
|
240
|
+
/**
|
|
241
|
+
* Where the identity provider sends the browser back. Defaults to the
|
|
242
|
+
* current origin and path, without query or fragment. It has to be one of
|
|
243
|
+
* the redirect URIs the connection client accepts.
|
|
244
|
+
*/
|
|
245
|
+
redirectUri?: string;
|
|
246
|
+
/** Defaults to the browser language, and to `pt-BR` when that is neither. */
|
|
247
|
+
language?: EmailCodeLanguage;
|
|
248
|
+
}
|
|
236
249
|
/** The address to send a one-time code to, and the language to write it in. */
|
|
237
250
|
interface EmailCodeRequest {
|
|
238
251
|
email: string;
|
|
@@ -352,7 +365,8 @@ interface AuthModuleOptions {
|
|
|
352
365
|
* Handles Google and Microsoft SSO, email and password sign-in, trusted session adoption, sign-out,
|
|
353
366
|
* and automatic token refresh.
|
|
354
367
|
* Auth state is persisted to localStorage with key `mitra_auth_{appId}`
|
|
355
|
-
* and restored on page reload
|
|
368
|
+
* and restored on page reload; a session from an identity connection is kept
|
|
369
|
+
* in sessionStorage under the same key instead, so it lives in its tab only.
|
|
356
370
|
*
|
|
357
371
|
* @example
|
|
358
372
|
* ```typescript
|
|
@@ -380,7 +394,11 @@ declare class AuthModule {
|
|
|
380
394
|
private readonly passwordAuth;
|
|
381
395
|
private readonly emailCode;
|
|
382
396
|
private readonly passwordForm;
|
|
397
|
+
private readonly identityConnection;
|
|
398
|
+
private readonly identityConnectionRedirect;
|
|
383
399
|
private brand;
|
|
400
|
+
/** Session kept in sessionStorage: an identity connection opens one app per host account, and sharing localStorage would hand one account's session to another tab's reload. */
|
|
401
|
+
private sessionScoped;
|
|
384
402
|
constructor(appId: string, iamBaseUrl: string, options?: AuthModuleOptions);
|
|
385
403
|
/** The currently authenticated user, or null. */
|
|
386
404
|
get currentUser(): User | null;
|
|
@@ -603,6 +621,58 @@ declare class AuthModule {
|
|
|
603
621
|
* `MAGIC_LINK_INVALID` when the link belongs here but cannot be used.
|
|
604
622
|
*/
|
|
605
623
|
completeEmailSignInRedirect(): Promise<User | null>;
|
|
624
|
+
/**
|
|
625
|
+
* Completes a sign-in made through an identity connection, such as Sankhya
|
|
626
|
+
* Pass, from the single-use code the platform bridge page leaves in the
|
|
627
|
+
* fragment (`#codeMitra`, `#stateMitra=connection.*`, `#connectionMitra`).
|
|
628
|
+
*
|
|
629
|
+
* `init()` already calls it, so an application only calls it itself when it
|
|
630
|
+
* does not call `init()`. The session is kept in `sessionStorage`, not
|
|
631
|
+
* `localStorage`, and so lives only as long as its tab.
|
|
632
|
+
*
|
|
633
|
+
* @returns The authenticated user, or `null` when the URL carries no
|
|
634
|
+
* identity connection result. A fragment of another sign-in method is left
|
|
635
|
+
* untouched.
|
|
636
|
+
* @throws When the fragment belongs to an identity connection but cannot be
|
|
637
|
+
* redeemed: outside an iframe, with an invalid connection, an error from the
|
|
638
|
+
* bridge, no code, or a code IAM refuses. The fragment is removed first, and
|
|
639
|
+
* the session this page held is dropped from memory, though not from storage.
|
|
640
|
+
*/
|
|
641
|
+
completeIdentityConnectionSignInRedirect(): Promise<User | null>;
|
|
642
|
+
/**
|
|
643
|
+
* Signs in through an identity connection, such as Sankhya Pass, outside a
|
|
644
|
+
* host system iframe: the page is sent to the connection's identity provider
|
|
645
|
+
* (Authorization Code with PKCE) and comes back to `redirectUri` with a code.
|
|
646
|
+
* `init()` finishes it on the way back, or {@link completeIdentityConnectionRedirect}
|
|
647
|
+
* when the app does not call `init()`. The returned promise never resolves,
|
|
648
|
+
* because the page navigates away.
|
|
649
|
+
*
|
|
650
|
+
* @param slug - The connection, such as `sankhya-pass`.
|
|
651
|
+
* @throws When the slug is invalid, the connection is unknown or does not
|
|
652
|
+
* support redirect sign-in, or `sessionStorage` is unavailable.
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* ```typescript
|
|
656
|
+
* await mitra.auth.signInWithIdentityConnection('sankhya-pass', { mode: 'redirect' });
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
signInWithIdentityConnection(slug: string, options: IdentityConnectionSignInOptions): Promise<User>;
|
|
660
|
+
/**
|
|
661
|
+
* Completes a redirect started by {@link signInWithIdentityConnection} from
|
|
662
|
+
* the query the identity provider sent back (`?code=...&state=connection.*`).
|
|
663
|
+
*
|
|
664
|
+
* `init()` already calls it. The session is kept in `sessionStorage`, like
|
|
665
|
+
* the one from the host system iframe, and lives only as long as its tab.
|
|
666
|
+
*
|
|
667
|
+
* @returns The authenticated user, or `null` when the query carries no
|
|
668
|
+
* identity connection redirect. Another query is left untouched.
|
|
669
|
+
* @throws When the query belongs to this flow but no pending request in this
|
|
670
|
+
* tab matches its state, the provider reports an error, or the provider or
|
|
671
|
+
* IAM refuses the code. The query is removed first. When a sign-in was
|
|
672
|
+
* pending in this tab, the session this page held is dropped from memory,
|
|
673
|
+
* though not from storage; a callback with no pending sign-in leaves it.
|
|
674
|
+
*/
|
|
675
|
+
completeIdentityConnectionRedirect(): Promise<User | null>;
|
|
606
676
|
/**
|
|
607
677
|
* @deprecated Use signUpWithPassword(), which opens the Mitra auth page,
|
|
608
678
|
* startPasswordSignUp() in an app with the form mode on, signInWithEmail() or SSO.
|
|
@@ -876,7 +946,7 @@ declare class AuthModule {
|
|
|
876
946
|
*/
|
|
877
947
|
confirmPasswordReset(confirmation: PasswordResetConfirmation): Promise<void>;
|
|
878
948
|
/**
|
|
879
|
-
* Signs out the current user, clearing all auth state and
|
|
949
|
+
* Signs out the current user, clearing all auth state and the stored session.
|
|
880
950
|
*
|
|
881
951
|
* In an app whose accounts are its own, the session also ends on the server:
|
|
882
952
|
* the refresh token is sent to IAM's logout, so it can no longer be renewed.
|
|
@@ -953,6 +1023,9 @@ declare class AuthModule {
|
|
|
953
1023
|
*
|
|
954
1024
|
* Call `me()` afterwards to fetch the associated user data. {@link allTokens}
|
|
955
1025
|
* goes back to `null`, because it belongs to the session being replaced.
|
|
1026
|
+
* The token starts a session of its own, so it is kept in `localStorage`
|
|
1027
|
+
* even when the one it replaces lived in its tab, and that tab copy is
|
|
1028
|
+
* removed in any case.
|
|
956
1029
|
*
|
|
957
1030
|
* @param token - JWT access token.
|
|
958
1031
|
* @param saveToStorage - Whether to persist to localStorage (default: true).
|
|
@@ -1116,6 +1189,8 @@ declare class AuthModule {
|
|
|
1116
1189
|
private notifyListeners;
|
|
1117
1190
|
private saveToStorage;
|
|
1118
1191
|
private loadFromStorage;
|
|
1192
|
+
/** An unusable entry is removed from this storage only, so a broken tab session does not take the shared one with it. */
|
|
1193
|
+
private restoreFrom;
|
|
1119
1194
|
private removeFromStorage;
|
|
1120
1195
|
}
|
|
1121
1196
|
|
|
@@ -1290,7 +1365,14 @@ interface MitraClient {
|
|
|
1290
1365
|
* passwordLoginEnabled, and the brand `requestEmailCode()` sends with, from
|
|
1291
1366
|
* the public app info endpoint.
|
|
1292
1367
|
*
|
|
1293
|
-
*
|
|
1368
|
+
* In a browser it also finishes a sign-in through an identity connection
|
|
1369
|
+
* (see `auth.completeIdentityConnectionSignInRedirect()` and
|
|
1370
|
+
* `auth.completeIdentityConnectionRedirect()`) when the URL carries one, and
|
|
1371
|
+
* rejects when that sign-in fails. Without such a fragment or query it makes
|
|
1372
|
+
* no extra request.
|
|
1373
|
+
*
|
|
1374
|
+
* Safe to call multiple times. A call made while another runs waits for it;
|
|
1375
|
+
* once the app info is read, later calls are no-ops.
|
|
1294
1376
|
*
|
|
1295
1377
|
* @example
|
|
1296
1378
|
* ```typescript
|
|
@@ -1343,6 +1425,7 @@ interface MitraClient {
|
|
|
1343
1425
|
agentTasks: AgentTasksWithSessions;
|
|
1344
1426
|
/** Browser-safe credential status, model discovery, and provider auth flows. */
|
|
1345
1427
|
agentCredentials: AgentCredentialsModule;
|
|
1428
|
+
readonly aiProviders: AiProvidersModule;
|
|
1346
1429
|
/**
|
|
1347
1430
|
* Integration module for proxying HTTP requests to external APIs.
|
|
1348
1431
|
*
|
|
@@ -1609,4 +1692,4 @@ type StopServerFunctionExecutionResponse = LegacyTypes.StopServerFunctionExecuti
|
|
|
1609
1692
|
/** @deprecated Legacy compatibility type. */
|
|
1610
1693
|
type UpdateRecordOptions = LegacyTypes.UpdateRecordOptions;
|
|
1611
1694
|
|
|
1612
|
-
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 AllTokens, type AuthAgentCredentialResult, type AuthPageSignInOptions, type BackofficeToken, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type EmailCodeLanguage, type EmailCodeRequest, type EmailCodeRequestResult, type EmailCodeVerification, 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 MitraSpaceToken, type PasswordChange, type PasswordResetConfirmation, type PasswordResetOptions, type PasswordResetRequestResult, type PasswordSignUpCompletion, type PasswordSignUpRequest, type PasswordSignUpRequestResult, type PatchRecordOptions, type PlatformSessionTokens, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|
|
1695
|
+
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 AllTokens, type AuthAgentCredentialResult, type AuthPageSignInOptions, type BackofficeToken, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type EmailCodeLanguage, type EmailCodeRequest, type EmailCodeRequestResult, type EmailCodeVerification, 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 IdentityConnectionSignInOptions, 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 MitraSpaceToken, type PasswordChange, type PasswordResetConfirmation, type PasswordResetOptions, type PasswordResetRequestResult, type PasswordSignUpCompletion, type PasswordSignUpRequest, type PasswordSignUpRequestResult, type PatchRecordOptions, type PlatformSessionTokens, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|