@raytio/decrypt-helper 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/dist/api/authedFetch.d.ts +1 -1
- package/dist/api/authedFetch.js +2 -4
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/resolveVerificationDetails.d.ts +1 -1
- package/dist/api/resolveVerificationDetails.js +4 -3
- package/dist/api/updateInstanceData.d.ts +2 -0
- package/dist/api/updateInstanceData.js +19 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -0
- package/dist/helpers/formatOutput.d.ts +11 -2
- package/dist/helpers/formatOutput.js +31 -17
- package/dist/helpers/lookup.d.ts +1 -1
- package/dist/helpers/lookup.js +5 -5
- package/dist/locales/index.d.ts +1 -1
- package/dist/pdf/components/POVerificationBadge.js +6 -6
- package/dist/pdf/components/Report.js +2 -1
- package/dist/pdf/components/Table.js +2 -2
- package/dist/public-methods/processSubmission.d.ts +1 -0
- package/dist/public-methods/processSubmission.js +19 -7
- package/package.json +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -7,13 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## 4.0.0 (2022-07-08)
|
|
11
|
+
|
|
12
|
+
- 💥 BREAKING CHANGE: !170 [json] [csv] changed the format of badges, the fields `$verified` and `$safeHarbour` have been replaced with `$badges`
|
|
13
|
+
- !176 fix field values being unexpectedly transformed
|
|
14
|
+
- !179 update dependencies
|
|
15
|
+
- !182 save the calculated score to the instance
|
|
16
|
+
|
|
10
17
|
## 3.2.0 (2022-04-21)
|
|
11
18
|
|
|
12
19
|
- !177 do not use `hashPassword` when logging in, and migrate old credentials
|
|
13
20
|
|
|
14
21
|
## 3.1.1 (2022-04-02)
|
|
15
22
|
|
|
16
|
-
- !
|
|
23
|
+
- !175 Fix import issue in v3.1
|
|
17
24
|
|
|
18
25
|
## 3.1.0 (2022-03-14)
|
|
19
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function authedFetch<T>(apiToken: string, url: string): Promise<T>;
|
|
1
|
+
export declare function authedFetch<T>(apiToken: string, url: string, options?: RequestInit): Promise<T>;
|
package/dist/api/authedFetch.js
CHANGED
|
@@ -10,11 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.authedFetch = void 0;
|
|
13
|
-
function authedFetch(apiToken, url) {
|
|
13
|
+
function authedFetch(apiToken, url, options) {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const apiResp = yield fetch(url, {
|
|
16
|
-
headers: { Authorization: `Bearer ${apiToken}` },
|
|
17
|
-
}).then((r) => r.json());
|
|
15
|
+
const apiResp = yield fetch(url, Object.assign(Object.assign({}, options), { headers: { Authorization: `Bearer ${apiToken}` } })).then((r) => r.json());
|
|
18
16
|
if (apiResp.message) {
|
|
19
17
|
throw new Error(`Failed due to API Error: "${apiResp.message}"`);
|
|
20
18
|
}
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
|
@@ -23,3 +23,4 @@ __exportStar(require("./getProfileObject"), exports);
|
|
|
23
23
|
__exportStar(require("./getSchema"), exports);
|
|
24
24
|
__exportStar(require("./resolveVerificationDetails"), exports);
|
|
25
25
|
__exportStar(require("./signIn"), exports);
|
|
26
|
+
__exportStar(require("./updateInstanceData"), exports);
|
|
@@ -4,6 +4,6 @@ export declare type ResolvedVerificationProvider = {
|
|
|
4
4
|
verifier_id?: string;
|
|
5
5
|
verifier_service_id?: string;
|
|
6
6
|
verifier_source_id?: string;
|
|
7
|
-
date
|
|
7
|
+
date?: string;
|
|
8
8
|
};
|
|
9
9
|
export declare function resolveVerificationDetails([details]: VerificationProvider[], apiToken: string, envConfig: EnvConfig): Promise<ResolvedVerificationProvider | undefined>;
|
|
@@ -12,13 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.resolveVerificationDetails = void 0;
|
|
13
13
|
const getProfileObject_1 = require("./getProfileObject");
|
|
14
14
|
function resolveVerificationDetails([details], apiToken, envConfig) {
|
|
15
|
+
var _a;
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
if (!details)
|
|
17
18
|
return undefined;
|
|
18
19
|
const maybeGet = (nId) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
var
|
|
20
|
+
var _b, _c;
|
|
20
21
|
return nId
|
|
21
|
-
? (
|
|
22
|
+
? (_c = (_b = (yield (0, getProfileObject_1.getProfileObject)(envConfig, apiToken, nId))) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c.provider_name
|
|
22
23
|
: undefined;
|
|
23
24
|
});
|
|
24
25
|
const [verifier_id, verifier_service_id, verifier_source_id] = yield Promise.all([
|
|
@@ -30,7 +31,7 @@ function resolveVerificationDetails([details], apiToken, envConfig) {
|
|
|
30
31
|
verifier_id,
|
|
31
32
|
verifier_service_id,
|
|
32
33
|
verifier_source_id,
|
|
33
|
-
date: details.date.toISOString(),
|
|
34
|
+
date: (_a = details.date) === null || _a === void 0 ? void 0 : _a.toISOString(),
|
|
34
35
|
};
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -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.updateInstanceData = void 0;
|
|
13
|
+
const authedFetch_1 = require("./authedFetch");
|
|
14
|
+
function updateInstanceData(apiToken, instance) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
yield (0, authedFetch_1.authedFetch)(apiToken, `share/v2/access_application/instance/${instance.i_id}`, { method: "PUT", body: JSON.stringify(instance) });
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.updateInstanceData = updateInstanceData;
|
package/dist/constants.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const ATTRIBUTE_MAP: {
|
|
|
8
8
|
"custom:ask_public": string[];
|
|
9
9
|
"custom:ask_private": string[];
|
|
10
10
|
};
|
|
11
|
-
export declare const INSTANCE_FIELDS_TO_REMOVE: readonly ["profile_objects", "relationships", "keys"];
|
|
11
|
+
export declare const INSTANCE_FIELDS_TO_REMOVE: readonly ["profile_objects", "relationships", "keys", "score"];
|
|
12
12
|
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 declare type Config = Record<typeof ENV_VARIABLES[number], string>;
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
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
|
-
$verified: POVerification;
|
|
5
4
|
$verification_details: ResolvedVerificationProvider | undefined;
|
|
6
5
|
$shouldBeVerifiedFields: string[] | undefined;
|
|
7
6
|
$nId: NId;
|
|
@@ -11,9 +10,19 @@ export declare type FlatPO = {
|
|
|
11
10
|
[fieldName: string]: {
|
|
12
11
|
title: string;
|
|
13
12
|
value: unknown;
|
|
13
|
+
formatted_value?: string | number;
|
|
14
14
|
verification: FieldVerification;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
$
|
|
17
|
+
$badges: {
|
|
18
|
+
verified: {
|
|
19
|
+
code: POVerification;
|
|
20
|
+
statusText: string;
|
|
21
|
+
};
|
|
22
|
+
safeHarbour?: {
|
|
23
|
+
code: boolean;
|
|
24
|
+
statusText: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
18
27
|
};
|
|
19
28
|
export declare function formatOutput(profileObjects: ProfileObject[], allSchemas: Schema[], realVers: RealVer[], apiToken: string, envConfig: EnvConfig): Promise<Record<string, FlatPO[]>>;
|
|
@@ -13,6 +13,7 @@ exports.formatOutput = void 0;
|
|
|
13
13
|
const core_1 = require("@raytio/core");
|
|
14
14
|
const ramda_1 = require("ramda");
|
|
15
15
|
const types_1 = require("@raytio/types");
|
|
16
|
+
const locales_1 = require("../locales");
|
|
16
17
|
const api_1 = require("../api");
|
|
17
18
|
const constants_1 = require("../constants");
|
|
18
19
|
const lookup_1 = require("./lookup");
|
|
@@ -44,31 +45,44 @@ function formatOutput(profileObjects, allSchemas, realVers, apiToken, envConfig)
|
|
|
44
45
|
var _b, _c;
|
|
45
46
|
const accP = yield acc;
|
|
46
47
|
(0, types_2.assertSafeProperty)(key);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
const prettyValue = typeof value === "string"
|
|
49
|
+
? yield (0, lookup_1.maybeGetLookupValue)(schema, key, value, apiToken)
|
|
50
|
+
: undefined;
|
|
51
|
+
const obj = {
|
|
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: verDetails.fieldVerifications[key] || types_1.FieldVerification.NotVerified,
|
|
55
|
+
};
|
|
56
|
+
if (prettyValue)
|
|
57
|
+
obj.formatted_value = prettyValue;
|
|
58
|
+
return Object.assign(Object.assign({}, accP), { [key]: obj });
|
|
55
59
|
}), Promise.resolve({}));
|
|
56
60
|
const thisPO = {
|
|
57
|
-
$verified: verDetails.status,
|
|
58
61
|
$verification_details: yield (0, api_1.resolveVerificationDetails)(verDetails.details.verifiers, apiToken, envConfig),
|
|
59
62
|
$shouldBeVerifiedFields: (_a = schema.verified_fields) === null || _a === void 0 ? void 0 : _a.map((x) => typeof x === "string" ? x : x.field),
|
|
60
63
|
$nId: PO.n_id,
|
|
61
64
|
$schemaName: schemaName,
|
|
62
65
|
$schemaTitle: schema.title,
|
|
63
66
|
$properties: reducedProperties,
|
|
64
|
-
$
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
$badges: {
|
|
68
|
+
verified: {
|
|
69
|
+
code: verDetails.status,
|
|
70
|
+
statusText: constants_1.PO_VER_TEXT_MAP[verDetails.status],
|
|
71
|
+
},
|
|
72
|
+
safeHarbour: schemaName === constants_1.SCHEMA.PERSON
|
|
73
|
+
? (({ isSafe }) => ({
|
|
74
|
+
code: isSafe,
|
|
75
|
+
statusText: isSafe
|
|
76
|
+
? (0, locales_1.$$)("POVerificationBadge.safe-harbour-yes")
|
|
77
|
+
: (0, locales_1.$$)("POVerificationBadge.safe-harbour-no"),
|
|
78
|
+
}))(yield (0, core_1.calcSafeHarbourScore)({
|
|
79
|
+
person: PO,
|
|
80
|
+
getSchema: (name) => (0, api_1.getSchema)(envConfig, name),
|
|
81
|
+
profileObjects,
|
|
82
|
+
realVers,
|
|
83
|
+
}))
|
|
84
|
+
: undefined,
|
|
85
|
+
},
|
|
72
86
|
};
|
|
73
87
|
return Object.assign(Object.assign({}, ac), { [schemaName]: [...existing, thisPO] });
|
|
74
88
|
}), Promise.resolve({}));
|
package/dist/helpers/lookup.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Schema } from "@raytio/types";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const maybeGetLookupValue: <T>(schema: Schema, k: string, value: T, apiToken: string) => Promise<string | number | T | undefined>;
|
package/dist/helpers/lookup.js
CHANGED
|
@@ -9,14 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.maybeGetLookupValue = void 0;
|
|
13
13
|
const getLookupOption_1 = require("../api/getLookupOption");
|
|
14
|
-
const
|
|
14
|
+
const maybeGetLookupValue = (schema, k, value, apiToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
var _a, _b, _c;
|
|
16
16
|
const lookupUrl = (_b = (_a = schema.properties) === null || _a === void 0 ? void 0 : _a[k]) === null || _b === void 0 ? void 0 : _b.lookup;
|
|
17
17
|
if (!lookupUrl)
|
|
18
|
-
return
|
|
18
|
+
return undefined;
|
|
19
19
|
const lookup = yield (0, getLookupOption_1.getLookupOption)(apiToken, lookupUrl);
|
|
20
|
-
return (
|
|
20
|
+
return (_c = lookup.find((l) => l.key === value)) === null || _c === void 0 ? void 0 : _c.value;
|
|
21
21
|
});
|
|
22
|
-
exports.
|
|
22
|
+
exports.maybeGetLookupValue = maybeGetLookupValue;
|
package/dist/locales/index.d.ts
CHANGED
|
@@ -40,5 +40,5 @@ declare global {
|
|
|
40
40
|
var lang: I18nLang;
|
|
41
41
|
}
|
|
42
42
|
export declare const isValidLocale: (lang: string) => lang is "en";
|
|
43
|
-
export declare const $$: (key: I18nKey, variables?: Record<string, string | number>
|
|
43
|
+
export declare const $$: (key: I18nKey, variables?: Record<string, string | number>) => string;
|
|
44
44
|
export {};
|
|
@@ -21,20 +21,20 @@ exports.FILE_MAP = {
|
|
|
21
21
|
};
|
|
22
22
|
const POVerificationBadge = ({ width, POs, }) => {
|
|
23
23
|
// TODO: this won't work if multiple POs of the same schema are shared
|
|
24
|
-
const { $
|
|
24
|
+
const { $badges, $verification_details, $shouldBeVerifiedFields } = POs[0];
|
|
25
25
|
const verifiedBy = $verification_details === null || $verification_details === void 0 ? void 0 : $verification_details.verifier_id;
|
|
26
26
|
return (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
27
27
|
$shouldBeVerifiedFields && (jsx_pdf_1.default.createElement(jsx_pdf_1.default.Fragment, null,
|
|
28
|
-
jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)(`${exports.FILE_MAP[$verified]}.svg`), width: width }),
|
|
29
|
-
jsx_pdf_1.default.createElement("text", { alignment: "center" }, constants_1.PO_VER_TEXT_MAP[$verified]),
|
|
28
|
+
jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)(`${exports.FILE_MAP[$badges.verified.code]}.svg`), width: width }),
|
|
29
|
+
jsx_pdf_1.default.createElement("text", { alignment: "center" }, constants_1.PO_VER_TEXT_MAP[$badges.verified.code]),
|
|
30
30
|
verifiedBy && (jsx_pdf_1.default.createElement("text", { alignment: "center" }, (0, locales_1.$$)("POVerificationBadge.verified-by", { verifiedBy }))))),
|
|
31
|
-
|
|
31
|
+
$badges.safeHarbour && (jsx_pdf_1.default.createElement("columns", { columnGap: 10 },
|
|
32
32
|
jsx_pdf_1.default.createElement("column", { width: width / 3 },
|
|
33
|
-
jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)(`${exports.FILE_MAP[$safeHarbour
|
|
33
|
+
jsx_pdf_1.default.createElement("svg", { content: (0, general_1.loadAsset)(`${exports.FILE_MAP[$badges.safeHarbour.code
|
|
34
34
|
? types_1.POVerification.FullyVerified
|
|
35
35
|
: types_1.POVerification.VerifiedFalse]}.svg`), width: width / 3 })),
|
|
36
36
|
jsx_pdf_1.default.createElement("column", { width: "auto" },
|
|
37
|
-
jsx_pdf_1.default.createElement("text", { alignment: "center" }, $safeHarbour
|
|
37
|
+
jsx_pdf_1.default.createElement("text", { alignment: "center" }, $badges.safeHarbour.code
|
|
38
38
|
? (0, locales_1.$$)("POVerificationBadge.safe-harbour-yes")
|
|
39
39
|
: (0, locales_1.$$)("POVerificationBadge.safe-harbour-no")))))));
|
|
40
40
|
};
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Report = void 0;
|
|
7
7
|
const jsx_pdf_1 = __importDefault(require("jsx-pdf"));
|
|
8
8
|
const crypto_1 = require("crypto");
|
|
9
|
+
const core_1 = require("@raytio/core");
|
|
9
10
|
const locales_1 = require("../../locales");
|
|
10
11
|
const POVerificationBadge_1 = require("./POVerificationBadge");
|
|
11
12
|
const Subheader_1 = require("./Subheader");
|
|
@@ -56,7 +57,7 @@ const Report = ({ data, files, config, aId, clientUrl, envConfig, version, }) =>
|
|
|
56
57
|
Object.entries(constants_1.SUBMISSION_DATA)
|
|
57
58
|
.map(([id, label]) => `${label}: ${(0, transform_1.transform)(id, data[id], config)}`)
|
|
58
59
|
.join("\n"),
|
|
59
|
-
data.score
|
|
60
|
+
(0, core_1.isScoreResultValid)(data.score)
|
|
60
61
|
? [
|
|
61
62
|
"",
|
|
62
63
|
`${(0, locales_1.$$)("constants.score")}: ${data.score.score}`,
|
|
@@ -32,14 +32,14 @@ const Table = ({ POs, files, config, }) => {
|
|
|
32
32
|
if (!PO.$properties[fieldName]) {
|
|
33
33
|
return [jsx_pdf_1.default.createElement("cell", null, " "), jsx_pdf_1.default.createElement("cell", null, " ")];
|
|
34
34
|
}
|
|
35
|
-
const { value, verification } = PO.$properties[fieldName];
|
|
35
|
+
const { value, formatted_value, verification } = PO.$properties[fieldName];
|
|
36
36
|
const color = (0, general_1.verifyColour)(verification);
|
|
37
37
|
// jsx-pdf currently doesn't support fragments, will make a PR at some point
|
|
38
38
|
return [
|
|
39
39
|
jsx_pdf_1.default.createElement("cell", null,
|
|
40
40
|
jsx_pdf_1.default.createElement(FieldVerificationBadge_1.FieldVerificationBadge, { width: 10, status: verification })),
|
|
41
41
|
jsx_pdf_1.default.createElement("cell", null,
|
|
42
|
-
jsx_pdf_1.default.createElement(InnerTableRows_1.InnerTableRows, { key: fieldName, value: value, files: files, config: config, color: color, imageFieldNames: imageFieldNames })),
|
|
42
|
+
jsx_pdf_1.default.createElement(InnerTableRows_1.InnerTableRows, { key: fieldName, value: formatted_value || value, files: files, config: config, color: color, imageFieldNames: imageFieldNames })),
|
|
43
43
|
];
|
|
44
44
|
})));
|
|
45
45
|
})));
|
|
@@ -31,7 +31,12 @@ function decryptStage(log, config, envConfig, instanceId) {
|
|
|
31
31
|
maxcryptor,
|
|
32
32
|
onCorruptedData: () => "🔒 Corrupted Data 🔒",
|
|
33
33
|
});
|
|
34
|
-
return {
|
|
34
|
+
return {
|
|
35
|
+
apiToken,
|
|
36
|
+
instance,
|
|
37
|
+
applicationDecryptor,
|
|
38
|
+
encryptedInstance: apiResp,
|
|
39
|
+
};
|
|
35
40
|
});
|
|
36
41
|
}
|
|
37
42
|
function processSubmission({ applicationId, instanceId, verbose, config, _supliedConfig, }) {
|
|
@@ -40,7 +45,7 @@ function processSubmission({ applicationId, instanceId, verbose, config, _suplie
|
|
|
40
45
|
try {
|
|
41
46
|
log("Fetching config...");
|
|
42
47
|
const envConfig = yield (0, api_1.fetchEnvConfig)(config.CLIENT_URL);
|
|
43
|
-
const { instance, apiToken, applicationDecryptor } = _supliedConfig ||
|
|
48
|
+
const { instance, apiToken, applicationDecryptor, encryptedInstance } = _supliedConfig ||
|
|
44
49
|
(yield decryptStage(log, config, envConfig, instanceId));
|
|
45
50
|
log("Checking verifications...");
|
|
46
51
|
const [profileObjects, verifications] = (0, helpers_1.splitPOAndVers)(instance.profile_objects);
|
|
@@ -61,13 +66,20 @@ function processSubmission({ applicationId, instanceId, verbose, config, _suplie
|
|
|
61
66
|
log("Fetching access application...");
|
|
62
67
|
const AA = yield (0, api_1.fetchAA)(apiToken, envConfig, instance.a_id);
|
|
63
68
|
let score;
|
|
64
|
-
if (AA.ruleset
|
|
65
|
-
typeof AA.ruleset === "object" &&
|
|
66
|
-
Object.keys(AA.ruleset).length) {
|
|
69
|
+
if ((0, core_1.isScoreConfigValid)(AA.ruleset)) {
|
|
67
70
|
const ruleInputData = yield (0, core_1.convertInstanceToRuleInput)(instance, realVers, (schemaName) => (0, api_1.getSchema)(envConfig, schemaName));
|
|
68
71
|
try {
|
|
72
|
+
// decrypt helper never uses a stored score. We always re-calculate it.
|
|
69
73
|
log("Calculating score...");
|
|
70
|
-
score = (0, core_1.calculateScore)(AA.ruleset, ruleInputData);
|
|
74
|
+
score = yield (0, core_1.calculateScore)(AA.ruleset, ruleInputData);
|
|
75
|
+
if (!(0, ramda_1.equals)(instance.score, score)) {
|
|
76
|
+
// the score we calculated is different to the one that's saved on the instance.
|
|
77
|
+
// So we save the new score.
|
|
78
|
+
log("Saving score to instance...");
|
|
79
|
+
// this can happen silently in the background, but we await it since so that we
|
|
80
|
+
// abort if this fails.
|
|
81
|
+
yield (0, api_1.updateInstanceData)(apiToken, Object.assign(Object.assign({}, encryptedInstance), { score }));
|
|
82
|
+
}
|
|
71
83
|
}
|
|
72
84
|
catch (ex) {
|
|
73
85
|
log(`Score calculation failed (${ex})`);
|
|
@@ -91,7 +103,7 @@ function processSubmission({ applicationId, instanceId, verbose, config, _suplie
|
|
|
91
103
|
constants_1.FIELD_VER_TEXT_MAP[field.verification],
|
|
92
104
|
],
|
|
93
105
|
]);
|
|
94
|
-
return Object.assign(Object.assign(
|
|
106
|
+
return Object.assign(Object.assign({}, flatPO), Object.fromEntries(obj));
|
|
95
107
|
}), PODetails)));
|
|
96
108
|
log("Success!");
|
|
97
109
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytio/decrypt-helper",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"author": "Raytio",
|
|
5
5
|
"description": "A helper to decrypt data shared by Raytio users",
|
|
6
6
|
"main": "dist",
|
|
@@ -22,39 +22,39 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@aws-amplify/auth": "3.4.25",
|
|
25
|
-
"@peculiar/webcrypto": "^1.
|
|
26
|
-
"@raytio/core": "^
|
|
25
|
+
"@peculiar/webcrypto": "^1.4.0",
|
|
26
|
+
"@raytio/core": "^10.0.1",
|
|
27
27
|
"@raytio/maxcryptor": "^3.1.0",
|
|
28
|
-
"@raytio/types": "^6.0.
|
|
28
|
+
"@raytio/types": "^6.0.2",
|
|
29
29
|
"aws-sdk": "^2.754.0",
|
|
30
30
|
"jsx-pdf": "^2.3.0",
|
|
31
31
|
"localstorage-polyfill": "^1.0.1",
|
|
32
32
|
"mime-types": "^2.1.35",
|
|
33
33
|
"node-fetch": "^2.6.7",
|
|
34
|
-
"pdfmake": "^0.2.
|
|
34
|
+
"pdfmake": "^0.2.5",
|
|
35
35
|
"ramda": "^0.28.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@raytio/react-intl-manager": "^6.3.0",
|
|
39
|
-
"@types/jest": "^
|
|
40
|
-
"@types/jest-image-snapshot": "^
|
|
39
|
+
"@types/jest": "^28.1.4",
|
|
40
|
+
"@types/jest-image-snapshot": "^5.1.0",
|
|
41
41
|
"@types/jsx-pdf": "^2.2.2",
|
|
42
42
|
"@types/mime-types": "^2.1.1",
|
|
43
|
-
"@types/node": "^16.11.
|
|
43
|
+
"@types/node": "^16.11.43",
|
|
44
44
|
"@types/node-fetch": "^2.5.12",
|
|
45
|
-
"@types/pdfmake": "^0.
|
|
46
|
-
"@types/ramda": "^0.28.
|
|
45
|
+
"@types/pdfmake": "^0.2.0",
|
|
46
|
+
"@types/ramda": "^0.28.14",
|
|
47
47
|
"babel-preset-react-app": "^10.0.1",
|
|
48
|
-
"dotenv": "^16.0.
|
|
49
|
-
"eslint": "^8.
|
|
50
|
-
"eslint-config-kyle": "^8.
|
|
51
|
-
"jest": "^
|
|
52
|
-
"jest-image-snapshot": "^
|
|
53
|
-
"jest-junit": "^
|
|
48
|
+
"dotenv": "^16.0.1",
|
|
49
|
+
"eslint": "^8.19.0",
|
|
50
|
+
"eslint-config-kyle": "^8.38.0",
|
|
51
|
+
"jest": "^28.1.2",
|
|
52
|
+
"jest-image-snapshot": "^5.1.0",
|
|
53
|
+
"jest-junit": "^14.0.0",
|
|
54
54
|
"pdf-to-img": "^1.2.0",
|
|
55
|
-
"ts-jest": "^
|
|
56
|
-
"ts-node": "^10.
|
|
57
|
-
"typescript": "^4.
|
|
55
|
+
"ts-jest": "^28.0.5",
|
|
56
|
+
"ts-node": "^10.8.2",
|
|
57
|
+
"typescript": "^4.7.4"
|
|
58
58
|
},
|
|
59
59
|
"eslintConfig": {
|
|
60
60
|
"extends": "kyle",
|