pediatric-ai-scribe-v3/public/js/assistant/sharing.js
Daniel 40e7dd5206
All checks were successful
Forgejo Android APK / Root app tests (push) Successful in 31s
Forgejo Android APK / Build signed APK (push) Successful in 1m57s
fix: bind clinical image and export actions to their original account
2026-09-07 07:45:48 +02:00

24 lines
1.1 KiB
JavaScript

// Keep the original document boundary as well as its ticket across fallbacks.
export function captureSharingOwner() {
var boundary = window.AccountBoundary;
var owner = boundary && typeof boundary.capture === 'function' && typeof boundary.signal === 'function'
? { boundary: boundary, ticket: boundary.capture(), signal: boundary.signal() } : null;
assertSharingOwner(owner);
return owner;
}
export function validSharingOwner(owner) {
return !!(owner && owner.ticket && owner.boundary === window.AccountBoundary &&
owner.signal && !owner.signal.aborted && typeof owner.boundary.valid === 'function' && owner.boundary.valid(owner.ticket));
}
export function assertSharingOwner(owner) {
if (!validSharingOwner(owner)) {
throw owner && typeof owner.boundary.error === 'function' ? owner.boundary.error() : new DOMException('Account unavailable', 'AbortError');
}
}
export function sharingFilename(prefix, extension) {
// An already-admitted OS write can finish after freeze; never reuse B's path.
return prefix + '-' + window.crypto.randomUUID() + '.' + extension;
}