@raytio/decrypt-helper 4.0.0 → 5.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.
- package/CHANGELOG.md +17 -0
- package/dist/api/authedFetch.js +1 -1
- package/dist/api/fetchEnvConfig.d.ts +3 -1
- package/dist/api/fetchEnvConfig.js +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/resolveVerificationDetails.d.ts +1 -1
- package/dist/api/resolveVerificationDetails.js +15 -18
- package/dist/api/signIn.js +1 -1
- package/dist/helpers/formatOutput.js +1 -1
- package/dist/helpers/json2csv.js +1 -1
- package/dist/pdf/components/Report.js +3 -1
- package/dist/pdf/helpers/transform.js +2 -1
- package/dist/public-methods/generatePDF.js +2 -2
- package/package.json +11 -11
- package/dist/api/getProfileObject.d.ts +0 -3
- package/dist/api/getProfileObject.js +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## 5.1.1 (2022-08-15)
|
|
11
|
+
|
|
12
|
+
- !189 load verifier details faster
|
|
13
|
+
- !187 automated dependency updates
|
|
14
|
+
|
|
15
|
+
## 5.1.0 (2022-08-13)
|
|
16
|
+
|
|
17
|
+
- !188 update raytio/core so that `repairDate` is used on dates
|
|
18
|
+
- !186 automated dependency updates
|
|
19
|
+
|
|
20
|
+
## 5.0.0 (2022-07-12)
|
|
21
|
+
|
|
22
|
+
- 💥 BREAKING CHANGE: !185 use `accessToken` instead of `idToken` when communicating with the Raytio API
|
|
23
|
+
- 💥 BREAKING CHANGE: !185 Improve how quotes (`"`) are escaped in the csv format to be compliant with [RFC-4180](https://datatracker.ietf.org/doc/html/rfc4180#section-2)
|
|
24
|
+
- !185 embed language into pdf
|
|
25
|
+
- !184 automated dependency updates
|
|
26
|
+
|
|
10
27
|
## 4.0.0 (2022-07-08)
|
|
11
28
|
|
|
12
29
|
- 💥 BREAKING CHANGE: !170 [json] [csv] changed the format of badges, the fields `$verified` and `$safeHarbour` have been replaced with `$badges`
|
package/dist/api/authedFetch.js
CHANGED
|
@@ -14,7 +14,7 @@ function authedFetch(apiToken, url, options) {
|
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
const apiResp = yield fetch(url, Object.assign(Object.assign({}, options), { headers: { Authorization: `Bearer ${apiToken}` } })).then((r) => r.json());
|
|
16
16
|
if (apiResp.message) {
|
|
17
|
-
throw new Error(`Failed due to API Error: "${apiResp.message}"`);
|
|
17
|
+
throw new Error(`Failed due to API Error from ${url}: "${apiResp.message}"`);
|
|
18
18
|
}
|
|
19
19
|
return apiResp;
|
|
20
20
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
declare const PARAMS: readonly ["cognito_region", "cognito_user_pool_id", "cognito_web_client_id", "api_url", "app_name", "logo_url"];
|
|
2
|
-
export declare type EnvConfig = Record<typeof PARAMS[number], string
|
|
2
|
+
export declare type EnvConfig = Record<typeof PARAMS[number], string> & {
|
|
3
|
+
clientUrl: string;
|
|
4
|
+
};
|
|
3
5
|
export declare function fetchEnvConfig(clientUrl: string): Promise<EnvConfig>;
|
|
4
6
|
export {};
|
|
@@ -29,7 +29,7 @@ function fetchEnvConfig(clientUrl) {
|
|
|
29
29
|
const missing = PARAMS.filter((p) => !(p in envConfig));
|
|
30
30
|
if (missing.length)
|
|
31
31
|
throw new Error(`Missing: ${missing.join(", ")}`);
|
|
32
|
-
return envConfig;
|
|
32
|
+
return Object.assign(Object.assign({}, envConfig), { clientUrl });
|
|
33
33
|
}
|
|
34
34
|
catch (ex) {
|
|
35
35
|
throw new Error(`The CLIENT_URL you specified is not a valid Raytio client. Are you sure you used the client URL, not the API url? You supplied: "${clientUrl}" (${ex})`);
|
package/dist/api/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from "./fetchAA";
|
|
|
3
3
|
export * from "./fetchEnvConfig";
|
|
4
4
|
export * from "./fetchInstanceData";
|
|
5
5
|
export * from "./getFiles";
|
|
6
|
-
export * from "./getProfileObject";
|
|
7
6
|
export * from "./getSchema";
|
|
8
7
|
export * from "./resolveVerificationDetails";
|
|
9
8
|
export * from "./signIn";
|
package/dist/api/index.js
CHANGED
|
@@ -19,7 +19,6 @@ __exportStar(require("./fetchAA"), exports);
|
|
|
19
19
|
__exportStar(require("./fetchEnvConfig"), exports);
|
|
20
20
|
__exportStar(require("./fetchInstanceData"), exports);
|
|
21
21
|
__exportStar(require("./getFiles"), exports);
|
|
22
|
-
__exportStar(require("./getProfileObject"), exports);
|
|
23
22
|
__exportStar(require("./getSchema"), exports);
|
|
24
23
|
__exportStar(require("./resolveVerificationDetails"), exports);
|
|
25
24
|
__exportStar(require("./signIn"), exports);
|
|
@@ -6,4 +6,4 @@ export declare type ResolvedVerificationProvider = {
|
|
|
6
6
|
verifier_source_id?: string;
|
|
7
7
|
date?: string;
|
|
8
8
|
};
|
|
9
|
-
export declare function resolveVerificationDetails([details]: VerificationProvider[],
|
|
9
|
+
export declare function resolveVerificationDetails([details]: VerificationProvider[], envConfig: EnvConfig): Promise<ResolvedVerificationProvider | undefined>;
|
|
@@ -8,30 +8,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.resolveVerificationDetails = void 0;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
17
|
+
let verifiersPromise;
|
|
18
|
+
function resolveVerificationDetails([details], envConfig) {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
16
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
21
|
if (!details)
|
|
18
22
|
return undefined;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
: undefined;
|
|
24
|
-
});
|
|
25
|
-
const [verifier_id, verifier_service_id, verifier_source_id] = yield Promise.all([
|
|
26
|
-
maybeGet(details.dataSourceNId),
|
|
27
|
-
maybeGet(details.serviceProviderNId),
|
|
28
|
-
maybeGet(details.verifierNId),
|
|
29
|
-
]);
|
|
23
|
+
verifiersPromise || (verifiersPromise = (0, node_fetch_1.default)(`${envConfig.clientUrl}/verifiers.json`)
|
|
24
|
+
.then((r) => r.json())
|
|
25
|
+
.catch(() => ({ verifiers: {} })));
|
|
26
|
+
const { verifiers } = yield verifiersPromise;
|
|
30
27
|
return {
|
|
31
|
-
verifier_id,
|
|
32
|
-
verifier_service_id,
|
|
33
|
-
verifier_source_id,
|
|
34
|
-
date: (
|
|
28
|
+
verifier_id: (_a = verifiers[details.verifierNId]) === null || _a === void 0 ? void 0 : _a.name,
|
|
29
|
+
verifier_service_id: (_b = verifiers[details.serviceProviderNId]) === null || _b === void 0 ? void 0 : _b.name,
|
|
30
|
+
verifier_source_id: (_c = verifiers[details.dataSourceNId]) === null || _c === void 0 ? void 0 : _c.name,
|
|
31
|
+
date: (_d = details.date) === null || _d === void 0 ? void 0 : _d.toISOString(),
|
|
35
32
|
};
|
|
36
33
|
});
|
|
37
34
|
}
|
package/dist/api/signIn.js
CHANGED
|
@@ -48,7 +48,7 @@ function signIn(CONFIG, envConfig) {
|
|
|
48
48
|
throw new Error(`The configured account (${CONFIG.RAYTIO_USERNAME}) has two factor authentication enabled. You must disable 2FA or use a different account`);
|
|
49
49
|
}
|
|
50
50
|
const user = yield auth_1.Auth.currentAuthenticatedUser();
|
|
51
|
-
const apiToken = (_b = (_a = user.signInUserSession) === null || _a === void 0 ? void 0 : _a.
|
|
51
|
+
const apiToken = (_b = (_a = user.signInUserSession) === null || _a === void 0 ? void 0 : _a.accessToken) === null || _b === void 0 ? void 0 : _b.jwtToken;
|
|
52
52
|
const cognitoAttributes = yield auth_1.Auth.userAttributes(user);
|
|
53
53
|
return { apiToken, cognitoAttributes };
|
|
54
54
|
});
|
|
@@ -58,7 +58,7 @@ function formatOutput(profileObjects, allSchemas, realVers, apiToken, envConfig)
|
|
|
58
58
|
return Object.assign(Object.assign({}, accP), { [key]: obj });
|
|
59
59
|
}), Promise.resolve({}));
|
|
60
60
|
const thisPO = {
|
|
61
|
-
$verification_details: yield (0, api_1.resolveVerificationDetails)(verDetails.details.verifiers,
|
|
61
|
+
$verification_details: yield (0, api_1.resolveVerificationDetails)(verDetails.details.verifiers, envConfig),
|
|
62
62
|
$shouldBeVerifiedFields: (_a = schema.verified_fields) === null || _a === void 0 ? void 0 : _a.map((x) => typeof x === "string" ? x : x.field),
|
|
63
63
|
$nId: PO.n_id,
|
|
64
64
|
$schemaName: schemaName,
|
package/dist/helpers/json2csv.js
CHANGED
|
@@ -17,7 +17,7 @@ function deepJsonToCsv(json) {
|
|
|
17
17
|
const flatJson = (0, exports.flattenObj)(json);
|
|
18
18
|
const [headerRow, values] = (0, ramda_1.transpose)(Object.entries(flatJson));
|
|
19
19
|
const toCsvRow = (row) => row
|
|
20
|
-
.map((field) => typeof field === "string" ? `"${field.replace(/"/g, '
|
|
20
|
+
.map((field) => typeof field === "string" ? `"${field.replace(/"/g, '""')}"` : field)
|
|
21
21
|
.join(",");
|
|
22
22
|
return `${toCsvRow(headerRow)}\n${toCsvRow(values)}`;
|
|
23
23
|
}
|
|
@@ -34,7 +34,9 @@ const Report = ({ data, files, config, aId, clientUrl, envConfig, version, }) =>
|
|
|
34
34
|
creator: appName,
|
|
35
35
|
producer: "Raytio",
|
|
36
36
|
subject: version,
|
|
37
|
-
},
|
|
37
|
+
},
|
|
38
|
+
// @ts-expect-error -- waiting on bpampuch/pdfmake#2453
|
|
39
|
+
lang: global.lang, ownerPassword: randomToken, permissions: {
|
|
38
40
|
printing: "highResolution",
|
|
39
41
|
copying: true, // allow copy/paste
|
|
40
42
|
}, pageSize: "A4", styles: style_1.classes, images: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transform = exports.IS_ARRAY_OF_OBJECTS = exports.IS_IMAGE = void 0;
|
|
4
|
+
const core_1 = require("@raytio/core");
|
|
4
5
|
const locales_1 = require("../../locales");
|
|
5
6
|
const general_1 = require("./general");
|
|
6
7
|
exports.IS_IMAGE = Symbol.for("image");
|
|
@@ -28,7 +29,7 @@ function transform(key, value, pdfConfig, imageFieldNames) {
|
|
|
28
29
|
switch (key) {
|
|
29
30
|
case "start_date":
|
|
30
31
|
case "end_date": {
|
|
31
|
-
return (0, general_1.formatDate)(
|
|
32
|
+
return (0, general_1.formatDate)((0, core_1.repairDate)(value), pdfConfig.DATE_FORMAT, pdfConfig.TIMEZONE);
|
|
32
33
|
}
|
|
33
34
|
default: {
|
|
34
35
|
return value;
|
|
@@ -29,7 +29,6 @@ const generatePDF = () => (data) => __awaiter(void 0, void 0, void 0, function*
|
|
|
29
29
|
console.log("Generating PDF Report...");
|
|
30
30
|
const { DATE_FORMAT = "en-nz", TIMEZONE = "Pacific/Auckland" } = process.env;
|
|
31
31
|
const pkg = JSON.parse(yield fs_1.promises.readFile((0, path_1.join)(__dirname, "../../package.json"), "utf8"));
|
|
32
|
-
const version = `node:${process.version} pkg:${pkg.version}`;
|
|
33
32
|
if (data.envConfig.logo_url) {
|
|
34
33
|
// there is a white labelling URL, so fetch it and write it to disk, overriding the default logo
|
|
35
34
|
const arrayBuf = yield (0, node_fetch_1.default)(data.envConfig.logo_url).then((r) => r.arrayBuffer());
|
|
@@ -44,9 +43,10 @@ const generatePDF = () => (data) => __awaiter(void 0, void 0, void 0, function*
|
|
|
44
43
|
console.warn(`The specified PDF_LANGUAGE is language is invalid (${customLang})`);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
46
|
+
const subject = `node:${process.version} pkg:${pkg.version} lang:${global.lang}`;
|
|
47
47
|
return new Promise((resolve) => {
|
|
48
48
|
const printer = new pdfmake_1.default(style_1.fonts);
|
|
49
|
-
const pdfDoc = printer.createPdfKitDocument(generatePdfJson(data, DATE_FORMAT, TIMEZONE,
|
|
49
|
+
const pdfDoc = printer.createPdfKitDocument(generatePdfJson(data, DATE_FORMAT, TIMEZONE, subject));
|
|
50
50
|
const chunks = [];
|
|
51
51
|
pdfDoc.on("data", (chunk) => chunks.push(chunk));
|
|
52
52
|
pdfDoc.on("end", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytio/decrypt-helper",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"author": "Raytio",
|
|
5
5
|
"description": "A helper to decrypt data shared by Raytio users",
|
|
6
6
|
"main": "dist",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@aws-amplify/auth": "3.4.25",
|
|
25
25
|
"@peculiar/webcrypto": "^1.4.0",
|
|
26
|
-
"@raytio/core": "^10.0
|
|
26
|
+
"@raytio/core": "^10.1.0",
|
|
27
27
|
"@raytio/maxcryptor": "^3.1.0",
|
|
28
28
|
"@raytio/types": "^6.0.2",
|
|
29
29
|
"aws-sdk": "^2.754.0",
|
|
@@ -36,24 +36,24 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@raytio/react-intl-manager": "^6.3.0",
|
|
39
|
-
"@types/jest": "^28.1.
|
|
39
|
+
"@types/jest": "^28.1.6",
|
|
40
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.48",
|
|
44
44
|
"@types/node-fetch": "^2.5.12",
|
|
45
|
-
"@types/pdfmake": "^0.2.
|
|
46
|
-
"@types/ramda": "^0.28.
|
|
45
|
+
"@types/pdfmake": "^0.2.1",
|
|
46
|
+
"@types/ramda": "^0.28.15",
|
|
47
47
|
"babel-preset-react-app": "^10.0.1",
|
|
48
48
|
"dotenv": "^16.0.1",
|
|
49
|
-
"eslint": "^8.
|
|
50
|
-
"eslint-config-kyle": "^8.
|
|
51
|
-
"jest": "^28.1.
|
|
49
|
+
"eslint": "^8.22.0",
|
|
50
|
+
"eslint-config-kyle": "^8.47.0",
|
|
51
|
+
"jest": "^28.1.3",
|
|
52
52
|
"jest-image-snapshot": "^5.1.0",
|
|
53
53
|
"jest-junit": "^14.0.0",
|
|
54
54
|
"pdf-to-img": "^1.2.0",
|
|
55
|
-
"ts-jest": "^28.0.
|
|
56
|
-
"ts-node": "^10.
|
|
55
|
+
"ts-jest": "^28.0.7",
|
|
56
|
+
"ts-node": "^10.9.1",
|
|
57
57
|
"typescript": "^4.7.4"
|
|
58
58
|
},
|
|
59
59
|
"eslintConfig": {
|
|
@@ -1,19 +0,0 @@
|
|
|
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.getProfileObject = void 0;
|
|
13
|
-
const authedFetch_1 = require("./authedFetch");
|
|
14
|
-
function getProfileObject(envConfig, apiToken, nId) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
return (0, authedFetch_1.authedFetch)(apiToken, `${envConfig.api_url}/graph/v2/profile_object/${nId}`);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
exports.getProfileObject = getProfileObject;
|