@raytio/decrypt-helper 6.3.3 → 6.3.5

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.
@@ -11,14 +11,19 @@ export function authedFetch(apiToken, url, options, retrying = false) {
11
11
  return __awaiter(this, void 0, void 0, function* () {
12
12
  console.log(`[API] ${retrying ? "Retry" : "Start"} ${url}`);
13
13
  const startTime = Date.now();
14
- const response = yield fetch(url, Object.assign(Object.assign({}, options), { headers: { Authorization: `Bearer ${apiToken}` } }));
15
- const apiResponse = yield response.json();
16
- const error = apiResponse.message || apiResponse.error;
17
- if (error) {
14
+ const response = yield fetch(url, Object.assign(Object.assign({}, options), { headers: Object.assign({ Authorization: `Bearer ${apiToken}` }, options === null || options === void 0 ? void 0 : options.headers) }));
15
+ let apiResponse = null;
16
+ const contentType = response.headers.get("content-type");
17
+ if (contentType === null || contentType === void 0 ? void 0 : contentType.startsWith("application/json")) {
18
+ const responseText = yield response.text();
19
+ apiResponse = responseText ? JSON.parse(responseText) : null;
20
+ }
21
+ if (!response.ok) {
18
22
  if (!retrying && response.status === 504) {
19
23
  console.log(`[API] Error ${response.status} (will retry) ${url}`);
20
24
  return authedFetch(apiToken, url, options, true);
21
25
  }
26
+ const error = (apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.message) || (apiResponse === null || apiResponse === void 0 ? void 0 : apiResponse.error) || "No error message provided";
22
27
  console.log(`[API] Error ${response.status} (no retry) ${url}`);
23
28
  throw new Error(`Failed due to API Error from ${url}: "${error}"`);
24
29
  }
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  let verifiersPromise;
11
11
  export function resolveVerificationDetails([details], envConfig) {
12
- var _a, _b, _c, _d;
12
+ var _a, _b, _c;
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  if (!details)
15
15
  return undefined;
@@ -21,7 +21,7 @@ export function resolveVerificationDetails([details], envConfig) {
21
21
  verifier_id: (_a = verifiers[details.verifierNId]) === null || _a === void 0 ? void 0 : _a.name,
22
22
  verifier_service_id: (_b = verifiers[details.serviceProviderNId]) === null || _b === void 0 ? void 0 : _b.name,
23
23
  verifier_source_id: (_c = verifiers[details.dataSourceNId]) === null || _c === void 0 ? void 0 : _c.name,
24
- date: (_d = details.date) === null || _d === void 0 ? void 0 : _d.toISOString(),
24
+ date: details.date ? new Date(details.date).toISOString() : undefined,
25
25
  };
26
26
  });
27
27
  }
@@ -14,6 +14,10 @@ import { authedFetch } from "./authedFetch.js";
14
14
  */
15
15
  export function updateInstanceData(apiToken, envConfig, iId, instance) {
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
- yield authedFetch(apiToken, `${envConfig.api_url}/db/v1/dsm_access_application_instances_u?id=eq.${iId}`, { method: "PATCH", body: JSON.stringify(instance) });
17
+ yield authedFetch(apiToken, `${envConfig.api_url}/db/v1/dsm_access_application_instances_u?id=eq.${iId}`, {
18
+ method: "PATCH",
19
+ headers: { "Content-Type": "application/json" },
20
+ body: JSON.stringify(instance),
21
+ });
18
22
  });
19
23
  }
@@ -26,7 +26,17 @@ const byPriority = (schema) => ([a], [b]) => {
26
26
  };
27
27
  export function formatOutput(profileObjects, allSchemas, realVers, apiToken, envConfig) {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
- const PODetails = profileObjects.reduce((accumulatorPromiseOuter, PO) => __awaiter(this, void 0, void 0, function* () {
29
+ const locale = process.env.PDF_LANGUAGE || process.env.DATE_FORMAT || "en-NZ";
30
+ const tagsToHide = [
31
+ "type:client_only",
32
+ "type:globally_unique_field",
33
+ ];
34
+ const filteredPOs = profileObjects.filter((PO) => {
35
+ const schemaName = findSchemaLabel(PO.labels);
36
+ return (schemaName &&
37
+ !tagsToHide.some((tag) => { var _a, _b; return (_b = (_a = allSchemas.find((s) => s.name === schemaName)) === null || _a === void 0 ? void 0 : _a.tags) === null || _b === void 0 ? void 0 : _b.includes(tag); }));
38
+ });
39
+ const PODetails = filteredPOs.reduce((accumulatorPromiseOuter, PO) => __awaiter(this, void 0, void 0, function* () {
30
40
  var _a;
31
41
  const accumulatorOuter = yield accumulatorPromiseOuter;
32
42
  const schemaName = findSchemaLabel(PO.labels);
@@ -39,14 +49,15 @@ export function formatOutput(profileObjects, allSchemas, realVers, apiToken, env
39
49
  const existing = accumulatorOuter[schemaName] || [];
40
50
  const poProperties = Object.entries(realProperties).sort(byPriority(schema));
41
51
  const reducedProperties = yield poProperties.reduce((accumulatorPromiseInner, [key, value]) => __awaiter(this, void 0, void 0, function* () {
42
- var _b, _c;
52
+ var _b, _c, _d;
43
53
  const accumulatorInner = yield accumulatorPromiseInner;
44
54
  assertSafeProperty(key);
45
55
  const prettyValue = typeof value === "string"
46
56
  ? yield maybeGetLookupValue(schema, key, value, apiToken)
47
57
  : undefined;
58
+ const schemaField = Object.values(schema.properties || {}).find((f) => f.$prop.split(" <=> ")[0] === (key === null || key === void 0 ? void 0 : key.split(" <=> ")[0]));
48
59
  const POInfo = {
49
- title: ((_c = (_b = schema.properties) === null || _b === void 0 ? void 0 : _b[key]) === null || _c === void 0 ? void 0 : _c.title) || key,
60
+ title: ((_d = (_c = (_b = schema === null || schema === void 0 ? void 0 : schema.i18n) === null || _b === void 0 ? void 0 : _b[locale]) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.title) || (schemaField === null || schemaField === void 0 ? void 0 : schemaField.title) || key,
50
61
  value,
51
62
  verification: versionDetails.fieldVerifications[key] ||
52
63
  FieldVerification.NotVerified,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytio/decrypt-helper",
3
- "version": "6.3.3",
3
+ "version": "6.3.5",
4
4
  "author": "Raytio",
5
5
  "type": "module",
6
6
  "description": "A helper to decrypt data shared by Raytio users",
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@aws-amplify/auth": "3.4.25",
26
- "@raytio/core": "^11.3.0",
26
+ "@raytio/core": "^11.5.0",
27
27
  "@raytio/maxcryptor": "^3.1.0",
28
- "@raytio/types": "^7.3.0",
28
+ "@raytio/types": "^8.0.0",
29
29
  "aws-sdk": "^2.754.0",
30
30
  "jsx-pdf": "^2.3.0",
31
31
  "localstorage-polyfill": "^1.0.1",