@raytio/core 9.0.1 → 10.0.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 +153 -0
- package/README.md +24 -2
- package/dist/accessApplication/index.js +5 -1
- package/dist/crypto/helpers.js +1 -1
- package/dist/crypto/index.js +5 -1
- package/dist/general/index.js +5 -1
- package/dist/index.js +5 -1
- package/dist/rules/calculateScore.d.ts +11 -1
- package/dist/rules/calculateScore.js +24 -3
- package/dist/rules/convertInstanceToRuleInput.js +3 -4
- package/dist/rules/evaluateScoreCondition.js +1 -1
- package/dist/rules/helpers/index.js +5 -1
- package/dist/rules/index.js +5 -1
- package/dist/rules/types/index.js +5 -1
- package/dist/schema/index.js +5 -1
- package/dist/util/canonicalJsonify.js +3 -1
- package/dist/util/index.js +5 -1
- package/dist/verifications/getPOVerification.js +1 -1
- package/dist/verifications/getVerifiedBy.js +1 -1
- package/dist/verifications/index.js +5 -2
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +1 -8
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +2 -7
- package/dist/verifications/verifyCheck/index.d.ts +1 -0
- package/dist/verifications/verifyCheck/index.js +8 -1
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +6 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +14 -6
- package/dist/verifications/verifyCheck/operations/index.js +5 -1
- package/package.json +6 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## 10.0.0 (2022-04-11)
|
|
11
|
+
|
|
12
|
+
- 💥 BREAKING CHANGE: `calculateScore` is now an async function, and returns extra diagnostics.
|
|
13
|
+
|
|
14
|
+
## 9.0.3 (2022-02-22)
|
|
15
|
+
|
|
16
|
+
- fixed a bug which caused valid live persons to show up as Not Verified.
|
|
17
|
+
|
|
18
|
+
## 9.0.2 (2022-02-10)
|
|
19
|
+
|
|
20
|
+
- removed the `UNSAFE_treatNoValueAsVerified` option. This option was never documented or officially supported, so this is not considered a breaking change.
|
|
21
|
+
- use the `date_component` schema field tag in date-related code
|
|
22
|
+
|
|
23
|
+
## 9.0.1 (2022-02-09)
|
|
24
|
+
|
|
25
|
+
- update `@raytio/types` to v6
|
|
26
|
+
|
|
27
|
+
## 9.0.0 (2022-02-01)
|
|
28
|
+
|
|
29
|
+
- 💥 BREAKING CHANGE: the value returned by `getPOVerification` has changed slightly: the `details` property is now an object
|
|
30
|
+
- 💥 BREAKING CHANGE: `getRealVerifications` has been removed. It has been replaced by the following two methods:
|
|
31
|
+
- `getSomeoneElsesRealVerifications` is identical to the former `getRealVerifications` - it requires calling the API
|
|
32
|
+
- `getOwnRealVerifications` verifies the signature locally, but can only be used if you're verifying your own data.
|
|
33
|
+
- create the `calculateScore` and `convertInstanceToRuleInput` for working with SubmissionRules
|
|
34
|
+
- support 1 level of sub-fields in SubmissionRules
|
|
35
|
+
- 💥 BREAKING CHANGE: `getSomeoneElsesRealVerifications` now requires you to supply the `aId` of the submission
|
|
36
|
+
|
|
37
|
+
## 8.1.3 (2021-10-05)
|
|
38
|
+
|
|
39
|
+
- published updated README.md
|
|
40
|
+
|
|
41
|
+
## 8.1.2 (2021-09-24)
|
|
42
|
+
|
|
43
|
+
- update API format for `nId`s that start with `HASHED::`
|
|
44
|
+
- move `cleanInstance` to `@raytio/core`
|
|
45
|
+
|
|
46
|
+
## 8.1.1 (2021-09-15)
|
|
47
|
+
|
|
48
|
+
- fix a bug with `nId`s that start with `HASHED::`
|
|
49
|
+
|
|
50
|
+
## 8.1.0 (2021-08-31)
|
|
51
|
+
|
|
52
|
+
- update `getRealVerifications` to support `nId`s that start with `HASHED::`
|
|
53
|
+
- changed the behaviour of `isConditionMet` when the condition is an empty object. It now returns false in this case
|
|
54
|
+
- use new format for verify_check API
|
|
55
|
+
|
|
56
|
+
## 8.0.0 (2021-07-28)
|
|
57
|
+
|
|
58
|
+
- support conditionally verifiable fields. This only works if the schema is processed by `processSchema`
|
|
59
|
+
- added `isConditionMet` to assit conditionally hidden/required/verifiable fields
|
|
60
|
+
- 💥 BREAKING CHANGE: `getPOVerification` no longer accepts `allSchema` and `schemaName` as an argument, this has been replaced with `schema`.
|
|
61
|
+
- 💥 BREAKING CHANGE: `calcSafeHarbourScore` is now async and no longer accepts `allSchema`, ths has been replaced with an argumnet called `getSchema`.
|
|
62
|
+
|
|
63
|
+
## 7.0.0 (2021-04-07)
|
|
64
|
+
|
|
65
|
+
- 💥 BREAKING CHANGE: (TS) `POVerification` and `FieldVerification` are now enums, not string unions
|
|
66
|
+
- fixed a commonjs export bug in v6.0.1
|
|
67
|
+
|
|
68
|
+
## 6.0.1 (2021-04-06)
|
|
69
|
+
|
|
70
|
+
- update `calcSafeHarbourScore` to ignore duplicate verifications
|
|
71
|
+
|
|
72
|
+
## 6.0.0 (2021-03-05)
|
|
73
|
+
|
|
74
|
+
- 💥 BREAKING CHANGE: `decryptSharedData` now return `instance` and `applicationDecryptor`
|
|
75
|
+
|
|
76
|
+
## 5.0.0 (2021-03-03)
|
|
77
|
+
|
|
78
|
+
- deps: upgrade maxcryptor to `0.3.0`
|
|
79
|
+
- 💥 BREAKING CHANGE: (TS) all IDs (e.g. `n_id`, `a_id`) now use nominal types (e.g. `NId`, `AId`)
|
|
80
|
+
- 💥 BREAKING CHANGE: require TypeScipt@4.2 or later
|
|
81
|
+
|
|
82
|
+
## 4.0.1 (2021-02-05)
|
|
83
|
+
|
|
84
|
+
- fixed an npm publishing issue with `v4.0.0`
|
|
85
|
+
|
|
86
|
+
## 4.0.0 (2021-02-04)
|
|
87
|
+
|
|
88
|
+
- 💥 BREAKING CHANGE: `LABELS_DENYLIST` is no longer exported. It was never documented and there should be no reason to use it. Use `findSchemaLabel` instead.
|
|
89
|
+
- 💥 BREAKING CHANGE: `createAA` should be supplied an `org_id` within the `application` attribute, not as a seperate attribute called `orgId`.
|
|
90
|
+
- 💥 BREAKING CHANGE: `decryptSharedData` no longer needs an `aId` attribute since it can get that information from the `instance` attribute. This isn't a breaking change per-se, but will cause type errors.
|
|
91
|
+
- use `unknown` instead of `any` in some predominantly internal types.
|
|
92
|
+
|
|
93
|
+
## 3.2.2 (2021-01-19)
|
|
94
|
+
|
|
95
|
+
- reverted a bug fix from v3.2.1 which was a work-around for badly formatted data.
|
|
96
|
+
|
|
97
|
+
## 3.2.1 (2021-01-18)
|
|
98
|
+
|
|
99
|
+
- fixed a bug where verified numbers weren't showing up as verified (reverted in v3.2.2)
|
|
100
|
+
- added `onCorruptedData` option to `decryptSharedData`
|
|
101
|
+
|
|
102
|
+
## 3.2.0 (2021-01-06)
|
|
103
|
+
|
|
104
|
+
- added `toCognitoAttributes` and `fromCognitoAttributes`
|
|
105
|
+
- properly handle errors from all API requests
|
|
106
|
+
|
|
107
|
+
## 3.1.0 (2020-12-19)
|
|
108
|
+
|
|
109
|
+
- add function to create an access application (`createAA`)
|
|
110
|
+
|
|
111
|
+
## 3.0.0 (2020-12-17)
|
|
112
|
+
|
|
113
|
+
- 💥 BREAKING CHANGE: change safe harbour calculation to compare against a base person, instead of using relationships
|
|
114
|
+
|
|
115
|
+
## 2.2.0 (2020-12-16)
|
|
116
|
+
|
|
117
|
+
- add Safe Harbour Compliance calculation (`calcSafeHarbourScore`)
|
|
118
|
+
|
|
119
|
+
## 2.1.0 (2020-12-11)
|
|
120
|
+
|
|
121
|
+
- add a new type of [`FieldVerification`](https://www.npmjs.com/package/@raytio/types#fieldverification): `Expired`
|
|
122
|
+
- add a new type of [`POVerification`](https://www.npmjs.com/package/@raytio/types#poverification): `Expired`
|
|
123
|
+
- add a `expired` attribute to [`RealVer`](https://www.npmjs.com/package/@raytio/types#realver).
|
|
124
|
+
- update `getPOVerification` to return `Expired` for verifications where all fields are expired
|
|
125
|
+
- [internal] snapshot tests for auto generated documentation
|
|
126
|
+
|
|
127
|
+
## 2.0.0 (2020-12-07)
|
|
128
|
+
|
|
129
|
+
- 💥 BREAKING CHANGE: support multiple verifications for the same data. This means that the `details` attribute returned by `getPOVerification` is now an array of [`VerificationProvider`](https://www.npmjs.com/package/@raytio/types#verificationprovider), instead of one [`VerificationProvider`](https://www.npmjs.com/package/@raytio/types#verificationprovider).
|
|
130
|
+
|
|
131
|
+
## 1.0.4 (2020-12-06)
|
|
132
|
+
|
|
133
|
+
- fixed a bug where verification details were wrong if the same field name and value were verified by two sources
|
|
134
|
+
- include metadata from the verifier in `RealVer`s
|
|
135
|
+
- fix a bug where verifications for referenced files weren't working
|
|
136
|
+
|
|
137
|
+
## 1.0.3 (2020-11-23)
|
|
138
|
+
|
|
139
|
+
- add `UNSAFE_treatNoValueAsVerified` option to getRealVerifications
|
|
140
|
+
- add `date` to `RealVer` type.
|
|
141
|
+
|
|
142
|
+
## 1.0.2 (2020-11-20)
|
|
143
|
+
|
|
144
|
+
- `findSchemaLabel` can cope with it's argument being undefined.
|
|
145
|
+
- added `"receiverCreated"` to the list of internal labels
|
|
146
|
+
|
|
147
|
+
## 1.0.1 (2020-11-18)
|
|
148
|
+
|
|
149
|
+
- `getRealVerifications` no longer requires an `apiToken` argument, since the API is available without authentication.
|
|
150
|
+
|
|
151
|
+
## 1.0.0 (2020-11-11)
|
|
152
|
+
|
|
153
|
+
First stable release
|
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ If you wish to use `@raytio/core` directly, an example of configuring polyfills
|
|
|
25
25
|
|
|
26
26
|
- [calcSafeHarbourScore](#calcsafeharbourscore)
|
|
27
27
|
- [calculateScore](#calculatescore)
|
|
28
|
+
- [checkJsonSignature](#checkjsonsignature)
|
|
28
29
|
- [cleanInstance](#cleaninstance)
|
|
29
30
|
- [convertInstanceToRuleInput](#convertinstancetoruleinput)
|
|
30
31
|
- [createAA](#createaa)
|
|
@@ -94,7 +95,7 @@ ___
|
|
|
94
95
|
|
|
95
96
|
### calculateScore
|
|
96
97
|
|
|
97
|
-
▸ **calculateScore**(`ruleConfig`, `ruleInput`): `ScoreResult
|
|
98
|
+
▸ **calculateScore**(`ruleConfig`, `ruleInput`): `Promise`<`ScoreResult`\>
|
|
98
99
|
|
|
99
100
|
the main function to calculate a score and category.
|
|
100
101
|
Might throw an error.
|
|
@@ -108,7 +109,28 @@ Might throw an error.
|
|
|
108
109
|
|
|
109
110
|
#### Returns
|
|
110
111
|
|
|
111
|
-
`ScoreResult
|
|
112
|
+
`Promise`<`ScoreResult`\>
|
|
113
|
+
|
|
114
|
+
___
|
|
115
|
+
|
|
116
|
+
### checkJsonSignature
|
|
117
|
+
|
|
118
|
+
▸ `Const` **checkJsonSignature**(`data`, `signature`): `Promise`<`boolean`\>
|
|
119
|
+
|
|
120
|
+
checks that a json object was signed by the provided signature. Unless you're
|
|
121
|
+
dealing with bundled verifications, you should use `getOwnRealVerifications`
|
|
122
|
+
or `getSomeoneElsesRealVerifications` instead.
|
|
123
|
+
|
|
124
|
+
#### Parameters
|
|
125
|
+
|
|
126
|
+
| Name | Type |
|
|
127
|
+
| :------ | :------ |
|
|
128
|
+
| `data` | `unknown` |
|
|
129
|
+
| `signature` | `string` |
|
|
130
|
+
|
|
131
|
+
#### Returns
|
|
132
|
+
|
|
133
|
+
`Promise`<`boolean`\>
|
|
112
134
|
|
|
113
135
|
___
|
|
114
136
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/crypto/helpers.js
CHANGED
|
@@ -17,7 +17,7 @@ exports.isEncrypted = isEncrypted;
|
|
|
17
17
|
* @param value anything
|
|
18
18
|
* @returns true or false depending on whether the input is an encrypted Raytio file
|
|
19
19
|
*/
|
|
20
|
-
const isEncryptedFile = (value) => { var _a, _b; return (0, exports.isEncrypted)(value) && ((_b = (_a = value === null || value === void 0 ? void 0 : value.encrypted_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.
|
|
20
|
+
const isEncryptedFile = (value) => { var _a, _b; return (0, exports.isEncrypted)(value) && ((_b = (_a = value === null || value === void 0 ? void 0 : value.encrypted_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.slice(0, 4)) === "urn:"; };
|
|
21
21
|
exports.isEncryptedFile = isEncryptedFile;
|
|
22
22
|
/**
|
|
23
23
|
* Given a profile object's properties, returns the number
|
package/dist/crypto/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/general/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -3,9 +3,19 @@ import { RuleData, ScoreConfig } from "./types";
|
|
|
3
3
|
export declare type ScoreResult = {
|
|
4
4
|
score: number;
|
|
5
5
|
category: string;
|
|
6
|
+
diagnostics: {
|
|
7
|
+
config: {
|
|
8
|
+
id: string;
|
|
9
|
+
rules: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
passed: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
6
16
|
};
|
|
7
17
|
/**
|
|
8
18
|
* the main function to calculate a score and category.
|
|
9
19
|
* Might throw an error.
|
|
10
20
|
*/
|
|
11
|
-
export declare function calculateScore(ruleConfig: ScoreConfig, ruleInput: RuleData): ScoreResult
|
|
21
|
+
export declare function calculateScore(ruleConfig: ScoreConfig, ruleInput: RuleData): Promise<ScoreResult>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.calculateScore = void 0;
|
|
4
4
|
const evaluateScoreCondition_1 = require("./evaluateScoreCondition");
|
|
5
5
|
const helpers_1 = require("./helpers");
|
|
6
|
+
const general_1 = require("../general");
|
|
6
7
|
function evaluateASTNode(node, data) {
|
|
7
8
|
if (node.type === "LanguageOperator") {
|
|
8
9
|
if (!node.children.length) {
|
|
@@ -27,16 +28,26 @@ function evaluateRule(rule, data) {
|
|
|
27
28
|
throw new Error("A rule may only have 1 root node");
|
|
28
29
|
}
|
|
29
30
|
const rulePassed = rule.tree.every(n => evaluateASTNode(n, data));
|
|
30
|
-
return
|
|
31
|
+
return {
|
|
32
|
+
passed: rulePassed,
|
|
33
|
+
score: rulePassed ? rule.trueWeight : rule.falseWeight,
|
|
34
|
+
};
|
|
31
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* We guarantee that the same configId or ruleId will always produce the same output.
|
|
38
|
+
* This is the closest thing we have to versioning.
|
|
39
|
+
*/
|
|
40
|
+
const jsonId = (json) => (0, general_1.hashPassword)(JSON.stringify(json)).then(hash => hash.slice(0, 10));
|
|
32
41
|
/**
|
|
33
42
|
* the main function to calculate a score and category.
|
|
34
43
|
* Might throw an error.
|
|
35
44
|
*/
|
|
36
|
-
function calculateScore(ruleConfig, ruleInput) {
|
|
45
|
+
async function calculateScore(ruleConfig, ruleInput) {
|
|
37
46
|
const result = ruleConfig.rules.map(rule => evaluateRule(rule, ruleInput));
|
|
38
47
|
const [addOrMultiply, initialValue] = (0, helpers_1.getCombinator)(ruleConfig.combinator);
|
|
39
|
-
const finalScore = result
|
|
48
|
+
const finalScore = result
|
|
49
|
+
.map(x => x.score)
|
|
50
|
+
.reduce(addOrMultiply, initialValue);
|
|
40
51
|
const matchingCategories = (0, helpers_1.addInfiniteThresholdBoundaries)(ruleConfig.scoreThresholds).filter(threshold => finalScore >= threshold.from && finalScore <= threshold.to);
|
|
41
52
|
if (matchingCategories.length === 0) {
|
|
42
53
|
throw new Error(`No categories match the final score (${finalScore})`);
|
|
@@ -47,6 +58,16 @@ function calculateScore(ruleConfig, ruleInput) {
|
|
|
47
58
|
return {
|
|
48
59
|
score: finalScore,
|
|
49
60
|
category: matchingCategories[0].name,
|
|
61
|
+
diagnostics: {
|
|
62
|
+
config: {
|
|
63
|
+
id: await jsonId(ruleConfig),
|
|
64
|
+
rules: await Promise.all(result.map(async ({ passed }, i) => {
|
|
65
|
+
const r = ruleConfig.rules[i];
|
|
66
|
+
const ruleId = await jsonId(r);
|
|
67
|
+
return { id: ruleId, name: r.name, passed };
|
|
68
|
+
})),
|
|
69
|
+
},
|
|
70
|
+
},
|
|
50
71
|
};
|
|
51
72
|
}
|
|
52
73
|
exports.calculateScore = calculateScore;
|
|
@@ -72,10 +72,9 @@ const convertInstanceToRuleInput = async (instance, realVers, getSchema) => {
|
|
|
72
72
|
memberFieldNames.includes(x.fieldName) &&
|
|
73
73
|
x.provider.verifierNId)) === null || _a === void 0 ? void 0 : _a.map(v => v.provider.verifierNId).filter((val) => !!val));
|
|
74
74
|
const values = Object.fromEntries(members);
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const yearFieldName = memberFieldNames.find(f => f.includes("year"));
|
|
75
|
+
const dayFieldName = memberFieldNames.find(f => { var _a; return (_a = schema.properties[f].tags) === null || _a === void 0 ? void 0 : _a.includes("date_component:day"); });
|
|
76
|
+
const monthFieldName = memberFieldNames.find(f => { var _a; return (_a = schema.properties[f].tags) === null || _a === void 0 ? void 0 : _a.includes("date_component:month"); });
|
|
77
|
+
const yearFieldName = memberFieldNames.find(f => { var _a; return (_a = schema.properties[f].tags) === null || _a === void 0 ? void 0 : _a.includes("date_component:year"); });
|
|
79
78
|
if (!dayFieldName || !monthFieldName || !yearFieldName) {
|
|
80
79
|
throw new Error("Failed to infer date component field");
|
|
81
80
|
}
|
|
@@ -27,7 +27,7 @@ function evaluateScoreCondition(node, data) {
|
|
|
27
27
|
const values = rawValues[i];
|
|
28
28
|
if (!values.length) {
|
|
29
29
|
// TODO: if one of the values required for your rule doesn't exist, then what?
|
|
30
|
-
// for now, the rule will return
|
|
30
|
+
// for now, the rule will return false.
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
33
|
// also check if the claimed type of the value matches the actual type of the value
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/rules/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/schema/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -28,8 +28,10 @@ function copyObjectWithSortedKeys(object) {
|
|
|
28
28
|
return `[${object.map(copyObjectWithSortedKeys).join(",")}]`;
|
|
29
29
|
}
|
|
30
30
|
if (typeof object === "number" && object % 1 !== 0) {
|
|
31
|
+
if (Number.isNaN(object) || !Number.isFinite(object))
|
|
32
|
+
return "null";
|
|
31
33
|
// float
|
|
32
|
-
const exponent = Math.
|
|
34
|
+
const exponent = Math.floor(Math.log10(Math.abs(object)));
|
|
33
35
|
let mantissa = `${object / 10 ** exponent}`;
|
|
34
36
|
if (!mantissa.includes("."))
|
|
35
37
|
mantissa += ".0";
|
package/dist/util/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -43,7 +43,7 @@ function getPOVerification({ PO, schema, realVers, }) {
|
|
|
43
43
|
const fieldVerifications = (0, ramda_1.mapObjIndexed)((content, fieldName) => {
|
|
44
44
|
const pertainingVers = realVers.filter(x => x.fieldName === fieldName &&
|
|
45
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)) &&
|
|
46
|
+
(0, ramda_1.equals)((0, maybeRereference_1.maybeRereference)(x.value), (0, maybeRereference_1.maybeRereference)(content)) &&
|
|
47
47
|
// if an nId is supplied, also filter out verifications that don't relate to that n_id
|
|
48
48
|
(PO.n_id ? x.belongsToNId === PO.n_id : true));
|
|
49
49
|
// .every() illogically returns true for arrays with zero length
|
|
@@ -10,7 +10,7 @@ const getVerifiedBy = ({ nId, realVers, shouldBeVerifiedProps, }) => {
|
|
|
10
10
|
const pertainingVers = realVers
|
|
11
11
|
.filter(x => mayBeVerifiedFields.includes(x.fieldName) &&
|
|
12
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) &&
|
|
13
|
+
(0, ramda_1.equals)((0, maybeRereference_1.maybeRereference)(shouldBeVerifiedProps[x.fieldName]), (0, maybeRereference_1.maybeRereference)(x.value)) &&
|
|
14
14
|
// if an nId is supplied, also filter out verifications that don't relate to that n_id
|
|
15
15
|
(nId ? x.belongsToNId === nId : true))
|
|
16
16
|
.map(x => x.provider);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
// not exporting checkVerifications; it's not a public API
|
|
14
17
|
__exportStar(require("./cleanInstance"), exports);
|
|
15
18
|
__exportStar(require("./getPOVerification"), exports);
|
|
16
19
|
__exportStar(require("./verifyCheck"), exports);
|
|
@@ -5,13 +5,6 @@ declare type Props = {
|
|
|
5
5
|
verifications: Verification[];
|
|
6
6
|
profileObjects: ProfileObject[];
|
|
7
7
|
controller?: AbortController;
|
|
8
|
-
/**
|
|
9
|
-
* do NOT use this option. If the value of a field
|
|
10
|
-
* equals the value of this prop, that field will be treated
|
|
11
|
-
* as verified, even if the API says it's not verified. See
|
|
12
|
-
* #614 for context. @deprecated
|
|
13
|
-
*/
|
|
14
|
-
UNSAFE_treatNoValueAsVerified?: string;
|
|
15
8
|
};
|
|
16
9
|
/**
|
|
17
10
|
* Given a list of verifications and decrypted profile objects, this function calls
|
|
@@ -22,5 +15,5 @@ declare type Props = {
|
|
|
22
15
|
*
|
|
23
16
|
* @returns a list of fileNames/values that are verified.
|
|
24
17
|
*/
|
|
25
|
-
export declare const getSomeoneElsesRealVerifications: ({ aId, apiUrl, verifications, profileObjects, controller,
|
|
18
|
+
export declare const getSomeoneElsesRealVerifications: ({ aId, apiUrl, verifications, profileObjects, controller, }: Props) => Promise<RealVer[]>;
|
|
26
19
|
export {};
|
|
@@ -17,7 +17,7 @@ POs.map(x => { var _a; return (_a = x.properties) === null || _a === void 0 ? vo
|
|
|
17
17
|
*
|
|
18
18
|
* @returns a list of fileNames/values that are verified.
|
|
19
19
|
*/
|
|
20
|
-
const getSomeoneElsesRealVerifications = async ({ aId, apiUrl, verifications, profileObjects, controller,
|
|
20
|
+
const getSomeoneElsesRealVerifications = async ({ aId, apiUrl, verifications, profileObjects, controller, }) => {
|
|
21
21
|
// for each verification (including passed: false), create a list of every possible that
|
|
22
22
|
// value that that verification might have been for. Flatten the list
|
|
23
23
|
// and send the whole thing to the API.
|
|
@@ -46,12 +46,7 @@ const getSomeoneElsesRealVerifications = async ({ aId, apiUrl, verifications, pr
|
|
|
46
46
|
// do NOT expose the `verified` prop from the /verify_check API to avoid semantic confusion,
|
|
47
47
|
// since verified: true does not mean that the verification is verified!
|
|
48
48
|
const realVers = apiResponse
|
|
49
|
-
.filter(x => x.verified
|
|
50
|
-
// if UNSAFE_treatNoValueAsVerified is enabled, and we don't know the value of this field,
|
|
51
|
-
// treat is as verified if the `passed` property is true (this is NOT a safe check).
|
|
52
|
-
(!!UNSAFE_treatNoValueAsVerified &&
|
|
53
|
-
x.data.value === UNSAFE_treatNoValueAsVerified &&
|
|
54
|
-
x.data.passed))
|
|
49
|
+
.filter(x => x.verified)
|
|
55
50
|
.map(({ signature, data, n_id: nID, valid_until }) => ({
|
|
56
51
|
fieldName: data.field,
|
|
57
52
|
value: data.value,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.checkJsonSignature = void 0;
|
|
13
18
|
__exportStar(require("./getOwnRealVerifications"), exports);
|
|
14
19
|
__exportStar(require("./getSomeoneElsesRealVerifications"), exports);
|
|
20
|
+
var operations_1 = require("./operations");
|
|
21
|
+
Object.defineProperty(exports, "checkJsonSignature", { enumerable: true, get: function () { return operations_1.checkJsonSignature; } });
|
|
@@ -5,5 +5,11 @@ declare type SingleVerToCheck = {
|
|
|
5
5
|
userId: UId;
|
|
6
6
|
value: unknown;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* checks that a json object was signed by the provided signature. Unless you're
|
|
10
|
+
* dealing with bundled verifications, you should use `getOwnRealVerifications`
|
|
11
|
+
* or `getSomeoneElsesRealVerifications` instead.
|
|
12
|
+
*/
|
|
13
|
+
export declare const checkJsonSignature: (data: unknown, signature: string) => Promise<boolean>;
|
|
8
14
|
export declare const checkOwnVerification: ({ verObject, signature, userId, value, }: SingleVerToCheck) => Promise<boolean>;
|
|
9
15
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkOwnVerification = exports.checkSignature = void 0;
|
|
3
|
+
exports.checkOwnVerification = exports.checkJsonSignature = exports.checkSignature = void 0;
|
|
4
4
|
const util_1 = require("../../../util");
|
|
5
5
|
let cache; // eslint-disable-line fp/no-let
|
|
6
6
|
const base64ToArrayBuffer = (str) => Uint8Array.from(atob(str), c => c.charCodeAt(0));
|
|
@@ -19,13 +19,21 @@ async function checkSignature(publicCryptoKey, signature, data) {
|
|
|
19
19
|
return isVerified;
|
|
20
20
|
}
|
|
21
21
|
exports.checkSignature = checkSignature;
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* checks that a json object was signed by the provided signature. Unless you're
|
|
24
|
+
* dealing with bundled verifications, you should use `getOwnRealVerifications`
|
|
25
|
+
* or `getSomeoneElsesRealVerifications` instead.
|
|
26
|
+
*/
|
|
27
|
+
const checkJsonSignature = async (data, signature) => {
|
|
23
28
|
const jwk = await getJwk();
|
|
24
|
-
|
|
25
|
-
throw new Error("No userId supplied");
|
|
26
|
-
const exapandedObject = Object.assign(Object.assign({}, verObject), { sub: userId, value });
|
|
27
|
-
const stringified = (0, util_1.canonicalJsonify)(exapandedObject);
|
|
29
|
+
const stringified = (0, util_1.canonicalJsonify)(data);
|
|
28
30
|
const result = await checkSignature(jwk, signature, stringified);
|
|
29
31
|
return result;
|
|
30
32
|
};
|
|
33
|
+
exports.checkJsonSignature = checkJsonSignature;
|
|
34
|
+
const checkOwnVerification = async ({ verObject, signature, userId, value, }) => {
|
|
35
|
+
if (!userId)
|
|
36
|
+
throw new Error("No userId supplied");
|
|
37
|
+
return (0, exports.checkJsonSignature)(Object.assign(Object.assign({}, verObject), { sub: userId, value }), signature);
|
|
38
|
+
};
|
|
31
39
|
exports.checkOwnVerification = checkOwnVerification;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytio/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"types": "index",
|
|
7
7
|
"files": [
|
|
8
8
|
"index.js",
|
|
9
9
|
"index.d.ts",
|
|
10
|
+
"CHANGELOG.md",
|
|
10
11
|
"dist"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
@@ -16,14 +17,14 @@
|
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"@raytio/maxcryptor": "3.1.0",
|
|
19
|
-
"@raytio/types": "6.0.
|
|
20
|
+
"@raytio/types": "6.0.1",
|
|
20
21
|
"ramda": "0.28.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@types/ramda": "0.
|
|
24
|
-
"jest": "27.
|
|
24
|
+
"@types/ramda": "0.28.11",
|
|
25
|
+
"jest": "27.5.1",
|
|
25
26
|
"localstorage-polyfill": "1.0.1",
|
|
26
|
-
"ts-jest": "27.1.
|
|
27
|
+
"ts-jest": "27.1.4"
|
|
27
28
|
},
|
|
28
29
|
"jest": {
|
|
29
30
|
"transform": {
|