Skip to content
Open
Show file tree
Hide file tree
Changes from 166 commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
9914a05
revert: restore ui-refresh to clean state before bad merges
ayinloya Apr 14, 2026
cda9679
revert: restore ui-refresh to pre-feature state for clean PR history
ayinloya Apr 14, 2026
9704014
feat(web-components): new document capture instructions screen
ayinloya Apr 14, 2026
5dfee2d
feat: add manual workflow_dispatch trigger with skip_tests option to …
ayinloya Apr 14, 2026
bb91bf5
chore(deps-dev): bump vite from 7.2.2 to 7.3.2 in the npm_and_yarn gr…
dependabot[bot] Apr 14, 2026
aeb2364
Merge branch 'ui-refresh' into new-doc-instruction-screen
ayinloya Apr 14, 2026
5bbac17
fix(web-components): enable shadow DOM for DocumentCaptureInstructions
ayinloya Apr 14, 2026
024bbd4
fix(web-components): add take-photo id to start button for test compat
ayinloya Apr 14, 2026
aaba9e8
feat(web-components): update Navigation to match new design (#592)
ayinloya Apr 15, 2026
63cad07
Rework capture screen
ayinloya Apr 28, 2026
84391ee
use document type shimmer as guide box
ayinloya Apr 28, 2026
367186d
Apply colour changes to outer of shimmer when detection changes
ayinloya Apr 28, 2026
3eea97c
Add auto capture component to docv for testing
ayinloya Apr 29, 2026
850a267
fix host navigation
ayinloya Apr 29, 2026
0a78ed8
Merge branch 'main' into new-doc-instruction-screen
ayinloya Apr 29, 2026
7ac76f0
Merge branch 'new-doc-instruction-screen' into document-auto-capture-…
ayinloya Apr 29, 2026
3913d09
Merge branch 'main' into ui-refresh
ayinloya Apr 29, 2026
5e48277
Merge branch 'ui-refresh' into document-auto-capture-rework
ayinloya Apr 30, 2026
c77697b
show rotated view on mobile and tablet only
ayinloya Apr 30, 2026
cea2b8d
fix(document-auto-capture): place buttons at bottom when UI isn't rot…
ayinloya Apr 30, 2026
cd32f17
Add sync-roi-to-guide to use guide as region of interest
ayinloya May 4, 2026
c6e74ac
Fix back id not getting the doctype
ayinloya May 4, 2026
59f196e
Add cropped preview
ayinloya May 4, 2026
3470824
Add a separate param for preview padding
ayinloya May 4, 2026
b241ced
Reduce the max width to 480 on desktop/laptop
ayinloya May 5, 2026
9ecc00b
Change how fill percentage is calculated
ayinloya May 5, 2026
70b144f
Complete auto capture mode support
ayinloya May 6, 2026
2475372
feat(web-components): new document capture instructions screen (#590)
ayinloya May 6, 2026
52b21e3
Merge branch 'ui-refresh' into document-auto-capture-rework
ayinloya May 7, 2026
1614f87
Fix lint
ayinloya May 7, 2026
5f6b928
Lint: fix
ayinloya May 7, 2026
4dd8142
remove dead code
ayinloya May 7, 2026
b9b6327
Fix ssl localhost
ayinloya May 7, 2026
fab82c5
Fix rules
ayinloya May 7, 2026
49845c6
fix lint
ayinloya May 7, 2026
da1194b
Merge branch 'main' into ui-refresh
ayinloya May 7, 2026
ff5e53e
Merge branch 'ui-refresh' into document-auto-capture-rework
ayinloya May 7, 2026
f5b6e44
rework ROI calculation and alerts
ayinloya May 9, 2026
e0e2980
Fix double rotation for manual capture
ayinloya May 9, 2026
30a39d9
reformat
ayinloya May 11, 2026
668d845
fix(document-auto-capture): type useCardDetection without ts-nocheck
ayinloya May 11, 2026
331c569
Merge branch 'main' into ui-refresh
ayinloya May 11, 2026
c457b59
Update capture and gallery botton icons
ayinloya May 11, 2026
0e24520
Merge branch 'ui-refresh' into document-auto-capture-rework
ayinloya May 11, 2026
8db8a5d
fix(document-auto-capture): crop preview/submitted image when UI is r…
ayinloya May 11, 2026
98176c4
Fix passport capture
ayinloya May 13, 2026
c16d6b0
Merge origin/main into document-auto-capture-rework
ayinloya May 15, 2026
420dacf
Merge branch 'main' into document-auto-capture-rework
ayinloya May 18, 2026
a5e6e58
iFix ROI for passports
ayinloya May 20, 2026
705a9d3
Merge branch 'main' into document-auto-capture-rework
ayinloya May 21, 2026
3f87bbb
feat(document-auto-capture): match legacy desktop UI and fix distance…
ayinloya Jun 1, 2026
ae84f42
feat(document): new back-flip instructions, review, and submission flow
ayinloya Jun 1, 2026
7c184d8
chore(document): fix lint + prettier on new-flow files
ayinloya Jun 2, 2026
9aafed2
chore: prettier formatting for desktop auto-capture + sst-env
ayinloya Jun 2, 2026
294f914
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 2, 2026
c66cb23
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 2, 2026
3b086df
test(embed): assert doc submission success state instead of #complete…
ayinloya Jun 2, 2026
418ca11
fix(document): inline lottie + guideline assets instead of import.met…
ayinloya Jun 2, 2026
c0cc4b9
Merge branch 'document-auto-capture-rework' of github.com:smileidenti…
ayinloya Jun 2, 2026
9f7b364
chore: prettier formatting for useCardDetection + sst-env
ayinloya Jun 2, 2026
14efa3a
refactor(document): drop unused fallbackAlt from hero instructions
ayinloya Jun 2, 2026
a8fa8df
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 2, 2026
671df7e
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 2, 2026
fe2dc4a
fix(document): point flip instruction Lottie at renamed asset
ayinloya Jun 2, 2026
20c705c
fix(document): address code-review findings on the new capture flow
ayinloya Jun 3, 2026
da299e8
Align capture options autocapture and timeout with mobile
ayinloya Jun 4, 2026
90e4866
fix(document): resolve PR review comments
ayinloya Jun 4, 2026
f771ace
select new options by default
ayinloya Jun 4, 2026
f0afa2d
Fix lint
ayinloya Jun 4, 2026
c5a44c5
realign shutter and feedback ui
ayinloya Jun 4, 2026
04f8ee8
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 4, 2026
de79690
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 4, 2026
e7066d9
Fix lint
ayinloya Jun 4, 2026
9de43d7
Update preview default selections
ayinloya Jun 4, 2026
d34197f
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 4, 2026
0cd61db
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 4, 2026
3005cfc
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 4, 2026
7a4c91c
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 4, 2026
1b70ee4
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 4, 2026
c8d2c51
fix(document): address auto-capture PR review findings
ayinloya Jun 4, 2026
5198ce1
fix(document): drop dead lottie fallback img; register .lottie in sto…
ayinloya Jun 4, 2026
cc73ddd
chore(example): default demo to auto-capture + new instructions
ayinloya Jun 4, 2026
0293eab
Disable agent mode for testing
ayinloya Jun 4, 2026
79b5b2c
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 5, 2026
6438737
refactor(document): drop unused HeroLottie fallback image
ayinloya Jun 5, 2026
4684dc2
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 5, 2026
5efcb15
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 5, 2026
b9fe9f7
fix(doc-auto-capture): eliminate epileptic feedback oscillation
ayinloya Jun 8, 2026
3c2fdb7
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 8, 2026
2b90ad0
Merge branch 'main' into document-auto-capture-rework
beastawakens Jun 8, 2026
1612f52
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 8, 2026
25af66e
fix(doc-auto-capture): eliminate epileptic feedback oscillation
ayinloya Jun 8, 2026
968d422
Merge branch 'document-auto-capture-rework' of github.com:smileidenti…
ayinloya Jun 8, 2026
5acf37f
Fix lint
ayinloya Jun 8, 2026
a0e960a
Merge remote-tracking branch 'origin/document-autocapture-old-design'…
ayinloya Jun 8, 2026
bee5b44
lint
ayinloya Jun 8, 2026
48ce3b7
fix(doc-auto-capture): remove capturedImage from detection loop deps
ayinloya Jun 8, 2026
2ce1e99
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 8, 2026
abaa11d
Update packages/web-components/lib/components/document/src/document-a…
ayinloya Jun 8, 2026
42a3a92
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 8, 2026
6aaf5fe
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 8, 2026
0aa186b
fix(doc-auto-capture): pin opencv.js SRI hash for supply-chain safety
ayinloya Jun 8, 2026
b0807b6
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 8, 2026
55d6a19
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 8, 2026
18970db
style: fix prettier formatting in DocumentCaptureInstructions
ayinloya Jun 8, 2026
f9e8a0e
fix(doc-auto-capture): self-host opencv.js on Smile ID S3
ayinloya Jun 8, 2026
b274199
fix(doc-auto-capture): serve opencv.js from web-models.smileidentity.com
ayinloya Jun 8, 2026
2e8e63d
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 8, 2026
ba4ed98
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 8, 2026
dc28264
Refactor attribute names to match mobilde names
ayinloya Jun 9, 2026
8af397b
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 9, 2026
0056ae2
style: fix lint
ayinloya Jun 9, 2026
e19ce0f
Merge origin/main into document-auto-capture-rework
ayinloya Jun 10, 2026
60c8874
refactor: rename auto_capture_feature to auto_capture_enabled
ayinloya Jun 10, 2026
92babff
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 12, 2026
046ab35
fix(doc-auto-capture): address PR #602 review comments (#654)
ayinloya Jun 12, 2026
5c18268
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 12, 2026
8a9c180
fix(document): widen desktop auto-capture band and guide too-close cards
claude Jun 12, 2026
e29fae6
fix(document): gate desktop id-card synthetic fallback on recent real…
ayinloya Jun 12, 2026
51683c5
fix(document): allow desktop id-card synthetic via grid coverage
ayinloya Jun 12, 2026
bb76853
fix(embed): forward host page debug flag to the hosted iframe
ayinloya Jun 12, 2026
412935b
fix(document): guide overflowing desktop cards back instead of "move …
ayinloya Jun 12, 2026
5137bab
fix(document): hand contours misread as overflow; add debug ROI overlay
ayinloya Jun 12, 2026
9a3223b
debug: surface docFill and grid cells in the tuning panel
ayinloya Jun 12, 2026
29291b4
debug: merge debugInfo fields instead of replacing per frame
ayinloya Jun 12, 2026
ca22a48
refactor(document): reuse smileid-navigation in doc auto-capture
ayinloya Jun 12, 2026
c0c66b1
refactor(document): reuse smileid-navigation in capture instructions
ayinloya Jun 12, 2026
751e812
fix(document): gate desktop capture button on captureMode + timeout
ayinloya Jun 15, 2026
ac7fe23
feat(document): default auto-capture timeout to 20s
ayinloya Jun 15, 2026
bc2c343
clean ups
ayinloya Jun 15, 2026
34c7369
Merge remote-tracking branch 'origin/document-autocapture-old-design'…
ayinloya Jun 15, 2026
ad20aee
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 16, 2026
6ef2446
fix(scw): escape and quote document-type and auto-capture attributes
ayinloya Jun 16, 2026
c064d72
fix(docv): address open PR review comments
ayinloya Jun 17, 2026
122fef1
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 17, 2026
7ce261a
Merge branch 'main' into document-auto-capture-rework
ayinloya Jun 17, 2026
2717369
Merge branch 'document-auto-capture-rework' into document-autocapture…
ayinloya Jun 17, 2026
3b0a86b
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 17, 2026
485ac61
Fix failing test
ayinloya Jun 18, 2026
5e9c89d
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 18, 2026
bd9b611
fix lint
ayinloya Jun 18, 2026
2022cf6
feat(document): adaptive contour-Canny for low-contrast backgrounds
ayinloya Jun 18, 2026
596d417
Increate edgeDensity threshold to 10
ayinloya Jun 18, 2026
c075e64
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 18, 2026
8564a0d
Merge branch 'document-capture-new-flow' into feat/mobile-capture-ada…
ayinloya Jun 18, 2026
203e708
fix(document): detect tilted & low-contrast cards on mobile auto-capture
ayinloya Jun 18, 2026
9969cfa
fix(document): reduce false auto-captures of non-ID rectangles
ayinloya Jun 18, 2026
6b76f47
fix(document): chroma-content gate to reject monochrome objects (keyb…
ayinloya Jun 18, 2026
22a6098
fix(document): set chroma-content threshold to 13 (measured)
ayinloya Jun 18, 2026
b3d1b6f
fix(document): gate book-doc synthetic fallback to stop empty-scene c…
ayinloya Jun 19, 2026
3dc7566
fix(document): apply chroma + tight aspect to the synthetic/region fa…
ayinloya Jun 19, 2026
2c41f89
test(document): default mobile region fallback OFF (Level 3)
ayinloya Jun 19, 2026
79c068f
fix(document): tighten passport aspect window to reject non-passport …
ayinloya Jun 19, 2026
8eb18a0
Merge branch 'main' into document-autocapture-old-design
ayinloya Jun 19, 2026
79e3796
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 19, 2026
a3a5fc1
Merge branch 'document-capture-new-flow' into feat/mobile-capture-ada…
ayinloya Jun 19, 2026
07e56b0
Merge branch 'main' into document-autocapture-old-design
ayinloya Jun 19, 2026
ace4fc8
Merge branch 'document-autocapture-old-design' into document-capture-…
ayinloya Jun 19, 2026
b146d25
Merge branch 'document-capture-new-flow' into feat/mobile-capture-ada…
ayinloya Jun 19, 2026
a5b892e
Merge branch 'main' into document-capture-new-flow
ayinloya Jun 19, 2026
ef92bde
style: lint fix
ayinloya Jun 19, 2026
b26a3c6
per frame best chroma calculation
ayinloya Jun 22, 2026
72a2e12
style: lint fix
ayinloya Jun 22, 2026
a23d51b
feat(document): harden auto-capture with composite frame quality scoring
ayinloya Jun 22, 2026
ef8584a
Merge branch 'document-capture-new-flow' into feat/mobile-capture-ada…
ayinloya Jun 22, 2026
c8c804d
fix(document): drop unused Ref import in DocumentCaptureInstructions
ayinloya Jun 22, 2026
963f380
remove unused Ref
ayinloya Jun 22, 2026
273b993
Merge branch 'document-capture-new-flow' into feat/mobile-capture-ada…
ayinloya Jun 22, 2026
f24bddc
fix(document): recover auto-capture loop after a per-frame CV error
ayinloya Jun 22, 2026
55f094d
fix(document): card-focused synthetic bbox so a hand can't inflate di…
ayinloya Jun 22, 2026
44192b1
refactor(embed): share doc-submission helpers across verification flows
ayinloya Jun 22, 2026
d778719
Merge branch 'document-capture-new-flow' into feat/mobile-capture-ada…
ayinloya Jun 23, 2026
ce882c1
restore flip animation screen
ayinloya Jun 23, 2026
4ea1690
Merge branch 'document-capture-new-flow' into feat/mobile-capture-ada…
ayinloya Jun 23, 2026
bbe9db8
Merge branch 'main' into feat/mobile-capture-adaptive-canny
ayinloya Jun 23, 2026
9472de3
fix(document): improve auto-capture detection logic
ayinloya Jun 25, 2026
4eba9ac
Reduce min fill to 65 on mobile
ayinloya Jun 25, 2026
2a79619
Fix lint
ayinloya Jun 25, 2026
c8b9598
Merge remote-tracking branch 'origin' into feat/mobile-capture-adapti…
ayinloya Jun 25, 2026
f99e9e1
revert config changes in app.tsx
ayinloya Jun 25, 2026
7baf811
(style): fix lint
ayinloya Jun 25, 2026
6e3ee8b
feat(document): seam-rejection for contour auto-capture
ayinloya Jun 25, 2026
e2f90ee
Merge branch 'main' into feat/mobile-capture-adaptive-canny
ayinloya Jun 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/embed/cypress/tests/document-verification.cy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ describe('document verification', () => {

cy.wait('@successfulUpload');

cy.getIFrameBody().find('#complete-screen').should('be.visible');
// The document submission UI now shows the completion state in-place
// (image + tick) rather than switching to the legacy #complete-screen.
cy.getIFrameBody()
.find('#doc-submission')
.should('have.attr', 'submission-state', 'success');
});
});

Expand Down Expand Up @@ -278,6 +282,10 @@ describe('legacy support - preselected country / id_types', () => {

cy.wait('@successfulUpload');

cy.getIFrameBody().find('#complete-screen').should('be.visible');
// The document submission UI now shows the completion state in-place
// (image + tick) rather than switching to the legacy #complete-screen.
cy.getIFrameBody()
.find('#doc-submission')
.should('have.attr', 'submission-state', 'success');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ describe('enhanced document verification', () => {

cy.wait('@successfulUpload');

cy.getIFrameBody().find('#complete-screen').should('be.visible');
// The document submission UI now shows the completion state in-place
// (image + tick) rather than switching to the legacy #complete-screen.
cy.getIFrameBody()
.find('#doc-submission')
.should('have.attr', 'submission-state', 'success');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ describe('enhanced document verification', () => {

cy.wait('@successfulUpload');

cy.getIFrameBody().find('#complete-screen').should('be.visible');
// The document submission UI now shows the completion state in-place
// (image + tick) rather than switching to the legacy #complete-screen.
cy.getIFrameBody()
.find('#doc-submission')
.should('have.attr', 'submission-state', 'success');
});
});
12 changes: 9 additions & 3 deletions packages/embed/cypress/tests/id-selection.cy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ describe('No ID Selection', () => {

cy.wait('@successfulUpload');

cy.getIFrameBody().find('#complete-screen').should('be.visible');
cy.getIFrameBody()
.find('#doc-submission')
.should('have.attr', 'submission-state', 'success');
});

it('enhanced_kyc', () => {
Expand Down Expand Up @@ -470,7 +472,9 @@ describe('Preselected Country', () => {

cy.wait('@successfulUpload');

cy.getIFrameBody().find('#complete-screen').should('be.visible');
cy.getIFrameBody()
.find('#doc-submission')
.should('have.attr', 'submission-state', 'success');
});

it('enhanced_kyc', () => {
Expand Down Expand Up @@ -725,7 +729,9 @@ describe('Preselected Country and ID Type', () => {

cy.wait('@successfulUpload');

cy.getIFrameBody().find('#complete-screen').should('be.visible');
cy.getIFrameBody()
.find('#doc-submission')
.should('have.attr', 'submission-state', 'success');
});

it('enhanced_kyc', () => {
Expand Down
33 changes: 6 additions & 27 deletions packages/embed/src/doc-verification.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,33 +248,12 @@ <h1 style="--flow-space: 4rem" data-i18n="pages.loading.title">
>
</smart-camera-web>

<section hidden id="upload-progress-screen" class="flow center">
<br />
<p class="spinner"></p>

<h1 style="--flow-space: 4rem" data-i18n="pages.upload.title">
Uploading
</h1>

<p>
<span data-i18n="pages.upload.subtitle">Just a few more seconds</span>
<br />
<span data-i18n="pages.upload.description"
>We are processing your request</span
>
</p>

<p class="center credits">
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
viewBox="0 0 90 9"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<use href="#attribution" />
</svg>
</p>
<section hidden id="upload-progress-screen">
<document-capture-submission
id="doc-submission"
submission-state="submitting"
style="display: block; width: 100%; min-height: 100vh"
></document-capture-submission>
</section>

<section hidden id="upload-failure-screen" class="flow center">
Expand Down
33 changes: 6 additions & 27 deletions packages/embed/src/enhanced-document-verification.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,33 +254,12 @@ <h1 style="--flow-space: 4rem" data-i18n="pages.loading.title">
>
</smart-camera-web>

<section hidden id="upload-progress-screen" class="flow center">
<br />
<p class="spinner"></p>

<h1 style="--flow-space: 4rem" data-i18n="pages.upload.title">
Uploading
</h1>

<p>
<span data-i18n="pages.upload.subtitle">Just a few more seconds</span>
<br />
<span data-i18n="pages.upload.description"
>We are processing your request</span
>
</p>

<p class="center credits">
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
viewBox="0 0 90 9"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<use href="#attribution" />
</svg>
</p>
<section hidden id="upload-progress-screen">
<document-capture-submission
id="doc-submission"
submission-state="submitting"
style="display: block; width: 100%; min-height: 100vh"
></document-capture-submission>
</section>

<section hidden id="upload-failure-screen" class="flow center">
Expand Down
81 changes: 77 additions & 4 deletions packages/embed/src/js/doc-verification.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ window.Sentry = Sentry;
);
const UploadFailureScreen = document.querySelector('#upload-failure-screen');
const CompleteScreen = document.querySelector('#complete-screen');
const DocSubmission = document.querySelector('#doc-submission');

const CloseIframeButtons = document.querySelectorAll('.close-iframe');
const RetryUploadButton = document.querySelector('#retry-upload');
Expand Down Expand Up @@ -693,6 +694,7 @@ window.Sentry = Sentry;
'smart-camera-web.publish',
(event) => {
images = event.detail.images;
showDocSubmission(images);
setActiveScreen(UploadProgressScreen);
handleFormSubmit(event);
},
Expand All @@ -715,6 +717,11 @@ window.Sentry = Sentry;
false,
);

// Close affordance on the submission screen (mirrors the iframe close).
window.addEventListener('document-capture-submission.close', () => {
closeWindow(true);
});

RetryUploadButton.addEventListener(
'click',
() => {
Expand Down Expand Up @@ -773,6 +780,68 @@ window.Sentry = Sentry;
activeScreen = node;
}

// Reconstruct a data URI for the captured document so the submission screen
// can show it behind the status card. Publish images carry raw base64 with
// the data: prefix stripped, so we re-add it.
//
// Pick the most recent ID-card image by type id (front=3, back=7) rather than
// blindly taking the last array entry — enhanced flows also publish selfie
// (2) / liveness (6) frames, and relying on append order would risk showing a
// face behind the document card. Sniff PNG vs JPEG from the base64 signature
// so gallery-uploaded PNGs aren't mislabelled.
function getDocPreviewDataUri(capturedImages) {
if (!Array.isArray(capturedImages)) return '';
const ID_CARD_TYPE_IDS = [3, 7];
const docImages = capturedImages.filter(
(img) => img?.image && ID_CARD_TYPE_IDS.includes(img.image_type_id),
);
const chosen =
docImages[docImages.length - 1] ||
capturedImages[capturedImages.length - 1];
if (!chosen?.image) return '';
const mime = chosen.image.startsWith('iVBOR') ? 'image/png' : 'image/jpeg';
return `data:${mime};base64,${chosen.image}`;
}

// Prime the <document-capture-submission> element with the captured image,
// partner theme/attribution, and the initial "submitting" state.
function showDocSubmission(capturedImages) {
if (!DocSubmission) return;
const previewSrc = getDocPreviewDataUri(capturedImages);
if (previewSrc) DocSubmission.setAttribute('image-src', previewSrc);
if (config.partner_details?.theme_color) {
DocSubmission.setAttribute(
'theme-color',
config.partner_details.theme_color,
);
}
if (config.hide_attribution) {
DocSubmission.setAttribute('hide-attribution', 'true');
}
DocSubmission.setAttribute('show-navigation', '');
// Clear any message left over from a prior attempt before re-submitting.
DocSubmission.removeAttribute('submission-message');
DocSubmission.setAttribute('submission-state', 'submitting');
}

// Flip the submission card between submitting → success / error. Driven by
// the upload lifecycle below (mirrors the Enhanced SmartSelfie host pattern).
// Falls back to the legacy static screens if the element isn't present.
function setDocSubmissionState(state, message) {
if (!DocSubmission) {
setActiveScreen(
state === 'success' ? CompleteScreen : UploadFailureScreen,
);
return;
}
DocSubmission.setAttribute('submission-state', state);
if (message) {
DocSubmission.setAttribute('submission-message', message);
} else {
DocSubmission.removeAttribute('submission-message');
}
}

async function handleFormSubmit(event) {
event.preventDefault();
const errorMessage = document.querySelector('.validation-message');
Expand Down Expand Up @@ -891,25 +960,29 @@ window.Sentry = Sentry;
});

request.upload.addEventListener('error', function (e) {
// Errors keep the legacy failure screen so the user retains the
// "Retry" affordance (#retry-upload); only success uses the new
// in-place submission card. Report rather than throw — a throw inside
// this listener is unhandled (no caller to catch it).
setActiveScreen(UploadFailureScreen);
throw new Error('uploadZip failed', { cause: e });
console.error('SmileIdentity - uploadZip failed', e);
});

request.onreadystatechange = function () {
if (
request.readyState === XMLHttpRequest.DONE &&
request.status === 200
) {
setActiveScreen(CompleteScreen);
setDocSubmissionState('success');
handleSuccess();
window.setTimeout(closeWindow, 2000);
window.setTimeout(closeWindow, 2500);
}
if (
request.readyState === XMLHttpRequest.DONE &&
request.status !== 200
) {
setActiveScreen(UploadFailureScreen);
throw new Error('uploadZip failed', { cause: request });
console.error('SmileIdentity - uploadZip failed', request.status);
}
};

Expand Down
Loading