@raytio/core 8.1.2 → 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 +482 -1
- package/dist/accessApplication/createAA.js +0 -1
- package/dist/crypto/decryptKeys.js +0 -2
- package/dist/crypto/helpers.d.ts +1 -1
- package/dist/general/index.d.ts +1 -0
- package/dist/general/index.js +1 -0
- package/dist/general/types.d.ts +6 -0
- package/dist/general/types.js +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- 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 +139 -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/{verifications/checkVerifications.d.ts → util/canonicalJsonify.d.ts} +0 -0
- package/dist/util/canonicalJsonify.js +48 -0
- package/dist/util/handleResponse.js +0 -1
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +1 -0
- package/dist/verifications/getPOVerification.d.ts +5 -2
- package/dist/verifications/getPOVerification.js +3 -4
- package/dist/verifications/index.d.ts +1 -1
- package/dist/verifications/index.js +1 -2
- package/dist/verifications/safeHarbour.d.ts +1 -1
- package/dist/verifications/safeHarbour.js +2 -2
- package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +13 -0
- package/dist/verifications/verifyCheck/getOwnRealVerifications.js +63 -0
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +19 -0
- package/dist/verifications/{getRealVerifications.js → verifyCheck/getSomeoneElsesRealVerifications.js} +21 -19
- package/dist/verifications/verifyCheck/index.d.ts +3 -0
- package/dist/verifications/verifyCheck/index.js +17 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +15 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +39 -0
- package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.d.ts +1 -0
- package/dist/verifications/{checkVerifications.js → verifyCheck/operations/checkSomeoneElsesVerifications.js} +4 -4
- 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/verifications/getRealVerifications.d.ts +0 -22
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UId, VerificationPayload } from "@raytio/types";
|
|
2
|
+
declare type SingleVerToCheck = {
|
|
3
|
+
verObject: VerificationPayload<false>;
|
|
4
|
+
signature: string;
|
|
5
|
+
userId: UId;
|
|
6
|
+
value: unknown;
|
|
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>;
|
|
14
|
+
export declare const checkOwnVerification: ({ verObject, signature, userId, value, }: SingleVerToCheck) => Promise<boolean>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkOwnVerification = exports.checkJsonSignature = exports.checkSignature = void 0;
|
|
4
|
+
const util_1 = require("../../../util");
|
|
5
|
+
let cache; // eslint-disable-line fp/no-let
|
|
6
|
+
const base64ToArrayBuffer = (str) => Uint8Array.from(atob(str), c => c.charCodeAt(0));
|
|
7
|
+
async function getJwk() {
|
|
8
|
+
// eslint-disable-next-line fp/no-mutation
|
|
9
|
+
cache || (cache = fetch("https://api-docs.rayt.io/lookups/raytio.pem")
|
|
10
|
+
.then(r => r.text())
|
|
11
|
+
.then(pem => crypto.subtle.importKey("spki", base64ToArrayBuffer(pem.split("-----")[2].trim()), { name: "RSA-PSS", hash: "SHA-512" }, false, ["verify"])));
|
|
12
|
+
return cache;
|
|
13
|
+
}
|
|
14
|
+
/** @internal exported only for tests */
|
|
15
|
+
async function checkSignature(publicCryptoKey, signature, data) {
|
|
16
|
+
// the logic must match https://gitlab.com/raytio/mono/-/blob/devo/common/signing/signing/sign.py
|
|
17
|
+
const signatureBuf = base64ToArrayBuffer(signature);
|
|
18
|
+
const isVerified = await crypto.subtle.verify({ name: "RSA-PSS", hash: "SHA-512", saltLength: 512 / 8 }, publicCryptoKey, signatureBuf, new TextEncoder().encode(data));
|
|
19
|
+
return isVerified;
|
|
20
|
+
}
|
|
21
|
+
exports.checkSignature = checkSignature;
|
|
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) => {
|
|
28
|
+
const jwk = await getJwk();
|
|
29
|
+
const stringified = (0, util_1.canonicalJsonify)(data);
|
|
30
|
+
const result = await checkSignature(jwk, signature, stringified);
|
|
31
|
+
return result;
|
|
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
|
+
};
|
|
39
|
+
exports.checkOwnVerification = checkOwnVerification;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const util_1 = require("
|
|
3
|
+
exports.checkSomeoneElsesVerifications = void 0;
|
|
4
|
+
const util_1 = require("../../../util");
|
|
5
5
|
/** @internal */
|
|
6
|
-
const
|
|
6
|
+
const checkSomeoneElsesVerifications = async ({ apiUrl, toVerify, controller, }) => {
|
|
7
7
|
const response = await fetch(`${apiUrl}/extract_verify/v2/verify_check`, {
|
|
8
8
|
method: "POST",
|
|
9
9
|
body: JSON.stringify(toVerify),
|
|
@@ -13,4 +13,4 @@ const checkVerifications = async ({ apiUrl, toVerify, controller, }) => {
|
|
|
13
13
|
// extra `m` items are garbage and don't have the verified field.
|
|
14
14
|
return response.filter(ver => "verified" in ver);
|
|
15
15
|
};
|
|
16
|
-
exports.
|
|
16
|
+
exports.checkSomeoneElsesVerifications = checkSomeoneElsesVerifications;
|
|
@@ -0,0 +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("./checkOwnVerification"), exports);
|
|
14
|
+
__exportStar(require("./checkSomeoneElsesVerifications"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytio/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"types": "index",
|
|
@@ -15,22 +15,22 @@
|
|
|
15
15
|
"test": "jest"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@raytio/maxcryptor": "3.0
|
|
19
|
-
"@raytio/types": "
|
|
20
|
-
"ramda": "0.
|
|
18
|
+
"@raytio/maxcryptor": "3.1.0",
|
|
19
|
+
"@raytio/types": "6.0.0",
|
|
20
|
+
"ramda": "0.28.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/ramda": "0.27.
|
|
24
|
-
"jest": "27.1
|
|
23
|
+
"@types/ramda": "0.27.64",
|
|
24
|
+
"jest": "27.5.1",
|
|
25
25
|
"localstorage-polyfill": "1.0.1",
|
|
26
|
-
"ts-jest": "27.
|
|
26
|
+
"ts-jest": "27.1.3"
|
|
27
27
|
},
|
|
28
28
|
"jest": {
|
|
29
29
|
"transform": {
|
|
30
30
|
"^.+\\.(t|j)sx?$": "ts-jest"
|
|
31
31
|
},
|
|
32
32
|
"testEnvironment": "node",
|
|
33
|
-
"collectCoverage":
|
|
33
|
+
"collectCoverage": false,
|
|
34
34
|
"coverageThreshold": {
|
|
35
35
|
"global": {
|
|
36
36
|
"statements": 100
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ProfileObject, Verification, RealVer } from "@raytio/types";
|
|
2
|
-
declare type Props = {
|
|
3
|
-
apiUrl: string;
|
|
4
|
-
verifications: Verification[];
|
|
5
|
-
profileObjects: ProfileObject[];
|
|
6
|
-
controller?: AbortController;
|
|
7
|
-
/**
|
|
8
|
-
* do NOT use this option. If the value of a field
|
|
9
|
-
* equals the value of this prop, that field will be treated
|
|
10
|
-
* as verified, even if the API says it's not verified. See
|
|
11
|
-
* #614 for context. @deprecated
|
|
12
|
-
*/
|
|
13
|
-
UNSAFE_treatNoValueAsVerified?: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Given a list of verifications and decrypted profile objects, this function calls
|
|
17
|
-
* the Raytio API to verify the credibility of these verifications, returning only valid
|
|
18
|
-
* verifications.
|
|
19
|
-
* @returns a list of fileNames/values that are verified.
|
|
20
|
-
*/
|
|
21
|
-
export declare const getRealVerifications: ({ apiUrl, verifications, profileObjects, controller, UNSAFE_treatNoValueAsVerified, }: Props) => Promise<RealVer[]>;
|
|
22
|
-
export {};
|