@atomm-developer/generator-sdk 1.0.12 → 1.0.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.
@@ -2626,16 +2626,18 @@ const OSS_BUCKET = "xtool-aimake-generator";
2626
2626
  const getBaseURL = (env) => {
2627
2627
  return BASE_URL_MAP[env] ?? BASE_URL_MAP.prod;
2628
2628
  };
2629
- const TOKEN_KEY_PREFIX = "__atomm_sdk_token__";
2629
+ const TOKEN_COOKIE_NAME = "utoken";
2630
+ const LEGACY_TOKEN_KEY_PREFIX = "__atomm_sdk_token__";
2630
2631
  const TOKEN_COOKIE_DOMAIN = ".atomm.com";
2631
2632
  const TOKEN_COOKIE_PATH = "/";
2632
2633
  const TOKEN_COOKIE_MAX_AGE_SECONDS = 15 * 24 * 60 * 60;
2633
- const getTokenKey = (appKey) => `${TOKEN_KEY_PREFIX}${appKey}`;
2634
2634
  const buildCookieBase = () => `Domain=${TOKEN_COOKIE_DOMAIN}; Path=${TOKEN_COOKIE_PATH}; SameSite=Lax`;
2635
+ const getLegacyTokenKey = (appKey) => `${LEGACY_TOKEN_KEY_PREFIX}${appKey}`;
2635
2636
  const setToken = (appKey, token) => {
2636
2637
  try {
2638
+ void appKey;
2637
2639
  document.cookie = [
2638
- `${getTokenKey(appKey)}=${encodeURIComponent(token)}`,
2640
+ `${TOKEN_COOKIE_NAME}=${encodeURIComponent(token)}`,
2639
2641
  buildCookieBase(),
2640
2642
  `Max-Age=${TOKEN_COOKIE_MAX_AGE_SECONDS}`
2641
2643
  ].join("; ");
@@ -2644,10 +2646,17 @@ const setToken = (appKey, token) => {
2644
2646
  };
2645
2647
  const getToken = (appKey) => {
2646
2648
  try {
2647
- void appKey;
2648
2649
  const cookies2 = document.cookie.split(";").map((part) => part.trim()).filter(Boolean);
2649
- const utokenEntry = cookies2.find((part) => part.startsWith("utoken="));
2650
- return utokenEntry ? decodeURIComponent(utokenEntry.slice("utoken=".length)) : "";
2650
+ const utokenEntry = cookies2.find((part) => part.startsWith(`${TOKEN_COOKIE_NAME}=`));
2651
+ if (utokenEntry) {
2652
+ return decodeURIComponent(utokenEntry.slice(`${TOKEN_COOKIE_NAME}=`.length));
2653
+ }
2654
+ const legacyToken = localStorage.getItem(getLegacyTokenKey(appKey)) || "";
2655
+ if (legacyToken) {
2656
+ setToken(appKey, legacyToken);
2657
+ return legacyToken;
2658
+ }
2659
+ return "";
2651
2660
  } catch {
2652
2661
  return "";
2653
2662
  }
@@ -2655,11 +2664,12 @@ const getToken = (appKey) => {
2655
2664
  const clearToken = (appKey) => {
2656
2665
  try {
2657
2666
  document.cookie = [
2658
- `${getTokenKey(appKey)}=`,
2667
+ `${TOKEN_COOKIE_NAME}=`,
2659
2668
  buildCookieBase(),
2660
2669
  "Expires=Thu, 01 Jan 1970 00:00:00 GMT",
2661
2670
  "Max-Age=0"
2662
2671
  ].join("; ");
2672
+ localStorage.removeItem(getLegacyTokenKey(appKey));
2663
2673
  } catch {
2664
2674
  }
2665
2675
  };
@@ -12324,7 +12334,7 @@ class HttpProtocol extends SerdeContext {
12324
12334
  });
12325
12335
  }
12326
12336
  async loadEventStreamCapability() {
12327
- const { EventStreamSerde } = await import("./index-C-L7AXBe.js");
12337
+ const { EventStreamSerde } = await import("./index-DXHQzHQx.js");
12328
12338
  return new EventStreamSerde({
12329
12339
  marshaller: this.getEventStreamMarshaller(),
12330
12340
  serializer: this.serializer,
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { t as toUtf8, f as fromUtf8 } from "./index-Bqy069_f.js";
4
+ import { t as toUtf8, f as fromUtf8 } from "./index-D5TE5seZ.js";
5
5
  class EventStreamSerde {
6
6
  constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
7
7
  __publicField(this, "marshaller");
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { G, S, T, w } from "./index-Bqy069_f.js";
1
+ import { G, S, T, w } from "./index-D5TE5seZ.js";
2
2
  export {
3
3
  G as GeneratorSDK,
4
4
  S as SdkError,