@raytio/core 11.2.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.
- package/CHANGELOG.md +4 -0
- package/README.md +126 -30
- package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.d.ts +1 -0
- package/dist/accessApplication/api/__tests__/fetchKeysForSubmission.test.js +28 -0
- package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.d.ts +1 -0
- package/dist/accessApplication/api/__tests__/fetchPOsOrAOsForSubmission.test.js +23 -0
- package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.d.ts +1 -0
- package/dist/accessApplication/api/__tests__/fetchRelationshipsForSubmission.test.js +27 -0
- package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.d.ts +1 -0
- package/dist/accessApplication/api/__tests__/getMissingDataForInstance.test.js +30 -0
- package/dist/accessApplication/api/fetchKeysForSubmission.d.ts +12 -0
- package/dist/accessApplication/api/fetchKeysForSubmission.js +15 -0
- package/dist/accessApplication/api/fetchPOsOrAOsForSubmission.d.ts +6 -0
- package/dist/accessApplication/api/fetchPOsOrAOsForSubmission.js +24 -0
- package/dist/accessApplication/api/fetchRelationshipsForSubmission.d.ts +6 -0
- package/dist/accessApplication/api/fetchRelationshipsForSubmission.js +9 -0
- package/dist/accessApplication/api/getMissingDataForInstance.d.ts +10 -0
- package/dist/accessApplication/api/getMissingDataForInstance.js +28 -0
- package/dist/accessApplication/api/index.d.ts +2 -0
- package/dist/accessApplication/api/index.js +18 -0
- package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.d.ts +1 -0
- package/dist/accessApplication/api/legacy/__tests__/convertRelationships.test.js +37 -0
- package/dist/accessApplication/api/legacy/convertRelationships.d.ts +16 -0
- package/dist/accessApplication/api/legacy/convertRelationships.js +20 -0
- package/dist/accessApplication/api/legacy/index.d.ts +1 -0
- package/dist/accessApplication/api/legacy/index.js +17 -0
- package/dist/accessApplication/createAA.d.ts +4 -1
- package/dist/accessApplication/createAA.js +70 -19
- package/dist/accessApplication/index.d.ts +1 -0
- package/dist/accessApplication/index.js +1 -0
- package/dist/crypto/cognitoAttributes.d.ts +1 -1
- package/dist/crypto/decryptSharedData.d.ts +3 -3
- package/dist/crypto/decryptSharedData.js +2 -5
- package/dist/crypto/getAADecryptor.d.ts +18 -3
- package/dist/crypto/getAADecryptor.js +10 -11
- package/dist/crypto/helpers.d.ts +2 -2
- package/dist/general/date.js +1 -2
- package/dist/general/password.js +1 -2
- package/dist/general/types.d.ts +9 -0
- package/dist/general/types.js +11 -2
- package/dist/rules/calculateScore.d.ts +1 -1
- package/dist/rules/calculateScore.js +2 -3
- package/dist/rules/convertInstanceToRuleInput.d.ts +3 -3
- package/dist/rules/convertInstanceToRuleInput.js +5 -2
- package/dist/rules/evaluateScoreCondition.d.ts +1 -1
- package/dist/rules/evaluateScoreCondition.js +1 -2
- package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +1 -1
- package/dist/rules/helpers/addInfiniteThresholdBoundaries.d.ts +1 -1
- package/dist/rules/helpers/checkTypeofValue.d.ts +1 -1
- package/dist/rules/helpers/checkTypeofValue.js +2 -3
- package/dist/rules/helpers/getValuesFromPath.d.ts +1 -1
- package/dist/rules/helpers/getValuesFromPath.js +1 -2
- package/dist/rules/helpers/thresholds.d.ts +1 -1
- package/dist/rules/helpers/thresholds.js +2 -3
- package/dist/rules/operators/bool.d.ts +1 -1
- package/dist/rules/operators/date.d.ts +1 -1
- package/dist/rules/operators/hfield.d.ts +1 -1
- package/dist/rules/operators/hschema.d.ts +1 -1
- package/dist/rules/operators/index.d.ts +1 -1
- package/dist/rules/operators/number.d.ts +1 -1
- package/dist/rules/operators/string.d.ts +1 -1
- package/dist/rules/types/config.d.ts +4 -3
- package/dist/rules/types/dataValueTypes.d.ts +2 -3
- package/dist/rules/types/internal.d.ts +4 -3
- package/dist/rules/validate.d.ts +2 -2
- package/dist/schema/expandSchema/__tests__/expandSchema.test.js +2 -2
- package/dist/schema/expandSchema/__tests__/i18n.test.js +1 -1
- package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +2 -2
- package/dist/schema/expandSchema/__tests__/processSchema.test.js +2 -2
- package/dist/schema/expandSchema/addLoadingTimes.d.ts +1 -1
- package/dist/schema/expandSchema/constants.d.ts +1 -1
- package/dist/schema/expandSchema/expandSchema.d.ts +1 -1
- package/dist/schema/expandSchema/expandSchema.js +1 -2
- package/dist/schema/expandSchema/maybeUseI18n.d.ts +1 -1
- package/dist/schema/expandSchema/processSchema.d.ts +1 -1
- package/dist/schema/expandSchema/processSchema.js +12 -10
- package/dist/schema/expandSchema/removePrivateFields.d.ts +57 -49
- package/dist/schema/expandSchema/sortSchemaProperties.d.ts +3 -3
- package/dist/schema/expandSchema/sortSchemaProperties.js +2 -2
- package/dist/schema/expandSchema/unwrapSchema.d.ts +2 -6
- package/dist/schema/expandSchema/unwrapSchema.js +1 -2
- package/dist/schema/labels.d.ts +2 -1
- package/dist/testHelpers.d.ts +2 -2
- package/dist/verifications/getPOVerification.d.ts +1 -1
- package/dist/verifications/getPOVerification.js +1 -2
- package/dist/verifications/index.d.ts +0 -1
- package/dist/verifications/index.js +0 -1
- package/dist/verifications/safeHarbour.d.ts +2 -2
- package/dist/verifications/safeHarbour.js +4 -4
- package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +3 -3
- package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +2 -2
- package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +1 -1
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +1 -1
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +1 -1
- package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +1 -1
- package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +2 -2
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +1 -1
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +4 -2
- package/package.json +6 -42
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { SchemaName } from "@raytio/types";
|
|
2
|
+
import type { GetTSType, HField, HSchema } from "./dataValueTypes";
|
|
3
|
+
import type { FieldValueTypes, ValueType } from "./config";
|
|
3
4
|
export type RuleDataProperty<T extends FieldValueTypes> = {
|
|
4
5
|
type: T;
|
|
5
6
|
value: GetTSType<T>;
|
|
6
7
|
hField: HField;
|
|
7
8
|
};
|
|
8
9
|
export type RuleData = {
|
|
9
|
-
[schemaName:
|
|
10
|
+
[schemaName: SchemaName]: {
|
|
10
11
|
hSchema: HSchema;
|
|
11
12
|
properties: {
|
|
12
13
|
[fieldName: string]: RuleDataProperty<FieldValueTypes>;
|
package/dist/rules/validate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ScoreResult } from "./calculateScore";
|
|
2
|
-
import { ScoreConfig } from "./types";
|
|
1
|
+
import type { ScoreResult } from "./calculateScore";
|
|
2
|
+
import type { ScoreConfig } from "./types";
|
|
3
3
|
/** determines whether a `ScoreResult` object is valid */
|
|
4
4
|
export declare const isScoreResultValid: (x: unknown) => x is ScoreResult;
|
|
5
5
|
/** determines whether a `ScoreConfig` object is valid */
|
|
@@ -62,14 +62,14 @@ describe("expandSchema", () => {
|
|
|
62
62
|
end_date: "2222-12-31T23:59:59+00:00",
|
|
63
63
|
version: "0.0.7",
|
|
64
64
|
schema_type: "ps",
|
|
65
|
-
i18n: fromAPI[0].schema.i18n,
|
|
65
|
+
i18n: fromAPI[0].schema.i18n, // unchanged
|
|
66
66
|
isProfileSchema: true,
|
|
67
67
|
isSpSchema: false,
|
|
68
68
|
properties: {
|
|
69
69
|
manufacture_year: {
|
|
70
70
|
// $id was removed
|
|
71
71
|
$prop: "manufacture_year",
|
|
72
|
-
$ref: "ss_birth_year_integer",
|
|
72
|
+
$ref: "ss_birth_year_integer", // it added a $ref tag
|
|
73
73
|
maximum: 2022,
|
|
74
74
|
minimum: 1900,
|
|
75
75
|
title: "Year of birth",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const i18n_1 = require("../i18n");
|
|
4
|
-
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in
|
|
4
|
+
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in vi.setup.ts
|
|
5
5
|
describe("getAllLocales", () => {
|
|
6
6
|
it("correctly expands languages with a country-componentand lowercases them", () => {
|
|
7
7
|
const expanded = (0, i18n_1.getAllLocales)([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const maybeUseI18n_1 = require("../maybeUseI18n");
|
|
4
|
-
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in
|
|
4
|
+
const DEFAULT_LOCALES = ["de-DE"]; // match what the client does in vi.setup.ts
|
|
5
5
|
describe("maybeUseI18n", () => {
|
|
6
6
|
it("correctly applies schema-wise overrides", () => {
|
|
7
7
|
const originalSchema = {
|
|
@@ -82,7 +82,7 @@ describe("maybeUseI18n", () => {
|
|
|
82
82
|
};
|
|
83
83
|
const translatedSchema = (0, maybeUseI18n_1.maybeUseI18n)(originalSchema, DEFAULT_LOCALES);
|
|
84
84
|
expect(translatedSchema).toStrictEqual({
|
|
85
|
-
clientLocale: "de",
|
|
85
|
+
clientLocale: "de", // note how this is 'de', not 'de-de' because the schema defined 'de'
|
|
86
86
|
groupNames: {},
|
|
87
87
|
group_title: undefined,
|
|
88
88
|
properties: {
|
|
@@ -53,7 +53,7 @@ describe("processSchema", () => {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
it("should not expand normal properties", async () => {
|
|
56
|
-
const getIdentityToken =
|
|
56
|
+
const getIdentityToken = vi.fn(async () => { });
|
|
57
57
|
const properties = {
|
|
58
58
|
first_name: {
|
|
59
59
|
priority: 10,
|
|
@@ -119,7 +119,7 @@ describe("processSchema", () => {
|
|
|
119
119
|
verified_fields: undefined,
|
|
120
120
|
isProfileSchema: false,
|
|
121
121
|
isSpSchema: false,
|
|
122
|
-
allOf: mock.schema.allOf,
|
|
122
|
+
allOf: mock.schema.allOf, // removed later
|
|
123
123
|
definitions: mock.schema.definitions, // removed later
|
|
124
124
|
});
|
|
125
125
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Schema } from "@raytio/types";
|
|
1
|
+
import type { Schema } from "@raytio/types";
|
|
2
2
|
export declare const addLoadingTimes: (schema: Schema) => Schema;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SchemaTag } from "@raytio/types";
|
|
1
|
+
import type { SchemaTag } from "@raytio/types";
|
|
2
2
|
export declare const TAG_DENYLIST: SchemaTag[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expandSchema =
|
|
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;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Schema } from "@raytio/types";
|
|
1
|
+
import type { Schema } from "@raytio/types";
|
|
2
2
|
export declare const maybeUseI18n: (schema: Schema, userLocales: readonly string[]) => Schema;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Schema, WrappedSchema } from "@raytio/types";
|
|
1
|
+
import type { Schema, WrappedSchema } from "@raytio/types";
|
|
2
2
|
import type { unwrapSchema } from "./unwrapSchema";
|
|
3
3
|
export declare const processSchema: (schema: ReturnType<typeof unwrapSchema>, allUnexpandedSchemas: WrappedSchema[]) => Schema;
|
|
@@ -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(
|
|
22
|
-
|
|
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(
|
|
47
|
-
|
|
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
|
}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { Schema } from "@raytio/types";
|
|
1
|
+
import type { Schema } from "@raytio/types";
|
|
2
2
|
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"
|
|
7
|
-
schema_type?: import("@raytio/types").SchemaType
|
|
8
|
-
title_plural?: string
|
|
9
|
-
schema_group?: string
|
|
10
|
-
tags?: import("@raytio/types").SchemaTag[]
|
|
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
|
|
19
|
-
description?: string
|
|
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
|
|
53
|
-
description?: string
|
|
49
|
+
title?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
};
|
|
52
|
+
[fieldNameOrGroupName: string]: import("@raytio/types").ServerSchemaField & {
|
|
53
|
+
title_plural?: string;
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
57
|
relationships?: {
|
|
58
58
|
relationship_name: string;
|
|
59
59
|
direction: "from";
|
|
60
60
|
type: string;
|
|
61
|
-
required_relationship?: boolean
|
|
62
|
-
oneOf?:
|
|
63
|
-
anyOf?:
|
|
64
|
-
multiple?: boolean
|
|
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
|
-
}
|
|
68
|
-
required?: string[]
|
|
69
|
-
}[]
|
|
67
|
+
};
|
|
68
|
+
required?: string[];
|
|
69
|
+
}[];
|
|
70
70
|
display?: {
|
|
71
71
|
head_main?: {
|
|
72
72
|
fields: string[];
|
|
73
|
-
format?: string
|
|
74
|
-
}
|
|
73
|
+
format?: string;
|
|
74
|
+
};
|
|
75
75
|
head_sub?: {
|
|
76
76
|
fields: string[];
|
|
77
|
-
format?: string
|
|
78
|
-
}
|
|
77
|
+
format?: string;
|
|
78
|
+
};
|
|
79
79
|
expand?: {
|
|
80
80
|
fields: string[];
|
|
81
81
|
label: string;
|
|
82
|
-
}[]
|
|
83
|
-
|
|
82
|
+
}[];
|
|
83
|
+
tabular?: {
|
|
84
|
+
fields: string[];
|
|
85
|
+
};
|
|
86
|
+
compact_table?: boolean;
|
|
87
|
+
};
|
|
84
88
|
onboard_properties?: {
|
|
85
89
|
profile_objects?: {
|
|
86
|
-
schema_name:
|
|
90
|
+
schema_name: import("@raytio/types").SchemaName;
|
|
87
91
|
properties: Record<string, unknown>;
|
|
88
|
-
}[]
|
|
92
|
+
}[];
|
|
89
93
|
relationships?: {
|
|
90
94
|
from: string;
|
|
91
95
|
to: string;
|
|
92
96
|
type: string;
|
|
93
|
-
properties?: Record<string, string
|
|
94
|
-
}[]
|
|
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
|
-
}[]
|
|
103
|
-
}[]
|
|
104
|
-
}[]
|
|
105
|
-
return_to?: string
|
|
106
|
-
}
|
|
107
|
-
name:
|
|
108
|
-
type?: import("@raytio/types").DataTypes
|
|
109
|
-
group_title?: string
|
|
110
|
-
verified_fields?: (string | import("@raytio/types").ConditionallyRequired)[]
|
|
111
|
-
required?: (string | import("@raytio/types").ConditionallyRequired)[]
|
|
112
|
-
wasExpandedByClient?: boolean
|
|
113
|
-
start_date?: string
|
|
114
|
-
end_date?: string
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
}[];
|
|
107
|
+
}[];
|
|
108
|
+
}[];
|
|
109
|
+
return_to?: string;
|
|
110
|
+
};
|
|
111
|
+
name: import("@raytio/types").SchemaName;
|
|
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
|
|
119
|
-
isProfileSchema?: boolean
|
|
120
|
-
isSpSchema?: boolean
|
|
126
|
+
timing?: Record<"extract" | "live_person" | "verify_pending_delay", number>;
|
|
127
|
+
isProfileSchema?: boolean;
|
|
128
|
+
isSpSchema?: boolean;
|
|
121
129
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NId, SchemaField, Urn } from "@raytio/types";
|
|
1
|
+
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
|
-
(urn: Urn):
|
|
5
|
-
(urn: Urn | undefined):
|
|
4
|
+
<IDType = NId>(urn: Urn): IDType;
|
|
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.
|
|
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,6 +1,2 @@
|
|
|
1
|
-
import { WrappedSchema } from "@raytio/types";
|
|
2
|
-
export
|
|
3
|
-
version: string;
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
6
|
-
export declare function unwrapSchema(wrapped: WrappedSchema): WrappedSchema["schema"] & Pick<WrappedSchema, "start_date" | "end_date" | "schema_type"> & ClientFields;
|
|
1
|
+
import type { Schema, WrappedSchema } from "@raytio/types";
|
|
2
|
+
export declare function unwrapSchema(wrapped: WrappedSchema): WrappedSchema["schema"] & Pick<WrappedSchema, "start_date" | "end_date" | "schema_type"> & Pick<Schema, "name" | "version">;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unwrapSchema =
|
|
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;
|
package/dist/schema/labels.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { SchemaName } from "@raytio/types";
|
|
1
2
|
/** Finds the label (on a profile object) which is the schema name */
|
|
2
|
-
export declare const findSchemaLabel: (labels: string[] | undefined) =>
|
|
3
|
+
export declare const findSchemaLabel: (labels: string[] | undefined) => SchemaName | undefined;
|
package/dist/testHelpers.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Mock } from "vitest";
|
|
2
2
|
/** like {@link Partial} but applies to all deep properties */
|
|
3
3
|
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) =>
|
|
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 { FieldVerification,
|
|
1
|
+
import { FieldVerification, type NId, POVerification, type ProfileObject, type ProfileObjectForUpload, type RealVer, type Schema, type VerificationProvider } from "@raytio/types";
|
|
2
2
|
export type VerDetails = {
|
|
3
3
|
sourceNId?: NId;
|
|
4
4
|
verifiers: VerificationProvider[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPOVerification =
|
|
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;
|
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./cleanInstance"), exports);
|
|
18
17
|
__exportStar(require("./getPOVerification"), exports);
|
|
19
18
|
__exportStar(require("./verifyCheck"), exports);
|
|
20
19
|
__exportStar(require("./getVerifiedBy"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProfileObject, RealVer, SafeHarbourCode, Schema } from "@raytio/types";
|
|
1
|
+
import { type ProfileObject, type RealVer, type SafeHarbourCode, type Schema, type SchemaName } from "@raytio/types";
|
|
2
2
|
/** an object listing the `xId`s for each SafeHarbourCode */
|
|
3
3
|
export type SafeHarbourObj = Partial<Record<SafeHarbourCode, string[]>>;
|
|
4
4
|
/** the response from {@link calcSafeHarbourScore} */
|
|
@@ -16,5 +16,5 @@ export declare const calcSafeHarbourScore: (data: {
|
|
|
16
16
|
person: ProfileObject;
|
|
17
17
|
profileObjects: ProfileObject[];
|
|
18
18
|
realVers: RealVer[];
|
|
19
|
-
getSchema(schemaName:
|
|
19
|
+
getSchema(schemaName: SchemaName): Promise<Schema>;
|
|
20
20
|
}) => Promise<SafeHarbourResult>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calcSafeHarbourScore =
|
|
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
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const __1 = require("..");
|
|
4
4
|
const operations_1 = require("../operations");
|
|
5
5
|
const testHelpers_1 = require("../../../testHelpers");
|
|
6
|
-
|
|
6
|
+
vi.mock("../operations");
|
|
7
7
|
/**
|
|
8
8
|
* in this test case:
|
|
9
9
|
* - there are valid verifications for fName=Max and fName=Erika, but we don't which
|
|
@@ -17,7 +17,7 @@ jest.mock("../operations");
|
|
|
17
17
|
*/
|
|
18
18
|
describe("getOwnRealVerifications", () => {
|
|
19
19
|
beforeAll(() => {
|
|
20
|
-
|
|
20
|
+
vi.fn(() => 1).mockImplementation(() => 123);
|
|
21
21
|
(0, testHelpers_1.m)(operations_1.checkOwnVerification).mockImplementation(async ({ signature, keyId }) => {
|
|
22
22
|
if (signature === "signatureForLastNameMustermannFromN2")
|
|
23
23
|
return false;
|
|
@@ -35,7 +35,7 @@ describe("getOwnRealVerifications", () => {
|
|
|
35
35
|
{
|
|
36
36
|
n_id: "nv1",
|
|
37
37
|
properties: {
|
|
38
|
-
valid_until: "2020-08-28T23:12:35.678Z",
|
|
38
|
+
valid_until: "2020-08-28T23:12:35.678Z", // this one has expired
|
|
39
39
|
verifications: [
|
|
40
40
|
{
|
|
41
41
|
signature: "signatureForFirstNameMax",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getSomeoneElsesRealVerifications_1 = require("../getSomeoneElsesRealVerifications");
|
|
4
4
|
const operations_1 = require("../operations");
|
|
5
|
-
|
|
5
|
+
vi.mock("../operations");
|
|
6
6
|
const checkVerificationsResp = [
|
|
7
7
|
{
|
|
8
8
|
verified: false,
|
|
@@ -133,7 +133,7 @@ const verifications = [
|
|
|
133
133
|
];
|
|
134
134
|
describe("getSomeoneElsesRealVerifications", () => {
|
|
135
135
|
beforeEach(() => {
|
|
136
|
-
|
|
136
|
+
vi.resetAllMocks();
|
|
137
137
|
operations_1.checkSomeoneElsesVerifications.mockResolvedValue(checkVerificationsResp);
|
|
138
138
|
});
|
|
139
139
|
it("returns an empty array if provided nothing", async () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProfileObject,
|
|
1
|
+
import type { ProfileObject, RealVer, UId, Verification } from "@raytio/types";
|
|
2
2
|
/**
|
|
3
3
|
* Given a list of verifications and decrypted profile objects, this function
|
|
4
4
|
* locally verifies the credibility of the signatures in the verifications.
|
|
@@ -64,7 +64,7 @@ const getSomeoneElsesRealVerifications = async ({ aId, apiUrl, verifications, pr
|
|
|
64
64
|
verified: data.passed,
|
|
65
65
|
nID,
|
|
66
66
|
belongsToNId: data.source_hashed_n_id
|
|
67
|
-
?
|
|
67
|
+
? (0, general_1.createHashedNId)(data.source_hashed_n_id, aId)
|
|
68
68
|
: data.source_n_id,
|
|
69
69
|
}));
|
|
70
70
|
return realVers;
|
|
@@ -7,7 +7,7 @@ const __1 = require("..");
|
|
|
7
7
|
const util_1 = require("../../../../util");
|
|
8
8
|
const checkOwnVerification_1 = require("../checkOwnVerification");
|
|
9
9
|
const sampleBundle_json_1 = __importDefault(require("./sampleBundle.json"));
|
|
10
|
-
global.fetch =
|
|
10
|
+
global.fetch = vi.fn().mockImplementation(async (url) => ({
|
|
11
11
|
text: async () => url.endsWith("raytio.pem")
|
|
12
12
|
? `-----BEGIN PUBLIC KEY-----
|
|
13
13
|
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAn9QtCqYa3H3ipFFU0xP3
|
package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js
CHANGED
|
@@ -13,7 +13,7 @@ const toVerify = [
|
|
|
13
13
|
];
|
|
14
14
|
describe("checkSomeoneElsesVerifications", () => {
|
|
15
15
|
it("calls the API and filters out garbage", async () => {
|
|
16
|
-
global.fetch =
|
|
16
|
+
global.fetch = vi
|
|
17
17
|
.fn()
|
|
18
18
|
.mockImplementation()
|
|
19
19
|
// first fetch request
|
|
@@ -34,7 +34,7 @@ describe("checkSomeoneElsesVerifications", () => {
|
|
|
34
34
|
expect(result).toStrictEqual([{ verified: true }, { verified: false }]);
|
|
35
35
|
});
|
|
36
36
|
it("throws an error if the API rejects", async () => {
|
|
37
|
-
global.fetch =
|
|
37
|
+
global.fetch = vi
|
|
38
38
|
.fn()
|
|
39
39
|
.mockImplementation()
|
|
40
40
|
// first fetch request
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkOwnVerification = exports.checkJsonSignature =
|
|
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`
|
|
@@ -31,6 +31,8 @@ const checkJsonSignature = async (data, signature, keyId) => {
|
|
|
31
31
|
if (!keyFileName || /[^\w-]/.test(keyFileName)) {
|
|
32
32
|
throw new Error("Invalid key ID");
|
|
33
33
|
}
|
|
34
|
+
// NOTE: We have to hard code the URL, we can't use an environment
|
|
35
|
+
// variable here, since this package is used outside of the monorepo.
|
|
34
36
|
const keyUrl = `https://api-docs.rayt.io/lookups/${keyFileName}.pem`;
|
|
35
37
|
const jwk = await getJwk(keyUrl);
|
|
36
38
|
const stringified = (0, util_1.canonicalJsonify)(data);
|