@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.
package/dist/native.d.ts CHANGED
@@ -210,6 +210,7 @@ interface CreateAccountResult {
210
210
  vmError: string | null;
211
211
  userErrorCode: string | null;
212
212
  executionResult: string | null;
213
+ signingSession?: SigningSessionDescriptorPayload;
213
214
  }
214
215
  interface GetConnectionStateResult {
215
216
  isAuthorized: boolean;
@@ -248,6 +249,15 @@ interface ConnectRequestPayload {
248
249
  intent?: ConnectIntent;
249
250
  }
250
251
 
252
+ interface SigningSessionDescriptorPayload {
253
+ id: string;
254
+ walletAddress: string;
255
+ publicKey: string;
256
+ authIdx: number;
257
+ expiresAt: string;
258
+ createdAt: string;
259
+ }
260
+
251
261
  interface WebViewRefLike {
252
262
  injectJavaScript: (script: string) => void;
253
263
  }
@@ -333,6 +343,7 @@ interface ConnectOptions {
333
343
  interface CreateAccountOptions {
334
344
  accountName?: string;
335
345
  metadata?: ConnectMetadataInput;
346
+ createSigningSession?: Omit<ThruSigningSessionCreateOptions, "walletAddress" | "review">;
336
347
  }
337
348
  interface RestoreConnectionOptions {
338
349
  hydrate?: boolean;
@@ -370,6 +381,7 @@ declare class NativeSDK {
370
381
  private readonly iosWebViewMode;
371
382
  private readonly walletExperience;
372
383
  private readonly defaultMetadata?;
384
+ private readonly signingSessions?;
373
385
  constructor(config?: NativeSDKConfig);
374
386
  /** Hand the WebView ref to the underlying provider/bridge. */
375
387
  attachWebView(ref: WebViewRefLike): void;
@@ -379,7 +391,7 @@ declare class NativeSDK {
379
391
  onMessage: (event: WebViewMessageEventLike) => void;
380
392
  /** Build the URL to load inside the shell <iframe>. */
381
393
  getIframeSrc(): string;
382
- /** Wallet origin (e.g. https://wallet.thru.org). */
394
+ /** Wallet origin (e.g. https://app.tid.sh). */
383
395
  getWalletOrigin(): string;
384
396
  /** Bind host UI lifecycle handlers used by custom WebView hosts. */
385
397
  setUiHandlers(handlers: NativeSDKUiHandlers): void;
package/dist/native.js CHANGED
@@ -484,7 +484,7 @@ var NativeThruChain = class {
484
484
 
485
485
  // src/native/provider/WebViewBridge.ts
486
486
  var PRODUCTION_WALLET_ORIGINS = [
487
- "https://wallet.thru.org",
487
+ "https://app.tid.sh",
488
488
  "https://wallet.tid.sh"
489
489
  ];
490
490
  function isDevelopmentBuild() {
@@ -720,7 +720,7 @@ var WebViewBridge = class {
720
720
  };
721
721
 
722
722
  // src/native/provider/NativeProvider.ts
723
- var DEFAULT_WALLET_URL = "https://wallet.thru.org/embedded/native";
723
+ var DEFAULT_WALLET_URL = "https://app.tid.sh/embedded/native";
724
724
  var DEFAULT_ORIGIN = "thru-mobile://app";
725
725
  var TRANSPARENT_FOCUS_SETTLE_MS = 500;
726
726
  var NativeProvider = class {
@@ -780,7 +780,7 @@ var NativeProvider = class {
780
780
  getIframeSrc() {
781
781
  return this.bridge.getIframeSrc();
782
782
  }
783
- /** Wallet origin (e.g. https://wallet.thru.org). The shell template
783
+ /** Wallet origin (e.g. https://app.tid.sh). The shell template
784
784
  should substitute this for WALLET_ORIGIN_PLACEHOLDER. */
785
785
  getWalletOrigin() {
786
786
  return this.bridge.walletOrigin;
@@ -854,6 +854,11 @@ var NativeProvider = class {
854
854
  const payload = {};
855
855
  if (options?.accountName) payload.accountName = options.accountName;
856
856
  if (options?.metadata) payload.metadata = options.metadata;
857
+ if (options?.createSigningSession) {
858
+ payload.createSigningSession = {
859
+ expiresAt: String(resolveSessionExpirySeconds(options.createSigningSession))
860
+ };
861
+ }
857
862
  const response = await this.bridge.sendMessage({
858
863
  id: createRequestId(),
859
864
  type: POST_MESSAGE_REQUEST_TYPES.CREATE_ACCOUNT,
@@ -1042,8 +1047,8 @@ var NativeProvider = class {
1042
1047
  var DEFAULT_STORAGE_KEY = "thru.native-sdk.connection.v1";
1043
1048
  var SELECTED_ACCOUNT_STORAGE_KEY_SUFFIX = ".selected-account.v1";
1044
1049
  var SIGNING_SESSION_STORAGE_KEY_SUFFIX = ".signing-sessions.v1";
1045
- var DEFAULT_NATIVE_WALLET_URL = "https://wallet.thru.org/embedded/native";
1046
- var DEFAULT_TRANSPARENT_WALLET_URL = "https://wallet.thru.org/embedded/native/transparent";
1050
+ var DEFAULT_NATIVE_WALLET_URL = "https://app.tid.sh/embedded/native";
1051
+ var DEFAULT_TRANSPARENT_WALLET_URL = "https://app.tid.sh/embedded/native/transparent";
1047
1052
  var CHECKING_WALLET_AVAILABILITY = {
1048
1053
  status: "checking",
1049
1054
  isAuthorized: false,
@@ -1067,6 +1072,16 @@ function completeAppMetadata(metadata) {
1067
1072
  ...metadata.imageUrl ? { imageUrl: metadata.imageUrl } : {}
1068
1073
  };
1069
1074
  }
1075
+ function signingSessionDescriptorFromWire(session) {
1076
+ return {
1077
+ id: session.id,
1078
+ walletAddress: session.walletAddress,
1079
+ publicKey: session.publicKey,
1080
+ authIdx: session.authIdx,
1081
+ expiresAt: Number(BigInt(session.expiresAt)),
1082
+ createdAt: Number(BigInt(session.createdAt))
1083
+ };
1084
+ }
1070
1085
  var NativeSDK = class {
1071
1086
  constructor(config = {}) {
1072
1087
  this.eventListeners = /* @__PURE__ */ new Map();
@@ -1097,6 +1112,7 @@ var NativeSDK = class {
1097
1112
  storageKey: config.signingSessionStorageKey ?? `${this.storageKey}${SIGNING_SESSION_STORAGE_KEY_SUFFIX}`
1098
1113
  })
1099
1114
  ) : void 0;
1115
+ this.signingSessions = signingSessions;
1100
1116
  this.provider = new NativeProvider({
1101
1117
  walletUrl,
1102
1118
  origin: this.origin,
@@ -1119,7 +1135,7 @@ var NativeSDK = class {
1119
1135
  getIframeSrc() {
1120
1136
  return this.provider.getIframeSrc();
1121
1137
  }
1122
- /** Wallet origin (e.g. https://wallet.thru.org). */
1138
+ /** Wallet origin (e.g. https://app.tid.sh). */
1123
1139
  getWalletOrigin() {
1124
1140
  return this.provider.getWalletOrigin();
1125
1141
  }
@@ -1218,7 +1234,8 @@ var NativeSDK = class {
1218
1234
  const metadata = this.resolveMetadata(options.metadata);
1219
1235
  const result = await this.provider.createAccount({
1220
1236
  ...options.accountName ? { accountName: options.accountName } : {},
1221
- ...metadata ? { metadata } : {}
1237
+ ...metadata ? { metadata } : {},
1238
+ ...options.createSigningSession ? { createSigningSession: options.createSigningSession } : {}
1222
1239
  });
1223
1240
  const selectedAccount = result.selectedAccount ?? result.account;
1224
1241
  const activeResult = {
@@ -1237,6 +1254,14 @@ var NativeSDK = class {
1237
1254
  await this.persistSelectedAccountAddress(
1238
1255
  activeResult.selectedAccount.address
1239
1256
  );
1257
+ if (activeResult.signingSession) {
1258
+ if (!this.signingSessions) {
1259
+ throw new Error("NativeSDKStorage is required for signing sessions");
1260
+ }
1261
+ await this.signingSessions.saveReplacingWalletSessions(
1262
+ signingSessionDescriptorFromWire(activeResult.signingSession)
1263
+ );
1264
+ }
1240
1265
  await this.clearPersistedConnection();
1241
1266
  this.setWalletAvailability(
1242
1267
  walletAvailabilityFromConnectResult(completedResult)