@entros/pulse-sdk 1.4.1 → 1.4.2

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/index.mjs CHANGED
@@ -1314,6 +1314,26 @@ async function buildEd25519ReceiptIx(receipt) {
1314
1314
 
1315
1315
  // src/submit/wallet.ts
1316
1316
  async function requestSasAttestation(wallet, walletAddress, relayerUrl, relayerApiKey, serverNonce) {
1317
+ if (!serverNonce) {
1318
+ sdkLog("[Entros SDK] Skipping SAS attestation: no server-issued nonce");
1319
+ return void 0;
1320
+ }
1321
+ if (!wallet?.signMessage) {
1322
+ sdkLog("[Entros SDK] Skipping SAS attestation: wallet does not support signMessage");
1323
+ return void 0;
1324
+ }
1325
+ let signature;
1326
+ let message;
1327
+ try {
1328
+ const timestamp = Math.floor(Date.now() / 1e3);
1329
+ message = `Entros-ATTEST:${walletAddress}:${timestamp}`;
1330
+ const messageBytes = new TextEncoder().encode(message);
1331
+ const sigBytes = await wallet.signMessage(messageBytes);
1332
+ signature = Array.from(sigBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
1333
+ } catch {
1334
+ sdkWarn("[Entros SDK] Wallet signMessage failed, skipping SAS attestation");
1335
+ return void 0;
1336
+ }
1317
1337
  try {
1318
1338
  const attestHeaders = {
1319
1339
  "Content-Type": "application/json"
@@ -1325,21 +1345,12 @@ async function requestSasAttestation(wallet, walletAddress, relayerUrl, relayerA
1325
1345
  const timer = setTimeout(() => controller.abort(), 15e3);
1326
1346
  const baseUrl = new URL(relayerUrl);
1327
1347
  const attestUrl = `${baseUrl.origin}/attest`;
1328
- const attestBody = { wallet_address: walletAddress };
1329
- if (serverNonce) attestBody.nonce = serverNonce;
1330
- if (wallet?.signMessage) {
1331
- try {
1332
- const timestamp = Math.floor(Date.now() / 1e3);
1333
- const attestMessage = `Entros-ATTEST:${walletAddress}:${timestamp}`;
1334
- const messageBytes = new TextEncoder().encode(attestMessage);
1335
- const sigBytes = await wallet.signMessage(messageBytes);
1336
- const sigHex = Array.from(sigBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
1337
- attestBody.signature = sigHex;
1338
- attestBody.message = attestMessage;
1339
- } catch {
1340
- sdkWarn("Wallet signMessage failed, skipping ownership proof");
1341
- }
1342
- }
1348
+ const attestBody = {
1349
+ wallet_address: walletAddress,
1350
+ nonce: serverNonce,
1351
+ signature,
1352
+ message
1353
+ };
1343
1354
  const attestRes = await fetch(attestUrl, {
1344
1355
  method: "POST",
1345
1356
  headers: attestHeaders,