Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed: add e-signature product #150

Merged
merged 47 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2f8c616
assets: add `e-signature.html` file
Nov 22, 2023
f0f3bb3
assets: add `js/e-signature.js` file
Nov 22, 2023
21289fa
components: add `signature_pad` component
Dec 4, 2023
249fa01
redesign: add `e_signature` product, improve error handling
Dec 4, 2023
7abaceb
feat(eSignature): add html / js files for eSignature
Dec 4, 2023
765df6b
styles: add styles for eSignature
Dec 4, 2023
89a6c00
tests: add tests for eSignature product
Dec 4, 2023
d604448
deps(components): add `signature_pad` as a dependency for components
Dec 4, 2023
9791339
Merge branch 'main' into embed/add-e_signature
tamssokari Dec 4, 2023
54dae7d
redesign(SignaturePad): make upload optional etc.
Dec 6, 2023
eaa865b
enh(eSignature): embed up to signature review screen
Dec 6, 2023
aea1d5d
Merge branch 'embed/add-e_signature' of github.com:smileidentity/web-…
Dec 6, 2023
879b329
Merge branch 'main' into embed/add-e_signature
Dec 12, 2023
644a739
redesign: use single name field, disable button until checkbox checke…
Dec 14, 2023
f585b6e
Merge branch 'main' into embed/add-e_signature
Dec 14, 2023
78942a4
format: run prettier through files
Dec 14, 2023
0952ca1
enh: work on back buttons
Dec 14, 2023
c8fb794
enh: add submitSignature method
Dec 14, 2023
f60f7b6
format: fix lint error
Dec 14, 2023
e3d3228
fix: fix typos and more
Dec 14, 2023
b78680d
fix: add explicit `Content-Type` header, fix others
Dec 14, 2023
884ac1c
enh: add failure / progress screens
Dec 14, 2023
8258c2a
fix: change `Content-Type` to `Content-type` header
Dec 14, 2023
83bce51
redesign: `image` is a blob object
Dec 14, 2023
d36522d
redesign: pass file and not blob, use toISOString for date
Dec 14, 2023
9c03f92
redesign: fix file constructor
Dec 14, 2023
f45f3c7
enh: allow the browser set the Content-Type header
Dec 14, 2023
d4a3391
redesign: add upload progress and upload failed screens
Dec 19, 2023
79d190b
fix: SignaturePad captures full drawn signature
Jan 16, 2024
69e2cd1
fix: signature-previews with max-width of 10rem
Jan 16, 2024
74cf9e8
enh(SignaturePad): support jpeg uploads
Jan 16, 2024
e1041ed
enh(SignaturePad): restrict upload preview to one file
Jan 16, 2024
a20e49f
Merge branch 'main' into embed/add-e_signature
Jan 16, 2024
038da49
styles: change icon sizes for back and close buttons
Jan 22, 2024
c60d547
redesign: use top offset, instead of center
Jan 23, 2024
c7b0002
fix(BackNavigation): make `setActiveScreen` direction aware
Jan 23, 2024
d95e833
components: create component for navigation
Jan 23, 2024
a8b3059
redesign: use navigation component in eSignature
Jan 23, 2024
be58ad0
redesign: resize checkbox input size, fix alignment
Jan 23, 2024
4636655
stories: add storybook page for SignaturePad component
Jan 23, 2024
2961708
redesign(SignaturePad): reset signature on pad should float
Jan 23, 2024
47749b2
fix(SignaturePad): no more offset for SignaturePad
Jan 23, 2024
84b35b7
redesign: calculate canvas width relative to container
Jan 23, 2024
482f9b5
Merge branch 'main' into embed/add-e_signature
Jan 25, 2024
b2a4af5
deps: export signature-pad component
Jan 25, 2024
29a1d11
fix: fix lint errors
Jan 25, 2024
d59410b
Merge branch 'main' into embed/add-e_signature
Jan 25, 2024
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
16 changes: 16 additions & 0 deletions packages/embed/cypress/fixtures/e_signature_documents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"documents": [
{
"id": "07ef4595-aaed-4597-b6af-444986ae4565",
"link": "https://smile-signable-document-development.s3.us-west-2.amazonaws.com/development/921/SINGLE_USE/caa31f97-0056-4672-99de-2e1b1c439e82-privacy%20policy.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYL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520j%2Fs9ayIvtgsmZWkLC99Wv8Sb4xpAz2paN7a%2FTwFPqAnkZVD&X-Amz-Signature=d157d3439c22a5832038af7a63928b4dec62b4326742184f88323556ebcf2fe7&X-Amz-SignedHeaders=host&x-id=GetObject",
"name": "privacy policy",
"size": 186790
},
{
"id": "6df1ceb5-72e5-4e38-9eef-66ee085aec17",
"link": "https://smile-signable-document-development.s3.us-west-2.amazonaws.com/development/921/SINGLE_USE/fbedce72-58f7-45c6-9e47-240e278719a7-terms%20and%20conditions.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIA4OAOFXPAHPEZQXW5%2F20231202%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20231202T190423Z&X-Amz-Expires=900&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEMv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLXdlc3QtMiJHMEUCIQDx6xxYPXeC6Nm1O6NkDRWNskY6jpWnTo0rhGsSq%2FhLpQIgP3rVKh1%2B0Mm8tceD%2BXXRPeyRCZHysxZNw6YFxhN0EXQqpwMINBADGgw4NTQ3MjgyMjc3NzYiDBIuWCw54%2BS8bXD4iiqEAygeRz2MdUibORe2HlZ7I53MftfqQdqtUZ6CCzSee%2F53ERKuFuQ59SfeEX6KwEpfDsgKxAJsSE%2B5DWdFz3F4KLXeaVb9Ri9EHl7%2BYfYFbFUe25eCk1r0%2FewDpEgDlYr7KSuV84oNCJDmHxxa%2BsMcG6PvfBJ26UNUk5MhHfYBaqhjLTHSlFODgu%2FwYalDEcEcyK5oiJfr3%2BUx8KcNlpQVx2ep%2BbNidaVX30K2lIGqkQ9BFTjYGGzXlJ2JuNoTQjNdobptZdL8lawO1MuXaBJLdFy3AMSbcB8Bp4v39N1HA5q5aVd3odt0JEBpJ0H9pf%2BBa%2BNsS5kaMXwO0w0xjc7SLDHSClMexzwf4vXqLHMW6oPbGvUMIwmqpkYVSkhPPBBDOpEO%2FezO1Eco5shWXBByJjLrAC8wyQcWxX7TS7M9dZAjKSNSAl6D0aHYTgDhCkyJiWFfMHFF4AAR0TurBZO7LMiPoU97D7CvI7lCT0%2FTSFF1c5%2B%2B5fD7vP0PKlDF%2B4o5bqp7%2Bs8wtP%2BtqwY6nQFJodwV1R2DKbSt%2BkrCRHKB8AsdRa2mw8r59BO7ZE3x7m%2FVl61yKoqq5F0G5VW1vr7rT3OHdrUP9aOQaLHtWpKpUby4H5LGAjSZzYkBEO6MunuQ79L6lZVBe23zE2NMxGdxkWCuuj5SNP12ewlslnC1aJBN38StdO520j%2Fs9ayIvtgsmZWkLC99Wv8Sb4xpAz2paN7a%2FTwFPqAnkZVD&X-Amz-Signature=889ccd4c0be2eb3fdc868b534c31c51c2c084542b44a89f37a4738203bff5d52&X-Amz-SignedHeaders=host&x-id=GetObject",
"name": "terms and conditions",
"size": 384244
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"error": "File not found for ID(s) 6df1ceb5-72e5-4e38-9eef-66ee085aec19"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"code": "2413",
"error": "\"ids\" does not contain 1 required value(s)"
}
57 changes: 57 additions & 0 deletions packages/embed/cypress/pages/e_signature.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
max-width: 100%;
min-height: 100%;
}
</style>
</head>

<body>
<script src="js/script.min.js"></script>

<script>
function displayError(error) {
const errorDiv = document.createElement("div");
errorDiv.setAttribute("class", "validation-message");
errorDiv.textContent = error;
document.body.appendChild(errorDiv);
}

SmileIdentity({
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXJ0bmVyX3BhcmFtcyI6eyJ1c2VyX2lkIjoid2ViLXRva2VuLXRlc3QtdXNlci0wMDEiLCJqb2JfaWQiOiJ3ZWItdG9rZW4tam9iLTEyMyIsImpvYl90eXBlIjo1fSwiY2FsbGJhY2tfdXJsIjoiaHR0cHM6Ly93ZWJob29rLnNpdGUvMWFhYTdhN2ItYWNjYi00MGFjLTg2NDMtZmQ4YTg3MDNlOWJlIiwiaWF0IjoxNjQ2OTQxNTQ5LCJleHAiOjE2NDg1ODg0ODN9.D83B4jSgQGJfSnQ5xALKea48okutLpbTcqojJTk4iGI",
product: "e_signature",
document_ids: ['07ef4595-aaed-4597-b6af-444986ae4565', '6df1ceb5-72e5-4e38-9eef-66ee085aec17'],
callback_url:
"https://webhook.site/1aaa7a7b-accb-40ac-8643-fd8a8703e9be",
environment: "development",
partner_details: {
name: "Test Org",
logo_url: "https://portal.smileidentity.com/favicon.ico",
partner_id: "212",
policy_url: "https://smileidentity.com/privacy-policy",
theme_color: "#000",
},
onSuccess: () => {},
onClose: () => {
displayError("User triggered this close action");
},
onError: (data) => {
displayError(JSON.stringify(data, null, 2));
},
});
</script>
</body>
</html>
58 changes: 58 additions & 0 deletions packages/embed/cypress/pages/e_signature_no_file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
max-width: 100%;
min-height: 100%;
}
</style>
</head>

<body>
<script src="js/script.min.js"></script>

<script>
function displayError(error) {
const errorDiv = document.createElement("div");
errorDiv.setAttribute("class", "validation-message");
errorDiv.textContent = error;
document.body.appendChild(errorDiv);
}

SmileIdentity({
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXJ0bmVyX3BhcmFtcyI6eyJ1c2VyX2lkIjoid2ViLXRva2VuLXRlc3QtdXNlci0wMDEiLCJqb2JfaWQiOiJ3ZWItdG9rZW4tam9iLTEyMyIsImpvYl90eXBlIjo1fSwiY2FsbGJhY2tfdXJsIjoiaHR0cHM6Ly93ZWJob29rLnNpdGUvMWFhYTdhN2ItYWNjYi00MGFjLTg2NDMtZmQ4YTg3MDNlOWJlIiwiaWF0IjoxNjQ2OTQxNTQ5LCJleHAiOjE2NDg1ODg0ODN9.D83B4jSgQGJfSnQ5xALKea48okutLpbTcqojJTk4iGI",
product: "e_signature",
document_ids: ['07ef4595-aaed-4597-b6af-444986ae4565', '6df1ceb5-72e5-4e38-9eef-66ee085aec17'],
callback_url:
"https://webhook.site/1aaa7a7b-accb-40ac-8643-fd8a8703e9be",
environment: "development",
partner_details: {
name: "Test Org",
logo_url: "https://portal.smileidentity.com/favicon.ico",
partner_id: "212",
policy_url: "https://smileidentity.com/privacy-policy",
theme_color: "#000",
},
onSuccess: () => {},
onClose: () => {
displayError("User triggered this close action");
},
onError: (data) => {
console.log(data);
displayError(JSON.stringify(data, null, 2));
},
});
</script>
</body>
</html>
56 changes: 56 additions & 0 deletions packages/embed/cypress/pages/e_signature_no_ids.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
max-width: 100%;
min-height: 100%;
}
</style>
</head>

<body>
<script src="js/script.min.js"></script>

<script>
function displayError(error) {
const errorDiv = document.createElement("div");
errorDiv.setAttribute("class", "validation-message");
errorDiv.textContent = error;
document.body.appendChild(errorDiv);
}

SmileIdentity({
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXJ0bmVyX3BhcmFtcyI6eyJ1c2VyX2lkIjoid2ViLXRva2VuLXRlc3QtdXNlci0wMDEiLCJqb2JfaWQiOiJ3ZWItdG9rZW4tam9iLTEyMyIsImpvYl90eXBlIjo1fSwiY2FsbGJhY2tfdXJsIjoiaHR0cHM6Ly93ZWJob29rLnNpdGUvMWFhYTdhN2ItYWNjYi00MGFjLTg2NDMtZmQ4YTg3MDNlOWJlIiwiaWF0IjoxNjQ2OTQxNTQ5LCJleHAiOjE2NDg1ODg0ODN9.D83B4jSgQGJfSnQ5xALKea48okutLpbTcqojJTk4iGI",
product: "e_signature",
callback_url:
"https://webhook.site/1aaa7a7b-accb-40ac-8643-fd8a8703e9be",
environment: "sandbox",
partner_details: {
name: "Test Org",
logo_url: "https://portal.smileidentity.com/favicon.ico",
partner_id: "212",
policy_url: "https://smileidentity.com/privacy-policy",
theme_color: "#000",
},
onSuccess: () => {},
onClose: () => {
displayError("User triggered this close action");
},
onError: (data) => {
displayError(JSON.stringify(data, null, 2));
},
});
</script>
</body>
</html>
76 changes: 76 additions & 0 deletions packages/embed/cypress/tests/e-signature.cy.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
describe("eSignature", () => {
describe("with no document ids passed", () => {
beforeEach(() => {
cy.visit("/e_signature_no_ids");
});

it("should show an error message", () => {
cy.get("iframe").should("not.exist");
cy.get(".validation-message").should("be.visible");
cy.get(".validation-message").should(
"contain",
"`document_ids` field is required for `e_signature` ",
);
});
});

describe("with no file found", () => {
beforeEach(() => {
cy.intercept(
{
method: "OPTIONS",
url: "*v1/documents**",
},
{
statusCode: 204,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "OPTIONS,GET,POST",
"Access-Control-Allow-Headers": "*",
},
},
);

cy.intercept(
{
method: "GET",
url: "*v1/documents**",
},
{
statusCode: 400,
fixture: "e_signature_documents_no_file.json",
},
);

cy.visit("/e_signature_no_file");
});

it("should show an error message", () => {
cy.get("iframe").should("not.exist");
cy.get(".validation-message").should("be.visible");
cy.get(".validation-message").should("contain", "File not found");
});
});

describe.only("with both document ids valid", () => {
beforeEach(() => {
cy.intercept(
{
method: "GET",
url: "*v1/documents**",
},
{
statusCode: 200,
fixture: "e_signature_documents.json",
},
);
cy.visit("/e_signature");
});

it("should proceed to upload a signature", () => {
cy.get("iframe").should("exist");

cy.getIFrameBody().find("#entry-screen").should("be.visible");
});
});
});
86 changes: 75 additions & 11 deletions packages/embed/src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,14 @@ main {
padding: 2rem;
overflow-y: scroll;
position: absolute;
max-height: 100vh;
}

@media screen and (min-width: 40rem) {
main {
padding: 2rem 5rem;
top: 50%;
top: 4rem;
left: 50%;
transform: translate(-50%, -50%);
}
}

@media screen and (min-width: 80rem) {
main {
max-height: 80%;
transform: translateX(-50%);
}
}

Expand Down Expand Up @@ -304,6 +297,20 @@ button[data-type="icon"] {
justify-content: end !important;
}

.checkbox-input {
display: flex;
}

.checkbox-input input {
inline-size: 1.25rem;
block-size: 1.25rem;
}

.checkbox-input label {
margin-inline-start: .5rem;
text-align: initial;
}

.nav {
display: flex;
justify-content: space-between;
Expand All @@ -319,8 +326,7 @@ button[data-type="icon"] {
}

.back-button-text {
font-size: 11px;
line-height: 11px;
line-height: 1;
color: rgb(21, 31, 114);
}

Expand Down Expand Up @@ -558,3 +564,61 @@ smileid-combobox-option[aria-selected] {
smileid-combobox-option[hidden] {
display: none;
}

.document-tips {
margin-block-start: 1.5rem;
display: flex;
align-items: center;
text-align: initial;
}

.document-tips svg {
flex-shrink: 0;
margin-inline-end: 1rem;
}

.document-tips p {
margin-block: 0;
}

.document-tips p:first-of-type {
font-size; 1.875rem;
font-weight: bold
}

[type='file'] {
display: none;
}

.document-tips > * + * {
margin-inline-start; 1em;
}

.document-list {
padding: 0px;
}

.document-list li {
list-style: none;
background-color: #F9F0E7;
padding: 1rem;
border-radius: .5rem;
}

.document-list li + li {
margin-block-start: 1rem;
}

.document-list a {
color: initial;
text-decoration: none;
margin: 0px;
}

smileid-signature-pad {
margin-inline: auto;
}

[id='preview-signature'] {
max-inline-size: 10rem;
}
Loading
Loading