@raytio/core 8.1.1 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +375 -19
- package/dist/accessApplication/createAA.d.ts +17 -17
- package/dist/accessApplication/createAA.js +71 -72
- package/dist/accessApplication/index.d.ts +1 -1
- package/dist/accessApplication/index.js +13 -13
- package/dist/crypto/cognitoAttributes.d.ts +15 -15
- package/dist/crypto/cognitoAttributes.js +33 -33
- package/dist/crypto/decryptKeys.d.ts +1 -1
- package/dist/crypto/decryptKeys.js +33 -35
- package/dist/crypto/decryptSharedData.d.ts +26 -26
- package/dist/crypto/decryptSharedData.js +38 -38
- package/dist/crypto/getAADecryptor.d.ts +11 -11
- package/dist/crypto/getAADecryptor.js +20 -20
- package/dist/crypto/helpers.d.ts +18 -18
- package/dist/crypto/helpers.js +26 -26
- package/dist/crypto/index.d.ts +4 -4
- package/dist/crypto/index.js +17 -17
- package/dist/general/conditional.d.ts +7 -7
- package/dist/general/conditional.js +22 -22
- package/dist/general/index.d.ts +3 -2
- package/dist/general/index.js +15 -14
- package/dist/general/password.d.ts +8 -8
- package/dist/general/password.js +29 -29
- package/dist/general/types.d.ts +6 -0
- package/dist/general/types.js +13 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +18 -17
- package/dist/rules/calculateScore.d.ts +11 -0
- package/dist/rules/calculateScore.js +52 -0
- package/dist/rules/convertInstanceToRuleInput.d.ts +3 -0
- package/dist/rules/convertInstanceToRuleInput.js +140 -0
- package/dist/rules/evaluateScoreCondition.d.ts +2 -0
- package/dist/rules/evaluateScoreCondition.js +45 -0
- package/dist/rules/helpers/addInfiniteThresholdBoundaries.d.ts +8 -0
- package/dist/rules/helpers/addInfiniteThresholdBoundaries.js +11 -0
- package/dist/rules/helpers/checkTypeofValue.d.ts +3 -0
- package/dist/rules/helpers/checkTypeofValue.js +43 -0
- package/dist/rules/helpers/getValuesFromPath.d.ts +3 -0
- package/dist/rules/helpers/getValuesFromPath.js +50 -0
- package/dist/rules/helpers/index.d.ts +5 -0
- package/dist/rules/helpers/index.js +17 -0
- package/dist/rules/helpers/symbols.d.ts +2 -0
- package/dist/rules/helpers/symbols.js +5 -0
- package/dist/rules/helpers/thresholds.d.ts +5 -0
- package/dist/rules/helpers/thresholds.js +47 -0
- package/dist/rules/index.d.ts +6 -0
- package/dist/rules/index.js +20 -0
- package/dist/rules/operators/bool.d.ts +2 -0
- package/dist/rules/operators/bool.js +17 -0
- package/dist/rules/operators/date.d.ts +2 -0
- package/dist/rules/operators/date.js +91 -0
- package/dist/rules/operators/hfield.d.ts +2 -0
- package/dist/rules/operators/hfield.js +33 -0
- package/dist/rules/operators/hschema.d.ts +2 -0
- package/dist/rules/operators/hschema.js +21 -0
- package/dist/rules/operators/index.d.ts +3 -0
- package/dist/rules/operators/index.js +11 -0
- package/dist/rules/operators/number.d.ts +2 -0
- package/dist/rules/operators/number.js +41 -0
- package/dist/rules/operators/string.d.ts +2 -0
- package/dist/rules/operators/string.js +58 -0
- package/dist/rules/types/config.d.ts +86 -0
- package/dist/rules/types/config.js +2 -0
- package/dist/rules/types/dataValueTypes.d.ts +19 -0
- package/dist/rules/types/dataValueTypes.js +4 -0
- package/dist/rules/types/index.d.ts +3 -0
- package/dist/rules/types/index.js +15 -0
- package/dist/rules/types/internal.d.ts +20 -0
- package/dist/rules/types/internal.js +2 -0
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +13 -13
- package/dist/schema/labels.d.ts +2 -2
- package/dist/schema/labels.js +20 -20
- package/dist/{verifications/checkVerifications.d.ts → util/canonicalJsonify.d.ts} +1 -1
- package/dist/util/canonicalJsonify.js +48 -0
- package/dist/util/handleResponse.d.ts +1 -1
- package/dist/util/handleResponse.js +21 -22
- package/dist/util/index.d.ts +2 -1
- package/dist/util/index.js +14 -13
- package/dist/verifications/cleanInstance.d.ts +9 -0
- package/dist/verifications/cleanInstance.js +15 -0
- package/dist/verifications/getPOVerification.d.ts +16 -13
- package/dist/verifications/getPOVerification.js +94 -95
- package/dist/verifications/getVerifiedBy.d.ts +1 -1
- package/dist/verifications/getVerifiedBy.js +19 -19
- package/dist/verifications/index.d.ts +5 -4
- package/dist/verifications/index.js +18 -17
- package/dist/verifications/maybeRereference.d.ts +1 -1
- package/dist/verifications/maybeRereference.js +10 -10
- package/dist/verifications/safeHarbour.d.ts +20 -20
- package/dist/verifications/safeHarbour.js +74 -74
- package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +13 -0
- package/dist/verifications/verifyCheck/getOwnRealVerifications.js +63 -0
- package/dist/verifications/{getRealVerifications.d.ts → verifyCheck/getSomeoneElsesRealVerifications.d.ts} +26 -22
- package/dist/verifications/{getRealVerifications.js → verifyCheck/getSomeoneElsesRealVerifications.js} +76 -66
- package/dist/verifications/verifyCheck/index.d.ts +2 -0
- package/dist/verifications/verifyCheck/index.js +14 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +9 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +31 -0
- package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.d.ts +1 -0
- package/dist/verifications/{checkVerifications.js → verifyCheck/operations/checkSomeoneElsesVerifications.js} +16 -16
- package/dist/verifications/verifyCheck/operations/index.d.ts +2 -0
- package/dist/verifications/verifyCheck/operations/index.js +14 -0
- package/package.json +8 -8
- package/dist/util/conditional.d.ts +0 -7
- package/dist/util/conditional.js +0 -15
package/dist/util/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./canonicalJsonify"), exports);
|
|
14
|
+
__exportStar(require("./handleResponse"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Instance } from "@raytio/types";
|
|
2
|
+
/**
|
|
3
|
+
* The API response from share/v2/access_application/instance/:iId
|
|
4
|
+
* returns a complicated hashed_n_id format, so you need to clean up
|
|
5
|
+
* the API response using this function as soon as possible.
|
|
6
|
+
*
|
|
7
|
+
* We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
|
|
8
|
+
*/
|
|
9
|
+
export declare function cleanInstance(instance: Instance): Instance;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanInstance = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
/**
|
|
6
|
+
* The API response from share/v2/access_application/instance/:iId
|
|
7
|
+
* returns a complicated hashed_n_id format, so you need to clean up
|
|
8
|
+
* the API response using this function as soon as possible.
|
|
9
|
+
*
|
|
10
|
+
* We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
|
|
11
|
+
*/
|
|
12
|
+
function cleanInstance(instance) {
|
|
13
|
+
return Object.assign(Object.assign({}, instance), { profile_objects: instance.profile_objects.map((PO) => (Object.assign(Object.assign({}, (0, ramda_1.omit)(["hashed_n_id"], PO)), { n_id: PO.n_id || `HASHED::${PO.hashed_n_id}::${instance.a_id}` }))) });
|
|
14
|
+
}
|
|
15
|
+
exports.cleanInstance = cleanInstance;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { FieldVerification, ProfileObject, POVerification, RealVer, Schema, VerificationProvider, ProfileObjectForUpload } from "@raytio/types";
|
|
2
|
-
/**
|
|
3
|
-
* Determines the verification status of a profile object, and its individual fields.
|
|
4
|
-
*/
|
|
5
|
-
export declare function getPOVerification({ PO, schema, realVers, }: {
|
|
6
|
-
PO: ProfileObject | ProfileObjectForUpload;
|
|
7
|
-
schema: Schema;
|
|
8
|
-
realVers: RealVer[];
|
|
9
|
-
}): {
|
|
10
|
-
status: POVerification;
|
|
11
|
-
details:
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { FieldVerification, ProfileObject, POVerification, RealVer, Schema, VerificationProvider, ProfileObjectForUpload, NId } from "@raytio/types";
|
|
2
|
+
/**
|
|
3
|
+
* Determines the verification status of a profile object, and its individual fields.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getPOVerification({ PO, schema, realVers, }: {
|
|
6
|
+
PO: ProfileObject | ProfileObjectForUpload;
|
|
7
|
+
schema: Schema;
|
|
8
|
+
realVers: RealVer[];
|
|
9
|
+
}): {
|
|
10
|
+
status: POVerification;
|
|
11
|
+
details: {
|
|
12
|
+
sourceNId?: NId;
|
|
13
|
+
verifiers: VerificationProvider[];
|
|
14
|
+
};
|
|
15
|
+
fieldVerifications: Record<string, FieldVerification>;
|
|
16
|
+
};
|
|
@@ -1,95 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPOVerification = void 0;
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
exports.getPOVerification = getPOVerification;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPOVerification = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
const types_1 = require("@raytio/types");
|
|
6
|
+
const crypto_1 = require("../crypto");
|
|
7
|
+
const getVerifiedBy_1 = require("./getVerifiedBy");
|
|
8
|
+
const maybeRereference_1 = require("./maybeRereference");
|
|
9
|
+
const general_1 = require("../general");
|
|
10
|
+
const schema_1 = require("../schema");
|
|
11
|
+
/**
|
|
12
|
+
* Determines the verification status of a profile object, and its individual fields.
|
|
13
|
+
*/
|
|
14
|
+
function getPOVerification({ PO, schema, realVers, }) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
// safe guard to avoid a misleading response from this function
|
|
17
|
+
const schemaName = PO.schema || (0, schema_1.findSchemaLabel)(PO.labels);
|
|
18
|
+
if (schema.name !== schemaName) {
|
|
19
|
+
throw new Error(`Wrong schema supplied to getPOVerification: ${schema.name} != ${schemaName}`);
|
|
20
|
+
}
|
|
21
|
+
const someAreEncrypted = !!(0, crypto_1.someEncrypted)(PO.properties);
|
|
22
|
+
if (someAreEncrypted) {
|
|
23
|
+
return {
|
|
24
|
+
status: types_1.POVerification.Encrypted,
|
|
25
|
+
details: { sourceNId: PO.n_id, verifiers: [] },
|
|
26
|
+
fieldVerifications: {},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// if a subObject is supplied, properties might not be an object.
|
|
30
|
+
// In which case this PO is definitely not verified
|
|
31
|
+
const shouldBeVerifiedProps = PO.properties instanceof Object
|
|
32
|
+
? (0, ramda_1.pick)(
|
|
33
|
+
// 📛 part1: this is the straightforward case, we pick the fields that are always verifiable
|
|
34
|
+
((_a = schema.verified_fields) === null || _a === void 0 ? void 0 : _a.filter((x) => typeof x === "string")) || [], PO.properties)
|
|
35
|
+
: {};
|
|
36
|
+
// 📛 part2: some fields may be conditionally verifiable. if so, and the condition is true, add them to shouldBeVerifiedProps
|
|
37
|
+
((_b = schema.verified_fields) !== null && _b !== void 0 ? _b : [])
|
|
38
|
+
.filter((x) => typeof x !== "string" && (0, general_1.isConditionMet)(x.if, PO.properties))
|
|
39
|
+
.forEach(x => {
|
|
40
|
+
// eslint-disable-next-line fp/no-mutation
|
|
41
|
+
shouldBeVerifiedProps[x.field] = PO.properties[x.field];
|
|
42
|
+
});
|
|
43
|
+
const fieldVerifications = (0, ramda_1.mapObjIndexed)((content, fieldName) => {
|
|
44
|
+
const pertainingVers = realVers.filter(x => x.fieldName === fieldName &&
|
|
45
|
+
// using ramda's `equals` because this needs to work for objects/arrays
|
|
46
|
+
(0, ramda_1.equals)(x.value, (0, maybeRereference_1.maybeRereference)(content)) &&
|
|
47
|
+
// if an nId is supplied, also filter out verifications that don't relate to that n_id
|
|
48
|
+
(PO.n_id ? x.belongsToNId === PO.n_id : true));
|
|
49
|
+
// .every() illogically returns true for arrays with zero length
|
|
50
|
+
if (pertainingVers.length && pertainingVers.every(x => x.expired)) {
|
|
51
|
+
return types_1.FieldVerification.Expired;
|
|
52
|
+
}
|
|
53
|
+
if (pertainingVers.some(x => !x.verified)) {
|
|
54
|
+
return types_1.FieldVerification.VerifiedFalse;
|
|
55
|
+
}
|
|
56
|
+
return pertainingVers.length
|
|
57
|
+
? types_1.FieldVerification.Verified
|
|
58
|
+
: types_1.FieldVerification.NotVerified;
|
|
59
|
+
}, shouldBeVerifiedProps);
|
|
60
|
+
const status = (() => {
|
|
61
|
+
if (!Object.values(shouldBeVerifiedProps).length) {
|
|
62
|
+
return types_1.POVerification.NotVerified;
|
|
63
|
+
}
|
|
64
|
+
const allExpired = Object.values(fieldVerifications).every(x => x === types_1.FieldVerification.Expired);
|
|
65
|
+
if (allExpired)
|
|
66
|
+
return types_1.POVerification.Expired;
|
|
67
|
+
const anyVerfiedFalse = Object.values(fieldVerifications).some(x => x === types_1.FieldVerification.VerifiedFalse);
|
|
68
|
+
if (anyVerfiedFalse)
|
|
69
|
+
return types_1.POVerification.VerifiedFalse;
|
|
70
|
+
const allVerified = Object.values(fieldVerifications).every(x => x === types_1.FieldVerification.Verified);
|
|
71
|
+
if (allVerified)
|
|
72
|
+
return types_1.POVerification.FullyVerified;
|
|
73
|
+
const anyVerified = Object.values(fieldVerifications).some(x => x === types_1.FieldVerification.Verified);
|
|
74
|
+
if (anyVerified)
|
|
75
|
+
return types_1.POVerification.PartiallyVerified;
|
|
76
|
+
const noneVerified = Object.values(fieldVerifications).every(x => x === types_1.FieldVerification.NotVerified);
|
|
77
|
+
if (noneVerified)
|
|
78
|
+
return types_1.POVerification.NotVerified;
|
|
79
|
+
// can't happen, but just in case the logic above fails
|
|
80
|
+
/* istanbul ignore next */
|
|
81
|
+
return types_1.POVerification.NotVerified;
|
|
82
|
+
})();
|
|
83
|
+
const verifiers = (0, getVerifiedBy_1.getVerifiedBy)({
|
|
84
|
+
nId: PO.n_id,
|
|
85
|
+
realVers,
|
|
86
|
+
shouldBeVerifiedProps,
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
status,
|
|
90
|
+
details: { sourceNId: PO.n_id, verifiers },
|
|
91
|
+
fieldVerifications,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
exports.getPOVerification = getPOVerification;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVerifiedBy = void 0;
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
const maybeRereference_1 = require("./maybeRereference");
|
|
6
|
-
// we should probably document this
|
|
7
|
-
/** @internal */
|
|
8
|
-
const getVerifiedBy = ({ nId, realVers, shouldBeVerifiedProps, }) => {
|
|
9
|
-
const mayBeVerifiedFields = Object.keys(shouldBeVerifiedProps);
|
|
10
|
-
const pertainingVers = realVers
|
|
11
|
-
.filter(x => mayBeVerifiedFields.includes(x.fieldName) &&
|
|
12
|
-
// using ramda's `equals` because this needs to work for objects/arrays
|
|
13
|
-
(0, ramda_1.equals)((0, maybeRereference_1.maybeRereference)(shouldBeVerifiedProps[x.fieldName]), x.value) &&
|
|
14
|
-
// if an nId is supplied, also filter out verifications that don't relate to that n_id
|
|
15
|
-
(nId ? x.belongsToNId === nId : true))
|
|
16
|
-
.map(x => x.provider);
|
|
17
|
-
return (0, ramda_1.uniqBy)(x => x.dataSourceNId, pertainingVers);
|
|
18
|
-
};
|
|
19
|
-
exports.getVerifiedBy = getVerifiedBy;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVerifiedBy = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
const maybeRereference_1 = require("./maybeRereference");
|
|
6
|
+
// we should probably document this
|
|
7
|
+
/** @internal */
|
|
8
|
+
const getVerifiedBy = ({ nId, realVers, shouldBeVerifiedProps, }) => {
|
|
9
|
+
const mayBeVerifiedFields = Object.keys(shouldBeVerifiedProps);
|
|
10
|
+
const pertainingVers = realVers
|
|
11
|
+
.filter(x => mayBeVerifiedFields.includes(x.fieldName) &&
|
|
12
|
+
// using ramda's `equals` because this needs to work for objects/arrays
|
|
13
|
+
(0, ramda_1.equals)((0, maybeRereference_1.maybeRereference)(shouldBeVerifiedProps[x.fieldName]), x.value) &&
|
|
14
|
+
// if an nId is supplied, also filter out verifications that don't relate to that n_id
|
|
15
|
+
(nId ? x.belongsToNId === nId : true))
|
|
16
|
+
.map(x => x.provider);
|
|
17
|
+
return (0, ramda_1.uniqBy)(x => x.dataSourceNId, pertainingVers);
|
|
18
|
+
};
|
|
19
|
+
exports.getVerifiedBy = getVerifiedBy;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
1
|
+
export * from "./cleanInstance";
|
|
2
|
+
export * from "./getPOVerification";
|
|
3
|
+
export * from "./verifyCheck";
|
|
4
|
+
export * from "./getVerifiedBy";
|
|
5
|
+
export * from "./safeHarbour";
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
// not exporting checkVerifications; it's not a public API
|
|
14
|
-
__exportStar(require("./
|
|
15
|
-
__exportStar(require("./
|
|
16
|
-
__exportStar(require("./
|
|
17
|
-
__exportStar(require("./
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
// not exporting checkVerifications; it's not a public API
|
|
14
|
+
__exportStar(require("./cleanInstance"), exports);
|
|
15
|
+
__exportStar(require("./getPOVerification"), exports);
|
|
16
|
+
__exportStar(require("./verifyCheck"), exports);
|
|
17
|
+
__exportStar(require("./getVerifiedBy"), exports);
|
|
18
|
+
__exportStar(require("./safeHarbour"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maybeRereference = void 0;
|
|
4
|
-
const hasNId = (value) => typeof value === "object" && !!value && "n_id" in value;
|
|
5
|
-
/**
|
|
6
|
-
* @internal see #578
|
|
7
|
-
* For values that have already been dereferenced, we recreate the `$ref`.
|
|
8
|
-
*/
|
|
9
|
-
const maybeRereference = (value) => hasNId(value) ? { $ref: `urn:profile_object:${value.n_id}` } : value;
|
|
10
|
-
exports.maybeRereference = maybeRereference;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maybeRereference = void 0;
|
|
4
|
+
const hasNId = (value) => typeof value === "object" && !!value && "n_id" in value;
|
|
5
|
+
/**
|
|
6
|
+
* @internal see #578
|
|
7
|
+
* For values that have already been dereferenced, we recreate the `$ref`.
|
|
8
|
+
*/
|
|
9
|
+
const maybeRereference = (value) => hasNId(value) ? { $ref: `urn:profile_object:${value.n_id}` } : value;
|
|
10
|
+
exports.maybeRereference = maybeRereference;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { ProfileObject, RealVer, Schema } from "@raytio/types";
|
|
2
|
-
/** an object listing the `xId`s for each SafeHarbourCode */
|
|
3
|
-
export declare type SafeHarbourObj = Partial<Record<SafeHarbourCode, string[]>>;
|
|
4
|
-
/** the response from {@link calcSafeHarbourScore} */
|
|
5
|
-
export declare type SafeHarbourResult = {
|
|
6
|
-
isSafe: boolean;
|
|
7
|
-
flags: SafeHarbourObj;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* The Safe Harbour Score indidicates whether a person's identity has been verified
|
|
11
|
-
* to the extent requried for Safe Harbour Compliance. This requires multiple verifications
|
|
12
|
-
* from different sources. For
|
|
13
|
-
* {@link https://dev-docs.rayt.io/docs/features/pep-checks Raytio Documentation}.
|
|
14
|
-
*/
|
|
15
|
-
export declare const calcSafeHarbourScore: (data: {
|
|
16
|
-
person: ProfileObject;
|
|
17
|
-
profileObjects: ProfileObject[];
|
|
18
|
-
realVers: RealVer[];
|
|
19
|
-
getSchema(schemaName: string): Promise<Schema>;
|
|
20
|
-
}) => Promise<SafeHarbourResult>;
|
|
1
|
+
import { ProfileObject, RealVer, Schema } from "@raytio/types";
|
|
2
|
+
/** an object listing the `xId`s for each SafeHarbourCode */
|
|
3
|
+
export declare type SafeHarbourObj = Partial<Record<SafeHarbourCode, string[]>>;
|
|
4
|
+
/** the response from {@link calcSafeHarbourScore} */
|
|
5
|
+
export declare type SafeHarbourResult = {
|
|
6
|
+
isSafe: boolean;
|
|
7
|
+
flags: SafeHarbourObj;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The Safe Harbour Score indidicates whether a person's identity has been verified
|
|
11
|
+
* to the extent requried for Safe Harbour Compliance. This requires multiple verifications
|
|
12
|
+
* from different sources. For information, refer to the
|
|
13
|
+
* {@link https://dev-docs.rayt.io/docs/features/pep-checks Raytio Documentation}.
|
|
14
|
+
*/
|
|
15
|
+
export declare const calcSafeHarbourScore: (data: {
|
|
16
|
+
person: ProfileObject;
|
|
17
|
+
profileObjects: ProfileObject[];
|
|
18
|
+
realVers: RealVer[];
|
|
19
|
+
getSchema(schemaName: string): Promise<Schema>;
|
|
20
|
+
}) => Promise<SafeHarbourResult>;
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calcSafeHarbourScore = exports.safeHarbourRequirementsMet = exports.getFlags = exports.filterByMutualFields = void 0;
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
const types_1 = require("@raytio/types");
|
|
6
|
-
const getPOVerification_1 = require("./getPOVerification");
|
|
7
|
-
const schema_1 = require("../schema");
|
|
8
|
-
/** @internal see #659 */
|
|
9
|
-
var SafeHarbourCode;
|
|
10
|
-
(function (SafeHarbourCode) {
|
|
11
|
-
SafeHarbourCode["M1"] = "M1";
|
|
12
|
-
SafeHarbourCode["M2"] = "M2";
|
|
13
|
-
SafeHarbourCode["N1"] = "N1";
|
|
14
|
-
})(SafeHarbourCode || (SafeHarbourCode = {}));
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
* we filter to only include the POs where all the mutual fields match the
|
|
18
|
-
* person, i.e. we only want POs that have fName, lName, etc. with the same
|
|
19
|
-
* value as the base person
|
|
20
|
-
*/
|
|
21
|
-
function filterByMutualFields(person, profileObjects) {
|
|
22
|
-
const personFields = Object.entries(person.properties).filter(([fieldName]) => fieldName !== "n_id");
|
|
23
|
-
if (!personFields.length)
|
|
24
|
-
return [];
|
|
25
|
-
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); }));
|
|
26
|
-
}
|
|
27
|
-
exports.filterByMutualFields = filterByMutualFields;
|
|
28
|
-
/** @internal */
|
|
29
|
-
async function getFlags({ person, profileObjects, realVers, getSchema, }) {
|
|
30
|
-
const POsWithSameFields = filterByMutualFields(person, profileObjects);
|
|
31
|
-
const relevantVers = (await Promise.all(POsWithSameFields.map(async (PO) => {
|
|
32
|
-
const schemaName = (0, schema_1.findSchemaLabel)(PO.labels);
|
|
33
|
-
const schema = await getSchema(schemaName);
|
|
34
|
-
return Object.assign({ nId: PO.n_id }, (0, getPOVerification_1.getPOVerification)({
|
|
35
|
-
schema,
|
|
36
|
-
PO,
|
|
37
|
-
realVers,
|
|
38
|
-
}));
|
|
39
|
-
})))
|
|
40
|
-
.filter(v => v.status === types_1.POVerification.FullyVerified)
|
|
41
|
-
.flatMap(v => v.details.map(verProvider => realVers.find(ver => ver.belongsToNId === v.nId &&
|
|
42
|
-
ver.provider.dataSourceNId === verProvider.dataSourceNId)))
|
|
43
|
-
.filter((x) => !!x);
|
|
44
|
-
// in case there are somehow duplicates (see #922)
|
|
45
|
-
return (0, ramda_1.uniqBy)(x => x.nID, relevantVers)
|
|
46
|
-
.filter(ver => { var _a; return (_a = ver.metadata) === null || _a === void 0 ? void 0 : _a["safeHarbourScore"]; })
|
|
47
|
-
.reduce((ac, ver) => {
|
|
48
|
-
var _a, _b;
|
|
49
|
-
const key = (_a = ver.metadata) === null || _a === void 0 ? void 0 : _a["safeHarbourScore"];
|
|
50
|
-
if ((_b = ac[key]) === null || _b === void 0 ? void 0 : _b.includes(ver.xId))
|
|
51
|
-
return ac;
|
|
52
|
-
return Object.assign(Object.assign({}, ac), { [key]: [...(ac[key] || []), ver.xId] });
|
|
53
|
-
}, {});
|
|
54
|
-
}
|
|
55
|
-
exports.getFlags = getFlags;
|
|
56
|
-
/** @internal */
|
|
57
|
-
function safeHarbourRequirementsMet(flags) {
|
|
58
|
-
const { M1 = 0, M2 = 0, N1 = 0 } = (0, ramda_1.mapObjIndexed)(xIds => xIds.length, flags);
|
|
59
|
-
// see https://bit.ly/2KKo4rF
|
|
60
|
-
const isSafe = M1 >= 2 ||
|
|
61
|
-
(M1 >= 1 && M2 >= 1) ||
|
|
62
|
-
(M1 >= 1 && N1 >= 1) ||
|
|
63
|
-
(M2 >= 1 && N1 >= 1);
|
|
64
|
-
return { isSafe, flags };
|
|
65
|
-
}
|
|
66
|
-
exports.safeHarbourRequirementsMet = safeHarbourRequirementsMet;
|
|
67
|
-
/**
|
|
68
|
-
* The Safe Harbour Score indidicates whether a person's identity has been verified
|
|
69
|
-
* to the extent requried for Safe Harbour Compliance. This requires multiple verifications
|
|
70
|
-
* from different sources. For
|
|
71
|
-
* {@link https://dev-docs.rayt.io/docs/features/pep-checks Raytio Documentation}.
|
|
72
|
-
*/
|
|
73
|
-
const calcSafeHarbourScore = (data) => getFlags(data).then(safeHarbourRequirementsMet);
|
|
74
|
-
exports.calcSafeHarbourScore = calcSafeHarbourScore;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calcSafeHarbourScore = exports.safeHarbourRequirementsMet = exports.getFlags = exports.filterByMutualFields = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
const types_1 = require("@raytio/types");
|
|
6
|
+
const getPOVerification_1 = require("./getPOVerification");
|
|
7
|
+
const schema_1 = require("../schema");
|
|
8
|
+
/** @internal see #659 */
|
|
9
|
+
var SafeHarbourCode;
|
|
10
|
+
(function (SafeHarbourCode) {
|
|
11
|
+
SafeHarbourCode["M1"] = "M1";
|
|
12
|
+
SafeHarbourCode["M2"] = "M2";
|
|
13
|
+
SafeHarbourCode["N1"] = "N1";
|
|
14
|
+
})(SafeHarbourCode || (SafeHarbourCode = {}));
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
* we filter to only include the POs where all the mutual fields match the
|
|
18
|
+
* person, i.e. we only want POs that have fName, lName, etc. with the same
|
|
19
|
+
* value as the base person
|
|
20
|
+
*/
|
|
21
|
+
function filterByMutualFields(person, profileObjects) {
|
|
22
|
+
const personFields = Object.entries(person.properties).filter(([fieldName]) => fieldName !== "n_id");
|
|
23
|
+
if (!personFields.length)
|
|
24
|
+
return [];
|
|
25
|
+
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); }));
|
|
26
|
+
}
|
|
27
|
+
exports.filterByMutualFields = filterByMutualFields;
|
|
28
|
+
/** @internal */
|
|
29
|
+
async function getFlags({ person, profileObjects, realVers, getSchema, }) {
|
|
30
|
+
const POsWithSameFields = filterByMutualFields(person, profileObjects);
|
|
31
|
+
const relevantVers = (await Promise.all(POsWithSameFields.map(async (PO) => {
|
|
32
|
+
const schemaName = (0, schema_1.findSchemaLabel)(PO.labels);
|
|
33
|
+
const schema = await getSchema(schemaName);
|
|
34
|
+
return Object.assign({ nId: PO.n_id }, (0, getPOVerification_1.getPOVerification)({
|
|
35
|
+
schema,
|
|
36
|
+
PO,
|
|
37
|
+
realVers,
|
|
38
|
+
}));
|
|
39
|
+
})))
|
|
40
|
+
.filter(v => v.status === types_1.POVerification.FullyVerified)
|
|
41
|
+
.flatMap(v => v.details.verifiers.map(verProvider => realVers.find(ver => ver.belongsToNId === v.nId &&
|
|
42
|
+
ver.provider.dataSourceNId === verProvider.dataSourceNId)))
|
|
43
|
+
.filter((x) => !!x);
|
|
44
|
+
// in case there are somehow duplicates (see #922)
|
|
45
|
+
return (0, ramda_1.uniqBy)(x => x.nID, relevantVers)
|
|
46
|
+
.filter(ver => { var _a; return (_a = ver.metadata) === null || _a === void 0 ? void 0 : _a["safeHarbourScore"]; })
|
|
47
|
+
.reduce((ac, ver) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const key = (_a = ver.metadata) === null || _a === void 0 ? void 0 : _a["safeHarbourScore"];
|
|
50
|
+
if ((_b = ac[key]) === null || _b === void 0 ? void 0 : _b.includes(ver.xId))
|
|
51
|
+
return ac;
|
|
52
|
+
return Object.assign(Object.assign({}, ac), { [key]: [...(ac[key] || []), ver.xId] });
|
|
53
|
+
}, {});
|
|
54
|
+
}
|
|
55
|
+
exports.getFlags = getFlags;
|
|
56
|
+
/** @internal */
|
|
57
|
+
function safeHarbourRequirementsMet(flags) {
|
|
58
|
+
const { M1 = 0, M2 = 0, N1 = 0 } = (0, ramda_1.mapObjIndexed)(xIds => xIds.length, flags);
|
|
59
|
+
// see https://bit.ly/2KKo4rF
|
|
60
|
+
const isSafe = M1 >= 2 ||
|
|
61
|
+
(M1 >= 1 && M2 >= 1) ||
|
|
62
|
+
(M1 >= 1 && N1 >= 1) ||
|
|
63
|
+
(M2 >= 1 && N1 >= 1);
|
|
64
|
+
return { isSafe, flags };
|
|
65
|
+
}
|
|
66
|
+
exports.safeHarbourRequirementsMet = safeHarbourRequirementsMet;
|
|
67
|
+
/**
|
|
68
|
+
* The Safe Harbour Score indidicates whether a person's identity has been verified
|
|
69
|
+
* to the extent requried for Safe Harbour Compliance. This requires multiple verifications
|
|
70
|
+
* from different sources. For information, refer to the
|
|
71
|
+
* {@link https://dev-docs.rayt.io/docs/features/pep-checks Raytio Documentation}.
|
|
72
|
+
*/
|
|
73
|
+
const calcSafeHarbourScore = (data) => getFlags(data).then(safeHarbourRequirementsMet);
|
|
74
|
+
exports.calcSafeHarbourScore = calcSafeHarbourScore;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ProfileObject, Verification, RealVer, UId } from "@raytio/types";
|
|
2
|
+
/**
|
|
3
|
+
* Given a list of verifications and decrypted profile objects, this function
|
|
4
|
+
* locally verifies the credibility of the signatures in the verifications.
|
|
5
|
+
*
|
|
6
|
+
* This function does NOT call the API, except to fetch the public key.
|
|
7
|
+
* @returns a list of authentic RealVer
|
|
8
|
+
*/
|
|
9
|
+
export declare const getOwnRealVerifications: ({ verifications, profileObjects, userId, }: {
|
|
10
|
+
verifications: Verification[];
|
|
11
|
+
profileObjects: ProfileObject[];
|
|
12
|
+
userId: UId;
|
|
13
|
+
}) => Promise<RealVer[]>;
|