@raytio/core 11.5.0 → 11.7.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 (133) hide show
  1. package/README.md +1708 -217
  2. package/dist/accessApplication/api/legacy/convertRelationships.d.ts +3 -5
  3. package/dist/accessApplication/api/legacy/convertRelationships.js +3 -3
  4. package/dist/crypto/cognitoAttributes.d.ts +3 -0
  5. package/dist/crypto/cognitoAttributes.js +15 -4
  6. package/dist/crypto/getAADecryptor.d.ts +1 -1
  7. package/dist/crypto/getAADecryptor.js +1 -3
  8. package/dist/crypto/index.d.ts +3 -0
  9. package/dist/crypto/index.js +6 -0
  10. package/dist/crypto/kdf/argon2.d.ts +67 -0
  11. package/dist/crypto/kdf/argon2.js +99 -0
  12. package/dist/crypto/kdf/index.d.ts +43 -0
  13. package/dist/crypto/kdf/index.js +106 -0
  14. package/dist/crypto/kdf/pbkdf2.d.ts +16 -0
  15. package/dist/crypto/kdf/pbkdf2.js +45 -0
  16. package/dist/crypto/kdf/twoSecretKdf.d.ts +37 -0
  17. package/dist/crypto/kdf/twoSecretKdf.js +66 -0
  18. package/dist/crypto/kdf/types.d.ts +65 -0
  19. package/dist/crypto/kdf/types.js +50 -0
  20. package/dist/crypto/kdf/utils.d.ts +59 -0
  21. package/dist/crypto/kdf/utils.js +110 -0
  22. package/dist/crypto/localSecret/format.d.ts +48 -0
  23. package/dist/crypto/localSecret/format.js +157 -0
  24. package/dist/crypto/localSecret/generator.d.ts +23 -0
  25. package/dist/crypto/localSecret/generator.js +53 -0
  26. package/dist/crypto/localSecret/index.d.ts +12 -0
  27. package/dist/crypto/localSecret/index.js +46 -0
  28. package/dist/crypto/localSecret/storage.d.ts +53 -0
  29. package/dist/crypto/localSecret/storage.js +207 -0
  30. package/dist/crypto/localSecret/types.d.ts +68 -0
  31. package/dist/crypto/localSecret/types.js +31 -0
  32. package/dist/crypto/pgpKey/encryption.d.ts +49 -0
  33. package/dist/crypto/pgpKey/encryption.js +104 -0
  34. package/dist/crypto/pgpKey/export.d.ts +59 -0
  35. package/dist/crypto/pgpKey/export.js +322 -0
  36. package/dist/crypto/pgpKey/format.d.ts +61 -0
  37. package/dist/crypto/pgpKey/format.js +143 -0
  38. package/dist/crypto/pgpKey/generator.d.ts +20 -0
  39. package/dist/crypto/pgpKey/generator.js +76 -0
  40. package/dist/crypto/pgpKey/import.d.ts +69 -0
  41. package/dist/crypto/pgpKey/import.js +239 -0
  42. package/dist/crypto/pgpKey/index.d.ts +19 -0
  43. package/dist/crypto/pgpKey/index.js +67 -0
  44. package/dist/crypto/pgpKey/signing.d.ts +44 -0
  45. package/dist/crypto/pgpKey/signing.js +71 -0
  46. package/dist/crypto/pgpKey/storage.d.ts +43 -0
  47. package/dist/crypto/pgpKey/storage.js +141 -0
  48. package/dist/crypto/pgpKey/types.d.ts +86 -0
  49. package/dist/crypto/pgpKey/types.js +25 -0
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +1 -0
  52. package/dist/rules/calculateScore.d.ts +1 -1
  53. package/dist/rules/convertInstanceToRuleInput.js +99 -97
  54. package/dist/rules/evaluateBadge.d.ts +36 -0
  55. package/dist/rules/evaluateBadge.js +36 -0
  56. package/dist/rules/index.d.ts +1 -0
  57. package/dist/rules/index.js +1 -0
  58. package/dist/rules/types/config.d.ts +1 -1
  59. package/dist/rules/types/dataValueTypes.d.ts +4 -4
  60. package/dist/schema/expandSchema/constants.js +1 -1
  61. package/dist/schema/expandSchema/expandSchema.d.ts +3 -3
  62. package/dist/schema/expandSchema/expandSchema.js +4 -4
  63. package/dist/schema/expandSchema/i18n.d.ts +6 -1
  64. package/dist/schema/expandSchema/i18n.js +32 -4
  65. package/dist/schema/expandSchema/maybeUseI18n.d.ts +2 -2
  66. package/dist/schema/expandSchema/maybeUseI18n.js +68 -11
  67. package/dist/schema/expandSchema/processSchema.js +14 -5
  68. package/dist/schema/expandSchema/removePrivateFields.d.ts +75 -22
  69. package/dist/schema/expandSchema/sortSchemaProperties.d.ts +4 -1
  70. package/dist/schema/expandSchema/sortSchemaProperties.js +24 -1
  71. package/dist/schema/labels.js +1 -2
  72. package/dist/util/canonicalJsonify.d.ts +7 -1
  73. package/dist/util/canonicalJsonify.js +3 -2
  74. package/dist/verifications/safeHarbour.js +5 -0
  75. package/dist/verifications/verifyCheck/getOwnRealVerifications.js +2 -0
  76. package/package.json +6 -4
  77. package/dist/__tests__/docs.test.d.ts +0 -1
  78. package/dist/__tests__/docs.test.js +0 -24
  79. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.d.ts +0 -1
  80. package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.js +0 -28
  81. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.d.ts +0 -1
  82. package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.js +0 -23
  83. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.d.ts +0 -1
  84. package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.js +0 -27
  85. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.d.ts +0 -1
  86. package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.js +0 -30
  87. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.d.ts +0 -1
  88. package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.js +0 -37
  89. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts +0 -1
  90. package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +0 -27
  91. package/dist/rules/helpers/__tests__/checkTypeofValue.test.d.ts +0 -1
  92. package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +0 -49
  93. package/dist/rules/helpers/__tests__/getValuesFromPath.test.d.ts +0 -1
  94. package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +0 -67
  95. package/dist/rules/helpers/__tests__/thresholds.test.d.ts +0 -1
  96. package/dist/rules/helpers/__tests__/thresholds.test.js +0 -32
  97. package/dist/rules/operators/__tests__/bool.test.d.ts +0 -1
  98. package/dist/rules/operators/__tests__/bool.test.js +0 -21
  99. package/dist/rules/operators/__tests__/date.test.d.ts +0 -1
  100. package/dist/rules/operators/__tests__/date.test.js +0 -81
  101. package/dist/rules/operators/__tests__/hfield.test.d.ts +0 -1
  102. package/dist/rules/operators/__tests__/hfield.test.js +0 -38
  103. package/dist/rules/operators/__tests__/hschema.test.d.ts +0 -1
  104. package/dist/rules/operators/__tests__/hschema.test.js +0 -24
  105. package/dist/rules/operators/__tests__/number.test.d.ts +0 -1
  106. package/dist/rules/operators/__tests__/number.test.js +0 -53
  107. package/dist/rules/operators/__tests__/string.test.d.ts +0 -1
  108. package/dist/rules/operators/__tests__/string.test.js +0 -74
  109. package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.d.ts +0 -1
  110. package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.js +0 -24
  111. package/dist/schema/expandSchema/__tests__/expandSchema.test.d.ts +0 -1
  112. package/dist/schema/expandSchema/__tests__/expandSchema.test.js +0 -96
  113. package/dist/schema/expandSchema/__tests__/i18n.test.d.ts +0 -1
  114. package/dist/schema/expandSchema/__tests__/i18n.test.js +0 -32
  115. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.d.ts +0 -1
  116. package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +0 -98
  117. package/dist/schema/expandSchema/__tests__/processSchema.test.d.ts +0 -1
  118. package/dist/schema/expandSchema/__tests__/processSchema.test.js +0 -326
  119. package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.d.ts +0 -1
  120. package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.js +0 -182
  121. package/dist/schema/expandSchema/__tests__/util.test.d.ts +0 -1
  122. package/dist/schema/expandSchema/__tests__/util.test.js +0 -19
  123. package/dist/verifications/cleanInstance.d.ts +0 -9
  124. package/dist/verifications/cleanInstance.js +0 -15
  125. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +0 -1
  126. package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +0 -221
  127. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +0 -1
  128. package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +0 -206
  129. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +0 -1
  130. package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +0 -138
  131. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +0 -1
  132. package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +0 -49
  133. package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +0 -44
@@ -19,21 +19,78 @@ const getGroupNames = (0, ramda_1.pipe)(ramda_1.toPairs,
19
19
  (0, ramda_1.filter)(([key]) => key.startsWith("group:")),
20
20
  // @ts-expect-error
21
21
  (0, ramda_1.map)(([key, value]) => [key.replace("group:", ""), value.title]), ramda_1.fromPairs);
22
- const maybeUseI18n = (schema, userLocales) => {
23
- var _a;
24
- if (!schema.i18n)
25
- return schema;
22
+ /**
23
+ * Builds a lookup of group translations from fnd_i18n_entries for a given locale.
24
+ * Returns a map like { "address": { title: "Address", title_plural: "Addresses" } }
25
+ */
26
+ const buildFndGroupLookup = (fndEntries, userLocales) => (0, ramda_1.fromPairs)(fndEntries
27
+ .filter(entry => entry.i18n_key.startsWith("group:"))
28
+ .map(entry => {
29
+ const groupKey = entry.i18n_key.replace("group:", "");
30
+ const localeToUse = (0, i18n_1.findSuitableLocale)(Object.keys(entry.translations), userLocales);
31
+ return localeToUse && entry.translations[localeToUse]
32
+ ? [groupKey, entry.translations[localeToUse]]
33
+ : undefined;
34
+ })
35
+ .filter((pair) => pair != null));
36
+ /**
37
+ * Helper to compute the group_title based on schema_group and optional translations.
38
+ * Falls back to fnd entries, then to the group name itself if no translation is available.
39
+ */
40
+ const computeGroupTitle = (schema, translations, fndGroupLookup) => {
41
+ var _a, _b;
42
+ const firstGroup = Array.isArray(schema.schema_group)
43
+ ? schema.schema_group[0]
44
+ : schema.schema_group;
45
+ if (!firstGroup)
46
+ return undefined;
47
+ // Schema i18n takes priority over fnd entries
48
+ if ((_a = translations === null || translations === void 0 ? void 0 : translations[firstGroup]) === null || _a === void 0 ? void 0 : _a.title_plural) {
49
+ return translations[firstGroup].title_plural;
50
+ }
51
+ // Fall back to fnd entries
52
+ if ((_b = fndGroupLookup === null || fndGroupLookup === void 0 ? void 0 : fndGroupLookup[firstGroup]) === null || _b === void 0 ? void 0 : _b.title_plural) {
53
+ return fndGroupLookup[firstGroup].title_plural;
54
+ }
55
+ // Fall back to the group name itself
56
+ return firstGroup;
57
+ };
58
+ const maybeUseI18n = (schema, userLocales, fndI18nEntries) => {
59
+ const fndGroupLookup = (fndI18nEntries === null || fndI18nEntries === void 0 ? void 0 : fndI18nEntries.length)
60
+ ? buildFndGroupLookup(fndI18nEntries, userLocales)
61
+ : undefined;
62
+ // Build fnd-based groupNames as fallback
63
+ const fndGroupNames = fndGroupLookup
64
+ ? (0, ramda_1.fromPairs)(Object.entries(fndGroupLookup).map(([key, value]) => [
65
+ key,
66
+ value.title,
67
+ ]))
68
+ : {};
69
+ // Always compute group_title based on schema_group, even without i18n
70
+ const baseGroupTitle = computeGroupTitle(schema, undefined, fndGroupLookup);
71
+ if (!schema.i18n) {
72
+ // No i18n available, but still set group_title and groupNames from fnd entries
73
+ return Object.assign(Object.assign(Object.assign({}, schema), (baseGroupTitle ? { group_title: baseGroupTitle } : {})), (Object.keys(fndGroupNames).length
74
+ ? { groupNames: fndGroupNames }
75
+ : {}));
76
+ }
26
77
  // try to find an exact match in schema.i18n. The fallback: if the schema
27
78
  // only has en-nz, but the user speaks en-US, then use en-nz.
28
79
  const localeToUse = (0, i18n_1.findSuitableLocale)(Object.keys(schema.i18n), userLocales);
29
80
  // the schema has an i18n property, but it doesn't include a lang that the user speaks
30
- if (!localeToUse)
31
- return schema;
32
- const _b = schema.i18n[localeToUse], { $schema } = _b, translations = __rest(_b, ["$schema"]);
33
- return Object.assign(Object.assign(Object.assign(Object.assign({}, schema), { clientLocale: localeToUse }), $schema), { group_title: schema.schema_group &&
34
- (((_a = translations[schema.schema_group]) === null || _a === void 0 ? void 0 : _a.title_plural) || schema.schema_group),
35
- // add a `groupNames` property to the schema
36
- groupNames: getGroupNames(translations),
81
+ if (!localeToUse) {
82
+ // Still set group_title and groupNames from fnd entries
83
+ return Object.assign(Object.assign(Object.assign({}, schema), (baseGroupTitle ? { group_title: baseGroupTitle } : {})), (Object.keys(fndGroupNames).length
84
+ ? { groupNames: fndGroupNames }
85
+ : {}));
86
+ }
87
+ const _a = schema.i18n[localeToUse], { $schema } = _a, translations = __rest(_a, ["$schema"]);
88
+ // Schema i18n groupNames override fnd groupNames
89
+ const schemaGroupNames = getGroupNames(translations);
90
+ const mergedGroupNames = Object.assign(Object.assign({}, fndGroupNames), schemaGroupNames);
91
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, schema), { clientLocale: localeToUse }), $schema), { group_title: computeGroupTitle(schema, translations, fndGroupLookup),
92
+ // merged groupNames: fnd entries as fallback, schema i18n overrides
93
+ groupNames: mergedGroupNames,
37
94
  // maybe apply translations per field
38
95
  properties: (0, ramda_1.mapObjIndexed)((field, fieldName) => (Object.assign(Object.assign({}, field), translations[fieldName])), schema.properties) });
39
96
  };
@@ -7,7 +7,7 @@ const sortSchemaProperties_1 = require("./sortSchemaProperties");
7
7
  const util_1 = require("./util");
8
8
  const convertIfEnum = (0, ramda_1.mapObjIndexed)(y => Object.values(y)[0]);
9
9
  const processSchema = (schema, allUnexpandedSchemas) => {
10
- var _a, _b, _c, _d, _e, _f, _g;
10
+ var _a, _b, _c, _d, _e, _f, _g, _h;
11
11
  const expandField = (property, key) => {
12
12
  var _a, _b, _c;
13
13
  if (!property.allOf)
@@ -27,10 +27,12 @@ const processSchema = (schema, allUnexpandedSchemas) => {
27
27
  return (0, ramda_1.pipe)((0, ramda_1.dissoc)("properties"), // subSchema don't have properties so remove
28
28
  (0, ramda_1.mergeWith)((main, sub) => {
29
29
  // merge custom props in; concatting arrays, but picking
30
- // the main value only for strings.
30
+ // the main (custom) value for everything else.
31
31
  if (typeof main === "string")
32
32
  return main;
33
- return [...main, ...sub];
33
+ if (Array.isArray(main) && Array.isArray(sub))
34
+ return [...main, ...sub];
35
+ return main;
34
36
  }, custom), (f) => (Object.assign(Object.assign({}, f), { $ref: subSchemaName })), // add $ref to the subSchema
35
37
  // add $ref to the subSchema
36
38
  field => (Object.assign(Object.assign({}, field), { $prop: key })))(subSchema);
@@ -82,7 +84,14 @@ const processSchema = (schema, allUnexpandedSchemas) => {
82
84
  ...conditionallyVerifiable,
83
85
  ]);
84
86
  const shouldBeConditionallyVerified = (_f = schema.allOf) === null || _f === void 0 ? void 0 : _f.some(x => { var _a, _b; return (_b = (_a = x.then) === null || _a === void 0 ? void 0 : _a.tags) === null || _b === void 0 ? void 0 : _b.includes("action:verify"); });
85
- return Object.assign(Object.assign({}, schema), { properties: Object.assign(Object.assign(Object.assign({}, exandedProps), globallyReferencedSubSchema), conditionalProperties), required: (0, ramda_1.uniq)([
87
+ // IF properties THEN tags (schema-level conditional tags)
88
+ const conditionalTags = ((_g = schema.allOf) === null || _g === void 0 ? void 0 : _g.filter(x => { var _a, _b; return ((_a = x.if) === null || _a === void 0 ? void 0 : _a.properties) && ((_b = x.then) === null || _b === void 0 ? void 0 : _b.tags); }).map(x => ({
89
+ tags: x.then.tags,
90
+ if: convertIfEnum(x.if.properties),
91
+ }))) || [];
92
+ return Object.assign(Object.assign({}, schema), {
93
+ // Schema-level conditional tags for runtime evaluation
94
+ conditionalTags: conditionalTags.length ? conditionalTags : undefined, properties: Object.assign(Object.assign(Object.assign({}, exandedProps), globallyReferencedSubSchema), conditionalProperties), required: (0, ramda_1.uniq)([
86
95
  ...(schema.required || []),
87
96
  ...allOfRequired,
88
97
  ...conditionallyRequired,
@@ -91,6 +100,6 @@ const processSchema = (schema, allUnexpandedSchemas) => {
91
100
  verified_fields: verifiedFields.length ? verifiedFields : undefined, tags: (0, ramda_1.uniq)([
92
101
  ...(schema.tags || []),
93
102
  ...(shouldBeConditionallyVerified ? ["action:verify"] : []),
94
- ]), isProfileSchema: !constants_1.TAG_DENYLIST.some(tag => { var _a; return (_a = schema.tags) === null || _a === void 0 ? void 0 : _a.includes(tag); }) && !!schema.title, isSpSchema: ((_g = schema.tags) === null || _g === void 0 ? void 0 : _g.includes("type:service_provider")) || false });
103
+ ]), isProfileSchema: !constants_1.TAG_DENYLIST.some(tag => { var _a; return (_a = schema.tags) === null || _a === void 0 ? void 0 : _a.includes(tag); }) && !!schema.title, isSpSchema: ((_h = schema.tags) === null || _h === void 0 ? void 0 : _h.includes("type:merchant")) || false });
95
104
  };
96
105
  exports.processSchema = processSchema;
@@ -6,8 +6,11 @@ export declare const removePrivateFields: (schema: Schema) => {
6
6
  description_decorator?: "md";
7
7
  schema_type?: import("@raytio/types").SchemaType;
8
8
  title_plural?: string;
9
- schema_group?: string;
9
+ schema_group?: string | string[];
10
+ search_terms?: string[];
10
11
  tags?: import("@raytio/types").SchemaTag[];
12
+ suggest_post_create?: import("@raytio/types").SchemaName;
13
+ schema_country_codes?: string[];
11
14
  i18n?: {
12
15
  [locale: string]: {
13
16
  $schema: {
@@ -84,32 +87,74 @@ export declare const removePrivateFields: (schema: Schema) => {
84
87
  fields: string[];
85
88
  };
86
89
  compact_table?: boolean;
87
- };
88
- onboard_properties?: {
89
- profile_objects?: {
90
- schema_name: import("@raytio/types").SchemaName;
91
- properties: Record<string, unknown>;
92
- }[];
93
- relationships?: {
94
- from: string;
95
- to: string;
96
- type: string;
97
- properties?: Record<string, string>;
98
- }[];
99
- organizations?: {
100
- properties: import("@raytio/types").Organization;
101
- access_applications?: {
102
- properties: Omit<import("@raytio/types").AA, "org_id">;
103
- links?: {
104
- description: string;
105
- wizardConfig: Omit<import("@raytio/types").WizardConfig, "a_id">;
106
- }[];
90
+ filters?: {
91
+ name: string;
92
+ operation: "and" | "or";
93
+ tokens: {
94
+ propertyKey: string;
95
+ operator: string;
96
+ value: string;
107
97
  }[];
108
98
  }[];
99
+ kanban?: {
100
+ column_field?: string;
101
+ title_field?: string;
102
+ card_fields?: string[];
103
+ };
104
+ };
105
+ onboard_properties?: {
106
+ actions?: {
107
+ create_organization?: Array<{
108
+ properties: import("@raytio/types").Json;
109
+ store_as?: string;
110
+ }>;
111
+ create_access_application_link?: Array<{
112
+ properties: Record<string, unknown>;
113
+ store_as?: string;
114
+ }>;
115
+ [key: string]: any;
116
+ };
117
+ execution_order?: string[];
118
+ db?: {
119
+ v1?: {
120
+ dsm_nodes?: Array<{
121
+ labels?: string[];
122
+ properties: Record<string, unknown>;
123
+ schema_name?: import("@raytio/types").SchemaName;
124
+ }>;
125
+ xrm_merchants?: Array<Record<string, unknown>>;
126
+ dsm_access_applications?: Array<Omit<import("@raytio/types").AA, "org_id" | "a_id"> & {
127
+ org_id?: string;
128
+ links?: {
129
+ description: string;
130
+ wizardConfig: Omit<import("@raytio/types").WizardConfig, "a_id">;
131
+ }[];
132
+ }>;
133
+ dsm_node_relationships?: Array<{
134
+ from: string;
135
+ to: string;
136
+ type: string;
137
+ properties?: Record<string, unknown>;
138
+ }>;
139
+ [endpoint: string]: Array<Record<string, unknown>> | undefined;
140
+ };
141
+ v2?: {
142
+ [endpoint: string]: Array<Record<string, unknown>> | undefined;
143
+ };
144
+ [version: string]: {
145
+ [endpoint: string]: Array<Record<string, unknown>> | undefined;
146
+ } | undefined;
147
+ };
148
+ [namespace: string]: {
149
+ [version: string]: {
150
+ [endpoint: string]: Array<Record<string, unknown>> | undefined;
151
+ } | undefined;
152
+ } | object | string[] | string | undefined;
109
153
  return_to?: string;
110
154
  };
111
155
  name: import("@raytio/types").SchemaName;
112
156
  type?: import("@raytio/types").DataTypes;
157
+ conditionalTags?: import("@raytio/types").ConditionalTags[];
113
158
  group_title?: string;
114
159
  verified_fields?: (string | import("@raytio/types").ConditionallyRequired)[];
115
160
  required?: (string | import("@raytio/types").ConditionallyRequired)[];
@@ -117,10 +162,18 @@ export declare const removePrivateFields: (schema: Schema) => {
117
162
  start_date?: string;
118
163
  end_date?: string;
119
164
  database?: {
120
- table: string;
165
+ table?: string;
121
166
  primary_key: string;
167
+ path?: string;
168
+ select?: string;
169
+ return_to?: import("@raytio/types").SchemaName;
170
+ method?: "POST" | "PATCH" | "DELETE";
171
+ query_parameters?: string;
122
172
  };
123
173
  groupNames?: Record<string, string>;
174
+ groups?: {
175
+ order?: string[];
176
+ };
124
177
  clientLocale?: string;
125
178
  version: string;
126
179
  timing?: Record<"extract" | "live_person" | "verify_pending_delay", number>;
@@ -16,6 +16,9 @@ export declare const NO_TAG = "-notag-common";
16
16
  * Schema properties are an object, so they need to be converted into an
17
17
  * array, grouped by the group tag, and then sorted based on the `priority`
18
18
  * attribute within their group.
19
+ *
20
+ * @param properties - The schema properties to sort
21
+ * @param groupOrder - Optional array specifying the order of groups. Groups not in this array will appear after ordered groups.
19
22
  */
20
- export declare function sortSchemaProperties(properties: Record<Key, SchemaField>): Section[];
23
+ export declare function sortSchemaProperties(properties: Record<Key, SchemaField>, groupOrder?: string[]): Section[];
21
24
  export {};
@@ -11,8 +11,11 @@ exports.NO_TAG = "-notag-common";
11
11
  * Schema properties are an object, so they need to be converted into an
12
12
  * array, grouped by the group tag, and then sorted based on the `priority`
13
13
  * attribute within their group.
14
+ *
15
+ * @param properties - The schema properties to sort
16
+ * @param groupOrder - Optional array specifying the order of groups. Groups not in this array will appear after ordered groups.
14
17
  */
15
- function sortSchemaProperties(properties) {
18
+ function sortSchemaProperties(properties, groupOrder) {
16
19
  const tagToSection = (field) => {
17
20
  var _a;
18
21
  // if there is a tag prefixed with `group:`, then use it
@@ -36,5 +39,25 @@ function sortSchemaProperties(properties) {
36
39
  const objWithSortedChildren = (0, ramda_1.mapObjIndexed)(fieldObjList => (0, ramda_1.sort)((a, b) => { var _a, _b; return ((_a = a.priority) !== null && _a !== void 0 ? _a : 0) - ((_b = b.priority) !== null && _b !== void 0 ? _b : 0); }, fieldObjList), unsorted);
37
40
  // defined seperately because typescript gets confused
38
41
  const unsortedFinal = Object.entries(objWithSortedChildren).map(([title, items]) => ({ title, items: (0, ramda_1.uniqBy)(f => f.$prop, items) }));
42
+ // If groupOrder is provided, sort groups according to it
43
+ if (groupOrder && groupOrder.length > 0) {
44
+ // Separate groups into ordered and unordered
45
+ const { orderedGroups, unorderedGroups } = unsortedFinal.reduce((acc, section) => {
46
+ if (groupOrder.includes(section.title)) {
47
+ return Object.assign(Object.assign({}, acc), { orderedGroups: [...acc.orderedGroups, section] });
48
+ }
49
+ return Object.assign(Object.assign({}, acc), { unorderedGroups: [...acc.unorderedGroups, section] });
50
+ }, { orderedGroups: [], unorderedGroups: [] });
51
+ // Sort ordered groups according to groupOrder array
52
+ const sortedOrderedGroups = (0, ramda_1.sort)((a, b) => {
53
+ const indexA = groupOrder.indexOf(a.title);
54
+ const indexB = groupOrder.indexOf(b.title);
55
+ return indexA - indexB;
56
+ }, orderedGroups);
57
+ // Sort unordered groups by priority of first child
58
+ const sortedUnorderedGroups = (0, ramda_1.sortBy)(x => x.items[0].priority, unorderedGroups);
59
+ // Return ordered groups first, then unordered groups
60
+ return [...sortedOrderedGroups, ...sortedUnorderedGroups];
61
+ }
39
62
  return (0, ramda_1.sortBy)(x => x.items[0].priority, unsortedFinal); // sort by priority of first child
40
63
  }
@@ -15,6 +15,5 @@ const LABELS_DENYLIST = [
15
15
  "receiverCreated",
16
16
  ];
17
17
  /** Finds the label (on a profile object) which is the schema name */
18
- const findSchemaLabel = (labels) => labels === null || labels === void 0 ? void 0 : labels.find(label => !LABELS_DENYLIST.includes(label) &&
19
- !label.startsWith("related_service_provider:"));
18
+ const findSchemaLabel = (labels) => labels === null || labels === void 0 ? void 0 : labels.find(label => !LABELS_DENYLIST.includes(label));
20
19
  exports.findSchemaLabel = findSchemaLabel;
@@ -1 +1,7 @@
1
- export {};
1
+ /**
2
+ * Creates a canonical JSON string representation of an object.
3
+ *
4
+ * Spec compliant, and matches
5
+ * https://gitlab.com/raytio/mono/-/blob/devo/common/signing/signing/canonical_json.py
6
+ */
7
+ export declare const canonicalJsonify: (object: unknown) => string;
@@ -42,8 +42,9 @@ function copyObjectWithSortedKeys(object) {
42
42
  return object; // bool or int
43
43
  }
44
44
  /**
45
- * @internal
46
- * spec compliant, and matches
45
+ * Creates a canonical JSON string representation of an object.
46
+ *
47
+ * Spec compliant, and matches
47
48
  * https://gitlab.com/raytio/mono/-/blob/devo/common/signing/signing/canonical_json.py
48
49
  */
49
50
  const canonicalJsonify = (object) => `${copyObjectWithSortedKeys(object)}`;
@@ -25,13 +25,18 @@ async function getFlags({ person, profileObjects, realVers, getSchema, }) {
25
25
  const POsWithSameFields = filterByMutualFields(person, profileObjects);
26
26
  const relevantVers = (await Promise.all(POsWithSameFields.map(async (PO) => {
27
27
  const schemaName = (0, schema_1.findSchemaLabel)(PO.labels);
28
+ if (!schemaName)
29
+ return undefined;
28
30
  const schema = await getSchema(schemaName);
31
+ if (!schema)
32
+ return undefined;
29
33
  return Object.assign({ nId: PO.n_id }, (0, getPOVerification_1.getPOVerification)({
30
34
  schema,
31
35
  PO,
32
36
  realVers,
33
37
  }));
34
38
  })))
39
+ .filter((v) => v != null)
35
40
  .filter(v => v.status === types_1.POVerification.FullyVerified)
36
41
  .flatMap(v => v.details.verifiers.map(verProvider => realVers.find(ver => ver.belongsToNId === v.nId &&
37
42
  ver.provider.dataSourceNId === verProvider.dataSourceNId)))
@@ -17,6 +17,8 @@ const getOwnRealVerifications = async ({ verifications, profileObjects, userId,
17
17
  // because attempting hundreds of webcrypto operations simultaneously will
18
18
  // probably upset some heritage web browser.
19
19
  for (const ver of verifications) {
20
+ if (!ver.properties.verifications)
21
+ continue;
20
22
  for (const verPO of ver.properties.verifications) {
21
23
  const { data, signature } = verPO;
22
24
  const sourcePO = profileObjects.find(PO => PO.n_id === data.source_n_id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytio/core",
3
- "version": "11.5.0",
3
+ "version": "11.7.0",
4
4
  "license": "MIT",
5
5
  "main": "index",
6
6
  "types": "index",
@@ -12,12 +12,14 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "docs": "sh ../../scripts/generate-docs.sh",
15
- "build": "tsc && rm -rf dist/**/__tests__",
16
- "test": "vitest && yarn docs"
15
+ "build": "yarn run -T tsc && rm -rf dist/**/__tests__",
16
+ "test": "yarn run -T vitest && yarn docs",
17
+ "test-ci": "yarn run -T vitest run && yarn docs"
17
18
  },
18
19
  "dependencies": {
19
20
  "@raytio/maxcryptor": "3.1.0",
20
- "@raytio/types": "8.0.0",
21
+ "@raytio/types": "8.2.0",
22
+ "openpgp": "^6.1.0",
21
23
  "ramda": "0.30.1"
22
24
  },
23
25
  "devDependencies": {
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable no-console */
4
- const child_process_1 = require("child_process");
5
- const fs_1 = require("fs");
6
- const util_1 = require("util");
7
- const execAsync = (0, util_1.promisify)(child_process_1.exec);
8
- describe("docs", () => {
9
- it("generates a nice README for @raytio/core & @raytio/types", async () => {
10
- console.log("(1/4) Running `yarn docs` for core...");
11
- console.log(Object.values(await execAsync("yarn docs")).join("\n"));
12
- console.log("(2/4) Reading README.md for core...");
13
- const readmeCore = await fs_1.promises.readFile("README.md", { encoding: "utf-8" });
14
- expect(readmeCore).toMatchSnapshot();
15
- // types & core are in the same test to avoid jest parallelizing them
16
- console.log("(3/4) Running `yarn docs` for types...");
17
- console.log(Object.values(await execAsync("cd ../types && yarn docs")).join("\n"));
18
- console.log("(4/4) Reading README.md for types...");
19
- const readmeTypes = await fs_1.promises.readFile("../types/README.md", {
20
- encoding: "utf-8",
21
- });
22
- expect(readmeTypes).toMatchSnapshot();
23
- }, 30000);
24
- });
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fetchKeysForSubmission_1 = require("../fetchKeysForSubmission");
4
- vi.spyOn(global, "fetch").mockResolvedValueOnce({
5
- json: async () => [
6
- { aain_id: "n1", field_name: "f1", key_data: 1 },
7
- { aain_id: "n1", field_name: "f2", key_data: 1 },
8
- { aain_id: "n2", field_name: "f2", key_data: 3 },
9
- { aain_id: "n3", field_name: "f1", key_data: 4 },
10
- { aain_id: "n3", field_name: "f2", key_data: 5 },
11
- { aain_id: "n3", field_name: "f3", key_data: 6 },
12
- ],
13
- });
14
- describe("fetchKeysForSubmission", () => {
15
- it("converts the hashed_n_id format into n_id", async () => {
16
- expect(await (0, fetchKeysForSubmission_1.fetchKeysForSubmission)({
17
- iId: "i1",
18
- apiToken: "apiToken",
19
- apiUrl: "apiUrl",
20
- })).toStrictEqual({
21
- n1: { f1: 1, f2: 1 },
22
- n2: { f2: 3 },
23
- n3: { f1: 4, f2: 5, f3: 6 },
24
- });
25
- expect(fetch).toHaveBeenCalledTimes(1);
26
- expect(fetch).toHaveBeenNthCalledWith(1, "apiUrl/db/v1/dsm_access_application_instance_node_keys?aai_id=eq.i1", { headers: { Authorization: "Bearer apiToken" } });
27
- });
28
- });
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fetchPOsOrAOsForSubmission_1 = require("../fetchPOsOrAOsForSubmission");
4
- vi.spyOn(global, "fetch").mockResolvedValueOnce({
5
- json: async () => [
6
- { n_id: "n1", properties: { a: 1 }, aa_id: "a1", aai_id: "i1" },
7
- { hashed_n_id: "n2", properties: { b: 2 }, aa_id: "a2", aai_id: "i2" },
8
- ],
9
- });
10
- describe("fetchPOsOrAOsForSubmission", () => {
11
- it("converts the hashed_n_id format into n_id", async () => {
12
- expect(await (0, fetchPOsOrAOsForSubmission_1.fetchPOsOrAOsForSubmission)({ iId: "i1", apiToken: "apiToken", apiUrl: "apiUrl" }, "AOs")).toStrictEqual([
13
- { n_id: "n1", properties: { a: 1 }, isFromSubmission: ["a1", "i1"] },
14
- {
15
- n_id: "HASHED::n2::a2",
16
- properties: { b: 2 },
17
- isFromSubmission: ["a2", "i2"],
18
- },
19
- ]);
20
- expect(fetch).toHaveBeenCalledTimes(1);
21
- expect(fetch).toHaveBeenNthCalledWith(1, "apiUrl/db/v1/dsm_access_application_instance_application_objects?aai_id=eq.i1", { headers: { Authorization: "Bearer apiToken" } });
22
- });
23
- });
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fetchRelationshipsForSubmission_1 = require("../fetchRelationshipsForSubmission");
4
- vi.spyOn(global, "fetch").mockResolvedValueOnce({
5
- json: async () => [
6
- { id: "p1", from_id: "n1", to_id: "n2" },
7
- { id: "p1", from_id: "n1", to_i_id: "n2" },
8
- ],
9
- });
10
- describe("fetchRelationshipsForSubmission", () => {
11
- it("converts the hashed_n_id format into n_id", async () => {
12
- expect(await (0, fetchRelationshipsForSubmission_1.fetchRelationshipsForSubmission)({
13
- iId: "i1",
14
- apiToken: "apiToken",
15
- apiUrl: "apiUrl",
16
- })).toStrictEqual([
17
- {
18
- p_id: "p1",
19
- start: "urn:profile_object:n1",
20
- end: "urn:profile_object:n2",
21
- },
22
- { p_id: "p1", start: "urn:profile_object:n1", end: "urn:instance:n2" },
23
- ]);
24
- expect(fetch).toHaveBeenCalledTimes(1);
25
- expect(fetch).toHaveBeenNthCalledWith(1, "apiUrl/db/v1/dsm_access_application_instance_node_relationships?aai_id=eq.i1", { headers: { Authorization: "Bearer apiToken" } });
26
- });
27
- });
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getMissingDataForInstance_1 = require("../getMissingDataForInstance");
4
- vi.mock("../fetchKeysForSubmission", () => ({
5
- fetchKeysForSubmission: async () => [3, 4],
6
- }));
7
- vi.mock("../fetchPOsOrAOsForSubmission", () => ({
8
- fetchPOsOrAOsForSubmission: async () => [1, 2],
9
- }));
10
- vi.mock("../fetchRelationshipsForSubmission", () => ({
11
- fetchRelationshipsForSubmission: async () => [5, 6],
12
- }));
13
- describe("getMissingDataForInstance", () => {
14
- it("converts the hashed_n_id format into n_id", async () => {
15
- expect(await (0, getMissingDataForInstance_1.getMissingDataForInstance)({
16
- instanceWithoutData: {
17
- id: "i1",
18
- confirmation_code: "ABC123",
19
- },
20
- apiToken: "apiToken",
21
- apiUrl: "apiUrl",
22
- })).toStrictEqual({
23
- confirmation_code: "ABC123",
24
- id: "i1",
25
- keys: [3, 4],
26
- profile_objects: [1, 2, 1, 2],
27
- relationships: [5, 6],
28
- });
29
- });
30
- });
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ramda_1 = require("ramda");
4
- const convertRelationships_1 = require("../convertRelationships");
5
- const relationship = {
6
- p_id: "PId",
7
- start_date: "",
8
- end_date: "",
9
- start: "urn:profile_object:1",
10
- end: "urn:profile_object:2",
11
- type: "IS_RELATED_TO",
12
- active: true,
13
- properties: undefined,
14
- };
15
- const serverRelationship = {
16
- id: "PId",
17
- start_date: "",
18
- end_date: "",
19
- active: true,
20
- from_id: `1`,
21
- to_id: `2`,
22
- to_i_id: null,
23
- type: "IS_RELATED_TO",
24
- properties: undefined,
25
- };
26
- describe("convertServerRelationship", () => {
27
- it("Converts fields in PO relationship", () => {
28
- expect((0, convertRelationships_1.convertServerRelationship)(serverRelationship)).toStrictEqual(relationship);
29
- });
30
- it("Converts fields in instance/crust relationship", () => {
31
- // Same Ids with Instance and PO to_ids swapped
32
- const instanceServerRelationship = Object.assign(Object.assign({}, (0, ramda_1.omit)(["to_id", "to_i_id"], serverRelationship)), { to_i_id: "2" });
33
- // Replacing Urn prepend text
34
- const instanceRelationship = Object.assign(Object.assign({}, (0, ramda_1.omit)(["end"], relationship)), { end: "urn:instance:2" });
35
- expect((0, convertRelationships_1.convertServerRelationship)(instanceServerRelationship)).toStrictEqual(instanceRelationship);
36
- });
37
- });
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const addInfiniteThresholdBoundaries_1 = require("../addInfiniteThresholdBoundaries");
4
- describe("addInfiniteThresholdBoundaries", () => {
5
- it("correctly re-adds Infinity to the first and last boundary", () => {
6
- expect((0, addInfiniteThresholdBoundaries_1.addInfiniteThresholdBoundaries)([
7
- { colour: "", from: null, to: 1, name: "❤️" },
8
- { colour: "", from: 2, to: 50, name: "💛" },
9
- { colour: "", from: 51, to: null, name: "💚" },
10
- ])).toStrictEqual([
11
- { colour: "", from: -Infinity, to: 1, name: "❤️" },
12
- { colour: "", from: 2, to: 50, name: "💛" },
13
- { colour: "", from: 51, to: Infinity, name: "💚" },
14
- ]);
15
- expect((0, addInfiniteThresholdBoundaries_1.addInfiniteThresholdBoundaries)([])).toStrictEqual([]);
16
- expect((0, addInfiniteThresholdBoundaries_1.addInfiniteThresholdBoundaries)([
17
- { colour: "", from: 1, to: 10, name: "my useless single category" },
18
- ])).toStrictEqual([
19
- {
20
- colour: "",
21
- from: -Infinity,
22
- to: Infinity,
23
- name: "my useless single category",
24
- },
25
- ]);
26
- });
27
- });