@medplum/core 1.0.6 → 2.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.
@@ -71,6 +71,14 @@ export interface MedplumClientOptions {
71
71
  * See: https://developer.mozilla.org/en-US/docs/Web/API/Request/cache
72
72
  */
73
73
  cacheTime?: number;
74
+ /**
75
+ * The length of time in milliseconds to delay requests for auto batching.
76
+ *
77
+ * Auto batching attempts to group multiple requests together into a single batch request.
78
+ *
79
+ * Default value is 0, which disables auto batching.
80
+ */
81
+ autoBatchTime?: number;
74
82
  /**
75
83
  * Fetch implementation.
76
84
  *
@@ -146,6 +154,7 @@ export interface BaseLoginRequest {
146
154
  readonly codeChallengeMethod?: string;
147
155
  readonly googleClientId?: string;
148
156
  readonly launch?: string;
157
+ readonly redirectUri?: string;
149
158
  }
150
159
  export interface EmailPasswordLoginRequest extends BaseLoginRequest {
151
160
  readonly email: string;
@@ -338,6 +347,12 @@ export declare class MedplumClient extends EventTarget {
338
347
  * @category Authentication
339
348
  */
340
349
  clear(): void;
350
+ /**
351
+ * Clears the active login from local storage.
352
+ * Does not clear all local storage (such as other logins).
353
+ * @category Authentication
354
+ */
355
+ clearActiveLogin(): void;
341
356
  /**
342
357
  * Invalidates any cached values or cached requests for the given URL.
343
358
  * @category Caching
@@ -467,10 +482,15 @@ export declare class MedplumClient extends EventTarget {
467
482
  * @returns Promise to the authentication response.
468
483
  */
469
484
  startGoogleLogin(loginRequest: GoogleLoginRequest): Promise<LoginAuthenticationResponse>;
470
- getCodeChallenge(loginRequest: BaseLoginRequest): {
471
- codeChallenge?: string;
472
- codeChallengeMethod?: string;
473
- };
485
+ /**
486
+ * Returns the PKCE code challenge and method.
487
+ * If the login request already includes a code challenge, it is returned.
488
+ * Otherwise, a new PKCE code challenge is generated.
489
+ * @category Authentication
490
+ * @param loginRequest The original login request.
491
+ * @returns The PKCE code challenge and method.
492
+ */
493
+ ensureCodeChallenge<T extends BaseLoginRequest>(loginRequest: T): Promise<T>;
474
494
  /**
475
495
  * Signs out locally.
476
496
  * Does not invalidate tokens with the server.
@@ -482,14 +502,23 @@ export declare class MedplumClient extends EventTarget {
482
502
  * Returns true if the user is signed in.
483
503
  * This may result in navigating away to the sign in page.
484
504
  * @category Authentication
505
+ * @param loginParams Optional login parameters.
485
506
  */
486
- signInWithRedirect(): Promise<ProfileResource | void>;
507
+ signInWithRedirect(loginParams?: Partial<BaseLoginRequest>): Promise<ProfileResource | void>;
487
508
  /**
488
509
  * Tries to sign out the user.
489
510
  * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
490
511
  * @category Authentication
491
512
  */
492
513
  signOutWithRedirect(): void;
514
+ /**
515
+ * Initiates sign in with an external identity provider.
516
+ * @param authorizeUrl The external authorization URL.
517
+ * @param clientId The external client ID.
518
+ * @param redirectUri The external identity provider redirect URI.
519
+ * @param baseLogin The Medplum login request.
520
+ */
521
+ signInWithExternalAuth(authorizeUrl: string, clientId: string, redirectUri: string, baseLogin: BaseLoginRequest): Promise<void>;
493
522
  /**
494
523
  * Builds a FHIR URL from a collection of URL path components.
495
524
  * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
@@ -1154,7 +1183,10 @@ export declare class MedplumClient extends EventTarget {
1154
1183
  * Starts a new PKCE flow.
1155
1184
  * These PKCE values are stateful, and must survive redirects and page refreshes.
1156
1185
  */
1157
- startPkce(): Promise<void>;
1186
+ startPkce(): Promise<{
1187
+ codeChallengeMethod: string;
1188
+ codeChallenge: string;
1189
+ }>;
1158
1190
  /**
1159
1191
  * Processes an OAuth authorization code.
1160
1192
  * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest