@checktiv/sdk-web 1.9.0 → 1.10.0

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.
Files changed (51) hide show
  1. package/dist/agents/manifest.json +12 -0
  2. package/dist/api-EY_fOZm-.d.ts +578 -0
  3. package/dist/capture-ui.d.ts +4 -4
  4. package/dist/capture-ui.js +4 -4
  5. package/dist/capture.d.ts +3 -3
  6. package/dist/capture.js +2 -2
  7. package/dist/challenge.js +1 -1
  8. package/dist/chunk-2SPZA3CQ.js +3 -0
  9. package/dist/chunk-4HIQN4KL.js +3 -0
  10. package/dist/chunk-C7GRMEYT.js +3 -0
  11. package/dist/{chunk-MCYAWMYQ.js → chunk-KYV5BPCD.js} +2 -2
  12. package/dist/chunk-LRKS6JEP.js +9 -0
  13. package/dist/chunk-SU6RE6UR.js +12 -0
  14. package/dist/chunk-T6NMRTFB.js +7 -0
  15. package/dist/chunk-UVTAPUGQ.js +3 -0
  16. package/dist/{chunk-WC6TLR42.js → chunk-WALPQ6TH.js} +2 -1
  17. package/dist/chunk-YK4WW4LX.js +7 -0
  18. package/dist/{chunk-FL2GCRSI.js → chunk-YRM5SYRT.js} +2 -2
  19. package/dist/{chunk-XSSM5ZB7.js → chunk-ZU4L3NDZ.js} +1 -1
  20. package/dist/collect-user-info.d.ts +4 -4
  21. package/dist/collect-user-info.js +5 -5
  22. package/dist/{controller-Ta5RgFZ4.d.ts → controller-CO5r6vXD.d.ts} +2 -2
  23. package/dist/{copy-CEILzVXc.d.ts → copy-D6Sd0BIe.d.ts} +1 -1
  24. package/dist/custom-form.css +1 -1
  25. package/dist/custom-form.d.ts +3 -3
  26. package/dist/custom-form.js +6 -7
  27. package/dist/esign/ceremony-runtime.js +7 -0
  28. package/dist/esign.d.ts +4 -0
  29. package/dist/esign.js +422 -0
  30. package/dist/fraud.d.ts +3 -3
  31. package/dist/fraud.js +4 -5
  32. package/dist/idv/cross-device.d.ts +3 -3
  33. package/dist/idv/cross-device.js +4 -5
  34. package/dist/idv.d.ts +3 -3
  35. package/dist/idv.js +12 -12
  36. package/dist/{index-G5mVvjNZ.d.ts → index-iyKwn5_z.d.ts} +3 -3
  37. package/dist/index.d.ts +6 -6
  38. package/dist/index.js +6 -7
  39. package/dist/{machine-BhPiYmOR.d.ts → machine-DXxarDcC.d.ts} +37 -2
  40. package/dist/react.d.ts +4 -4
  41. package/dist/react.js +7 -8
  42. package/dist/workspace.d.ts +3 -3
  43. package/dist/workspace.js +2 -1
  44. package/package.json +10 -3
  45. package/dist/api-BrQqQbGK.d.ts +0 -342
  46. package/dist/chunk-523TT3PD.js +0 -7
  47. package/dist/chunk-7GP5REM7.js +0 -3
  48. package/dist/chunk-BBO2X73Y.js +0 -9
  49. package/dist/chunk-S2OOEDJS.js +0 -3
  50. package/dist/chunk-T4R5TTE5.js +0 -7
  51. package/dist/chunk-WPMO4FQ2.js +0 -13
@@ -0,0 +1,7 @@
1
+ import { initTransport } from '../chunk-UVTAPUGQ.js';
2
+ import { isEsignConsentOutcome, resolveEsignDocumentCopy, ESIGN_STATES, ESIGN_CONSENT_ACTIONS, ESIGN_DOCUMENT_ACTIONS } from '../chunk-2SPZA3CQ.js';
3
+ import '../chunk-AIK7CDV6.js';
4
+
5
+ function esignFrameOwnsDownload(documentCount){return documentCount===1}function createEsignChrome(deps){const doc=deps.container.ownerDocument;let documentPanel=null;function ensurePanel(existing,marker){if(existing!==null)return existing;const el=doc.createElement("div");el.setAttribute(marker,"");el.className="ctv-esign-callout-body";deps.container.appendChild(el);return el}function button(label,onClick){const el=doc.createElement("button");el.type="button";el.className="ctv-esign-btn ctv-esign-btn-ghost";el.textContent=label;el.addEventListener("click",onClick);return el}function line(text,role){const el=doc.createElement("p");el.className="ctv-esign-callout-text";el.setAttribute("role",role);el.textContent=text;return el}function renderDocuments(model){if(model.documents.length===0){documentPanel?.remove();documentPanel=null;return}const panel=ensurePanel(documentPanel,"data-checktiv-esign-documents");documentPanel=panel;panel.replaceChildren();const frameOwnsTheControl=!model.owned&&model.framePaintsTopBar&&esignFrameOwnsDownload(model.documents.length);if(!frameOwnsTheControl){const controls=doc.createElement("div");controls.className="ctv-esign-callout-actions";panel.appendChild(controls);const label=resolveEsignDocumentCopy(deps.copy,"download");for(const[index,document_]of model.documents.entries()){const text=model.documents.length>1?`${label} ${index+1}`:label;const control=button(text,()=>deps.on.onDownload(document_.documentId));control.setAttribute("data-checktiv-esign-download",document_.documentId);controls.appendChild(control);}}if(model.downloadFailed){const error=line(resolveEsignDocumentCopy(deps.copy,"downloadFailed"),"alert");error.setAttribute("data-checktiv-esign-download-error","");panel.appendChild(error);}if(model.downloadRemoved){const removed=line(resolveEsignDocumentCopy(deps.copy,"downloadRemoved"),"alert");removed.setAttribute("data-checktiv-esign-download-removed","");panel.appendChild(removed);}if(panel.childElementCount===0){panel.remove();documentPanel=null;}}return {render(model){renderDocuments(model);},destroy(){documentPanel?.remove();documentPanel=null;}}}function filenameFromDisposition(raw){if(raw===null)return "document.pdf";const match=/filename="([^"]+)"/.exec(raw);const name=match?.[1];return name!==void 0&&name.length>0?name:"document.pdf"}function saveBlobAsDownload(blob,filename,deps){const doc=deps.container.ownerDocument;const view=doc.defaultView;if(view===null||typeof view.URL?.createObjectURL!=="function")return false;const objectUrl=view.URL.createObjectURL(blob);const anchor=doc.createElement("a");anchor.href=objectUrl;anchor.download=filename;anchor.rel="noopener";anchor.style.display="none";doc.body.appendChild(anchor);anchor.click();anchor.remove();deps.schedule(()=>view.URL.revokeObjectURL(objectUrl),0);return true}var ESIGN_PROTOCOL_VERSION=1;var MIN_ESIGN_PROTOCOL_VERSION=1;function checkInboundProtocolVersion(value){if(value===void 0)return "ok";if(typeof value!=="number"||!Number.isFinite(value))return "malformed";return value<MIN_ESIGN_PROTOCOL_VERSION?"mismatch":"ok"}function isRecord(value){return typeof value==="object"&&value!==null}function isDocumentDocShape(value){if(!isRecord(value))return false;if(value.type!=="doc")return false;return value.content===void 0||Array.isArray(value.content)}function isBundleDocumentShape(value){if(!isRecord(value))return false;if(typeof value.documentId!=="string"||value.documentId.length===0)return false;if(typeof value.templateVersionId!=="string"||value.templateVersionId.length===0){return false}if(typeof value.documentOrder!=="number")return false;if(typeof value.preSignatureHash!=="string")return false;if(!isRecord(value.resolvedVariables))return false;return isDocumentDocShape(value.doc)}function isEsignBundleShape(value){if(!isRecord(value))return false;if(typeof value.envelopeId!=="string"||value.envelopeId.length===0)return false;if(!Array.isArray(value.documents)||value.documents.length===0)return false;if(!value.documents.every(isBundleDocumentShape))return false;if(!Array.isArray(value.parties))return false;const disclosure=value.disclosure;if(!isRecord(disclosure))return false;if(typeof disclosure.version!=="string"||disclosure.version.length===0)return false;if(typeof disclosure.hash!=="string"||disclosure.hash.length===0)return false;if(typeof disclosure.body!=="string"||disclosure.body.length===0)return false;if(typeof disclosure.locale!=="string"||disclosure.locale.length===0)return false;const settings=value.settings;if(!isRecord(settings))return false;if(typeof settings.requireScrollToEnd!=="boolean")return false;if(settings.minimumAgeYears!==void 0&&typeof settings.minimumAgeYears!=="number"){return false}return true}function isEsignProjectionShape(value){if(!isRecord(value))return false;if(typeof value.envelopeId!=="string"||value.envelopeId.length===0)return false;if(typeof value.status!=="string"||value.status.length===0)return false;if(typeof value.expiresAt!=="string")return false;if(!("disclosure"in value)||!("scrolledToEndAt"in value))return false;if(!("adoptedSignature"in value)||!("adoptedAt"in value))return false;return "chainHeadSequence"in value}function parseEsignInbound(data){if(!isRecord(data))return null;const type=data.type;if(typeof type!=="string"||!type.startsWith("esign:"))return null;const verdict=checkInboundProtocolVersion(data.protocolVersion);if(verdict==="malformed")return null;if(verdict==="mismatch")return {kind:"protocol_mismatch"};const protocolVersion=typeof data.protocolVersion==="number"?data.protocolVersion:ESIGN_PROTOCOL_VERSION;if(type==="esign:ready"){return {kind:"message",message:{type:"esign:ready",protocolVersion}}}if(type==="esign:state"){const state=data.state;if(typeof state!=="string"||!isEsignState(state))return null;return {kind:"message",message:{type:"esign:state",protocolVersion,state}}}if(type==="esign:event"){const event=data.event;if(!isCeremonyEventShape(event))return null;return {kind:"message",message:{type:"esign:event",protocolVersion,event}}}if(type==="esign:submit"){const body=data.body;if(!isSubmitBodyShape(body))return null;return {kind:"message",message:{type:"esign:submit",protocolVersion,body}}}if(type==="esign:resize"){const height=data.height;if(typeof height!=="number"||!Number.isFinite(height)||height<=0)return null;return {kind:"message",message:{type:"esign:resize",protocolVersion,height}}}if(type==="esign:consent_act"){const action=data.action;if(typeof action!=="string"||!isEsignConsentAction(action))return null;return {kind:"message",message:{type:"esign:consent_act",protocolVersion,action}}}if(type==="esign:scroll_request"){const offsetTop=data.offsetTop;if(typeof offsetTop!=="number"||!Number.isFinite(offsetTop)||offsetTop<0)return null;return {kind:"message",message:{type:"esign:scroll_request",protocolVersion,offsetTop}}}if(type==="esign:document_act"){const{action,documentId}=data;if(typeof action!=="string"||!isEsignDocumentAction(action))return null;if(typeof documentId!=="string"||documentId.length===0)return null;return {kind:"message",message:{type:"esign:document_act",protocolVersion,action,documentId}}}if(type==="esign:document_extent"){const{documentId,endOffsetTop}=data;if(typeof documentId!=="string"||documentId.length===0)return null;if(typeof endOffsetTop!=="number"||!Number.isFinite(endOffsetTop)||endOffsetTop<0){return null}return {kind:"message",message:{type:"esign:document_extent",protocolVersion,documentId,endOffsetTop}}}return null}function isEsignConsentAction(value){return ESIGN_CONSENT_ACTIONS.includes(value)}function isEsignDocumentAction(value){return ESIGN_DOCUMENT_ACTIONS.includes(value)}var CEREMONY_EVENT_TYPES=["document.viewed","disclosure.presented","disclosure.consented","document.scrolled_to_end","signature.adopted"];function isCeremonyEventShape(value){if(!isRecord(value))return false;return typeof value.type==="string"&&isCeremonyEventType(value.type)}function isCeremonyEventType(value){const types=CEREMONY_EVENT_TYPES;return types.includes(value)}function isSubmitBodyShape(value){if(!isRecord(value))return false;if(!Array.isArray(value.documents)||value.documents.length===0)return false;const signed=value.adoptedSignature!==void 0;const declined=value.declineReason!==void 0;return signed!==declined}function isEsignState(value){return ESIGN_STATES.includes(value)}function buildSignerLocalContext(context){return {getTimezoneOffsetMinutes:(context.now??new Date).getTimezoneOffset(),...context.locale!==void 0?{locale:context.locale}:{}}}function buildEsignCeremonyEventBody(input,context={}){const common={protocolVersion:ESIGN_PROTOCOL_VERSION,...buildSignerLocalContext(context)};switch(input.type){case "document.viewed":return {...common,type:"document.viewed",documentId:input.documentId};case "disclosure.presented":return {...common,type:"disclosure.presented",...input.disclosureLocale!==void 0?{disclosureLocale:input.disclosureLocale}:{}};case "disclosure.consented":return {...common,type:"disclosure.consented",disclosureVersion:input.disclosureVersion,disclosureLocale:input.disclosureLocale,disclosureHash:input.disclosureHash};case "document.scrolled_to_end":return {...common,type:"document.scrolled_to_end",documentId:input.documentId};case "signature.adopted":return {...common,type:"signature.adopted",adoptedSignature:input.adoptedSignature};default:return assertNeverCeremonyEvent(input)}}function buildEsignConsentActBody(action,context={}){return {protocolVersion:ESIGN_PROTOCOL_VERSION,action,...buildSignerLocalContext(context)}}function parseEsignConsentActBody(body){if(!isRecord(body))return null;const outcome=body.outcome;if(typeof outcome!=="string"||!isEsignConsentOutcome(outcome))return null;return outcome}function isEsignDocumentRemovedBody(body){return isRecord(body)&&body.removed===true}function assertNeverCeremonyEvent(input){throw new Error(`Unhandled esign ceremony event input: ${JSON.stringify(input)}`)}var ESIGN_REFUSAL_STATE={esign_protocol_unsupported:{disposition:"upgrade",state:"protocol_mismatch"},esign_envelope_not_ready:{disposition:"retry",state:"preparing"},esign_event_out_of_order:{disposition:"resume",state:"conflict"},esign_disclosure_mismatch:{disposition:"resume",state:"consent"},esign_unknown_document:{disposition:"resume",state:"conflict"},esign_documents_incomplete:{disposition:"resume",state:"conflict"},esign_consent_required:{disposition:"resume",state:"consent"},esign_read_through_required:{disposition:"resume",state:"scroll_incomplete"},esign_signature_not_adopted:{disposition:"resume",state:"adopt"},esign_signature_mismatch:{disposition:"resume",state:"adopt"},esign_template_version_stale:{disposition:"resume",state:"conflict"},esign_age_assurance_required:{disposition:"resume",state:"age_gate"},esign_minimum_age_not_met:{disposition:"blocked",state:"age_blocked"},esign_consent_withdrawn:{disposition:"withdrawn",state:"terminal_withdrawn"},esign_envelope_conflict:{disposition:"concluded",state:"conflict"}};function isRecord2(value){return typeof value==="object"&&value!==null}function isEsignRefusalCode(value){return Object.prototype.hasOwnProperty.call(ESIGN_REFUSAL_STATE,value)}function readEsignRefusal(body){if(!isRecord2(body))return null;const error=body.error;if(!isRecord2(error))return null;const code=error.code;if(typeof code!=="string"||!isEsignRefusalCode(code))return null;const retryAfterMs=error.retryAfterMs;return {code,retryAfterMs:typeof retryAfterMs==="number"&&Number.isFinite(retryAfterMs)&&retryAfterMs>0?retryAfterMs:void 0}}function wireEsignTransport(options){const{win,embedOrigin,getFrameWindow,handlers}=options;return initTransport({win,allowedOrigins:[embedOrigin],parse:parseEsignInbound,expectedSource:getFrameWindow,onMessage:(inbound,post)=>{if(inbound.kind==="protocol_mismatch"){handlers.onProtocolMismatch();return}const message=inbound.message;switch(message.type){case "esign:ready":handlers.onReady(post);return;case "esign:state":handlers.onState(message);return;case "esign:event":handlers.onEvent(message,post);return;case "esign:submit":handlers.onSubmit(message);return;case "esign:resize":handlers.onResize(message);return;case "esign:consent_act":handlers.onConsentAct(message,post);return;case "esign:scroll_request":handlers.onScrollRequest(message);return;case "esign:document_act":handlers.onDocumentAct(message);return;case "esign:document_extent":handlers.onDocumentExtent(message);return;default:return assertNeverEsignInbound(message)}}})}function assertNeverEsignInbound(message){throw new Error(`Unhandled esign inbound message: ${JSON.stringify(message)}`)}
6
+
7
+ export { ESIGN_PROTOCOL_VERSION, ESIGN_REFUSAL_STATE, buildEsignCeremonyEventBody, buildEsignConsentActBody, createEsignChrome, filenameFromDisposition, isEsignBundleShape, isEsignDocumentRemovedBody, isEsignProjectionShape, parseEsignConsentActBody, readEsignRefusal, saveBlobAsDownload, wireEsignTransport };
@@ -0,0 +1,4 @@
1
+ export { f as ChecktivEsignEvent, a0 as ESIGN_CONSENT_ACTIONS, a1 as ESIGN_COPY_FALLBACKS, a2 as ESIGN_COPY_STATE_KEYS, a3 as ESIGN_COUNT_TOKEN, a4 as ESIGN_DOCUMENT_FALLBACKS, a5 as ESIGN_DOCUMENT_KEYS, a6 as ESIGN_FRAME_ANNOUNCE_TIMEOUT_MS, a7 as ESIGN_LABELS, a8 as ESIGN_LABEL_FALLBACKS, a9 as ESIGN_OUTCOME_RIGHTS_KEY, aa as ESIGN_RIGHTS_FALLBACKS, ab as ESIGN_RIGHTS_KEYS, ac as ESIGN_SHELL_FALLBACKS, ad as ESIGN_SHELL_KEYS, ae as ESIGN_STATES, af as ESIGN_STATE_RIGHTS, ag as ESIGN_TERMINAL_STATUS_KEY, ah as EsignConsentAction, ai as EsignConsentOutcome, aj as EsignContextMint, E as EsignCopy, ak as EsignCopyScalarKey, al as EsignDocumentCopyKey, m as EsignHandle, am as EsignLabel, n as EsignMountOptions, an as EsignRightsAffordance, ao as EsignRightsKey, ap as EsignShellKey, o as EsignState, aq as EsignSubmitOutcome, ar as EsignTerminalState, as as TERMINAL_STATUS_TO_STATE, at as TerminalEnvelopeStatus, au as createEsign, av as esignStateOffersRights, aw as parseEsignMint, ax as parseEsignPending, ay as resolveEsignCopy, az as resolveEsignDocumentCopy, aA as resolveEsignFrameTitle, aB as resolveEsignLabel, aC as resolveEsignOutcomeCopy, aD as resolveEsignRightsCopy, aE as resolveEsignShellCopy, aF as resolveEsignTerminalStatus } from './api-EY_fOZm-.js';
2
+ import './machine-DXxarDcC.js';
3
+ import './copy-D6Sd0BIe.js';
4
+ import './copy-DCeQ4JKx.js';
package/dist/esign.js ADDED
@@ -0,0 +1,422 @@
1
+ import { resolveCaptureTheme } from './chunk-4HIQN4KL.js';
2
+ import { isTerminalEnvelopeStatus, TERMINAL_STATUS_TO_STATE, ESIGN_PREPARING_MAX_ATTEMPTS, esignPreparingDelayMs, isEsignFrameFatalState, resolveEsignFrameTitle, ESIGN_FRAME_ANNOUNCE_TIMEOUT_MS, ESIGN_SCROLL_TARGET_MARGIN_PX, ESIGN_TERMINAL_STATUS_KEY, ESIGN_PREPARING_STALL_MS, resolveEsignShellCopy, resolveEsignCopy, resolveEsignDocumentCopy, resolveEsignLabel } from './chunk-2SPZA3CQ.js';
3
+ export { ESIGN_CONSENT_ACTIONS, ESIGN_COPY_FALLBACKS, ESIGN_COPY_STATE_KEYS, ESIGN_COUNT_TOKEN, ESIGN_DOCUMENT_FALLBACKS, ESIGN_DOCUMENT_KEYS, ESIGN_FRAME_ANNOUNCE_TIMEOUT_MS, ESIGN_LABELS, ESIGN_LABEL_FALLBACKS, ESIGN_OUTCOME_RIGHTS_KEY, ESIGN_RIGHTS_FALLBACKS, ESIGN_RIGHTS_KEYS, ESIGN_SHELL_FALLBACKS, ESIGN_SHELL_KEYS, ESIGN_STATES, ESIGN_STATE_RIGHTS, ESIGN_TERMINAL_STATUS_KEY, TERMINAL_STATUS_TO_STATE, esignStateOffersRights, resolveEsignCopy, resolveEsignDocumentCopy, resolveEsignFrameTitle, resolveEsignLabel, resolveEsignOutcomeCopy, resolveEsignRightsCopy, resolveEsignShellCopy, resolveEsignTerminalStatus } from './chunk-2SPZA3CQ.js';
4
+ import { registerModule } from './chunk-GFHNOZVO.js';
5
+ import { resolveSession, warnWrongTokenPlane } from './chunk-YK4WW4LX.js';
6
+ import './chunk-IQKHRPJR.js';
7
+ import { assertNever } from './chunk-UBQTPS5J.js';
8
+ import { withTokenRetry, createChecktivError, isCredentialUnverifiable, isChecktivError, mapHttpStatusToError } from './chunk-C7GRMEYT.js';
9
+ import { dataPlaneHeaders, stepSubmitPath, isCanonicalOrigin, SESSIONS_ME_PATH } from './chunk-HFQJYEGZ.js';
10
+ import './chunk-QFA3K5ZV.js';
11
+ import './chunk-AIK7CDV6.js';
12
+
13
+ function esignBundlePath(stepId,opts={}){return `${esignStepPath(stepId)}${localeQuery(opts.locale)}`}function esignStepPath(stepId){return `${SESSIONS_ME_PATH}/esign/${encodeURIComponent(stepId)}`}function localeQuery(locale){if(locale===void 0||locale.length===0)return "";return `?locale=${encodeURIComponent(locale)}`}function esignEventsPath(stepId){return `${esignStepPath(stepId)}/events`}function esignContextMintPath(stepId,opts={}){return `${esignStepPath(stepId)}/context${localeQuery(opts.locale)}`}function esignConsentWithdrawPath(stepId){return `${esignStepPath(stepId)}/consent-withdraw`}function esignDocumentPath(stepId,documentId){return `${esignStepPath(stepId)}/documents/${encodeURIComponent(documentId)}`}function isRecord(value){return typeof value==="object"&&value!==null}function parseEsignMint(body){if(!isRecord(body)||!isRecord(body.data))return null;const d=body.data;const contextToken=d.context_token;const embedOrigin=d.embed_origin;const disclosureLocale=d.disclosure_locale;if(typeof contextToken!=="string"||contextToken.length===0)return null;if(!isCanonicalOrigin(embedOrigin))return null;if(typeof disclosureLocale!=="string"||disclosureLocale.length<2)return null;return {contextToken,embedOrigin,disclosureLocale}}function parseEsignPending(body){if(!isRecord(body)||body.pending!==true)return null;const retryAfterMs=body.retryAfterMs;if(typeof retryAfterMs!=="number"||!Number.isFinite(retryAfterMs))return null;return {retryAfterMs}}async function readJson(res){try{return await res.json()}catch{return null}}function retryAfterMsFromHeader(res){const raw=res.headers.get("retry-after");if(raw===null)return void 0;const seconds=Number.parseInt(raw,10);if(!Number.isFinite(seconds)||seconds<=0)return void 0;return seconds*1e3}function esignPlaneThrowCode(err,fallback){return isChecktivError(err)&&err.code==="session_parked"?"session_parked":fallback}function warnEsignThrow(site,err){console.warn(`[Checktiv] esign ${site} threw.`,err);}function reportEsignThrow(site,err,fallback){const reported=esignPlaneThrowCode(err,fallback);if(!isChecktivError(err)||err.code!==reported)warnEsignThrow(site,err);return reported}async function postCeremonyEvent(d,rt,stepId,body){let res;try{res=await withTokenRetry(d.ctx.tokens,token=>d.fetchImpl(d.ctx.apiBaseOrigin+esignEventsPath(stepId),{method:"POST",headers:dataPlaneHeaders(d.ctx,token,{withJsonBody:true}),body:JSON.stringify(body)}));}catch(err){d.fail(reportEsignThrow("ceremony event",err,"sdk_load_failed"));return {kind:"failed"}}if(!res.ok){return await d.refuseAttempt(rt,res,stepId,"sdk_load_failed")}const parsed=await readJson(res);if(!rt.isEsignProjectionShape(parsed)){d.fail("sdk_load_failed");return {kind:"failed"}}return {kind:"ok",value:parsed}}async function fetchBundleOnce(d,rt,stepId,quiet=false){let res;try{res=await withTokenRetry(d.ctx.tokens,token=>d.fetchImpl(d.ctx.apiBaseOrigin+esignBundlePath(stepId,{locale:d.ctx.locale}),{method:"GET",headers:dataPlaneHeaders(d.ctx,token)}));}catch(err){const code=reportEsignThrow("bundle read",err,"sdk_load_failed");if(!quiet)d.fail(code);return {kind:"failed"}}if(!res.ok){if(!quiet){if(res.status===409)d.fail("session_parked");else d.failFromStatus(res.status,"sdk_load_failed");}return {kind:"failed"}}const parsed=await readJson(res);const pending=parseEsignPending(parsed);if(pending!==null)return {kind:"pending",retryAfterMs:pending.retryAfterMs};if(!rt.isEsignBundleShape(parsed)){if(!quiet)d.fail("sdk_load_failed");return {kind:"failed"}}return {kind:"ok",value:parsed}}async function mintSignContext(d,stepId){let res;try{res=await withTokenRetry(d.ctx.tokens,token=>d.fetchImpl(d.ctx.apiBaseOrigin+esignContextMintPath(stepId,{locale:d.ctx.locale}),{method:"POST",headers:dataPlaneHeaders(d.ctx,token,{withJsonBody:true}),body:"{}"}));}catch(err){d.fail(reportEsignThrow("context mint",err,"sdk_load_failed"));return null}if(!res.ok){d.failFromStatus(res.status,"sdk_load_failed");return null}const mint=parseEsignMint(await readJson(res));if(mint===null){d.fail("sdk_load_failed");return null}return mint}async function submitOnce(d,rt,sessionId,stepId,body){let res;try{res=await withTokenRetry(d.ctx.tokens,token=>d.fetchImpl(d.ctx.apiBaseOrigin+stepSubmitPath(sessionId,stepId),{method:"POST",headers:dataPlaneHeaders(d.ctx,token,{withJsonBody:true}),body:JSON.stringify(body)}));}catch(err){warnEsignThrow("step submit",err);d.fail("submit_failed");return {kind:"failed"}}if(d.isDestroyed())return {kind:"failed"};if(!res.ok)return await d.refuseAttempt(rt,res,stepId,"submit_failed");return {kind:"ok",value:true}}async function postConsentAct(d,rt,stepId,action){let res;try{res=await withTokenRetry(d.ctx.tokens,token=>d.fetchImpl(d.ctx.apiBaseOrigin+esignConsentWithdrawPath(stepId),{method:"POST",headers:dataPlaneHeaders(d.ctx,token,{withJsonBody:true}),body:JSON.stringify(rt.buildEsignConsentActBody(action,{locale:d.ctx.locale}))}));}catch(err){warnEsignThrow("consumer act",err);return {kind:"failed"}}if(!res.ok)return {kind:"failed"};const outcome=rt.parseEsignConsentActBody(await readJson(res));if(outcome===null)return {kind:"failed"};return {kind:"ok",outcome}}function fetchEsignDocument(d,stepId,documentId){return withTokenRetry(d.ctx.tokens,token=>d.fetchImpl(d.ctx.apiBaseOrigin+esignDocumentPath(stepId,documentId),{method:"GET",headers:dataPlaneHeaders(d.ctx,token)}))}function createEsignErrorEvent(code){return {type:"checktiv.esign.error",error:createChecktivError(code)}}var ESIGN_FAILURE_STATE={token_expired:"token_expired",protocol_mismatch:"protocol_mismatch",session_expired:"error",upload_failed:"error",sdk_load_failed:"error",session_parked:"error",submit_failed:"submit_error",wrong_token_type:"error"};var ESIGN_PANEL_SILENT_ATTR="data-checktiv-esign-silent";var MARK={info:"i",ok:"\u2713",warn:"!",stop:"\u2715",neutral:"\u2022"};var IN_CEREMONY={tone:"info",mark:MARK.info,actions:["reload"]};var ESIGN_PANEL_SPEC={preparing:{tone:"info",mark:MARK.info,actions:[]},consent:IN_CEREMONY,read:IN_CEREMONY,scroll_incomplete:IN_CEREMONY,adopt:IN_CEREMONY,age_gate:IN_CEREMONY,explain:IN_CEREMONY,sign:IN_CEREMONY,decline:IN_CEREMONY,withdraw:IN_CEREMONY,obscured:IN_CEREMONY,age_blocked:{tone:"warning",mark:MARK.warn,actions:[]},frame_blocked:{tone:"danger",mark:MARK.stop,actions:["reload","printAndSign"]},conflict:{tone:"warning",mark:MARK.warn,actions:["reload"]},token_expired:{tone:"warning",mark:MARK.warn,actions:["reload"]},protocol_mismatch:{tone:"danger",mark:MARK.stop,actions:["reload"]},error:{tone:"danger",mark:MARK.stop,actions:["reload","help"]},submit_error:{tone:"danger",mark:MARK.stop,actions:["reloadToCheck"]},terminal_signed:{tone:"success",mark:MARK.ok,actions:[]},terminal_declined:{tone:"neutral",mark:MARK.neutral,actions:["help"]},terminal_voided:{tone:"warning",mark:MARK.warn,actions:["help"]},terminal_expired:{tone:"warning",mark:MARK.warn,actions:["help"]},terminal_withdrawn:{tone:"neutral",mark:MARK.neutral,actions:["help"]}};var TONE_CLASS={info:"ctv-esign-callout-info",success:"ctv-esign-callout-success",warning:"ctv-esign-callout-warning",danger:"ctv-esign-callout-danger",neutral:""};var ACTION_WORD={reload:"reload",reloadToCheck:"reloadToCheck",printAndSign:"printAndSign",help:"getHelp"};function isTerminalPanelState(state){return Object.prototype.hasOwnProperty.call(ESIGN_TERMINAL_STATUS_KEY,state)}function createEsignStatePanel(deps){const doc=deps.container.ownerDocument;let panel=null;let body=null;let mark=null;let title=null;let text=null;let skeleton=null;let actions=null;function button(label,primary,onClick){const el=doc.createElement("button");el.type="button";el.className=`ctv-esign-btn ctv-esign-btn-${primary?"primary":"ghost"}`;el.textContent=label;el.addEventListener("click",onClick);return el}function ensurePanel(){const existing=panel;if(existing!==null)return existing;const root=doc.createElement("div");root.setAttribute("data-checktiv-esign-panel","");const markEl=doc.createElement("span");markEl.className="ctv-esign-callout-mark";markEl.setAttribute("aria-hidden","true");const bodyEl=doc.createElement("div");bodyEl.className="ctv-esign-callout-body";const titleEl=doc.createElement("p");titleEl.className="ctv-esign-callout-title";titleEl.setAttribute("data-checktiv-esign-terminal-status","");const textEl=doc.createElement("p");textEl.className="ctv-esign-callout-text";textEl.setAttribute("data-checktiv-esign-status","");textEl.setAttribute("role","status");const actionsEl=doc.createElement("div");actionsEl.className="ctv-esign-callout-actions";actionsEl.setAttribute("data-checktiv-esign-actions","");bodyEl.append(titleEl,textEl,actionsEl);root.append(markEl,bodyEl);deps.container.appendChild(root);panel=root;body=bodyEl;mark=markEl;title=titleEl;text=textEl;actions=actionsEl;return root}function renderSkeleton(column){if(skeleton!==null)return;const el=doc.createElement("div");el.className="ctv-esign-skeleton";el.setAttribute("aria-hidden","true");el.setAttribute("data-checktiv-esign-preparing-skeleton","");column.insertBefore(el,column.firstChild);skeleton=el;}function removeSkeleton(){skeleton?.remove();skeleton=null;}function silence(root){root.className="";root.removeAttribute("data-checktiv-esign-tone");root.setAttribute(ESIGN_PANEL_SILENT_ATTR,"");if(mark!==null){mark.textContent="";mark.hidden=true;}if(title!==null){title.textContent="";title.hidden=true;}if(text!==null)text.textContent="";if(actions!==null){actions.replaceChildren();actions.hidden=true;}removeSkeleton();}function isActionLive(action,model){if(action==="help")return deps.on.onHelp!==void 0;if(action==="printAndSign")return model.hasDocuments;return true}function actionWord(action){return resolveEsignLabel(deps.copy,ACTION_WORD[action])}function runAction(action,state){if(action==="help")deps.on.onHelp?.(state);else if(action==="printAndSign")deps.on.onPrintAndSign();else deps.on.onReload();}return {render(model){const state=model.state;if(state===null||!model.owned){if(panel===null)return;silence(panel);return}const spec=ESIGN_PANEL_SPEC[state];const root=ensurePanel();root.removeAttribute(ESIGN_PANEL_SILENT_ATTR);const loading=state==="preparing";const tone=TONE_CLASS[spec.tone];root.className=loading?"ctv-esign-loading":`ctv-esign-callout${tone===""?"":` ${tone}`}`;root.setAttribute("data-checktiv-esign-tone",spec.tone);if(mark!==null){mark.textContent=spec.mark;mark.hidden=loading;}const terminal=isTerminalPanelState(state);if(title!==null){title.textContent=terminal?resolveEsignShellCopy(deps.copy,ESIGN_TERMINAL_STATUS_KEY[state]):"";title.hidden=!terminal;}if(text!==null)text.textContent=resolveEsignCopy(deps.copy,state);if(loading&&!model.hasFrame&&body!==null)renderSkeleton(body);else removeSkeleton();if(actions===null)return;actions.replaceChildren();const late=state==="preparing"&&(model.preparingStalled||model.polls*2>=ESIGN_PREPARING_MAX_ATTEMPTS);const wanted=late?["reload"]:spec.actions;let primary=true;for(const action of wanted){if(!isActionLive(action,model))continue;const control=button(actionWord(action),primary,()=>runAction(action,state));control.setAttribute("data-checktiv-esign-action",action);actions.appendChild(control);primary=false;}if(model.printAndSignStarted){const note=doc.createElement("p");note.className="ctv-esign-callout-text";note.setAttribute("data-checktiv-esign-print-note","");note.textContent=resolveEsignDocumentCopy(deps.copy,"printAndSignStarted");actions.appendChild(note);}actions.hidden=actions.childElementCount===0;},destroy(){panel?.remove();panel=null;body=null;skeleton=null;}}}function applyEmbedTheme(theme,root,surface="inherit"){root.dataset.theme=theme.colorMode;root.style.setProperty("color-scheme",theme.colorMode);applyEmbedSurfacePaint(root,surface);const brand=theme.brandTokens;if(!brand)return;root.style.setProperty("--theme-primary",brand.primary);root.style.setProperty("--theme-primary-hover",brand.primaryHover);root.style.setProperty("--theme-on-primary",brand.onPrimary);root.style.setProperty("--theme-secondary",brand.secondary);root.style.setProperty("--theme-ring",brand.primary);}function applyEmbedSurfacePaint(root,surface){if(surface==="inherit")return;root.style.setProperty("background-color",surface==="transparent"?"transparent":"var(--theme-bg)");}var STYLE_ELEMENT_ID="ctv-esign-styles";var STYLE_MARKER_ATTR="data-ctv-esign-styles";var ESIGN_MODE_ATTR="data-ctv-esign-mode";var ESIGN_FRAME_CLASS="ctv-esign-frame";var delivery="none";var SCOPE_RULES=`
14
+ .ctv-esign {
15
+ box-sizing: border-box;
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: 0.75rem;
19
+ width: 100%;
20
+ padding: 1rem;
21
+ background-color: var(--theme-surface-1, #ffffff);
22
+ color: var(--theme-on-surface-1, #16181d);
23
+ border: 1px solid var(--theme-border, hsla(225, 12%, 10%, 0.1));
24
+ border-radius: var(--theme-shape-radius, 0.75rem);
25
+ font-family: var(--theme-font-family-sans, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif);
26
+ font-size: 0.875rem;
27
+ line-height: 1.5;
28
+ }
29
+
30
+ .ctv-esign *,
31
+ .ctv-esign *::before,
32
+ .ctv-esign *::after {
33
+ box-sizing: inherit;
34
+ }
35
+
36
+ .ctv-esign-sr-only {
37
+ position: absolute;
38
+ width: 1px;
39
+ height: 1px;
40
+ padding: 0;
41
+ margin: -1px;
42
+ overflow: hidden;
43
+ clip-path: inset(50%);
44
+ white-space: nowrap;
45
+ border: 0;
46
+ }
47
+ `;var PRIMITIVE_RULES=`
48
+ .ctv-esign-card {
49
+ background-color: var(--theme-surface-1, #ffffff);
50
+ color: var(--theme-on-surface-1, #16181d);
51
+ border: 1px solid var(--theme-border, hsla(225, 12%, 10%, 0.1));
52
+ border-radius: var(--theme-shape-radius, 0.75rem);
53
+ padding: 2rem;
54
+ }
55
+
56
+ .ctv-esign-input {
57
+ width: 100%;
58
+ background-color: var(--theme-surface-2, #f2f2ee);
59
+ color: var(--theme-on-surface-2, #16181d);
60
+ border: 1px solid var(--theme-border-strong, hsla(225, 12%, 10%, 0.18));
61
+ border-radius: var(--theme-button-border-radius, 0.4rem);
62
+ padding: 0.6rem 0.8rem;
63
+ font-size: max(16px, var(--font-size-base, 14px));
64
+ transition: border-color var(--theme-transition, 0.2s ease-in-out), background-color var(--theme-transition, 0.2s ease-in-out);
65
+ }
66
+
67
+ .ctv-esign-input::placeholder {
68
+ color: var(--theme-on-surface-2-muted, hsla(225, 12%, 10%, 0.62));
69
+ }
70
+
71
+ .ctv-esign-input:hover {
72
+ border-color: var(--theme-ring, #2563eb);
73
+ }
74
+
75
+ .ctv-esign-input:focus-visible {
76
+ outline: 2px solid var(--theme-ring, #2563eb);
77
+ outline-offset: 2px;
78
+ border-color: var(--theme-ring, #2563eb);
79
+ }
80
+
81
+ @media (forced-colors: active) {
82
+ .ctv-esign-input:focus-visible {
83
+ outline-color: Highlight;
84
+ }
85
+ }
86
+
87
+ .ctv-esign-btn {
88
+ display: inline-flex;
89
+ align-items: center;
90
+ justify-content: center;
91
+ gap: 0.5rem;
92
+ padding: 0.65rem 1.1rem;
93
+ border-radius: var(--theme-button-border-radius, 0.4rem);
94
+ font-size: var(--font-size-sm, 12px);
95
+ font-weight: 600;
96
+ letter-spacing: 0.01em;
97
+ border: 1px solid transparent;
98
+ cursor: pointer;
99
+ text-decoration: none;
100
+ transition: background-color var(--theme-transition, 0.2s ease-in-out), color var(--theme-transition, 0.2s ease-in-out), border-color var(--theme-transition, 0.2s ease-in-out), transform var(--theme-transition, 0.2s ease-in-out);
101
+ }
102
+
103
+ .ctv-esign-btn:active {
104
+ transform: translateY(1px);
105
+ }
106
+
107
+ .ctv-esign-btn:disabled {
108
+ opacity: 0.55;
109
+ cursor: not-allowed;
110
+ }
111
+
112
+ .ctv-esign-btn-primary,
113
+ a.ctv-esign-btn-primary {
114
+ background-color: var(--theme-primary, #2563eb);
115
+ color: var(--theme-on-primary, #ffffff);
116
+ }
117
+
118
+ .ctv-esign-btn-primary:hover:not(:disabled),
119
+ a.ctv-esign-btn-primary:hover {
120
+ background-color: var(--theme-primary-hover, #1d4ed8);
121
+ color: var(--theme-on-primary, #ffffff);
122
+ }
123
+
124
+ .ctv-esign-btn-ghost,
125
+ a.ctv-esign-btn-ghost {
126
+ background-color: transparent;
127
+ color: var(--theme-on-bg, #121316);
128
+ border-color: var(--theme-border-strong, hsla(225, 12%, 10%, 0.18));
129
+ }
130
+
131
+ .ctv-esign-btn-ghost:hover:not(:disabled),
132
+ a.ctv-esign-btn-ghost:hover {
133
+ background-color: var(--theme-surface-2, #f2f2ee);
134
+ color: var(--theme-on-bg, #121316);
135
+ border-color: var(--theme-ring, #2563eb);
136
+ }
137
+
138
+ .ctv-esign-btn-danger,
139
+ a.ctv-esign-btn-danger {
140
+ background-color: var(--theme-danger, #b91c1c);
141
+ color: var(--theme-on-danger, #ffffff);
142
+ }
143
+
144
+ .ctv-esign-btn-danger:hover:not(:disabled),
145
+ a.ctv-esign-btn-danger:hover {
146
+ background-color: var(--theme-danger-hover, #991b1b);
147
+ color: var(--theme-on-danger, #ffffff);
148
+ }
149
+
150
+ @media (max-width: 519.98px) {
151
+ .ctv-esign-btn,
152
+ .ctv-esign-input {
153
+ min-height: 44px;
154
+ }
155
+ }
156
+ `;var GATED_CONTROL_RULES=`
157
+ .ctv-esign-btn[aria-disabled='true'] {
158
+ opacity: 0.55;
159
+ cursor: not-allowed;
160
+ }
161
+ `;var BAR_RULES=`
162
+ .ctv-esign-bar {
163
+ display: flex;
164
+ align-items: center;
165
+ flex-wrap: wrap;
166
+ gap: 0.5rem 0.75rem;
167
+ padding: 0.625rem 0.875rem;
168
+ background-color: var(--theme-surface-2, #f2f2ee);
169
+ color: var(--theme-on-surface-2, #16181d);
170
+ border: 1px solid var(--theme-border, hsla(225, 12%, 10%, 0.1));
171
+ border-radius: var(--theme-button-border-radius, 0.4rem);
172
+ }
173
+
174
+ .ctv-esign-bar-title {
175
+ flex: 1 1 auto;
176
+ min-width: 0;
177
+ margin: 0;
178
+ font-size: 0.9375rem;
179
+ font-weight: 600;
180
+ line-height: 1.3;
181
+ }
182
+
183
+ .ctv-esign-bar-actions {
184
+ display: flex;
185
+ flex: none;
186
+ align-items: center;
187
+ gap: 0.5rem;
188
+ margin-left: auto;
189
+ }
190
+ `;var CALLOUT_RULES=`
191
+ .ctv-esign-callout {
192
+ display: flex;
193
+ align-items: flex-start;
194
+ gap: 0.625rem;
195
+ padding: 0.75rem 0.875rem;
196
+ background-color: var(--theme-surface-1, #ffffff);
197
+ color: var(--theme-on-surface-1, #16181d);
198
+ border: 1px solid var(--theme-border, hsla(225, 12%, 10%, 0.1));
199
+ border-left-width: 3px;
200
+ border-radius: var(--theme-button-border-radius, 0.4rem);
201
+ line-height: 1.5;
202
+ }
203
+
204
+ .ctv-esign-callout-mark {
205
+ flex: none;
206
+ line-height: 1.5;
207
+ }
208
+
209
+ .ctv-esign-callout-body {
210
+ flex: 1 1 auto;
211
+ min-width: 0;
212
+ }
213
+
214
+ .ctv-esign-callout-title {
215
+ margin: 0;
216
+ font-size: 0.9375rem;
217
+ font-weight: 600;
218
+ line-height: 1.35;
219
+ }
220
+
221
+ .ctv-esign-callout-text {
222
+ margin: 0.25rem 0 0;
223
+ }
224
+
225
+ .ctv-esign-callout-actions {
226
+ display: flex;
227
+ flex-wrap: wrap;
228
+ gap: 0.5rem;
229
+ margin-top: 0.625rem;
230
+ }
231
+
232
+ .ctv-esign-callout-info {
233
+ border-left-color: var(--theme-primary, #2563eb);
234
+ }
235
+
236
+ .ctv-esign-callout-success {
237
+ border-left-color: var(--theme-success, #3f8f46);
238
+ }
239
+
240
+ .ctv-esign-callout-warning {
241
+ border-left-color: var(--theme-warning, #d97706);
242
+ }
243
+
244
+ .ctv-esign-callout-danger {
245
+ border-left-color: var(--theme-danger, #b91c1c);
246
+ }
247
+ `;var MENU_RULES=`
248
+ .ctv-esign-menu {
249
+ display: flex;
250
+ flex-direction: column;
251
+ margin: 0.375rem 0 0;
252
+ padding: 0.25rem;
253
+ list-style: none;
254
+ background-color: var(--theme-surface-1, #ffffff);
255
+ color: var(--theme-on-surface-1, #16181d);
256
+ border: 1px solid var(--theme-border-strong, hsla(225, 12%, 10%, 0.18));
257
+ border-radius: var(--theme-button-border-radius, 0.4rem);
258
+ }
259
+
260
+ .ctv-esign-menu-item {
261
+ display: flex;
262
+ align-items: center;
263
+ gap: 0.5rem;
264
+ width: 100%;
265
+ padding: 0.5rem 0.625rem;
266
+ background-color: transparent;
267
+ color: inherit;
268
+ border: 0;
269
+ border-radius: 0.25rem;
270
+ font: inherit;
271
+ text-align: left;
272
+ cursor: pointer;
273
+ }
274
+
275
+ .ctv-esign-menu-item:hover:not([aria-disabled='true']) {
276
+ background-color: var(--theme-surface-2, #f2f2ee);
277
+ }
278
+
279
+ @media (max-width: 519.98px) {
280
+ .ctv-esign-menu-item {
281
+ min-height: 44px;
282
+ }
283
+ }
284
+ `;var TILE_RULES=`
285
+ .ctv-esign-tiles {
286
+ display: grid;
287
+ grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
288
+ gap: 0.5rem;
289
+ margin: 0;
290
+ padding: 0;
291
+ border: 0;
292
+ }
293
+
294
+ .ctv-esign-tile {
295
+ display: flex;
296
+ align-items: center;
297
+ justify-content: center;
298
+ gap: 0.375rem;
299
+ min-height: 3.25rem;
300
+ padding: 0.5rem 0.75rem;
301
+ background-color: var(--theme-surface-1, #ffffff);
302
+ color: var(--theme-on-surface-1, #16181d);
303
+ border: 1px solid var(--theme-border-strong, hsla(225, 12%, 10%, 0.18));
304
+ border-radius: var(--theme-button-border-radius, 0.4rem);
305
+ text-align: center;
306
+ cursor: pointer;
307
+ }
308
+
309
+ .ctv-esign-tile-selected {
310
+ border-width: 2px;
311
+ border-color: var(--theme-primary, #2563eb);
312
+ padding: calc(0.5rem - 1px) calc(0.75rem - 1px);
313
+ }
314
+
315
+ .ctv-esign-tile-mark {
316
+ flex: none;
317
+ }
318
+ `;var CHECKBOX_RULES=`
319
+ .ctv-esign-check {
320
+ display: flex;
321
+ align-items: flex-start;
322
+ gap: 0.625rem;
323
+ }
324
+
325
+ .ctv-esign-check-input {
326
+ flex: none;
327
+ width: 1.125rem;
328
+ height: 1.125rem;
329
+ margin: 0.1875rem 0 0;
330
+ accent-color: var(--theme-primary, #2563eb);
331
+ cursor: pointer;
332
+ }
333
+
334
+ .ctv-esign-check-label {
335
+ flex: 1 1 auto;
336
+ min-width: 0;
337
+ line-height: 1.5;
338
+ cursor: pointer;
339
+ }
340
+
341
+ @media (max-width: 519.98px) {
342
+ .ctv-esign-check-input {
343
+ width: 24px;
344
+ height: 24px;
345
+ margin-top: 0;
346
+ }
347
+ }
348
+ `;var ESIGN_PLACEHOLDER_BOX="min(70dvh, 480px)";var SKELETON_RULES=`
349
+ .ctv-esign-loading {
350
+ display: block;
351
+ }
352
+
353
+ .ctv-esign-skeleton {
354
+ position: relative;
355
+ overflow: hidden;
356
+ width: 100%;
357
+ height: ${ESIGN_PLACEHOLDER_BOX};
358
+ margin: 0 0 0.625rem;
359
+ background-color: var(--theme-surface-2, #f2f2ee);
360
+ border-radius: var(--theme-button-border-radius, 0.4rem);
361
+ }
362
+
363
+ .ctv-esign-skeleton::before {
364
+ content: '';
365
+ position: absolute;
366
+ inset: 0;
367
+ background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.22) 50%, transparent 70%);
368
+ background-size: 200% 100%;
369
+ animation: ctv-esign-skeleton-sweep 1.4s ease-in-out infinite;
370
+ }
371
+
372
+ @keyframes ctv-esign-skeleton-sweep {
373
+ from {
374
+ background-position: 200% 0;
375
+ }
376
+ to {
377
+ background-position: -200% 0;
378
+ }
379
+ }
380
+
381
+ @media (prefers-reduced-motion: reduce) {
382
+ .ctv-esign-skeleton::before {
383
+ animation: none;
384
+ }
385
+ }
386
+ `;var FRAME_RULES=`
387
+ .ctv-esign-frame {
388
+ width: 100%;
389
+ border: 0;
390
+ }
391
+ `;var DARK_TOKENS=`
392
+ --theme-on-bg: #f3f3ef;
393
+ --theme-surface-1: #15171c;
394
+ --theme-on-surface-1: #f3f3ef;
395
+ --theme-on-surface-1-muted: hsla(40, 20%, 95%, 0.6);
396
+ --theme-surface-2: #1c1e24;
397
+ --theme-on-surface-2: #f3f3ef;
398
+ --theme-on-surface-2-muted: hsla(40, 20%, 95%, 0.6);
399
+ --theme-primary: #82a6f4;
400
+ --theme-primary-hover: #a8c1f7;
401
+ --theme-on-primary: #0b0c0f;
402
+ --theme-ring: #82a6f4;
403
+ --theme-success: #5fbe6d;
404
+ --theme-warning: #fbbf24;
405
+ --theme-danger: #fca5a5;
406
+ --theme-danger-hover: #f87171;
407
+ --theme-on-danger: #0b0c0f;
408
+ --theme-border: hsla(40, 20%, 95%, 0.08);
409
+ --theme-border-strong: hsla(40, 20%, 95%, 0.16);
410
+ `;var DARK_RULES=`
411
+ @media (prefers-color-scheme: dark) {
412
+ .ctv-esign:not([${ESIGN_MODE_ATTR}='light']) {
413
+ color-scheme: dark;
414
+ ${DARK_TOKENS} }
415
+ }
416
+
417
+ .ctv-esign[${ESIGN_MODE_ATTR}='dark'] {
418
+ color-scheme: dark;
419
+ ${DARK_TOKENS}}
420
+ `;var ESIGN_STYLESHEET=[SCOPE_RULES,PRIMITIVE_RULES,GATED_CONTROL_RULES,BAR_RULES,CALLOUT_RULES,MENU_RULES,TILE_RULES,CHECKBOX_RULES,SKELETON_RULES,FRAME_RULES,DARK_RULES].join("\n");var adoptedSheet=null;function supportsConstructableStyleSheets(){return typeof CSSStyleSheet==="function"&&typeof CSSStyleSheet.prototype.replaceSync==="function"&&"adoptedStyleSheets"in Document.prototype}function adoptConstructableStyleSheet(){try{if(adoptedSheet===null){adoptedSheet=new CSSStyleSheet;adoptedSheet.replaceSync(ESIGN_STYLESHEET);}if(!document.adoptedStyleSheets.includes(adoptedSheet)){document.adoptedStyleSheets=[...document.adoptedStyleSheets,adoptedSheet];}return true}catch{return false}}function injectLegacyStyleElement(){if(document.getElementById(STYLE_ELEMENT_ID)!==null)return;const style=document.createElement("style");style.id=STYLE_ELEMENT_ID;style.setAttribute(STYLE_MARKER_ATTR,"");style.textContent=ESIGN_STYLESHEET;document.head.appendChild(style);}function ensureEsignStyles(scope,theme){if(typeof document==="undefined")return;delivery=supportsConstructableStyleSheets()&&adoptConstructableStyleSheet()?"adopted":"element";if(delivery==="element")injectLegacyStyleElement();applyEmbedTheme(theme,scope);delete scope.dataset.theme;scope.setAttribute(ESIGN_MODE_ATTR,theme.colorMode);}function applyEsignFrameBox(frame){frame.className=ESIGN_FRAME_CLASS;if(delivery==="adopted")return;frame.style.width="100%";frame.style.border="0";}function createEsignLoaderChrome(d){const shell=d.container===null?null:d.container.ownerDocument.createElement("div");if(d.container!==null&&shell!==null){shell.setAttribute("data-checktiv-esign-shell","");d.container.appendChild(shell);}const statePanel=shell===null?null:createEsignStatePanel({container:shell,copy:d.copy,on:statePanelHandlers()});let chrome=null;let runtime=null;let downloadFailed=false;let downloadRemoved=false;let printAndSignStarted=false;let preparingStalled=false;let stallTimerArmed=false;function statePanelHandlers(){return {onReload:()=>d.reload(),onPrintAndSign:()=>{printAndSignStarted=true;runFirstDocumentAct();},onHelp:d.onHelp}}function runFirstDocumentAct(){const first=d.readCeremonyView().documents[0];if(runtime===null||first===void 0)return;void fetchAndDeliverDocument(runtime,first.documentId);}function render(){if(d.isDestroyed())return;const view=d.readCeremonyView();armStallTimer(view.state);statePanel?.render({state:view.state,owned:view.owned,polls:view.polls,hasDocuments:view.documents.length>0,hasFrame:view.hasFrame,preparingStalled,printAndSignStarted});chrome?.render({documents:view.documents,owned:view.owned,framePaintsTopBar:view.hasFrame&&view.state!=="withdraw",downloadFailed,downloadRemoved});if(shell===null)return;const painted=[...shell.children].some(el=>!el.hasAttribute(ESIGN_PANEL_SILENT_ATTR));shell.className=painted?"ctv-esign":"";if(!painted)return;ensureEsignStyles(shell,d.readTheme());}function armStallTimer(state){if(stallTimerArmed||state!=="preparing")return;stallTimerArmed=true;d.schedule(()=>{preparingStalled=true;render();},ESIGN_PREPARING_STALL_MS);}async function fetchAndDeliverDocument(rt,documentId){const stepId=d.getStepId();const container=d.container;if(stepId===null||container===null)return;downloadFailed=false;downloadRemoved=false;render();let res;try{res=await fetchEsignDocument(d.plane,stepId,documentId);}catch(err){warnEsignThrow("document download",err);downloadFailed=true;render();return}if(d.isDestroyed())return;if(isCredentialUnverifiable(res)){d.plane.fail("token_expired");return}if(res.ok&&(res.headers.get("content-type")??"").includes("application/json")){const body=await res.json().catch(()=>null);if(d.isDestroyed())return;downloadRemoved=rt.isEsignDocumentRemovedBody(body);downloadFailed=!downloadRemoved;render();return}let delivered=false;if(res.ok){const blobDeps={container,schedule:(cb,ms)=>d.schedule(cb,ms)};try{const blob=await res.blob();delivered=rt.saveBlobAsDownload(blob,rt.filenameFromDisposition(res.headers.get("content-disposition")),blobDeps);}catch(err){warnEsignThrow("document download",err);delivered=false;}}if(delivered)return;downloadFailed=true;render();}return {ensure(rt){if(chrome!==null||shell===null)return;runtime=rt;chrome=rt.createEsignChrome({container:shell,copy:d.copy,on:{onDownload:documentId=>void fetchAndDeliverDocument(rt,documentId)}});},render,runDocumentAct(documentId){if(runtime===null)return;void fetchAndDeliverDocument(runtime,documentId);},destroy(){chrome?.destroy();statePanel?.destroy();shell?.remove();}}}var ceremonyRuntimePromise=null;function loadCeremonyRuntime(){ceremonyRuntimePromise??(ceremonyRuntimePromise=import('./esign/ceremony-runtime.js').catch(error=>{ceremonyRuntimePromise=null;throw error}));return ceremonyRuntimePromise}function resolveEsignTheme(ctxTheme,opts){return resolveCaptureTheme(ctxTheme,opts)}function watchEsignHostTheme(deps){const teardowns=[];if(typeof deps.win.matchMedia==="function"){try{const query=deps.win.matchMedia("(prefers-color-scheme: dark)");if(typeof query.addEventListener==="function"){const onQuery=()=>deps.onChange();query.addEventListener("change",onQuery);teardowns.push(()=>query.removeEventListener("change",onQuery));}}catch{}}const ObserverCtor=deps.win.MutationObserver;if(typeof ObserverCtor==="function"){const observer=new ObserverCtor(()=>deps.onChange());observer.observe(deps.root,{attributes:true,attributeFilter:["data-theme"]});teardowns.push(()=>observer.disconnect());}return ()=>{while(teardowns.length>0)teardowns.pop()?.();}}function createEsign(ctx,opts){const fetchImpl=(input,init)=>(opts.fetchImpl??fetch)(input,init);const scheduler=opts.schedule??{set:(cb,ms)=>setTimeout(cb,ms),clear:handle=>clearTimeout(handle)};const emit=e=>opts.onEvent?.(e);let destroyed=false;let transport=null;let frame=null;let postToFrame=null;let sentTheme=null;let stopThemeWatch=null;let documentExtent=null;let readStartPosted=false;let stopReadWatch=null;let pollTimer=null;let cancelFrameDeadline=null;let resolvePoll=null;let bundle=null;let projection=null;let currentState=null;let resumeAttempted=false;let stepIdOfCurrentMount=null;let sessionIdOfCurrentMount=null;const container=resolveTarget(opts.target);let loaderOwnsCurrentSentence=false;let preparingPolls=0;const setState=(state,loaderOwnsSentence=false)=>{if(destroyed)return;currentState=state;loaderOwnsCurrentSentence=frame===null||loaderOwnsSentence;if(frame!==null){if(loaderOwnsSentence)frame.setAttribute("inert","");else frame.removeAttribute("inert");frame.style.opacity=loaderOwnsSentence?"0.5":"";}loaderChrome.render();emit({type:"checktiv.esign.state",state});};const fail=code=>{if(destroyed)return;emit(createEsignErrorEvent(code));setState(ESIGN_FAILURE_STATE[code],true);};const failFromStatus=(httpStatus,fallback)=>{fail(mapHttpStatusToError(httpStatus)==="token_expired"?"token_expired":fallback);};const plane={ctx,fetchImpl,fail,failFromStatus,isDestroyed:()=>destroyed,refuseAttempt};const loaderChrome=createEsignLoaderChrome({container,copy:opts.copy,plane,getStepId:()=>stepIdOfCurrentMount,isDestroyed:()=>destroyed,schedule:(cb,ms)=>void scheduler.set(cb,ms),reload:()=>container?.ownerDocument.defaultView?.location.reload(),onHelp:opts.onRequestHelp,readTheme:()=>resolveEsignTheme(ctx.theme),readCeremonyView:()=>({state:currentState,documents:bundle?.documents??[],owned:loaderOwnsCurrentSentence,polls:preparingPolls,hasFrame:frame!==null})});void(async()=>{try{await load();}catch(err){warnEsignThrow("load sequence",err);fail("sdk_load_failed");}})();async function load(){setState("preparing");void loadCeremonyRuntime().catch(()=>void 0);const identity=await resolveIdentity();if(destroyed)return;if(identity===null){return}const{sessionId,stepId}=identity;stepIdOfCurrentMount=stepId;sessionIdOfCurrentMount=sessionId;const rt=await loadCeremonyRuntime();if(destroyed)return;loaderChrome.ensure(rt);const first=await withBackoff(()=>postCeremonyEvent(plane,rt,stepId,rt.buildEsignCeremonyEventBody({type:"disclosure.presented",...ctx.locale.length>=2?{disclosureLocale:ctx.locale}:{}},{locale:ctx.locale})));if(destroyed||first===null)return;projection=first;if(isTerminalEnvelopeStatus(projection.status)){await settleTerminal(rt,stepId,TERMINAL_STATUS_TO_STATE[projection.status]);return}if(projection.consentWithdrawnAt!==null){await settleTerminal(rt,stepId,"terminal_withdrawn");return}const loaded=await withBackoff(()=>fetchBundleOnce(plane,rt,stepId));if(destroyed||loaded===null)return;bundle=loaded;loaderChrome.render();const mint=await mintSignContext(plane,stepId);if(destroyed||mint===null)return;mountFrame(rt,mint,sessionId,stepId);}async function resolveIdentity(){if(opts.session!==void 0)return opts.session;const resolution=await resolveSession(ctx,fetchImpl);switch(resolution.kind){case "ok":return {sessionId:resolution.session.sessionId,stepId:resolution.session.stepId};case "parked":fail("session_parked");return null;case "wrong_token":warnWrongTokenPlane();fail("wrong_token_type");return null;case "unresolved":case "nothing_to_render":fail("session_expired");return null;default:return assertNever(resolution)}}async function withBackoff(attempt,exhaustedCode="upload_failed"){for(let i=0;i<ESIGN_PREPARING_MAX_ATTEMPTS;i+=1){if(destroyed)return null;const outcome=await attempt();if(outcome.kind==="ok")return outcome.value;if(outcome.kind==="failed")return null;preparingPolls+=1;setState("preparing");const alive=await sleep(esignPreparingDelayMs(outcome.retryAfterMs));if(!alive)return null}fail(exhaustedCode);return null}function mountFrame(rt,mint,sessionId,stepId){const view=container?.ownerDocument.defaultView??null;if(container===null||view===null){fail("sdk_load_failed");return}transport=rt.wireEsignTransport({win:view,embedOrigin:mint.embedOrigin,getFrameWindow:()=>frame?.contentWindow??null,handlers:{onReady:post=>{clearFrameDeadline();if(bundle===null||projection===null)return;sentTheme=resolveEsignTheme(ctx.theme);post({type:"esign:init",protocolVersion:rt.ESIGN_PROTOCOL_VERSION,bundle,copy:opts.copy??{},projection,theme:sentTheme});loaderOwnsCurrentSentence=false;loaderChrome.render();emit({type:"checktiv.esign.ready"});},onState:message=>{clearFrameDeadline();if(frame!==null&&frame.hasAttribute("inert"))return;if(isEsignFrameFatalState(message.state)){teardownFrame();setState(message.state);return}currentState=message.state;loaderOwnsCurrentSentence=false;loaderChrome.render();emit({type:"checktiv.esign.state",state:message.state});},onEvent:(message,post)=>{void(async()=>{const outcome=await postCeremonyEvent(plane,rt,stepId,message.event);if(destroyed)return;if(outcome.kind!=="ok"){post({type:"esign:event_failed",protocolVersion:rt.ESIGN_PROTOCOL_VERSION,event:message.event.type});return}projection=outcome.value;post({type:"esign:projection",protocolVersion:rt.ESIGN_PROTOCOL_VERSION,projection:outcome.value});})();},onSubmit:message=>{void submitStep(rt,sessionId,stepId,message.body);},onResize:message=>{if(frame===null)return;frame.style.minHeight="";frame.style.height=`${Math.ceil(message.height)}px`;},onConsentAct:(message,post)=>{void(async()=>{const result=await postConsentAct(plane,rt,stepId,message.action);if(destroyed)return;post({type:"esign:consent_result",protocolVersion:rt.ESIGN_PROTOCOL_VERSION,result});})();},onScrollRequest:message=>{scrollFrameOffsetIntoView(message.offsetTop);},onDocumentAct:message=>{loaderChrome.runDocumentAct(message.documentId);},onDocumentExtent:message=>{documentExtent=message;if(stopReadWatch===null){const observe=()=>reportReadProgress(rt.ESIGN_PROTOCOL_VERSION,true);view.addEventListener("scroll",observe,{capture:true,passive:true});stopReadWatch=()=>view.removeEventListener("scroll",observe,{capture:true});}reportReadProgress(rt.ESIGN_PROTOCOL_VERSION,false);},onProtocolMismatch:()=>{teardownFrame();fail("protocol_mismatch");}}});postToFrame=message=>{const target=frame?.contentWindow??null;if(target===null)return;target.postMessage(message,mint.embedOrigin);};stopThemeWatch?.();stopThemeWatch=watchEsignHostTheme({win:view,root:container.ownerDocument.documentElement,onChange:()=>{if(destroyed)return;const next=resolveEsignTheme(ctx.theme);if(sentTheme===null||sentTheme.colorMode===next.colorMode)return;sentTheme=next;postToFrame?.({type:"esign:theme",protocolVersion:rt.ESIGN_PROTOCOL_VERSION,theme:next});}});const el=container.ownerDocument.createElement("iframe");el.src=`${mint.embedOrigin}/esign/sign?ctx=${encodeURIComponent(mint.contextToken)}`;el.title=resolveEsignFrameTitle(opts.copy);el.setAttribute("lang",mint.disclosureLocale);applyEsignFrameBox(el);el.style.minHeight=ESIGN_PLACEHOLDER_BOX;frame=el;container.appendChild(el);loaderChrome.render();const deadline=view.setTimeout(onFrameSilent,ESIGN_FRAME_ANNOUNCE_TIMEOUT_MS);cancelFrameDeadline=()=>view.clearTimeout(deadline);}function scrollFrameOffsetIntoView(offsetTop){const el=frame;const view=el?.ownerDocument.defaultView??null;if(el===null||view===null)return;const port=nearestScrollableAncestor(el,view);const portTop=port===null?0:port.getBoundingClientRect().top;const top=el.getBoundingClientRect().top+offsetTop-portTop-ESIGN_SCROLL_TARGET_MARGIN_PX;const behavior=prefersReducedMotion(view)?"auto":"smooth";if(port===null)view.scrollBy({top,behavior});else port.scrollBy({top,behavior});}function reportReadProgress(protocolVersion,fromScroll){const extent=documentExtent;const el=frame;const view=el?.ownerDocument.defaultView??null;if(extent===null||el===null||view===null)return;const port=nearestScrollableAncestor(el,view);const fold=port===null?view.innerHeight:port.getBoundingClientRect().bottom;const reachedEnd=el.getBoundingClientRect().top+extent.endOffsetTop<=fold;if(reachedEnd)documentExtent=null;else if(!fromScroll||readStartPosted)return;else readStartPosted=true;postToFrame?.({type:"esign:read_progress",protocolVersion,documentId:extent.documentId,reachedEnd});}function clearFrameDeadline(){cancelFrameDeadline?.();cancelFrameDeadline=null;}function onFrameSilent(){cancelFrameDeadline=null;if(destroyed)return;teardownFrame();emit(createEsignErrorEvent("sdk_load_failed"));setState("frame_blocked",true);}async function submitStep(rt,sessionId,stepId,body){const accepted=await withBackoff(()=>submitOnce(plane,rt,sessionId,stepId,body),"submit_failed");if(destroyed||accepted===null)return;const outcome=body.declineReason!==void 0?"declined":"signed";teardownFrame();setState(outcome==="declined"?"terminal_declined":"terminal_signed");emit({type:"checktiv.esign.submitted",sessionId,outcome});}async function refuseAttempt(rt,res,stepId,fallback){const refusal=rt.readEsignRefusal(await readJson(res));if(refusal===null){failFromStatus(res.status,fallback);return {kind:"failed"}}const{disposition,state}=rt.ESIGN_REFUSAL_STATE[refusal.code];switch(disposition){case "retry":return {kind:"pending",retryAfterMs:refusal.retryAfterMs??retryAfterMsFromHeader(res)};case "resume":void repairResume(rt,stepId);return {kind:"failed"};case "blocked":setState(state);postToFrame?.({type:"esign:blocked",protocolVersion:rt.ESIGN_PROTOCOL_VERSION,state});return {kind:"failed"};case "withdrawn":case "concluded":teardownFrame();void settleTerminal(rt,stepId,state);return {kind:"failed"};case "upgrade":teardownFrame();emit(createEsignErrorEvent("protocol_mismatch"));setState(state);return {kind:"failed"};default:return assertNeverDisposition(disposition)}}async function repairResume(rt,stepId){if(destroyed)return;teardownFrame();if(resumeAttempted){setState("conflict");return}resumeAttempted=true;setState("preparing");const sessionId=sessionIdOfCurrentMount;const refreshed=await fetchBundleOnce(plane,rt,stepId,true);if(destroyed)return;if(refreshed.kind!=="ok"||sessionId===null){setState("conflict");return}bundle=refreshed.value;loaderChrome.render();const next=await postCeremonyEvent(plane,rt,stepId,rt.buildEsignCeremonyEventBody({type:"disclosure.presented",...ctx.locale.length>=2?{disclosureLocale:ctx.locale}:{}},{locale:ctx.locale}));if(destroyed||next.kind!=="ok")return;projection=next.value;const mint=await mintSignContext(plane,stepId);if(destroyed||mint===null)return;mountFrame(rt,mint,sessionId,stepId);}async function settleTerminal(rt,stepId,state){setState(state);const loaded=await fetchBundleOnce(plane,rt,stepId,true);if(destroyed||loaded.kind!=="ok")return;bundle=loaded.value;loaderChrome.render();}function teardownFrame(){clearFrameDeadline();transport?.teardown();transport=null;frame?.remove();frame=null;postToFrame=null;stopThemeWatch?.();stopThemeWatch=null;stopReadWatch?.();stopReadWatch=null;documentExtent=null;readStartPosted=false;sentTheme=null;}function sleep(ms){return new Promise(resolve=>{resolvePoll=resolve;pollTimer=scheduler.set(()=>{pollTimer=null;resolvePoll=null;resolve(!destroyed);},ms);})}return {destroy(){destroyed=true;clearFrameDeadline();if(pollTimer!==null){scheduler.clear(pollTimer);pollTimer=null;}resolvePoll?.(false);resolvePoll=null;teardownFrame();loaderChrome.destroy();}}}function assertNeverDisposition(disposition){throw new Error(`Unhandled esign refusal disposition: ${JSON.stringify(disposition)}`)}function resolveTarget(target){if(typeof target!=="string")return target;if(typeof document==="undefined")return null;return document.querySelector(target)}function prefersReducedMotion(view){if(typeof view.matchMedia!=="function")return false;try{return view.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return false}}function nearestScrollableAncestor(el,view){let node=el.parentElement;while(node!==null&&node!==node.ownerDocument.body){const overflowY=view.getComputedStyle(node).overflowY;if((overflowY==="auto"||overflowY==="scroll")&&node.scrollHeight>node.clientHeight){return node}node=node.parentElement;}return null}registerModule("esign",createEsign);
421
+
422
+ export { createEsign, parseEsignMint, parseEsignPending };
package/dist/fraud.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { g as ChecktivFraudEvent, F as FraudHandle, l as FraudMountOptions, X as createFraud } from './api-BrQqQbGK.js';
2
- import './machine-BhPiYmOR.js';
3
- import './copy-CEILzVXc.js';
1
+ export { h as ChecktivFraudEvent, F as FraudHandle, p as FraudMountOptions, aG as createFraud } from './api-EY_fOZm-.js';
2
+ import './machine-DXxarDcC.js';
3
+ import './copy-D6Sd0BIe.js';
4
4
  import './copy-DCeQ4JKx.js';
package/dist/fraud.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import { registerModule } from './chunk-GFHNOZVO.js';
2
- import { createChecktivError } from './chunk-7GP5REM7.js';
3
- import { resolveSession, warnWrongTokenPlane } from './chunk-523TT3PD.js';
2
+ import { resolveSession, warnWrongTokenPlane } from './chunk-YK4WW4LX.js';
3
+ import './chunk-IQKHRPJR.js';
4
4
  import { assertNever } from './chunk-UBQTPS5J.js';
5
- import { withTokenRetry } from './chunk-S2OOEDJS.js';
5
+ import { createChecktivError, withTokenRetry } from './chunk-C7GRMEYT.js';
6
6
  import { TELEMETRY_PATH, dataPlaneHeaders } from './chunk-HFQJYEGZ.js';
7
- import './chunk-IQKHRPJR.js';
8
7
  import './chunk-QFA3K5ZV.js';
9
8
  import { __publicField } from './chunk-AIK7CDV6.js';
10
9
 
11
- var MAX_STEPS=50;var MAX_STEP_SECONDS=86400;var MAX_STEP_PASTE_COUNT=1e4;var MAX_STEP_ID_LEN=80;function defaultNow(){return typeof performance!=="undefined"&&typeof performance.now==="function"?performance.now():Date.now()}var BehavioralTracker=class{constructor(now=defaultNow){__publicField(this,"steps",new Map);__publicField(this,"activeStepId",null);__publicField(this,"now");this.now=now;}get currentStepId(){return this.activeStepId}enter(rawStepId){const stepId=this.boundStepId(rawStepId);if(stepId===null)return;this.closeActiveInterval();const existing=this.steps.get(stepId);if(existing){existing.enteredAtMs=this.now();}else {this.steps.set(stepId,{stepId,enteredAtMs:this.now(),accumulatedMs:0,pasteCount:0});}this.activeStepId=stepId;}recordPaste(rawStepId){const target=rawStepId===void 0?this.activeStepId:this.boundStepId(rawStepId);if(target===null)return;const existing=this.steps.get(target);if(existing){if(existing.pasteCount<MAX_STEP_PASTE_COUNT)existing.pasteCount+=1;return}this.steps.set(target,{stepId:target,enteredAtMs:null,accumulatedMs:0,pasteCount:1});}snapshot(){this.closeActiveInterval();if(this.activeStepId!==null){const active=this.steps.get(this.activeStepId);if(active)active.enteredAtMs=this.now();}const out=[];for(const acc of this.steps.values()){if(out.length>=MAX_STEPS)break;out.push({stepId:acc.stepId,seconds:this.boundSeconds(acc.accumulatedMs),pasteCount:acc.pasteCount});}return out}closeActiveInterval(){if(this.activeStepId===null)return;const active=this.steps.get(this.activeStepId);if(!active||active.enteredAtMs===null)return;const delta=this.now()-active.enteredAtMs;if(delta>0)active.accumulatedMs+=delta;active.enteredAtMs=null;}boundStepId(rawStepId){if(typeof rawStepId!=="string")return null;const trimmed=rawStepId.trim();if(trimmed.length===0)return null;return trimmed.length>MAX_STEP_ID_LEN?trimmed.slice(0,MAX_STEP_ID_LEN):trimmed}boundSeconds(ms){const seconds=ms/1e3;if(!Number.isFinite(seconds)||seconds<0)return 0;return seconds>MAX_STEP_SECONDS?MAX_STEP_SECONDS:seconds}};var DEVICE_MODEL_HINT_MAX=120;function readBoundedString(value,max){if(typeof value!=="string")return null;const trimmed=value.trim();if(trimmed.length===0)return null;return trimmed.length>max?trimmed.slice(0,max):trimmed}function readTimezone(){try{const tz=Intl.DateTimeFormat().resolvedOptions().timeZone;return readBoundedString(tz,64)}catch{return null}}function readMaxTouchPoints(nav){const raw=nav.maxTouchPoints;if(typeof raw!=="number"||!Number.isFinite(raw))return 0;const floored=Math.floor(raw);if(floored<0)return 0;return floored>512?512:floored}function readPluginCount(nav){const plugins=nav.plugins;const len=plugins&&typeof plugins.length==="number"?plugins.length:0;if(!Number.isFinite(len)||len<0)return 0;return len>256?256:Math.floor(len)}function readDeviceModelHint(nav){const uaData=nav.userAgentData;if(typeof uaData!=="object"||uaData===null)return null;return readBoundedString(uaData.platform,DEVICE_MODEL_HINT_MAX)}function readBehaviorTraits(nav=navigator){return {webdriver:nav.webdriver===true,maxTouchPoints:readMaxTouchPoints(nav),timezone:readTimezone(),pluginCount:readPluginCount(nav),deviceModelHint:readDeviceModelHint(nav)}}var BEHAVIOR_CAPTURED_EVENT="kyc.fraud.behavior_captured";var MAX_SEGMENTS=4;var MAX_SEGMENT_STEPS=50;var DEFAULT_SUBMIT_TIMEOUT_MS=2500;function defaultSleep(ms){return new Promise(resolve=>setTimeout(resolve,ms))}function createGatedTransport(inner,opts){const sleep=opts.sleep??defaultSleep;return {async postTelemetry(events){for(let attempt=0;attempt<=opts.maxRetries;attempt+=1){if(attempt>0)await sleep(opts.retryDelayMs).catch(()=>{});try{const res=await inner.postTelemetry(events);if(res.ok)return}catch{}}console.warn("[fraud-agent] flush failed");}}}function withTimeout(promise,ms){return new Promise(resolve=>{let settled=false;const done=()=>{if(settled)return;settled=true;resolve();};const timer=setTimeout(done,ms);void promise.finally(()=>{clearTimeout(timer);done();});})}function boundSegmentSteps(steps){return steps.length>MAX_SEGMENT_STEPS?steps.slice(0,MAX_SEGMENT_STEPS):steps}function createFraudAgent(options){const{transport,sessionId,pasteListenerTarget,now,submitTimeoutMs=DEFAULT_SUBMIT_TIMEOUT_MS}=options;const tracker=new BehavioralTracker(now);let parentTraits=null;const traits=()=>parentTraits??(parentTraits=readBehaviorTraits());const embedSegments=[];const pasteTarget=pasteListenerTarget===void 0?typeof document!=="undefined"?document:null:pasteListenerTarget;const onPasteEvent=()=>{tracker.recordPaste();};if(pasteTarget){pasteTarget.addEventListener("paste",onPasteEvent,{capture:true,passive:true});}function buildPayload(){const steps=tracker.snapshot();const parentTraitsValue=traits();const payload={steps,traits:parentTraitsValue};if(embedSegments.length>0){payload.segments=[{surface:"parent",steps,traits:parentTraitsValue},...embedSegments.slice(0,MAX_SEGMENTS-1).map(seg=>({surface:"embed",steps:boundSegmentSteps(seg.steps),traits:seg.traits}))];}return payload}return {onStepEnter(stepId){tracker.enter(stepId);},onPaste(stepId){tracker.recordPaste(stepId);},mergeEmbedSegment(segment){if(embedSegments.length>=MAX_SEGMENTS-1)return;embedSegments.push({steps:boundSegmentSteps(segment.steps),traits:segment.traits});},async onSubmit(){if(sessionId===void 0)return;const payload=buildPayload();const activeStepId=tracker.currentStepId;const post=(async()=>{try{await transport.postTelemetry([{event:BEHAVIOR_CAPTURED_EVENT,sessionId,...activeStepId!==null?{stepId:activeStepId}:{},ts:Date.now(),payload}]);}catch{}})();await withTimeout(post,submitTimeoutMs);},dispose(){if(pasteTarget){pasteTarget.removeEventListener("paste",onPasteEvent,{capture:true});}}}}var TELEMETRY_FLUSH_MAX_RETRIES=1;var TELEMETRY_FLUSH_RETRY_DELAY_MS=400;function createTelemetryTransport(ctx,fetchImpl){const url=ctx.apiBaseOrigin+TELEMETRY_PATH;return {postTelemetry(events){return withTokenRetry(ctx.tokens,token=>fetchImpl(url,{method:"POST",headers:dataPlaneHeaders(ctx,token,{withJsonBody:true}),body:JSON.stringify({events})}),result=>result?.status===401)}}}function createFraud(ctx,opts){const fetchImpl=opts.fetchImpl??fetch;const transport=createGatedTransport(createTelemetryTransport(ctx,fetchImpl),{maxRetries:TELEMETRY_FLUSH_MAX_RETRIES,retryDelayMs:TELEMETRY_FLUSH_RETRY_DELAY_MS});let destroyed=false;let agent=null;void Promise.resolve().then(async()=>{const granted=await opts.onConsent();if(destroyed||!granted)return;const resolution=await resolveSession(ctx,fetchImpl);if(destroyed)return;let session;switch(resolution.kind){case "ok":session=resolution.session;break;case "wrong_token":warnWrongTokenPlane();opts.onEvent?.({type:"checktiv.fraud.error",error:createChecktivError("wrong_token_type")});return;case "unresolved":opts.onEvent?.({type:"checktiv.fraud.error",error:createChecktivError("session_expired")});return;case "nothing_to_render":return;default:return assertNever(resolution)}agent=createFraudAgent({transport,sessionId:session.sessionId});opts.onEvent?.({type:"checktiv.fraud.started"});}).catch(()=>{});return {destroy(){destroyed=true;agent?.dispose();agent=null;}}}registerModule("fraud",createFraud);
10
+ var MAX_STEPS=50;var MAX_STEP_SECONDS=86400;var MAX_STEP_PASTE_COUNT=1e4;var MAX_STEP_ID_LEN=80;function defaultNow(){return typeof performance!=="undefined"&&typeof performance.now==="function"?performance.now():Date.now()}var BehavioralTracker=class{constructor(now=defaultNow){__publicField(this,"steps",new Map);__publicField(this,"activeStepId",null);__publicField(this,"now");this.now=now;}get currentStepId(){return this.activeStepId}enter(rawStepId){const stepId=this.boundStepId(rawStepId);if(stepId===null)return;this.closeActiveInterval();const existing=this.steps.get(stepId);if(existing){existing.enteredAtMs=this.now();}else {this.steps.set(stepId,{stepId,enteredAtMs:this.now(),accumulatedMs:0,pasteCount:0});}this.activeStepId=stepId;}recordPaste(rawStepId){const target=rawStepId===void 0?this.activeStepId:this.boundStepId(rawStepId);if(target===null)return;const existing=this.steps.get(target);if(existing){if(existing.pasteCount<MAX_STEP_PASTE_COUNT)existing.pasteCount+=1;return}this.steps.set(target,{stepId:target,enteredAtMs:null,accumulatedMs:0,pasteCount:1});}snapshot(){this.closeActiveInterval();if(this.activeStepId!==null){const active=this.steps.get(this.activeStepId);if(active)active.enteredAtMs=this.now();}const out=[];for(const acc of this.steps.values()){if(out.length>=MAX_STEPS)break;out.push({stepId:acc.stepId,seconds:this.boundSeconds(acc.accumulatedMs),pasteCount:acc.pasteCount});}return out}closeActiveInterval(){if(this.activeStepId===null)return;const active=this.steps.get(this.activeStepId);if(!active||active.enteredAtMs===null)return;const delta=this.now()-active.enteredAtMs;if(delta>0)active.accumulatedMs+=delta;active.enteredAtMs=null;}boundStepId(rawStepId){if(typeof rawStepId!=="string")return null;const trimmed=rawStepId.trim();if(trimmed.length===0)return null;return trimmed.length>MAX_STEP_ID_LEN?trimmed.slice(0,MAX_STEP_ID_LEN):trimmed}boundSeconds(ms){const seconds=ms/1e3;if(!Number.isFinite(seconds)||seconds<0)return 0;return seconds>MAX_STEP_SECONDS?MAX_STEP_SECONDS:seconds}};var DEVICE_MODEL_HINT_MAX=120;function readBoundedString(value,max){if(typeof value!=="string")return null;const trimmed=value.trim();if(trimmed.length===0)return null;return trimmed.length>max?trimmed.slice(0,max):trimmed}function readTimezone(){try{const tz=Intl.DateTimeFormat().resolvedOptions().timeZone;return readBoundedString(tz,64)}catch{return null}}function readMaxTouchPoints(nav){const raw=nav.maxTouchPoints;if(typeof raw!=="number"||!Number.isFinite(raw))return 0;const floored=Math.floor(raw);if(floored<0)return 0;return floored>512?512:floored}function readPluginCount(nav){const plugins=nav.plugins;const len=plugins&&typeof plugins.length==="number"?plugins.length:0;if(!Number.isFinite(len)||len<0)return 0;return len>256?256:Math.floor(len)}function readDeviceModelHint(nav){const uaData=nav.userAgentData;if(typeof uaData!=="object"||uaData===null)return null;return readBoundedString(uaData.platform,DEVICE_MODEL_HINT_MAX)}function readBehaviorTraits(nav=navigator){return {webdriver:nav.webdriver===true,maxTouchPoints:readMaxTouchPoints(nav),timezone:readTimezone(),pluginCount:readPluginCount(nav),deviceModelHint:readDeviceModelHint(nav)}}var BEHAVIOR_CAPTURED_EVENT="kyc.fraud.behavior_captured";var MAX_SEGMENTS=4;var MAX_SEGMENT_STEPS=50;var DEFAULT_SUBMIT_TIMEOUT_MS=2500;function defaultSleep(ms){return new Promise(resolve=>setTimeout(resolve,ms))}function createGatedTransport(inner,opts){const sleep=opts.sleep??defaultSleep;return {async postTelemetry(events){for(let attempt=0;attempt<=opts.maxRetries;attempt+=1){if(attempt>0)await sleep(opts.retryDelayMs).catch(()=>{});try{const res=await inner.postTelemetry(events);if(res.ok)return}catch{}}console.warn("[fraud-agent] flush failed");}}}function withTimeout(promise,ms){return new Promise(resolve=>{let settled=false;const done=()=>{if(settled)return;settled=true;resolve();};const timer=setTimeout(done,ms);void promise.finally(()=>{clearTimeout(timer);done();});})}function boundSegmentSteps(steps){return steps.length>MAX_SEGMENT_STEPS?steps.slice(0,MAX_SEGMENT_STEPS):steps}function createFraudAgent(options){const{transport,sessionId,pasteListenerTarget,now,submitTimeoutMs=DEFAULT_SUBMIT_TIMEOUT_MS}=options;const tracker=new BehavioralTracker(now);let parentTraits=null;const traits=()=>parentTraits??(parentTraits=readBehaviorTraits());const embedSegments=[];const pasteTarget=pasteListenerTarget===void 0?typeof document!=="undefined"?document:null:pasteListenerTarget;const onPasteEvent=()=>{tracker.recordPaste();};if(pasteTarget){pasteTarget.addEventListener("paste",onPasteEvent,{capture:true,passive:true});}function buildPayload(){const steps=tracker.snapshot();const parentTraitsValue=traits();const payload={steps,traits:parentTraitsValue};if(embedSegments.length>0){payload.segments=[{surface:"parent",steps,traits:parentTraitsValue},...embedSegments.slice(0,MAX_SEGMENTS-1).map(seg=>({surface:"embed",steps:boundSegmentSteps(seg.steps),traits:seg.traits}))];}return payload}return {onStepEnter(stepId){tracker.enter(stepId);},onPaste(stepId){tracker.recordPaste(stepId);},mergeEmbedSegment(segment){if(embedSegments.length>=MAX_SEGMENTS-1)return;embedSegments.push({steps:boundSegmentSteps(segment.steps),traits:segment.traits});},async onSubmit(){if(sessionId===void 0)return;const payload=buildPayload();const activeStepId=tracker.currentStepId;const post=(async()=>{try{await transport.postTelemetry([{event:BEHAVIOR_CAPTURED_EVENT,sessionId,...activeStepId!==null?{stepId:activeStepId}:{},ts:Date.now(),payload}]);}catch{}})();await withTimeout(post,submitTimeoutMs);},dispose(){if(pasteTarget){pasteTarget.removeEventListener("paste",onPasteEvent,{capture:true});}}}}var TELEMETRY_FLUSH_MAX_RETRIES=1;var TELEMETRY_FLUSH_RETRY_DELAY_MS=400;function createTelemetryTransport(ctx,fetchImpl){const url=ctx.apiBaseOrigin+TELEMETRY_PATH;return {postTelemetry(events){return withTokenRetry(ctx.tokens,token=>fetchImpl(url,{method:"POST",headers:dataPlaneHeaders(ctx,token,{withJsonBody:true}),body:JSON.stringify({events})}))}}}function createFraud(ctx,opts){const fetchImpl=opts.fetchImpl??fetch;const transport=createGatedTransport(createTelemetryTransport(ctx,fetchImpl),{maxRetries:TELEMETRY_FLUSH_MAX_RETRIES,retryDelayMs:TELEMETRY_FLUSH_RETRY_DELAY_MS});let destroyed=false;let agent=null;void Promise.resolve().then(async()=>{const granted=await opts.onConsent();if(destroyed||!granted)return;const resolution=await resolveSession(ctx,fetchImpl);if(destroyed)return;let session;switch(resolution.kind){case "ok":session=resolution.session;break;case "wrong_token":warnWrongTokenPlane();opts.onEvent?.({type:"checktiv.fraud.error",error:createChecktivError("wrong_token_type")});return;case "unresolved":opts.onEvent?.({type:"checktiv.fraud.error",error:createChecktivError("session_expired")});return;case "parked":opts.onEvent?.({type:"checktiv.fraud.error",error:createChecktivError("session_parked")});return;case "nothing_to_render":return;default:return assertNever(resolution)}agent=createFraudAgent({transport,sessionId:session.sessionId});opts.onEvent?.({type:"checktiv.fraud.started"});}).catch(()=>{});return {destroy(){destroyed=true;agent?.dispose();agent=null;}}}registerModule("fraud",createFraud);
12
11
 
13
12
  export { createFraud };
@@ -1,8 +1,8 @@
1
- import { S as SdkCrossDeviceStatusResponse } from '../machine-BhPiYmOR.js';
2
- import { J as SubstrateContext, k as CrossDeviceHandoffHook, h as ChecktivIdvEvent } from '../api-BrQqQbGK.js';
1
+ import { S as SdkCrossDeviceStatusResponse } from '../machine-DXxarDcC.js';
2
+ import { Q as SubstrateContext, l as CrossDeviceHandoffHook, i as ChecktivIdvEvent } from '../api-EY_fOZm-.js';
3
3
  import { C as CrossDeviceCopy } from '../copy-DCeQ4JKx.js';
4
4
  import { CrossDevicePanelProps, CrossDeviceHandle } from '../cross-device.js';
5
- import '../copy-CEILzVXc.js';
5
+ import '../copy-D6Sd0BIe.js';
6
6
 
7
7
  interface ManagedCrossDeviceParams {
8
8
  ctx: SubstrateContext;