@raytio/decrypt-helper 3.0.2 → 3.2.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.
- package/CHANGELOG.md +19 -4
- package/README.md +1 -0
- package/dist/api/fetchEnvConfig.d.ts +1 -1
- package/dist/api/fetchEnvConfig.js +8 -2
- package/dist/api/index.js +5 -1
- package/dist/api/signIn.js +28 -11
- package/dist/constants.d.ts +4 -1
- package/dist/constants.js +17 -13
- package/dist/helpers/formatOutput.js +1 -1
- package/dist/helpers/index.js +5 -1
- package/dist/helpers/splitPOAndVers.js +1 -1
- package/dist/locales/index.d.ts +44 -0
- package/dist/locales/index.js +21 -0
- package/dist/locales/translations/en.json +33 -0
- package/dist/pdf/components/Images.js +2 -1
- package/dist/pdf/components/POVerificationBadge.js +5 -6
- package/dist/pdf/components/Report.d.ts +3 -1
- package/dist/pdf/components/Report.js +31 -14
- package/dist/pdf/components/Subheader.js +4 -3
- package/dist/pdf/components/ValidationDisplay.js +2 -3
- package/dist/pdf/components/VerifyBox.js +2 -1
- package/dist/pdf/constants.js +6 -5
- package/dist/pdf/helpers/transform.js +3 -2
- package/dist/public-methods/generatePDF.js +17 -1
- package/dist/public-methods/processSubmission.d.ts +3 -0
- package/dist/public-methods/processSubmission.js +1 -0
- package/package.json +29 -13
- package/dist/api/__tests__/fetchEnvConfig.test.d.ts +0 -1
- package/dist/api/__tests__/fetchEnvConfig.test.js +0 -29
- package/dist/api/__tests__/getFiles.test.d.ts +0 -1
- package/dist/api/__tests__/getFiles.test.js +0 -45
- package/dist/helpers/__tests__/formatOutput.test.d.ts +0 -1
- package/dist/helpers/__tests__/formatOutput.test.js +0 -131
- package/dist/helpers/__tests__/lookup.test.d.ts +0 -1
- package/dist/helpers/__tests__/lookup.test.js +0 -79
- package/dist/test/pdf.d.ts +0 -4
- package/dist/test/pdf.js +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -7,16 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## 3.2.0 (2022-04-21)
|
|
11
|
+
|
|
12
|
+
- !177 do not use `hashPassword` when logging in, and migrate old credentials
|
|
13
|
+
|
|
14
|
+
## 3.1.1 (2022-04-02)
|
|
15
|
+
|
|
16
|
+
- !168 Fix import issue in v3.1
|
|
17
|
+
|
|
18
|
+
## 3.1.0 (2022-03-14)
|
|
19
|
+
|
|
20
|
+
- !168 Support internationalizing the pdf
|
|
21
|
+
- !167 Support while labelling the pdf
|
|
22
|
+
- !166 List the person schema first in the PDF
|
|
23
|
+
- !163, !165, !169, !171, !172 automated dependency updates
|
|
24
|
+
|
|
10
25
|
## 3.0.2 (2022-02-16)
|
|
11
26
|
|
|
12
|
-
- fix PDF bug for multiple POs from the same schema
|
|
13
|
-
- remove legacy internal property called `$source`
|
|
14
|
-
- fix field verification status being `undefined` instead of `NotVerified`/`60002`
|
|
27
|
+
- !164 fix PDF bug for multiple POs from the same schema
|
|
28
|
+
- !164 remove legacy internal property called `$source`
|
|
29
|
+
- !164 fix field verification status being `undefined` instead of `NotVerified`/`60002`
|
|
15
30
|
- 💥 BREAKING CHANGE: we no longer use `schema_group` to group schema in the json, csv, and pdf
|
|
16
31
|
|
|
17
32
|
## 3.0.1 (2022-02-15)
|
|
18
33
|
|
|
19
|
-
- fix bug with PDF generation
|
|
34
|
+
- !162 fix bug with PDF generation
|
|
20
35
|
|
|
21
36
|
## 3.0.0 (2022-02-04)
|
|
22
37
|
|
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ raytio
|
|
|
42
42
|
// for available timezone options, see the map on https://momentjs.com/timezone
|
|
43
43
|
DATE_FORMAT: "en-nz",
|
|
44
44
|
TIMEZONE: "Pacific/Auckland",
|
|
45
|
+
PDF_LANGUAGE: "en", // the value must be one of the languages listed here: https://gitlab.com/raytio/tools/decrypt-helper/-/tree/main/src/locales/translations
|
|
45
46
|
},
|
|
46
47
|
verbose: true,
|
|
47
48
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const PARAMS: readonly ["cognito_region", "cognito_user_pool_id", "cognito_web_client_id", "api_url"];
|
|
1
|
+
declare const PARAMS: readonly ["cognito_region", "cognito_user_pool_id", "cognito_web_client_id", "api_url", "app_name", "logo_url"];
|
|
2
2
|
export declare type EnvConfig = Record<typeof PARAMS[number], string>;
|
|
3
3
|
export declare function fetchEnvConfig(clientUrl: string): Promise<EnvConfig>;
|
|
4
4
|
export {};
|
|
@@ -15,12 +15,18 @@ const PARAMS = [
|
|
|
15
15
|
"cognito_user_pool_id",
|
|
16
16
|
"cognito_web_client_id",
|
|
17
17
|
"api_url",
|
|
18
|
+
"app_name",
|
|
19
|
+
"logo_url", // must be a URL to a png file
|
|
18
20
|
];
|
|
21
|
+
const DEFAULTS = {
|
|
22
|
+
app_name: "Raytio",
|
|
23
|
+
logo_url: undefined,
|
|
24
|
+
};
|
|
19
25
|
function fetchEnvConfig(clientUrl) {
|
|
20
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
27
|
try {
|
|
22
|
-
const envConfig = yield fetch(`${clientUrl}/client_config.json`).then((r) => r.json());
|
|
23
|
-
const missing = PARAMS.filter((p) => !envConfig
|
|
28
|
+
const envConfig = Object.assign(Object.assign({}, DEFAULTS), (yield fetch(`${clientUrl}/client_config.json`).then((r) => r.json())));
|
|
29
|
+
const missing = PARAMS.filter((p) => !(p in envConfig));
|
|
24
30
|
if (missing.length)
|
|
25
31
|
throw new Error(`Missing: ${missing.join(", ")}`);
|
|
26
32
|
return envConfig;
|
package/dist/api/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/api/signIn.js
CHANGED
|
@@ -8,31 +8,48 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.signIn = void 0;
|
|
16
|
-
const auth_1 =
|
|
13
|
+
const auth_1 = require("@aws-amplify/auth");
|
|
17
14
|
const core_1 = require("@raytio/core");
|
|
15
|
+
/** see #1252 in the client repo */
|
|
16
|
+
function signInWithPasswordMigration(username, password) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
try {
|
|
19
|
+
const userObj = yield auth_1.Auth.signIn(username, password);
|
|
20
|
+
return userObj;
|
|
21
|
+
}
|
|
22
|
+
catch (_a) {
|
|
23
|
+
// if the login fails, try again with their hashed password.
|
|
24
|
+
// if it's successful the second time, we quietly change their password.
|
|
25
|
+
const hashedPassword = yield (0, core_1.hashPassword)(password);
|
|
26
|
+
const userObj = yield auth_1.Auth.signIn(username, hashedPassword);
|
|
27
|
+
// the login was successful. So we need to migrate their account.
|
|
28
|
+
// No changes to the maxcryptor, purely to cognito.
|
|
29
|
+
// we can only migrate their password if there are no login challenges
|
|
30
|
+
if (!userObj.challengeName) {
|
|
31
|
+
console.log("Migrating credentials...");
|
|
32
|
+
yield auth_1.Auth.changePassword(userObj, hashedPassword, password);
|
|
33
|
+
}
|
|
34
|
+
return userObj;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
18
38
|
function signIn(CONFIG, envConfig) {
|
|
19
39
|
var _a, _b;
|
|
20
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
auth_1.
|
|
41
|
+
auth_1.Auth.configure({
|
|
22
42
|
region: envConfig.cognito_region,
|
|
23
43
|
userPoolId: envConfig.cognito_user_pool_id,
|
|
24
44
|
userPoolWebClientId: envConfig.cognito_web_client_id,
|
|
25
45
|
});
|
|
26
|
-
const userObj = yield
|
|
27
|
-
username: CONFIG.RAYTIO_USERNAME,
|
|
28
|
-
password: yield (0, core_1.hashPassword)(CONFIG.RAYTIO_PASSWORD),
|
|
29
|
-
});
|
|
46
|
+
const userObj = yield signInWithPasswordMigration(CONFIG.RAYTIO_USERNAME, CONFIG.RAYTIO_PASSWORD);
|
|
30
47
|
if (userObj.challengeName === "SOFTWARE_TOKEN_MFA") {
|
|
31
48
|
throw new Error(`The configured account (${CONFIG.RAYTIO_USERNAME}) has two factor authentication enabled. You must disable 2FA or use a different account`);
|
|
32
49
|
}
|
|
33
|
-
const user = yield auth_1.
|
|
50
|
+
const user = yield auth_1.Auth.currentAuthenticatedUser();
|
|
34
51
|
const apiToken = (_b = (_a = user.signInUserSession) === null || _a === void 0 ? void 0 : _a.idToken) === null || _b === void 0 ? void 0 : _b.jwtToken;
|
|
35
|
-
const cognitoAttributes = yield auth_1.
|
|
52
|
+
const cognitoAttributes = yield auth_1.Auth.userAttributes(user);
|
|
36
53
|
return { apiToken, cognitoAttributes };
|
|
37
54
|
});
|
|
38
55
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare const ATTRIBUTE_MAP: {
|
|
|
8
8
|
"custom:ask_public": string[];
|
|
9
9
|
"custom:ask_private": string[];
|
|
10
10
|
};
|
|
11
|
-
export declare const VERIFICATION_SCHEMA = "ss_Verification";
|
|
12
11
|
export declare const INSTANCE_FIELDS_TO_REMOVE: readonly ["profile_objects", "relationships", "keys"];
|
|
13
12
|
export declare const FIELDS_TO_REMOVE: readonly ["n_id", "document"];
|
|
14
13
|
export declare const ENV_VARIABLES: readonly ["CLIENT_URL", "RAYTIO_USERNAME", "RAYTIO_PASSWORD"];
|
|
@@ -18,3 +17,7 @@ export declare type InstanceDataToPassOn = Omit<Instance, typeof INSTANCE_FIELDS
|
|
|
18
17
|
};
|
|
19
18
|
export declare const PO_VER_TEXT_MAP: Record<POVerification, string>;
|
|
20
19
|
export declare const FIELD_VER_TEXT_MAP: Record<FieldVerification, string>;
|
|
20
|
+
export declare const SCHEMA: {
|
|
21
|
+
readonly VERIFICATION: "ss_Verification";
|
|
22
|
+
readonly PERSON: "ss_Person_Name";
|
|
23
|
+
};
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FIELD_VER_TEXT_MAP = exports.PO_VER_TEXT_MAP = exports.ENV_VARIABLES = exports.FIELDS_TO_REMOVE = exports.INSTANCE_FIELDS_TO_REMOVE = exports.
|
|
3
|
+
exports.SCHEMA = exports.FIELD_VER_TEXT_MAP = exports.PO_VER_TEXT_MAP = exports.ENV_VARIABLES = exports.FIELDS_TO_REMOVE = exports.INSTANCE_FIELDS_TO_REMOVE = exports.ATTRIBUTE_MAP = void 0;
|
|
4
4
|
const types_1 = require("@raytio/types");
|
|
5
|
+
const locales_1 = require("./locales");
|
|
5
6
|
exports.ATTRIBUTE_MAP = {
|
|
6
7
|
"custom:kek_derivation": ["kek_derivation_config"],
|
|
7
8
|
"custom:dek_encryption": ["private_key_encryption_config"],
|
|
@@ -10,7 +11,6 @@ exports.ATTRIBUTE_MAP = {
|
|
|
10
11
|
"custom:ask_public": ["signing_key_pair", "public_key"],
|
|
11
12
|
"custom:ask_private": ["signing_key_pair", "private_key"],
|
|
12
13
|
};
|
|
13
|
-
exports.VERIFICATION_SCHEMA = "ss_Verification";
|
|
14
14
|
exports.INSTANCE_FIELDS_TO_REMOVE = [
|
|
15
15
|
"profile_objects",
|
|
16
16
|
"relationships",
|
|
@@ -23,18 +23,22 @@ exports.ENV_VARIABLES = [
|
|
|
23
23
|
"RAYTIO_PASSWORD",
|
|
24
24
|
];
|
|
25
25
|
exports.PO_VER_TEXT_MAP = {
|
|
26
|
-
[types_1.POVerification.FullyVerified]:
|
|
27
|
-
[types_1.POVerification.PartiallyVerified]:
|
|
28
|
-
[types_1.POVerification.NotVerified]:
|
|
29
|
-
[types_1.POVerification.Expired]: "Expired",
|
|
30
|
-
[types_1.POVerification.VerifiedFalse]:
|
|
26
|
+
[types_1.POVerification.FullyVerified]: (0, locales_1.$$)("POVerification.FullyVerified"),
|
|
27
|
+
[types_1.POVerification.PartiallyVerified]: (0, locales_1.$$)("POVerification.PartiallyVerified"),
|
|
28
|
+
[types_1.POVerification.NotVerified]: (0, locales_1.$$)("POVerification.NotVerified"),
|
|
29
|
+
[types_1.POVerification.Expired]: (0, locales_1.$$)("POVerification.Expired"),
|
|
30
|
+
[types_1.POVerification.VerifiedFalse]: (0, locales_1.$$)("POVerification.VerifiedFalse"),
|
|
31
31
|
// not possible but included here for completeness
|
|
32
|
-
[types_1.POVerification.Encrypted]: "Encrypted",
|
|
33
|
-
[types_1.POVerification.Loading]: "Loading
|
|
32
|
+
[types_1.POVerification.Encrypted]: (0, locales_1.$$)("POVerification.Encrypted"),
|
|
33
|
+
[types_1.POVerification.Loading]: (0, locales_1.$$)("POVerification.Loading"),
|
|
34
34
|
};
|
|
35
35
|
exports.FIELD_VER_TEXT_MAP = {
|
|
36
|
-
[types_1.FieldVerification.Verified]: "Verified",
|
|
37
|
-
[types_1.FieldVerification.NotVerified]:
|
|
38
|
-
[types_1.FieldVerification.Expired]: "Expired",
|
|
39
|
-
[types_1.FieldVerification.VerifiedFalse]:
|
|
36
|
+
[types_1.FieldVerification.Verified]: (0, locales_1.$$)("FieldVerification.Verified"),
|
|
37
|
+
[types_1.FieldVerification.NotVerified]: (0, locales_1.$$)("FieldVerification.NotVerified"),
|
|
38
|
+
[types_1.FieldVerification.Expired]: (0, locales_1.$$)("FieldVerification.Expired"),
|
|
39
|
+
[types_1.FieldVerification.VerifiedFalse]: (0, locales_1.$$)("FieldVerification.VerifiedFalse"),
|
|
40
|
+
};
|
|
41
|
+
exports.SCHEMA = {
|
|
42
|
+
VERIFICATION: "ss_Verification",
|
|
43
|
+
PERSON: "ss_Person_Name",
|
|
40
44
|
};
|
|
@@ -61,7 +61,7 @@ function formatOutput(profileObjects, allSchemas, realVers, apiToken, envConfig)
|
|
|
61
61
|
$schemaName: schemaName,
|
|
62
62
|
$schemaTitle: schema.title,
|
|
63
63
|
$properties: reducedProperties,
|
|
64
|
-
$safeHarbour: schemaName ===
|
|
64
|
+
$safeHarbour: schemaName === constants_1.SCHEMA.PERSON
|
|
65
65
|
? (yield (0, core_1.calcSafeHarbourScore)({
|
|
66
66
|
person: PO,
|
|
67
67
|
getSchema: (name) => (0, api_1.getSchema)(envConfig, name),
|
package/dist/helpers/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -4,7 +4,7 @@ exports.splitPOAndVers = void 0;
|
|
|
4
4
|
const core_1 = require("@raytio/core");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const splitPOAndVers = (list) => list.reduce((ac, PO) => {
|
|
7
|
-
const isVer = (0, core_1.findSchemaLabel)(PO.labels) === constants_1.
|
|
7
|
+
const isVer = (0, core_1.findSchemaLabel)(PO.labels) === constants_1.SCHEMA.VERIFICATION;
|
|
8
8
|
ac[+isVer].push(PO);
|
|
9
9
|
return ac;
|
|
10
10
|
}, [[], []]);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import en from "./translations/en.json";
|
|
2
|
+
declare const locales: {
|
|
3
|
+
readonly en: {
|
|
4
|
+
"FieldVerification.Expired": string;
|
|
5
|
+
"FieldVerification.NotVerified": string;
|
|
6
|
+
"FieldVerification.Verified": string;
|
|
7
|
+
"FieldVerification.VerifiedFalse": string;
|
|
8
|
+
"Images.file-not-found": string;
|
|
9
|
+
"POVerification.Encrypted": string;
|
|
10
|
+
"POVerification.Expired": string;
|
|
11
|
+
"POVerification.FullyVerified": string;
|
|
12
|
+
"POVerification.Loading": string;
|
|
13
|
+
"POVerification.NotVerified": string;
|
|
14
|
+
"POVerification.PartiallyVerified": string;
|
|
15
|
+
"POVerification.VerifiedFalse": string;
|
|
16
|
+
"POVerificationBadge.safe-harbour-no": string;
|
|
17
|
+
"POVerificationBadge.safe-harbour-yes": string;
|
|
18
|
+
"POVerificationBadge.verified-by": string;
|
|
19
|
+
"Report.footer-private": string;
|
|
20
|
+
"Report.header": string;
|
|
21
|
+
"Report.meta.title": string;
|
|
22
|
+
"Report.pagecount": string;
|
|
23
|
+
"ValidationDisplay.text": string;
|
|
24
|
+
"VerifyBox.text": string;
|
|
25
|
+
"constants.confirmation_code": string;
|
|
26
|
+
"constants.end_date": string;
|
|
27
|
+
"constants.i_id": string;
|
|
28
|
+
"constants.reference": string;
|
|
29
|
+
"constants.score": string;
|
|
30
|
+
"constants.score-category": string;
|
|
31
|
+
"constants.start_date": string;
|
|
32
|
+
"field.boolean.no": string;
|
|
33
|
+
"field.boolean.yes": string;
|
|
34
|
+
"field.undefined": string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare type I18nKey = keyof typeof en;
|
|
38
|
+
export declare type I18nLang = keyof typeof locales;
|
|
39
|
+
declare global {
|
|
40
|
+
var lang: I18nLang;
|
|
41
|
+
}
|
|
42
|
+
export declare const isValidLocale: (lang: string) => lang is "en";
|
|
43
|
+
export declare const $$: (key: I18nKey, variables?: Record<string, string | number> | undefined) => string;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.$$ = exports.isValidLocale = void 0;
|
|
7
|
+
const en_json_1 = __importDefault(require("./translations/en.json"));
|
|
8
|
+
const locales = { en: en_json_1.default };
|
|
9
|
+
const isValidLocale = (lang) => lang in locales;
|
|
10
|
+
exports.isValidLocale = isValidLocale;
|
|
11
|
+
const $$ = (key, variables) => {
|
|
12
|
+
const strings = locales[global.lang || "en"];
|
|
13
|
+
const replaceWithVariable = (_, varName) => {
|
|
14
|
+
const value = variables === null || variables === void 0 ? void 0 : variables[varName];
|
|
15
|
+
if (!value)
|
|
16
|
+
throw new Error(`[i18n] variable '${varName}' not defined`);
|
|
17
|
+
return `${value}`;
|
|
18
|
+
};
|
|
19
|
+
return strings[key].replace(/{([^}]+)}/g, replaceWithVariable);
|
|
20
|
+
};
|
|
21
|
+
exports.$$ = $$;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"FieldVerification.Expired": "Expired",
|
|
3
|
+
"FieldVerification.NotVerified": "Not Verified",
|
|
4
|
+
"FieldVerification.Verified": "Verified",
|
|
5
|
+
"FieldVerification.VerifiedFalse": "Verified False",
|
|
6
|
+
"Images.file-not-found": "File not found",
|
|
7
|
+
"POVerification.Encrypted": "Encrypted",
|
|
8
|
+
"POVerification.Expired": "Expired",
|
|
9
|
+
"POVerification.FullyVerified": "Fully Verified",
|
|
10
|
+
"POVerification.Loading": "Loading...",
|
|
11
|
+
"POVerification.NotVerified": "Not Verified",
|
|
12
|
+
"POVerification.PartiallyVerified": "Partially Verified",
|
|
13
|
+
"POVerification.VerifiedFalse": "Verified False",
|
|
14
|
+
"POVerificationBadge.safe-harbour-no": "Not Safe Harbour Compliant",
|
|
15
|
+
"POVerificationBadge.safe-harbour-yes": "Safe Harbour Compliant",
|
|
16
|
+
"POVerificationBadge.verified-by": "by {verifiedBy}",
|
|
17
|
+
"Report.footer-private": "Private and Confidential",
|
|
18
|
+
"Report.header": "{appName} Verification Report",
|
|
19
|
+
"Report.meta.title": "{appName} Verification Report - {iId}",
|
|
20
|
+
"Report.pagecount": "{currentPage} of {pageCount}",
|
|
21
|
+
"ValidationDisplay.text": "Score: {n}/10",
|
|
22
|
+
"VerifyBox.text": "To verify this submission, scan the QR Code or click here",
|
|
23
|
+
"constants.confirmation_code": "Code",
|
|
24
|
+
"constants.end_date": "Expiry Date",
|
|
25
|
+
"constants.i_id": "Submission ID",
|
|
26
|
+
"constants.reference": "Reference",
|
|
27
|
+
"constants.score": "Score",
|
|
28
|
+
"constants.score-category": "Score Category",
|
|
29
|
+
"constants.start_date": "Date Shared",
|
|
30
|
+
"field.boolean.no": "No",
|
|
31
|
+
"field.boolean.yes": "Yes",
|
|
32
|
+
"field.undefined": "N/A"
|
|
33
|
+
}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Images = void 0;
|
|
7
7
|
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
+
const locales_1 = require("../../locales");
|
|
8
9
|
const helpers_1 = require("../../helpers");
|
|
9
10
|
const Images = ({ nIds, files, }) => {
|
|
10
11
|
return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null, nIds.map((nId) => {
|
|
@@ -12,7 +13,7 @@ const Images = ({ nIds, files, }) => {
|
|
|
12
13
|
const file = (_a = files[nId]) === null || _a === void 0 ? void 0 : _a[0];
|
|
13
14
|
if (file)
|
|
14
15
|
(0, helpers_1.assertSafeProperty)(file);
|
|
15
|
-
return file ? (jsx_pdf_1.default.createElement("image", { src: file, width: 300 })) : (jsx_pdf_1.default.createElement("text", null, "
|
|
16
|
+
return file ? (jsx_pdf_1.default.createElement("image", { src: file, width: 300 })) : (jsx_pdf_1.default.createElement("text", null, (0, locales_1.$$)("Images.file-not-found")));
|
|
16
17
|
})));
|
|
17
18
|
};
|
|
18
19
|
exports.Images = Images;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.POVerificationBadge = exports.FILE_MAP = void 0;
|
|
7
7
|
const types_1 = require("@raytio/types");
|
|
8
8
|
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
9
|
+
const locales_1 = require("../../locales");
|
|
9
10
|
const general_1 = require("../helpers/general");
|
|
10
11
|
const constants_1 = require("../../constants");
|
|
11
12
|
exports.FILE_MAP = {
|
|
@@ -26,17 +27,15 @@ const POVerificationBadge = ({ width, POs, }) => {
|
|
|
26
27
|
$shouldBeVerifiedFields && (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
27
28
|
jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)(`${exports.FILE_MAP[$verified]}.svg`), width: width }),
|
|
28
29
|
jsx_pdf_1.default.createElement("text", { alignment: "center" }, constants_1.PO_VER_TEXT_MAP[$verified]),
|
|
29
|
-
verifiedBy && jsx_pdf_1.default.createElement("text", { alignment: "center" },
|
|
30
|
-
"by ",
|
|
31
|
-
verifiedBy))),
|
|
30
|
+
verifiedBy && (jsx_pdf_1.default.createElement("text", { alignment: "center" }, (0, locales_1.$$)("POVerificationBadge.verified-by", { verifiedBy }))))),
|
|
32
31
|
typeof $safeHarbour === "boolean" && (jsx_pdf_1.default.createElement("columns", { columnGap: 10 },
|
|
33
32
|
jsx_pdf_1.default.createElement("column", { width: width / 3 },
|
|
34
33
|
jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)(`${exports.FILE_MAP[$safeHarbour
|
|
35
34
|
? types_1.POVerification.FullyVerified
|
|
36
35
|
: types_1.POVerification.VerifiedFalse]}.svg`), width: width / 3 })),
|
|
37
36
|
jsx_pdf_1.default.createElement("column", { width: "auto" },
|
|
38
|
-
jsx_pdf_1.default.createElement("text", { alignment: "center" },
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
jsx_pdf_1.default.createElement("text", { alignment: "center" }, $safeHarbour
|
|
38
|
+
? (0, locales_1.$$)("POVerificationBadge.safe-harbour-yes")
|
|
39
|
+
: (0, locales_1.$$)("POVerificationBadge.safe-harbour-no")))))));
|
|
41
40
|
};
|
|
42
41
|
exports.POVerificationBadge = POVerificationBadge;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="jsx-pdf" />
|
|
2
2
|
import type { AId } from "@raytio/types";
|
|
3
3
|
import { PdfConfig } from "../types";
|
|
4
|
+
import { EnvConfig } from "../../api";
|
|
4
5
|
import { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
|
|
5
|
-
export declare const Report: ({ data, files, config, aId, clientUrl, version, }: {
|
|
6
|
+
export declare const Report: ({ data, files, config, aId, clientUrl, envConfig, version, }: {
|
|
6
7
|
data: ProcessSubmissionOutput["json"];
|
|
7
8
|
files: ProcessSubmissionOutput["files"];
|
|
8
9
|
config: PdfConfig;
|
|
9
10
|
aId: AId;
|
|
10
11
|
clientUrl: string;
|
|
12
|
+
envConfig: EnvConfig;
|
|
11
13
|
version: string;
|
|
12
14
|
}) => JSX.Element;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Report = void 0;
|
|
7
7
|
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
8
|
const crypto_1 = require("crypto");
|
|
9
|
+
const locales_1 = require("../../locales");
|
|
9
10
|
const POVerificationBadge_1 = require("./POVerificationBadge");
|
|
10
11
|
const Subheader_1 = require("./Subheader");
|
|
11
12
|
const TableTitle_1 = require("./TableTitle");
|
|
@@ -15,27 +16,40 @@ const general_1 = require("../helpers/general");
|
|
|
15
16
|
const VerifyBox_1 = require("./VerifyBox");
|
|
16
17
|
const constants_1 = require("../constants");
|
|
17
18
|
const transform_1 = require("../helpers/transform");
|
|
18
|
-
const
|
|
19
|
+
const constants_2 = require("../../constants");
|
|
20
|
+
const Report = ({ data, files, config, aId, clientUrl, envConfig, version, }) => {
|
|
19
21
|
// The PDF is read only; there's no reason why anyone would ever need to unlock it.
|
|
20
22
|
const randomToken = (0, crypto_1.randomBytes)(32).toString("base64");
|
|
23
|
+
const schemas = Object.values(data.profile_objects).sort(
|
|
24
|
+
// sort it so that the person schema comes first
|
|
25
|
+
(a, b) => {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return +(((_a = b[0]) === null || _a === void 0 ? void 0 : _a.$schemaName) === constants_2.SCHEMA.PERSON) -
|
|
28
|
+
+(((_b = a[0]) === null || _b === void 0 ? void 0 : _b.$schemaName) === constants_2.SCHEMA.PERSON);
|
|
29
|
+
});
|
|
30
|
+
const appName = envConfig.app_name;
|
|
21
31
|
return (jsx_pdf_1.default.createElement("document", { defaultStyle: { font: "Lato", fontSize: 12 }, info: {
|
|
22
|
-
title:
|
|
23
|
-
creator:
|
|
32
|
+
title: (0, locales_1.$$)("Report.meta.title", { appName, iId: data.i_id }),
|
|
33
|
+
creator: appName,
|
|
24
34
|
producer: "Raytio",
|
|
25
35
|
subject: version,
|
|
26
36
|
}, ownerPassword: randomToken, permissions: {
|
|
27
37
|
printing: "highResolution",
|
|
28
38
|
copying: true, // allow copy/paste
|
|
29
39
|
}, pageSize: "A4", styles: style_1.classes, images: {
|
|
30
|
-
raytioLogo:
|
|
40
|
+
raytioLogo: envConfig.logo_url
|
|
41
|
+
? (0, general_1.asset)("custom-logo.png")
|
|
42
|
+
: (0, general_1.asset)("logo.png"),
|
|
31
43
|
} },
|
|
32
44
|
jsx_pdf_1.default.createElement("header", null, (currentPage) => currentPage !== 1 && (jsx_pdf_1.default.createElement("stack", { color: "#333", fontSize: 10 },
|
|
33
45
|
jsx_pdf_1.default.createElement("text", { margin: 16 },
|
|
34
|
-
jsx_pdf_1.default.createElement("text", { bold: true },
|
|
46
|
+
jsx_pdf_1.default.createElement("text", { bold: true },
|
|
47
|
+
(0, locales_1.$$)("Report.header", { appName }),
|
|
48
|
+
" - "),
|
|
35
49
|
jsx_pdf_1.default.createElement("text", null, data.i_id))))),
|
|
36
50
|
jsx_pdf_1.default.createElement("content", null,
|
|
37
51
|
jsx_pdf_1.default.createElement("image", { src: "raytioLogo", width: 150, alignment: "center" }),
|
|
38
|
-
jsx_pdf_1.default.createElement("text", { style: ["header", "marginBottom"], alignment: "center" }, "
|
|
52
|
+
jsx_pdf_1.default.createElement("text", { style: ["header", "marginBottom"], alignment: "center" }, (0, locales_1.$$)("Report.header", { appName })),
|
|
39
53
|
jsx_pdf_1.default.createElement("columns", { columnGap: 10 },
|
|
40
54
|
jsx_pdf_1.default.createElement("column", { width: "auto" },
|
|
41
55
|
jsx_pdf_1.default.createElement("text", { style: ["subheader", "marginBottom"] },
|
|
@@ -43,14 +57,18 @@ const Report = ({ data, files, config, aId, clientUrl, version, }) => {
|
|
|
43
57
|
.map(([id, label]) => `${label}: ${(0, transform_1.transform)(id, data[id], config)}`)
|
|
44
58
|
.join("\n"),
|
|
45
59
|
data.score
|
|
46
|
-
?
|
|
60
|
+
? [
|
|
61
|
+
"",
|
|
62
|
+
`${(0, locales_1.$$)("constants.score")}: ${data.score.score}`,
|
|
63
|
+
`${(0, locales_1.$$)("constants.score-category")}: ${data.score.category}`,
|
|
64
|
+
].join("\n")
|
|
47
65
|
: ""),
|
|
48
66
|
jsx_pdf_1.default.createElement(Subheader_1.Subheader, { data: data, config: config })),
|
|
49
67
|
jsx_pdf_1.default.createElement("column", { width: "*" },
|
|
50
68
|
jsx_pdf_1.default.createElement("text", null, " ")),
|
|
51
69
|
jsx_pdf_1.default.createElement("column", { width: 150 },
|
|
52
70
|
jsx_pdf_1.default.createElement(VerifyBox_1.VerifyBox, { aId: aId, iId: data.i_id, clientUrl: clientUrl }))),
|
|
53
|
-
|
|
71
|
+
schemas.map((POs) => {
|
|
54
72
|
// for each schema
|
|
55
73
|
return (jsx_pdf_1.default.createElement("stack", {
|
|
56
74
|
// unbreakable is off because it crashes if its too big for one page
|
|
@@ -65,11 +83,10 @@ const Report = ({ data, files, config, aId, clientUrl, version, }) => {
|
|
|
65
83
|
})),
|
|
66
84
|
jsx_pdf_1.default.createElement("footer", null, (currentPage, pageCount, pageSize) => (jsx_pdf_1.default.createElement("stack", { bold: true, color: "#333", fontSize: 10 },
|
|
67
85
|
jsx_pdf_1.default.createElement("text", { margin: 16 },
|
|
68
|
-
jsx_pdf_1.default.createElement("text", null,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
pageCount))))));
|
|
86
|
+
jsx_pdf_1.default.createElement("text", null,
|
|
87
|
+
(0, locales_1.$$)("Report.header", { appName }),
|
|
88
|
+
" - "),
|
|
89
|
+
jsx_pdf_1.default.createElement("text", { color: "#fb7171" }, (0, locales_1.$$)("Report.footer-private"))),
|
|
90
|
+
jsx_pdf_1.default.createElement("text", { absolutePosition: { x: pageSize.width - 50, y: 15 } }, (0, locales_1.$$)("Report.pagecount", { currentPage, pageCount })))))));
|
|
74
91
|
};
|
|
75
92
|
exports.Report = Report;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Subheader = void 0;
|
|
7
7
|
const types_1 = require("@raytio/types");
|
|
8
8
|
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
9
|
+
const locales_1 = require("../../locales");
|
|
9
10
|
const FieldVerificationBadge_1 = require("./FieldVerificationBadge");
|
|
10
11
|
const Subheader = () => {
|
|
11
12
|
return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
@@ -14,14 +15,14 @@ const Subheader = () => {
|
|
|
14
15
|
jsx_pdf_1.default.createElement("row", null,
|
|
15
16
|
jsx_pdf_1.default.createElement("cell", null,
|
|
16
17
|
jsx_pdf_1.default.createElement(FieldVerificationBadge_1.FieldVerificationBadge, { width: 10, status: types_1.FieldVerification.Verified })),
|
|
17
|
-
jsx_pdf_1.default.createElement("cell", null, "Verified")),
|
|
18
|
+
jsx_pdf_1.default.createElement("cell", null, (0, locales_1.$$)("FieldVerification.Verified"))),
|
|
18
19
|
jsx_pdf_1.default.createElement("row", null,
|
|
19
20
|
jsx_pdf_1.default.createElement("cell", null,
|
|
20
21
|
jsx_pdf_1.default.createElement(FieldVerificationBadge_1.FieldVerificationBadge, { width: 10, status: types_1.FieldVerification.NotVerified })),
|
|
21
|
-
jsx_pdf_1.default.createElement("cell", null,
|
|
22
|
+
jsx_pdf_1.default.createElement("cell", null, (0, locales_1.$$)("FieldVerification.NotVerified"))),
|
|
22
23
|
jsx_pdf_1.default.createElement("row", null,
|
|
23
24
|
jsx_pdf_1.default.createElement("cell", null,
|
|
24
25
|
jsx_pdf_1.default.createElement(FieldVerificationBadge_1.FieldVerificationBadge, { width: 10, status: types_1.FieldVerification.VerifiedFalse })),
|
|
25
|
-
jsx_pdf_1.default.createElement("cell", null,
|
|
26
|
+
jsx_pdf_1.default.createElement("cell", null, (0, locales_1.$$)("FieldVerification.VerifiedFalse"))))));
|
|
26
27
|
};
|
|
27
28
|
exports.Subheader = Subheader;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ValidationDisplay = void 0;
|
|
7
7
|
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
+
const locales_1 = require("../../locales");
|
|
8
9
|
const pieChart_1 = require("./pieChart");
|
|
9
10
|
const helpers_1 = require("../../helpers");
|
|
10
11
|
const SEVERITY_COLOURS = {
|
|
@@ -16,9 +17,7 @@ const ValidationDisplay = ({ value, }) => {
|
|
|
16
17
|
const colour = value.score > 0.5 ? "#c2d887" : "#fb7171";
|
|
17
18
|
return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
18
19
|
jsx_pdf_1.default.createElement("svg", { content: (0, pieChart_1.pieChart)(colour, value.score * 100), width: 50 }),
|
|
19
|
-
"
|
|
20
|
-
value.score * 10,
|
|
21
|
-
"/10",
|
|
20
|
+
(0, locales_1.$$)("ValidationDisplay.text", { n: value.score * 10 }),
|
|
22
21
|
Object.values(value.breakdown)
|
|
23
22
|
.filter((x) => x.severity && x.reason)
|
|
24
23
|
.map((x) => {
|
|
@@ -5,10 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.VerifyBox = void 0;
|
|
7
7
|
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
|
+
const locales_1 = require("../../locales");
|
|
8
9
|
const VerifyBox = ({ aId, iId, clientUrl }) => {
|
|
9
10
|
const url = `${clientUrl}/apps/s/${aId}/i/${iId}`;
|
|
10
11
|
return (jsx_pdf_1.default.createElement("stack", { alignment: "center" },
|
|
11
|
-
jsx_pdf_1.default.createElement("text", { link: url },
|
|
12
|
+
jsx_pdf_1.default.createElement("text", { link: url }, (0, locales_1.$$)("VerifyBox.text")),
|
|
12
13
|
jsx_pdf_1.default.createElement("qr", { content: url, fit: 150 }),
|
|
13
14
|
jsx_pdf_1.default.createElement("text", { color: "#1e90ff", fontSize: 9, link: url, alignment: "left" }, url)));
|
|
14
15
|
};
|
package/dist/pdf/constants.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SUBMISSION_DATA = void 0;
|
|
4
|
+
const locales_1 = require("../locales");
|
|
4
5
|
exports.SUBMISSION_DATA = {
|
|
5
|
-
confirmation_code: "
|
|
6
|
-
i_id:
|
|
7
|
-
reference: "
|
|
8
|
-
start_date:
|
|
9
|
-
end_date:
|
|
6
|
+
confirmation_code: (0, locales_1.$$)("constants.confirmation_code"),
|
|
7
|
+
i_id: (0, locales_1.$$)("constants.i_id"),
|
|
8
|
+
reference: (0, locales_1.$$)("constants.reference"),
|
|
9
|
+
start_date: (0, locales_1.$$)("constants.start_date"),
|
|
10
|
+
end_date: (0, locales_1.$$)("constants.end_date"),
|
|
10
11
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transform = exports.IS_ARRAY_OF_OBJECTS = exports.IS_IMAGE = void 0;
|
|
4
|
+
const locales_1 = require("../../locales");
|
|
4
5
|
const general_1 = require("./general");
|
|
5
6
|
exports.IS_IMAGE = Symbol.for("image");
|
|
6
7
|
exports.IS_ARRAY_OF_OBJECTS = Symbol.for("ArrayOfObjects");
|
|
7
8
|
function transform(key, value, pdfConfig, imageFieldNames) {
|
|
8
9
|
// value is possible to be false if type boolean
|
|
9
10
|
if (value === undefined) {
|
|
10
|
-
return "
|
|
11
|
+
return (0, locales_1.$$)("field.undefined");
|
|
11
12
|
}
|
|
12
13
|
if (typeof value === "boolean") {
|
|
13
|
-
return value ? "
|
|
14
|
+
return value ? (0, locales_1.$$)("field.boolean.yes") : (0, locales_1.$$)("field.boolean.no");
|
|
14
15
|
}
|
|
15
16
|
if (imageFieldNames === null || imageFieldNames === void 0 ? void 0 : imageFieldNames.includes(key)) {
|
|
16
17
|
return exports.IS_IMAGE;
|
|
@@ -15,12 +15,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.generatePDF = exports.generatePdfJson = void 0;
|
|
16
16
|
const pdfmake_1 = __importDefault(require("pdfmake"));
|
|
17
17
|
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
18
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
18
19
|
const fs_1 = require("fs");
|
|
19
20
|
const path_1 = require("path");
|
|
21
|
+
const locales_1 = require("../locales");
|
|
20
22
|
const Report_1 = require("../pdf/components/Report");
|
|
21
23
|
const style_1 = require("../pdf/style");
|
|
22
24
|
function generatePdfJson(data, DATE_FORMAT, TIMEZONE, version) {
|
|
23
|
-
return jsx_pdf_1.default.renderPdf(jsx_pdf_1.default.createElement(Report_1.Report, { data: data.json, files: data.files, aId: data.a_id, clientUrl: data.client_url, config: { DATE_FORMAT, TIMEZONE }, version: version }));
|
|
25
|
+
return jsx_pdf_1.default.renderPdf(jsx_pdf_1.default.createElement(Report_1.Report, { data: data.json, files: data.files, aId: data.a_id, clientUrl: data.client_url, envConfig: data.envConfig, config: { DATE_FORMAT, TIMEZONE }, version: version }));
|
|
24
26
|
}
|
|
25
27
|
exports.generatePdfJson = generatePdfJson;
|
|
26
28
|
const generatePDF = () => (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -28,6 +30,20 @@ const generatePDF = () => (data) => __awaiter(void 0, void 0, void 0, function*
|
|
|
28
30
|
const { DATE_FORMAT = "en-nz", TIMEZONE = "Pacific/Auckland" } = process.env;
|
|
29
31
|
const pkg = JSON.parse(yield fs_1.promises.readFile((0, path_1.join)(__dirname, "../../package.json"), "utf8"));
|
|
30
32
|
const version = `node:${process.version} pkg:${pkg.version}`;
|
|
33
|
+
if (data.envConfig.logo_url) {
|
|
34
|
+
// there is a white labelling URL, so fetch it and write it to disk, overriding the default logo
|
|
35
|
+
const arrayBuf = yield (0, node_fetch_1.default)(data.envConfig.logo_url).then((r) => r.arrayBuffer());
|
|
36
|
+
yield fs_1.promises.writeFile((0, path_1.join)(__dirname, "../../assets/custom-logo.png"), Buffer.from(arrayBuf));
|
|
37
|
+
}
|
|
38
|
+
const customLang = process.env.PDF_LANGUAGE;
|
|
39
|
+
if (customLang) {
|
|
40
|
+
if ((0, locales_1.isValidLocale)(customLang)) {
|
|
41
|
+
global.lang = customLang;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.warn(`The specified PDF_LANGUAGE is language is invalid (${customLang})`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
31
47
|
return new Promise((resolve) => {
|
|
32
48
|
const printer = new pdfmake_1.default(style_1.fonts);
|
|
33
49
|
const pdfDoc = printer.createPdfKitDocument(generatePdfJson(data, DATE_FORMAT, TIMEZONE, version));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AId, IId, Instance } from "@raytio/types";
|
|
2
2
|
import { Config, InstanceDataToPassOn } from "../constants";
|
|
3
3
|
import { FlatPO } from "../helpers";
|
|
4
|
+
import { EnvConfig } from "../api";
|
|
4
5
|
import { ApplicationEncryptorLike } from "../types";
|
|
5
6
|
declare type DecryptData = {
|
|
6
7
|
apiToken: string;
|
|
@@ -39,6 +40,8 @@ export interface ProcessSubmissionOutput {
|
|
|
39
40
|
a_id: AId;
|
|
40
41
|
/** passed down so that pdf generation has access to it */
|
|
41
42
|
client_url: string;
|
|
43
|
+
/** passed down so that pdf generation has access to it */
|
|
44
|
+
envConfig: EnvConfig;
|
|
42
45
|
}
|
|
43
46
|
export declare function processSubmission({ applicationId, instanceId, verbose, config, _supliedConfig, }: ProcessSubmissionInput): Promise<ProcessSubmissionOutput>;
|
|
44
47
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytio/decrypt-helper",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"author": "Raytio",
|
|
5
5
|
"description": "A helper to decrypt data shared by Raytio users",
|
|
6
6
|
"main": "dist",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
12
|
"dev-pdf": "ts-node src/test/pdf",
|
|
13
|
-
"build": "tsc",
|
|
13
|
+
"build": "tsc && find dist -path \"*/__tests__*\" -delete && rm -rf dist/test",
|
|
14
|
+
"i18n": "react-intl-manager",
|
|
14
15
|
"lint": "eslint --format pretty --ext .js,.ts,.tsx --color --ignore-path .gitignore .",
|
|
15
16
|
"test": "jest --colors"
|
|
16
17
|
},
|
|
@@ -21,37 +22,39 @@
|
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"@aws-amplify/auth": "3.4.25",
|
|
24
|
-
"@peculiar/webcrypto": "^1.2
|
|
25
|
-
"@raytio/core": "^9.0.
|
|
25
|
+
"@peculiar/webcrypto": "^1.3.2",
|
|
26
|
+
"@raytio/core": "^9.0.3",
|
|
26
27
|
"@raytio/maxcryptor": "^3.1.0",
|
|
27
28
|
"@raytio/types": "^6.0.0",
|
|
28
29
|
"aws-sdk": "^2.754.0",
|
|
29
30
|
"jsx-pdf": "^2.3.0",
|
|
30
31
|
"localstorage-polyfill": "^1.0.1",
|
|
31
|
-
"mime-types": "^2.1.
|
|
32
|
+
"mime-types": "^2.1.35",
|
|
32
33
|
"node-fetch": "^2.6.7",
|
|
33
34
|
"pdfmake": "^0.2.4",
|
|
34
35
|
"ramda": "^0.28.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
+
"@raytio/react-intl-manager": "^6.3.0",
|
|
39
|
+
"@types/jest": "^27.4.1",
|
|
38
40
|
"@types/jest-image-snapshot": "^4.3.1",
|
|
39
41
|
"@types/jsx-pdf": "^2.2.2",
|
|
40
42
|
"@types/mime-types": "^2.1.1",
|
|
41
|
-
"@types/node": "^16.11.
|
|
43
|
+
"@types/node": "^16.11.26",
|
|
42
44
|
"@types/node-fetch": "^2.5.12",
|
|
43
45
|
"@types/pdfmake": "^0.1.20",
|
|
44
|
-
"@types/ramda": "^0.
|
|
46
|
+
"@types/ramda": "^0.28.1",
|
|
47
|
+
"babel-preset-react-app": "^10.0.1",
|
|
45
48
|
"dotenv": "^16.0.0",
|
|
46
|
-
"eslint": "^8.
|
|
47
|
-
"eslint-config-kyle": "^8.
|
|
49
|
+
"eslint": "^8.11.0",
|
|
50
|
+
"eslint-config-kyle": "^8.13.0",
|
|
48
51
|
"jest": "^27.5.1",
|
|
49
52
|
"jest-image-snapshot": "^4.5.1",
|
|
50
53
|
"jest-junit": "^13.0.0",
|
|
51
54
|
"pdf-to-img": "^1.2.0",
|
|
52
55
|
"ts-jest": "^27.1.3",
|
|
53
|
-
"ts-node": "^10.
|
|
54
|
-
"typescript": "^4.
|
|
56
|
+
"ts-node": "^10.7.0",
|
|
57
|
+
"typescript": "^4.6.2"
|
|
55
58
|
},
|
|
56
59
|
"eslintConfig": {
|
|
57
60
|
"extends": "kyle",
|
|
@@ -70,6 +73,9 @@
|
|
|
70
73
|
}
|
|
71
74
|
},
|
|
72
75
|
"jest": {
|
|
76
|
+
"testMatch": [
|
|
77
|
+
"**/__tests__/?(*.)+(spec|test).[jt]s?(x)"
|
|
78
|
+
],
|
|
73
79
|
"transform": {
|
|
74
80
|
"^.+\\.(t|j)sx?$": "ts-jest"
|
|
75
81
|
},
|
|
@@ -88,10 +94,14 @@
|
|
|
88
94
|
"/dist/",
|
|
89
95
|
"/coverage/"
|
|
90
96
|
],
|
|
97
|
+
"moduleDirectories": [
|
|
98
|
+
"node_modules",
|
|
99
|
+
"src"
|
|
100
|
+
],
|
|
91
101
|
"testTimeout": 300000,
|
|
92
102
|
"testEnvironment": "node",
|
|
93
103
|
"setupFilesAfterEnv": [
|
|
94
|
-
"./
|
|
104
|
+
"./src/__tests__/setupTests.ts"
|
|
95
105
|
],
|
|
96
106
|
"reporters": [
|
|
97
107
|
"default",
|
|
@@ -104,5 +114,11 @@
|
|
|
104
114
|
},
|
|
105
115
|
"engines": {
|
|
106
116
|
"node": ">=14"
|
|
117
|
+
},
|
|
118
|
+
"i18n": {
|
|
119
|
+
"localeDir": "src/locales/translations",
|
|
120
|
+
"messagesDir": "tmp/.messages",
|
|
121
|
+
"codeQualityReport": "tmp/codequality.json",
|
|
122
|
+
"moduleSourceName": false
|
|
107
123
|
}
|
|
108
124
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const fetchEnvConfig_1 = require("../fetchEnvConfig");
|
|
13
|
-
describe.each `
|
|
14
|
-
clientUrl | apiUrl
|
|
15
|
-
${"https://app.rayt.io"} | ${"https://api.rayt.io"}
|
|
16
|
-
${"https://app-dev.rayt.io"} | ${"https://api-dev.rayt.io"}
|
|
17
|
-
`("fetchEnvConfig $clientUrl / $apiUrl", ({ clientUrl, apiUrl }) => {
|
|
18
|
-
it("works if you pass it a valid client url", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
expect(yield (0, fetchEnvConfig_1.fetchEnvConfig)(clientUrl)).toStrictEqual({
|
|
20
|
-
api_url: apiUrl,
|
|
21
|
-
cognito_region: "us-east-1",
|
|
22
|
-
cognito_user_pool_id: expect.any(String),
|
|
23
|
-
cognito_web_client_id: expect.any(String),
|
|
24
|
-
});
|
|
25
|
-
}));
|
|
26
|
-
it("throws an error if you pass it an invalid url", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
yield expect(() => (0, fetchEnvConfig_1.fetchEnvConfig)(apiUrl)).rejects.toThrow(new Error(`The CLIENT_URL you specified is not a valid Raytio client. Are you sure you used the client URL, not the API url? You supplied: "${apiUrl}" (Error: Missing: cognito_region, cognito_user_pool_id, cognito_web_client_id, api_url)`));
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const getFiles_1 = require("../getFiles");
|
|
13
|
-
const IMAGE_URL = "https://gitlab.com/raytio/tools/decrypt-helper/uploads/1d7e98aece246b19846d6d994ddca792/dl_limited.jpg";
|
|
14
|
-
describe("getFiles", () => {
|
|
15
|
-
it("can fetch files from urn:temp_object:", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const profileObjects = [
|
|
17
|
-
{
|
|
18
|
-
n_id: "my_drivers_lisense",
|
|
19
|
-
properties: {
|
|
20
|
-
name: "sam sample",
|
|
21
|
-
age: 123,
|
|
22
|
-
photo: {
|
|
23
|
-
content: `urn:temp_object:${btoa(IMAGE_URL)}`,
|
|
24
|
-
n_id: "my_image",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
labels: ["ss_driver_license"],
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
const instance = {};
|
|
31
|
-
const envConfig = {};
|
|
32
|
-
const applicationDecryptor = {
|
|
33
|
-
decrypt() {
|
|
34
|
-
throw new Error("This shouldn't be called");
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
const files = yield (0, getFiles_1.getFiles)(profileObjects, instance, "api token", envConfig, applicationDecryptor);
|
|
38
|
-
expect(files).toStrictEqual({
|
|
39
|
-
my_image: [expect.any(String), "jpeg"],
|
|
40
|
-
});
|
|
41
|
-
expect(files.my_image[0].startsWith("data:image/jpeg;base64,/9j/4QCGRXhpZgAATU0AKgAA")).toBe(true);
|
|
42
|
-
// eslint-disable-next-line jest/prefer-to-have-length -- because jest will print the huge b64 to the terminal if it fails
|
|
43
|
-
expect(files.my_image[0].length).toBe(57987);
|
|
44
|
-
}));
|
|
45
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const types_1 = require("@raytio/types");
|
|
13
|
-
const formatOutput_1 = require("../formatOutput");
|
|
14
|
-
const api_1 = require("../../api");
|
|
15
|
-
jest.mock("../../api");
|
|
16
|
-
const profileObjects = [
|
|
17
|
-
{
|
|
18
|
-
labels: ["ss_name"],
|
|
19
|
-
properties: { fName: "john", lName: "doe" },
|
|
20
|
-
n_id: "n1",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
labels: ["ss_nz_drivers_license"],
|
|
24
|
-
properties: { license_number: "DW012345", issuer: "NZTA" },
|
|
25
|
-
n_id: "n2",
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
labels: ["ss_nsw_drivers_license"],
|
|
29
|
-
properties: { license_number: "ABC123", city: "Sydney" },
|
|
30
|
-
n_id: "n3",
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
const allSchemas = [
|
|
34
|
-
{ name: "ss_name", title: "Your Name", description: "", properties: {} },
|
|
35
|
-
{
|
|
36
|
-
name: "ss_nz_drivers_license",
|
|
37
|
-
schema_group: "DL",
|
|
38
|
-
title: "NZ Drivers License",
|
|
39
|
-
description: "",
|
|
40
|
-
properties: {},
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "ss_nsw_drivers_license",
|
|
44
|
-
schema_group: "DL",
|
|
45
|
-
title: "NSW Drivers License",
|
|
46
|
-
description: "",
|
|
47
|
-
properties: {},
|
|
48
|
-
},
|
|
49
|
-
];
|
|
50
|
-
const realVers = [];
|
|
51
|
-
describe("formatOutput", () => {
|
|
52
|
-
beforeEach(() => {
|
|
53
|
-
m(api_1.resolveVerificationDetails).mockResolvedValue(Symbol.for("VerificationDetails"));
|
|
54
|
-
});
|
|
55
|
-
it("does not use schema_group to group schema", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
const output = yield (0, formatOutput_1.formatOutput)(profileObjects, allSchemas, realVers, "[apiToken]",
|
|
57
|
-
// @ts-expect-error testing if it works with booleans not stringied bools
|
|
58
|
-
Symbol.for("envConfig"));
|
|
59
|
-
expect(output).toStrictEqual({
|
|
60
|
-
ss_nz_drivers_license: [
|
|
61
|
-
{
|
|
62
|
-
$verification_details: Symbol.for("VerificationDetails"),
|
|
63
|
-
$verified: types_1.POVerification.NotVerified,
|
|
64
|
-
$shouldBeVerifiedFields: undefined,
|
|
65
|
-
$nId: "n2",
|
|
66
|
-
$properties: {
|
|
67
|
-
issuer: {
|
|
68
|
-
title: "issuer",
|
|
69
|
-
value: "NZTA",
|
|
70
|
-
verification: types_1.FieldVerification.NotVerified,
|
|
71
|
-
},
|
|
72
|
-
license_number: {
|
|
73
|
-
title: "license_number",
|
|
74
|
-
value: "DW012345",
|
|
75
|
-
verification: types_1.FieldVerification.NotVerified,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
$safeHarbour: "NOT_APPLICABLE",
|
|
79
|
-
$schemaName: "ss_nz_drivers_license",
|
|
80
|
-
$schemaTitle: "NZ Drivers License",
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
ss_nsw_drivers_license: [
|
|
84
|
-
{
|
|
85
|
-
$verification_details: Symbol.for("VerificationDetails"),
|
|
86
|
-
$verified: types_1.POVerification.NotVerified,
|
|
87
|
-
$shouldBeVerifiedFields: undefined,
|
|
88
|
-
$nId: "n3",
|
|
89
|
-
$properties: {
|
|
90
|
-
city: {
|
|
91
|
-
title: "city",
|
|
92
|
-
value: "Sydney",
|
|
93
|
-
verification: types_1.FieldVerification.NotVerified,
|
|
94
|
-
},
|
|
95
|
-
license_number: {
|
|
96
|
-
title: "license_number",
|
|
97
|
-
value: "ABC123",
|
|
98
|
-
verification: types_1.FieldVerification.NotVerified,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
$safeHarbour: "NOT_APPLICABLE",
|
|
102
|
-
$schemaName: "ss_nsw_drivers_license",
|
|
103
|
-
$schemaTitle: "NSW Drivers License",
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
ss_name: [
|
|
107
|
-
{
|
|
108
|
-
$verification_details: Symbol.for("VerificationDetails"),
|
|
109
|
-
$verified: types_1.POVerification.NotVerified,
|
|
110
|
-
$shouldBeVerifiedFields: undefined,
|
|
111
|
-
$nId: "n1",
|
|
112
|
-
$properties: {
|
|
113
|
-
fName: {
|
|
114
|
-
title: "fName",
|
|
115
|
-
value: "john",
|
|
116
|
-
verification: types_1.FieldVerification.NotVerified,
|
|
117
|
-
},
|
|
118
|
-
lName: {
|
|
119
|
-
title: "lName",
|
|
120
|
-
value: "doe",
|
|
121
|
-
verification: types_1.FieldVerification.NotVerified,
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
$safeHarbour: "NOT_APPLICABLE",
|
|
125
|
-
$schemaName: "ss_name",
|
|
126
|
-
$schemaTitle: "Your Name",
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
});
|
|
130
|
-
}));
|
|
131
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const getLookupOption_ts_1 = require("../../api/getLookupOption.ts");
|
|
13
|
-
const lookup_ts_1 = require("../lookup.ts");
|
|
14
|
-
jest.mock("../../api/getLookupOption.ts");
|
|
15
|
-
describe("maybeAddLookupValue", () => {
|
|
16
|
-
it("returns lookup if no value", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
getLookupOption_ts_1.getLookupOption.mockImplementation(() => []);
|
|
18
|
-
const value = "NZ";
|
|
19
|
-
const key = "country";
|
|
20
|
-
const schema = {
|
|
21
|
-
properties: {
|
|
22
|
-
country: {
|
|
23
|
-
priority: 200,
|
|
24
|
-
tags: ["display:no_autofill"],
|
|
25
|
-
description: "The country of this location",
|
|
26
|
-
default: "NZ",
|
|
27
|
-
type: "string",
|
|
28
|
-
title: "Location country",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
const result = yield (0, lookup_ts_1.maybeAddLookupValue)(schema, key, value);
|
|
33
|
-
expect(result).toBe("NZ");
|
|
34
|
-
}));
|
|
35
|
-
it("Returns lookup value", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
getLookupOption_ts_1.getLookupOption.mockImplementation(() => [
|
|
37
|
-
{ key: "NZ", value: "New Zealand" },
|
|
38
|
-
]);
|
|
39
|
-
const value = "NZ";
|
|
40
|
-
const key = "country";
|
|
41
|
-
const schema = {
|
|
42
|
-
properties: {
|
|
43
|
-
country: {
|
|
44
|
-
priority: 200,
|
|
45
|
-
tags: ["display:no_autofill"],
|
|
46
|
-
lookup: "https://LookupAPI.yes",
|
|
47
|
-
description: "The country of this location",
|
|
48
|
-
default: "NZ",
|
|
49
|
-
type: "string",
|
|
50
|
-
title: "Location country",
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
const result = yield (0, lookup_ts_1.maybeAddLookupValue)(schema, key, value);
|
|
55
|
-
expect(result).toBe("New Zealand");
|
|
56
|
-
}));
|
|
57
|
-
it("Returns value if no corresponding key in lookup", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
-
getLookupOption_ts_1.getLookupOption.mockImplementation(() => [
|
|
59
|
-
{ key: "DE", value: "Doesn't Exist" },
|
|
60
|
-
]);
|
|
61
|
-
const value = "NZ";
|
|
62
|
-
const key = "country";
|
|
63
|
-
const schema = {
|
|
64
|
-
properties: {
|
|
65
|
-
country: {
|
|
66
|
-
priority: 200,
|
|
67
|
-
tags: ["display:no_autofill"],
|
|
68
|
-
lookup: "https://LookupAPI.yes",
|
|
69
|
-
description: "The country of this location",
|
|
70
|
-
default: "NZ",
|
|
71
|
-
type: "string",
|
|
72
|
-
title: "Location country",
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
const result = yield (0, lookup_ts_1.maybeAddLookupValue)(schema, key, value);
|
|
77
|
-
expect(result).toBe("NZ");
|
|
78
|
-
}));
|
|
79
|
-
});
|
package/dist/test/pdf.d.ts
DELETED
package/dist/test/pdf.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* This is just for developing locally
|
|
4
|
-
*/
|
|
5
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const fs_1 = require("fs");
|
|
10
|
-
const pdfmake_1 = __importDefault(require("pdfmake"));
|
|
11
|
-
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
12
|
-
const path_1 = require("path");
|
|
13
|
-
const Report_1 = require("../pdf/components/Report");
|
|
14
|
-
const style_1 = require("../pdf/style");
|
|
15
|
-
let json;
|
|
16
|
-
try {
|
|
17
|
-
json = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, "../../out.json"), { encoding: "utf-8" }));
|
|
18
|
-
}
|
|
19
|
-
catch (_a) {
|
|
20
|
-
console.error("You need to save some data into out.json beforing using this test script");
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
let files = {};
|
|
24
|
-
try {
|
|
25
|
-
files = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, "../../out-otherfiles.json"), {
|
|
26
|
-
encoding: "utf-8",
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
catch (_b) {
|
|
30
|
-
console.warn("Files not found");
|
|
31
|
-
}
|
|
32
|
-
const printer = new pdfmake_1.default(style_1.fonts);
|
|
33
|
-
const pdfDoc = printer.createPdfKitDocument(jsx_pdf_1.default.renderPdf(jsx_pdf_1.default.createElement(Report_1.Report, { data: json, files: files, aId: "my_a_id", clientUrl: "https://example.com", config: { DATE_FORMAT: "fr-FR", TIMEZONE: "Atlantic/Azores" }, version: "\u2764\uFE0F\u200D\uD83D\uDD25" })));
|
|
34
|
-
pdfDoc.pipe((0, fs_1.createWriteStream)("out.pdf"));
|
|
35
|
-
pdfDoc.end();
|