|
331 | 331 | if (text) { |
332 | 332 | w3dsInput = text.trim(); |
333 | 333 | actionError = null; |
334 | | - addLog("info", "Decoded QR", text.slice(0, 50) + (text.length > 50 ? "…" : "")); |
| 334 | + addLog( |
| 335 | + "info", |
| 336 | + "Decoded QR", |
| 337 | + text.slice(0, 50) + (text.length > 50 ? "…" : ""), |
| 338 | + ); |
335 | 339 | } else { |
336 | 340 | qrDecodeError = "No QR code found in image."; |
337 | 341 | } |
|
354 | 358 | } |
355 | 359 |
|
356 | 360 | function handlePaste(e: ClipboardEvent) { |
357 | | - const item = Array.from(e.clipboardData?.items ?? []).find( |
358 | | - (it) => it.type.startsWith("image/"), |
| 361 | + const item = Array.from(e.clipboardData?.items ?? []).find((it) => |
| 362 | + it.type.startsWith("image/"), |
359 | 363 | ); |
360 | 364 | const file = item?.getAsFile(); |
361 | 365 | if (file) { |
|
428 | 432 | } else { |
429 | 433 | const sessionId = url.searchParams.get("session") ?? ""; |
430 | 434 | const redirectUri = url.searchParams.get("redirect_uri") ?? ""; |
| 435 | + const dataParam = url.searchParams.get("data") ?? ""; |
431 | 436 | if (!sessionId || !redirectUri) { |
432 | 437 | actionError = "w3ds://sign needs session and redirect_uri."; |
433 | 438 | return; |
434 | 439 | } |
| 440 | + // Decode base64 data if present, otherwise fallback to sessionId |
| 441 | + let messageToSign = sessionId; |
| 442 | + if (dataParam) { |
| 443 | + try { |
| 444 | + messageToSign = atob(dataParam); |
| 445 | + } catch { |
| 446 | + messageToSign = dataParam; |
| 447 | + } |
| 448 | + } |
435 | 449 | const signature = await signPayload({ |
436 | 450 | cryptoAdapter: adapter, |
437 | 451 | keyId: selectedIdentity.keyId, |
438 | 452 | context: "onboarding", |
439 | | - payload: sessionId, |
| 453 | + payload: messageToSign, |
440 | 454 | }); |
441 | 455 | const body = { |
442 | 456 | sessionId, |
443 | 457 | signature, |
444 | 458 | w3id: selectedIdentity.w3id, |
445 | | - message: sessionId, |
| 459 | + message: messageToSign, |
446 | 460 | }; |
447 | 461 | const res = await fetch(redirectUri, { |
448 | 462 | method: "POST", |
|
578 | 592 | <p> |
579 | 593 | Paste a <code>w3ds://auth</code> or |
580 | 594 | <code>w3ds://sign</code> URI (or HTTP URL with session/redirect_uri). |
581 | | - You can also upload or paste an image of a QR code to decode the request. |
| 595 | + You can also upload or paste an image of a QR code to decode |
| 596 | + the request. |
582 | 597 | </p> |
583 | 598 | <div class="w3ds-qr-actions"> |
584 | 599 | <input |
|
0 commit comments