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

feat: add validation to qr #45

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"license": "MPL-2.0",
"private": true,
"packageManager": "yarn@1.22.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/country-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"license": "MPL-2.0",
"main": "./build/index.js",
"exports": {
Expand Down
41 changes: 29 additions & 12 deletions packages/country-config/src/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ export const esignet = (
url.searchParams.append("acr_values", "mosip:idp:acr:static-code");
url.searchParams.append("claims", openIdProviderClaims);
url.searchParams.append("state", "fetch-on-mount");
url.searchParams.append(
"redirect_uri",
'${window.location.href}',
);
url.searchParams.append("redirect_uri", "${window.location.href}");

return {
name: fieldName,
Expand Down Expand Up @@ -115,8 +112,7 @@ export const esignetCallback = ({
},
body: {
clientId: openIdProviderClientId,
redirectUri:
'${window.location.href}',
redirectUri: "${window.location.href}",
},

method: "POST",
Expand Down Expand Up @@ -170,8 +166,22 @@ export const idReader = (
};
};

export const qr = () => ({
type MessageDescriptor = {
id: string;
defaultMessage: string;
description?: string;
};

export const qr = ({
validation,
}: {
validation: {
rule: Record<string, unknown>;
errorMessage: MessageDescriptor;
};
}) => ({
type: "QR",
validation,
});

export const verified = (event: string, sectionId: string) => {
Expand All @@ -195,19 +205,24 @@ export const verified = (event: string, sectionId: string) => {
};
};

export const idPendingVerificationBanner = (
function capitalize(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}

export const idVerificationBanner = (
event: string,
sectionId: string,
status: "pending" | "verified" | "failed",
) => {
const fieldName = "verified";
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
return {
name: "idPending",
name: `id${capitalize(status)}.`,
type: "ID_VERIFICATION_BANNER",
fieldId,
hideInPreview: true,
custom: true,
bannerType: "pending",
bannerType: status,
idFieldName: "idReader",
label: {
id: "form.field.label.empty",
Expand All @@ -217,7 +232,7 @@ export const idPendingVerificationBanner = (
conditionals: [
{
action: "hide",
expression: '$form?.verified !== "pending"',
expression: `$form?.verified !== "${status}"`,
},
],
};
Expand All @@ -226,6 +241,8 @@ export const idPendingVerificationBanner = (
export const idVerificationFields = (event: string, sectionId: string) => {
return [
verified(event, sectionId),
idPendingVerificationBanner(event, sectionId),
idVerificationBanner(event, sectionId, "pending"),
idVerificationBanner(event, sectionId, "verified"),
idVerificationBanner(event, sectionId, "failed"),
];
};
2 changes: 1 addition & 1 deletion packages/esignet-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opencrvs/esignet-mock",
"license": "MPL-2.0",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"main": "index.js",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/mosip-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip-api",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"license": "MPL-2.0",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/mosip-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opencrvs/mosip-mock",
"version": "1.7.0-alpha.13",
"version": "1.7.0-alpha.14",
"license": "MPL-2.0",
"scripts": {
"dev": "NODE_ENV=development tsx watch src/index.ts",
Expand Down
Loading