@raytio/core 9.0.1 → 9.0.2
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 +22 -0
- package/dist/rules/convertInstanceToRuleInput.js +3 -4
- package/dist/verifications/index.js +0 -1
- 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 +3 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +6 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +14 -6
- package/package.json +2 -2
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)
|
|
@@ -112,6 +113,27 @@ Might throw an error.
|
|
|
112
113
|
|
|
113
114
|
___
|
|
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`\>
|
|
134
|
+
|
|
135
|
+
___
|
|
136
|
+
|
|
115
137
|
### cleanInstance
|
|
116
138
|
|
|
117
139
|
▸ **cleanInstance**(`instance`): `Instance`
|
|
@@ -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
|
}
|
|
@@ -10,7 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
// not exporting checkVerifications; it's not a public API
|
|
14
13
|
__exportStar(require("./cleanInstance"), exports);
|
|
15
14
|
__exportStar(require("./getPOVerification"), exports);
|
|
16
15
|
__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,
|
|
@@ -10,5 +10,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.checkJsonSignature = void 0;
|
|
13
14
|
__exportStar(require("./getOwnRealVerifications"), exports);
|
|
14
15
|
__exportStar(require("./getSomeoneElsesRealVerifications"), exports);
|
|
16
|
+
var operations_1 = require("./operations");
|
|
17
|
+
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytio/core",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"types": "index",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/ramda": "0.27.64",
|
|
24
|
-
"jest": "27.
|
|
24
|
+
"jest": "27.5.1",
|
|
25
25
|
"localstorage-polyfill": "1.0.1",
|
|
26
26
|
"ts-jest": "27.1.3"
|
|
27
27
|
},
|