@sparkvault/sdk-js 2.0.4 → 2.1.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.
@@ -832,6 +832,35 @@ function base64urlEncode(data) {
832
832
  function arrayBufferToBase64url(buffer) {
833
833
  return base64urlEncode(new Uint8Array(buffer));
834
834
  }
835
+ /**
836
+ * Decode base64url string to Uint8Array
837
+ *
838
+ * @param base64url - Base64url encoded string
839
+ * @returns Decoded bytes as Uint8Array
840
+ */
841
+ function base64urlDecode(base64url) {
842
+ const base64 = base64url.replace(/-/g, '+').replace(/_/g, '/');
843
+ const padded = base64 + '='.repeat((4 - (base64.length % 4)) % 4);
844
+ const binary = atob(padded);
845
+ const bytes = new Uint8Array(binary.length);
846
+ for (let i = 0; i < binary.length; i++) {
847
+ bytes[i] = binary.charCodeAt(i);
848
+ }
849
+ return bytes;
850
+ }
851
+ /**
852
+ * Decode base64url string to ArrayBuffer
853
+ *
854
+ * @param base64url - Base64url encoded string
855
+ * @returns Decoded ArrayBuffer
856
+ */
857
+ function base64urlToArrayBuffer(base64url) {
858
+ const bytes = base64urlDecode(base64url);
859
+ // Create a new ArrayBuffer with exact copy (avoids TypeScript ArrayBufferLike issue)
860
+ const buffer = new ArrayBuffer(bytes.length);
861
+ new Uint8Array(buffer).set(bytes);
862
+ return buffer;
863
+ }
835
864
  /**
836
865
  * Decode base64url string to UTF-8 string
837
866
  *
@@ -1568,11 +1597,115 @@ class PasskeyHandler {
1568
1597
  return result;
1569
1598
  }
1570
1599
  /**
1571
- * Verify user with existing passkey via popup
1600
+ * Verify user with an existing passkey.
1601
+ *
1602
+ * On the Identity origin (the hosted widget / hosted login) the ceremony runs
1603
+ * inline — same-origin with the RP id, one tap, no popup. On a third-party
1604
+ * origin the rpId would not match the document, so it falls back to the popup
1605
+ * served from the Identity origin. (Verification, unlike registration, is
1606
+ * supported in cross-origin iframes, so the embedded widget uses the inline
1607
+ * path.)
1572
1608
  */
1573
1609
  async verify() {
1610
+ if (this.canRunCeremonyInline()) {
1611
+ return this.verifyInline();
1612
+ }
1574
1613
  return this.openPasskeyPopup('verify');
1575
1614
  }
1615
+ /**
1616
+ * True when the SDK is running ON the Identity origin and the browser exposes
1617
+ * WebAuthn — the only place an inline ceremony's rpId matches the document.
1618
+ */
1619
+ canRunCeremonyInline() {
1620
+ return typeof window !== 'undefined'
1621
+ && typeof navigator !== 'undefined'
1622
+ && !!navigator.credentials
1623
+ && window.location.origin === this.trustedOrigin;
1624
+ }
1625
+ /**
1626
+ * Run the discoverable verification ceremony directly in this document and
1627
+ * map the outcome onto the same PasskeyResult shape the popup produces.
1628
+ */
1629
+ async verifyInline() {
1630
+ try {
1631
+ const challenge = await this.api.startPasskeyVerify(undefined, 'email', this.state.authContext);
1632
+ const credential = await navigator.credentials.get({
1633
+ publicKey: {
1634
+ challenge: base64urlToArrayBuffer(challenge.challenge),
1635
+ rpId: challenge.rpId,
1636
+ timeout: challenge.timeout,
1637
+ userVerification: 'required',
1638
+ },
1639
+ });
1640
+ if (!credential) {
1641
+ return { success: false, error: 'Failed to get passkey', errorType: 'unknown' };
1642
+ }
1643
+ const response = await this.api.completePasskeyVerify({
1644
+ session: challenge.session,
1645
+ credential,
1646
+ authContext: this.state.authContext,
1647
+ });
1648
+ return {
1649
+ success: true,
1650
+ result: {
1651
+ token: response.token,
1652
+ identity: response.identity || this.state.recipient,
1653
+ identityType: response.identity_type || 'email',
1654
+ svid: response.svid,
1655
+ sessionId: response.session_id,
1656
+ refreshToken: response.refresh_token,
1657
+ redirect: response.redirect,
1658
+ },
1659
+ };
1660
+ }
1661
+ catch (error) {
1662
+ return this.mapInlineCeremonyError(error);
1663
+ }
1664
+ }
1665
+ /**
1666
+ * Map a thrown inline-ceremony error onto PasskeyResult, mirroring the
1667
+ * popup's error codes so the widget renders the same dedicated states
1668
+ * (cancelled, identity locked, no passkey → registration).
1669
+ */
1670
+ mapInlineCeremonyError(error) {
1671
+ // User dismissed the system sheet, or no credential was available.
1672
+ if (error instanceof Error && error.name === 'NotAllowedError') {
1673
+ return {
1674
+ success: false,
1675
+ error: 'Authentication was cancelled. Please try again.',
1676
+ errorType: 'cancelled',
1677
+ };
1678
+ }
1679
+ if (error instanceof IdentityApiError) {
1680
+ if (error.code === 'identity_locked') {
1681
+ return {
1682
+ success: false,
1683
+ error: 'This SparkVault Identity is locked. Visit auth.sv to manage it.',
1684
+ errorType: 'unknown',
1685
+ errorCode: 'identity_locked',
1686
+ };
1687
+ }
1688
+ if (error.code === 'passkey_not_registered') {
1689
+ return {
1690
+ success: false,
1691
+ error: 'No passkey found. Create one to continue.',
1692
+ errorType: 'not_found',
1693
+ errorCode: 'passkey_not_registered',
1694
+ };
1695
+ }
1696
+ return {
1697
+ success: false,
1698
+ error: error.message || 'Passkey authentication failed',
1699
+ errorType: 'unknown',
1700
+ errorCode: error.code,
1701
+ };
1702
+ }
1703
+ return {
1704
+ success: false,
1705
+ error: error instanceof Error ? error.message : 'Passkey authentication failed',
1706
+ errorType: 'unknown',
1707
+ };
1708
+ }
1576
1709
  /**
1577
1710
  * Open passkey popup and wait for result
1578
1711
  */
@@ -5609,6 +5742,19 @@ const SPARKLINK_CSP_BLOCKED_ERROR = {
5609
5742
  ].join(' '),
5610
5743
  code: 'sparklink_csp_blocked',
5611
5744
  };
5745
+ /**
5746
+ * Navigate the browser. When the flow runs inside the embed iframe, the host
5747
+ * injects `onNavigate` (via VerifyOptions) so redirects move the customer's
5748
+ * top window rather than the iframe — providers refuse to be framed anyway.
5749
+ * Outside the iframe this falls back to a normal same-window navigation.
5750
+ */
5751
+ function navigateWith(options, url) {
5752
+ if (options.onNavigate) {
5753
+ options.onNavigate(url);
5754
+ return;
5755
+ }
5756
+ window.location.href = url;
5757
+ }
5612
5758
  class IdentityRenderer {
5613
5759
  constructor(container, api, options, callbacks) {
5614
5760
  // View management
@@ -5869,7 +6015,7 @@ class IdentityRenderer {
5869
6015
  return new MethodSelectView({
5870
6016
  email: state.email,
5871
6017
  methods: state.methods,
5872
- onSelectMethod: (method) => this.handleMethodSelect(method),
6018
+ onSelectMethod: (method) => this.handleMethodSelect(method, true),
5873
6019
  onBack: state.email ? () => this.showIdentityInput() : undefined,
5874
6020
  });
5875
6021
  case 'totp-verify':
@@ -6048,7 +6194,13 @@ class IdentityRenderer {
6048
6194
  getAllowedIdentityTypes() {
6049
6195
  return this.verificationState.getAllowedIdentityTypes();
6050
6196
  }
6051
- async handleMethodSelect(method) {
6197
+ /**
6198
+ * @param userInitiated True when called from a live click on the picker, so
6199
+ * a popup may be opened synchronously within that gesture. False when
6200
+ * auto-selected after an async step (e.g. the single enabled method), where
6201
+ * opening a popup would be blocked.
6202
+ */
6203
+ async handleMethodSelect(method, userInitiated = false) {
6052
6204
  try {
6053
6205
  switch (method.type) {
6054
6206
  case 'totp': {
@@ -6076,11 +6228,21 @@ class IdentityRenderer {
6076
6228
  break;
6077
6229
  }
6078
6230
  case 'passkey': {
6079
- this.setState({
6080
- view: 'passkey',
6081
- recipient: this.recipient,
6082
- mode: 'verify',
6083
- });
6231
+ if (userInitiated) {
6232
+ // Live picker tap: open the passkey popup directly within this
6233
+ // gesture (window.open in verify() runs before the first await),
6234
+ // skipping the redundant in-widget passkey screen.
6235
+ await this.launchPasskeyVerify();
6236
+ }
6237
+ else {
6238
+ // Auto-selected without a fresh gesture: a popup would be blocked,
6239
+ // so land on the passkey view whose button supplies the gesture.
6240
+ this.setState({
6241
+ view: 'passkey',
6242
+ recipient: this.recipient,
6243
+ mode: 'verify',
6244
+ });
6245
+ }
6084
6246
  break;
6085
6247
  }
6086
6248
  case 'sparklink': {
@@ -6169,7 +6331,7 @@ class IdentityRenderer {
6169
6331
  // page-level handler can act before we navigate away.
6170
6332
  this.safeOnSuccess(result.result);
6171
6333
  if (typeof result.result.redirect === 'string' && result.result.redirect) {
6172
- window.location.href = result.result.redirect;
6334
+ navigateWith(this.options, result.result.redirect);
6173
6335
  }
6174
6336
  }
6175
6337
  else if (result.errorCode === 'identity_locked') {
@@ -6236,7 +6398,7 @@ class IdentityRenderer {
6236
6398
  this.close();
6237
6399
  this.safeOnSuccess(result);
6238
6400
  if (typeof result.redirect === 'string' && result.redirect) {
6239
- window.location.href = result.redirect;
6401
+ navigateWith(this.options, result.redirect);
6240
6402
  }
6241
6403
  }
6242
6404
  catch (error) {
@@ -6269,11 +6431,29 @@ class IdentityRenderer {
6269
6431
  const result = currentMode === 'register'
6270
6432
  ? await this.passkeyHandler.register()
6271
6433
  : await this.passkeyHandler.verify();
6434
+ this.applyPasskeyResult(result, currentMode);
6435
+ }
6436
+ /**
6437
+ * Open the verify popup straight from a live picker gesture, showing a
6438
+ * loading state while the ceremony runs. window.open inside verify() fires
6439
+ * synchronously (before the first await), so it stays within the gesture.
6440
+ */
6441
+ async launchPasskeyVerify() {
6442
+ this.setState({ view: 'loading' });
6443
+ const result = await this.passkeyHandler.verify();
6444
+ this.applyPasskeyResult(result, 'verify');
6445
+ }
6446
+ /**
6447
+ * Apply a passkey ceremony result: complete on success, or route to the
6448
+ * matching recovery state. Shared by the passkey view and the direct
6449
+ * picker launch so both behave identically.
6450
+ */
6451
+ applyPasskeyResult(result, currentMode) {
6272
6452
  if (result.success && result.result) {
6273
6453
  this.close();
6274
6454
  this.safeOnSuccess(result.result);
6275
6455
  if (typeof result.result.redirect === 'string' && result.result.redirect) {
6276
- window.location.href = result.result.redirect;
6456
+ navigateWith(this.options, result.result.redirect);
6277
6457
  }
6278
6458
  }
6279
6459
  else if (result.errorCode === 'identity_locked') {
@@ -6284,24 +6464,22 @@ class IdentityRenderer {
6284
6464
  message: 'This SparkVault Identity is locked. Visit auth.sv to manage it.',
6285
6465
  });
6286
6466
  }
6467
+ else if (result.errorType === 'not_found') {
6468
+ // No passkey yet — pivot the same screen to registration.
6469
+ this.setState({
6470
+ view: 'passkey',
6471
+ recipient: this.recipient,
6472
+ mode: 'register',
6473
+ error: result.error,
6474
+ });
6475
+ }
6287
6476
  else {
6288
- // Handle different error types
6289
- if (result.errorType === 'not_found') {
6290
- this.setState({
6291
- view: 'passkey',
6292
- recipient: this.recipient,
6293
- mode: 'register',
6294
- error: result.error,
6295
- });
6296
- }
6297
- else {
6298
- this.setState({
6299
- view: 'passkey',
6300
- recipient: this.recipient,
6301
- mode: currentMode,
6302
- error: result.error,
6303
- });
6304
- }
6477
+ this.setState({
6478
+ view: 'passkey',
6479
+ recipient: this.recipient,
6480
+ mode: currentMode,
6481
+ error: result.error,
6482
+ });
6305
6483
  }
6306
6484
  }
6307
6485
  /**
@@ -6338,7 +6516,7 @@ class IdentityRenderer {
6338
6516
  this.close();
6339
6517
  this.safeOnSuccess(pendingResult);
6340
6518
  if (typeof pendingResult.redirect === 'string' && pendingResult.redirect) {
6341
- window.location.href = pendingResult.redirect;
6519
+ navigateWith(this.options, pendingResult.redirect);
6342
6520
  }
6343
6521
  }
6344
6522
  }
@@ -6349,7 +6527,7 @@ class IdentityRenderer {
6349
6527
  sessionStorage.setItem('sv_oauth_state', state);
6350
6528
  sessionStorage.setItem('sv_oauth_email', this.recipient);
6351
6529
  const authUrl = this.api.getSocialAuthUrl(provider, redirectUri, state, this.verificationState.authContext);
6352
- window.location.href = authUrl;
6530
+ navigateWith(this.options, authUrl);
6353
6531
  }
6354
6532
  normalizeError(error) {
6355
6533
  if (error instanceof IdentityApiError) {
@@ -6425,7 +6603,7 @@ class IdentityRenderer {
6425
6603
  this.close();
6426
6604
  this.safeOnSuccess(result.result);
6427
6605
  if (typeof result.result.redirect === 'string' && result.result.redirect) {
6428
- window.location.href = result.result.redirect;
6606
+ navigateWith(this.options, result.result.redirect);
6429
6607
  }
6430
6608
  }
6431
6609
  else if (result.errorType === 'cancelled') {
@@ -6457,7 +6635,7 @@ class IdentityRenderer {
6457
6635
  this.close();
6458
6636
  this.safeOnSuccess(pendingResult);
6459
6637
  if (typeof pendingResult.redirect === 'string' && pendingResult.redirect) {
6460
- window.location.href = pendingResult.redirect;
6638
+ navigateWith(this.options, pendingResult.redirect);
6461
6639
  }
6462
6640
  }
6463
6641
  /**
@@ -6629,7 +6807,7 @@ class IdentityRenderer {
6629
6807
  // a no-op (the document is already unloading); if not, this rescues
6630
6808
  // simple-mode flows whose host forgot to act on result.redirect.
6631
6809
  if (typeof result.redirect === 'string' && result.redirect) {
6632
- window.location.href = result.redirect;
6810
+ navigateWith(this.options, result.redirect);
6633
6811
  }
6634
6812
  }
6635
6813
  /**
@@ -6708,6 +6886,132 @@ class IdentityRenderer {
6708
6886
  }
6709
6887
  }
6710
6888
 
6889
+ /* global HTMLIFrameElement */
6890
+ /**
6891
+ * Widget Embedder
6892
+ *
6893
+ * Host-side half of the iframe architecture. For dialog (modal) verification,
6894
+ * the SDK injects a borderless, transparent, full-viewport iframe pointing at
6895
+ * the SparkVault-hosted widget page and bridges the result back over
6896
+ * postMessage. Running the flow on the SparkVault origin lets passkey login
6897
+ * complete in a single tap on every platform — the WebAuthn ceremony is
6898
+ * same-origin with the RP id and the user's tap lives in the iframe document —
6899
+ * without a popup.
6900
+ *
6901
+ * The widget renders the SDK's own modal (overlay, backdrop, chrome) inside the
6902
+ * iframe, so the page sees only a transparent full-viewport frame: no border,
6903
+ * no seam, visually identical to the in-page modal.
6904
+ */
6905
+ /** Result envelope posted by the widget page. */
6906
+ const RESULT_TYPE = 'sparkvault-identity-result';
6907
+ /** Top-window navigation request posted by the widget (social / OIDC). */
6908
+ const REDIRECT_TYPE = 'sparkvault-identity-redirect';
6909
+ class WidgetEmbedder {
6910
+ constructor(config, options, callbacks) {
6911
+ this.config = config;
6912
+ this.options = options;
6913
+ this.callbacks = callbacks;
6914
+ this.iframe = null;
6915
+ this.settled = false;
6916
+ this.previousBodyOverflow = '';
6917
+ // Only ever trust messages from the Identity origin the SDK is configured
6918
+ // against — never the broader sparkvault.com family.
6919
+ this.trustedOrigin = new URL(this.config.identityBaseUrl).origin;
6920
+ this.boundHandleMessage = (event) => this.handleMessage(event);
6921
+ }
6922
+ start() {
6923
+ const iframe = document.createElement('iframe');
6924
+ iframe.src = this.buildUrl();
6925
+ iframe.title = 'Sign in';
6926
+ // Delegate WebAuthn into the cross-origin widget document so the ceremony
6927
+ // runs there. The widget response also opts in via Permissions-Policy.
6928
+ iframe.setAttribute('allow', 'publickey-credentials-get; publickey-credentials-create');
6929
+ iframe.style.cssText = [
6930
+ 'position:fixed',
6931
+ 'inset:0',
6932
+ 'width:100%',
6933
+ 'height:100%',
6934
+ 'border:0',
6935
+ 'margin:0',
6936
+ 'padding:0',
6937
+ 'background:transparent',
6938
+ 'z-index:2147483647',
6939
+ ].join(';');
6940
+ this.iframe = iframe;
6941
+ // Lock host scroll while the modal (rendered inside the iframe) is open.
6942
+ this.previousBodyOverflow = document.body.style.overflow;
6943
+ document.body.style.overflow = 'hidden';
6944
+ window.addEventListener('message', this.boundHandleMessage);
6945
+ document.body.appendChild(iframe);
6946
+ }
6947
+ close() {
6948
+ if (this.iframe?.parentNode) {
6949
+ this.iframe.parentNode.removeChild(this.iframe);
6950
+ }
6951
+ this.iframe = null;
6952
+ window.removeEventListener('message', this.boundHandleMessage);
6953
+ document.body.style.overflow = this.previousBodyOverflow;
6954
+ }
6955
+ buildUrl() {
6956
+ const url = new URL(`${this.config.identityBaseUrl}/${this.config.accountId}/widget`);
6957
+ url.searchParams.set('origin', window.location.origin);
6958
+ if (this.options.email)
6959
+ url.searchParams.set('email', this.options.email);
6960
+ if (this.options.phone)
6961
+ url.searchParams.set('phone', this.options.phone);
6962
+ if (this.options.backdropBlur === false)
6963
+ url.searchParams.set('backdrop_blur', 'false');
6964
+ const authContext = this.options.authContext;
6965
+ if (authContext?.authRequestId) {
6966
+ url.searchParams.set('auth_request_id', authContext.authRequestId);
6967
+ }
6968
+ if (authContext?.simpleMode) {
6969
+ url.searchParams.set('simple_mode', JSON.stringify({
6970
+ success_url: authContext.simpleMode.successUrl,
6971
+ failure_url: authContext.simpleMode.failureUrl,
6972
+ state: authContext.simpleMode.state,
6973
+ session_id: authContext.simpleMode.sessionId,
6974
+ }));
6975
+ }
6976
+ return url.toString();
6977
+ }
6978
+ handleMessage(event) {
6979
+ if (event.origin !== this.trustedOrigin)
6980
+ return;
6981
+ if (this.iframe && event.source !== this.iframe.contentWindow)
6982
+ return;
6983
+ const data = event.data;
6984
+ if (!data || typeof data.type !== 'string')
6985
+ return;
6986
+ // Social / OIDC redirect: the widget cannot navigate the top window from a
6987
+ // cross-origin frame, so it asks us to. Navigating away tears down the
6988
+ // iframe; on return the host SDK consumes the redirect token.
6989
+ if (data.type === REDIRECT_TYPE && typeof data.url === 'string') {
6990
+ window.location.href = data.url;
6991
+ return;
6992
+ }
6993
+ if (data.type !== RESULT_TYPE || this.settled)
6994
+ return;
6995
+ this.settled = true;
6996
+ this.close();
6997
+ if (data.success && data.result) {
6998
+ const result = data.result;
6999
+ this.callbacks.onSuccess(result);
7000
+ // Mirror the renderer's belt-and-suspenders: complete a server-issued
7001
+ // redirect from the host's own top window if the customer didn't.
7002
+ if (typeof result.redirect === 'string' && result.redirect) {
7003
+ window.location.href = result.redirect;
7004
+ }
7005
+ }
7006
+ else if (data.cancelled) {
7007
+ this.callbacks.onCancel();
7008
+ }
7009
+ else {
7010
+ this.callbacks.onError(new Error(data.error || 'Verification failed'));
7011
+ }
7012
+ }
7013
+ }
7014
+
6711
7015
  /**
6712
7016
  * Inline Container
6713
7017
  *
@@ -6982,6 +7286,7 @@ function isTokenClaims(payload) {
6982
7286
  class IdentityModule {
6983
7287
  constructor(config) {
6984
7288
  this.renderer = null;
7289
+ this.embedder = null;
6985
7290
  this.attachedElements = new Map();
6986
7291
  this.config = config;
6987
7292
  this.api = new IdentityApi(config);
@@ -7012,6 +7317,10 @@ class IdentityModule {
7012
7317
  options.onSuccess?.(redirectResult);
7013
7318
  return redirectResult;
7014
7319
  }
7320
+ if (this.embedder) {
7321
+ this.embedder.close();
7322
+ this.embedder = null;
7323
+ }
7015
7324
  if (this.renderer) {
7016
7325
  this.renderer.close();
7017
7326
  }
@@ -7019,37 +7328,53 @@ class IdentityModule {
7019
7328
  // AbortController aborted on close() would short-circuit the next
7020
7329
  // session's first request as "Request cancelled".
7021
7330
  this.api.resetSession();
7022
- const isInline = !!options.target;
7023
- const container = isInline
7024
- ? this.createInlineContainer(options.target)
7025
- : new ModalContainer();
7026
7331
  // Merge global config defaults with per-call options
7027
7332
  const mergedOptions = {
7028
7333
  ...options,
7029
7334
  // Use global backdropBlur unless explicitly overridden per-call
7030
7335
  backdropBlur: options.backdropBlur ?? this.config.backdropBlur,
7031
7336
  };
7032
- return new Promise((resolve, reject) => {
7033
- this.renderer = new IdentityRenderer(container, this.api, mergedOptions, {
7034
- onSuccess: (result) => {
7035
- options.onSuccess?.(result);
7036
- resolve(result);
7037
- },
7038
- onError: (error) => {
7039
- options.onError?.(error);
7040
- reject(error);
7041
- },
7042
- onCancel: () => {
7043
- const error = new UserCancelledError();
7044
- options.onCancel?.();
7045
- reject(error);
7046
- },
7047
- });
7048
- this.renderer.start().catch((error) => {
7337
+ // Inline rendering (target) and explicit local mode run the flow in this
7338
+ // document. Dialog mode embeds the SparkVault-hosted widget in an iframe so
7339
+ // passkey login completes in one tap with no popup. `renderMode: 'local'`
7340
+ // is how the hosted widget itself runs the flow (and avoids re-embedding).
7341
+ const isInline = !!options.target;
7342
+ const useLocal = options.renderMode === 'local' || isInline;
7343
+ let resolveRef;
7344
+ let rejectRef;
7345
+ const settledPromise = new Promise((resolve, reject) => {
7346
+ resolveRef = resolve;
7347
+ rejectRef = reject;
7348
+ });
7349
+ const hostCallbacks = {
7350
+ onSuccess: (result) => {
7351
+ options.onSuccess?.(result);
7352
+ resolveRef(result);
7353
+ },
7354
+ onError: (error) => {
7049
7355
  options.onError?.(error);
7050
- reject(error);
7051
- });
7356
+ rejectRef(error);
7357
+ },
7358
+ onCancel: () => {
7359
+ const error = new UserCancelledError();
7360
+ options.onCancel?.();
7361
+ rejectRef(error);
7362
+ },
7363
+ };
7364
+ if (!useLocal) {
7365
+ this.embedder = new WidgetEmbedder(this.config, mergedOptions, hostCallbacks);
7366
+ this.embedder.start();
7367
+ return settledPromise;
7368
+ }
7369
+ const container = isInline
7370
+ ? this.createInlineContainer(options.target)
7371
+ : new ModalContainer();
7372
+ this.renderer = new IdentityRenderer(container, this.api, mergedOptions, hostCallbacks);
7373
+ this.renderer.start().catch((error) => {
7374
+ options.onError?.(error);
7375
+ rejectRef(error);
7052
7376
  });
7377
+ return settledPromise;
7053
7378
  }
7054
7379
  /**
7055
7380
  * Attach identity verification to element clicks.