@raytio/decrypt-helper 2.2.0 → 2.2.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.
- package/CHANGELOG.md +4 -0
- package/dist/api/fetchAA.d.ts +3 -0
- package/dist/api/fetchAA.js +19 -0
- package/dist/api/getSchema.d.ts +1 -1
- package/dist/api/getSchema.js +4 -4
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/constants.d.ts +4 -1
- package/dist/helpers/formatOutput.js +1 -1
- package/dist/pdf/components/Report.js +7 -3
- package/dist/public-methods/processSubmission.js +20 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## 2.2.1 (2022-02-09)
|
|
11
|
+
|
|
12
|
+
- !158 include the submission score in the json and pdf
|
|
13
|
+
|
|
10
14
|
## 2.2.0 (2022-02-04)
|
|
11
15
|
|
|
12
16
|
- !153 fix rendering of arrays of primitive values
|
|
@@ -0,0 +1,19 @@
|
|
|
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.fetchAA = void 0;
|
|
13
|
+
const authedFetch_1 = require("./authedFetch");
|
|
14
|
+
function fetchAA(apiToken, envConfig, aId) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
return (0, authedFetch_1.authedFetch)(apiToken, `${envConfig.api_url}/share/v2/access_application/${aId}`);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.fetchAA = fetchAA;
|
package/dist/api/getSchema.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Schema } from "@raytio/types";
|
|
2
2
|
import { EnvConfig } from "./fetchEnvConfig";
|
|
3
|
-
export declare function getSchema(envConfig: EnvConfig,
|
|
3
|
+
export declare function getSchema(envConfig: EnvConfig, name: string): Promise<Schema>;
|
package/dist/api/getSchema.js
CHANGED
|
@@ -12,18 +12,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getSchema = void 0;
|
|
13
13
|
const authedFetch_1 = require("./authedFetch");
|
|
14
14
|
const cache = new Map();
|
|
15
|
-
function $getSchema(envConfig,
|
|
15
|
+
function $getSchema(envConfig, name) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const [schemaHead, ...schemaTail] = name.split("_");
|
|
18
|
-
const schema = yield (0, authedFetch_1.authedFetch)(
|
|
18
|
+
const schema = yield (0, authedFetch_1.authedFetch)("", `${envConfig.api_url}/graph/v2/schema_public/${schemaHead}/${schemaTail.join("_")}?expand=true`);
|
|
19
19
|
return Object.assign(Object.assign({}, schema), { name });
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
function getSchema(envConfig,
|
|
22
|
+
function getSchema(envConfig, name) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
if (cache.has(name))
|
|
25
25
|
return cache.get(name);
|
|
26
|
-
const promise = $getSchema(envConfig,
|
|
26
|
+
const promise = $getSchema(envConfig, name);
|
|
27
27
|
cache.set(name, promise);
|
|
28
28
|
return promise;
|
|
29
29
|
});
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./authedFetch"), exports);
|
|
14
|
+
__exportStar(require("./fetchAA"), exports);
|
|
14
15
|
__exportStar(require("./fetchEnvConfig"), exports);
|
|
15
16
|
__exportStar(require("./fetchInstanceData"), exports);
|
|
16
17
|
__exportStar(require("./getFiles"), exports);
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ScoreResult } from "@raytio/core";
|
|
1
2
|
import { FieldVerification, Instance, POVerification } from "@raytio/types";
|
|
2
3
|
export declare const ATTRIBUTE_MAP: {
|
|
3
4
|
"custom:kek_derivation": string[];
|
|
@@ -12,6 +13,8 @@ export declare const INSTANCE_FIELDS_TO_REMOVE: readonly ["profile_objects", "re
|
|
|
12
13
|
export declare const FIELDS_TO_REMOVE: readonly ["n_id", "document"];
|
|
13
14
|
export declare const ENV_VARIABLES: readonly ["CLIENT_URL", "READABLE_FIELD_NAMES", "USERNAME", "PASSWORD"];
|
|
14
15
|
export declare type Config = Record<typeof ENV_VARIABLES[number], string>;
|
|
15
|
-
export declare type InstanceDataToPassOn = Omit<Instance, typeof INSTANCE_FIELDS_TO_REMOVE[number]
|
|
16
|
+
export declare type InstanceDataToPassOn = Omit<Instance, typeof INSTANCE_FIELDS_TO_REMOVE[number]> & {
|
|
17
|
+
score?: ScoreResult;
|
|
18
|
+
};
|
|
16
19
|
export declare const PO_VER_TEXT_MAP: Record<POVerification, string>;
|
|
17
20
|
export declare const FIELD_VER_TEXT_MAP: Record<FieldVerification, string>;
|
|
@@ -61,7 +61,7 @@ function formatOutput(profileObjects, allSchemas, realVers, apiToken, CONFIG, en
|
|
|
61
61
|
$nId: PO.n_id, $schemaName: schemaName, $properties: reducedProperties, $safeHarbour: schemaName === "ss_Person_Name"
|
|
62
62
|
? (yield (0, core_1.calcSafeHarbourScore)({
|
|
63
63
|
person: PO,
|
|
64
|
-
getSchema: (name) => (0, api_1.getSchema)(envConfig,
|
|
64
|
+
getSchema: (name) => (0, api_1.getSchema)(envConfig, name),
|
|
65
65
|
profileObjects,
|
|
66
66
|
realVers,
|
|
67
67
|
})).isSafe
|
|
@@ -39,9 +39,13 @@ const Report = ({ data, files, config, aId, clientUrl, version, }) => {
|
|
|
39
39
|
jsx_pdf_1.default.createElement("text", { style: ["header", "marginBottom"], alignment: "center" }, "Raytio Verification Report"),
|
|
40
40
|
jsx_pdf_1.default.createElement("columns", { columnGap: 10 },
|
|
41
41
|
jsx_pdf_1.default.createElement("column", { width: "auto" },
|
|
42
|
-
jsx_pdf_1.default.createElement("text", { style: ["subheader", "marginBottom"] },
|
|
43
|
-
.
|
|
44
|
-
|
|
42
|
+
jsx_pdf_1.default.createElement("text", { style: ["subheader", "marginBottom"] },
|
|
43
|
+
Object.entries(constants_1.SUBMISSION_DATA)
|
|
44
|
+
.map(([id, label]) => `${label}: ${(0, transform_1.transform)(id, data[id], config)}`)
|
|
45
|
+
.join("\n"),
|
|
46
|
+
data.score
|
|
47
|
+
? `\nScore: ${data.score.score}\nScore Category: ${data.score.category}`
|
|
48
|
+
: ""),
|
|
45
49
|
jsx_pdf_1.default.createElement(Subheader_1.Subheader, { data: data, config: config })),
|
|
46
50
|
jsx_pdf_1.default.createElement("column", { width: "*" },
|
|
47
51
|
jsx_pdf_1.default.createElement("text", null, " ")),
|
|
@@ -57,7 +57,25 @@ function processSubmission({ applicationId, instanceId, verbose, config, _suplie
|
|
|
57
57
|
throw new Error("Submission contains invalid objects");
|
|
58
58
|
return schemaName;
|
|
59
59
|
});
|
|
60
|
-
const allSchemas = yield Promise.all((0, ramda_1.uniq)(schemaNames).map((name) => (0, api_1.getSchema)(envConfig,
|
|
60
|
+
const allSchemas = yield Promise.all((0, ramda_1.uniq)(schemaNames).map((name) => (0, api_1.getSchema)(envConfig, name)));
|
|
61
|
+
log("Fetching access application...");
|
|
62
|
+
const AA = yield (0, api_1.fetchAA)(apiToken, envConfig, instance.a_id);
|
|
63
|
+
let score;
|
|
64
|
+
if (AA.ruleset &&
|
|
65
|
+
typeof AA.ruleset === "object" &&
|
|
66
|
+
Object.keys(AA.ruleset).length) {
|
|
67
|
+
const ruleInputData = yield (0, core_1.convertInstanceToRuleInput)(instance, realVers, (schemaName) => (0, api_1.getSchema)(envConfig, schemaName));
|
|
68
|
+
try {
|
|
69
|
+
log("Calculating score...");
|
|
70
|
+
score = (0, core_1.calculateScore)(AA.ruleset, ruleInputData);
|
|
71
|
+
}
|
|
72
|
+
catch (ex) {
|
|
73
|
+
log(`Score calculation failed (${ex})`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
log("No score rules configured on the AA.");
|
|
78
|
+
}
|
|
61
79
|
// TODO: resolve URNs if any fields are URNs
|
|
62
80
|
log("Fetching verification providers...");
|
|
63
81
|
const PODetails = yield (0, helpers_1.formatOutput)(profileObjects, allSchemas, realVers, apiToken, config, envConfig);
|
|
@@ -85,7 +103,7 @@ function processSubmission({ applicationId, instanceId, verbose, config, _suplie
|
|
|
85
103
|
}), PODetails)));
|
|
86
104
|
log("Success!");
|
|
87
105
|
return {
|
|
88
|
-
json: Object.assign(Object.assign({}, instanceDataToPassOn), PODetails),
|
|
106
|
+
json: Object.assign(Object.assign(Object.assign({}, instanceDataToPassOn), { score }), PODetails),
|
|
89
107
|
csv,
|
|
90
108
|
files,
|
|
91
109
|
a_id: applicationId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytio/decrypt-helper",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"author": "Raytio",
|
|
5
5
|
"description": "A helper to decrypt data shared by Raytio users",
|
|
6
6
|
"main": "dist",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@aws-amplify/auth": "3.4.25",
|
|
24
24
|
"@peculiar/webcrypto": "^1.2.3",
|
|
25
|
-
"@raytio/core": "^9.0.
|
|
25
|
+
"@raytio/core": "^9.0.1",
|
|
26
26
|
"@raytio/maxcryptor": "^3.1.0",
|
|
27
|
-
"@raytio/types": "^
|
|
27
|
+
"@raytio/types": "^6.0.0",
|
|
28
28
|
"aws-sdk": "^2.754.0",
|
|
29
29
|
"jsx-pdf": "^2.3.0",
|
|
30
30
|
"localstorage-polyfill": "^1.0.1",
|