mitra-interactions-sdk 1.0.65 → 1.0.67

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.mjs CHANGED
@@ -359,6 +359,28 @@ async function resetPasswordMitra(options) {
359
359
  });
360
360
  }
361
361
 
362
+ // src/sf-proof.ts
363
+ var SF_EXECUTION_TOKEN_ENV = "MITRA_SF_EXECUTION_TOKEN";
364
+ var SF_EXECUTION_TOKEN_HEADER = "X-SF-Execution-Token";
365
+ function defaultEnv() {
366
+ const proc = globalThis.process;
367
+ return proc == null ? void 0 : proc.env;
368
+ }
369
+ function defaultHasWindow() {
370
+ return typeof globalThis.window !== "undefined";
371
+ }
372
+ function readServerFunctionProof(env = defaultEnv(), hasWindow = defaultHasWindow()) {
373
+ if (hasWindow) return null;
374
+ const raw = env == null ? void 0 : env[SF_EXECUTION_TOKEN_ENV];
375
+ if (typeof raw !== "string") return null;
376
+ const token = raw.trim();
377
+ return token.length > 0 ? token : null;
378
+ }
379
+ function withServerFunctionProof(headers, proof = readServerFunctionProof()) {
380
+ if (!proof) return headers;
381
+ return { ...headers, [SF_EXECUTION_TOKEN_HEADER]: proof };
382
+ }
383
+
362
384
  // src/client.ts
363
385
  function getFetch2() {
364
386
  if (typeof globalThis.fetch === "function") {
@@ -373,7 +395,7 @@ function buildHeaders() {
373
395
  const config = getConfig();
374
396
  const headers = { "Content-Type": "application/json" };
375
397
  if (config.token) headers["Authorization"] = formatToken(config.token);
376
- return headers;
398
+ return withServerFunctionProof(headers);
377
399
  }
378
400
  function buildUrl(endpoint, params) {
379
401
  const config = getConfig();
@@ -481,7 +503,7 @@ var http = {
481
503
  if (config.token) headers["Authorization"] = formatToken(config.token);
482
504
  return fetchWithRefresh(buildUrl(endpoint), {
483
505
  method: "POST",
484
- headers,
506
+ headers: withServerFunctionProof(headers),
485
507
  body: formData
486
508
  });
487
509
  },
@@ -722,6 +744,13 @@ async function downloadFilePrivateMitra(options) {
722
744
  key: options.key
723
745
  });
724
746
  }
747
+ async function getFileLinkMitra(options) {
748
+ return http.get("/interactions/fileLink", {
749
+ projectId: resolveProjectId2(options.projectId),
750
+ key: options.key,
751
+ ...options.ttlSeconds !== void 0 ? { ttlSeconds: options.ttlSeconds } : {}
752
+ });
753
+ }
725
754
  async function deleteFileMitra(options) {
726
755
  return http.del("/interactions/deleteFile", {
727
756
  projectId: resolveProjectId2(options.projectId),
@@ -2067,6 +2096,15 @@ function createMitraInstance(initialConfig) {
2067
2096
  key: options.key
2068
2097
  });
2069
2098
  },
2099
+ async getFileLink(options) {
2100
+ return request("GET", "/interactions/fileLink", {
2101
+ params: {
2102
+ projectId: resolveProjectId4(options.projectId),
2103
+ key: options.key,
2104
+ ...options.ttlSeconds !== void 0 ? { ttlSeconds: options.ttlSeconds } : {}
2105
+ }
2106
+ });
2107
+ },
2070
2108
  async deleteFile(options) {
2071
2109
  return request("DELETE", "/interactions/deleteFile", {
2072
2110
  params: { projectId: resolveProjectId4(options.projectId), key: options.key }
@@ -2292,6 +2330,6 @@ function resolveProjectId2(projectId) {
2292
2330
  throw new Error("projectId \xE9 obrigat\xF3rio. Passe nas options ou configure via configureSdkMitra({ projectId }).");
2293
2331
  }
2294
2332
 
2295
- export { callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteFileMitra, deleteProfileMitra, deleteRecordMitra, downloadFilePrivateMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executeDbActionMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, openChatMitra, patchRecordMitra, refreshTokenSilently, resetPasswordMitra, resolveProjectId2 as resolveProjectId, runActionMitra, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePrivateMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
2333
+ export { SF_EXECUTION_TOKEN_ENV, SF_EXECUTION_TOKEN_HEADER, callIntegrationMitra, closeChatMitra, configureSdkMitra, createMitraInstance, createProfileMitra, createRecordMitra, createRecordsBatchMitra, deleteFileMitra, deleteProfileMitra, deleteRecordMitra, downloadFilePrivateMitra, emailLoginMitra, emailResendCodeMitra, emailSignupMitra, emailVerifyCodeMitra, executeDataLoaderMitra, executeDbActionMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getFileLinkMitra, getProfileDetailsMitra, getPublicServerFunctionExecutionMitra, getRecordMitra, getVariableMitra, listIntegrationsMitra, listProfilesMitra, listRecordsMitra, listVariablesMitra, loginMitra, loginWithEmailMitra, loginWithGoogleMitra, loginWithMicrosoftMitra, manageAgentChatMitra, manageAgentCredentialMitra, openChatMitra, patchRecordMitra, readServerFunctionProof, refreshTokenSilently, resetPasswordMitra, resolveProjectId2 as resolveProjectId, runActionMitra, sendPasswordResetCodeMitra, setFileStatusMitra, setProfileActionsMitra, setProfileDmlTablesMitra, setProfileScreensMitra, setProfileSelectTablesMitra, setProfileServerFunctionsMitra, setProfileUsersMitra, setVariableMitra, stopServerFunctionExecutionMitra, updateProfileMitra, updateRecordMitra, uploadFileLoadableMitra, uploadFilePrivateMitra, uploadFilePublicMitra, validatePasswordResetCodeMitra };
2296
2334
  //# sourceMappingURL=index.mjs.map
2297
2335
  //# sourceMappingURL=index.mjs.map