@thru/wallet 0.2.29 → 0.2.31
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/{BrowserSDK-CRQTOT8S.d.ts → BrowserSDK-CQd2uC--.d.ts} +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/native/react/transparent.js +26 -1
- package/dist/native/react/transparent.js.map +1 -1
- package/dist/native/react.js +26 -1
- package/dist/native/react.js.map +1 -1
- package/dist/native.d.ts +12 -0
- package/dist/native.js +26 -1
- package/dist/native.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.js.map +1 -1
- package/package.json +2 -2
- package/src/native/NativeSDK.test.ts +87 -0
- package/src/native/NativeSDK.ts +30 -0
- package/src/native/provider/NativeProvider.ts +8 -0
- package/src/protocol/postMessage.ts +4 -0
package/dist/native/react.js
CHANGED
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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)
|