@raytio/types 7.1.0 → 7.3.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/src/raytio.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Encrypted } from "./crypto";
2
- import { Colors, CustomFonts } from "./theme";
1
+ import type { Encrypted } from "./crypto";
2
+ import type { Colors, CustomFonts } from "./theme";
3
3
 
4
4
  /** @internal see Microsoft/TypeScript#202 */
5
5
  export type StringWithIdentity<T> = string & { $$typeof$$: T };
@@ -13,6 +13,8 @@ export type PId = StringWithIdentity<"PId">;
13
13
  export type IId = StringWithIdentity<"IId">;
14
14
  /** An `n_id` is the ID of a {@link ProfileObject} */
15
15
  export type NId = StringWithIdentity<"NId">;
16
+ /** ⚠️ This ID duplicates the {@link NId} and should only be used in exceptional circumstances */
17
+ export type NId2 = StringWithIdentity<"NId2">;
16
18
  /** A `g_id` is the ID of a group */
17
19
  export type GId = StringWithIdentity<"GId">;
18
20
  /** A `u_id` is the ID of a user */
@@ -25,8 +27,10 @@ export type OId = StringWithIdentity<"OId">;
25
27
  export type WId = StringWithIdentity<"WId">;
26
28
  /** An `l_id` is the ID of any data stored in the KV-Store */ // e.g. StoredWizardConfig and VerBundleMetadata
27
29
  export type LId = StringWithIdentity<"LId">;
28
-
29
- export type AnyId = PId | IId | NId | GId | UId | AId | OId | WId;
30
+ /** A `k_id` (also called a `aack_id` or a `publicKeyId`) is the ID of an AA's public key */
31
+ export type KId = StringWithIdentity<"KId">;
32
+ /** A `SchemaName` is the ID of a {@link Schema} */
33
+ export type SchemaName = StringWithIdentity<"SchemaName">;
30
34
 
31
35
  export type DataTypes =
32
36
  | "string"
@@ -47,8 +51,33 @@ export type SubmissionStatus =
47
51
  | "Received"
48
52
  | "Accepted";
49
53
 
54
+ /**
55
+ * Every object in the new database has these fields. In the
56
+ * interest of type-safety, the `id` should be one of the
57
+ * well-known IDs that extend {@link StringWithIdentity} (e.g.
58
+ * {@link NId} or {@link AId}). If the ID is irrelevant, then
59
+ * use `CommonFields<never>` rather than `CommonFields<string>`.
60
+ * This will deliberately prevent you from utilising the `id`
61
+ * field until you define a special type for that ID.
62
+ *
63
+ * This is especially important with the new API where it is much
64
+ * easier to mix up the different types of IDs.
65
+ */
66
+ export type CommonFields<
67
+ IdType extends StringWithIdentity<string>,
68
+ Metadata = unknown,
69
+ > = {
70
+ id: IdType;
71
+ /** ISO Date */
72
+ start_date: string;
73
+ /** ISO Date */
74
+ end_date: string;
75
+ active: boolean;
76
+ metadata: Metadata | undefined;
77
+ };
78
+
50
79
  /** You can supply an option type argument if you know exactly what the properties will be */
51
- export type ProfileObject<Properties = Json> = {
80
+ export type ProfileObject<Properties = Json> = Partial<CommonFields<NId2>> & {
52
81
  n_id: NId;
53
82
  properties: Properties;
54
83
  labels: string[];
@@ -72,21 +101,10 @@ export type ProfileObjectForUpload<Properties = Json> = {
72
101
 
73
102
  // TODO: represent the below constraint in the typedef
74
103
  // `schema` XOR `n_id` depending on whether creating or updating
75
- schema?: string; // only if creating a new PO
104
+ schema?: SchemaName; // only if creating a new PO
76
105
  n_id?: NId; // only if editing an existing PO
77
106
  };
78
107
 
79
- /**
80
- * arbitrary key-values pairs stored on a Profile Object.
81
- * May contain nested JSON and {@link Encrypted} properties.
82
- *
83
- * There are some limits to field names: they cannot be called
84
- * `__signature` nor can they include the character sequence `<=>`.
85
- *
86
- * @deprecated - use {@link Json}
87
- */
88
- export type Properties = Json;
89
-
90
108
  export type UrnNodeType =
91
109
  | "user"
92
110
  | "profile_object"
@@ -96,7 +114,13 @@ export type UrnNodeType =
96
114
  | "document";
97
115
 
98
116
  /** e.g. "urn:user:..." */
99
- export type Urn = `urn:${UrnNodeType}:${AnyId}`;
117
+ export type Urn =
118
+ | `urn:user:${UId}`
119
+ | `urn:profile_object:${NId}`
120
+ | `urn:instance:${IId}`
121
+ | `urn:temp_object:${LId}`
122
+ | `urn:schema:${SchemaName}`
123
+ | `urn:document:${NId}`;
100
124
 
101
125
  export type Relationship = {
102
126
  start: Urn;
@@ -108,6 +132,9 @@ export type Relationship = {
108
132
  name?: string;
109
133
  [fieldName: string]: unknown;
110
134
  };
135
+ start_date?: string;
136
+ end_date?: string;
137
+ active?: boolean;
111
138
  };
112
139
 
113
140
  export type Lookup = {
@@ -135,8 +162,9 @@ export type AA = {
135
162
  description?: string;
136
163
  /** If a user signs up while completing this form, this message will be sent in the sign up email. */
137
164
  aa_introduction?: string;
165
+ /** @deprecated see !2101 */
138
166
  picture?: Urn;
139
- /** Easy to use AA logo url for pasting inot emails */
167
+ /** Easy to use AA logo url for pasting into emails */
140
168
  picture_url?: string;
141
169
  scopes?: string[];
142
170
  tags?: AATag[];
@@ -159,17 +187,24 @@ export type AA = {
159
187
  /** if true, only specific email addresses can submit the form */
160
188
  auth_list_enabled?: boolean;
161
189
 
190
+ /** Currently Unused Attributes */
191
+ start_date?: Date;
192
+ end_date?: Date;
193
+ active?: boolean;
194
+ key?: string;
195
+ logout_uri?: string[];
196
+ metadata?: unknown;
197
+ secret?: unknown;
198
+
162
199
  /** @internal */
163
200
  transitions?: unknown[];
164
201
  };
165
202
 
166
- export type Instance = {
167
- /** Access application instance ID */
168
- i_id: IId;
203
+ export type InstanceWithoutData = CommonFields<IId, { message?: string }> & {
169
204
  /** ID of the access application this submission was made to */
170
- a_id: AId;
171
- /** name of the access application this submission was made to */
172
- aa_name: string;
205
+ aa_id: AId;
206
+ /** ID of the public key for this AA */
207
+ aack_id: KId;
173
208
  /** Code that validates information has been shared */
174
209
  confirmation_code: string;
175
210
  /** reference provided by the user who shared the data */
@@ -177,37 +212,50 @@ export type Instance = {
177
212
  /** Email of user who shared the data */
178
213
  data_provider_email: string;
179
214
  thread: string;
180
- /** Latest date in which the shared information was available */
181
- end_date: string;
182
- /** Earliest date on which the shared information was available */
183
- start_date: string;
184
215
  /** The status of a submission */
185
216
  state: SubmissionStatus;
186
- /** @deprecated The status of a submission */
187
- _state?: SubmissionStatus;
188
- /** Previous status of the shared information */
189
- previous_state: SubmissionStatus;
190
217
  /** Hash of the Service Provider ID */
191
- sub_service_provider_hash?: string;
218
+ sub_service_provider_hash: string;
192
219
  /** Service provider ID */
193
- service_provider_n_id?: NId;
194
- /** data associated is access application's instance */
220
+ service_provider_n_id: NId;
221
+
222
+ /** added by the client once it calculates the score */
223
+ // Defined as `unknown` instead of `ScoreResult` because it could be nonsense,
224
+ // or a deprected version of `ScoreResult`.
225
+ score?: unknown;
226
+
227
+ // Currently Unused properties
228
+ /** Previous status of the shared information */
229
+ previous_state?: SubmissionStatus;
230
+ /** Device Id */
231
+ device_id?: unknown;
232
+ /** Source IP */
233
+ source_ip?: unknown;
234
+ /** Related Offers */
235
+ related_offers?: unknown;
236
+ /** Instance Version */
237
+ instance_version?: unknown;
238
+ /** Footer Html */
239
+ platform_footer_html?: unknown;
240
+ /** Related Service Types */
241
+ related_service_types?: unknown;
242
+ };
243
+
244
+ /**
245
+ * The API used to store data in this format, but it no
246
+ * longer does :( so `@raytio/core` reconstructs this object.
247
+ */
248
+ export type Instance = InstanceWithoutData & {
195
249
  profile_objects: ProfileObject[];
196
- // TODO: (semver breaking) mark as optional since the get-shared-data API doesn't return keys
197
250
  keys: {
198
- [nId: NId]: {
251
+ // this is no longer keyed by the nId,
252
+ [nId2: NId2]: {
199
253
  [fieldName: string]: {
200
254
  data: string;
201
- n_id: NId;
202
255
  };
203
256
  };
204
257
  };
205
- relationships?: Relationship[];
206
-
207
- /** added by the client once it calculates the score */
208
- // Defined as `unknown` instead of `ScoreResult` because it could be nonsense,
209
- // or a deprected version of `ScoreResult`.
210
- score?: unknown;
258
+ relationships: Relationship[];
211
259
  };
212
260
 
213
261
  /**
@@ -218,15 +266,8 @@ export type Organization = {
218
266
  id: OId;
219
267
  name: string;
220
268
  email: string;
221
- address: {
222
- locationType: string;
223
- street1: string;
224
- street2: string;
225
- city: string;
226
- region: string;
227
- country: string;
228
- };
229
- customer: Record<string, unknown>;
269
+ address: unknown; // Waiting on Backend Progress Before being properly updated (as of #1361)
270
+ customer: unknown; // Waiting on Backend Progress Before being properly updated (as of #1361) (was previously Record<string, unknown>)
230
271
  };
231
272
 
232
273
  /** @internal some APIs now return extra info */
package/src/schema.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { AA, DataTypes, Organization, Urn } from "./raytio";
2
- import { WizardConfig } from "./wizard";
1
+ import type { AA, DataTypes, Organization, SchemaName, Urn } from "./raytio";
2
+ import type { WizardConfig } from "./wizard";
3
3
 
4
4
  /** should be renamed since this applies to ConditionallyVerifiable */
5
5
  export type ConditionallyRequired = {
@@ -33,6 +33,7 @@ export type SchemaFieldTag =
33
33
  | "date_component:year"
34
34
  // other
35
35
  | "action:client_upload"
36
+ | "action:require_webauthn"
36
37
  | "verify:show_if_pending"
37
38
  | "special:hide_select_behind_button"
38
39
  | "type:capture_geolocation" // triggers the wizard's GeoLocationInput field
@@ -103,7 +104,7 @@ export type SchemaField = {
103
104
  };
104
105
 
105
106
  /** If this field refers to a sub-object */
106
- $ref?: string;
107
+ $ref?: SchemaName;
107
108
 
108
109
  /**
109
110
  * @internal
@@ -164,15 +165,17 @@ export type ServerSchemaField = Omit<SchemaField, "$prop">;
164
165
 
165
166
  /** not exported. Attributes that are identical in both client schema & server schema */
166
167
  export type CommonSchemaAttributes = {
167
- type?: DataTypes;
168
-
169
168
  /** these fields will always exist on schema */
170
- name: string;
171
169
  title: string;
172
170
  description: string;
171
+ /** specifies that the description is formatted in markdown */
172
+ description_decorator?: "md";
173
+
174
+ schema_type?: SchemaType;
173
175
 
174
176
  /** plural version of the title */
175
177
  title_plural?: string;
178
+
176
179
  /**
177
180
  * the group that a schema belongs to, such as "passports". This is useful for
178
181
  * forms that accept different types of similar documents.
@@ -200,6 +203,10 @@ export type CommonSchemaAttributes = {
200
203
  $loading_link_to_person: { title: string };
201
204
  $loading_delete_pending_ver: { title: string };
202
205
  $loading_pending_ver_resubmit: { title: string };
206
+ $loading_long_verification_message: {
207
+ title?: string;
208
+ description?: string;
209
+ };
203
210
 
204
211
  [fieldNameOrGroupName: string]: ServerSchemaField & {
205
212
  title_plural?: string;
@@ -214,9 +221,9 @@ export type CommonSchemaAttributes = {
214
221
  /** if required_relationship then use will be alerted in relationship menu and won't be able to share PO unless filled out */
215
222
  required_relationship?: boolean;
216
223
  /** Specify `oneOf` XOR `anyOf`. It's a list of schema names, or `"instance"` (see #784) */
217
- oneOf?: string[];
224
+ oneOf?: (SchemaName | "instance")[];
218
225
  /** Specify `oneOf` XOR `anyOf` It's a list of schema names. */
219
- anyOf?: string[];
226
+ anyOf?: SchemaName[];
220
227
 
221
228
  /** assume TRUE if not specified */
222
229
  multiple?: boolean;
@@ -252,7 +259,7 @@ export type CommonSchemaAttributes = {
252
259
  onboard_properties?: {
253
260
  /** Profile Objects that should be created */
254
261
  profile_objects?: {
255
- schema_name: string;
262
+ schema_name: SchemaName;
256
263
  properties: Record<string, unknown>;
257
264
  }[];
258
265
 
@@ -292,6 +299,12 @@ export type CommonSchemaAttributes = {
292
299
  * of what the API returns.
293
300
  */
294
301
  export type Schema = CommonSchemaAttributes & {
302
+ /** added by the client, copied from {@link WrappedSchema} */
303
+ name: SchemaName;
304
+
305
+ /** added by client */
306
+ type?: DataTypes;
307
+
295
308
  /** the localized title of the `schema_group`. added by the client */
296
309
  group_title?: string;
297
310
 
@@ -336,6 +349,9 @@ export type Schema = CommonSchemaAttributes & {
336
349
  isSpSchema?: boolean;
337
350
  };
338
351
 
352
+ /** Type Classification of a Schema returned by API */
353
+ export type SchemaType = "ss" | "ps" | "us";
354
+
339
355
  /** This is what's returned by the API */
340
356
  export type WrappedSchema = {
341
357
  active: true;
@@ -343,9 +359,12 @@ export type WrappedSchema = {
343
359
  start_date: string;
344
360
  /** ISO Date. If this tag exists, the schema is deprecated. */
345
361
  end_date: string;
346
- name: string;
347
- type: "ss" | "ps" | "us";
348
- version: string;
362
+
363
+ /** Schema Name Type and Version Properties */
364
+ schema_name: SchemaName;
365
+ schema_type: SchemaType;
366
+ schema_version: string;
367
+
349
368
  /** whether the \`version\` is the latest version */
350
369
  version_current: boolean;
351
370
  schema: CommonSchemaAttributes & {
@@ -355,6 +374,7 @@ export type WrappedSchema = {
355
374
  $schema?: string;
356
375
 
357
376
  definitions?: Record<string, { $ref: Urn }>;
377
+
358
378
  allOf?: {
359
379
  $ref?: string;
360
380
  if?: Partial<WrappedSchema["schema"]>;
@@ -1,10 +1,37 @@
1
- import { NId, ProfileObject } from "./raytio";
1
+ import type { NId, ProfileObject, SchemaName } from "./raytio";
2
+
3
+ // see #659
4
+ export enum SafeHarbourCode {
5
+ /** “a match has been made on each the Full Name, Address and Date of Birth” */
6
+ M1 = "M1",
7
+ /** “a match has been made on both Full Name and Date of Birth (but not Address)” */
8
+ M2 = "M2",
9
+ /** “a match has been made on both Full Name and Address (but not Date of Birth)” */
10
+ N1 = "N1",
11
+ }
2
12
 
3
13
  export type VerificationPayload<WithValue extends boolean> = {
4
14
  // we deliberately haven't defined 'sub'
5
15
  field: string;
6
- schema?: string;
7
- metadata?: Record<string, unknown>;
16
+ schema?: SchemaName;
17
+ metadata?: {
18
+ safeHarbourScore?: SafeHarbourCode;
19
+ status?: "pending";
20
+ pending_details?: {
21
+ /**
22
+ * for pending verifications - whether the verifier will complete fast enough that
23
+ * we can show a loading indicator. If not, the user has to come back another day.
24
+ */
25
+ pending_time: "short" | "long";
26
+ /**
27
+ * for pending verifications - whether further user interaction is required to
28
+ * complete the verification, or if it will complete silently in the background.
29
+ */
30
+ pending_type: "time" | "user";
31
+ };
32
+
33
+ [otherAttributes: string]: unknown;
34
+ };
8
35
  passed: boolean;
9
36
  request_div: string;
10
37
  /** @deprecated don't use this, it looks like the schema name but it's not */
@@ -45,6 +72,15 @@ export type Verification<WithValue extends boolean = false> = ProfileObject<{
45
72
  {
46
73
  signature: string;
47
74
  data: VerificationPayload<WithValue>;
75
+
76
+ /** undefined for data created before July 2023 */
77
+ key_id?: string;
78
+ /** undefined for data created before July 2023 */
79
+ key_urn?: string;
80
+ /** undefined for data created before July 2023 */
81
+ signing_algorithm?: "RSASSA_PSS_SHA_512";
82
+ /** undefined for data created before July 2023 */
83
+ hashing_algorithm?: "SHA512";
48
84
  },
49
85
  ];
50
86
  }>;
@@ -95,7 +131,7 @@ export type RealVer = {
95
131
  */
96
132
  verified: boolean;
97
133
  /** arbitary metadata returned by the verifier */
98
- metadata?: Record<string, unknown>;
134
+ metadata?: VerificationPayload<false>["metadata"];
99
135
  /** nId of the verification */
100
136
  nID: NId;
101
137
  /** nId of the PO that the verification belongs to. Could be undefined */
package/src/wizard.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AId } from "./raytio";
1
+ import type { AId, SchemaName } from "./raytio";
2
2
 
3
3
  export type WizardPageTag =
4
4
  // actions
@@ -9,7 +9,7 @@ export type WizardPage = {
9
9
  /** if undefined, the schema title will be used */
10
10
  name?: string | symbol;
11
11
  filter: "oneOf" | "anyOf";
12
- schemas: string[];
12
+ schemas: SchemaName[];
13
13
 
14
14
  /** the fallback description, if there isn't one for the specific situation */
15
15
  description?: string;
@@ -110,9 +110,9 @@ export type WizardConfig = {
110
110
  /** number of days in the future */
111
111
  expiry_date?: number;
112
112
  /** if specified, a Wizard will be shown on the review page with this schema */
113
- terms_schema?: string;
113
+ terms_schema?: SchemaName;
114
114
  /** if specified, a Wizard will be shown on the review page with this schema */
115
- signature_schema?: string;
115
+ signature_schema?: SchemaName;
116
116
 
117
117
  // the following ones are generally not pre-configured, instead they
118
118
  // just come from the URL query params.
@@ -141,6 +141,9 @@ export type WizardConfig = {
141
141
  /** the loading message to show next to the spinner after the review screen */
142
142
  sharing_data_message?: string;
143
143
 
144
+ /** If this value is true, the form will display some data sharing information before the form (WizardPreview) */
145
+ display_sharing_preview?: boolean;
146
+
144
147
  /** a list of relationships that should be created after the wizard completes (see #987) */
145
148
  relationships?: {
146
149
  /** schema name */
@@ -152,4 +155,7 @@ export type WizardConfig = {
152
155
  /** relationship properties */
153
156
  properties?: Record<string, any>;
154
157
  }[];
158
+
159
+ /** if specified, the user must validate their WebAuthN credential before they can submit the form */
160
+ webauthn_type?: ("usb" | "nfc" | "ble" | "internal")[];
155
161
  };