@thru/wallet 0.2.29 → 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;
package/dist/native.js CHANGED
@@ -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,
@@ -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,
@@ -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)