@raytio/core 11.3.0 → 11.4.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.
Files changed (29) hide show
  1. package/README.md +7 -0
  2. package/dist/accessApplication/api/fetchKeysForSubmission.js +1 -2
  3. package/dist/accessApplication/api/fetchPOsOrAOsForSubmission.js +1 -2
  4. package/dist/accessApplication/api/fetchRelationshipsForSubmission.js +1 -2
  5. package/dist/accessApplication/api/legacy/convertRelationships.js +1 -2
  6. package/dist/accessApplication/createAA.d.ts +4 -1
  7. package/dist/accessApplication/createAA.js +67 -17
  8. package/dist/crypto/decryptSharedData.d.ts +1 -1
  9. package/dist/crypto/getAADecryptor.js +2 -3
  10. package/dist/general/date.js +1 -2
  11. package/dist/general/password.js +1 -2
  12. package/dist/general/types.js +2 -2
  13. package/dist/rules/calculateScore.js +2 -3
  14. package/dist/rules/evaluateScoreCondition.js +1 -2
  15. package/dist/rules/helpers/checkTypeofValue.js +2 -3
  16. package/dist/rules/helpers/getValuesFromPath.js +1 -2
  17. package/dist/rules/helpers/thresholds.js +2 -3
  18. package/dist/schema/expandSchema/expandSchema.js +1 -2
  19. package/dist/schema/expandSchema/processSchema.js +12 -10
  20. package/dist/schema/expandSchema/removePrivateFields.d.ts +54 -46
  21. package/dist/schema/expandSchema/sortSchemaProperties.d.ts +1 -1
  22. package/dist/schema/expandSchema/sortSchemaProperties.js +2 -2
  23. package/dist/schema/expandSchema/unwrapSchema.js +1 -2
  24. package/dist/testHelpers.d.ts +1 -1
  25. package/dist/verifications/cleanInstance.d.ts +1 -1
  26. package/dist/verifications/getPOVerification.js +1 -2
  27. package/dist/verifications/safeHarbour.js +4 -4
  28. package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +2 -2
  29. package/package.json +3 -3
package/README.md CHANGED
@@ -20,6 +20,7 @@ If you wish to use `@raytio/core` directly, an example of configuring polyfills
20
20
 
21
21
  - [SafeHarbourObj](#safeharbourobj)
22
22
  - [SafeHarbourResult](#safeharbourresult)
23
+ - [ServerAA](#serveraa)
23
24
  - [ServerRelationship](#serverrelationship)
24
25
  - [VerDetails](#verdetails)
25
26
 
@@ -81,6 +82,12 @@ the response from [calcSafeHarbourScore](#calcsafeharbourscore)
81
82
 
82
83
  ___
83
84
 
85
+ ### ServerAA
86
+
87
+ Ƭ **ServerAA**: `Omit`<`AA`, ``"a_id"``\> & { `id`: `AId` }
88
+
89
+ ___
90
+
84
91
  ### ServerRelationship
85
92
 
86
93
  Ƭ **ServerRelationship**: `Omit`<`Relationship`, ``"p_id"`` \| ``"start"`` \| ``"end"``\> & { `from_id`: `NId` ; `id`: `PId` } & { `to_id`: `NId` } \| { `to_i_id`: `IId` }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchKeysForSubmission = void 0;
3
+ exports.fetchKeysForSubmission = fetchKeysForSubmission;
4
4
  const util_1 = require("../../util");
5
5
  async function fetchKeysForSubmission({ apiToken, apiUrl, iId, }) {
6
6
  var _a;
@@ -13,4 +13,3 @@ async function fetchKeysForSubmission({ apiToken, apiUrl, iId, }) {
13
13
  }
14
14
  return keysObject;
15
15
  }
16
- exports.fetchKeysForSubmission = fetchKeysForSubmission;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchPOsOrAOsForSubmission = void 0;
3
+ exports.fetchPOsOrAOsForSubmission = fetchPOsOrAOsForSubmission;
4
4
  const ramda_1 = require("ramda");
5
5
  const util_1 = require("../../util");
6
6
  const general_1 = require("../../general");
@@ -22,4 +22,3 @@ async function fetchPOsOrAOsForSubmission({ iId, apiUrl, apiToken }, type) {
22
22
  const cleanedPOs = POsforAA.map((PO) => (Object.assign(Object.assign({}, (0, ramda_1.omit)(["aa_id", "aai_id", "hashed_n_id"], PO)), { n_id: PO.n_id || (0, general_1.createHashedNId)(PO.hashed_n_id, PO.aa_id), isFromSubmission: [PO.aa_id, PO.aai_id] }))).filter(PO => PO.properties !== null && PO.properties !== undefined);
23
23
  return cleanedPOs;
24
24
  }
25
- exports.fetchPOsOrAOsForSubmission = fetchPOsOrAOsForSubmission;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchRelationshipsForSubmission = void 0;
3
+ exports.fetchRelationshipsForSubmission = fetchRelationshipsForSubmission;
4
4
  const util_1 = require("../../util");
5
5
  const legacy_1 = require("./legacy");
6
6
  async function fetchRelationshipsForSubmission({ iId, apiUrl, apiToken, }) {
7
7
  const relationships = await fetch(`${apiUrl}/db/v1/dsm_access_application_instance_node_relationships?aai_id=eq.${iId}`, { headers: { Authorization: `Bearer ${apiToken}` } }).then(util_1.handleResponse);
8
8
  return relationships.map(legacy_1.convertServerRelationship);
9
9
  }
10
- exports.fetchRelationshipsForSubmission = fetchRelationshipsForSubmission;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertServerRelationship = void 0;
3
+ exports.convertServerRelationship = convertServerRelationship;
4
4
  const ramda_1 = require("ramda");
5
5
  /**
6
6
  * Converts relationship type used by the server into the (Urn format) type used by the client
@@ -18,4 +18,3 @@ function convertServerRelationship(serverRelationship) {
18
18
  : `urn:instance:${serverRelationship.to_i_id}`;
19
19
  return Object.assign({ p_id: id, start: `urn:profile_object:${from_id}`, end }, (0, ramda_1.omit)(["id", "from_id", "to_id", "to_i_id"], serverRelationship));
20
20
  }
21
- exports.convertServerRelationship = convertServerRelationship;
@@ -1,5 +1,8 @@
1
1
  import type { Maxcryptor, UserDoc } from "@raytio/maxcryptor";
2
- import type { AA } from "@raytio/types";
2
+ import type { AA, AId } from "@raytio/types";
3
+ export type ServerAA = Omit<AA, "a_id"> & {
4
+ id: AId;
5
+ };
3
6
  /**
4
7
  * Creates an Access Application and associated public+private keys.
5
8
  *
@@ -1,28 +1,70 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAA = void 0;
14
+ exports.createAA = createAA;
4
15
  const util_1 = require("../util");
5
16
  /** @internal */
6
- const createApplication = ({ apiUrl, apiToken, application, }) => fetch(`${apiUrl}/share/v2/access_application`, {
17
+ const createApplication = ({ apiUrl, apiToken, application, }) => fetch(`${apiUrl}/db/v1/dsm_access_applications`, {
7
18
  method: "POST",
8
19
  body: JSON.stringify(application),
9
- headers: { Authorization: `Bearer ${apiToken}` },
20
+ headers: {
21
+ Authorization: `Bearer ${apiToken}`,
22
+ "Content-Type": "application/json",
23
+ Prefer: "return=representation",
24
+ },
25
+ }).then(util_1.handleResponse);
26
+ /** @internal */
27
+ const createAATransitions = async ({ apiUrl, apiToken, transitions, }) => fetch(`${apiUrl}/db/v1/dsm_access_application_transitions`, {
28
+ method: "POST",
29
+ body: JSON.stringify(transitions),
30
+ headers: {
31
+ Authorization: `Bearer ${apiToken}`,
32
+ "Content-Type": "application/json",
33
+ },
10
34
  }).then(util_1.handleResponse);
11
35
  /** @internal */
12
36
  const createApplicationPublicKey = async ({ apiUrl, apiToken, aId, publicKey, }) => {
13
- const PO = await fetch(`${apiUrl}/share/v2/access_application/${aId}/public_key`, {
37
+ const PO = await fetch(`${apiUrl}/db/v1/dsm_access_application_public_keys`, {
14
38
  method: "POST",
15
- body: JSON.stringify({ a_id: aId, key: publicKey }),
16
- headers: { Authorization: `Bearer ${apiToken}` },
39
+ headers: {
40
+ Authorization: `Bearer ${apiToken}`,
41
+ Accept: "application/json",
42
+ "Content-Type": "application/json",
43
+ Prefer: "return=representation",
44
+ },
45
+ body: JSON.stringify({
46
+ aa_id: aId,
47
+ public_key: publicKey,
48
+ metadata: null,
49
+ }),
17
50
  }).then(util_1.handleResponse);
18
51
  // temporary typecast until this API is updated
19
- return { publicKeyId: PO.n_id };
52
+ return { publicKeyId: PO[0].id };
20
53
  };
21
54
  /** @internal */
22
- const createApplicationEncryptedPrivateKey = ({ apiUrl, apiToken, publicKeyId, encryptedPrivateKey, }) => fetch(`${apiUrl}/share/v2/access_application/public_key/${publicKeyId}/private_key`, {
55
+ const createApplicationEncryptedPrivateKey = ({ apiUrl, apiToken, aId, publicKeyId, encryptedPrivateKey, }) => fetch(`${apiUrl}/db/v1/dsm_access_application_private_keys`, {
23
56
  method: "POST",
24
- body: JSON.stringify({ n_id: publicKeyId, key: encryptedPrivateKey }),
25
- headers: { Authorization: `Bearer ${apiToken}` },
57
+ headers: {
58
+ Authorization: `Bearer ${apiToken}`,
59
+ Accept: "application/json",
60
+ "Content-Type": "application/json",
61
+ Prefer: "return=representation",
62
+ },
63
+ body: JSON.stringify({
64
+ aa_id: aId,
65
+ aack_id: publicKeyId,
66
+ encrypted_private_key: encryptedPrivateKey,
67
+ }),
26
68
  }).then(util_1.handleResponse);
27
69
  /** @internal */
28
70
  async function createApplicationEncryptor(userDoc, maxcryptor) {
@@ -46,27 +88,35 @@ async function createApplicationEncryptor(userDoc, maxcryptor) {
46
88
  * as well as the `userDoc` data which is stored in the user's cognito attributes.
47
89
  */
48
90
  async function createAA({ apiUrl, apiToken, userDoc, maxcryptor, application, }) {
49
- if (!application.org_id) {
50
- throw new Error("Cannot create an AA without an org_id");
91
+ if (!application.customer_id) {
92
+ throw new Error("Cannot create an AA without a customer_id");
51
93
  }
52
- const newApp = await createApplication({
94
+ const { transitions } = application, applicationWithoutTransitions = __rest(application, ["transitions"]);
95
+ const createAAResponse = await createApplication({
53
96
  apiUrl,
54
97
  apiToken,
55
- application,
98
+ application: applicationWithoutTransitions,
99
+ });
100
+ const _a = createAAResponse[0], { id: newAppID } = _a, restOfNewApp = __rest(_a, ["id"]);
101
+ const transitionsWithAid = (transitions || []).map(item => (Object.assign(Object.assign({}, item), { aa_id: newAppID })));
102
+ await createAATransitions({
103
+ apiUrl,
104
+ apiToken,
105
+ transitions: transitionsWithAid,
56
106
  });
57
107
  const { publicKey, encryptedPrivateKey } = await createApplicationEncryptor(userDoc, maxcryptor);
58
108
  const { publicKeyId } = await createApplicationPublicKey({
59
109
  apiUrl,
60
110
  apiToken,
61
- aId: newApp.a_id,
111
+ aId: newAppID,
62
112
  publicKey,
63
113
  });
64
114
  await createApplicationEncryptedPrivateKey({
65
115
  apiUrl,
66
116
  apiToken,
117
+ aId: newAppID,
67
118
  publicKeyId,
68
119
  encryptedPrivateKey,
69
120
  });
70
- return newApp;
121
+ return Object.assign({ a_id: newAppID }, restOfNewApp);
71
122
  }
72
- exports.createAA = createAA;
@@ -19,7 +19,7 @@ export declare const decryptSharedData: ({ instanceData, maxcryptor, apiUrl, api
19
19
  * If you supply a function, it will be called instead of throwing an error,
20
20
  * and the value you return will be used instead of the corrupted field value.
21
21
  */
22
- onCorruptedData?: ((fieldName: string, fieldValue: Encrypted, error: Error) => any) | undefined;
22
+ onCorruptedData?: (fieldName: string, fieldValue: Encrypted, error: Error) => any;
23
23
  }) => Promise<{
24
24
  instance: Instance;
25
25
  applicationDecryptor: ApplicationEncryptor;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAADecryptor = exports.getAAPublicKey = void 0;
3
+ exports.getAAPublicKey = getAAPublicKey;
4
+ exports.getAADecryptor = getAADecryptor;
4
5
  const util_1 = require("../util");
5
6
  /**
6
7
  * Fetches the Public Key Information for an Access Application
@@ -15,7 +16,6 @@ async function getAAPublicKey({ apiUrl, apiToken, aId, }) {
15
16
  }
16
17
  return publicKey;
17
18
  }
18
- exports.getAAPublicKey = getAAPublicKey;
19
19
  /**
20
20
  * Fetches the Private Key Information from a Public Key
21
21
  * @returns An encrypted Private Key
@@ -45,4 +45,3 @@ async function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }) {
45
45
  publicKeyId,
46
46
  };
47
47
  }
48
- exports.getAADecryptor = getAADecryptor;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.repairDate = void 0;
3
+ exports.repairDate = repairDate;
4
4
  /** repairs broken ISO dates into valid JS date objects */
5
5
  function repairDate(date) {
6
6
  if (date instanceof Date)
@@ -15,4 +15,3 @@ function repairDate(date) {
15
15
  }
16
16
  return new Date(date);
17
17
  }
18
- exports.repairDate = repairDate;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hashPassword = void 0;
3
+ exports.hashPassword = hashPassword;
4
4
  // ⚠ updating this value will lock all existing users out of their accounts
5
5
  /** @internal */
6
6
  const SALT = "247 213 94 9 15 236 156 48 194 177 107 216 198 215 169 239";
@@ -28,4 +28,3 @@ async function hashPassword(password) {
28
28
  .join("");
29
29
  return btoa(compositeStr);
30
30
  }
31
- exports.hashPassword = hashPassword;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createHashedNId = exports.assertSafeProperty = void 0;
3
+ exports.createHashedNId = void 0;
4
+ exports.assertSafeProperty = assertSafeProperty;
4
5
  /**
5
6
  * to prevent a key from the JS object prototype (e.g. `__proto__`) from
6
7
  * returning an unexpected value (see #1162)
@@ -10,7 +11,6 @@ function assertSafeProperty(key) {
10
11
  if (key in {})
11
12
  throw new Error("Unacceptable object property");
12
13
  }
13
- exports.assertSafeProperty = assertSafeProperty;
14
14
  /**
15
15
  * the API returns hashed {@link NId}s in a separate field,
16
16
  * which breaks the whole app. So, we move the hashed ID into
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateScore = exports.evaluateRule = void 0;
3
+ exports.evaluateRule = evaluateRule;
4
+ exports.calculateScore = calculateScore;
4
5
  const evaluateScoreCondition_1 = require("./evaluateScoreCondition");
5
6
  const helpers_1 = require("./helpers");
6
7
  const general_1 = require("../general");
@@ -35,7 +36,6 @@ function evaluateRule(rule, data) {
35
36
  score: rulePassed ? rule.trueWeight : rule.falseWeight,
36
37
  };
37
38
  }
38
- exports.evaluateRule = evaluateRule;
39
39
  /**
40
40
  * We guarantee that the same configId or ruleId will always produce the same output.
41
41
  * This is the closest thing we have to versioning.
@@ -79,4 +79,3 @@ async function calculateScore(ruleConfig, ruleInput) {
79
79
  },
80
80
  };
81
81
  }
82
- exports.calculateScore = calculateScore;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.evaluateScoreCondition = void 0;
3
+ exports.evaluateScoreCondition = evaluateScoreCondition;
4
4
  const ramda_1 = require("ramda");
5
5
  const general_1 = require("../general");
6
6
  const operators_1 = require("./operators");
@@ -41,4 +41,3 @@ function evaluateScoreCondition(node, data) {
41
41
  // data value. Return true if ANY of the values return true.
42
42
  return options.some(args => op.implementation(...args));
43
43
  }
44
- exports.evaluateScoreCondition = evaluateScoreCondition;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.simplifyValueType = exports.checkTypeofValue = void 0;
3
+ exports.checkTypeofValue = checkTypeofValue;
4
+ exports.simplifyValueType = simplifyValueType;
4
5
  const types_1 = require("@raytio/types");
5
6
  const symbols_1 = require("./symbols");
6
7
  const types_2 = require("../types");
@@ -46,7 +47,6 @@ function checkTypeofValue(type, value) {
46
47
  return false;
47
48
  }
48
49
  }
49
- exports.checkTypeofValue = checkTypeofValue;
50
50
  /**
51
51
  * Some types are effectively equivilant (e.g. n_id and string).
52
52
  * Any exceptions defined here should use the same validator in
@@ -57,4 +57,3 @@ function simplifyValueType(type) {
57
57
  return "String";
58
58
  return type;
59
59
  }
60
- exports.simplifyValueType = simplifyValueType;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getValuesFromPath = void 0;
3
+ exports.getValuesFromPath = getValuesFromPath;
4
4
  const general_1 = require("../../general");
5
5
  /** this returns an array because there might be multiple of the same schema shared */
6
6
  function getValuesFromPath(path, data) {
@@ -47,4 +47,3 @@ function getValuesFromPath(path, data) {
47
47
  throw new Error(`Invalid ValuePath[0] (${type})`);
48
48
  }
49
49
  }
50
- exports.getValuesFromPath = getValuesFromPath;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getThresholdBoundary = exports.getCombinator = void 0;
3
+ exports.getCombinator = getCombinator;
4
+ exports.getThresholdBoundary = getThresholdBoundary;
4
5
  /** @ignore */
5
6
  function getCombinator(combinator) {
6
7
  switch (combinator) {
@@ -12,7 +13,6 @@ function getCombinator(combinator) {
12
13
  throw new Error("Invalid combinator");
13
14
  }
14
15
  }
15
- exports.getCombinator = getCombinator;
16
16
  /** @ignore */
17
17
  function getThresholdBoundary(combinator, rules) {
18
18
  switch (combinator) {
@@ -43,4 +43,3 @@ function getThresholdBoundary(combinator, rules) {
43
43
  throw new Error("Invalid combinator");
44
44
  }
45
45
  }
46
- exports.getThresholdBoundary = getThresholdBoundary;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expandSchema = void 0;
3
+ exports.expandSchema = expandSchema;
4
4
  const addLoadingTimes_1 = require("./addLoadingTimes");
5
5
  const maybeUseI18n_1 = require("./maybeUseI18n");
6
6
  const processSchema_1 = require("./processSchema");
@@ -16,4 +16,3 @@ function expandSchema(wrappedSchema, allUnexpandedSchemas, userLocales) {
16
16
  const schema = (0, removePrivateFields_1.removePrivateFields)((0, maybeUseI18n_1.maybeUseI18n)((0, addLoadingTimes_1.addLoadingTimes)((0, processSchema_1.processSchema)((0, unwrapSchema_1.unwrapSchema)(wrappedSchema), allUnexpandedSchemas)), userLocales));
17
17
  return Object.assign({ wasExpandedByClient: true }, schema);
18
18
  }
19
- exports.expandSchema = expandSchema;
@@ -9,17 +9,18 @@ const convertIfEnum = (0, ramda_1.mapObjIndexed)(y => Object.values(y)[0]);
9
9
  const processSchema = (schema, allUnexpandedSchemas) => {
10
10
  var _a, _b, _c, _d, _e, _f, _g;
11
11
  const expandField = (property, key) => {
12
- var _a, _b;
12
+ var _a, _b, _c;
13
13
  if (!property.allOf)
14
14
  return Object.assign(Object.assign({}, property), { $prop: key });
15
15
  // this property references another schema
16
16
  const [{ $ref }, custom] = property.allOf;
17
17
  if (!$ref)
18
18
  throw new Error("allOf missing $ref");
19
- const subSchemaName = (0, sortSchemaProperties_1.getNidFromUrn)((_a = schema.definitions) === null || _a === void 0 ? void 0 : _a[$ref.split("/")[2]].$ref);
20
- if (!subSchemaName)
21
- throw new Error("Invalid schema");
22
- const subSchema = (_b = allUnexpandedSchemas.find(s => s.schema_name === subSchemaName)) === null || _b === void 0 ? void 0 : _b.schema;
19
+ const subSchemaName = (0, sortSchemaProperties_1.getNidFromUrn)((_b = (_a = schema.definitions) === null || _a === void 0 ? void 0 : _a[$ref.split("/")[2]]) === null || _b === void 0 ? void 0 : _b.$ref);
20
+ if (!subSchemaName) {
21
+ throw new Error(`No definition for “${$ref}” in “${schema.name}”`);
22
+ }
23
+ const subSchema = (_c = allUnexpandedSchemas.find(s => s.schema_name === subSchemaName)) === null || _c === void 0 ? void 0 : _c.schema;
23
24
  if (!subSchema) {
24
25
  throw new Error(`Could not resolve subschema '${subSchemaName}'`);
25
26
  }
@@ -37,14 +38,15 @@ const processSchema = (schema, allUnexpandedSchemas) => {
37
38
  const exandedProps = (0, ramda_1.mapObjIndexed)(expandField, schema.properties);
38
39
  const allOfRequired = [];
39
40
  const globallyReferencedSubSchema = (_b = (_a = schema.allOf) === null || _a === void 0 ? void 0 : _a.reduce((ac, { $ref }) => {
40
- var _a, _b;
41
+ var _a, _b, _c;
41
42
  // TODO: should this block of code re-use `expandField`?
42
43
  if (!$ref)
43
44
  return ac; // this allOf entry is not a reference
44
- const subSchemaName = (0, sortSchemaProperties_1.getNidFromUrn)((_a = schema.definitions) === null || _a === void 0 ? void 0 : _a[$ref.split("/")[2]].$ref);
45
- if (!subSchemaName)
46
- throw new Error("Invalid schema");
47
- const subSchema = (_b = allUnexpandedSchemas.find(s => s.schema_name === subSchemaName)) === null || _b === void 0 ? void 0 : _b.schema;
45
+ const subSchemaName = (0, sortSchemaProperties_1.getNidFromUrn)((_b = (_a = schema.definitions) === null || _a === void 0 ? void 0 : _a[$ref.split("/")[2]]) === null || _b === void 0 ? void 0 : _b.$ref);
46
+ if (!subSchemaName) {
47
+ throw new Error(`No definition for “${$ref}” in “${schema.name}”`);
48
+ }
49
+ const subSchema = (_c = allUnexpandedSchemas.find(s => s.schema_name === subSchemaName)) === null || _c === void 0 ? void 0 : _c.schema;
48
50
  if (!subSchema) {
49
51
  throw new Error(`Could not resolve subschema '${subSchemaName}'`);
50
52
  }
@@ -3,20 +3,17 @@ export declare const removePrivateFields: (schema: Schema) => {
3
3
  properties: Record<string, Omit<import("@raytio/types").SchemaField, "$id" | "allOf" | "$schema" | "definitions">>;
4
4
  title: string;
5
5
  description: string;
6
- description_decorator?: "md" | undefined;
7
- schema_type?: import("@raytio/types").SchemaType | undefined;
8
- title_plural?: string | undefined;
9
- schema_group?: string | undefined;
10
- tags?: import("@raytio/types").SchemaTag[] | undefined;
6
+ description_decorator?: "md";
7
+ schema_type?: import("@raytio/types").SchemaType;
8
+ title_plural?: string;
9
+ schema_group?: string;
10
+ tags?: import("@raytio/types").SchemaTag[];
11
11
  i18n?: {
12
12
  [locale: string]: {
13
- [fieldNameOrGroupName: string]: import("@raytio/types").ServerSchemaField & {
14
- title_plural?: string | undefined;
15
- };
16
13
  $schema: {
17
14
  title: string;
18
- title_plural?: string | undefined;
19
- description?: string | undefined;
15
+ title_plural?: string;
16
+ description?: string;
20
17
  };
21
18
  $loading_extract: {
22
19
  title: string;
@@ -49,49 +46,56 @@ export declare const removePrivateFields: (schema: Schema) => {
49
46
  title: string;
50
47
  };
51
48
  $loading_long_verification_message: {
52
- title?: string | undefined;
53
- description?: string | undefined;
49
+ title?: string;
50
+ description?: string;
51
+ };
52
+ [fieldNameOrGroupName: string]: import("@raytio/types").ServerSchemaField & {
53
+ title_plural?: string;
54
54
  };
55
55
  };
56
- } | undefined;
56
+ };
57
57
  relationships?: {
58
58
  relationship_name: string;
59
59
  direction: "from";
60
60
  type: string;
61
- required_relationship?: boolean | undefined;
62
- oneOf?: (import("@raytio/types").SchemaName | "instance")[] | undefined;
63
- anyOf?: import("@raytio/types").SchemaName[] | undefined;
64
- multiple?: boolean | undefined;
61
+ required_relationship?: boolean;
62
+ oneOf?: (import("@raytio/types").SchemaName | "instance")[];
63
+ anyOf?: import("@raytio/types").SchemaName[];
64
+ multiple?: boolean;
65
65
  properties?: {
66
66
  [fieldName: string]: import("@raytio/types").SchemaField;
67
- } | undefined;
68
- required?: string[] | undefined;
69
- }[] | undefined;
67
+ };
68
+ required?: string[];
69
+ }[];
70
70
  display?: {
71
71
  head_main?: {
72
72
  fields: string[];
73
- format?: string | undefined;
74
- } | undefined;
73
+ format?: string;
74
+ };
75
75
  head_sub?: {
76
76
  fields: string[];
77
- format?: string | undefined;
78
- } | undefined;
77
+ format?: string;
78
+ };
79
79
  expand?: {
80
80
  fields: string[];
81
81
  label: string;
82
- }[] | undefined;
83
- } | undefined;
82
+ }[];
83
+ tabular?: {
84
+ fields: string[];
85
+ };
86
+ compact_table?: boolean;
87
+ };
84
88
  onboard_properties?: {
85
89
  profile_objects?: {
86
90
  schema_name: import("@raytio/types").SchemaName;
87
91
  properties: Record<string, unknown>;
88
- }[] | undefined;
92
+ }[];
89
93
  relationships?: {
90
94
  from: string;
91
95
  to: string;
92
96
  type: string;
93
- properties?: Record<string, string> | undefined;
94
- }[] | undefined;
97
+ properties?: Record<string, string>;
98
+ }[];
95
99
  organizations?: {
96
100
  properties: import("@raytio/types").Organization;
97
101
  access_applications?: {
@@ -99,23 +103,27 @@ export declare const removePrivateFields: (schema: Schema) => {
99
103
  links?: {
100
104
  description: string;
101
105
  wizardConfig: Omit<import("@raytio/types").WizardConfig, "a_id">;
102
- }[] | undefined;
103
- }[] | undefined;
104
- }[] | undefined;
105
- return_to?: string | undefined;
106
- } | undefined;
106
+ }[];
107
+ }[];
108
+ }[];
109
+ return_to?: string;
110
+ };
107
111
  name: import("@raytio/types").SchemaName;
108
- type?: import("@raytio/types").DataTypes | undefined;
109
- group_title?: string | undefined;
110
- verified_fields?: (string | import("@raytio/types").ConditionallyRequired)[] | undefined;
111
- required?: (string | import("@raytio/types").ConditionallyRequired)[] | undefined;
112
- wasExpandedByClient?: boolean | undefined;
113
- start_date?: string | undefined;
114
- end_date?: string | undefined;
115
- groupNames?: Record<string, string> | undefined;
116
- clientLocale?: string | undefined;
112
+ type?: import("@raytio/types").DataTypes;
113
+ group_title?: string;
114
+ verified_fields?: (string | import("@raytio/types").ConditionallyRequired)[];
115
+ required?: (string | import("@raytio/types").ConditionallyRequired)[];
116
+ wasExpandedByClient?: boolean;
117
+ start_date?: string;
118
+ end_date?: string;
119
+ database?: {
120
+ table: string;
121
+ primary_key: string;
122
+ };
123
+ groupNames?: Record<string, string>;
124
+ clientLocale?: string;
117
125
  version: string;
118
- timing?: Record<"extract" | "live_person" | "verify_pending_delay", number> | undefined;
119
- isProfileSchema?: boolean | undefined;
120
- isSpSchema?: boolean | undefined;
126
+ timing?: Record<"extract" | "live_person" | "verify_pending_delay", number>;
127
+ isProfileSchema?: boolean;
128
+ isSpSchema?: boolean;
121
129
  };
@@ -2,7 +2,7 @@ import type { NId, SchemaField, Urn } from "@raytio/types";
2
2
  /** two overloads - if you provide undefined, you might get undefined back */
3
3
  export declare const getNidFromUrn: {
4
4
  <IDType = NId>(urn: Urn): IDType;
5
- <IDType_1 = NId>(urn: Urn | undefined): IDType_1 | undefined;
5
+ <IDType = NId>(urn: Urn | undefined): IDType | undefined;
6
6
  };
7
7
  type Key = string;
8
8
  type Tag = string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sortSchemaProperties = exports.NO_TAG = exports.getNidFromUrn = void 0;
3
+ exports.NO_TAG = exports.getNidFromUrn = void 0;
4
+ exports.sortSchemaProperties = sortSchemaProperties;
4
5
  const ramda_1 = require("ramda");
5
6
  /** two overloads - if you provide undefined, you might get undefined back */
6
7
  exports.getNidFromUrn = ((urn) => urn === null || urn === void 0 ? void 0 : urn.split(":")[2]);
@@ -37,4 +38,3 @@ function sortSchemaProperties(properties) {
37
38
  const unsortedFinal = Object.entries(objWithSortedChildren).map(([title, items]) => ({ title, items: (0, ramda_1.uniqBy)(f => f.$prop, items) }));
38
39
  return (0, ramda_1.sortBy)(x => x.items[0].priority, unsortedFinal); // sort by priority of first child
39
40
  }
40
- exports.sortSchemaProperties = sortSchemaProperties;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unwrapSchema = void 0;
3
+ exports.unwrapSchema = unwrapSchema;
4
4
  function unwrapSchema(wrapped) {
5
5
  return Object.assign(Object.assign({}, wrapped.schema), { name: wrapped.schema_name, start_date: wrapped.start_date, end_date: wrapped.end_date, version: wrapped.schema_version, schema_type: wrapped.schema_type });
6
6
  }
7
- exports.unwrapSchema = unwrapSchema;
@@ -4,6 +4,6 @@ export type DeepPartial<T> = T | (T extends object ? {
4
4
  [K in keyof T]?: DeepPartial<T[K]>;
5
5
  } : T extends (infer U)[] ? DeepPartial<U>[] : T);
6
6
  /** tells typescript that this function is mocked */
7
- export declare const m: (func: unknown) => Mock<any, any>;
7
+ export declare const m: (func: unknown) => Mock;
8
8
  /** helper to let us define type-safe partial mocks */
9
9
  export declare const deepPartial: <T>(partial: DeepPartial<T>) => T;
@@ -1,4 +1,4 @@
1
- import type { Instance } from "@raytio/types";
1
+ import { Instance } from "@raytio/types";
2
2
  /**
3
3
  * The API response from share/v2/access_application/instance/:iId
4
4
  * returns a complicated hashed_n_id format, so you need to clean up
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPOVerification = void 0;
3
+ exports.getPOVerification = getPOVerification;
4
4
  const ramda_1 = require("ramda");
5
5
  const types_1 = require("@raytio/types");
6
6
  const crypto_1 = require("../crypto");
@@ -106,4 +106,3 @@ function getPOVerification({ PO, schema, realVers, }) {
106
106
  fieldVerifications,
107
107
  };
108
108
  }
109
- exports.getPOVerification = getPOVerification;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calcSafeHarbourScore = exports.safeHarbourRequirementsMet = exports.getFlags = exports.filterByMutualFields = void 0;
3
+ exports.calcSafeHarbourScore = void 0;
4
+ exports.filterByMutualFields = filterByMutualFields;
5
+ exports.getFlags = getFlags;
6
+ exports.safeHarbourRequirementsMet = safeHarbourRequirementsMet;
4
7
  const ramda_1 = require("ramda");
5
8
  const types_1 = require("@raytio/types");
6
9
  const getPOVerification_1 = require("./getPOVerification");
@@ -17,7 +20,6 @@ function filterByMutualFields(person, profileObjects) {
17
20
  return [];
18
21
  return profileObjects.filter(PO => personFields.every(([k, v]) => { var _a; return ((_a = PO.properties) === null || _a === void 0 ? void 0 : _a[k]) && (0, ramda_1.equals)(PO.properties[k], v); }));
19
22
  }
20
- exports.filterByMutualFields = filterByMutualFields;
21
23
  /** @internal */
22
24
  async function getFlags({ person, profileObjects, realVers, getSchema, }) {
23
25
  const POsWithSameFields = filterByMutualFields(person, profileObjects);
@@ -45,7 +47,6 @@ async function getFlags({ person, profileObjects, realVers, getSchema, }) {
45
47
  return Object.assign(Object.assign({}, ac), { [key]: [...(ac[key] || []), ver.xId] });
46
48
  }, {});
47
49
  }
48
- exports.getFlags = getFlags;
49
50
  /** @internal */
50
51
  function safeHarbourRequirementsMet(flags) {
51
52
  const { M1 = 0, M2 = 0, N1 = 0 } = (0, ramda_1.mapObjIndexed)(xIds => xIds.length, flags);
@@ -56,7 +57,6 @@ function safeHarbourRequirementsMet(flags) {
56
57
  (M2 >= 1 && N1 >= 1);
57
58
  return { isSafe, flags };
58
59
  }
59
- exports.safeHarbourRequirementsMet = safeHarbourRequirementsMet;
60
60
  /**
61
61
  * The Safe Harbour Score indidicates whether a person's identity has been verified
62
62
  * to the extent requried for Safe Harbour Compliance. This requires multiple verifications
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkOwnVerification = exports.checkJsonSignature = exports.checkSignature = void 0;
3
+ exports.checkOwnVerification = exports.checkJsonSignature = void 0;
4
+ exports.checkSignature = checkSignature;
4
5
  const util_1 = require("../../../util");
5
6
  const cache = {};
6
7
  const base64ToArrayBuffer = (str) => Uint8Array.from(atob(str), c => c.charCodeAt(0));
@@ -18,7 +19,6 @@ async function checkSignature(publicCryptoKey, signature, data) {
18
19
  const isVerified = await crypto.subtle.verify({ name: "RSA-PSS", hash: "SHA-512", saltLength: 512 / 8 }, publicCryptoKey, signatureBuf, new TextEncoder().encode(data));
19
20
  return isVerified;
20
21
  }
21
- exports.checkSignature = checkSignature;
22
22
  /**
23
23
  * checks that a json object was signed by the provided signature. Unless you're
24
24
  * dealing with bundled verifications, you should use `getOwnRealVerifications`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytio/core",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "license": "MIT",
5
5
  "main": "index",
6
6
  "types": "index",
@@ -12,13 +12,13 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "docs": "sh ../../scripts/generate-docs.sh",
15
- "build": "tsc && rimraf dist/**/__tests__",
15
+ "build": "tsc && rm -rf dist/**/__tests__",
16
16
  "test": "vitest && yarn docs"
17
17
  },
18
18
  "dependencies": {
19
19
  "@raytio/maxcryptor": "3.1.0",
20
20
  "@raytio/types": "7.3.0",
21
- "ramda": "0.29.1"
21
+ "ramda": "0.30.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/ramda": "0.29.7"