@raytio/decrypt-helper 3.0.1 → 3.0.2

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 CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## 3.0.2 (2022-02-16)
11
+
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`
15
+ - 💥 BREAKING CHANGE: we no longer use `schema_group` to group schema in the json, csv, and pdf
16
+
10
17
  ## 3.0.1 (2022-02-15)
11
18
 
12
19
  - fix bug with PDF generation
@@ -52,12 +52,12 @@ describe("formatOutput", () => {
52
52
  beforeEach(() => {
53
53
  m(api_1.resolveVerificationDetails).mockResolvedValue(Symbol.for("VerificationDetails"));
54
54
  });
55
- it("uses schema_group to group schema", () => __awaiter(void 0, void 0, void 0, function* () {
55
+ it("does not use schema_group to group schema", () => __awaiter(void 0, void 0, void 0, function* () {
56
56
  const output = yield (0, formatOutput_1.formatOutput)(profileObjects, allSchemas, realVers, "[apiToken]",
57
57
  // @ts-expect-error testing if it works with booleans not stringied bools
58
58
  Symbol.for("envConfig"));
59
59
  expect(output).toStrictEqual({
60
- DL: [
60
+ ss_nz_drivers_license: [
61
61
  {
62
62
  $verification_details: Symbol.for("VerificationDetails"),
63
63
  $verified: types_1.POVerification.NotVerified,
@@ -67,18 +67,20 @@ describe("formatOutput", () => {
67
67
  issuer: {
68
68
  title: "issuer",
69
69
  value: "NZTA",
70
- verification: undefined,
70
+ verification: types_1.FieldVerification.NotVerified,
71
71
  },
72
72
  license_number: {
73
73
  title: "license_number",
74
74
  value: "DW012345",
75
- verification: undefined,
75
+ verification: types_1.FieldVerification.NotVerified,
76
76
  },
77
77
  },
78
78
  $safeHarbour: "NOT_APPLICABLE",
79
79
  $schemaName: "ss_nz_drivers_license",
80
80
  $schemaTitle: "NZ Drivers License",
81
81
  },
82
+ ],
83
+ ss_nsw_drivers_license: [
82
84
  {
83
85
  $verification_details: Symbol.for("VerificationDetails"),
84
86
  $verified: types_1.POVerification.NotVerified,
@@ -88,12 +90,12 @@ describe("formatOutput", () => {
88
90
  city: {
89
91
  title: "city",
90
92
  value: "Sydney",
91
- verification: undefined,
93
+ verification: types_1.FieldVerification.NotVerified,
92
94
  },
93
95
  license_number: {
94
96
  title: "license_number",
95
97
  value: "ABC123",
96
- verification: undefined,
98
+ verification: types_1.FieldVerification.NotVerified,
97
99
  },
98
100
  },
99
101
  $safeHarbour: "NOT_APPLICABLE",
@@ -111,12 +113,12 @@ describe("formatOutput", () => {
111
113
  fName: {
112
114
  title: "fName",
113
115
  value: "john",
114
- verification: undefined,
116
+ verification: types_1.FieldVerification.NotVerified,
115
117
  },
116
118
  lName: {
117
119
  title: "lName",
118
120
  value: "doe",
119
- verification: undefined,
121
+ verification: types_1.FieldVerification.NotVerified,
120
122
  },
121
123
  },
122
124
  $safeHarbour: "NOT_APPLICABLE",
@@ -1,4 +1,4 @@
1
- import type { FieldVerification, NId, POVerification, ProfileObject, RealVer, Schema } from "@raytio/types";
1
+ import { FieldVerification, NId, POVerification, ProfileObject, RealVer, Schema } from "@raytio/types";
2
2
  import { ResolvedVerificationProvider, EnvConfig } from "../api";
3
3
  export declare type FlatPO = {
4
4
  $verified: POVerification;
@@ -12,14 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.formatOutput = void 0;
13
13
  const core_1 = require("@raytio/core");
14
14
  const ramda_1 = require("ramda");
15
+ const types_1 = require("@raytio/types");
15
16
  const api_1 = require("../api");
16
17
  const constants_1 = require("../constants");
17
18
  const lookup_1 = require("./lookup");
18
- const types_1 = require("./types");
19
+ const types_2 = require("./types");
19
20
  const byPriority = (schema) => ([a], [b]) => {
20
21
  var _a, _b, _c, _d, _e, _f;
21
- (0, types_1.assertSafeProperty)(a);
22
- (0, types_1.assertSafeProperty)(b);
22
+ (0, types_2.assertSafeProperty)(a);
23
+ (0, types_2.assertSafeProperty)(b);
23
24
  // if no priority, it becomes the last
24
25
  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;
25
26
  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,7 +29,7 @@ const byPriority = (schema) => ([a], [b]) => {
28
29
  function formatOutput(profileObjects, allSchemas, realVers, apiToken, envConfig) {
29
30
  return __awaiter(this, void 0, void 0, function* () {
30
31
  const PODetails = profileObjects.reduce((acPromise, PO) => __awaiter(this, void 0, void 0, function* () {
31
- var _a, _b;
32
+ var _a;
32
33
  const ac = yield acPromise;
33
34
  const schemaName = (0, core_1.findSchemaLabel)(PO.labels);
34
35
  const schema = allSchemas.find((x) => x.name === schemaName);
@@ -36,26 +37,26 @@ function formatOutput(profileObjects, allSchemas, realVers, apiToken, envConfig)
36
37
  throw new Error(`${schema} is missing!`);
37
38
  const verDetails = (0, core_1.getPOVerification)({ PO, schema, realVers });
38
39
  const realProps = (0, ramda_1.omit)(constants_1.FIELDS_TO_REMOVE, PO.properties);
39
- const schemaNameOrGroup = (_a = schema.schema_group) !== null && _a !== void 0 ? _a : schema.name;
40
- (0, types_1.assertSafeProperty)(schemaNameOrGroup);
41
- const existing = ac[schemaNameOrGroup] || [];
40
+ (0, types_2.assertSafeProperty)(schemaName);
41
+ const existing = ac[schemaName] || [];
42
42
  const poProperties = Object.entries(realProps).sort(byPriority(schema));
43
43
  const reducedProperties = yield poProperties.reduce((acc, [key, value]) => __awaiter(this, void 0, void 0, function* () {
44
- var _c, _d;
44
+ var _b, _c;
45
45
  const accP = yield acc;
46
- (0, types_1.assertSafeProperty)(key);
46
+ (0, types_2.assertSafeProperty)(key);
47
47
  return Object.assign(Object.assign({}, accP), { [key]: {
48
- title: ((_d = (_c = schema.properties) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.title) || key,
48
+ title: ((_c = (_b = schema.properties) === null || _b === void 0 ? void 0 : _b[key]) === null || _c === void 0 ? void 0 : _c.title) || key,
49
49
  value: typeof value === "string"
50
50
  ? yield (0, lookup_1.maybeAddLookupValue)(schema, key, value, apiToken)
51
51
  : value,
52
- verification: verDetails.fieldVerifications[key],
52
+ verification: verDetails.fieldVerifications[key] ||
53
+ types_1.FieldVerification.NotVerified,
53
54
  } });
54
55
  }), Promise.resolve({}));
55
56
  const thisPO = {
56
57
  $verified: verDetails.status,
57
58
  $verification_details: yield (0, api_1.resolveVerificationDetails)(verDetails.details.verifiers, apiToken, envConfig),
58
- $shouldBeVerifiedFields: (_b = schema.verified_fields) === null || _b === void 0 ? void 0 : _b.map((x) => typeof x === "string" ? x : x.field),
59
+ $shouldBeVerifiedFields: (_a = schema.verified_fields) === null || _a === void 0 ? void 0 : _a.map((x) => typeof x === "string" ? x : x.field),
59
60
  $nId: PO.n_id,
60
61
  $schemaName: schemaName,
61
62
  $schemaTitle: schema.title,
@@ -69,7 +70,7 @@ function formatOutput(profileObjects, allSchemas, realVers, apiToken, envConfig)
69
70
  })).isSafe
70
71
  : "NOT_APPLICABLE",
71
72
  };
72
- return Object.assign(Object.assign({}, ac), { [schemaNameOrGroup]: [...existing, thisPO] });
73
+ return Object.assign(Object.assign({}, ac), { [schemaName]: [...existing, thisPO] });
73
74
  }), Promise.resolve({}));
74
75
  return PODetails;
75
76
  });
@@ -25,8 +25,13 @@ const Table = ({ POs, files, config, }) => {
25
25
  return (jsx_pdf_1.default.createElement("row", null,
26
26
  jsx_pdf_1.default.createElement("cell", null,
27
27
  jsx_pdf_1.default.createElement("text", { color: "#12130e" }, ((_a = POs.find((PO) => PO.$properties[fieldName])) === null || _a === void 0 ? void 0 : _a.$properties[fieldName].title) || fieldName)),
28
- POs.filter((PO) => PO.$properties[fieldName]).flatMap((PO) => {
28
+ POs.flatMap((PO) => {
29
29
  (0, helpers_1.assertSafeProperty)(fieldName);
30
+ // if we're sharing multiple POs in this schema, and this field doesn't exist on this paticular PO,
31
+ // then just render some empty cells
32
+ if (!PO.$properties[fieldName]) {
33
+ return [jsx_pdf_1.default.createElement("cell", null, " "), jsx_pdf_1.default.createElement("cell", null, " ")];
34
+ }
30
35
  const { value, verification } = PO.$properties[fieldName];
31
36
  const color = (0, general_1.verifyColour)(verification);
32
37
  // jsx-pdf currently doesn't support fragments, will make a PR at some point
@@ -1,4 +1,4 @@
1
- import type { AId, IId, Instance, ProfileObject, RealVer, Schema } from "@raytio/types";
1
+ import type { AId, IId, Instance } from "@raytio/types";
2
2
  import { Config, InstanceDataToPassOn } from "../constants";
3
3
  import { FlatPO } from "../helpers";
4
4
  import { ApplicationEncryptorLike } from "../types";
@@ -39,12 +39,6 @@ export interface ProcessSubmissionOutput {
39
39
  a_id: AId;
40
40
  /** passed down so that pdf generation has access to it */
41
41
  client_url: string;
42
- /** @deprecated the low-level data for this submission - for Raytio internal use or advanced users */
43
- $source: {
44
- profileObjects: ProfileObject[];
45
- allSchemas: Schema[];
46
- realVers: RealVer[];
47
- };
48
42
  }
49
43
  export declare function processSubmission({ applicationId, instanceId, verbose, config, _supliedConfig, }: ProcessSubmissionInput): Promise<ProcessSubmissionOutput>;
50
44
  export {};
@@ -100,11 +100,6 @@ function processSubmission({ applicationId, instanceId, verbose, config, _suplie
100
100
  files,
101
101
  a_id: applicationId,
102
102
  client_url: config.CLIENT_URL,
103
- $source: {
104
- profileObjects,
105
- allSchemas,
106
- realVers,
107
- },
108
103
  };
109
104
  }
110
105
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytio/decrypt-helper",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "author": "Raytio",
5
5
  "description": "A helper to decrypt data shared by Raytio users",
6
6
  "main": "dist",