@raytio/decrypt-helper 6.1.0 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/api/authedFetch.d.ts +1 -0
  2. package/dist/api/authedFetch.js +33 -0
  3. package/dist/api/fetchAA.d.ts +3 -0
  4. package/dist/api/fetchAA.js +19 -0
  5. package/dist/api/fetchEnvConfig.d.ts +6 -0
  6. package/dist/api/fetchEnvConfig.js +39 -0
  7. package/dist/api/fetchInstanceData.d.ts +3 -0
  8. package/dist/api/fetchInstanceData.js +21 -0
  9. package/dist/api/getFiles.d.ts +6 -0
  10. package/dist/api/getFiles.js +92 -0
  11. package/dist/api/getLookupOption.d.ts +2 -0
  12. package/dist/api/getLookupOption.js +32 -0
  13. package/dist/api/getSchema.d.ts +3 -0
  14. package/dist/api/getSchema.js +23 -0
  15. package/dist/api/index.d.ts +9 -0
  16. package/dist/api/index.js +25 -0
  17. package/dist/api/resolveVerificationDetails.d.ts +11 -0
  18. package/dist/api/resolveVerificationDetails.js +36 -0
  19. package/dist/api/signIn.d.ts +7 -0
  20. package/dist/api/signIn.js +56 -0
  21. package/dist/api/updateInstanceData.d.ts +2 -0
  22. package/dist/api/updateInstanceData.js +19 -0
  23. package/dist/api/uploadToObjectStore.d.ts +5 -0
  24. package/dist/api/uploadToObjectStore.js +42 -0
  25. package/dist/api/videoToImage.d.ts +3 -0
  26. package/dist/api/videoToImage.js +30 -0
  27. package/dist/configureEnv.d.ts +1 -0
  28. package/dist/configureEnv.js +30 -0
  29. package/dist/constants.d.ts +23 -0
  30. package/dist/constants.js +45 -0
  31. package/dist/helpers/file.d.ts +13 -0
  32. package/dist/helpers/file.js +17 -0
  33. package/dist/helpers/formatOutput.d.ts +28 -0
  34. package/dist/helpers/formatOutput.js +93 -0
  35. package/dist/helpers/index.d.ts +6 -0
  36. package/dist/helpers/index.js +22 -0
  37. package/dist/helpers/json2csv.d.ts +2 -0
  38. package/dist/helpers/json2csv.js +24 -0
  39. package/dist/helpers/lookup.d.ts +2 -0
  40. package/dist/helpers/lookup.js +22 -0
  41. package/dist/helpers/setupMaxcryptor.d.ts +4 -0
  42. package/dist/helpers/setupMaxcryptor.js +28 -0
  43. package/dist/helpers/splitPOAndVers.d.ts +2 -0
  44. package/dist/helpers/splitPOAndVers.js +12 -0
  45. package/dist/helpers/types.d.ts +1 -0
  46. package/dist/helpers/types.js +9 -0
  47. package/dist/index.d.ts +7 -0
  48. package/dist/index.js +18 -0
  49. package/dist/locales/index.d.ts +44 -0
  50. package/dist/locales/index.js +22 -0
  51. package/dist/locales/translations/en.json +33 -0
  52. package/dist/pdf/components/FieldVerificationBadge.d.ts +6 -0
  53. package/dist/pdf/components/FieldVerificationBadge.js +19 -0
  54. package/dist/pdf/components/Images.d.ts +6 -0
  55. package/dist/pdf/components/Images.js +20 -0
  56. package/dist/pdf/components/InnerTableRows.d.ts +11 -0
  57. package/dist/pdf/components/InnerTableRows.js +37 -0
  58. package/dist/pdf/components/POVerificationBadge.d.ts +8 -0
  59. package/dist/pdf/components/POVerificationBadge.js +41 -0
  60. package/dist/pdf/components/Report.d.ts +13 -0
  61. package/dist/pdf/components/Report.js +98 -0
  62. package/dist/pdf/components/Subheader.d.ts +2 -0
  63. package/dist/pdf/components/Subheader.js +28 -0
  64. package/dist/pdf/components/Table.d.ts +9 -0
  65. package/dist/pdf/components/Table.js +47 -0
  66. package/dist/pdf/components/TableTitle.d.ts +5 -0
  67. package/dist/pdf/components/TableTitle.js +17 -0
  68. package/dist/pdf/components/ValidationDisplay.d.ts +5 -0
  69. package/dist/pdf/components/ValidationDisplay.js +29 -0
  70. package/dist/pdf/components/VerifyBox.d.ts +9 -0
  71. package/dist/pdf/components/VerifyBox.js +19 -0
  72. package/dist/pdf/components/pieChart.d.ts +6 -0
  73. package/dist/pdf/components/pieChart.js +27 -0
  74. package/dist/pdf/constants.d.ts +3 -0
  75. package/dist/pdf/constants.js +12 -0
  76. package/dist/pdf/helpers/general.d.ts +8 -0
  77. package/dist/pdf/helpers/general.js +37 -0
  78. package/dist/pdf/helpers/transform.d.ts +4 -0
  79. package/dist/pdf/helpers/transform.js +39 -0
  80. package/dist/pdf/style.d.ts +10 -0
  81. package/dist/pdf/style.js +24 -0
  82. package/dist/public-methods/generatePDF.d.ts +4 -0
  83. package/dist/public-methods/generatePDF.js +60 -0
  84. package/dist/public-methods/getAndValidateConfig.d.ts +8 -0
  85. package/dist/public-methods/getAndValidateConfig.js +20 -0
  86. package/dist/public-methods/processSubmission.d.ts +49 -0
  87. package/dist/public-methods/processSubmission.js +128 -0
  88. package/dist/public-methods/saveToS3Bucket.d.ts +2 -0
  89. package/dist/public-methods/saveToS3Bucket.js +60 -0
  90. package/dist/public-methods/version.d.ts +2 -0
  91. package/dist/public-methods/version.js +15 -0
  92. package/package.json +7 -7
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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
+ const types_1 = require("@raytio/types");
5
+ const locales_1 = require("./locales");
6
+ exports.ATTRIBUTE_MAP = {
7
+ "custom:kek_derivation": ["kek_derivation_config"],
8
+ "custom:dek_encryption": ["private_key_encryption_config"],
9
+ "custom:aek_public": ["encryption_key_pair", "public_key"],
10
+ "custom:aek_private": ["encryption_key_pair", "private_key"],
11
+ "custom:ask_public": ["signing_key_pair", "public_key"],
12
+ "custom:ask_private": ["signing_key_pair", "private_key"],
13
+ };
14
+ exports.INSTANCE_FIELDS_TO_REMOVE = [
15
+ "profile_objects",
16
+ "relationships",
17
+ "keys",
18
+ "score",
19
+ ];
20
+ exports.FIELDS_TO_REMOVE = ["n_id", "document"];
21
+ exports.ENV_VARIABLES = [
22
+ "CLIENT_URL",
23
+ "RAYTIO_USERNAME",
24
+ "RAYTIO_PASSWORD",
25
+ ];
26
+ exports.PO_VER_TEXT_MAP = {
27
+ [types_1.POVerification.FullyVerified]: (0, locales_1.$$)("POVerification.FullyVerified"),
28
+ [types_1.POVerification.PartiallyVerified]: (0, locales_1.$$)("POVerification.PartiallyVerified"),
29
+ [types_1.POVerification.NotVerified]: (0, locales_1.$$)("POVerification.NotVerified"),
30
+ [types_1.POVerification.Expired]: (0, locales_1.$$)("POVerification.Expired"),
31
+ [types_1.POVerification.VerifiedFalse]: (0, locales_1.$$)("POVerification.VerifiedFalse"),
32
+ // not possible but included here for completeness
33
+ [types_1.POVerification.Encrypted]: (0, locales_1.$$)("POVerification.Encrypted"),
34
+ [types_1.POVerification.Loading]: (0, locales_1.$$)("POVerification.Loading"),
35
+ };
36
+ exports.FIELD_VER_TEXT_MAP = {
37
+ [types_1.FieldVerification.Verified]: (0, locales_1.$$)("FieldVerification.Verified"),
38
+ [types_1.FieldVerification.NotVerified]: (0, locales_1.$$)("FieldVerification.NotVerified"),
39
+ [types_1.FieldVerification.Expired]: (0, locales_1.$$)("FieldVerification.Expired"),
40
+ [types_1.FieldVerification.VerifiedFalse]: (0, locales_1.$$)("FieldVerification.VerifiedFalse"),
41
+ };
42
+ exports.SCHEMA = {
43
+ VERIFICATION: "ss_Verification",
44
+ PERSON: "ss_Person_Name",
45
+ };
@@ -0,0 +1,13 @@
1
+ import type { Encrypted, NId, Urn } from "@raytio/types";
2
+ import type { FlatPO } from "./formatOutput";
3
+ export type RaytFile = {
4
+ n_id: NId;
5
+ content: Urn | Encrypted;
6
+ } | {
7
+ n_id: NId;
8
+ Content: Urn | Encrypted;
9
+ };
10
+ /** checks if a field value is a file */
11
+ export declare const isFieldValueFile: (fieldValue: unknown) => fieldValue is RaytFile;
12
+ /** checks if a PO is a file */
13
+ export declare const isPOFile: (PO: FlatPO) => boolean;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPOFile = exports.isFieldValueFile = void 0;
4
+ const core_1 = require("@raytio/core");
5
+ const URN_PREFIX = "urn:";
6
+ /** @internal */
7
+ const isObject = (x) => !!x && typeof x === "object";
8
+ /** @internal */
9
+ const isUrnOrEncrypted = (x) => (typeof x === "string" && x.startsWith(URN_PREFIX)) || (0, core_1.isEncrypted)(x);
10
+ /** checks if a field value is a file */
11
+ const isFieldValueFile = (fieldValue) => isObject(fieldValue) &&
12
+ "content" in fieldValue &&
13
+ isUrnOrEncrypted(fieldValue.content);
14
+ exports.isFieldValueFile = isFieldValueFile;
15
+ /** checks if a PO is a file */
16
+ const isPOFile = (PO) => { var _a; return (0, exports.isFieldValueFile)({ content: (_a = PO.$properties.content) === null || _a === void 0 ? void 0 : _a.value }); };
17
+ exports.isPOFile = isPOFile;
@@ -0,0 +1,28 @@
1
+ import { FieldVerification, NId, POVerification, ProfileObject, RealVer, Schema } from "@raytio/types";
2
+ import { ResolvedVerificationProvider, EnvConfig } from "../api";
3
+ export type FlatPO = {
4
+ $verification_details: ResolvedVerificationProvider | undefined;
5
+ $shouldBeVerifiedFields: string[] | undefined;
6
+ $nId: NId;
7
+ $schemaName: string;
8
+ $schemaTitle: string;
9
+ $properties: {
10
+ [fieldName: string]: {
11
+ title: string;
12
+ value: unknown;
13
+ formatted_value?: string | number;
14
+ verification: FieldVerification;
15
+ };
16
+ };
17
+ $badges: {
18
+ verified: {
19
+ code: POVerification;
20
+ statusText: string;
21
+ };
22
+ safeHarbour?: {
23
+ code: boolean;
24
+ statusText: string;
25
+ };
26
+ };
27
+ };
28
+ export declare function formatOutput(profileObjects: ProfileObject[], allSchemas: Schema[], realVers: RealVer[], apiToken: string, envConfig: EnvConfig): Promise<Record<string, FlatPO[]>>;
@@ -0,0 +1,93 @@
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
+ exports.formatOutput = void 0;
13
+ const core_1 = require("@raytio/core");
14
+ const ramda_1 = require("ramda");
15
+ const types_1 = require("@raytio/types");
16
+ const locales_1 = require("../locales");
17
+ const api_1 = require("../api");
18
+ const constants_1 = require("../constants");
19
+ const lookup_1 = require("./lookup");
20
+ const types_2 = require("./types");
21
+ const byPriority = (schema) => ([a], [b]) => {
22
+ var _a, _b, _c, _d, _e, _f;
23
+ (0, types_2.assertSafeProperty)(a);
24
+ (0, types_2.assertSafeProperty)(b);
25
+ // if no priority, it becomes the last
26
+ const aPriority = (_c = (_b = (_a = schema.properties) === null || _a === void 0 ? void 0 : _a[a]) === null || _b === void 0 ? void 0 : _b.priority) !== null && _c !== void 0 ? _c : Infinity;
27
+ const bPriority = (_f = (_e = (_d = schema.properties) === null || _d === void 0 ? void 0 : _d[b]) === null || _e === void 0 ? void 0 : _e.priority) !== null && _f !== void 0 ? _f : Infinity;
28
+ return aPriority - bPriority;
29
+ };
30
+ function formatOutput(profileObjects, allSchemas, realVers, apiToken, envConfig) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const PODetails = profileObjects.reduce((accumulatorPromiseOuter, PO) => __awaiter(this, void 0, void 0, function* () {
33
+ var _a;
34
+ const accumulatorOuter = yield accumulatorPromiseOuter;
35
+ const schemaName = (0, core_1.findSchemaLabel)(PO.labels);
36
+ const schema = allSchemas.find((x) => x.name === schemaName);
37
+ if (!schema)
38
+ throw new Error(`${schema} is missing!`);
39
+ const versionDetails = (0, core_1.getPOVerification)({ PO, schema, realVers });
40
+ const realProperties = (0, ramda_1.omit)(constants_1.FIELDS_TO_REMOVE, PO.properties);
41
+ (0, types_2.assertSafeProperty)(schemaName);
42
+ const existing = accumulatorOuter[schemaName] || [];
43
+ const poProperties = Object.entries(realProperties).sort(byPriority(schema));
44
+ const reducedProperties = yield poProperties.reduce((accumulatorPromiseInner, [key, value]) => __awaiter(this, void 0, void 0, function* () {
45
+ var _b, _c;
46
+ const accumulatorInner = yield accumulatorPromiseInner;
47
+ (0, types_2.assertSafeProperty)(key);
48
+ const prettyValue = typeof value === "string"
49
+ ? yield (0, lookup_1.maybeGetLookupValue)(schema, key, value, apiToken)
50
+ : undefined;
51
+ const POInfo = {
52
+ title: ((_c = (_b = schema.properties) === null || _b === void 0 ? void 0 : _b[key]) === null || _c === void 0 ? void 0 : _c.title) || key,
53
+ value,
54
+ verification: versionDetails.fieldVerifications[key] ||
55
+ types_1.FieldVerification.NotVerified,
56
+ };
57
+ if (prettyValue)
58
+ POInfo.formatted_value = prettyValue;
59
+ return Object.assign(Object.assign({}, accumulatorInner), { [key]: POInfo });
60
+ }), Promise.resolve({}));
61
+ const thisPO = {
62
+ $verification_details: yield (0, api_1.resolveVerificationDetails)(versionDetails.details.verifiers, envConfig),
63
+ $shouldBeVerifiedFields: (_a = schema.verified_fields) === null || _a === void 0 ? void 0 : _a.map((x) => typeof x === "string" ? x : x.field),
64
+ $nId: PO.n_id,
65
+ $schemaName: schemaName,
66
+ $schemaTitle: schema.title,
67
+ $properties: reducedProperties,
68
+ $badges: {
69
+ verified: {
70
+ code: versionDetails.status,
71
+ statusText: constants_1.PO_VER_TEXT_MAP[versionDetails.status],
72
+ },
73
+ safeHarbour: schemaName === constants_1.SCHEMA.PERSON
74
+ ? yield (0, core_1.calcSafeHarbourScore)({
75
+ person: PO,
76
+ getSchema: (name) => __awaiter(this, void 0, void 0, function* () { return allSchemas.find((x) => x.name === name); }),
77
+ profileObjects,
78
+ realVers,
79
+ }).then(({ isSafe }) => ({
80
+ code: isSafe,
81
+ statusText: isSafe
82
+ ? (0, locales_1.$$)("POVerificationBadge.safe-harbour-yes")
83
+ : (0, locales_1.$$)("POVerificationBadge.safe-harbour-no"),
84
+ }))
85
+ : undefined,
86
+ },
87
+ };
88
+ return Object.assign(Object.assign({}, accumulatorOuter), { [schemaName]: [...existing, thisPO] });
89
+ }), Promise.resolve({}));
90
+ return PODetails;
91
+ });
92
+ }
93
+ exports.formatOutput = formatOutput;
@@ -0,0 +1,6 @@
1
+ export * from "./formatOutput";
2
+ export * from "./json2csv";
3
+ export * from "./setupMaxcryptor";
4
+ export * from "./splitPOAndVers";
5
+ export * from "./file";
6
+ export * from "./types";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
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);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./formatOutput"), exports);
18
+ __exportStar(require("./json2csv"), exports);
19
+ __exportStar(require("./setupMaxcryptor"), exports);
20
+ __exportStar(require("./splitPOAndVers"), exports);
21
+ __exportStar(require("./file"), exports);
22
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const flattenObject: (rootObject: Record<string, unknown>) => Record<string, never>;
2
+ export declare function deepJsonToCsv(json: Record<string, unknown>): string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deepJsonToCsv = exports.flattenObject = void 0;
4
+ const ramda_1 = require("ramda");
5
+ // copied from raytio-client
6
+ const flattenObject = (rootObject) => {
7
+ const go = (object) => (0, ramda_1.chain)(([k, v]) => {
8
+ if ((0, ramda_1.type)(v) === "Object" || (0, ramda_1.type)(v) === "Array") {
9
+ return (0, ramda_1.map)(([k_, v_]) => [`${k}.${k_}`, v_], go(v));
10
+ }
11
+ return [[k, v]];
12
+ }, (0, ramda_1.toPairs)(object));
13
+ return (0, ramda_1.fromPairs)(go(rootObject));
14
+ };
15
+ exports.flattenObject = flattenObject;
16
+ const toCsvRow = (row) => row
17
+ .map((field) => typeof field === "string" ? `"${field.replaceAll('"', '""')}"` : field)
18
+ .join(",");
19
+ function deepJsonToCsv(json) {
20
+ const flatJson = (0, exports.flattenObject)(json);
21
+ const [headerRow, values] = (0, ramda_1.transpose)(Object.entries(flatJson));
22
+ return `${toCsvRow(headerRow)}\n${toCsvRow(values)}`;
23
+ }
24
+ exports.deepJsonToCsv = deepJsonToCsv;
@@ -0,0 +1,2 @@
1
+ import { Schema } from "@raytio/types";
2
+ export declare const maybeGetLookupValue: <T>(schema: Schema, k: string, value: T, apiToken: string) => Promise<string | number | T | undefined>;
@@ -0,0 +1,22 @@
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
+ exports.maybeGetLookupValue = void 0;
13
+ const getLookupOption_1 = require("../api/getLookupOption");
14
+ const maybeGetLookupValue = (schema, k, value, apiToken) => __awaiter(void 0, void 0, void 0, function* () {
15
+ var _a, _b, _c;
16
+ const lookupUrl = (_b = (_a = schema.properties) === null || _a === void 0 ? void 0 : _a[k]) === null || _b === void 0 ? void 0 : _b.lookup;
17
+ if (!lookupUrl)
18
+ return undefined;
19
+ const lookup = yield (0, getLookupOption_1.getLookupOption)(apiToken, lookupUrl);
20
+ return (_c = lookup.find((l) => l.key === value)) === null || _c === void 0 ? void 0 : _c.value;
21
+ });
22
+ exports.maybeGetLookupValue = maybeGetLookupValue;
@@ -0,0 +1,4 @@
1
+ import { Maxcryptor } from "@raytio/maxcryptor";
2
+ import type { ICognitoUserAttributeData } from "amazon-cognito-identity-js";
3
+ import { Config } from "../constants";
4
+ export declare function setupMaxcryptor(CONFIG: Config, cognitoAttributes: ICognitoUserAttributeData[]): Promise<Maxcryptor>;
@@ -0,0 +1,28 @@
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
+ exports.setupMaxcryptor = void 0;
13
+ const maxcryptor_1 = require("@raytio/maxcryptor");
14
+ const ramda_1 = require("ramda");
15
+ const constants_1 = require("../constants");
16
+ const isMaxcryptorAttribute = (name) => name in constants_1.ATTRIBUTE_MAP;
17
+ function setupMaxcryptor(CONFIG, cognitoAttributes) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const userDocument = cognitoAttributes.reduce((accumulator, { Name, Value }) => {
20
+ if (!isMaxcryptorAttribute(Name))
21
+ return accumulator;
22
+ return (0, ramda_1.assocPath)(constants_1.ATTRIBUTE_MAP[Name], JSON.parse(Value), accumulator);
23
+ }, {});
24
+ const { encryptor: maxcryptor } = yield (0, maxcryptor_1.encryptorFromExistingUser)(userDocument, CONFIG.RAYTIO_PASSWORD);
25
+ return maxcryptor;
26
+ });
27
+ }
28
+ exports.setupMaxcryptor = setupMaxcryptor;
@@ -0,0 +1,2 @@
1
+ import type { ProfileObject, Verification } from "@raytio/types";
2
+ export declare const splitPOAndVers: (list: ProfileObject[]) => [ProfileObject[], Verification[]];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitPOAndVers = void 0;
4
+ const core_1 = require("@raytio/core");
5
+ const constants_1 = require("../constants");
6
+ const splitPOAndVers = (list) => list.reduce((accumulator, PO) => {
7
+ const isVerification = (0, core_1.findSchemaLabel)(PO.labels) === constants_1.SCHEMA.VERIFICATION;
8
+ // move to the left or right array depending on whther +isVerification is 0 or 1
9
+ accumulator[+isVerification].push(PO);
10
+ return accumulator;
11
+ }, [[], []]);
12
+ exports.splitPOAndVers = splitPOAndVers;
@@ -0,0 +1 @@
1
+ export declare function assertSafeProperty(property: unknown): asserts property is string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertSafeProperty = void 0;
4
+ function assertSafeProperty(property) {
5
+ if (typeof property !== "string" || property in {}) {
6
+ throw new Error(`Invalid property name '${property}'`);
7
+ }
8
+ }
9
+ exports.assertSafeProperty = assertSafeProperty;
@@ -0,0 +1,7 @@
1
+ import "./configureEnv";
2
+ export { fetchEnvConfig, EnvConfig } from "./api/fetchEnvConfig";
3
+ export { generatePDF } from "./public-methods/generatePDF";
4
+ export { processSubmission } from "./public-methods/processSubmission";
5
+ export { getAndValidateConfig } from "./public-methods/getAndValidateConfig";
6
+ export { saveToS3Bucket } from "./public-methods/saveToS3Bucket";
7
+ export { version } from "./public-methods/version";
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = exports.saveToS3Bucket = exports.getAndValidateConfig = exports.processSubmission = exports.generatePDF = exports.fetchEnvConfig = void 0;
4
+ // do this first
5
+ require("./configureEnv");
6
+ /* this is what consumers of the package have access to */
7
+ var fetchEnvConfig_1 = require("./api/fetchEnvConfig");
8
+ Object.defineProperty(exports, "fetchEnvConfig", { enumerable: true, get: function () { return fetchEnvConfig_1.fetchEnvConfig; } });
9
+ var generatePDF_1 = require("./public-methods/generatePDF");
10
+ Object.defineProperty(exports, "generatePDF", { enumerable: true, get: function () { return generatePDF_1.generatePDF; } });
11
+ var processSubmission_1 = require("./public-methods/processSubmission");
12
+ Object.defineProperty(exports, "processSubmission", { enumerable: true, get: function () { return processSubmission_1.processSubmission; } });
13
+ var getAndValidateConfig_1 = require("./public-methods/getAndValidateConfig");
14
+ Object.defineProperty(exports, "getAndValidateConfig", { enumerable: true, get: function () { return getAndValidateConfig_1.getAndValidateConfig; } });
15
+ var saveToS3Bucket_1 = require("./public-methods/saveToS3Bucket");
16
+ Object.defineProperty(exports, "saveToS3Bucket", { enumerable: true, get: function () { return saveToS3Bucket_1.saveToS3Bucket; } });
17
+ var version_1 = require("./public-methods/version");
18
+ Object.defineProperty(exports, "version", { enumerable: true, get: function () { return version_1.version; } });
@@ -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 type I18nKey = keyof typeof en;
38
+ export 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>) => string;
44
+ export {};
@@ -0,0 +1,22 @@
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 = (_, variableName) => {
14
+ const value = variables === null || variables === void 0 ? void 0 : variables[variableName];
15
+ if (value === undefined) {
16
+ throw new TypeError(`[i18n] variable '${variableName}' not defined`);
17
+ }
18
+ return `${value}`;
19
+ };
20
+ return strings[key].replaceAll(/{([^}]+)}/g, replaceWithVariable);
21
+ };
22
+ 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
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="jsx-pdf" />
2
+ import { FieldVerification } from "@raytio/types";
3
+ export declare const FieldVerificationBadge: ({ status, width, }: {
4
+ status: FieldVerification | undefined;
5
+ width: number;
6
+ }) => null | JSX.Element;
@@ -0,0 +1,19 @@
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.FieldVerificationBadge = void 0;
7
+ const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
8
+ const types_1 = require("@raytio/types");
9
+ const general_1 = require("../helpers/general");
10
+ const FieldVerificationBadge = ({ status, width, }) => {
11
+ if (status === types_1.FieldVerification.VerifiedFalse) {
12
+ return (jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)("verified_false_small.svg"), width: width }));
13
+ }
14
+ if (status === types_1.FieldVerification.Verified) {
15
+ return jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)("verified_tick_small.svg"), width: width });
16
+ }
17
+ return null;
18
+ };
19
+ exports.FieldVerificationBadge = FieldVerificationBadge;
@@ -0,0 +1,6 @@
1
+ /// <reference types="jsx-pdf" />
2
+ import { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
3
+ export declare const Images: ({ nIds, files, }: {
4
+ nIds: string[];
5
+ files: ProcessSubmissionOutput["files"];
6
+ }) => JSX.Element;
@@ -0,0 +1,20 @@
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.Images = void 0;
7
+ const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
8
+ const locales_1 = require("../../locales");
9
+ const helpers_1 = require("../../helpers");
10
+ const Images = ({ nIds, files, }) => {
11
+ return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null, nIds.map((nId) => {
12
+ var _a;
13
+ // for videos, prefer the static frame over the original video
14
+ const file = (_a = (files[`${nId}_videoFrame`] || files[nId])) === null || _a === void 0 ? void 0 : _a[0];
15
+ if (file)
16
+ (0, helpers_1.assertSafeProperty)(file);
17
+ 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")));
18
+ })));
19
+ };
20
+ exports.Images = Images;
@@ -0,0 +1,11 @@
1
+ /// <reference types="jsx-pdf" />
2
+ import { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
3
+ import { PdfConfig } from "../types";
4
+ export declare const InnerTableRows: ({ key, value, imageFieldNames, config, files, color, }: {
5
+ key: string;
6
+ value: any;
7
+ files: ProcessSubmissionOutput["files"];
8
+ config: PdfConfig;
9
+ color: string;
10
+ imageFieldNames: string[];
11
+ }) => JSX.Element;
@@ -0,0 +1,37 @@
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.InnerTableRows = void 0;
7
+ const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
8
+ const ramda_1 = require("ramda");
9
+ const helpers_1 = require("../../helpers");
10
+ const transform_1 = require("../helpers/transform");
11
+ const Images_1 = require("./Images");
12
+ const ValidationDisplay_1 = require("./ValidationDisplay");
13
+ const InnerTableRows = ({ key, value, imageFieldNames, config, files, color, }) => {
14
+ if (typeof value === "object" &&
15
+ value &&
16
+ "score" in value &&
17
+ "breakdown" in value) {
18
+ return jsx_pdf_1.default.createElement(ValidationDisplay_1.ValidationDisplay, { value: value });
19
+ }
20
+ const text = (0, transform_1.transform)(key, value, config, imageFieldNames);
21
+ if (typeof text !== "string" && text === transform_1.IS_IMAGE) {
22
+ return jsx_pdf_1.default.createElement(Images_1.Images, { files: files, nIds: [value.n_id] });
23
+ }
24
+ if (typeof text !== "string" && text === transform_1.IS_ARRAY_OF_OBJECTS) {
25
+ const headers = [(0, ramda_1.uniq)(value.flatMap(Object.keys))];
26
+ const tableValues = [...headers, ...value];
27
+ return (jsx_pdf_1.default.createElement("table", { headerRows: 1, layout: "headerLineOnly" }, tableValues.map((data, tableValueIndex) => {
28
+ return (jsx_pdf_1.default.createElement("row", null, headers[0].map((header) => {
29
+ (0, helpers_1.assertSafeProperty)(header);
30
+ return (jsx_pdf_1.default.createElement("cell", null,
31
+ jsx_pdf_1.default.createElement(exports.InnerTableRows, { key: header, value: data[header] || (tableValueIndex === 0 ? header : "-"), files: files, config: config, color: color, imageFieldNames: imageFieldNames })));
32
+ })));
33
+ })));
34
+ }
35
+ return jsx_pdf_1.default.createElement("text", { color: color }, text.slice(0, 100));
36
+ };
37
+ exports.InnerTableRows = InnerTableRows;
@@ -0,0 +1,8 @@
1
+ /// <reference types="jsx-pdf" />
2
+ import { POVerification } from "@raytio/types";
3
+ import { FlatPO } from "../../helpers";
4
+ export declare const FILE_MAP: Record<POVerification, string>;
5
+ export declare const POVerificationBadge: ({ width, POs, }: {
6
+ width: number;
7
+ POs: FlatPO[];
8
+ }) => JSX.Element;