@thru/wallet 0.2.28 → 0.2.30

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.
@@ -479,7 +479,7 @@ var NativeThruChain = class {
479
479
 
480
480
  // src/native/provider/WebViewBridge.ts
481
481
  var PRODUCTION_WALLET_ORIGINS = [
482
- "https://wallet.thru.org",
482
+ "https://app.tid.sh",
483
483
  "https://wallet.tid.sh"
484
484
  ];
485
485
  function isDevelopmentBuild() {
@@ -715,7 +715,7 @@ var WebViewBridge = class {
715
715
  };
716
716
 
717
717
  // src/native/provider/NativeProvider.ts
718
- var DEFAULT_WALLET_URL = "https://wallet.thru.org/embedded/native";
718
+ var DEFAULT_WALLET_URL = "https://app.tid.sh/embedded/native";
719
719
  var DEFAULT_ORIGIN = "thru-mobile://app";
720
720
  var TRANSPARENT_FOCUS_SETTLE_MS = 500;
721
721
  var NativeProvider = class {
@@ -775,7 +775,7 @@ var NativeProvider = class {
775
775
  getIframeSrc() {
776
776
  return this.bridge.getIframeSrc();
777
777
  }
778
- /** Wallet origin (e.g. https://wallet.thru.org). The shell template
778
+ /** Wallet origin (e.g. https://app.tid.sh). The shell template
779
779
  should substitute this for WALLET_ORIGIN_PLACEHOLDER. */
780
780
  getWalletOrigin() {
781
781
  return this.bridge.walletOrigin;
@@ -849,6 +849,11 @@ var NativeProvider = class {
849
849
  const payload = {};
850
850
  if (options?.accountName) payload.accountName = options.accountName;
851
851
  if (options?.metadata) payload.metadata = options.metadata;
852
+ if (options?.createSigningSession) {
853
+ payload.createSigningSession = {
854
+ expiresAt: String(resolveSessionExpirySeconds(options.createSigningSession))
855
+ };
856
+ }
852
857
  const response = await this.bridge.sendMessage({
853
858
  id: createRequestId(),
854
859
  type: POST_MESSAGE_REQUEST_TYPES.CREATE_ACCOUNT,
@@ -1037,8 +1042,8 @@ var NativeProvider = class {
1037
1042
  var DEFAULT_STORAGE_KEY = "thru.native-sdk.connection.v1";
1038
1043
  var SELECTED_ACCOUNT_STORAGE_KEY_SUFFIX = ".selected-account.v1";
1039
1044
  var SIGNING_SESSION_STORAGE_KEY_SUFFIX = ".signing-sessions.v1";
1040
- var DEFAULT_NATIVE_WALLET_URL = "https://wallet.thru.org/embedded/native";
1041
- var DEFAULT_TRANSPARENT_WALLET_URL = "https://wallet.thru.org/embedded/native/transparent";
1045
+ var DEFAULT_NATIVE_WALLET_URL = "https://app.tid.sh/embedded/native";
1046
+ var DEFAULT_TRANSPARENT_WALLET_URL = "https://app.tid.sh/embedded/native/transparent";
1042
1047
  var CHECKING_WALLET_AVAILABILITY = {
1043
1048
  status: "checking",
1044
1049
  isAuthorized: false,
@@ -1062,6 +1067,16 @@ function completeAppMetadata(metadata) {
1062
1067
  ...metadata.imageUrl ? { imageUrl: metadata.imageUrl } : {}
1063
1068
  };
1064
1069
  }
1070
+ function signingSessionDescriptorFromWire(session) {
1071
+ return {
1072
+ id: session.id,
1073
+ walletAddress: session.walletAddress,
1074
+ publicKey: session.publicKey,
1075
+ authIdx: session.authIdx,
1076
+ expiresAt: Number(BigInt(session.expiresAt)),
1077
+ createdAt: Number(BigInt(session.createdAt))
1078
+ };
1079
+ }
1065
1080
  var NativeSDK = class {
1066
1081
  constructor(config = {}) {
1067
1082
  this.eventListeners = /* @__PURE__ */ new Map();
@@ -1092,6 +1107,7 @@ var NativeSDK = class {
1092
1107
  storageKey: config.signingSessionStorageKey ?? `${this.storageKey}${SIGNING_SESSION_STORAGE_KEY_SUFFIX}`
1093
1108
  })
1094
1109
  ) : void 0;
1110
+ this.signingSessions = signingSessions;
1095
1111
  this.provider = new NativeProvider({
1096
1112
  walletUrl,
1097
1113
  origin: this.origin,
@@ -1114,7 +1130,7 @@ var NativeSDK = class {
1114
1130
  getIframeSrc() {
1115
1131
  return this.provider.getIframeSrc();
1116
1132
  }
1117
- /** Wallet origin (e.g. https://wallet.thru.org). */
1133
+ /** Wallet origin (e.g. https://app.tid.sh). */
1118
1134
  getWalletOrigin() {
1119
1135
  return this.provider.getWalletOrigin();
1120
1136
  }
@@ -1213,7 +1229,8 @@ var NativeSDK = class {
1213
1229
  const metadata = this.resolveMetadata(options.metadata);
1214
1230
  const result = await this.provider.createAccount({
1215
1231
  ...options.accountName ? { accountName: options.accountName } : {},
1216
- ...metadata ? { metadata } : {}
1232
+ ...metadata ? { metadata } : {},
1233
+ ...options.createSigningSession ? { createSigningSession: options.createSigningSession } : {}
1217
1234
  });
1218
1235
  const selectedAccount = result.selectedAccount ?? result.account;
1219
1236
  const activeResult = {
@@ -1232,6 +1249,14 @@ var NativeSDK = class {
1232
1249
  await this.persistSelectedAccountAddress(
1233
1250
  activeResult.selectedAccount.address
1234
1251
  );
1252
+ if (activeResult.signingSession) {
1253
+ if (!this.signingSessions) {
1254
+ throw new Error("NativeSDKStorage is required for signing sessions");
1255
+ }
1256
+ await this.signingSessions.saveReplacingWalletSessions(
1257
+ signingSessionDescriptorFromWire(activeResult.signingSession)
1258
+ );
1259
+ }
1235
1260
  await this.clearPersistedConnection();
1236
1261
  this.setWalletAvailability(
1237
1262
  walletAvailabilityFromConnectResult(completedResult)