mitra-interactions-sdk 1.0.60-beta.12 → 1.0.60-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +111 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -881,6 +881,13 @@ declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginRespo
|
|
|
881
881
|
declare function emailVerifyCodeMitra(options: EmailVerifyCodeOptions): Promise<LoginResponse>;
|
|
882
882
|
declare function emailResendCodeMitra(options: EmailResendCodeOptions): Promise<void>;
|
|
883
883
|
declare function refreshTokenSilently(authUrl: string, projectId: number | string): Promise<LoginResponse>;
|
|
884
|
+
/**
|
|
885
|
+
* Conclui o SSO em modo redirect (novo Mitra). O app chama no boot: se houver
|
|
886
|
+
* codeMitra/stateMitra no fragment, valida e troca o code por token. Retorna null
|
|
887
|
+
* quando não há retorno de SSO pendente. Exclusivo do novo mundo — o legacy trata
|
|
888
|
+
* o retorno de redirect pelo próprio template (tokenMitra no fragment).
|
|
889
|
+
*/
|
|
890
|
+
declare function completeSsoRedirectMitra(): Promise<LoginResponse | null>;
|
|
884
891
|
|
|
885
892
|
/**
|
|
886
893
|
* Mitra Interactions SDK - Password Reset (legacy backend)
|
|
@@ -1127,4 +1134,4 @@ declare function setProfileScreensMitra(options: SetProfileScreensOptions): Prom
|
|
|
1127
1134
|
*/
|
|
1128
1135
|
declare function setProfileServerFunctionsMitra(options: SetProfileServerFunctionsOptions): Promise<SetProfilePermissionResponse>;
|
|
1129
1136
|
|
|
1130
|
-
export { type AgentApiKeyTarget, type AgentAttachment, type AgentAttachmentType, type AgentAuthMeta, type AgentChat, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModelGroup, type AgentModelOption, type AgentProviderListItem, type AgentQueueChangeEvent, type AgentStatusChangeEvent, type AgentSubscriptionAccount, type AgentSubscriptionTarget, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialOptions, type AuthAgentCredentialResult, type AuthClaudeResult, type AuthCodexResult, type AuthMethod, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialOptions, type ConnectAgentSubscriptionResult, type ConnectableSubscriptionTarget, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAccessType, type CredentialAction, type CredentialTarget, type DeleteAgentChatResult, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type ManageAgentCredentialResult, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type QueuedItem, type RenameAgentChatResult, type ResetPasswordOptions, type SendOptions, type SendPasswordResetCodeOptions, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, type ValidatePasswordResetCodeOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
|
|
1137
|
+
export { type AgentApiKeyTarget, type AgentAttachment, type AgentAttachmentType, type AgentAuthMeta, type AgentChat, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModelGroup, type AgentModelOption, type AgentProviderListItem, type AgentQueueChangeEvent, type AgentStatusChangeEvent, type AgentSubscriptionAccount, type AgentSubscriptionTarget, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialOptions, type AuthAgentCredentialResult, type AuthClaudeResult, type AuthCodexResult, type AuthMethod, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialOptions, type ConnectAgentSubscriptionResult, type ConnectableSubscriptionTarget, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAccessType, type CredentialAction, type CredentialTarget, type DeleteAgentChatResult, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type ManageAgentCredentialResult, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type QueuedItem, type RenameAgentChatResult, type ResetPasswordOptions, type SendOptions, type SendPasswordResetCodeOptions, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, type ValidatePasswordResetCodeOptions, callIntegrationMitra, completeSsoRedirectMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
|
package/dist/index.d.ts
CHANGED
|
@@ -881,6 +881,13 @@ declare function emailLoginMitra(options: EmailLoginOptions): Promise<LoginRespo
|
|
|
881
881
|
declare function emailVerifyCodeMitra(options: EmailVerifyCodeOptions): Promise<LoginResponse>;
|
|
882
882
|
declare function emailResendCodeMitra(options: EmailResendCodeOptions): Promise<void>;
|
|
883
883
|
declare function refreshTokenSilently(authUrl: string, projectId: number | string): Promise<LoginResponse>;
|
|
884
|
+
/**
|
|
885
|
+
* Conclui o SSO em modo redirect (novo Mitra). O app chama no boot: se houver
|
|
886
|
+
* codeMitra/stateMitra no fragment, valida e troca o code por token. Retorna null
|
|
887
|
+
* quando não há retorno de SSO pendente. Exclusivo do novo mundo — o legacy trata
|
|
888
|
+
* o retorno de redirect pelo próprio template (tokenMitra no fragment).
|
|
889
|
+
*/
|
|
890
|
+
declare function completeSsoRedirectMitra(): Promise<LoginResponse | null>;
|
|
884
891
|
|
|
885
892
|
/**
|
|
886
893
|
* Mitra Interactions SDK - Password Reset (legacy backend)
|
|
@@ -1127,4 +1134,4 @@ declare function setProfileScreensMitra(options: SetProfileScreensOptions): Prom
|
|
|
1127
1134
|
*/
|
|
1128
1135
|
declare function setProfileServerFunctionsMitra(options: SetProfileServerFunctionsOptions): Promise<SetProfilePermissionResponse>;
|
|
1129
1136
|
|
|
1130
|
-
export { type AgentApiKeyTarget, type AgentAttachment, type AgentAttachmentType, type AgentAuthMeta, type AgentChat, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModelGroup, type AgentModelOption, type AgentProviderListItem, type AgentQueueChangeEvent, type AgentStatusChangeEvent, type AgentSubscriptionAccount, type AgentSubscriptionTarget, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialOptions, type AuthAgentCredentialResult, type AuthClaudeResult, type AuthCodexResult, type AuthMethod, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialOptions, type ConnectAgentSubscriptionResult, type ConnectableSubscriptionTarget, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAccessType, type CredentialAction, type CredentialTarget, type DeleteAgentChatResult, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type ManageAgentCredentialResult, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type QueuedItem, type RenameAgentChatResult, type ResetPasswordOptions, type SendOptions, type SendPasswordResetCodeOptions, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, type ValidatePasswordResetCodeOptions, callIntegrationMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
|
|
1137
|
+
export { type AgentApiKeyTarget, type AgentAttachment, type AgentAttachmentType, type AgentAuthMeta, type AgentChat, type AgentDeltaEvent, type AgentErrorEvent, type AgentMessage, type AgentModelGroup, type AgentModelOption, type AgentProviderListItem, type AgentQueueChangeEvent, type AgentStatusChangeEvent, type AgentSubscriptionAccount, type AgentSubscriptionTarget, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AuthAgentCredentialOptions, type AuthAgentCredentialResult, type AuthClaudeResult, type AuthCodexResult, type AuthMethod, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialOptions, type ConnectAgentSubscriptionResult, type ConnectableSubscriptionTarget, type CreateProfileOptions, type CreateProfileResponse, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAccessType, type CredentialAction, type CredentialTarget, type DeleteAgentChatResult, type DeleteProfileOptions, type DeleteProfileResponse, type DeleteRecordOptions, type EmailLoginOptions, type EmailResendCodeOptions, type EmailSignupOptions, type EmailVerifyCodeOptions, type ExecuteDataLoaderOptions, type ExecuteDataLoaderResponse, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetProfileDetailsOptions, type GetProfileDetailsResponse, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListProfilesOptions, type ListProfilesResponse, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type ManageAgentCredentialResult, type MitraConfig, type MitraInstance, type PatchRecordOptions, type ProfileTableRef, type QueuedItem, type RenameAgentChatResult, type ResetPasswordOptions, type SendOptions, type SendPasswordResetCodeOptions, type SetFileStatusOptions, type SetFileStatusResponse, type SetProfileActionsOptions, type SetProfileDmlTablesOptions, type SetProfilePermissionResponse, type SetProfileScreensOptions, type SetProfileSelectTablesOptions, type SetProfileServerFunctionsOptions, type SetProfileUsersOptions, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateProfileOptions, type UpdateProfileResponse, type UpdateRecordOptions, type UploadFileOptions, type UploadFileResponse, type ValidatePasswordResetCodeOptions, callIntegrationMitra, completeSsoRedirectMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteProfileMitra, deleteRecordMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
|
package/dist/index.js
CHANGED
|
@@ -309,18 +309,82 @@ function normalizeResponse(tokens, authUrl) {
|
|
|
309
309
|
var NOT_SUPPORTED_POPUP = 'Login via popup (loginWithEmailMitra/loginMitra com method "email" ou "mitra") ainda n\xE3o suportado no novo Mitra. Use emailLoginMitra({ email, password }).';
|
|
310
310
|
var NOT_SUPPORTED_VERIFY = "emailVerifyCodeMitra n\xE3o existe no novo Mitra (signup \xE9 direto, sem c\xF3digo de verifica\xE7\xE3o).";
|
|
311
311
|
var NOT_SUPPORTED_RESEND = "emailResendCodeMitra n\xE3o existe no novo Mitra.";
|
|
312
|
-
var NOT_SUPPORTED_REDIRECT = 'mode "redirect" ainda n\xE3o suportado no novo Mitra para SSO. Use mode "popup" (default).';
|
|
313
312
|
var OAUTH_RESULT_TYPE = "mitra-oauth-result";
|
|
314
313
|
var POPUP_W = 480;
|
|
315
314
|
var POPUP_H = 600;
|
|
316
315
|
var POPUP_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
317
|
-
var SSO_AUTH_PAGE_URL = "https://
|
|
316
|
+
var SSO_AUTH_PAGE_URL = "https://stg.mitralab.io/sdk-auth.html";
|
|
318
317
|
async function fetchSsoAuthPageUrl(_baseURL) {
|
|
319
318
|
return SSO_AUTH_PAGE_URL;
|
|
320
319
|
}
|
|
321
|
-
|
|
320
|
+
var SSO_ENABLED_PROVIDERS = ["google"];
|
|
321
|
+
function providerLabel(provider) {
|
|
322
|
+
return provider === "microsoft" ? "Microsoft" : provider === "google" ? "Google" : provider;
|
|
323
|
+
}
|
|
324
|
+
function assertProviderAvailable(provider) {
|
|
325
|
+
if (!SSO_ENABLED_PROVIDERS.includes(provider)) {
|
|
326
|
+
throw new Error(`Login com ${providerLabel(provider)} ainda n\xE3o dispon\xEDvel no novo Mitra.`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function stripToOriginPath(url) {
|
|
330
|
+
try {
|
|
331
|
+
const u = new URL(url);
|
|
332
|
+
return u.origin + u.pathname;
|
|
333
|
+
} catch (e) {
|
|
334
|
+
return url.split("?")[0].split("#")[0];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
async function exchangeSsoCode(authUrl, provider, code, redirectUri, projectId) {
|
|
338
|
+
const data = await postBffAuth(buildBffAuthEndpoint(authUrl, `/${provider}`), {
|
|
339
|
+
appId: String(projectId),
|
|
340
|
+
code,
|
|
341
|
+
redirectUri
|
|
342
|
+
});
|
|
343
|
+
const response = {
|
|
344
|
+
token: data.token,
|
|
345
|
+
// baseURL = authUrl (gateway); o BFF não devolve URLs de bootstrap.
|
|
346
|
+
baseURL: authUrl,
|
|
347
|
+
...data.refreshToken ? { refreshToken: data.refreshToken } : {}
|
|
348
|
+
};
|
|
349
|
+
autoConfigureFromLogin2(response, authUrl, projectId);
|
|
350
|
+
return response;
|
|
351
|
+
}
|
|
352
|
+
var SSO_REDIRECT_STORE_KEY = "mitra_sso_redirect";
|
|
353
|
+
function persistRedirectContext(ctx) {
|
|
354
|
+
try {
|
|
355
|
+
sessionStorage.setItem(SSO_REDIRECT_STORE_KEY, JSON.stringify(ctx));
|
|
356
|
+
} catch (e) {
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function readRedirectContext() {
|
|
360
|
+
try {
|
|
361
|
+
const raw = sessionStorage.getItem(SSO_REDIRECT_STORE_KEY);
|
|
362
|
+
return raw ? JSON.parse(raw) : null;
|
|
363
|
+
} catch (e) {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function clearRedirectContext() {
|
|
368
|
+
try {
|
|
369
|
+
sessionStorage.removeItem(SSO_REDIRECT_STORE_KEY);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function buildStartUrl(authPageUrl, provider, state, appId, apiUrl, returnTo) {
|
|
322
374
|
const sep = authPageUrl.includes("?") ? "&" : "?";
|
|
323
|
-
|
|
375
|
+
const query = {
|
|
376
|
+
provider,
|
|
377
|
+
state,
|
|
378
|
+
appId,
|
|
379
|
+
apiUrl,
|
|
380
|
+
// origin = origin desta SDK; a página trava o postMessage do result nela.
|
|
381
|
+
origin: window.location.origin,
|
|
382
|
+
// Contrato novo: a página NÃO troca mais o code — devolve o code cru (popup
|
|
383
|
+
// via postMessage, redirect via #codeMitra). A SDK troca no BFF /auth/{provider}.
|
|
384
|
+
responseType: "code"
|
|
385
|
+
};
|
|
386
|
+
if (returnTo) query.returnTo = returnTo;
|
|
387
|
+
return authPageUrl + sep + new URLSearchParams(query).toString();
|
|
324
388
|
}
|
|
325
389
|
function getOriginFromUrl2(url) {
|
|
326
390
|
try {
|
|
@@ -377,11 +441,11 @@ function openOAuthPopup(providerUrl, expectedOrigin, expectedState) {
|
|
|
377
441
|
reject(new Error(data.error || "Erro na autentica\xE7\xE3o OAuth."));
|
|
378
442
|
return;
|
|
379
443
|
}
|
|
380
|
-
if (!data.token) {
|
|
381
|
-
reject(new Error("Resposta OAuth sem token."));
|
|
444
|
+
if (!data.code && !data.token) {
|
|
445
|
+
reject(new Error("Resposta OAuth sem code nem token."));
|
|
382
446
|
return;
|
|
383
447
|
}
|
|
384
|
-
resolve({ token: data.token });
|
|
448
|
+
resolve({ code: data.code, token: data.token });
|
|
385
449
|
}
|
|
386
450
|
function cleanup() {
|
|
387
451
|
clearTimeout(timer);
|
|
@@ -394,13 +458,14 @@ function openOAuthPopup(providerUrl, expectedOrigin, expectedState) {
|
|
|
394
458
|
}
|
|
395
459
|
var _oauthInFlight = null;
|
|
396
460
|
async function loginWithProvider(provider, options) {
|
|
397
|
-
|
|
461
|
+
assertProviderAvailable(provider);
|
|
398
462
|
if (typeof window === "undefined") {
|
|
399
463
|
throw new Error("SSO s\xF3 funciona em ambiente browser.");
|
|
400
464
|
}
|
|
401
465
|
if ((options == null ? void 0 : options.mode) === "redirect") {
|
|
402
|
-
|
|
466
|
+
return startSsoRedirect(provider, options);
|
|
403
467
|
}
|
|
468
|
+
if (_oauthInFlight) return _oauthInFlight;
|
|
404
469
|
_oauthInFlight = (async () => {
|
|
405
470
|
try {
|
|
406
471
|
const { authUrl, projectId } = resolveLoginOptions2(options);
|
|
@@ -408,8 +473,12 @@ async function loginWithProvider(provider, options) {
|
|
|
408
473
|
const appId = String(projectId);
|
|
409
474
|
const authPageUrl = await fetchSsoAuthPageUrl(authUrl);
|
|
410
475
|
const pageOrigin = getOriginFromUrl2(authPageUrl);
|
|
476
|
+
const redirectUri = stripToOriginPath(authPageUrl);
|
|
411
477
|
const startUrl = buildStartUrl(authPageUrl, provider, state, appId, authUrl);
|
|
412
|
-
const { token } = await openOAuthPopup(startUrl, pageOrigin, state);
|
|
478
|
+
const { code, token } = await openOAuthPopup(startUrl, pageOrigin, state);
|
|
479
|
+
if (code) {
|
|
480
|
+
return await exchangeSsoCode(authUrl, provider, code, redirectUri, projectId);
|
|
481
|
+
}
|
|
413
482
|
const response = normalizeResponse(token, authUrl);
|
|
414
483
|
autoConfigureFromLogin2(response, authUrl, projectId);
|
|
415
484
|
return response;
|
|
@@ -419,6 +488,34 @@ async function loginWithProvider(provider, options) {
|
|
|
419
488
|
})();
|
|
420
489
|
return _oauthInFlight;
|
|
421
490
|
}
|
|
491
|
+
async function startSsoRedirect(provider, options) {
|
|
492
|
+
const { authUrl, projectId } = resolveLoginOptions2(options);
|
|
493
|
+
const state = generateState();
|
|
494
|
+
const appId = String(projectId);
|
|
495
|
+
const authPageUrl = await fetchSsoAuthPageUrl();
|
|
496
|
+
const redirectUri = stripToOriginPath(authPageUrl);
|
|
497
|
+
persistRedirectContext({ state, provider, authUrl, projectId: appId, redirectUri });
|
|
498
|
+
const startUrl = buildStartUrl(authPageUrl, provider, state, appId, authUrl, window.location.href);
|
|
499
|
+
window.location.assign(startUrl);
|
|
500
|
+
return new Promise(() => {
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
async function completeSsoRedirectMitra() {
|
|
504
|
+
var _a;
|
|
505
|
+
if (typeof window === "undefined") return null;
|
|
506
|
+
const hash = ((_a = window.location.hash) == null ? void 0 : _a.slice(1)) || "";
|
|
507
|
+
const params = new URLSearchParams(hash);
|
|
508
|
+
const code = params.get("codeMitra");
|
|
509
|
+
const state = params.get("stateMitra");
|
|
510
|
+
if (!code || !state) return null;
|
|
511
|
+
const ctx = readRedirectContext();
|
|
512
|
+
clearRedirectContext();
|
|
513
|
+
window.history.replaceState({}, "", window.location.pathname + window.location.search);
|
|
514
|
+
if (!ctx || ctx.state !== state) {
|
|
515
|
+
throw new Error("State inv\xE1lido no retorno do SSO (poss\xEDvel CSRF).");
|
|
516
|
+
}
|
|
517
|
+
return exchangeSsoCode(ctx.authUrl, ctx.provider, code, ctx.redirectUri, ctx.projectId);
|
|
518
|
+
}
|
|
422
519
|
async function loginWithEmailMitra2(_options) {
|
|
423
520
|
throw new Error(NOT_SUPPORTED_POPUP);
|
|
424
521
|
}
|
|
@@ -548,6 +645,9 @@ async function emailResendCodeMitra3(options) {
|
|
|
548
645
|
async function refreshTokenSilently3(authUrl, projectId) {
|
|
549
646
|
return isLegacyAuthUrl(authUrl) ? refreshTokenSilently(authUrl, projectId) : refreshTokenSilently2(authUrl);
|
|
550
647
|
}
|
|
648
|
+
async function completeSsoRedirectMitra2() {
|
|
649
|
+
return completeSsoRedirectMitra();
|
|
650
|
+
}
|
|
551
651
|
|
|
552
652
|
// src/password-reset.ts
|
|
553
653
|
var AUTH_API_BY_AUTH_URL = {
|
|
@@ -2355,6 +2455,7 @@ function resolveProjectId2(projectId) {
|
|
|
2355
2455
|
}
|
|
2356
2456
|
|
|
2357
2457
|
exports.callIntegrationMitra = callIntegrationMitra;
|
|
2458
|
+
exports.completeSsoRedirectMitra = completeSsoRedirectMitra2;
|
|
2358
2459
|
exports.configureSdkMitra = configureSdkMitra;
|
|
2359
2460
|
exports.createMitraInstance = createMitraInstance;
|
|
2360
2461
|
exports.createProfileMitra = createProfileMitra;
|