@raytio/decrypt-helper 6.3.0 → 6.3.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 (64) hide show
  1. package/dist/api/fetchAA.d.ts +1 -1
  2. package/dist/api/fetchAA.js +1 -1
  3. package/dist/api/fetchInstanceData.d.ts +1 -1
  4. package/dist/api/fetchInstanceData.js +1 -1
  5. package/dist/api/getFiles.d.ts +2 -2
  6. package/dist/api/getFiles.js +3 -3
  7. package/dist/api/getLookupOption.js +1 -1
  8. package/dist/api/getSchema.d.ts +1 -1
  9. package/dist/api/getSchema.js +1 -1
  10. package/dist/api/index.d.ts +9 -9
  11. package/dist/api/index.js +9 -9
  12. package/dist/api/resolveVerificationDetails.d.ts +1 -1
  13. package/dist/api/signIn.d.ts +2 -2
  14. package/dist/api/updateInstanceData.d.ts +1 -1
  15. package/dist/api/updateInstanceData.js +1 -1
  16. package/dist/api/uploadToObjectStore.d.ts +1 -1
  17. package/dist/api/uploadToObjectStore.js +1 -1
  18. package/dist/api/videoToImage.d.ts +1 -1
  19. package/dist/api/videoToImage.js +2 -2
  20. package/dist/configureEnv.js +16 -1
  21. package/dist/constants.d.ts +2 -2
  22. package/dist/constants.js +1 -1
  23. package/dist/helpers/file.d.ts +1 -1
  24. package/dist/helpers/formatOutput.d.ts +1 -1
  25. package/dist/helpers/formatOutput.js +5 -5
  26. package/dist/helpers/index.d.ts +6 -6
  27. package/dist/helpers/index.js +6 -6
  28. package/dist/helpers/lookup.js +15 -2
  29. package/dist/helpers/pathUtils.d.ts +1 -0
  30. package/dist/helpers/pathUtils.js +6 -0
  31. package/dist/helpers/setupMaxcryptor.d.ts +3 -3
  32. package/dist/helpers/setupMaxcryptor.js +5 -4
  33. package/dist/helpers/splitPOAndVers.js +1 -1
  34. package/dist/index.d.ts +7 -7
  35. package/dist/index.js +7 -7
  36. package/dist/pdf/components/FieldVerificationBadge.js +1 -1
  37. package/dist/pdf/components/Images.d.ts +1 -1
  38. package/dist/pdf/components/Images.js +2 -2
  39. package/dist/pdf/components/InnerTableRows.d.ts +2 -2
  40. package/dist/pdf/components/InnerTableRows.js +4 -4
  41. package/dist/pdf/components/POVerificationBadge.d.ts +1 -1
  42. package/dist/pdf/components/POVerificationBadge.js +3 -3
  43. package/dist/pdf/components/Report.d.ts +3 -3
  44. package/dist/pdf/components/Report.js +12 -12
  45. package/dist/pdf/components/Subheader.js +2 -2
  46. package/dist/pdf/components/Table.d.ts +3 -3
  47. package/dist/pdf/components/Table.js +5 -5
  48. package/dist/pdf/components/TableTitle.d.ts +1 -1
  49. package/dist/pdf/components/TableTitle.js +1 -1
  50. package/dist/pdf/components/ValidationDisplay.js +3 -3
  51. package/dist/pdf/components/VerifyBox.js +2 -2
  52. package/dist/pdf/constants.js +1 -1
  53. package/dist/pdf/helpers/general.js +2 -1
  54. package/dist/pdf/helpers/transform.js +2 -2
  55. package/dist/pdf/style.js +1 -1
  56. package/dist/public-methods/generatePDF.d.ts +1 -1
  57. package/dist/public-methods/generatePDF.js +5 -4
  58. package/dist/public-methods/getAndValidateConfig.d.ts +1 -1
  59. package/dist/public-methods/getAndValidateConfig.js +1 -1
  60. package/dist/public-methods/processSubmission.d.ts +4 -4
  61. package/dist/public-methods/processSubmission.js +4 -4
  62. package/dist/public-methods/saveToS3Bucket.d.ts +1 -1
  63. package/dist/public-methods/version.js +2 -1
  64. package/package.json +6 -5
@@ -1,3 +1,3 @@
1
1
  import type { AA, AId } from "@raytio/types";
2
- import type { EnvConfig } from "./fetchEnvConfig";
2
+ import type { EnvConfig } from "./fetchEnvConfig.js";
3
3
  export declare function fetchAA(apiToken: string, envConfig: EnvConfig, aId: AId): Promise<AA>;
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { authedFetch } from "./authedFetch";
10
+ import { authedFetch } from "./authedFetch.js";
11
11
  export function fetchAA(apiToken, envConfig, aId) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
13
  const [AA] = yield authedFetch(apiToken, `${envConfig.api_url}/db/v1/dsm_access_applications?id=eq.${aId}`);
@@ -1,3 +1,3 @@
1
1
  import type { IId, InstanceWithoutData } from "@raytio/types";
2
- import type { EnvConfig } from "./fetchEnvConfig";
2
+ import type { EnvConfig } from "./fetchEnvConfig.js";
3
3
  export declare function fetchInstanceData(apiToken: string, envConfig: EnvConfig, instanceId: IId): Promise<InstanceWithoutData>;
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { authedFetch } from "./authedFetch";
10
+ import { authedFetch } from "./authedFetch.js";
11
11
  export function fetchInstanceData(apiToken, envConfig, instanceId) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
13
  const [instance] = yield authedFetch(apiToken, `${envConfig.api_url}/db/v1/dsm_access_application_instances?id=eq.${instanceId}`);
@@ -1,6 +1,6 @@
1
1
  import type { Instance, NId, ProfileObject } from "@raytio/types";
2
- import type { ApplicationEncryptorLike } from "../types";
3
- import type { EnvConfig } from "./fetchEnvConfig";
2
+ import type { ApplicationEncryptorLike } from "../types.js";
3
+ import type { EnvConfig } from "./fetchEnvConfig.js";
4
4
  type FileObject = Record<NId, [dataUrl: string, fileExtension: string]>;
5
5
  export declare function getFiles(profileObjects: ProfileObject[], instance: Instance, apiToken: string, envConfig: EnvConfig, applicationDecryptor: ApplicationEncryptorLike): Promise<FileObject>;
6
6
  export {};
@@ -9,9 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { getNidFromUrn, isEncrypted } from "@raytio/core";
11
11
  import { extension, types } from "mime-types";
12
- import { isFieldValueFile, isTruthy, isUrn } from "../helpers/file";
13
- import { authedFetch } from "./authedFetch";
14
- import { videoToImage } from "./videoToImage";
12
+ import { isFieldValueFile, isTruthy, isUrn } from "../helpers/file.js";
13
+ import { authedFetch } from "./authedFetch.js";
14
+ import { videoToImage } from "./videoToImage.js";
15
15
  const TEMP_OBJ_PREFIX = "urn:temp_object:";
16
16
  const getFileExtn = (b64) => { var _a; return extension(((_a = b64.split(":")[1]) === null || _a === void 0 ? void 0 : _a.split(";base64,")[0]) || "text/plain") || "txt"; };
17
17
  const decryptFile = (encryptedData, encryptedObject, applicationDecryptor, wdek) => __awaiter(void 0, void 0, void 0, function* () {
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { authedFetch } from "./authedFetch";
10
+ import { authedFetch } from "./authedFetch.js";
11
11
  /**
12
12
  * We cache the promise so that only one XHR request is ever sent
13
13
  */
@@ -1,3 +1,3 @@
1
1
  import type { Schema } from "@raytio/types";
2
- import type { EnvConfig } from "./fetchEnvConfig";
2
+ import type { EnvConfig } from "./fetchEnvConfig.js";
3
3
  export declare function getAllSchema(envConfig: EnvConfig): Promise<Schema[]>;
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { expandSchema } from "@raytio/core";
11
- import { authedFetch } from "./authedFetch";
11
+ import { authedFetch } from "./authedFetch.js";
12
12
  export function getAllSchema(envConfig) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  const list = yield authedFetch("", `${envConfig.api_url}/db/v1/dsm_schema?version_current=eq.true`);
@@ -1,9 +1,9 @@
1
- export * from "./authedFetch";
2
- export * from "./fetchAA";
3
- export * from "./fetchEnvConfig";
4
- export * from "./fetchInstanceData";
5
- export * from "./getFiles";
6
- export * from "./getSchema";
7
- export * from "./resolveVerificationDetails";
8
- export * from "./signIn";
9
- export * from "./updateInstanceData";
1
+ export * from "./authedFetch.js";
2
+ export * from "./fetchAA.js";
3
+ export * from "./fetchEnvConfig.js";
4
+ export * from "./fetchInstanceData.js";
5
+ export * from "./getFiles.js";
6
+ export * from "./getSchema.js";
7
+ export * from "./resolveVerificationDetails.js";
8
+ export * from "./signIn.js";
9
+ export * from "./updateInstanceData.js";
package/dist/api/index.js CHANGED
@@ -1,9 +1,9 @@
1
- export * from "./authedFetch";
2
- export * from "./fetchAA";
3
- export * from "./fetchEnvConfig";
4
- export * from "./fetchInstanceData";
5
- export * from "./getFiles";
6
- export * from "./getSchema";
7
- export * from "./resolveVerificationDetails";
8
- export * from "./signIn";
9
- export * from "./updateInstanceData";
1
+ export * from "./authedFetch.js";
2
+ export * from "./fetchAA.js";
3
+ export * from "./fetchEnvConfig.js";
4
+ export * from "./fetchInstanceData.js";
5
+ export * from "./getFiles.js";
6
+ export * from "./getSchema.js";
7
+ export * from "./resolveVerificationDetails.js";
8
+ export * from "./signIn.js";
9
+ export * from "./updateInstanceData.js";
@@ -1,5 +1,5 @@
1
1
  import type { VerificationProvider } from "@raytio/types";
2
- import type { EnvConfig } from "./fetchEnvConfig";
2
+ import type { EnvConfig } from "./fetchEnvConfig.js";
3
3
  export type ResolvedVerificationProvider = {
4
4
  verifier_id?: string;
5
5
  verifier_service_id?: string;
@@ -1,6 +1,6 @@
1
1
  import type { ICognitoUserAttributeData } from "amazon-cognito-identity-js";
2
- import type { Config } from "../constants";
3
- import type { EnvConfig } from "./fetchEnvConfig";
2
+ import type { Config } from "../constants.js";
3
+ import type { EnvConfig } from "./fetchEnvConfig.js";
4
4
  export declare function signIn(CONFIG: Config, envConfig: EnvConfig): Promise<{
5
5
  apiToken: string;
6
6
  cognitoAttributes: ICognitoUserAttributeData[];
@@ -1,5 +1,5 @@
1
1
  import type { IId, InstanceWithoutData } from "@raytio/types";
2
- import type { EnvConfig } from "./fetchEnvConfig";
2
+ import type { EnvConfig } from "./fetchEnvConfig.js";
3
3
  /**
4
4
  * only specific fields can be updated, passing the entire
5
5
  * instance object to the v3 API will cause an error.
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { authedFetch } from "./authedFetch";
10
+ import { authedFetch } from "./authedFetch.js";
11
11
  /**
12
12
  * only specific fields can be updated, passing the entire
13
13
  * instance object to the v3 API will cause an error.
@@ -1,4 +1,4 @@
1
- import type { EnvConfig } from "./fetchEnvConfig";
1
+ import type { EnvConfig } from "./fetchEnvConfig.js";
2
2
  export declare function uploadToObjectStore(apiToken: string, envConfig: EnvConfig, dataUrl: string, expiryDate?: Date): Promise<{
3
3
  objectStoreId: string;
4
4
  retrievalUrl: string;
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { authedFetch } from "./authedFetch";
10
+ import { authedFetch } from "./authedFetch.js";
11
11
  //
12
12
  // this file is mostly copy-pasted from the client repo. If you make
13
13
  // a change here, consider making the same change in the client.
@@ -1,3 +1,3 @@
1
- import type { EnvConfig } from "./fetchEnvConfig";
1
+ import type { EnvConfig } from "./fetchEnvConfig.js";
2
2
  /** Use the extractor API to get the middle frame from a video */
3
3
  export declare function videoToImage(apiToken: string, envConfig: EnvConfig, videoDataUrl: string): Promise<string>;
@@ -7,8 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { authedFetch } from "./authedFetch";
11
- import { uploadToObjectStore } from "./uploadToObjectStore";
10
+ import { authedFetch } from "./authedFetch.js";
11
+ import { uploadToObjectStore } from "./uploadToObjectStore.js";
12
12
  /** Use the extractor API to get the middle frame from a video */
13
13
  export function videoToImage(apiToken, envConfig, videoDataUrl) {
14
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,4 +1,19 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  // for @aws-amplify/auth
2
11
  import "localstorage-polyfill";
3
12
  // Polyfill crypto for node ≤18.
4
- globalThis.crypto || (globalThis.crypto = require("node:crypto"));
13
+ if (!globalThis.crypto) {
14
+ (() => __awaiter(void 0, void 0, void 0, function* () {
15
+ const { webcrypto } = yield import("node:crypto");
16
+ // @ts-expect-error fix
17
+ globalThis.crypto = webcrypto;
18
+ }))();
19
+ }
@@ -1,4 +1,4 @@
1
- import type { ScoreResult } from "@raytio/core";
1
+ import * as RaytioCore from "@raytio/core";
2
2
  import { FieldVerification, type Instance, POVerification } from "@raytio/types";
3
3
  export declare const ATTRIBUTE_MAP: {
4
4
  "custom:kek_derivation": string[];
@@ -13,7 +13,7 @@ export declare const FIELDS_TO_REMOVE: readonly ["n_id", "document"];
13
13
  export declare const ENV_VARIABLES: readonly ["CLIENT_URL", "RAYTIO_USERNAME", "RAYTIO_PASSWORD"];
14
14
  export type Config = Record<(typeof ENV_VARIABLES)[number], string>;
15
15
  export type InstanceDataToPassOn = Omit<Instance, (typeof INSTANCE_FIELDS_TO_REMOVE)[number]> & {
16
- score?: ScoreResult;
16
+ score?: RaytioCore.ScoreResult;
17
17
  };
18
18
  export declare const PO_VER_TEXT_MAP: Record<POVerification, string>;
19
19
  export declare const FIELD_VER_TEXT_MAP: Record<FieldVerification, string>;
package/dist/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FieldVerification, POVerification, } from "@raytio/types";
2
- import { $$ } from "./locales";
2
+ import { $$ } from "./locales/index.js";
3
3
  export const ATTRIBUTE_MAP = {
4
4
  "custom:kek_derivation": ["kek_derivation_config"],
5
5
  "custom:dek_encryption": ["private_key_encryption_config"],
@@ -1,5 +1,5 @@
1
1
  import type { Encrypted, NId, Urn } from "@raytio/types";
2
- import type { FlatPO } from "./formatOutput";
2
+ import type { FlatPO } from "./formatOutput.js";
3
3
  /** @internal */
4
4
  export declare const isTruthy: <T>(x: "" | 0 | T | null | undefined) => x is T;
5
5
  /** @internal */
@@ -1,5 +1,5 @@
1
1
  import { FieldVerification, type NId, type POVerification, type ProfileObject, type RealVer, type Schema } from "@raytio/types";
2
- import { type EnvConfig, type ResolvedVerificationProvider } from "../api";
2
+ import { type EnvConfig, type ResolvedVerificationProvider } from "../api/index.js";
3
3
  export type FlatPO = {
4
4
  $verification_details: ResolvedVerificationProvider | undefined;
5
5
  $shouldBeVerifiedFields: string[] | undefined;
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { calcSafeHarbourScore, findSchemaLabel, getPOVerification, } from "@raytio/core";
11
11
  import { omit } from "ramda";
12
12
  import { FieldVerification, } from "@raytio/types";
13
- import { $$ } from "../locales";
14
- import { resolveVerificationDetails, } from "../api";
15
- import { FIELDS_TO_REMOVE, PO_VER_TEXT_MAP, SCHEMA } from "../constants";
16
- import { maybeGetLookupValue } from "./lookup";
17
- import { assertSafeProperty } from "./types";
13
+ import { $$ } from "../locales/index.js";
14
+ import { resolveVerificationDetails, } from "../api/index.js";
15
+ import { FIELDS_TO_REMOVE, PO_VER_TEXT_MAP, SCHEMA } from "../constants.js";
16
+ import { maybeGetLookupValue } from "./lookup.js";
17
+ import { assertSafeProperty } from "./types.js";
18
18
  const byPriority = (schema) => ([a], [b]) => {
19
19
  var _a, _b, _c, _d, _e, _f;
20
20
  assertSafeProperty(a);
@@ -1,6 +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";
1
+ export * from "./formatOutput.js";
2
+ export * from "./json2csv.js";
3
+ export * from "./setupMaxcryptor.js";
4
+ export * from "./splitPOAndVers.js";
5
+ export * from "./file.js";
6
+ export * from "./types.js";
@@ -1,6 +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";
1
+ export * from "./formatOutput.js";
2
+ export * from "./json2csv.js";
3
+ export * from "./setupMaxcryptor.js";
4
+ export * from "./splitPOAndVers.js";
5
+ export * from "./file.js";
6
+ export * from "./types.js";
@@ -7,12 +7,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { getLookupOption } from "../api/getLookupOption";
10
+ import { getLookupOption } from "../api/getLookupOption.js";
11
11
  export const maybeGetLookupValue = (schema, k, value, apiToken) => __awaiter(void 0, void 0, void 0, function* () {
12
12
  var _a, _b, _c;
13
13
  const lookupUrl = (_b = (_a = schema.properties) === null || _a === void 0 ? void 0 : _a[k]) === null || _b === void 0 ? void 0 : _b.lookup;
14
14
  if (!lookupUrl)
15
15
  return undefined;
16
- const lookup = yield getLookupOption(apiToken, lookupUrl);
16
+ // Replace environment variables in the lookup URL
17
+ const regex = /{([^}]+)}/g;
18
+ const matches = lookupUrl.match(regex);
19
+ const replaced = matches === null || matches === void 0 ? void 0 : matches.map((match) => {
20
+ var _a;
21
+ const toReplace = match.replace("{", "").replace("}", "");
22
+ return (_a = process.env[toReplace]) !== null && _a !== void 0 ? _a : "";
23
+ });
24
+ const resolvedLookupUrl = matches
25
+ ? matches
26
+ .reduce((url, match, i) => { var _a; return url.replace(match, (_a = replaced === null || replaced === void 0 ? void 0 : replaced[i]) !== null && _a !== void 0 ? _a : ""); }, lookupUrl)
27
+ .replaceAll(/([^:]\/)\/+/g, "$1") // replaces doubles slashes (bar http://)
28
+ : lookupUrl;
29
+ const lookup = yield getLookupOption(apiToken, resolvedLookupUrl);
17
30
  return (_c = lookup.find((l) => l.key === value)) === null || _c === void 0 ? void 0 : _c.value;
18
31
  });
@@ -0,0 +1 @@
1
+ export declare function getDirname(): string;
@@ -0,0 +1,6 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { dirname } from "node:path";
3
+ export function getDirname() {
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ return dirname(__filename);
6
+ }
@@ -1,4 +1,4 @@
1
- import { type Maxcryptor } from "@raytio/maxcryptor";
1
+ import * as maxcryptor from "@raytio/maxcryptor";
2
2
  import type { ICognitoUserAttributeData } from "amazon-cognito-identity-js";
3
- import { type Config } from "../constants";
4
- export declare function setupMaxcryptor(CONFIG: Config, cognitoAttributes: ICognitoUserAttributeData[]): Promise<Maxcryptor>;
3
+ import { type Config } from "../constants.js";
4
+ export declare function setupMaxcryptor(CONFIG: Config, cognitoAttributes: ICognitoUserAttributeData[]): Promise<maxcryptor.Maxcryptor>;
@@ -7,9 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { encryptorFromExistingUser, } from "@raytio/maxcryptor";
10
+ import * as maxcryptor from "@raytio/maxcryptor";
11
11
  import { assocPath } from "ramda";
12
- import { ATTRIBUTE_MAP } from "../constants";
12
+ import { ATTRIBUTE_MAP } from "../constants.js";
13
+ const { encryptorFromExistingUser } = maxcryptor;
13
14
  const isMaxcryptorAttribute = (name) => name in ATTRIBUTE_MAP;
14
15
  export function setupMaxcryptor(CONFIG, cognitoAttributes) {
15
16
  return __awaiter(this, void 0, void 0, function* () {
@@ -18,7 +19,7 @@ export function setupMaxcryptor(CONFIG, cognitoAttributes) {
18
19
  return accumulator;
19
20
  return assocPath(ATTRIBUTE_MAP[Name], JSON.parse(Value), accumulator);
20
21
  }, {});
21
- const { encryptor: maxcryptor } = yield encryptorFromExistingUser(userDocument, CONFIG.RAYTIO_PASSWORD);
22
- return maxcryptor;
22
+ const { encryptor: maxcryptorEncryptor } = yield encryptorFromExistingUser(userDocument, CONFIG.RAYTIO_PASSWORD);
23
+ return maxcryptorEncryptor;
23
24
  });
24
25
  }
@@ -1,5 +1,5 @@
1
1
  import { findSchemaLabel } from "@raytio/core";
2
- import { SCHEMA } from "../constants";
2
+ import { SCHEMA } from "../constants.js";
3
3
  export const splitPOAndVers = (list) => list.reduce((accumulator, PO) => {
4
4
  const isVerification = findSchemaLabel(PO.labels) === SCHEMA.VERIFICATION;
5
5
  // move to the left or right array depending on whther +isVerification is 0 or 1
package/dist/index.d.ts CHANGED
@@ -1,7 +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";
1
+ import "./configureEnv.js";
2
+ export { fetchEnvConfig, EnvConfig } from "./api/fetchEnvConfig.js";
3
+ export { generatePDF } from "./public-methods/generatePDF.js";
4
+ export { processSubmission } from "./public-methods/processSubmission.js";
5
+ export { getAndValidateConfig } from "./public-methods/getAndValidateConfig.js";
6
+ export { saveToS3Bucket } from "./public-methods/saveToS3Bucket.js";
7
+ export { version } from "./public-methods/version.js";
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // do this first
2
- import "./configureEnv";
2
+ import "./configureEnv.js";
3
3
  /* this is what consumers of the package have access to */
4
- export { fetchEnvConfig } from "./api/fetchEnvConfig";
5
- export { generatePDF } from "./public-methods/generatePDF";
6
- export { processSubmission } from "./public-methods/processSubmission";
7
- export { getAndValidateConfig } from "./public-methods/getAndValidateConfig";
8
- export { saveToS3Bucket } from "./public-methods/saveToS3Bucket";
9
- export { version } from "./public-methods/version";
4
+ export { fetchEnvConfig } from "./api/fetchEnvConfig.js";
5
+ export { generatePDF } from "./public-methods/generatePDF.js";
6
+ export { processSubmission } from "./public-methods/processSubmission.js";
7
+ export { getAndValidateConfig } from "./public-methods/getAndValidateConfig.js";
8
+ export { saveToS3Bucket } from "./public-methods/saveToS3Bucket.js";
9
+ export { version } from "./public-methods/version.js";
@@ -1,6 +1,6 @@
1
1
  import JsxPdf from "jsx-pdf";
2
2
  import { FieldVerification } from "@raytio/types";
3
- import { loadAsset } from "../helpers/general";
3
+ import { loadAsset } from "../helpers/general.js";
4
4
  export const FieldVerificationBadge = ({ status, width, }) => {
5
5
  if (status === FieldVerification.VerifiedFalse) {
6
6
  return (JsxPdf.createElement("svg", { content: loadAsset("verified_false_small.svg"), width: width }));
@@ -1,4 +1,4 @@
1
- import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
1
+ import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission.js";
2
2
  export declare const Images: ({ nIds, files, }: {
3
3
  nIds: string[];
4
4
  files: ProcessSubmissionOutput["files"];
@@ -1,6 +1,6 @@
1
1
  import JsxPdf from "jsx-pdf";
2
- import { $$ } from "../../locales";
3
- import { assertSafeProperty } from "../../helpers";
2
+ import { $$ } from "../../locales/index.js";
3
+ import { assertSafeProperty } from "../../helpers/index.js";
4
4
  export const Images = ({ nIds, files, }) => {
5
5
  return (JsxPdf.createElement(JsxPdf.Fragment, null, nIds.map((nId) => {
6
6
  var _a;
@@ -1,5 +1,5 @@
1
- import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
2
- import type { PdfConfig } from "../types";
1
+ import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission.js";
2
+ import type { PdfConfig } from "../types.js";
3
3
  export declare const InnerTableRows: ({ key, value, imageFieldNames, config, files, color, }: {
4
4
  key: string;
5
5
  value: any;
@@ -1,9 +1,9 @@
1
1
  import JsxPdf from "jsx-pdf";
2
2
  import { uniq } from "ramda";
3
- import { assertSafeProperty } from "../../helpers";
4
- import { IS_ARRAY_OF_OBJECTS, IS_IMAGE, transform } from "../helpers/transform";
5
- import { Images } from "./Images";
6
- import { ValidationDisplay } from "./ValidationDisplay";
3
+ import { assertSafeProperty } from "../../helpers/index.js";
4
+ import { IS_ARRAY_OF_OBJECTS, IS_IMAGE, transform, } from "../helpers/transform.js";
5
+ import { Images } from "./Images.js";
6
+ import { ValidationDisplay } from "./ValidationDisplay.js";
7
7
  export const InnerTableRows = ({ key, value, imageFieldNames, config, files, color, }) => {
8
8
  if (typeof value === "object" &&
9
9
  value &&
@@ -1,5 +1,5 @@
1
1
  import { POVerification } from "@raytio/types";
2
- import type { FlatPO } from "../../helpers";
2
+ import type { FlatPO } from "../../helpers/index.js";
3
3
  export declare const FILE_MAP: Record<POVerification, string>;
4
4
  export declare const POVerificationBadge: ({ width, POs, }: {
5
5
  width: number;
@@ -1,8 +1,8 @@
1
1
  import { POVerification } from "@raytio/types";
2
2
  import JsxPdf from "jsx-pdf";
3
- import { $$ } from "../../locales";
4
- import { loadAsset } from "../helpers/general";
5
- import { PO_VER_TEXT_MAP } from "../../constants";
3
+ import { $$ } from "../../locales/index.js";
4
+ import { loadAsset } from "../helpers/general.js";
5
+ import { PO_VER_TEXT_MAP } from "../../constants.js";
6
6
  export const FILE_MAP = {
7
7
  [POVerification.FullyVerified]: "verified_user_big",
8
8
  [POVerification.PartiallyVerified]: "verified_partial_big",
@@ -1,7 +1,7 @@
1
1
  import type { AId } from "@raytio/types";
2
- import type { PdfConfig } from "../types";
3
- import type { EnvConfig } from "../../api";
4
- import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
2
+ import type { PdfConfig } from "../types.js";
3
+ import type { EnvConfig } from "../../api/index.js";
4
+ import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission.js";
5
5
  export declare const Report: ({ data, files, config, aId, clientUrl, envConfig, }: {
6
6
  data: ProcessSubmissionOutput["json"];
7
7
  files: ProcessSubmissionOutput["files"];
@@ -1,18 +1,18 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import JsxPdf from "jsx-pdf";
3
3
  import { isScoreResultValid } from "@raytio/core";
4
- import { $$ } from "../../locales";
5
- import { classes } from "../style";
6
- import { asset } from "../helpers/general";
7
- import { NULL_I_ID, SUBMISSION_DATA } from "../constants";
8
- import { transform } from "../helpers/transform";
9
- import { SCHEMA } from "../../constants";
10
- import { version } from "../../public-methods/version";
11
- import { VerifyBox } from "./VerifyBox";
12
- import { Table } from "./Table";
13
- import { TableTitle } from "./TableTitle";
14
- import { Subheader } from "./Subheader";
15
- import { POVerificationBadge } from "./POVerificationBadge";
4
+ import { $$ } from "../../locales/index.js";
5
+ import { classes } from "../style.js";
6
+ import { asset } from "../helpers/general.js";
7
+ import { NULL_I_ID, SUBMISSION_DATA } from "../constants.js";
8
+ import { transform } from "../helpers/transform.js";
9
+ import { SCHEMA } from "../../constants.js";
10
+ import { version } from "../../public-methods/version.js";
11
+ import { VerifyBox } from "./VerifyBox.js";
12
+ import { Table } from "./Table.js";
13
+ import { TableTitle } from "./TableTitle.js";
14
+ import { Subheader } from "./Subheader.js";
15
+ import { POVerificationBadge } from "./POVerificationBadge.js";
16
16
  export const Report = ({ data, files, config, aId, clientUrl, envConfig, }) => {
17
17
  // The PDF is read only; there's no reason why anyone would ever need to unlock it.
18
18
  const randomToken = randomBytes(32).toString("base64");
@@ -1,7 +1,7 @@
1
1
  import { FieldVerification } from "@raytio/types";
2
2
  import JsxPdf from "jsx-pdf";
3
- import { $$ } from "../../locales";
4
- import { FieldVerificationBadge } from "./FieldVerificationBadge";
3
+ import { $$ } from "../../locales/index.js";
4
+ import { FieldVerificationBadge } from "./FieldVerificationBadge.js";
5
5
  export const Subheader = () => {
6
6
  return (JsxPdf.createElement(JsxPdf.Fragment, null,
7
7
  JsxPdf.createElement("text", { bold: true, style: "marginBottom" }, "Key:"),
@@ -1,6 +1,6 @@
1
- import type { PdfConfig } from "../types";
2
- import { type FlatPO } from "../../helpers";
3
- import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission";
1
+ import type { PdfConfig } from "../types.js";
2
+ import { type FlatPO } from "../../helpers/index.js";
3
+ import type { ProcessSubmissionOutput } from "../../public-methods/processSubmission.js";
4
4
  export declare const Table: ({ POs, files, config, }: {
5
5
  POs: FlatPO[];
6
6
  files: ProcessSubmissionOutput["files"];
@@ -1,9 +1,9 @@
1
1
  import JsxPdf from "jsx-pdf";
2
- import { verifyColour } from "../helpers/general";
3
- import { assertSafeProperty, isFieldValueFile, isPOFile, } from "../../helpers";
4
- import { FieldVerificationBadge } from "./FieldVerificationBadge";
5
- import { Images } from "./Images";
6
- import { InnerTableRows } from "./InnerTableRows";
2
+ import { verifyColour } from "../helpers/general.js";
3
+ import { assertSafeProperty, isFieldValueFile, isPOFile, } from "../../helpers/index.js";
4
+ import { FieldVerificationBadge } from "./FieldVerificationBadge.js";
5
+ import { Images } from "./Images.js";
6
+ import { InnerTableRows } from "./InnerTableRows.js";
7
7
  export const Table = ({ POs, files, config, }) => {
8
8
  /** every fieldName in these profile object */
9
9
  const fieldNames = [
@@ -1,4 +1,4 @@
1
- import { type FlatPO } from "../../helpers";
1
+ import { type FlatPO } from "../../helpers/index.js";
2
2
  export declare const TableTitle: ({ POs }: {
3
3
  POs: FlatPO[];
4
4
  }) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import JsxPdf from "jsx-pdf";
2
- import { isPOFile } from "../../helpers";
2
+ import { isPOFile } from "../../helpers/index.js";
3
3
  export const TableTitle = ({ POs }) => {
4
4
  var _a;
5
5
  const schemaTitle = POs[0].$schemaTitle;
@@ -1,7 +1,7 @@
1
1
  import JsxPdf from "jsx-pdf";
2
- import { $$ } from "../../locales";
3
- import { assertSafeProperty } from "../../helpers";
4
- import { pieChart } from "./pieChart";
2
+ import { $$ } from "../../locales/index.js";
3
+ import { assertSafeProperty } from "../../helpers/index.js";
4
+ import { pieChart } from "./pieChart.js";
5
5
  const SEVERITY_COLOURS = {
6
6
  low: "#2e8bc0",
7
7
  medium: "#ff9800",
@@ -1,6 +1,6 @@
1
1
  import JsxPdf from "jsx-pdf";
2
- import { $$ } from "../../locales";
3
- import { NULL_I_ID } from "../constants";
2
+ import { $$ } from "../../locales/index.js";
3
+ import { NULL_I_ID } from "../constants.js";
4
4
  export const VerifyBox = ({ aId, iId, clientUrl }) => {
5
5
  if (iId === NULL_I_ID)
6
6
  return null;
@@ -1,4 +1,4 @@
1
- import { $$ } from "../locales";
1
+ import { $$ } from "../locales/index.js";
2
2
  export const NULL_I_ID = "00000000-0000-0000-0000-000000000000";
3
3
  export const SUBMISSION_DATA = {
4
4
  confirmation_code: $$("constants.confirmation_code"),
@@ -1,11 +1,12 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { FieldVerification, POVerification } from "@raytio/types";
4
+ import { getDirname } from "../../helpers/pathUtils.js";
4
5
  export const asset = (name) => {
5
6
  if (/[^.A-Z_a-z-]/.test(name) || name.includes("..")) {
6
7
  throw new Error("Invalid asset name");
7
8
  }
8
- return join(__dirname, "../../../assets/", name);
9
+ return join(getDirname(), "./../../assets/", name);
9
10
  };
10
11
  export const loadAsset = (name) => readFileSync(asset(name), { encoding: "utf8" });
11
12
  export const verifyColour = (x) => {
@@ -1,6 +1,6 @@
1
1
  import { repairDate } from "@raytio/core";
2
- import { $$ } from "../../locales";
3
- import { formatDate } from "./general";
2
+ import { $$ } from "../../locales/index.js";
3
+ import { formatDate } from "./general.js";
4
4
  export const IS_IMAGE = Symbol.for("image");
5
5
  export const IS_ARRAY_OF_OBJECTS = Symbol.for("ArrayOfObjects");
6
6
  export function transform(key, value, pdfConfig, imageFieldNames) {
package/dist/pdf/style.js CHANGED
@@ -1,4 +1,4 @@
1
- import { asset } from "./helpers/general";
1
+ import { asset } from "./helpers/general.js";
2
2
  export const classes = {
3
3
  header: {
4
4
  fontSize: 18,
@@ -1,4 +1,4 @@
1
1
  import type { TDocumentDefinitions } from "pdfmake/interfaces";
2
- import type { ProcessSubmissionOutput } from "./processSubmission";
2
+ import type { ProcessSubmissionOutput } from "./processSubmission.js";
3
3
  export declare function generatePdfJson(data: ProcessSubmissionOutput, DATE_FORMAT: string, TIMEZONE: string): TDocumentDefinitions;
4
4
  export declare const generatePDF: () => (data: ProcessSubmissionOutput) => Promise<ProcessSubmissionOutput>;
@@ -11,9 +11,10 @@ import { promises as fs } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import PdfPrinter from "pdfmake";
13
13
  import JsxPdf from "jsx-pdf";
14
- import { isValidLocale } from "../locales";
15
- import { Report } from "../pdf/components/Report";
16
- import { fonts } from "../pdf/style";
14
+ import { isValidLocale } from "../locales/index.js";
15
+ import { Report } from "../pdf/components/Report.js";
16
+ import { fonts } from "../pdf/style.js";
17
+ import { getDirname } from "../helpers/pathUtils.js";
17
18
  export function generatePdfJson(data, DATE_FORMAT, TIMEZONE) {
18
19
  return JsxPdf.renderPdf(JsxPdf.createElement(Report, { data: data.json, files: data.files, aId: data.a_id, clientUrl: data.client_url, envConfig: data.envConfig, config: { DATE_FORMAT, TIMEZONE } }));
19
20
  }
@@ -25,7 +26,7 @@ export const generatePDF = () =>
25
26
  if (data.envConfig.logo_url) {
26
27
  // there is a white labelling URL, so fetch it and write it to disk, overriding the default logo
27
28
  const arrayBuf = yield fetch(data.envConfig.logo_url).then((r) => r.arrayBuffer());
28
- yield fs.writeFile(join(__dirname, "../../assets/custom-logo.png"), Buffer.from(arrayBuf));
29
+ yield fs.writeFile(join(getDirname(), "../../assets/custom-logo.png"), Buffer.from(arrayBuf));
29
30
  }
30
31
  if (customLang) {
31
32
  if (isValidLocale(customLang)) {
@@ -1,4 +1,4 @@
1
- import { type Config } from "../constants";
1
+ import { type Config } from "../constants.js";
2
2
  /**
3
3
  * This helper is designed for environments where the configuration
4
4
  * options are in the environment variables, such as AWS lambda.
@@ -1,4 +1,4 @@
1
- import { ENV_VARIABLES } from "../constants";
1
+ import { ENV_VARIABLES } from "../constants.js";
2
2
  /**
3
3
  * This helper is designed for environments where the configuration
4
4
  * options are in the environment variables, such as AWS lambda.
@@ -1,8 +1,8 @@
1
1
  import type { AId, IId, Instance, RealVer } from "@raytio/types";
2
- import { type Config, type InstanceDataToPassOn } from "../constants";
3
- import { type FlatPO } from "../helpers";
4
- import { type EnvConfig } from "../api";
5
- import type { ApplicationEncryptorLike } from "../types";
2
+ import { type Config, type InstanceDataToPassOn } from "../constants.js";
3
+ import { type FlatPO } from "../helpers/index.js";
4
+ import { type EnvConfig } from "../api/index.js";
5
+ import type { ApplicationEncryptorLike } from "../types.js";
6
6
  type DecryptData = {
7
7
  apiToken: string;
8
8
  instance: Instance;
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { equals, mapObjIndexed, omit } from "ramda";
11
11
  import { calculateScore, convertInstanceToRuleInput, decryptSharedData, getMissingDataForInstance, getSomeoneElsesRealVerifications, isScoreConfigValid, } from "@raytio/core";
12
- import { FIELD_VER_TEXT_MAP, INSTANCE_FIELDS_TO_REMOVE, } from "../constants";
13
- import { deepJsonToCsv, formatOutput, setupMaxcryptor, splitPOAndVers, } from "../helpers";
14
- import { fetchAA, fetchEnvConfig, fetchInstanceData, getAllSchema, getFiles, signIn, updateInstanceData, } from "../api";
15
- import { NULL_I_ID } from "../pdf/constants";
12
+ import { FIELD_VER_TEXT_MAP, INSTANCE_FIELDS_TO_REMOVE, } from "../constants.js";
13
+ import { deepJsonToCsv, formatOutput, setupMaxcryptor, splitPOAndVers, } from "../helpers/index.js";
14
+ import { fetchAA, fetchEnvConfig, fetchInstanceData, getAllSchema, getFiles, signIn, updateInstanceData, } from "../api/index.js";
15
+ import { NULL_I_ID } from "../pdf/constants.js";
16
16
  function decryptStage(log, config, envConfig, instanceId) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  log("Authenticating...");
@@ -1,2 +1,2 @@
1
- import type { ProcessSubmissionOutput } from "./processSubmission";
1
+ import type { ProcessSubmissionOutput } from "./processSubmission.js";
2
2
  export declare const saveToS3Bucket: () => (input: ProcessSubmissionOutput) => Promise<void>;
@@ -1,6 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- export const packageDotJson = JSON.parse(readFileSync(join(__dirname, "../../package.json"), "utf8"));
3
+ import { getDirname } from "../helpers/pathUtils.js";
4
+ export const packageDotJson = JSON.parse(readFileSync(join(getDirname(), "../../package.json"), "utf8"));
4
5
  export const version = Object.entries({
5
6
  LANG: process.env.PDF_LANGUAGE || "default",
6
7
  N: process.version.slice(1),
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@raytio/decrypt-helper",
3
- "version": "6.3.0",
3
+ "version": "6.3.1",
4
4
  "author": "Raytio",
5
5
  "type": "module",
6
6
  "description": "A helper to decrypt data shared by Raytio users",
7
- "main": "dist",
7
+ "main": "dist/index.js",
8
8
  "files": [
9
9
  "assets",
10
10
  "dist"
@@ -30,8 +30,8 @@
30
30
  "jsx-pdf": "^2.3.0",
31
31
  "localstorage-polyfill": "^1.0.1",
32
32
  "mime-types": "^2.1.35",
33
- "pdfmake": "^0.2.9",
34
- "ramda": "^0.29.1"
33
+ "pdfmake": "^0.2.10",
34
+ "ramda": "^0.30.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@raytio/react-intl-manager": "^6.4.0",
@@ -46,6 +46,7 @@
46
46
  "dotenv": "^16.3.1",
47
47
  "eslint": "^8.55.0",
48
48
  "eslint-config-kyle": "^18.0.1",
49
+ "eslint-plugin-jsx-a11y": "^6.8.0",
49
50
  "jest-image-snapshot": "^6.3.0",
50
51
  "pdf-to-img": "^2.1.2",
51
52
  "ts-node": "^10.9.1",
@@ -101,4 +102,4 @@
101
102
  "codeQualityReport": "tmp/codequality.json",
102
103
  "moduleSourceName": false
103
104
  }
104
- }
105
+ }