@raytio/types 5.0.0 → 6.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/README.md +400 -267
- package/dist/crypto.d.ts +1 -1
- package/dist/raytio.d.ts +34 -9
- package/dist/schema.d.ts +87 -22
- package/dist/theme.d.ts +5 -0
- package/dist/verification.d.ts +26 -19
- package/dist/verification.js +4 -0
- package/dist/wizard.d.ts +46 -5
- package/package.json +3 -2
- package/src/__tests__/schema.ts +23 -0
- package/src/crypto.ts +2 -1
- package/src/raytio.ts +41 -10
- package/src/schema.ts +103 -29
- package/src/theme.ts +3 -0
- package/src/verification.ts +35 -22
- package/src/wizard.ts +65 -5
package/src/raytio.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Encrypted } from "./crypto";
|
|
2
|
-
import { Colors } from "./theme";
|
|
2
|
+
import { Colors, CustomFonts } from "./theme";
|
|
3
3
|
|
|
4
4
|
/** @internal see Microsoft/TypeScript#202 */
|
|
5
5
|
export type StringWithIdentity<T> = string & { $$typeof$$: T };
|
|
6
6
|
|
|
7
|
+
/** @internal */
|
|
8
|
+
type Json = Record<string, any>; // TODO: (semver breaking) unknown
|
|
9
|
+
|
|
7
10
|
/** A `p_id` is the ID of a @see Relationship */
|
|
8
11
|
export type PId = StringWithIdentity<"PId">;
|
|
9
12
|
/** An `i_id` is the ID of an @see Instance */
|
|
@@ -17,7 +20,6 @@ export type UId = StringWithIdentity<"UId">;
|
|
|
17
20
|
/** An `a_id` is the ID of an @see AA */
|
|
18
21
|
export type AId = StringWithIdentity<"AId">;
|
|
19
22
|
|
|
20
|
-
/** @internal */
|
|
21
23
|
export type DataTypes =
|
|
22
24
|
| "string"
|
|
23
25
|
| "number"
|
|
@@ -27,7 +29,6 @@ export type DataTypes =
|
|
|
27
29
|
| "array"
|
|
28
30
|
| "null";
|
|
29
31
|
|
|
30
|
-
/** @internal */
|
|
31
32
|
export type SubmissionStatus =
|
|
32
33
|
| "Submitted"
|
|
33
34
|
| "Processing"
|
|
@@ -39,7 +40,7 @@ export type SubmissionStatus =
|
|
|
39
40
|
| "Accepted";
|
|
40
41
|
|
|
41
42
|
/** You can supply an option type argument if you know exactly what the properties will be */
|
|
42
|
-
export type ProfileObject<Properties =
|
|
43
|
+
export type ProfileObject<Properties = Json> = {
|
|
43
44
|
n_id: NId;
|
|
44
45
|
properties: Properties;
|
|
45
46
|
labels: string[];
|
|
@@ -49,11 +50,11 @@ export type ProfileObject<Properties = any> = {
|
|
|
49
50
|
* @internal the client adds this, if this PO doesn't actually belong to the current user,
|
|
50
51
|
* i.e. it's actually from a submission. If truthy, it's the `[aId, iId]` of the submission.
|
|
51
52
|
*/
|
|
52
|
-
isFromSubmission?: [aId:
|
|
53
|
+
isFromSubmission?: [aId: AId, iId: IId];
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
/** @internal This is what we send the API */
|
|
56
|
-
export type ProfileObjectForUpload<Properties =
|
|
57
|
+
export type ProfileObjectForUpload<Properties = Json> = {
|
|
57
58
|
properties: Properties;
|
|
58
59
|
document?: {
|
|
59
60
|
content?: string | Encrypted;
|
|
@@ -61,6 +62,7 @@ export type ProfileObjectForUpload<Properties = any> = {
|
|
|
61
62
|
};
|
|
62
63
|
labels?: string[];
|
|
63
64
|
|
|
65
|
+
// TODO: represent the below constraint in the typedef
|
|
64
66
|
// `schema` XOR `n_id` depending on whether creating or updating
|
|
65
67
|
schema?: string; // only if creating a new PO
|
|
66
68
|
n_id?: NId; // only if editing an existing PO
|
|
@@ -81,7 +83,7 @@ export type UrnNodeType =
|
|
|
81
83
|
| "user"
|
|
82
84
|
| "profile_object"
|
|
83
85
|
| "instance"
|
|
84
|
-
| "temp_object" // this will only be encountered in backend environments which lack access to an applicationDecryptor
|
|
86
|
+
| "temp_object" // this will only be encountered in backend environments which lack access to an applicationDecryptor, or from RapidShare
|
|
85
87
|
| "document";
|
|
86
88
|
|
|
87
89
|
/** e.g. "urn:user:..." */
|
|
@@ -106,6 +108,9 @@ export type Lookup = {
|
|
|
106
108
|
label?: string | number;
|
|
107
109
|
children?: Lookup[];
|
|
108
110
|
description?: string;
|
|
111
|
+
|
|
112
|
+
/** used in AkahuDynamicSection only */
|
|
113
|
+
requires_2FA?: boolean;
|
|
109
114
|
};
|
|
110
115
|
|
|
111
116
|
export type AA = {
|
|
@@ -114,19 +119,27 @@ export type AA = {
|
|
|
114
119
|
description?: string;
|
|
115
120
|
/** If a user signs up while completing this form, this message will be sent in the sign up email. */
|
|
116
121
|
aa_introduction?: string;
|
|
117
|
-
picture?:
|
|
122
|
+
picture?: Urn;
|
|
118
123
|
/** Easy to use AA logo url for pasting inot emails */
|
|
119
124
|
picture_url?: string;
|
|
120
125
|
scopes?: string[];
|
|
121
126
|
tags?: string[];
|
|
122
127
|
callback_uri?: string[];
|
|
128
|
+
/** markdown or string help information including [phoneNumber || email] */
|
|
129
|
+
aa_help?: string;
|
|
123
130
|
theme?: {
|
|
124
|
-
|
|
131
|
+
font?: CustomFonts;
|
|
132
|
+
colors?: Colors;
|
|
125
133
|
};
|
|
126
134
|
/** the n_id of the associated service provider */
|
|
127
135
|
service_provider_n_id?: NId;
|
|
128
136
|
/** the id of the associated organisation */
|
|
129
137
|
org_id: string;
|
|
138
|
+
|
|
139
|
+
/** configuration for the submission rules */
|
|
140
|
+
// we know the type should be `ScoreConfig`, but we can't rely that it's valid, or the right version
|
|
141
|
+
ruleset?: unknown;
|
|
142
|
+
|
|
130
143
|
/** @internal */
|
|
131
144
|
_transitions?: unknown[];
|
|
132
145
|
};
|
|
@@ -154,7 +167,7 @@ export type Instance = {
|
|
|
154
167
|
/** @depreacted The status of a submission */
|
|
155
168
|
_state?: SubmissionStatus;
|
|
156
169
|
/** Previous status of the shared information */
|
|
157
|
-
previous_state:
|
|
170
|
+
previous_state: SubmissionStatus;
|
|
158
171
|
/** Hash of the Service Provider ID */
|
|
159
172
|
sub_service_provider_hash?: string;
|
|
160
173
|
/** Service provider ID */
|
|
@@ -171,6 +184,7 @@ export type Instance = {
|
|
|
171
184
|
};
|
|
172
185
|
};
|
|
173
186
|
};
|
|
187
|
+
relationships?: Relationship[];
|
|
174
188
|
};
|
|
175
189
|
|
|
176
190
|
/**
|
|
@@ -191,3 +205,20 @@ export type Organization = {
|
|
|
191
205
|
};
|
|
192
206
|
customer: Record<string, unknown>;
|
|
193
207
|
};
|
|
208
|
+
|
|
209
|
+
/** validation data returned by preVerify (part of the extract&map API) */
|
|
210
|
+
export type Validation = {
|
|
211
|
+
score: number;
|
|
212
|
+
warning?: string[];
|
|
213
|
+
breakdown: {
|
|
214
|
+
[category: string]: {
|
|
215
|
+
passed: boolean;
|
|
216
|
+
/** only present if passed=false */
|
|
217
|
+
code?: number;
|
|
218
|
+
/** only present if passed=false */
|
|
219
|
+
reason?: string;
|
|
220
|
+
/** only present if passed=false */
|
|
221
|
+
severity?: "low" | "medium" | "high";
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
};
|
package/src/schema.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { AA, DataTypes, Organization, Urn } from "./raytio";
|
|
1
|
+
import { AA, DataTypes, NId, Organization, Urn } from "./raytio";
|
|
2
2
|
import { WizardConfig } from "./wizard";
|
|
3
3
|
|
|
4
|
+
/** should be renamed since this applies to ConditionallyVerifiable */
|
|
4
5
|
export type ConditionallyRequired = {
|
|
5
6
|
field: string;
|
|
6
7
|
if: {
|
|
@@ -22,6 +23,8 @@ export type SchemaFieldTag =
|
|
|
22
23
|
| "display:survey"
|
|
23
24
|
| "display:quoting"
|
|
24
25
|
| "display:customModal"
|
|
26
|
+
| "display:terms_conditions"
|
|
27
|
+
| "display:showOnWizard" // added by #837, TODO: document
|
|
25
28
|
| `display:main_media:${string}` // property name to determine what image to display
|
|
26
29
|
// other
|
|
27
30
|
| "action:client_upload"
|
|
@@ -30,16 +33,17 @@ export type SchemaFieldTag =
|
|
|
30
33
|
| "type:extract_required";
|
|
31
34
|
|
|
32
35
|
export type SchemaTag =
|
|
33
|
-
// legacy (TODO: remove these)
|
|
34
|
-
| "type:provider_profile"
|
|
35
|
-
| "type:service_offer"
|
|
36
|
-
| "client_only"
|
|
37
|
-
| "globally_unique_field"
|
|
38
36
|
// action
|
|
37
|
+
| "action:experimental_pass_object_store_id"
|
|
39
38
|
| "action:verify"
|
|
40
|
-
|
|
39
|
+
// camera
|
|
40
|
+
| "default_camera:rear"
|
|
41
|
+
| "default_camera:front"
|
|
42
|
+
// misc
|
|
43
|
+
| `link_to:${/* schemaName */ string}:${/* relationshipType */ string}`
|
|
41
44
|
// type
|
|
42
45
|
| "type:service_provider"
|
|
46
|
+
| "type:service_offer"
|
|
43
47
|
| "type:marketplace"
|
|
44
48
|
| "type:client_only"
|
|
45
49
|
| "type:globally_unique_field";
|
|
@@ -48,21 +52,21 @@ export type SchemaField = {
|
|
|
48
52
|
/** @deprecated don't use, it's inconsistent */
|
|
49
53
|
$id?: string;
|
|
50
54
|
title?: string;
|
|
55
|
+
title_plural?: string;
|
|
51
56
|
description?: string;
|
|
52
57
|
/** readOnly means the Wizard won't show this field */
|
|
53
58
|
readOnly?: boolean;
|
|
54
59
|
examples?: unknown[];
|
|
55
60
|
tags?: SchemaFieldTag[];
|
|
56
61
|
type?: DataTypes;
|
|
57
|
-
enum?:
|
|
62
|
+
enum?: string[];
|
|
58
63
|
maximum?: number;
|
|
59
64
|
minimum?: number;
|
|
60
65
|
/** @deprecated raytio's usage not documented */
|
|
61
66
|
maxLength?: number;
|
|
62
67
|
/** @deprecated raytio's usage not documented */
|
|
63
68
|
minLength?: number;
|
|
64
|
-
/**
|
|
65
|
-
defaultValue?: unknown;
|
|
69
|
+
/** the default value */
|
|
66
70
|
default?: unknown;
|
|
67
71
|
pattern?: string;
|
|
68
72
|
/** whether the field should be encrypted */
|
|
@@ -70,13 +74,17 @@ export type SchemaField = {
|
|
|
70
74
|
format?: "date" | "date-time";
|
|
71
75
|
contentMediaType?: string;
|
|
72
76
|
contentEncoding?: "base64";
|
|
73
|
-
/** for nested
|
|
77
|
+
/** `items` is used for nested arrays, (while `properties` is used for nested objects) */
|
|
74
78
|
items?: {
|
|
75
79
|
type: DataTypes;
|
|
76
80
|
properties: {
|
|
77
81
|
[subFieldName: string]: SchemaField;
|
|
78
82
|
};
|
|
79
83
|
};
|
|
84
|
+
/** `properties` is used for nested objects, (while `items` is used for nested arrays) */
|
|
85
|
+
properties?: {
|
|
86
|
+
[subFieldName: string]: SchemaField;
|
|
87
|
+
};
|
|
80
88
|
|
|
81
89
|
/** If this field refers to a sub-object */
|
|
82
90
|
$ref?: string;
|
|
@@ -98,10 +106,10 @@ export type SchemaField = {
|
|
|
98
106
|
/** URL to a JSON file in the `Lookup` format */
|
|
99
107
|
lookup?: string;
|
|
100
108
|
/** @internal the client adds this - it's the fieldName. */
|
|
101
|
-
$prop
|
|
109
|
+
$prop: string;
|
|
102
110
|
priority?: number;
|
|
103
111
|
/** @internal if supplied, it's the existing field values. Added by the client */
|
|
104
|
-
subObjectRef?:
|
|
112
|
+
subObjectRef?: unknown[];
|
|
105
113
|
/** specifies that the description is formatted in markdown */
|
|
106
114
|
description_decorator?: "md";
|
|
107
115
|
/** if a `pattern` is specified, this is the error message */
|
|
@@ -118,6 +126,8 @@ export type SchemaField = {
|
|
|
118
126
|
};
|
|
119
127
|
/** if this field is a table input, this determines the text to show on the "Add Row" btn */
|
|
120
128
|
add_row_btn_label?: string;
|
|
129
|
+
/** if this field is a table input, this determines the text to show if the table is empty */
|
|
130
|
+
table_empty_message?: string;
|
|
121
131
|
|
|
122
132
|
/**
|
|
123
133
|
* used on fields that are a signature file picker, see !849
|
|
@@ -138,26 +148,32 @@ export type SchemaField = {
|
|
|
138
148
|
* `name`. This type can be used for both the schema and for individual fields.
|
|
139
149
|
*/
|
|
140
150
|
export type Schema = {
|
|
151
|
+
/** @deprecated don't use this */
|
|
141
152
|
$id?: string;
|
|
142
153
|
$schema?: string;
|
|
154
|
+
n_id?: NId;
|
|
143
155
|
|
|
144
|
-
/**
|
|
156
|
+
/** these fields will always exist on schema */
|
|
145
157
|
name: string;
|
|
158
|
+
title: string;
|
|
159
|
+
description: string;
|
|
146
160
|
|
|
161
|
+
/** plural version of the title */
|
|
162
|
+
title_plural?: string;
|
|
147
163
|
/**
|
|
148
164
|
* the group that a schema belongs to, such as "passports". This is useful for
|
|
149
165
|
* forms that accept different types of similar documents.
|
|
150
166
|
*/
|
|
151
167
|
schema_group?: string;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
description?: string;
|
|
168
|
+
/** the localized title of the `schema_group`. added by the client */
|
|
169
|
+
group_title?: string;
|
|
155
170
|
|
|
156
171
|
/** @deprecated not sure why a schema would have this, only fields should */
|
|
157
172
|
$ref?: string;
|
|
158
173
|
|
|
159
174
|
tags?: SchemaTag[];
|
|
160
|
-
|
|
175
|
+
/** originally `string[]`, the client modifies this */
|
|
176
|
+
verified_fields?: (string | ConditionallyRequired)[];
|
|
161
177
|
|
|
162
178
|
wasExpandedByClient?: boolean;
|
|
163
179
|
/** added by client */
|
|
@@ -172,13 +188,11 @@ export type Schema = {
|
|
|
172
188
|
then?: Schema;
|
|
173
189
|
}[];
|
|
174
190
|
|
|
175
|
-
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
*/
|
|
181
|
-
properties?: {
|
|
191
|
+
/** If this tag exists, the schema is deprecated. ISO Date. */
|
|
192
|
+
end_date?: string;
|
|
193
|
+
|
|
194
|
+
/** 🚨 Note that there are cases where properties are undefined, e.g. if the schema is a sub-object */
|
|
195
|
+
properties: {
|
|
182
196
|
[fieldName: string]: SchemaField;
|
|
183
197
|
};
|
|
184
198
|
|
|
@@ -187,9 +201,25 @@ export type Schema = {
|
|
|
187
201
|
[locale: string]: {
|
|
188
202
|
// @ts-expect-error I don't understand what's wrong
|
|
189
203
|
$schema: Schema;
|
|
190
|
-
// not that for entries that start in "group:", only the title field will be used.
|
|
204
|
+
// not that for entries that start in "group:" or $loading_, only the title field will be used.
|
|
205
|
+
// ^ the exception is `group:{GROUP_NAME}:{SUB_GROUP}.field` which is used for the combined field title/desc
|
|
191
206
|
// normal fields can specify any field attributes to override.
|
|
192
|
-
|
|
207
|
+
|
|
208
|
+
// see !1796 for where these are used
|
|
209
|
+
$loading_extract: { title: string };
|
|
210
|
+
$loading_verify: { title: string };
|
|
211
|
+
$loading_save: { title: string };
|
|
212
|
+
$loading_update: { title: string };
|
|
213
|
+
$loading_upload: { title: string };
|
|
214
|
+
$loading_create_sub_obj: { title: string };
|
|
215
|
+
$loading_permission: { title: string };
|
|
216
|
+
$loading_link_to_person: { title: string };
|
|
217
|
+
$loading_delete_pending_ver: { title: string };
|
|
218
|
+
$loading_pending_ver_resubmit: { title: string };
|
|
219
|
+
|
|
220
|
+
[fieldNameOrGroupName: string]: Omit<SchemaField, "$prop"> & {
|
|
221
|
+
title_plural?: string;
|
|
222
|
+
};
|
|
193
223
|
};
|
|
194
224
|
};
|
|
195
225
|
/** @internal the client adds this after processing the i18n property */
|
|
@@ -202,13 +232,14 @@ export type Schema = {
|
|
|
202
232
|
* the estimated loading times in seconds for various API calls. The client adds
|
|
203
233
|
* this field after processing the schema tags.
|
|
204
234
|
*/
|
|
205
|
-
timing?: Record<"extract" | "
|
|
235
|
+
timing?: Record<"extract" | "live_person" | "verify_pending_delay", number>;
|
|
206
236
|
|
|
207
237
|
relationships?: {
|
|
208
238
|
relationship_name: string;
|
|
209
239
|
direction: "from";
|
|
210
240
|
type: string;
|
|
211
|
-
|
|
241
|
+
/** if required_relationship then use will be alerted in relationship menu and won't be able to share PO unless filled out */
|
|
242
|
+
required_relationship?: boolean;
|
|
212
243
|
/** Specify `oneOf` XOR `anyOf`. It's a list of schema names, or `"instance"` (see #784) */
|
|
213
244
|
oneOf?: string[];
|
|
214
245
|
/** Specify `oneOf` XOR `anyOf` It's a list of schema names. */
|
|
@@ -258,6 +289,15 @@ export type Schema = {
|
|
|
258
289
|
properties: Record<string, unknown>;
|
|
259
290
|
}[];
|
|
260
291
|
|
|
292
|
+
/** Relationships that should be created */
|
|
293
|
+
relationships?: {
|
|
294
|
+
/** will normally look like `"{n_id:profile_objects[0]}"` */
|
|
295
|
+
from: string;
|
|
296
|
+
to: string;
|
|
297
|
+
type: string;
|
|
298
|
+
properties?: Record<string, string>;
|
|
299
|
+
}[];
|
|
300
|
+
|
|
261
301
|
/**
|
|
262
302
|
* Organizations that should be created. NOTE: if multiple are specified, when the wizard
|
|
263
303
|
* completes, the _first one_ will be selected
|
|
@@ -274,5 +314,39 @@ export type Schema = {
|
|
|
274
314
|
}[];
|
|
275
315
|
}[];
|
|
276
316
|
}[];
|
|
317
|
+
|
|
318
|
+
/** The relative path in the client to redirect to once finished. May include variables */
|
|
319
|
+
return_to?: string;
|
|
277
320
|
};
|
|
278
321
|
};
|
|
322
|
+
|
|
323
|
+
/** Only certain properties from the schema */
|
|
324
|
+
export type SchemaMetadata = Pick<
|
|
325
|
+
Schema,
|
|
326
|
+
// if you update this list, also update SCHEMA_METADATA_FIELDS
|
|
327
|
+
| "name"
|
|
328
|
+
| "title"
|
|
329
|
+
| "description"
|
|
330
|
+
| "schema_group"
|
|
331
|
+
| "end_date"
|
|
332
|
+
| "i18n"
|
|
333
|
+
| "display"
|
|
334
|
+
| "tags"
|
|
335
|
+
// added by the client
|
|
336
|
+
| "clientLocale"
|
|
337
|
+
| "groupNames"
|
|
338
|
+
| "title_plural"
|
|
339
|
+
| "group_title"
|
|
340
|
+
> & {
|
|
341
|
+
/**
|
|
342
|
+
* @deprecated this prop exists so that SchemaMetadata does not extend Schema.
|
|
343
|
+
* use `getSchema(schemaName)` to fetch the full schema
|
|
344
|
+
*/
|
|
345
|
+
__typeof__: "You cannot supply SchemaMetadata to a function that expects Schema";
|
|
346
|
+
|
|
347
|
+
isProfileSchema: boolean;
|
|
348
|
+
isSpSchema: boolean;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
/** @ignore */
|
|
352
|
+
export type RelationDefinition = NonNullable<Schema["relationships"]>[number];
|
package/src/theme.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type Colors = {
|
|
|
13
13
|
/** only used by the fancy layout on the login screen */
|
|
14
14
|
raytioOrangeShade: string;
|
|
15
15
|
successGreen: string;
|
|
16
|
+
loadingYellow: string;
|
|
16
17
|
errorRed: string;
|
|
17
18
|
textLight: string;
|
|
18
19
|
textMedium: string;
|
|
@@ -23,3 +24,5 @@ export type Colors = {
|
|
|
23
24
|
blankBackground: string;
|
|
24
25
|
blank: string;
|
|
25
26
|
};
|
|
27
|
+
|
|
28
|
+
export type CustomFonts = { header?: string; body?: string };
|
package/src/verification.ts
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
import { NId, ProfileObject } from "./raytio";
|
|
2
2
|
|
|
3
|
+
export type VerificationPayload<WithValue extends boolean> = {
|
|
4
|
+
// we deliberately haven't defined 'sub'
|
|
5
|
+
field: string;
|
|
6
|
+
schema?: string;
|
|
7
|
+
metadata?: Record<string, unknown>;
|
|
8
|
+
passed: boolean;
|
|
9
|
+
request_div: string;
|
|
10
|
+
/** @deprecated don't use this, it looks like the schema name but it's not */
|
|
11
|
+
source: string;
|
|
12
|
+
/** the n_id of the parent profile object that this ver belongs (NOT the n_id of the field) */
|
|
13
|
+
source_n_id?: NId;
|
|
14
|
+
/** like `source_n_id` */
|
|
15
|
+
source_hashed_n_id?: NId;
|
|
16
|
+
type?: null;
|
|
17
|
+
v_id: string;
|
|
18
|
+
verification_date: string;
|
|
19
|
+
verifier_id?: NId;
|
|
20
|
+
verifier_source_id?: NId;
|
|
21
|
+
verifier_service_id?: NId;
|
|
22
|
+
verifier_div: string;
|
|
23
|
+
/** ISO Date */
|
|
24
|
+
valid_until?: string;
|
|
25
|
+
// we are disabling the eslint rule beacuse even tho `{}` acts illogically in typescript,
|
|
26
|
+
// in this case it's working as expected in the intersection type, see
|
|
27
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-632833366
|
|
28
|
+
// and https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-645510515
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
30
|
+
} & (WithValue extends true ? { value: string | number } : {});
|
|
31
|
+
|
|
3
32
|
/**
|
|
4
33
|
* Different APIs inconsistently include the `value` prop. If you know it exists,
|
|
5
34
|
* use `Verification<true>`, otherwise just `Verification`. Verifications from
|
|
@@ -17,27 +46,7 @@ export type Verification<WithValue extends boolean = false> = ProfileObject<{
|
|
|
17
46
|
verifications: [
|
|
18
47
|
{
|
|
19
48
|
signature: string;
|
|
20
|
-
data:
|
|
21
|
-
field: string;
|
|
22
|
-
metadata?: Record<string, unknown>;
|
|
23
|
-
passed: boolean;
|
|
24
|
-
request_div: string;
|
|
25
|
-
/** @deprecated don't use this, it looks like the schema name but it's not */
|
|
26
|
-
source: string;
|
|
27
|
-
/** the n_id of the parent profile object that this ver belongs (NOT the n_id of the field) */
|
|
28
|
-
source_n_id: NId;
|
|
29
|
-
v_id: string;
|
|
30
|
-
verification_date: string;
|
|
31
|
-
verifier_id?: NId;
|
|
32
|
-
verifier_source_id?: NId;
|
|
33
|
-
verifier_service_id?: NId;
|
|
34
|
-
verifier_div: string;
|
|
35
|
-
// we are disabling the eslint rule beacuse even tho `{}` acts illogically in typescript,
|
|
36
|
-
// in this case it's working as expected in the intersection type, see
|
|
37
|
-
// https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-632833366
|
|
38
|
-
// and https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-645510515
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
40
|
-
} & (WithValue extends true ? { value: string | number } : {});
|
|
49
|
+
data: VerificationPayload<WithValue>;
|
|
41
50
|
},
|
|
42
51
|
];
|
|
43
52
|
}>;
|
|
@@ -46,6 +55,8 @@ export type Verification<WithValue extends boolean = false> = ProfileObject<{
|
|
|
46
55
|
* "Not Verified" means show no badge, cf. "Verified False" means the
|
|
47
56
|
* verifier revealed that the data was wrong. So show a ❌
|
|
48
57
|
*/
|
|
58
|
+
// We cannot change the enum values, since ScoreRules have been generated
|
|
59
|
+
// with the enum values hardcoded. The enum value are also used to find the "best" or "worst" verification (lower=better)
|
|
49
60
|
export enum FieldVerification {
|
|
50
61
|
Verified = 60_001,
|
|
51
62
|
NotVerified,
|
|
@@ -53,6 +64,8 @@ export enum FieldVerification {
|
|
|
53
64
|
Expired,
|
|
54
65
|
}
|
|
55
66
|
|
|
67
|
+
// We cannot change the enum values, since ScoreRules have been generated
|
|
68
|
+
// with the enum values hardcoded.
|
|
56
69
|
export enum POVerification {
|
|
57
70
|
FullyVerified = 70_001,
|
|
58
71
|
PartiallyVerified,
|
|
@@ -75,7 +88,7 @@ export type VerificationProvider = {
|
|
|
75
88
|
/** This is what @raytio/core exposes, which is more useable than @see Verification */
|
|
76
89
|
export type RealVer = {
|
|
77
90
|
fieldName: string;
|
|
78
|
-
value:
|
|
91
|
+
value: unknown;
|
|
79
92
|
provider: VerificationProvider;
|
|
80
93
|
signature: string;
|
|
81
94
|
/**
|
package/src/wizard.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { AId } from "./raytio";
|
|
2
2
|
|
|
3
3
|
/** configuration data for a single wizard page (@see WizardConfig) */
|
|
4
|
-
export
|
|
4
|
+
export type WizardPage = {
|
|
5
5
|
/** if undefined, the schema title will be used */
|
|
6
|
-
name?: string;
|
|
6
|
+
name?: string | symbol;
|
|
7
7
|
filter: "oneOf" | "anyOf";
|
|
8
8
|
schemas: string[];
|
|
9
9
|
|
|
10
|
+
/** the fallback description, if there isn't one for the specific situation */
|
|
10
11
|
description?: string;
|
|
12
|
+
description_select?: string;
|
|
13
|
+
description_create?: string;
|
|
14
|
+
description_update?: string;
|
|
15
|
+
|
|
11
16
|
/** if explictly == false, then it's an AO (not a PO), in which case there can only be one schema */
|
|
12
17
|
profile?: boolean;
|
|
13
18
|
/** if true this page can be skipped. The PageResult wil be undefined */
|
|
@@ -28,13 +33,46 @@ export interface WizardPage {
|
|
|
28
33
|
/** whether the field descriptions should be shown */
|
|
29
34
|
display_field_description?: boolean;
|
|
30
35
|
|
|
31
|
-
/** if supplied, only the fields that are listed should be shared */
|
|
32
|
-
|
|
36
|
+
/** if supplied, only the fields that are listed should be shared (#520, #1024) */
|
|
37
|
+
field_list?: string[];
|
|
33
38
|
|
|
34
39
|
/** custom text & header that's displayed on reverfication modal for expired PO */
|
|
35
40
|
reverify_header?: string;
|
|
36
41
|
reverify_text?: string;
|
|
37
|
-
|
|
42
|
+
|
|
43
|
+
/** do not allow uploading in ImageDynamicSection if this is explictly false */
|
|
44
|
+
allow_upload?: boolean;
|
|
45
|
+
|
|
46
|
+
/** for ImageDynamicSection, the minimum score to be treated as a pass */
|
|
47
|
+
extract_threshold?: number;
|
|
48
|
+
|
|
49
|
+
/** for ImageDynamicSection, the action to take if pre-verify passes */
|
|
50
|
+
extract_threshold_pass_action?: "review" | "next_step";
|
|
51
|
+
|
|
52
|
+
/** for ImageDynamicSection, the action to take if pre-verify fails */
|
|
53
|
+
extract_threshold_fail_action?:
|
|
54
|
+
| "capture" // go back
|
|
55
|
+
| "capture_review" // prompt user to go back OR continue to review screen. If this option is chosen, licenses that do not meet the threshold can be submited
|
|
56
|
+
| "recapture_or_next_step" // prompt user to go back OR continue & skip the review page. If this option is chosen, licenses that do not meet the threshold can be submited
|
|
57
|
+
| "review" // continue to review page
|
|
58
|
+
| "next_step"; // continue & skip the review page
|
|
59
|
+
|
|
60
|
+
/** for ImageDynamicSection, the action to take if the API returns no `validation: {}` object */
|
|
61
|
+
extract_threshold_null_action?: WizardPage["extract_threshold_fail_action"];
|
|
62
|
+
|
|
63
|
+
/** if `false`, ProfileObjects created while completing the form will not be verified. `undefined` implies `true` */
|
|
64
|
+
verify_data?: boolean;
|
|
65
|
+
|
|
66
|
+
/** a list of fields that should not be required, even if the schema says they're required */
|
|
67
|
+
optional_fields?: string[];
|
|
68
|
+
|
|
69
|
+
/** the information to share. undefined implies both. */
|
|
70
|
+
// TODO: 'profile' is not supported yet
|
|
71
|
+
share?: "profile" | "verification" | "both";
|
|
72
|
+
|
|
73
|
+
/** can you force the colour theme to change for just one page (#1066, #1074). At the moment this on pages that use WebcamImageCapture */
|
|
74
|
+
display_mode?: "light" | "dark" | "default";
|
|
75
|
+
};
|
|
38
76
|
|
|
39
77
|
/**
|
|
40
78
|
* when a form link is generated, this is what gets saved on the API.
|
|
@@ -75,4 +113,26 @@ export type WizardConfig = {
|
|
|
75
113
|
|
|
76
114
|
/** if specified, the email addresses that a submission should be sent to */
|
|
77
115
|
emails?: string[];
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* whether the passwordless-signup process should be used if the user visits
|
|
119
|
+
* this form, and they are not logged in. If false, the standard sign-up
|
|
120
|
+
* process will be used
|
|
121
|
+
*/
|
|
122
|
+
quick_onboard?: boolean;
|
|
123
|
+
|
|
124
|
+
/** the loading message to show next to the spinner after the review screen */
|
|
125
|
+
sharing_data_message?: string;
|
|
126
|
+
|
|
127
|
+
/** a list of relationships that should be created after the wizard completes (see #987) */
|
|
128
|
+
relationships?: {
|
|
129
|
+
/** schema name */
|
|
130
|
+
from: string;
|
|
131
|
+
/** schema name */
|
|
132
|
+
to: string;
|
|
133
|
+
/** relationship type */
|
|
134
|
+
type: string;
|
|
135
|
+
/** relationship properties */
|
|
136
|
+
properties?: Record<string, any>;
|
|
137
|
+
}[];
|
|
78
138
|
};
|