@raytio/core 10.1.0 → 11.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 +6 -0
- package/README.md +100 -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/index.d.ts +1 -1
- package/dist/schema/index.js +17 -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 +74 -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
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## 11.0.0 (2022-04-20)
|
|
11
|
+
|
|
12
|
+
- 💥 BREAKING CHANGE: Changed the input arguments of `convertInstanceToRuleInput` to only require a list of `ProfileObject`s, instead of the whole `Instance` object.
|
|
13
|
+
- Any profile object with an expired field is now considered `Expired`, even if other fields are verified.
|
|
14
|
+
- Fix the `valid_until` attribute being ignored on verifications
|
|
15
|
+
|
|
10
16
|
## 10.1.0 (2022-07-06)
|
|
11
17
|
|
|
12
18
|
- move `repairDate` into core, and use it when processing verifications
|
package/README.md
CHANGED
|
@@ -16,10 +16,11 @@ If you wish to use `@raytio/core` directly, an example of configuring polyfills
|
|
|
16
16
|
|
|
17
17
|
## Table of contents
|
|
18
18
|
|
|
19
|
-
### Type
|
|
19
|
+
### Type Aliases
|
|
20
20
|
|
|
21
21
|
- [SafeHarbourObj](#safeharbourobj)
|
|
22
22
|
- [SafeHarbourResult](#safeharbourresult)
|
|
23
|
+
- [VerDetails](#verdetails)
|
|
23
24
|
|
|
24
25
|
### Functions
|
|
25
26
|
|
|
@@ -30,6 +31,7 @@ If you wish to use `@raytio/core` directly, an example of configuring polyfills
|
|
|
30
31
|
- [convertInstanceToRuleInput](#convertinstancetoruleinput)
|
|
31
32
|
- [createAA](#createaa)
|
|
32
33
|
- [decryptSharedData](#decryptshareddata)
|
|
34
|
+
- [evaluateRule](#evaluaterule)
|
|
33
35
|
- [findSchemaLabel](#findschemalabel)
|
|
34
36
|
- [fromCognitoAttributes](#fromcognitoattributes)
|
|
35
37
|
- [getAADecryptor](#getaadecryptor)
|
|
@@ -46,7 +48,7 @@ If you wish to use `@raytio/core` directly, an example of configuring polyfills
|
|
|
46
48
|
- [someEncrypted](#someencrypted)
|
|
47
49
|
- [toCognitoAttributes](#tocognitoattributes)
|
|
48
50
|
|
|
49
|
-
## Type
|
|
51
|
+
## Type Aliases
|
|
50
52
|
|
|
51
53
|
### SafeHarbourObj
|
|
52
54
|
|
|
@@ -69,11 +71,25 @@ the response from [calcSafeHarbourScore](#calcsafeharbourscore)
|
|
|
69
71
|
| `flags` | [`SafeHarbourObj`](#safeharbourobj) |
|
|
70
72
|
| `isSafe` | `boolean` |
|
|
71
73
|
|
|
74
|
+
___
|
|
75
|
+
|
|
76
|
+
### VerDetails
|
|
77
|
+
|
|
78
|
+
Ƭ **VerDetails**: `Object`
|
|
79
|
+
|
|
80
|
+
#### Type declaration
|
|
81
|
+
|
|
82
|
+
| Name | Type | Description |
|
|
83
|
+
| :------ | :------ | :------ |
|
|
84
|
+
| `expiryDate?` | `Date` | field only present for expired verifications |
|
|
85
|
+
| `sourceNId?` | `NId` | - |
|
|
86
|
+
| `verifiers` | `VerificationProvider`[] | - |
|
|
87
|
+
|
|
72
88
|
## Functions
|
|
73
89
|
|
|
74
90
|
### calcSafeHarbourScore
|
|
75
91
|
|
|
76
|
-
▸
|
|
92
|
+
▸ **calcSafeHarbourScore**(`data`): `Promise`<[`SafeHarbourResult`](#safeharbourresult)\>
|
|
77
93
|
|
|
78
94
|
The Safe Harbour Score indidicates whether a person's identity has been verified
|
|
79
95
|
to the extent requried for Safe Harbour Compliance. This requires multiple verifications
|
|
@@ -85,8 +101,8 @@ from different sources. For information, refer to the
|
|
|
85
101
|
| Name | Type |
|
|
86
102
|
| :------ | :------ |
|
|
87
103
|
| `data` | `Object` |
|
|
88
|
-
| `data.person` | `ProfileObject
|
|
89
|
-
| `data.profileObjects` | `ProfileObject
|
|
104
|
+
| `data.person` | `ProfileObject` |
|
|
105
|
+
| `data.profileObjects` | `ProfileObject`[] |
|
|
90
106
|
| `data.realVers` | `RealVer`[] |
|
|
91
107
|
| `data.getSchema` | (`schemaName`: `string`) => `Promise`<`Schema`\> |
|
|
92
108
|
|
|
@@ -118,7 +134,7 @@ ___
|
|
|
118
134
|
|
|
119
135
|
### checkJsonSignature
|
|
120
136
|
|
|
121
|
-
▸
|
|
137
|
+
▸ **checkJsonSignature**(`data`, `signature`): `Promise`<`boolean`\>
|
|
122
138
|
|
|
123
139
|
checks that a json object was signed by the provided signature. Unless you're
|
|
124
140
|
dealing with bundled verifications, you should use `getOwnRealVerifications`
|
|
@@ -161,13 +177,13 @@ ___
|
|
|
161
177
|
|
|
162
178
|
### convertInstanceToRuleInput
|
|
163
179
|
|
|
164
|
-
▸
|
|
180
|
+
▸ **convertInstanceToRuleInput**(`POs`, `realVers`, `getSchema`): `Promise`<`RuleData`\>
|
|
165
181
|
|
|
166
182
|
#### Parameters
|
|
167
183
|
|
|
168
184
|
| Name | Type |
|
|
169
185
|
| :------ | :------ |
|
|
170
|
-
| `
|
|
186
|
+
| `POs` | `ProfileObject`[] |
|
|
171
187
|
| `realVers` | `RealVer`[] |
|
|
172
188
|
| `getSchema` | (`schemaName`: `string`) => `Promise`<`Schema`\> |
|
|
173
189
|
|
|
@@ -179,7 +195,7 @@ ___
|
|
|
179
195
|
|
|
180
196
|
### createAA
|
|
181
197
|
|
|
182
|
-
▸ **createAA**(
|
|
198
|
+
▸ **createAA**(`«destructured»`): `Promise`<`AA`\>
|
|
183
199
|
|
|
184
200
|
Creates an Access Application and associated public+private keys.
|
|
185
201
|
|
|
@@ -192,12 +208,12 @@ as well as the `userDoc` data which is stored in the user's cognito attributes.
|
|
|
192
208
|
|
|
193
209
|
| Name | Type |
|
|
194
210
|
| :------ | :------ |
|
|
195
|
-
|
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
199
|
-
| `
|
|
200
|
-
| `
|
|
211
|
+
| `«destructured»` | `Object` |
|
|
212
|
+
| › `apiToken` | `string` |
|
|
213
|
+
| › `apiUrl` | `string` |
|
|
214
|
+
| › `application` | `Omit`<`AA`, ``"a_id"``\> |
|
|
215
|
+
| › `maxcryptor` | `DataEncryptorI` |
|
|
216
|
+
| › `userDoc` | `UserDoc` |
|
|
201
217
|
|
|
202
218
|
#### Returns
|
|
203
219
|
|
|
@@ -207,7 +223,7 @@ ___
|
|
|
207
223
|
|
|
208
224
|
### decryptSharedData
|
|
209
225
|
|
|
210
|
-
▸
|
|
226
|
+
▸ **decryptSharedData**(`«destructured»`): `Promise`<{ `applicationDecryptor`: `ApplicationDataEncryptorI` ; `instance`: `Instance` }\>
|
|
211
227
|
|
|
212
228
|
Decrypts any encrypted properties included in the supplied `instanceData`.
|
|
213
229
|
If nothing is encrypted the supplied `instanceData` is returned.
|
|
@@ -220,24 +236,48 @@ supply a `onCorruptedData` function which returns a value to use instead.
|
|
|
220
236
|
|
|
221
237
|
| Name | Type |
|
|
222
238
|
| :------ | :------ |
|
|
223
|
-
|
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
228
|
-
| `
|
|
239
|
+
| `«destructured»` | `Object` |
|
|
240
|
+
| › `apiToken` | `string` |
|
|
241
|
+
| › `apiUrl` | `string` |
|
|
242
|
+
| › `instanceData` | `Instance` |
|
|
243
|
+
| › `maxcryptor` | `DataEncryptorI` |
|
|
244
|
+
| › `onCorruptedData?` | (`fieldName`: `string`, `fieldValue`: `Encrypted`, `error`: `Error`) => `any` |
|
|
229
245
|
|
|
230
246
|
#### Returns
|
|
231
247
|
|
|
232
|
-
`Promise
|
|
248
|
+
`Promise`<{ `applicationDecryptor`: `ApplicationDataEncryptorI` ; `instance`: `Instance` }\>
|
|
233
249
|
|
|
234
250
|
a copy of `instanceData` with all properties decrypted.
|
|
235
251
|
|
|
236
252
|
___
|
|
237
253
|
|
|
254
|
+
### evaluateRule
|
|
255
|
+
|
|
256
|
+
▸ **evaluateRule**(`rule`, `data`): `Object`
|
|
257
|
+
|
|
258
|
+
evaluates an individual rule, normally you should use [calculateScore](#calculatescore)
|
|
259
|
+
|
|
260
|
+
#### Parameters
|
|
261
|
+
|
|
262
|
+
| Name | Type |
|
|
263
|
+
| :------ | :------ |
|
|
264
|
+
| `rule` | `ScoreRule` |
|
|
265
|
+
| `data` | `RuleData` |
|
|
266
|
+
|
|
267
|
+
#### Returns
|
|
268
|
+
|
|
269
|
+
`Object`
|
|
270
|
+
|
|
271
|
+
| Name | Type |
|
|
272
|
+
| :------ | :------ |
|
|
273
|
+
| `passed` | `boolean` |
|
|
274
|
+
| `score` | `number` |
|
|
275
|
+
|
|
276
|
+
___
|
|
277
|
+
|
|
238
278
|
### findSchemaLabel
|
|
239
279
|
|
|
240
|
-
▸
|
|
280
|
+
▸ **findSchemaLabel**(`labels`): `undefined` \| `string`
|
|
241
281
|
|
|
242
282
|
Finds the label (on a profile object) which is the schema name
|
|
243
283
|
|
|
@@ -255,7 +295,7 @@ ___
|
|
|
255
295
|
|
|
256
296
|
### fromCognitoAttributes
|
|
257
297
|
|
|
258
|
-
▸
|
|
298
|
+
▸ **fromCognitoAttributes**(`attributes`): `UserDoc`
|
|
259
299
|
|
|
260
300
|
This function converts Cognito's userAttributes into a maxcryptor UserDoc.
|
|
261
301
|
The userAttributes come from `const attributes = await Auth.userAttributes(user)`
|
|
@@ -274,24 +314,24 @@ ___
|
|
|
274
314
|
|
|
275
315
|
### getAADecryptor
|
|
276
316
|
|
|
277
|
-
▸ **getAADecryptor**(
|
|
317
|
+
▸ **getAADecryptor**(`«destructured»`): `Promise`<{ `decryptor`: `ApplicationEncryptor` ; `publicKeyNId`: `NId` }\>
|
|
278
318
|
|
|
279
319
|
Fetchs the public and private keys for an Access Application, then initializes
|
|
280
|
-
the [Maxcryptor](https://npm.im/@raytio/maxcryptor)'s `ApplicationEncryptor`.
|
|
320
|
+
the [https://npm.im/@raytio/maxcryptor|Maxcryptor](https://npm.im/@raytio/maxcryptor|Maxcryptor)'s `ApplicationEncryptor`.
|
|
281
321
|
|
|
282
322
|
#### Parameters
|
|
283
323
|
|
|
284
324
|
| Name | Type |
|
|
285
325
|
| :------ | :------ |
|
|
286
|
-
|
|
|
287
|
-
| `
|
|
288
|
-
| `
|
|
289
|
-
| `
|
|
290
|
-
| `
|
|
326
|
+
| `«destructured»` | `Object` |
|
|
327
|
+
| › `aId` | `AId` |
|
|
328
|
+
| › `apiToken` | `string` |
|
|
329
|
+
| › `apiUrl` | `string` |
|
|
330
|
+
| › `maxcryptor` | `DataEncryptorI` |
|
|
291
331
|
|
|
292
332
|
#### Returns
|
|
293
333
|
|
|
294
|
-
`Promise
|
|
334
|
+
`Promise`<{ `decryptor`: `ApplicationEncryptor` ; `publicKeyNId`: `NId` }\>
|
|
295
335
|
|
|
296
336
|
an `ApplicationEncryptor` and the public key of the Access Application
|
|
297
337
|
|
|
@@ -299,7 +339,7 @@ ___
|
|
|
299
339
|
|
|
300
340
|
### getOwnRealVerifications
|
|
301
341
|
|
|
302
|
-
▸
|
|
342
|
+
▸ **getOwnRealVerifications**(`«destructured»`): `Promise`<`RealVer`[]\>
|
|
303
343
|
|
|
304
344
|
Given a list of verifications and decrypted profile objects, this function
|
|
305
345
|
locally verifies the credibility of the signatures in the verifications.
|
|
@@ -310,10 +350,10 @@ This function does NOT call the API, except to fetch the public key.
|
|
|
310
350
|
|
|
311
351
|
| Name | Type |
|
|
312
352
|
| :------ | :------ |
|
|
313
|
-
|
|
|
314
|
-
| `
|
|
315
|
-
| `
|
|
316
|
-
| `
|
|
353
|
+
| `«destructured»` | `Object` |
|
|
354
|
+
| › `profileObjects` | `ProfileObject`[] |
|
|
355
|
+
| › `userId` | `UId` |
|
|
356
|
+
| › `verifications` | `Verification`[] |
|
|
317
357
|
|
|
318
358
|
#### Returns
|
|
319
359
|
|
|
@@ -325,7 +365,7 @@ ___
|
|
|
325
365
|
|
|
326
366
|
### getPOVerification
|
|
327
367
|
|
|
328
|
-
▸ **getPOVerification**(
|
|
368
|
+
▸ **getPOVerification**(`«destructured»`): `Object`
|
|
329
369
|
|
|
330
370
|
Determines the verification status of a profile object, and its individual fields.
|
|
331
371
|
|
|
@@ -333,10 +373,10 @@ Determines the verification status of a profile object, and its individual field
|
|
|
333
373
|
|
|
334
374
|
| Name | Type |
|
|
335
375
|
| :------ | :------ |
|
|
336
|
-
|
|
|
337
|
-
| `
|
|
338
|
-
| `
|
|
339
|
-
| `
|
|
376
|
+
| `«destructured»` | `Object` |
|
|
377
|
+
| › `PO` | `ProfileObject` \| `ProfileObjectForUpload` |
|
|
378
|
+
| › `realVers` | `RealVer`[] |
|
|
379
|
+
| › `schema` | `Schema` |
|
|
340
380
|
|
|
341
381
|
#### Returns
|
|
342
382
|
|
|
@@ -344,9 +384,7 @@ Determines the verification status of a profile object, and its individual field
|
|
|
344
384
|
|
|
345
385
|
| Name | Type |
|
|
346
386
|
| :------ | :------ |
|
|
347
|
-
| `details` | `
|
|
348
|
-
| `details.sourceNId?` | `NId` |
|
|
349
|
-
| `details.verifiers` | `VerificationProvider`[] |
|
|
387
|
+
| `details` | [`VerDetails`](#verdetails) |
|
|
350
388
|
| `fieldVerifications` | `Record`<`string`, `FieldVerification`\> |
|
|
351
389
|
| `status` | `POVerification` |
|
|
352
390
|
|
|
@@ -354,7 +392,7 @@ ___
|
|
|
354
392
|
|
|
355
393
|
### getSomeoneElsesRealVerifications
|
|
356
394
|
|
|
357
|
-
▸
|
|
395
|
+
▸ **getSomeoneElsesRealVerifications**(`«destructured»`): `Promise`<`RealVer`[]\>
|
|
358
396
|
|
|
359
397
|
Given a list of verifications and decrypted profile objects, this function calls
|
|
360
398
|
the Raytio API to verify the credibility of these verifications, returning only valid
|
|
@@ -366,7 +404,7 @@ verifications.
|
|
|
366
404
|
|
|
367
405
|
| Name | Type |
|
|
368
406
|
| :------ | :------ |
|
|
369
|
-
|
|
|
407
|
+
| `«destructured»` | `Props` |
|
|
370
408
|
|
|
371
409
|
#### Returns
|
|
372
410
|
|
|
@@ -380,7 +418,9 @@ ___
|
|
|
380
418
|
|
|
381
419
|
▸ **hashPassword**(`password`): `Promise`<`string`\>
|
|
382
420
|
|
|
383
|
-
**`
|
|
421
|
+
**`Deprecated`**
|
|
422
|
+
|
|
423
|
+
legacy feature, see #1252
|
|
384
424
|
|
|
385
425
|
AWS Cognito never gets the raw password. We send them
|
|
386
426
|
a hashed verison using PBKDF2 with SHA-256 and 10,000
|
|
@@ -402,12 +442,13 @@ ___
|
|
|
402
442
|
|
|
403
443
|
### isConditionMet
|
|
404
444
|
|
|
405
|
-
▸
|
|
445
|
+
▸ **isConditionMet**(`condition`, `formValues`): `boolean`
|
|
406
446
|
|
|
407
447
|
Checks all other form values in case any have a
|
|
408
448
|
trigger value that makes this field required.
|
|
409
449
|
|
|
410
|
-
**`
|
|
450
|
+
**`Example`**
|
|
451
|
+
|
|
411
452
|
```json
|
|
412
453
|
[
|
|
413
454
|
{ "if": { "age": [17, 18], "city": ["Taupō"] } },
|
|
@@ -432,7 +473,7 @@ ___
|
|
|
432
473
|
|
|
433
474
|
### isEncrypted
|
|
434
475
|
|
|
435
|
-
▸
|
|
476
|
+
▸ **isEncrypted**(`value`): value is Encrypted
|
|
436
477
|
|
|
437
478
|
Determines where the input is an encrypted Raytio object
|
|
438
479
|
|
|
@@ -444,7 +485,7 @@ Determines where the input is an encrypted Raytio object
|
|
|
444
485
|
|
|
445
486
|
#### Returns
|
|
446
487
|
|
|
447
|
-
value is Encrypted
|
|
488
|
+
value is Encrypted
|
|
448
489
|
|
|
449
490
|
true or false depending on whether the input is an encrypted Raytio object
|
|
450
491
|
|
|
@@ -452,7 +493,7 @@ ___
|
|
|
452
493
|
|
|
453
494
|
### isEncryptedFile
|
|
454
495
|
|
|
455
|
-
▸
|
|
496
|
+
▸ **isEncryptedFile**(`value`): value is Encrypted
|
|
456
497
|
|
|
457
498
|
Determines where the input is an encrypted Raytio file
|
|
458
499
|
|
|
@@ -464,7 +505,7 @@ Determines where the input is an encrypted Raytio file
|
|
|
464
505
|
|
|
465
506
|
#### Returns
|
|
466
507
|
|
|
467
|
-
value is Encrypted
|
|
508
|
+
value is Encrypted
|
|
468
509
|
|
|
469
510
|
true or false depending on whether the input is an encrypted Raytio file
|
|
470
511
|
|
|
@@ -472,7 +513,7 @@ ___
|
|
|
472
513
|
|
|
473
514
|
### isScoreConfigValid
|
|
474
515
|
|
|
475
|
-
▸
|
|
516
|
+
▸ **isScoreConfigValid**(`x`): x is ScoreConfig
|
|
476
517
|
|
|
477
518
|
determines whether a `ScoreConfig` object is valid
|
|
478
519
|
|
|
@@ -490,7 +531,7 @@ ___
|
|
|
490
531
|
|
|
491
532
|
### isScoreResultValid
|
|
492
533
|
|
|
493
|
-
▸
|
|
534
|
+
▸ **isScoreResultValid**(`x`): x is ScoreResult
|
|
494
535
|
|
|
495
536
|
determines whether a `ScoreResult` object is valid
|
|
496
537
|
|
|
@@ -526,7 +567,7 @@ ___
|
|
|
526
567
|
|
|
527
568
|
### someEncrypted
|
|
528
569
|
|
|
529
|
-
▸
|
|
570
|
+
▸ **someEncrypted**<`T`, `K`\>(`...args`): `number`
|
|
530
571
|
|
|
531
572
|
Given a profile object's properties, returns the number
|
|
532
573
|
of properties that are encryted.
|
|
@@ -552,7 +593,7 @@ ___
|
|
|
552
593
|
|
|
553
594
|
### toCognitoAttributes
|
|
554
595
|
|
|
555
|
-
▸
|
|
596
|
+
▸ **toCognitoAttributes**(`userDoc`): `Object`
|
|
556
597
|
|
|
557
598
|
Given a `UserDoc` from the maxcryptor, this returns an object
|
|
558
599
|
which you can provide to `Auth.updateUserAttributes()`. It is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
8
|
+
describe("docs", () => {
|
|
9
|
+
it("generates a nice README for @raytio/core & @raytio/types", async () => {
|
|
10
|
+
console.log("(1/4) Running `yarn docs` for core...");
|
|
11
|
+
console.log(Object.values(await execAsync("yarn docs")).join("\n"));
|
|
12
|
+
console.log("(2/4) Reading README.md for core...");
|
|
13
|
+
const readmeCore = await fs_1.promises.readFile("README.md", { encoding: "utf-8" });
|
|
14
|
+
expect(readmeCore).toMatchSnapshot();
|
|
15
|
+
// types & core are in the same test to avoid jest parallelizing them
|
|
16
|
+
console.log("(3/4) Running `yarn docs` for types...");
|
|
17
|
+
console.log(Object.values(await execAsync("cd ../types && yarn docs")).join("\n"));
|
|
18
|
+
console.log("(4/4) Reading README.md for types...");
|
|
19
|
+
const readmeTypes = await fs_1.promises.readFile("../types/README.md", {
|
|
20
|
+
encoding: "utf-8",
|
|
21
|
+
});
|
|
22
|
+
expect(readmeTypes).toMatchSnapshot();
|
|
23
|
+
}, 30000);
|
|
24
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { Maxcryptor, UserDoc } from "@raytio/maxcryptor";
|
|
2
|
-
import type { AA } from "@raytio/types";
|
|
3
|
-
/**
|
|
4
|
-
* Creates an Access Application and associated public+private keys.
|
|
5
|
-
*
|
|
6
|
-
* The user must be part of an organization, and you need to include the `orgId`.
|
|
7
|
-
*
|
|
8
|
-
* You must also supply an apiToken and an instance of the maxcryptor for that user,
|
|
9
|
-
* as well as the `userDoc` data which is stored in the user's cognito attributes.
|
|
10
|
-
*/
|
|
11
|
-
export declare function createAA({ apiUrl, apiToken, userDoc, maxcryptor, application, }: {
|
|
12
|
-
apiUrl: string;
|
|
13
|
-
apiToken: string;
|
|
14
|
-
application: Omit<AA, "a_id">;
|
|
15
|
-
userDoc: UserDoc;
|
|
16
|
-
maxcryptor: Maxcryptor;
|
|
17
|
-
}): Promise<AA>;
|
|
1
|
+
import type { Maxcryptor, UserDoc } from "@raytio/maxcryptor";
|
|
2
|
+
import type { AA } from "@raytio/types";
|
|
3
|
+
/**
|
|
4
|
+
* Creates an Access Application and associated public+private keys.
|
|
5
|
+
*
|
|
6
|
+
* The user must be part of an organization, and you need to include the `orgId`.
|
|
7
|
+
*
|
|
8
|
+
* You must also supply an apiToken and an instance of the maxcryptor for that user,
|
|
9
|
+
* as well as the `userDoc` data which is stored in the user's cognito attributes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createAA({ apiUrl, apiToken, userDoc, maxcryptor, application, }: {
|
|
12
|
+
apiUrl: string;
|
|
13
|
+
apiToken: string;
|
|
14
|
+
application: Omit<AA, "a_id">;
|
|
15
|
+
userDoc: UserDoc;
|
|
16
|
+
maxcryptor: Maxcryptor;
|
|
17
|
+
}): Promise<AA>;
|
|
@@ -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);
|