@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/{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
|
@@ -845,6 +845,11 @@ var NativeProvider = class {
|
|
|
845
845
|
const payload = {};
|
|
846
846
|
if (options?.accountName) payload.accountName = options.accountName;
|
|
847
847
|
if (options?.metadata) payload.metadata = options.metadata;
|
|
848
|
+
if (options?.createSigningSession) {
|
|
849
|
+
payload.createSigningSession = {
|
|
850
|
+
expiresAt: String(resolveSessionExpirySeconds(options.createSigningSession))
|
|
851
|
+
};
|
|
852
|
+
}
|
|
848
853
|
const response = await this.bridge.sendMessage({
|
|
849
854
|
id: createRequestId(),
|
|
850
855
|
type: POST_MESSAGE_REQUEST_TYPES.CREATE_ACCOUNT,
|
|
@@ -1058,6 +1063,16 @@ function completeAppMetadata(metadata) {
|
|
|
1058
1063
|
...metadata.imageUrl ? { imageUrl: metadata.imageUrl } : {}
|
|
1059
1064
|
};
|
|
1060
1065
|
}
|
|
1066
|
+
function signingSessionDescriptorFromWire(session) {
|
|
1067
|
+
return {
|
|
1068
|
+
id: session.id,
|
|
1069
|
+
walletAddress: session.walletAddress,
|
|
1070
|
+
publicKey: session.publicKey,
|
|
1071
|
+
authIdx: session.authIdx,
|
|
1072
|
+
expiresAt: Number(BigInt(session.expiresAt)),
|
|
1073
|
+
createdAt: Number(BigInt(session.createdAt))
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1061
1076
|
var NativeSDK = class {
|
|
1062
1077
|
constructor(config = {}) {
|
|
1063
1078
|
this.eventListeners = /* @__PURE__ */ new Map();
|
|
@@ -1088,6 +1103,7 @@ var NativeSDK = class {
|
|
|
1088
1103
|
storageKey: config.signingSessionStorageKey ?? `${this.storageKey}${SIGNING_SESSION_STORAGE_KEY_SUFFIX}`
|
|
1089
1104
|
})
|
|
1090
1105
|
) : void 0;
|
|
1106
|
+
this.signingSessions = signingSessions;
|
|
1091
1107
|
this.provider = new NativeProvider({
|
|
1092
1108
|
walletUrl,
|
|
1093
1109
|
origin: this.origin,
|
|
@@ -1209,7 +1225,8 @@ var NativeSDK = class {
|
|
|
1209
1225
|
const metadata = this.resolveMetadata(options.metadata);
|
|
1210
1226
|
const result = await this.provider.createAccount({
|
|
1211
1227
|
...options.accountName ? { accountName: options.accountName } : {},
|
|
1212
|
-
...metadata ? { metadata } : {}
|
|
1228
|
+
...metadata ? { metadata } : {},
|
|
1229
|
+
...options.createSigningSession ? { createSigningSession: options.createSigningSession } : {}
|
|
1213
1230
|
});
|
|
1214
1231
|
const selectedAccount = result.selectedAccount ?? result.account;
|
|
1215
1232
|
const activeResult = {
|
|
@@ -1228,6 +1245,14 @@ var NativeSDK = class {
|
|
|
1228
1245
|
await this.persistSelectedAccountAddress(
|
|
1229
1246
|
activeResult.selectedAccount.address
|
|
1230
1247
|
);
|
|
1248
|
+
if (activeResult.signingSession) {
|
|
1249
|
+
if (!this.signingSessions) {
|
|
1250
|
+
throw new Error("NativeSDKStorage is required for signing sessions");
|
|
1251
|
+
}
|
|
1252
|
+
await this.signingSessions.saveReplacingWalletSessions(
|
|
1253
|
+
signingSessionDescriptorFromWire(activeResult.signingSession)
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1231
1256
|
await this.clearPersistedConnection();
|
|
1232
1257
|
this.setWalletAvailability(
|
|
1233
1258
|
walletAvailabilityFromConnectResult(completedResult)
|