@raytio/core 10.1.0 → 11.1.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 +10 -0
- package/README.md +198 -59
- package/dist/{util/hash.d.ts → __tests__/docs.test.d.ts} +1 -1
- package/dist/__tests__/docs.test.js +24 -0
- package/dist/accessApplication/createAA.d.ts +17 -17
- package/dist/accessApplication/createAA.js +71 -71
- package/dist/accessApplication/index.d.ts +1 -1
- package/dist/accessApplication/index.js +17 -17
- 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 -33
- package/dist/crypto/decryptSharedData.d.ts +26 -26
- package/dist/crypto/decryptSharedData.js +38 -38
- package/dist/crypto/getAADecryptor.d.ts +16 -16
- 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 +21 -21
- package/dist/general/conditional.d.ts +17 -17
- package/dist/general/conditional.js +32 -32
- package/dist/general/date.d.ts +2 -2
- package/dist/general/date.js +18 -18
- package/dist/general/index.d.ts +4 -4
- package/dist/general/index.js +20 -20
- package/dist/general/password.d.ts +10 -10
- package/dist/general/password.js +31 -31
- package/dist/general/types.d.ts +6 -6
- package/dist/general/types.js +13 -13
- package/dist/index.d.ts +6 -6
- package/dist/index.js +22 -22
- package/dist/rules/calculateScore.d.ts +28 -23
- package/dist/rules/calculateScore.js +82 -76
- package/dist/rules/convertInstanceToRuleInput.d.ts +3 -3
- package/dist/rules/convertInstanceToRuleInput.js +138 -139
- package/dist/rules/evaluateScoreCondition.d.ts +2 -2
- package/dist/rules/evaluateScoreCondition.js +44 -45
- package/dist/{verifications/checkVerifications.d.ts → rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.d.ts} +1 -1
- package/dist/rules/helpers/__tests__/addInfiniteThresholdBoundaries.test.js +27 -0
- package/dist/{verifications/checkVerificationsNew.d.ts → rules/helpers/__tests__/checkTypeofValue.test.d.ts} +1 -1
- package/dist/rules/helpers/__tests__/checkTypeofValue.test.js +49 -0
- package/dist/{verifications/verifyCheck/util/canonicalJsonify.d.ts → rules/helpers/__tests__/getValuesFromPath.test.d.ts} +1 -1
- package/dist/rules/helpers/__tests__/getValuesFromPath.test.js +67 -0
- package/dist/rules/helpers/__tests__/thresholds.test.d.ts +1 -0
- package/dist/rules/helpers/__tests__/thresholds.test.js +32 -0
- package/dist/rules/helpers/addInfiniteThresholdBoundaries.d.ts +8 -8
- package/dist/rules/helpers/addInfiniteThresholdBoundaries.js +11 -11
- package/dist/rules/helpers/checkTypeofValue.d.ts +9 -9
- package/dist/rules/helpers/checkTypeofValue.js +60 -55
- package/dist/rules/helpers/getValuesFromPath.d.ts +3 -3
- package/dist/rules/helpers/getValuesFromPath.js +50 -50
- package/dist/rules/helpers/index.d.ts +5 -5
- package/dist/rules/helpers/index.js +21 -21
- package/dist/rules/helpers/symbols.d.ts +2 -2
- package/dist/rules/helpers/symbols.js +5 -5
- package/dist/rules/helpers/thresholds.d.ts +5 -5
- package/dist/rules/helpers/thresholds.js +46 -47
- package/dist/rules/index.d.ts +7 -7
- package/dist/rules/index.js +25 -25
- package/dist/rules/operators/__tests__/bool.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/bool.test.js +21 -0
- package/dist/rules/operators/__tests__/date.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/date.test.js +81 -0
- package/dist/rules/operators/__tests__/hfield.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/hfield.test.js +38 -0
- package/dist/rules/operators/__tests__/hschema.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/hschema.test.js +24 -0
- package/dist/rules/operators/__tests__/number.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/number.test.js +53 -0
- package/dist/rules/operators/__tests__/string.test.d.ts +1 -0
- package/dist/rules/operators/__tests__/string.test.js +74 -0
- package/dist/rules/operators/bool.d.ts +2 -2
- package/dist/rules/operators/bool.js +17 -17
- package/dist/rules/operators/date.d.ts +2 -2
- package/dist/rules/operators/date.js +91 -91
- package/dist/rules/operators/hfield.d.ts +2 -2
- package/dist/rules/operators/hfield.js +33 -33
- package/dist/rules/operators/hschema.d.ts +2 -2
- package/dist/rules/operators/hschema.js +21 -21
- package/dist/rules/operators/index.d.ts +3 -3
- package/dist/rules/operators/index.js +11 -11
- package/dist/rules/operators/number.d.ts +2 -2
- package/dist/rules/operators/number.js +41 -41
- package/dist/rules/operators/string.d.ts +2 -2
- package/dist/rules/operators/string.js +58 -58
- package/dist/rules/types/config.d.ts +95 -91
- package/dist/rules/types/config.js +2 -2
- package/dist/rules/types/dataValueTypes.d.ts +19 -19
- package/dist/rules/types/dataValueTypes.js +4 -4
- package/dist/rules/types/index.d.ts +3 -3
- package/dist/rules/types/index.js +19 -19
- package/dist/rules/types/internal.d.ts +20 -20
- package/dist/rules/types/internal.js +2 -2
- package/dist/rules/validate.d.ts +6 -6
- package/dist/rules/validate.js +14 -14
- package/dist/rules/version.d.ts +1 -1
- package/dist/rules/version.js +5 -5
- package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.d.ts +1 -0
- package/dist/schema/expandSchema/__tests__/addLoadingTimes.test.js +24 -0
- package/dist/schema/expandSchema/__tests__/expandSchema.test.d.ts +1 -0
- package/dist/schema/expandSchema/__tests__/expandSchema.test.js +95 -0
- package/dist/schema/expandSchema/__tests__/i18n.test.d.ts +1 -0
- package/dist/schema/expandSchema/__tests__/i18n.test.js +32 -0
- package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.d.ts +1 -0
- package/dist/schema/expandSchema/__tests__/maybeUseI18n.test.js +98 -0
- package/dist/schema/expandSchema/__tests__/processSchema.test.d.ts +1 -0
- package/dist/schema/expandSchema/__tests__/processSchema.test.js +326 -0
- package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.d.ts +1 -0
- package/dist/schema/expandSchema/__tests__/sortSchemaProperties.test.js +182 -0
- package/dist/schema/expandSchema/__tests__/util.test.d.ts +1 -0
- package/dist/schema/expandSchema/__tests__/util.test.js +19 -0
- package/dist/schema/expandSchema/addLoadingTimes.d.ts +2 -0
- package/dist/schema/expandSchema/addLoadingTimes.js +12 -0
- package/dist/schema/expandSchema/constants.d.ts +2 -0
- package/dist/schema/expandSchema/constants.js +11 -0
- package/dist/schema/expandSchema/expandSchema.d.ts +7 -0
- package/dist/schema/expandSchema/expandSchema.js +19 -0
- package/dist/schema/expandSchema/i18n.d.ts +5 -0
- package/dist/schema/expandSchema/i18n.js +20 -0
- package/dist/schema/expandSchema/index.d.ts +3 -0
- package/dist/schema/expandSchema/index.js +21 -0
- package/dist/schema/expandSchema/maybeUseI18n.d.ts +2 -0
- package/dist/schema/expandSchema/maybeUseI18n.js +40 -0
- package/dist/schema/expandSchema/processSchema.d.ts +4 -0
- package/dist/schema/expandSchema/processSchema.js +94 -0
- package/dist/schema/expandSchema/removePrivateFields.d.ts +119 -0
- package/dist/schema/expandSchema/removePrivateFields.js +15 -0
- package/dist/schema/expandSchema/sortSchemaProperties.d.ts +21 -0
- package/dist/schema/expandSchema/sortSchemaProperties.js +40 -0
- package/dist/schema/expandSchema/unwrapSchema.d.ts +6 -0
- package/dist/schema/expandSchema/unwrapSchema.js +7 -0
- package/dist/schema/expandSchema/util.d.ts +6 -0
- package/dist/schema/expandSchema/util.js +15 -0
- package/dist/schema/index.d.ts +2 -1
- package/dist/schema/index.js +18 -17
- package/dist/schema/labels.d.ts +2 -2
- package/dist/schema/labels.js +20 -20
- package/dist/util/canonicalJsonify.d.ts +1 -1
- package/dist/util/canonicalJsonify.js +50 -50
- package/dist/util/handleResponse.d.ts +1 -1
- package/dist/util/handleResponse.js +21 -21
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.js +18 -18
- package/dist/verifications/cleanInstance.d.ts +9 -9
- package/dist/verifications/cleanInstance.js +15 -15
- package/dist/verifications/getPOVerification.d.ts +19 -16
- package/dist/verifications/getPOVerification.js +105 -94
- package/dist/verifications/getVerifiedBy.d.ts +1 -1
- package/dist/verifications/getVerifiedBy.js +19 -19
- package/dist/verifications/index.d.ts +5 -5
- package/dist/verifications/index.js +21 -21
- 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 +67 -74
- package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.d.ts +1 -0
- package/dist/verifications/verifyCheck/__tests__/getOwnRealVerifications.test.js +152 -0
- package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.d.ts +1 -0
- package/dist/verifications/verifyCheck/__tests__/getSomeoneElsesRealVerifications.test.js +205 -0
- package/dist/verifications/verifyCheck/getOwnRealVerifications.d.ts +13 -13
- package/dist/verifications/verifyCheck/getOwnRealVerifications.js +66 -64
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.d.ts +19 -19
- package/dist/verifications/verifyCheck/getSomeoneElsesRealVerifications.js +72 -72
- package/dist/verifications/verifyCheck/index.d.ts +3 -3
- package/dist/verifications/verifyCheck/index.js +21 -21
- package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.d.ts +1 -0
- package/dist/verifications/verifyCheck/operations/__tests__/checkOwnVerification.test.js +91 -0
- package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.d.ts +1 -0
- package/dist/verifications/verifyCheck/operations/__tests__/checkSomeoneElsesVerifications.test.js +49 -0
- package/dist/verifications/verifyCheck/operations/__tests__/sampleBundle.json +43 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +15 -15
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +39 -39
- package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.d.ts +1 -1
- package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.js +16 -16
- package/dist/verifications/verifyCheck/operations/index.d.ts +2 -2
- package/dist/verifications/verifyCheck/operations/index.js +18 -18
- package/package.json +13 -10
- package/dist/rules/helpers/getLhsTypeofValue.d.ts +0 -0
- package/dist/rules/helpers/getLhsTypeofValue.js +0 -1
- package/dist/rules/helpers/getValueFromPath.d.ts +0 -2
- package/dist/rules/helpers/getValueFromPath.js +0 -35
- package/dist/rules/helpers/rebuildInfiniteValues.d.ts +0 -3
- package/dist/rules/helpers/rebuildInfiniteValues.js +0 -6
- package/dist/rules/isScoreResultValid.d.ts +0 -2
- package/dist/rules/isScoreResultValid.js +0 -9
- package/dist/rules/operators/array.d.ts +0 -2
- package/dist/rules/operators/array.js +0 -74
- package/dist/rules/types/operators.d.ts +0 -19
- package/dist/rules/types/operators.js +0 -2
- package/dist/rules/types/score.d.ts +0 -50
- package/dist/rules/types/score.js +0 -2
- package/dist/util/conditional.d.ts +0 -7
- package/dist/util/conditional.js +0 -15
- package/dist/util/hash.js +0 -11
- package/dist/verifications/checkSingleVerification.d.ts +0 -9
- package/dist/verifications/checkSingleVerification.js +0 -29
- package/dist/verifications/checkVerifications.js +0 -16
- package/dist/verifications/checkVerificationsNew.js +0 -16
- package/dist/verifications/getOwnRealVerifications.d.ts +0 -14
- package/dist/verifications/getOwnRealVerifications.js +0 -64
- package/dist/verifications/getRealVerifications.d.ts +0 -22
- package/dist/verifications/getRealVerifications.js +0 -71
- package/dist/verifications/verifyCheck/util/canonicalJsonify.js +0 -48
- package/dist/verifications/verifyCheck/util/getValuesForAField.d.ts +0 -2
- package/dist/verifications/verifyCheck/util/getValuesForAField.js +0 -9
- package/dist/verifications/verifyCheck/util/index.d.ts +0 -2
- package/dist/verifications/verifyCheck/util/index.js +0 -14
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAA = void 0;
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
/** @internal */
|
|
6
|
-
const createApplication = ({ apiUrl, apiToken, application, }) => fetch(`${apiUrl}/share/v2/access_application`, {
|
|
7
|
-
method: "POST",
|
|
8
|
-
body: JSON.stringify(application),
|
|
9
|
-
headers: { Authorization: `Bearer ${apiToken}` },
|
|
10
|
-
}).then(util_1.handleResponse);
|
|
11
|
-
/** @internal */
|
|
12
|
-
const createApplicationPublicKey = async ({ apiUrl, apiToken, aId, publicKey, }) => {
|
|
13
|
-
const PO = await fetch(`${apiUrl}/share/v2/access_application/${aId}/public_key`, {
|
|
14
|
-
method: "POST",
|
|
15
|
-
body: JSON.stringify({ a_id: aId, key: publicKey }),
|
|
16
|
-
headers: { Authorization: `Bearer ${apiToken}` },
|
|
17
|
-
}).then(util_1.handleResponse);
|
|
18
|
-
return { publicKeyNId: PO.n_id };
|
|
19
|
-
};
|
|
20
|
-
/** @internal */
|
|
21
|
-
const createApplicationEncryptedPrivateKey = ({ apiUrl, apiToken, publicKeyNId, encryptedPrivateKey, }) => fetch(`${apiUrl}/share/v2/access_application/public_key/${publicKeyNId}/private_key`, {
|
|
22
|
-
method: "POST",
|
|
23
|
-
body: JSON.stringify({ n_id: publicKeyNId, key: encryptedPrivateKey }),
|
|
24
|
-
headers: { Authorization: `Bearer ${apiToken}` },
|
|
25
|
-
}).then(util_1.handleResponse);
|
|
26
|
-
/** @internal */
|
|
27
|
-
async function createApplicationEncryptor(userDoc, maxcryptor) {
|
|
28
|
-
const applicationEncryptor = await maxcryptor.createApplicationEncryptor();
|
|
29
|
-
// The exported public key should be available for everyone
|
|
30
|
-
const publicKey = await applicationEncryptor.exportPublicKey();
|
|
31
|
-
// Encrypt the private key for the current user
|
|
32
|
-
const encryptedPrivateKey = await applicationEncryptor.encryptPrivateKey(userDoc.encryption_key_pair.public_key);
|
|
33
|
-
return {
|
|
34
|
-
applicationEncryptor,
|
|
35
|
-
publicKey,
|
|
36
|
-
encryptedPrivateKey,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Creates an Access Application and associated public+private keys.
|
|
41
|
-
*
|
|
42
|
-
* The user must be part of an organization, and you need to include the `orgId`.
|
|
43
|
-
*
|
|
44
|
-
* You must also supply an apiToken and an instance of the maxcryptor for that user,
|
|
45
|
-
* as well as the `userDoc` data which is stored in the user's cognito attributes.
|
|
46
|
-
*/
|
|
47
|
-
async function createAA({ apiUrl, apiToken, userDoc, maxcryptor, application, }) {
|
|
48
|
-
if (!application.org_id) {
|
|
49
|
-
throw new Error("Cannot create an AA without an org_id");
|
|
50
|
-
}
|
|
51
|
-
const newApp = await createApplication({
|
|
52
|
-
apiUrl,
|
|
53
|
-
apiToken,
|
|
54
|
-
application,
|
|
55
|
-
});
|
|
56
|
-
const { publicKey, encryptedPrivateKey } = await createApplicationEncryptor(userDoc, maxcryptor);
|
|
57
|
-
const { publicKeyNId } = await createApplicationPublicKey({
|
|
58
|
-
apiUrl,
|
|
59
|
-
apiToken,
|
|
60
|
-
aId: newApp.a_id,
|
|
61
|
-
publicKey,
|
|
62
|
-
});
|
|
63
|
-
await createApplicationEncryptedPrivateKey({
|
|
64
|
-
apiUrl,
|
|
65
|
-
apiToken,
|
|
66
|
-
publicKeyNId,
|
|
67
|
-
encryptedPrivateKey,
|
|
68
|
-
});
|
|
69
|
-
return newApp;
|
|
70
|
-
}
|
|
71
|
-
exports.createAA = createAA;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAA = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
/** @internal */
|
|
6
|
+
const createApplication = ({ apiUrl, apiToken, application, }) => fetch(`${apiUrl}/share/v2/access_application`, {
|
|
7
|
+
method: "POST",
|
|
8
|
+
body: JSON.stringify(application),
|
|
9
|
+
headers: { Authorization: `Bearer ${apiToken}` },
|
|
10
|
+
}).then(util_1.handleResponse);
|
|
11
|
+
/** @internal */
|
|
12
|
+
const createApplicationPublicKey = async ({ apiUrl, apiToken, aId, publicKey, }) => {
|
|
13
|
+
const PO = await fetch(`${apiUrl}/share/v2/access_application/${aId}/public_key`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
body: JSON.stringify({ a_id: aId, key: publicKey }),
|
|
16
|
+
headers: { Authorization: `Bearer ${apiToken}` },
|
|
17
|
+
}).then(util_1.handleResponse);
|
|
18
|
+
return { publicKeyNId: PO.n_id };
|
|
19
|
+
};
|
|
20
|
+
/** @internal */
|
|
21
|
+
const createApplicationEncryptedPrivateKey = ({ apiUrl, apiToken, publicKeyNId, encryptedPrivateKey, }) => fetch(`${apiUrl}/share/v2/access_application/public_key/${publicKeyNId}/private_key`, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
body: JSON.stringify({ n_id: publicKeyNId, key: encryptedPrivateKey }),
|
|
24
|
+
headers: { Authorization: `Bearer ${apiToken}` },
|
|
25
|
+
}).then(util_1.handleResponse);
|
|
26
|
+
/** @internal */
|
|
27
|
+
async function createApplicationEncryptor(userDoc, maxcryptor) {
|
|
28
|
+
const applicationEncryptor = await maxcryptor.createApplicationEncryptor();
|
|
29
|
+
// The exported public key should be available for everyone
|
|
30
|
+
const publicKey = await applicationEncryptor.exportPublicKey();
|
|
31
|
+
// Encrypt the private key for the current user
|
|
32
|
+
const encryptedPrivateKey = await applicationEncryptor.encryptPrivateKey(userDoc.encryption_key_pair.public_key);
|
|
33
|
+
return {
|
|
34
|
+
applicationEncryptor,
|
|
35
|
+
publicKey,
|
|
36
|
+
encryptedPrivateKey,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an Access Application and associated public+private keys.
|
|
41
|
+
*
|
|
42
|
+
* The user must be part of an organization, and you need to include the `orgId`.
|
|
43
|
+
*
|
|
44
|
+
* You must also supply an apiToken and an instance of the maxcryptor for that user,
|
|
45
|
+
* as well as the `userDoc` data which is stored in the user's cognito attributes.
|
|
46
|
+
*/
|
|
47
|
+
async function createAA({ apiUrl, apiToken, userDoc, maxcryptor, application, }) {
|
|
48
|
+
if (!application.org_id) {
|
|
49
|
+
throw new Error("Cannot create an AA without an org_id");
|
|
50
|
+
}
|
|
51
|
+
const newApp = await createApplication({
|
|
52
|
+
apiUrl,
|
|
53
|
+
apiToken,
|
|
54
|
+
application,
|
|
55
|
+
});
|
|
56
|
+
const { publicKey, encryptedPrivateKey } = await createApplicationEncryptor(userDoc, maxcryptor);
|
|
57
|
+
const { publicKeyNId } = await createApplicationPublicKey({
|
|
58
|
+
apiUrl,
|
|
59
|
+
apiToken,
|
|
60
|
+
aId: newApp.a_id,
|
|
61
|
+
publicKey,
|
|
62
|
+
});
|
|
63
|
+
await createApplicationEncryptedPrivateKey({
|
|
64
|
+
apiUrl,
|
|
65
|
+
apiToken,
|
|
66
|
+
publicKeyNId,
|
|
67
|
+
encryptedPrivateKey,
|
|
68
|
+
});
|
|
69
|
+
return newApp;
|
|
70
|
+
}
|
|
71
|
+
exports.createAA = createAA;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./createAA";
|
|
1
|
+
export * from "./createAA";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./createAA"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./createAA"), exports);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { UserDoc } from "@raytio/maxcryptor";
|
|
2
|
-
import type { ICognitoUserAttributeData } from "amazon-cognito-identity-js";
|
|
3
|
-
/**
|
|
4
|
-
* Given a `UserDoc` from the maxcryptor, this returns an object
|
|
5
|
-
* which you can provide to `Auth.updateUserAttributes()`. It is
|
|
6
|
-
* an object of stringified Json.
|
|
7
|
-
*/
|
|
8
|
-
export declare const toCognitoAttributes: (userDoc: UserDoc) => {
|
|
9
|
-
[customCognitoName: string]: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* This function converts Cognito's userAttributes into a maxcryptor UserDoc.
|
|
13
|
-
* The userAttributes come from `const attributes = await Auth.userAttributes(user)`
|
|
14
|
-
*/
|
|
15
|
-
export declare const fromCognitoAttributes: (attributes: ICognitoUserAttributeData[]) => UserDoc;
|
|
1
|
+
import { UserDoc } from "@raytio/maxcryptor";
|
|
2
|
+
import type { ICognitoUserAttributeData } from "amazon-cognito-identity-js";
|
|
3
|
+
/**
|
|
4
|
+
* Given a `UserDoc` from the maxcryptor, this returns an object
|
|
5
|
+
* which you can provide to `Auth.updateUserAttributes()`. It is
|
|
6
|
+
* an object of stringified Json.
|
|
7
|
+
*/
|
|
8
|
+
export declare const toCognitoAttributes: (userDoc: UserDoc) => {
|
|
9
|
+
[customCognitoName: string]: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* This function converts Cognito's userAttributes into a maxcryptor UserDoc.
|
|
13
|
+
* The userAttributes come from `const attributes = await Auth.userAttributes(user)`
|
|
14
|
+
*/
|
|
15
|
+
export declare const fromCognitoAttributes: (attributes: ICognitoUserAttributeData[]) => UserDoc;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fromCognitoAttributes = exports.toCognitoAttributes = void 0;
|
|
4
|
-
const ramda_1 = require("ramda");
|
|
5
|
-
const ATTRIBUTE_MAP = {
|
|
6
|
-
"custom:kek_derivation": ["kek_derivation_config"],
|
|
7
|
-
"custom:dek_encryption": ["private_key_encryption_config"],
|
|
8
|
-
"custom:aek_public": ["encryption_key_pair", "public_key"],
|
|
9
|
-
"custom:aek_private": ["encryption_key_pair", "private_key"],
|
|
10
|
-
"custom:ask_public": ["signing_key_pair", "public_key"],
|
|
11
|
-
"custom:ask_private": ["signing_key_pair", "private_key"],
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Given a `UserDoc` from the maxcryptor, this returns an object
|
|
15
|
-
* which you can provide to `Auth.updateUserAttributes()`. It is
|
|
16
|
-
* an object of stringified Json.
|
|
17
|
-
*/
|
|
18
|
-
const toCognitoAttributes = (userDoc) => Object.fromEntries(Object.entries(ATTRIBUTE_MAP).map(([cognitoKey, deepPath]) => [
|
|
19
|
-
cognitoKey,
|
|
20
|
-
JSON.stringify((0, ramda_1.path)(deepPath, userDoc)),
|
|
21
|
-
]));
|
|
22
|
-
exports.toCognitoAttributes = toCognitoAttributes;
|
|
23
|
-
/**
|
|
24
|
-
* This function converts Cognito's userAttributes into a maxcryptor UserDoc.
|
|
25
|
-
* The userAttributes come from `const attributes = await Auth.userAttributes(user)`
|
|
26
|
-
*/
|
|
27
|
-
const fromCognitoAttributes = (attributes) => attributes.reduce((ac, { Name, Value }) => {
|
|
28
|
-
const maybePath = ATTRIBUTE_MAP[Name];
|
|
29
|
-
if (!maybePath)
|
|
30
|
-
return ac; // we don't know about this attribute
|
|
31
|
-
return (0, ramda_1.assocPath)(maybePath, JSON.parse(Value), ac);
|
|
32
|
-
}, {});
|
|
33
|
-
exports.fromCognitoAttributes = fromCognitoAttributes;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromCognitoAttributes = exports.toCognitoAttributes = void 0;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
const ATTRIBUTE_MAP = {
|
|
6
|
+
"custom:kek_derivation": ["kek_derivation_config"],
|
|
7
|
+
"custom:dek_encryption": ["private_key_encryption_config"],
|
|
8
|
+
"custom:aek_public": ["encryption_key_pair", "public_key"],
|
|
9
|
+
"custom:aek_private": ["encryption_key_pair", "private_key"],
|
|
10
|
+
"custom:ask_public": ["signing_key_pair", "public_key"],
|
|
11
|
+
"custom:ask_private": ["signing_key_pair", "private_key"],
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Given a `UserDoc` from the maxcryptor, this returns an object
|
|
15
|
+
* which you can provide to `Auth.updateUserAttributes()`. It is
|
|
16
|
+
* an object of stringified Json.
|
|
17
|
+
*/
|
|
18
|
+
const toCognitoAttributes = (userDoc) => Object.fromEntries(Object.entries(ATTRIBUTE_MAP).map(([cognitoKey, deepPath]) => [
|
|
19
|
+
cognitoKey,
|
|
20
|
+
JSON.stringify((0, ramda_1.path)(deepPath, userDoc)),
|
|
21
|
+
]));
|
|
22
|
+
exports.toCognitoAttributes = toCognitoAttributes;
|
|
23
|
+
/**
|
|
24
|
+
* This function converts Cognito's userAttributes into a maxcryptor UserDoc.
|
|
25
|
+
* The userAttributes come from `const attributes = await Auth.userAttributes(user)`
|
|
26
|
+
*/
|
|
27
|
+
const fromCognitoAttributes = (attributes) => attributes.reduce((ac, { Name, Value }) => {
|
|
28
|
+
const maybePath = ATTRIBUTE_MAP[Name];
|
|
29
|
+
if (!maybePath)
|
|
30
|
+
return ac; // we don't know about this attribute
|
|
31
|
+
return (0, ramda_1.assocPath)(maybePath, JSON.parse(Value), ac);
|
|
32
|
+
}, {});
|
|
33
|
+
exports.fromCognitoAttributes = fromCognitoAttributes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decryptKeys = void 0;
|
|
4
|
-
const helpers_1 = require("./helpers");
|
|
5
|
-
/** @internal */
|
|
6
|
-
const decryptKeys = async ({ applicationDecryptor, keys, data, onCorruptedData, }) => {
|
|
7
|
-
const KVPairs = await Promise.all(Object.entries(data).map(async ([key, value]) => {
|
|
8
|
-
var _a;
|
|
9
|
-
if (!(0, helpers_1.isEncrypted)(value))
|
|
10
|
-
return [key, value];
|
|
11
|
-
const encryptedDecryptionKey = (_a = keys === null || keys === void 0 ? void 0 : keys[key]) === null || _a === void 0 ? void 0 : _a.data;
|
|
12
|
-
if (!encryptedDecryptionKey) {
|
|
13
|
-
const error = new Error(`Can't decrypt shared data because there are no keys for ${key}`);
|
|
14
|
-
if (onCorruptedData)
|
|
15
|
-
return [key, onCorruptedData(key, value, error)];
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
return [
|
|
20
|
-
key,
|
|
21
|
-
await applicationDecryptor.decrypt(value, encryptedDecryptionKey),
|
|
22
|
-
];
|
|
23
|
-
}
|
|
24
|
-
catch (_ex) {
|
|
25
|
-
const error = _ex instanceof Error ? _ex : new Error(`${_ex}`);
|
|
26
|
-
if (onCorruptedData)
|
|
27
|
-
return [key, onCorruptedData(key, value, error)];
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
31
|
-
return Object.fromEntries(KVPairs);
|
|
32
|
-
};
|
|
33
|
-
exports.decryptKeys = decryptKeys;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decryptKeys = void 0;
|
|
4
|
+
const helpers_1 = require("./helpers");
|
|
5
|
+
/** @internal */
|
|
6
|
+
const decryptKeys = async ({ applicationDecryptor, keys, data, onCorruptedData, }) => {
|
|
7
|
+
const KVPairs = await Promise.all(Object.entries(data).map(async ([key, value]) => {
|
|
8
|
+
var _a;
|
|
9
|
+
if (!(0, helpers_1.isEncrypted)(value))
|
|
10
|
+
return [key, value];
|
|
11
|
+
const encryptedDecryptionKey = (_a = keys === null || keys === void 0 ? void 0 : keys[key]) === null || _a === void 0 ? void 0 : _a.data;
|
|
12
|
+
if (!encryptedDecryptionKey) {
|
|
13
|
+
const error = new Error(`Can't decrypt shared data because there are no keys for ${key}`);
|
|
14
|
+
if (onCorruptedData)
|
|
15
|
+
return [key, onCorruptedData(key, value, error)];
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
return [
|
|
20
|
+
key,
|
|
21
|
+
await applicationDecryptor.decrypt(value, encryptedDecryptionKey),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
catch (_ex) {
|
|
25
|
+
const error = _ex instanceof Error ? _ex : new Error(`${_ex}`);
|
|
26
|
+
if (onCorruptedData)
|
|
27
|
+
return [key, onCorruptedData(key, value, error)];
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
return Object.fromEntries(KVPairs);
|
|
32
|
+
};
|
|
33
|
+
exports.decryptKeys = decryptKeys;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Maxcryptor, ApplicationEncryptor } from "@raytio/maxcryptor";
|
|
2
|
-
import { Encrypted, Instance } from "@raytio/types";
|
|
3
|
-
/**
|
|
4
|
-
* Decrypts any encrypted properties included in the supplied `instanceData`.
|
|
5
|
-
* If nothing is encrypted the supplied `instanceData` is returned.
|
|
6
|
-
*
|
|
7
|
-
* It will reject if there are keys missing for any encrypted properties, or
|
|
8
|
-
* if the encrypted data is invalid. If you don't want it to reject, you can
|
|
9
|
-
* supply a `onCorruptedData` function which returns a value to use instead.
|
|
10
|
-
*
|
|
11
|
-
* @returns a copy of `instanceData` with all properties decrypted.
|
|
12
|
-
*/
|
|
13
|
-
export declare const decryptSharedData: ({ instanceData, maxcryptor, apiUrl, apiToken, onCorruptedData, }: {
|
|
14
|
-
instanceData: Instance;
|
|
15
|
-
maxcryptor: Maxcryptor;
|
|
16
|
-
apiUrl: string;
|
|
17
|
-
apiToken: string;
|
|
18
|
-
/**
|
|
19
|
-
* If you supply a function, it will be called instead of throwing an error,
|
|
20
|
-
* and the value you return will be used instead of the corrupted field value.
|
|
21
|
-
*/
|
|
22
|
-
onCorruptedData?: ((fieldName: string, fieldValue: Encrypted, error: Error) => any) | undefined;
|
|
23
|
-
}) => Promise<{
|
|
24
|
-
instance: Instance;
|
|
25
|
-
applicationDecryptor: ApplicationEncryptor;
|
|
26
|
-
}>;
|
|
1
|
+
import { Maxcryptor, ApplicationEncryptor } from "@raytio/maxcryptor";
|
|
2
|
+
import { Encrypted, Instance } from "@raytio/types";
|
|
3
|
+
/**
|
|
4
|
+
* Decrypts any encrypted properties included in the supplied `instanceData`.
|
|
5
|
+
* If nothing is encrypted the supplied `instanceData` is returned.
|
|
6
|
+
*
|
|
7
|
+
* It will reject if there are keys missing for any encrypted properties, or
|
|
8
|
+
* if the encrypted data is invalid. If you don't want it to reject, you can
|
|
9
|
+
* supply a `onCorruptedData` function which returns a value to use instead.
|
|
10
|
+
*
|
|
11
|
+
* @returns a copy of `instanceData` with all properties decrypted.
|
|
12
|
+
*/
|
|
13
|
+
export declare const decryptSharedData: ({ instanceData, maxcryptor, apiUrl, apiToken, onCorruptedData, }: {
|
|
14
|
+
instanceData: Instance;
|
|
15
|
+
maxcryptor: Maxcryptor;
|
|
16
|
+
apiUrl: string;
|
|
17
|
+
apiToken: string;
|
|
18
|
+
/**
|
|
19
|
+
* If you supply a function, it will be called instead of throwing an error,
|
|
20
|
+
* and the value you return will be used instead of the corrupted field value.
|
|
21
|
+
*/
|
|
22
|
+
onCorruptedData?: ((fieldName: string, fieldValue: Encrypted, error: Error) => any) | undefined;
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
instance: Instance;
|
|
25
|
+
applicationDecryptor: ApplicationEncryptor;
|
|
26
|
+
}>;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decryptSharedData = void 0;
|
|
4
|
-
const getAADecryptor_1 = require("./getAADecryptor");
|
|
5
|
-
const decryptKeys_1 = require("./decryptKeys");
|
|
6
|
-
/**
|
|
7
|
-
* Decrypts any encrypted properties included in the supplied `instanceData`.
|
|
8
|
-
* If nothing is encrypted the supplied `instanceData` is returned.
|
|
9
|
-
*
|
|
10
|
-
* It will reject if there are keys missing for any encrypted properties, or
|
|
11
|
-
* if the encrypted data is invalid. If you don't want it to reject, you can
|
|
12
|
-
* supply a `onCorruptedData` function which returns a value to use instead.
|
|
13
|
-
*
|
|
14
|
-
* @returns a copy of `instanceData` with all properties decrypted.
|
|
15
|
-
*/
|
|
16
|
-
const decryptSharedData = async ({ instanceData, maxcryptor, apiUrl, apiToken, onCorruptedData, }) => {
|
|
17
|
-
const { decryptor: applicationDecryptor } = await (0, getAADecryptor_1.getAADecryptor)({
|
|
18
|
-
aId: instanceData.a_id,
|
|
19
|
-
maxcryptor,
|
|
20
|
-
apiUrl,
|
|
21
|
-
apiToken,
|
|
22
|
-
});
|
|
23
|
-
const instance = Object.assign(Object.assign({}, instanceData), { profile_objects: await Promise.all(instanceData.profile_objects.map(async (PO) => {
|
|
24
|
-
const realNId = PO.n_id.startsWith("HASHED::")
|
|
25
|
-
? PO.n_id.split("::")[1]
|
|
26
|
-
: PO.n_id;
|
|
27
|
-
const keys = instanceData.keys[realNId];
|
|
28
|
-
const decryptedProperties = await (0, decryptKeys_1.decryptKeys)({
|
|
29
|
-
applicationDecryptor,
|
|
30
|
-
keys,
|
|
31
|
-
data: PO.properties,
|
|
32
|
-
onCorruptedData,
|
|
33
|
-
});
|
|
34
|
-
return Object.assign(Object.assign({}, PO), { properties: decryptedProperties });
|
|
35
|
-
})) });
|
|
36
|
-
return { instance, applicationDecryptor };
|
|
37
|
-
};
|
|
38
|
-
exports.decryptSharedData = decryptSharedData;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decryptSharedData = void 0;
|
|
4
|
+
const getAADecryptor_1 = require("./getAADecryptor");
|
|
5
|
+
const decryptKeys_1 = require("./decryptKeys");
|
|
6
|
+
/**
|
|
7
|
+
* Decrypts any encrypted properties included in the supplied `instanceData`.
|
|
8
|
+
* If nothing is encrypted the supplied `instanceData` is returned.
|
|
9
|
+
*
|
|
10
|
+
* It will reject if there are keys missing for any encrypted properties, or
|
|
11
|
+
* if the encrypted data is invalid. If you don't want it to reject, you can
|
|
12
|
+
* supply a `onCorruptedData` function which returns a value to use instead.
|
|
13
|
+
*
|
|
14
|
+
* @returns a copy of `instanceData` with all properties decrypted.
|
|
15
|
+
*/
|
|
16
|
+
const decryptSharedData = async ({ instanceData, maxcryptor, apiUrl, apiToken, onCorruptedData, }) => {
|
|
17
|
+
const { decryptor: applicationDecryptor } = await (0, getAADecryptor_1.getAADecryptor)({
|
|
18
|
+
aId: instanceData.a_id,
|
|
19
|
+
maxcryptor,
|
|
20
|
+
apiUrl,
|
|
21
|
+
apiToken,
|
|
22
|
+
});
|
|
23
|
+
const instance = Object.assign(Object.assign({}, instanceData), { profile_objects: await Promise.all(instanceData.profile_objects.map(async (PO) => {
|
|
24
|
+
const realNId = PO.n_id.startsWith("HASHED::")
|
|
25
|
+
? PO.n_id.split("::")[1]
|
|
26
|
+
: PO.n_id;
|
|
27
|
+
const keys = instanceData.keys[realNId];
|
|
28
|
+
const decryptedProperties = await (0, decryptKeys_1.decryptKeys)({
|
|
29
|
+
applicationDecryptor,
|
|
30
|
+
keys,
|
|
31
|
+
data: PO.properties,
|
|
32
|
+
onCorruptedData,
|
|
33
|
+
});
|
|
34
|
+
return Object.assign(Object.assign({}, PO), { properties: decryptedProperties });
|
|
35
|
+
})) });
|
|
36
|
+
return { instance, applicationDecryptor };
|
|
37
|
+
};
|
|
38
|
+
exports.decryptSharedData = decryptSharedData;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ApplicationEncryptor, Maxcryptor } from "@raytio/maxcryptor";
|
|
2
|
-
import { NId, AId } from "@raytio/types";
|
|
3
|
-
/**
|
|
4
|
-
* Fetchs the public and private keys for an Access Application, then initializes
|
|
5
|
-
* the {@link https://npm.im/@raytio/maxcryptor|Maxcryptor}'s `ApplicationEncryptor`.
|
|
6
|
-
* @returns an `ApplicationEncryptor` and the public key of the Access Application
|
|
7
|
-
*/
|
|
8
|
-
export declare function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }: {
|
|
9
|
-
aId: AId;
|
|
10
|
-
apiUrl: string;
|
|
11
|
-
maxcryptor: Maxcryptor;
|
|
12
|
-
apiToken: string;
|
|
13
|
-
}): Promise<{
|
|
14
|
-
decryptor: ApplicationEncryptor;
|
|
15
|
-
publicKeyNId: NId;
|
|
16
|
-
}>;
|
|
1
|
+
import { ApplicationEncryptor, Maxcryptor } from "@raytio/maxcryptor";
|
|
2
|
+
import { NId, AId } from "@raytio/types";
|
|
3
|
+
/**
|
|
4
|
+
* Fetchs the public and private keys for an Access Application, then initializes
|
|
5
|
+
* the {@link https://npm.im/@raytio/maxcryptor|Maxcryptor}'s `ApplicationEncryptor`.
|
|
6
|
+
* @returns an `ApplicationEncryptor` and the public key of the Access Application
|
|
7
|
+
*/
|
|
8
|
+
export declare function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }: {
|
|
9
|
+
aId: AId;
|
|
10
|
+
apiUrl: string;
|
|
11
|
+
maxcryptor: Maxcryptor;
|
|
12
|
+
apiToken: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
decryptor: ApplicationEncryptor;
|
|
15
|
+
publicKeyNId: NId;
|
|
16
|
+
}>;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAADecryptor = void 0;
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
/**
|
|
6
|
-
* Fetchs the public and private keys for an Access Application, then initializes
|
|
7
|
-
* the {@link https://npm.im/@raytio/maxcryptor|Maxcryptor}'s `ApplicationEncryptor`.
|
|
8
|
-
* @returns an `ApplicationEncryptor` and the public key of the Access Application
|
|
9
|
-
*/
|
|
10
|
-
async function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }) {
|
|
11
|
-
const { n_id: publicKeyNId, properties: publicKey } = (await fetch(`${apiUrl}/share/v2/access_application/${aId}/public_key`, {
|
|
12
|
-
headers: { Authorization: `Bearer ${apiToken}` },
|
|
13
|
-
}).then(util_1.handleResponse));
|
|
14
|
-
const privateKey = await fetch(`${apiUrl}/share/v2/access_application/public_key/${publicKeyNId}/private_key`, { headers: { Authorization: `Bearer ${apiToken}` } }).then(util_1.handleResponse);
|
|
15
|
-
return {
|
|
16
|
-
decryptor: await maxcryptor.loadApplicationEncryptorForDecryption(publicKey, privateKey),
|
|
17
|
-
publicKeyNId,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
exports.getAADecryptor = getAADecryptor;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAADecryptor = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
/**
|
|
6
|
+
* Fetchs the public and private keys for an Access Application, then initializes
|
|
7
|
+
* the {@link https://npm.im/@raytio/maxcryptor|Maxcryptor}'s `ApplicationEncryptor`.
|
|
8
|
+
* @returns an `ApplicationEncryptor` and the public key of the Access Application
|
|
9
|
+
*/
|
|
10
|
+
async function getAADecryptor({ aId, apiUrl, maxcryptor, apiToken, }) {
|
|
11
|
+
const { n_id: publicKeyNId, properties: publicKey } = (await fetch(`${apiUrl}/share/v2/access_application/${aId}/public_key`, {
|
|
12
|
+
headers: { Authorization: `Bearer ${apiToken}` },
|
|
13
|
+
}).then(util_1.handleResponse));
|
|
14
|
+
const privateKey = await fetch(`${apiUrl}/share/v2/access_application/public_key/${publicKeyNId}/private_key`, { headers: { Authorization: `Bearer ${apiToken}` } }).then(util_1.handleResponse);
|
|
15
|
+
return {
|
|
16
|
+
decryptor: await maxcryptor.loadApplicationEncryptorForDecryption(publicKey, privateKey),
|
|
17
|
+
publicKeyNId,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.getAADecryptor = getAADecryptor;
|
package/dist/crypto/helpers.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Encrypted } from "@raytio/types";
|
|
2
|
-
/**
|
|
3
|
-
* Determines where the input is an encrypted Raytio object
|
|
4
|
-
* @param value anything
|
|
5
|
-
* @returns true or false depending on whether the input is an encrypted Raytio object
|
|
6
|
-
*/
|
|
7
|
-
export declare const isEncrypted: (value: unknown) => value is Encrypted
|
|
8
|
-
/**
|
|
9
|
-
* Determines where the input is an encrypted Raytio file
|
|
10
|
-
* @param value anything
|
|
11
|
-
* @returns true or false depending on whether the input is an encrypted Raytio file
|
|
12
|
-
*/
|
|
13
|
-
export declare const isEncryptedFile: (value: unknown) => value is Encrypted
|
|
14
|
-
/**
|
|
15
|
-
* Given a profile object's properties, returns the number
|
|
16
|
-
* of properties that are encryted.
|
|
17
|
-
*/
|
|
18
|
-
export declare const someEncrypted: <T extends object, K extends keyof T>(obj: T) => number;
|
|
1
|
+
import { Encrypted } from "@raytio/types";
|
|
2
|
+
/**
|
|
3
|
+
* Determines where the input is an encrypted Raytio object
|
|
4
|
+
* @param value anything
|
|
5
|
+
* @returns true or false depending on whether the input is an encrypted Raytio object
|
|
6
|
+
*/
|
|
7
|
+
export declare const isEncrypted: (value: unknown) => value is Encrypted;
|
|
8
|
+
/**
|
|
9
|
+
* Determines where the input is an encrypted Raytio file
|
|
10
|
+
* @param value anything
|
|
11
|
+
* @returns true or false depending on whether the input is an encrypted Raytio file
|
|
12
|
+
*/
|
|
13
|
+
export declare const isEncryptedFile: (value: unknown) => value is Encrypted;
|
|
14
|
+
/**
|
|
15
|
+
* Given a profile object's properties, returns the number
|
|
16
|
+
* of properties that are encryted.
|
|
17
|
+
*/
|
|
18
|
+
export declare const someEncrypted: <T extends object, K extends keyof T>(obj: T) => number;
|