@raytio/core 8.1.1 → 9.0.1
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 +375 -19
- package/dist/accessApplication/createAA.d.ts +17 -17
- package/dist/accessApplication/createAA.js +71 -72
- package/dist/accessApplication/index.d.ts +1 -1
- package/dist/accessApplication/index.js +13 -13
- 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 -35
- package/dist/crypto/decryptSharedData.d.ts +26 -26
- package/dist/crypto/decryptSharedData.js +38 -38
- package/dist/crypto/getAADecryptor.d.ts +11 -11
- 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 +17 -17
- package/dist/general/conditional.d.ts +7 -7
- package/dist/general/conditional.js +22 -22
- package/dist/general/index.d.ts +3 -2
- package/dist/general/index.js +15 -14
- package/dist/general/password.d.ts +8 -8
- package/dist/general/password.js +29 -29
- package/dist/general/types.d.ts +6 -0
- package/dist/general/types.js +13 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +18 -17
- 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 +140 -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/schema/index.d.ts +1 -1
- package/dist/schema/index.js +13 -13
- package/dist/schema/labels.d.ts +2 -2
- package/dist/schema/labels.js +20 -20
- package/dist/{verifications/checkVerifications.d.ts → util/canonicalJsonify.d.ts} +1 -1
- package/dist/util/canonicalJsonify.js +48 -0
- package/dist/util/handleResponse.d.ts +1 -1
- package/dist/util/handleResponse.js +21 -22
- package/dist/util/index.d.ts +2 -1
- package/dist/util/index.js +14 -13
- package/dist/verifications/cleanInstance.d.ts +9 -0
- package/dist/verifications/cleanInstance.js +15 -0
- package/dist/verifications/getPOVerification.d.ts +16 -13
- package/dist/verifications/getPOVerification.js +94 -95
- package/dist/verifications/getVerifiedBy.d.ts +1 -1
- package/dist/verifications/getVerifiedBy.js +19 -19
- package/dist/verifications/index.d.ts +5 -4
- package/dist/verifications/index.js +18 -17
- 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/getOwnRealVerifications.d.ts +13 -0
- package/dist/verifications/verifyCheck/getOwnRealVerifications.js +63 -0
- package/dist/verifications/{getRealVerifications.d.ts → verifyCheck/getSomeoneElsesRealVerifications.d.ts} +26 -22
- package/dist/verifications/{getRealVerifications.js → verifyCheck/getSomeoneElsesRealVerifications.js} +76 -66
- package/dist/verifications/verifyCheck/index.d.ts +2 -0
- package/dist/verifications/verifyCheck/index.js +14 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.d.ts +9 -0
- package/dist/verifications/verifyCheck/operations/checkOwnVerification.js +31 -0
- package/dist/verifications/verifyCheck/operations/checkSomeoneElsesVerifications.d.ts +1 -0
- package/dist/verifications/{checkVerifications.js → verifyCheck/operations/checkSomeoneElsesVerifications.js} +16 -16
- 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/util/conditional.d.ts +0 -7
- package/dist/util/conditional.js +0 -15
package/README.md
CHANGED
|
@@ -10,109 +10,465 @@ Nodejs does not support [fetch](https://developer.mozilla.org/en-US/docs/Web/API
|
|
|
10
10
|
|
|
11
11
|
If you use the high-level [`@raytio/decrypt-helper`](https://npm.im/@raytio/decrypt-helper) module, you don't need to worry about this.
|
|
12
12
|
|
|
13
|
-
If you wish to use `@raytio/core` directly, an example of configuring polyfills for nodejs is availble [here](https://gitlab.com/raytio/tools/decrypt-helper/-/blob/
|
|
13
|
+
If you wish to use `@raytio/core` directly, an example of configuring polyfills for nodejs is availble [here](https://gitlab.com/raytio/tools/decrypt-helper/-/blob/main/src/configureEnv.ts)
|
|
14
14
|
|
|
15
15
|
# API
|
|
16
16
|
|
|
17
17
|
## Table of contents
|
|
18
18
|
|
|
19
|
-
###
|
|
19
|
+
### Type aliases
|
|
20
20
|
|
|
21
21
|
- [SafeHarbourObj](#safeharbourobj)
|
|
22
|
+
- [SafeHarbourResult](#safeharbourresult)
|
|
23
|
+
|
|
24
|
+
### Functions
|
|
25
|
+
|
|
22
26
|
- [calcSafeHarbourScore](#calcsafeharbourscore)
|
|
27
|
+
- [calculateScore](#calculatescore)
|
|
28
|
+
- [cleanInstance](#cleaninstance)
|
|
29
|
+
- [convertInstanceToRuleInput](#convertinstancetoruleinput)
|
|
23
30
|
- [createAA](#createaa)
|
|
24
31
|
- [decryptSharedData](#decryptshareddata)
|
|
25
32
|
- [findSchemaLabel](#findschemalabel)
|
|
26
33
|
- [fromCognitoAttributes](#fromcognitoattributes)
|
|
27
34
|
- [getAADecryptor](#getaadecryptor)
|
|
35
|
+
- [getOwnRealVerifications](#getownrealverifications)
|
|
28
36
|
- [getPOVerification](#getpoverification)
|
|
29
|
-
- [
|
|
37
|
+
- [getSomeoneElsesRealVerifications](#getsomeoneelsesrealverifications)
|
|
30
38
|
- [hashPassword](#hashpassword)
|
|
39
|
+
- [isConditionMet](#isconditionmet)
|
|
31
40
|
- [isEncrypted](#isencrypted)
|
|
32
41
|
- [isEncryptedFile](#isencryptedfile)
|
|
33
42
|
- [someEncrypted](#someencrypted)
|
|
34
43
|
- [toCognitoAttributes](#tocognitoattributes)
|
|
35
44
|
|
|
36
|
-
##
|
|
45
|
+
## Type aliases
|
|
37
46
|
|
|
38
47
|
### SafeHarbourObj
|
|
39
48
|
|
|
40
|
-
|
|
49
|
+
Ƭ **SafeHarbourObj**: `Partial`<`Record`<`SafeHarbourCode`, `string`[]\>\>
|
|
50
|
+
|
|
51
|
+
an object listing the `xId`s for each SafeHarbourCode
|
|
41
52
|
|
|
42
53
|
___
|
|
43
54
|
|
|
55
|
+
### SafeHarbourResult
|
|
56
|
+
|
|
57
|
+
Ƭ **SafeHarbourResult**: `Object`
|
|
58
|
+
|
|
59
|
+
the response from [calcSafeHarbourScore](#calcsafeharbourscore)
|
|
60
|
+
|
|
61
|
+
#### Type declaration
|
|
62
|
+
|
|
63
|
+
| Name | Type |
|
|
64
|
+
| :------ | :------ |
|
|
65
|
+
| `flags` | [`SafeHarbourObj`](#safeharbourobj) |
|
|
66
|
+
| `isSafe` | `boolean` |
|
|
67
|
+
|
|
68
|
+
## Functions
|
|
69
|
+
|
|
44
70
|
### calcSafeHarbourScore
|
|
45
71
|
|
|
46
|
-
|
|
72
|
+
▸ `Const` **calcSafeHarbourScore**(`data`): `Promise`<[`SafeHarbourResult`](#safeharbourresult)\>
|
|
73
|
+
|
|
74
|
+
The Safe Harbour Score indidicates whether a person's identity has been verified
|
|
75
|
+
to the extent requried for Safe Harbour Compliance. This requires multiple verifications
|
|
76
|
+
from different sources. For information, refer to the
|
|
77
|
+
[Raytio Documentation](https://dev-docs.rayt.io/docs/features/pep-checks).
|
|
78
|
+
|
|
79
|
+
#### Parameters
|
|
80
|
+
|
|
81
|
+
| Name | Type |
|
|
82
|
+
| :------ | :------ |
|
|
83
|
+
| `data` | `Object` |
|
|
84
|
+
| `data.person` | `ProfileObject`<`Json`\> |
|
|
85
|
+
| `data.profileObjects` | `ProfileObject`<`Json`\>[] |
|
|
86
|
+
| `data.realVers` | `RealVer`[] |
|
|
87
|
+
| `data.getSchema` | (`schemaName`: `string`) => `Promise`<`Schema`\> |
|
|
88
|
+
|
|
89
|
+
#### Returns
|
|
90
|
+
|
|
91
|
+
`Promise`<[`SafeHarbourResult`](#safeharbourresult)\>
|
|
92
|
+
|
|
93
|
+
___
|
|
94
|
+
|
|
95
|
+
### calculateScore
|
|
96
|
+
|
|
97
|
+
▸ **calculateScore**(`ruleConfig`, `ruleInput`): `ScoreResult`
|
|
98
|
+
|
|
99
|
+
the main function to calculate a score and category.
|
|
100
|
+
Might throw an error.
|
|
101
|
+
|
|
102
|
+
#### Parameters
|
|
103
|
+
|
|
104
|
+
| Name | Type |
|
|
105
|
+
| :------ | :------ |
|
|
106
|
+
| `ruleConfig` | `ScoreConfig` |
|
|
107
|
+
| `ruleInput` | `RuleData` |
|
|
108
|
+
|
|
109
|
+
#### Returns
|
|
110
|
+
|
|
111
|
+
`ScoreResult`
|
|
112
|
+
|
|
113
|
+
___
|
|
114
|
+
|
|
115
|
+
### cleanInstance
|
|
116
|
+
|
|
117
|
+
▸ **cleanInstance**(`instance`): `Instance`
|
|
118
|
+
|
|
119
|
+
The API response from share/v2/access_application/instance/:iId
|
|
120
|
+
returns a complicated hashed_n_id format, so you need to clean up
|
|
121
|
+
the API response using this function as soon as possible.
|
|
122
|
+
|
|
123
|
+
We relace `hashed_n_id`s with a string `HASHED::{NId}::{AId}`
|
|
124
|
+
|
|
125
|
+
#### Parameters
|
|
126
|
+
|
|
127
|
+
| Name | Type |
|
|
128
|
+
| :------ | :------ |
|
|
129
|
+
| `instance` | `Instance` |
|
|
130
|
+
|
|
131
|
+
#### Returns
|
|
132
|
+
|
|
133
|
+
`Instance`
|
|
134
|
+
|
|
135
|
+
___
|
|
136
|
+
|
|
137
|
+
### convertInstanceToRuleInput
|
|
138
|
+
|
|
139
|
+
▸ `Const` **convertInstanceToRuleInput**(`instance`, `realVers`, `getSchema`): `Promise`<`RuleData`\>
|
|
140
|
+
|
|
141
|
+
#### Parameters
|
|
142
|
+
|
|
143
|
+
| Name | Type |
|
|
144
|
+
| :------ | :------ |
|
|
145
|
+
| `instance` | `Instance` |
|
|
146
|
+
| `realVers` | `RealVer`[] |
|
|
147
|
+
| `getSchema` | (`schemaName`: `string`) => `Promise`<`Schema`\> |
|
|
148
|
+
|
|
149
|
+
#### Returns
|
|
150
|
+
|
|
151
|
+
`Promise`<`RuleData`\>
|
|
47
152
|
|
|
48
153
|
___
|
|
49
154
|
|
|
50
155
|
### createAA
|
|
51
156
|
|
|
52
|
-
|
|
157
|
+
▸ **createAA**(`__namedParameters`): `Promise`<`AA`\>
|
|
158
|
+
|
|
159
|
+
Creates an Access Application and associated public+private keys.
|
|
160
|
+
|
|
161
|
+
The user must be part of an organization, and you need to include the `orgId`.
|
|
162
|
+
|
|
163
|
+
You must also supply an apiToken and an instance of the maxcryptor for that user,
|
|
164
|
+
as well as the `userDoc` data which is stored in the user's cognito attributes.
|
|
165
|
+
|
|
166
|
+
#### Parameters
|
|
167
|
+
|
|
168
|
+
| Name | Type |
|
|
169
|
+
| :------ | :------ |
|
|
170
|
+
| `__namedParameters` | `Object` |
|
|
171
|
+
| `__namedParameters.apiToken` | `string` |
|
|
172
|
+
| `__namedParameters.apiUrl` | `string` |
|
|
173
|
+
| `__namedParameters.application` | `Omit`<`AA`, ``"a_id"``\> |
|
|
174
|
+
| `__namedParameters.maxcryptor` | `DataEncryptorI` |
|
|
175
|
+
| `__namedParameters.userDoc` | `UserDoc` |
|
|
176
|
+
|
|
177
|
+
#### Returns
|
|
178
|
+
|
|
179
|
+
`Promise`<`AA`\>
|
|
53
180
|
|
|
54
181
|
___
|
|
55
182
|
|
|
56
183
|
### decryptSharedData
|
|
57
184
|
|
|
58
|
-
|
|
185
|
+
▸ `Const` **decryptSharedData**(`__namedParameters`): `Promise`<`Object`\>
|
|
186
|
+
|
|
187
|
+
Decrypts any encrypted properties included in the supplied `instanceData`.
|
|
188
|
+
If nothing is encrypted the supplied `instanceData` is returned.
|
|
189
|
+
|
|
190
|
+
It will reject if there are keys missing for any encrypted properties, or
|
|
191
|
+
if the encrypted data is invalid. If you don't want it to reject, you can
|
|
192
|
+
supply a `onCorruptedData` function which returns a value to use instead.
|
|
193
|
+
|
|
194
|
+
#### Parameters
|
|
195
|
+
|
|
196
|
+
| Name | Type |
|
|
197
|
+
| :------ | :------ |
|
|
198
|
+
| `__namedParameters` | `Object` |
|
|
199
|
+
| `__namedParameters.apiToken` | `string` |
|
|
200
|
+
| `__namedParameters.apiUrl` | `string` |
|
|
201
|
+
| `__namedParameters.instanceData` | `Instance` |
|
|
202
|
+
| `__namedParameters.maxcryptor` | `DataEncryptorI` |
|
|
203
|
+
| `__namedParameters.onCorruptedData?` | (`fieldName`: `string`, `fieldValue`: `Encrypted`<`string`\>, `error`: `Error`) => `any` |
|
|
204
|
+
|
|
205
|
+
#### Returns
|
|
206
|
+
|
|
207
|
+
`Promise`<`Object`\>
|
|
208
|
+
|
|
209
|
+
a copy of `instanceData` with all properties decrypted.
|
|
59
210
|
|
|
60
211
|
___
|
|
61
212
|
|
|
62
213
|
### findSchemaLabel
|
|
63
214
|
|
|
64
|
-
|
|
215
|
+
▸ `Const` **findSchemaLabel**(`labels`): `undefined` \| `string`
|
|
216
|
+
|
|
217
|
+
Finds the label (on a profile object) which is the schema name
|
|
218
|
+
|
|
219
|
+
#### Parameters
|
|
220
|
+
|
|
221
|
+
| Name | Type |
|
|
222
|
+
| :------ | :------ |
|
|
223
|
+
| `labels` | `undefined` \| `string`[] |
|
|
224
|
+
|
|
225
|
+
#### Returns
|
|
226
|
+
|
|
227
|
+
`undefined` \| `string`
|
|
65
228
|
|
|
66
229
|
___
|
|
67
230
|
|
|
68
231
|
### fromCognitoAttributes
|
|
69
232
|
|
|
70
|
-
|
|
233
|
+
▸ `Const` **fromCognitoAttributes**(`attributes`): `UserDoc`
|
|
234
|
+
|
|
235
|
+
This function converts Cognito's userAttributes into a maxcryptor UserDoc.
|
|
236
|
+
The userAttributes come from `const attributes = await Auth.userAttributes(user)`
|
|
237
|
+
|
|
238
|
+
#### Parameters
|
|
239
|
+
|
|
240
|
+
| Name | Type |
|
|
241
|
+
| :------ | :------ |
|
|
242
|
+
| `attributes` | `ICognitoUserAttributeData`[] |
|
|
243
|
+
|
|
244
|
+
#### Returns
|
|
245
|
+
|
|
246
|
+
`UserDoc`
|
|
71
247
|
|
|
72
248
|
___
|
|
73
249
|
|
|
74
250
|
### getAADecryptor
|
|
75
251
|
|
|
76
|
-
|
|
252
|
+
▸ **getAADecryptor**(`__namedParameters`): `Promise`<`Object`\>
|
|
253
|
+
|
|
254
|
+
Fetchs the public and private keys for an Access Application, then initializes
|
|
255
|
+
the [Maxcryptor](https://npm.im/@raytio/maxcryptor)'s `ApplicationEncryptor`.
|
|
256
|
+
|
|
257
|
+
#### Parameters
|
|
258
|
+
|
|
259
|
+
| Name | Type |
|
|
260
|
+
| :------ | :------ |
|
|
261
|
+
| `__namedParameters` | `Arg` |
|
|
262
|
+
|
|
263
|
+
#### Returns
|
|
264
|
+
|
|
265
|
+
`Promise`<`Object`\>
|
|
266
|
+
|
|
267
|
+
an `ApplicationEncryptor` and the public key of the Access Application
|
|
268
|
+
|
|
269
|
+
___
|
|
270
|
+
|
|
271
|
+
### getOwnRealVerifications
|
|
272
|
+
|
|
273
|
+
▸ `Const` **getOwnRealVerifications**(`__namedParameters`): `Promise`<`RealVer`[]\>
|
|
274
|
+
|
|
275
|
+
Given a list of verifications and decrypted profile objects, this function
|
|
276
|
+
locally verifies the credibility of the signatures in the verifications.
|
|
277
|
+
|
|
278
|
+
This function does NOT call the API, except to fetch the public key.
|
|
279
|
+
|
|
280
|
+
#### Parameters
|
|
281
|
+
|
|
282
|
+
| Name | Type |
|
|
283
|
+
| :------ | :------ |
|
|
284
|
+
| `__namedParameters` | `Object` |
|
|
285
|
+
| `__namedParameters.profileObjects` | `ProfileObject`<`Json`\>[] |
|
|
286
|
+
| `__namedParameters.userId` | `UId` |
|
|
287
|
+
| `__namedParameters.verifications` | `Verification`<``false``\>[] |
|
|
288
|
+
|
|
289
|
+
#### Returns
|
|
290
|
+
|
|
291
|
+
`Promise`<`RealVer`[]\>
|
|
292
|
+
|
|
293
|
+
a list of authentic RealVer
|
|
77
294
|
|
|
78
295
|
___
|
|
79
296
|
|
|
80
297
|
### getPOVerification
|
|
81
298
|
|
|
82
|
-
|
|
299
|
+
▸ **getPOVerification**(`__namedParameters`): `Object`
|
|
300
|
+
|
|
301
|
+
Determines the verification status of a profile object, and its individual fields.
|
|
302
|
+
|
|
303
|
+
#### Parameters
|
|
304
|
+
|
|
305
|
+
| Name | Type |
|
|
306
|
+
| :------ | :------ |
|
|
307
|
+
| `__namedParameters` | `Object` |
|
|
308
|
+
| `__namedParameters.PO` | `ProfileObject`<`Json`\> \| `ProfileObjectForUpload`<`Json`\> |
|
|
309
|
+
| `__namedParameters.realVers` | `RealVer`[] |
|
|
310
|
+
| `__namedParameters.schema` | `Schema` |
|
|
311
|
+
|
|
312
|
+
#### Returns
|
|
313
|
+
|
|
314
|
+
`Object`
|
|
315
|
+
|
|
316
|
+
| Name | Type |
|
|
317
|
+
| :------ | :------ |
|
|
318
|
+
| `details` | `Object` |
|
|
319
|
+
| `details.sourceNId?` | `NId` |
|
|
320
|
+
| `details.verifiers` | `VerificationProvider`[] |
|
|
321
|
+
| `fieldVerifications` | `Record`<`string`, `FieldVerification`\> |
|
|
322
|
+
| `status` | `POVerification` |
|
|
83
323
|
|
|
84
324
|
___
|
|
85
325
|
|
|
86
|
-
###
|
|
326
|
+
### getSomeoneElsesRealVerifications
|
|
327
|
+
|
|
328
|
+
▸ `Const` **getSomeoneElsesRealVerifications**(`__namedParameters`): `Promise`<`RealVer`[]\>
|
|
329
|
+
|
|
330
|
+
Given a list of verifications and decrypted profile objects, this function calls
|
|
331
|
+
the Raytio API to verify the credibility of these verifications, returning only valid
|
|
332
|
+
verifications.
|
|
333
|
+
|
|
334
|
+
❗ prefer `getOwnRealVerifications` if the data to be verified belongs to the current user.
|
|
335
|
+
|
|
336
|
+
#### Parameters
|
|
337
|
+
|
|
338
|
+
| Name | Type |
|
|
339
|
+
| :------ | :------ |
|
|
340
|
+
| `__namedParameters` | `Props` |
|
|
87
341
|
|
|
88
|
-
|
|
342
|
+
#### Returns
|
|
343
|
+
|
|
344
|
+
`Promise`<`RealVer`[]\>
|
|
345
|
+
|
|
346
|
+
a list of fileNames/values that are verified.
|
|
89
347
|
|
|
90
348
|
___
|
|
91
349
|
|
|
92
350
|
### hashPassword
|
|
93
351
|
|
|
94
|
-
|
|
352
|
+
▸ **hashPassword**(`password`): `Promise`<`string`\>
|
|
353
|
+
|
|
354
|
+
AWS Cognito never gets the raw password. We send them
|
|
355
|
+
a hashed verison using PBKDF2 with SHA-256 and 10,000
|
|
356
|
+
iterations.
|
|
357
|
+
|
|
358
|
+
#### Parameters
|
|
359
|
+
|
|
360
|
+
| Name | Type | Description |
|
|
361
|
+
| :------ | :------ | :------ |
|
|
362
|
+
| `password` | `string` | The raw password |
|
|
363
|
+
|
|
364
|
+
#### Returns
|
|
365
|
+
|
|
366
|
+
`Promise`<`string`\>
|
|
367
|
+
|
|
368
|
+
Promise resolving to the hashed password
|
|
369
|
+
|
|
370
|
+
___
|
|
371
|
+
|
|
372
|
+
### isConditionMet
|
|
373
|
+
|
|
374
|
+
▸ `Const` **isConditionMet**(`condition`, `formValues`): `boolean`
|
|
375
|
+
|
|
376
|
+
Checks all other form values in case any have a
|
|
377
|
+
trigger value that makes this field requirted.
|
|
378
|
+
|
|
379
|
+
#### Parameters
|
|
380
|
+
|
|
381
|
+
| Name | Type |
|
|
382
|
+
| :------ | :------ |
|
|
383
|
+
| `condition` | `Record`<`string`, `ConditionValue`[]\> |
|
|
384
|
+
| `formValues` | `Record`<`string`, `unknown`\> |
|
|
385
|
+
|
|
386
|
+
#### Returns
|
|
387
|
+
|
|
388
|
+
`boolean`
|
|
95
389
|
|
|
96
390
|
___
|
|
97
391
|
|
|
98
392
|
### isEncrypted
|
|
99
393
|
|
|
100
|
-
|
|
394
|
+
▸ `Const` **isEncrypted**(`value`): value is Encrypted<string\>
|
|
395
|
+
|
|
396
|
+
Determines where the input is an encrypted Raytio object
|
|
397
|
+
|
|
398
|
+
#### Parameters
|
|
399
|
+
|
|
400
|
+
| Name | Type | Description |
|
|
401
|
+
| :------ | :------ | :------ |
|
|
402
|
+
| `value` | `unknown` | anything |
|
|
403
|
+
|
|
404
|
+
#### Returns
|
|
405
|
+
|
|
406
|
+
value is Encrypted<string\>
|
|
407
|
+
|
|
408
|
+
true or false depending on whether the input is an encrypted Raytio object
|
|
101
409
|
|
|
102
410
|
___
|
|
103
411
|
|
|
104
412
|
### isEncryptedFile
|
|
105
413
|
|
|
106
|
-
|
|
414
|
+
▸ `Const` **isEncryptedFile**(`value`): value is Encrypted<string\>
|
|
415
|
+
|
|
416
|
+
Determines where the input is an encrypted Raytio file
|
|
417
|
+
|
|
418
|
+
#### Parameters
|
|
419
|
+
|
|
420
|
+
| Name | Type | Description |
|
|
421
|
+
| :------ | :------ | :------ |
|
|
422
|
+
| `value` | `unknown` | anything |
|
|
423
|
+
|
|
424
|
+
#### Returns
|
|
425
|
+
|
|
426
|
+
value is Encrypted<string\>
|
|
427
|
+
|
|
428
|
+
true or false depending on whether the input is an encrypted Raytio file
|
|
107
429
|
|
|
108
430
|
___
|
|
109
431
|
|
|
110
432
|
### someEncrypted
|
|
111
433
|
|
|
112
|
-
|
|
434
|
+
▸ `Const` **someEncrypted**<`T`, `K`\>(...`args`): `number`
|
|
435
|
+
|
|
436
|
+
Given a profile object's properties, returns the number
|
|
437
|
+
of properties that are encryted.
|
|
438
|
+
|
|
439
|
+
#### Type parameters
|
|
440
|
+
|
|
441
|
+
| Name | Type |
|
|
442
|
+
| :------ | :------ |
|
|
443
|
+
| `T` | extends `object` |
|
|
444
|
+
| `K` | extends `string` \| `number` \| `symbol` |
|
|
445
|
+
|
|
446
|
+
#### Parameters
|
|
447
|
+
|
|
448
|
+
| Name | Type |
|
|
449
|
+
| :------ | :------ |
|
|
450
|
+
| `...args` | [obj: T] |
|
|
451
|
+
|
|
452
|
+
#### Returns
|
|
453
|
+
|
|
454
|
+
`number`
|
|
113
455
|
|
|
114
456
|
___
|
|
115
457
|
|
|
116
458
|
### toCognitoAttributes
|
|
117
459
|
|
|
118
|
-
|
|
460
|
+
▸ `Const` **toCognitoAttributes**(`userDoc`): `Object`
|
|
461
|
+
|
|
462
|
+
Given a `UserDoc` from the maxcryptor, this returns an object
|
|
463
|
+
which you can provide to `Auth.updateUserAttributes()`. It is
|
|
464
|
+
an object of stringified Json.
|
|
465
|
+
|
|
466
|
+
#### Parameters
|
|
467
|
+
|
|
468
|
+
| Name | Type |
|
|
469
|
+
| :------ | :------ |
|
|
470
|
+
| `userDoc` | `UserDoc` |
|
|
471
|
+
|
|
472
|
+
#### Returns
|
|
473
|
+
|
|
474
|
+
`Object`
|
|
@@ -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,72 +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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
const {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
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,13 +1,13 @@
|
|
|
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("./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
|
+
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("./createAA"), exports);
|