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