@block-auth.io/angular 0.5.1 → 0.7.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.
@@ -1,7 +1,7 @@
1
1
  import { DOCUMENT, isPlatformBrowser, NgComponentOutlet } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
3
  import { InjectionToken, makeEnvironmentProviders, inject, DestroyRef, signal, computed, Injectable, output, PLATFORM_ID, effect, Directive, ElementRef, input, ChangeDetectionStrategy, Component, viewChild, HostListener, untracked, linkedSignal, afterNextRender } from '@angular/core';
4
- import { createBlockAuthClient, $locale, setLocale, t, $user, getUserRoles, getUserRoleNames, getUserRoleSlugs, hasRole, hasRoleBySlug, hasAnyRole, hasAnyRoleBySlug, fetchUserProfile, startExtensionSync, createAuthRuntime, $extension, getExtensionStoreUrl, utils, getDefaultPhoneCountry, resolvePhoneDraft, getPhoneCountries, searchPhoneCountries, updatePhoneDraft, getSolicitedFields, getSolicitedParams, isSolicitedDataComplete, PARAM_LABEL_KEYS, PARAM_ERROR_KEYS, getSolicitedHintKey, PARAM_INPUT_TYPE, isSolicitedHintSuccess, isSolicitedEmailSelectable, formatSolicitedEmailOption, EMPTY_SOLICITED_DATA_FORM, openExtensionOnTxn, getSolicitedAcceptParams, setSolicitedValue, setSolicitedShared, saveSolicitedValue, undoSolicitedValue, setSolicitedEmailChoice, needsExtensionUnlock, deepLinkFor, makeQrDataUrl, setIsSigningLoader } from '@block-auth.io/core';
4
+ import { createBlockAuthClient, $locale, setLocale, t, $user, getUserRoles, getUserRoleNames, getUserRoleSlugs, hasRole, hasRoleBySlug, hasAnyRole, hasAnyRoleBySlug, fetchUserProfile, startExtensionSync, createAuthRuntime, $extension, getExtensionStoreUrl, utils, getDefaultPhoneCountry, resolvePhoneDraft, getPhoneCountries, searchPhoneCountries, updatePhoneDraft, getSolicitedFields, getSolicitedParams, isSolicitedDataComplete, PARAM_LABEL_KEYS, PARAM_ERROR_KEYS, getSolicitedHintKey, PARAM_INPUT_TYPE, isSolicitedHintSuccess, isSolicitedEmailSelectable, formatSolicitedEmailOption, EMPTY_SOLICITED_DATA_FORM, openExtensionOnTxn, getSolicitedAcceptParams, setSolicitedValue, setSolicitedShared, saveSolicitedValue, undoSolicitedValue, setSolicitedEmailChoice, needsExtensionUnlock, deepLinkFor, makeQrDataUrl, setIsSigningLoader, AccountLinkError } from '@block-auth.io/core';
5
5
  export { getUserRoleNames, getUserRoleSlugs, getUserRoles, hasAnyRole, hasAnyRoleBySlug, hasRole, hasRoleBySlug, loadUserProfile } from '@block-auth.io/core';
6
6
 
7
7
  // GENERADO por scripts/css-to-ts.mjs — no editar a mano.
@@ -165,6 +165,8 @@ class BlockAuthRuntimeDirective {
165
165
  if (!isPlatformBrowser(this.platformId))
166
166
  return;
167
167
  this.stopExtensionSync = startExtensionSync();
168
+ if (!this.client.apiUrl)
169
+ return;
168
170
  this.runtime = createAuthRuntime(this.client, {
169
171
  onSuccess: (address) => this.success.emit(address),
170
172
  onError: () => this.errored.emit(),
@@ -9703,6 +9705,8 @@ class FlowBlockAuthComponent {
9703
9705
  this.additionalDropdownItems = input(null, ...(ngDevMode ? [{ debugName: "additionalDropdownItems" }] : []));
9704
9706
  /** Status-button label override. */
9705
9707
  this.buttonText = input('', ...(ngDevMode ? [{ debugName: "buttonText" }] : []));
9708
+ this.onAuthCode = input(undefined, ...(ngDevMode ? [{ debugName: "onAuthCode" }] : []));
9709
+ this.user = input(undefined, ...(ngDevMode ? [{ debugName: "user" }] : []));
9706
9710
  this.success = output();
9707
9711
  this.errored = output();
9708
9712
  this.loggedOut = output();
@@ -9710,15 +9714,30 @@ class FlowBlockAuthComponent {
9710
9714
  this.ws = this.ba.ws;
9711
9715
  this.ui = this.ba.ui;
9712
9716
  this.locale = this.ba.locale;
9717
+ this.client = this.ba.client;
9718
+ this.isHosted = !this.client.apiUrl;
9719
+ this.isPopupOpen = signal(false, ...(ngDevMode ? [{ debugName: "isPopupOpen" }] : []));
9720
+ this.userKey = computed(() => {
9721
+ const user = this.user();
9722
+ return user === undefined ? undefined : JSON.stringify(user);
9723
+ }, ...(ngDevMode ? [{ debugName: "userKey" }] : []));
9713
9724
  this.isUiConfig = computed(() => this.ui().uiConfig != null && Object.keys(this.ui().uiConfig).length > 0, ...(ngDevMode ? [{ debugName: "isUiConfig" }] : []));
9725
+ // Locked from the extension (its settings, or its OTP ran out): only the
9726
+ // code in the extension unlocks it. Log In here used to sign the user in
9727
+ // straight from the page while the server's OTP window was still open, so
9728
+ // the lock never applied to a returning login.
9729
+ this.ext = injectStore($extension);
9730
+ this.isExtensionLocked = computed(() => this.ui().serviceName === 'blockauth' && this.ext().isLocked, ...(ngDevMode ? [{ debugName: "isExtensionLocked" }] : []));
9714
9731
  // Copia localizada del backend (`app()` -> uiConfig.config.content.btns):
9715
9732
  // { reviewApi, signUp, logIn, restore } cada una keyed por locale (en/es).
9716
9733
  this.btnsTexts = computed(() => this.ui().uiConfig?.config?.content?.btns, ...(ngDevMode ? [{ debugName: "btnsTexts" }] : []));
9717
- this.showDDP = computed(() => this.ws().ready &&
9718
- this.ui().isSdkSignedIn &&
9719
- this.ui().isServiceConnected &&
9720
- this.showDropdownWhenConnected() &&
9721
- this.ui().isSignedFirstCheck, ...(ngDevMode ? [{ debugName: "showDDP" }] : []));
9734
+ this.showDDP = computed(() => this.isHosted
9735
+ ? this.ui().isSigned && this.showDropdownWhenConnected()
9736
+ : this.ws().ready &&
9737
+ this.ui().isSdkSignedIn &&
9738
+ this.ui().isServiceConnected &&
9739
+ this.showDropdownWhenConnected() &&
9740
+ this.ui().isSignedFirstCheck, ...(ngDevMode ? [{ debugName: "showDDP" }] : []));
9722
9741
  // Azul mientras arranca, transparente una vez firmado en el SDK, naranja en
9723
9742
  // on-deletion, rojo si la api key es inválida.
9724
9743
  this.bgClassNames = computed(() => 'bal-ba-glass-status-btn ' +
@@ -9736,9 +9755,22 @@ class FlowBlockAuthComponent {
9736
9755
  es: 'Restaurar cuenta',
9737
9756
  en: 'Restore account',
9738
9757
  };
9758
+ this.unlockOtpDefault = {
9759
+ es: 'Desbloquear OTP',
9760
+ en: 'Unlock OTP',
9761
+ };
9739
9762
  this.label = computed(() => {
9740
9763
  if (this.isLoading())
9741
9764
  return '';
9765
+ if (this.ui().isSdkSignedIn &&
9766
+ !this.ui().isOnDeletion &&
9767
+ this.ui().isServiceConnected &&
9768
+ !this.ui().isSigned &&
9769
+ this.isExtensionLocked()) {
9770
+ return (this.btnsTexts()?.unlockOtp?.[this.locale()] ??
9771
+ this.unlockOtpDefault[this.locale()] ??
9772
+ this.unlockOtpDefault['en']);
9773
+ }
9742
9774
  if (!this.ui().isSdkSignedIn)
9743
9775
  return this.btnsTexts()?.reviewApi?.[this.locale()] ?? '';
9744
9776
  if (this.ui().isOnDeletion) {
@@ -9754,8 +9786,48 @@ class FlowBlockAuthComponent {
9754
9786
  }
9755
9787
  return '';
9756
9788
  }, ...(ngDevMode ? [{ debugName: "label" }] : []));
9789
+ this.hostedLoginDefault = {
9790
+ es: 'Inicia Sesión',
9791
+ en: 'Log In',
9792
+ };
9793
+ this.hostedLoginLabel = computed(() => this.hostedLoginDefault[this.locale()] ?? this.hostedLoginDefault['en'], ...(ngDevMode ? [{ debugName: "hostedLoginLabel" }] : []));
9757
9794
  /** Reenvía el logout manual del dropdown al output `loggedOut`. */
9758
9795
  this.onLogoutForwarder = () => this.loggedOut.emit();
9796
+ effect(() => {
9797
+ if (!this.isHosted || this.userKey() === undefined)
9798
+ return;
9799
+ const user = untracked(this.user);
9800
+ if (user)
9801
+ this.client.rememberHostedLogin(user);
9802
+ else
9803
+ this.client.forgetHostedLogin();
9804
+ });
9805
+ }
9806
+ ngOnInit() {
9807
+ if (!this.isHosted || this.user() !== undefined || !this.client.hasAuthEndpoint)
9808
+ return;
9809
+ this.client.restoreHostedLogin().catch(() => this.errored.emit());
9810
+ }
9811
+ onHostedLoginClicked() {
9812
+ if (this.isPopupOpen())
9813
+ return;
9814
+ this.isPopupOpen.set(true);
9815
+ const authCode = this.onAuthCode();
9816
+ const login = authCode
9817
+ ? this.client
9818
+ .authorizeWithPopup()
9819
+ .then((code) => authCode(code))
9820
+ .then((user) => {
9821
+ this.client.rememberHostedLogin(user);
9822
+ return user;
9823
+ })
9824
+ : this.client.hasAuthEndpoint
9825
+ ? this.client.loginWithAuthEndpoint()
9826
+ : this.client.loginWithPopup();
9827
+ login
9828
+ .then(({ address }) => this.success.emit(address))
9829
+ .catch(() => this.errored.emit())
9830
+ .finally(() => this.isPopupOpen.set(false));
9759
9831
  }
9760
9832
  onFlowBAClicked() {
9761
9833
  if (!(this.ui().isSdkSignedIn && this.ws().ready))
@@ -9768,6 +9840,12 @@ class FlowBlockAuthComponent {
9768
9840
  this.ba.openModal('signup');
9769
9841
  return;
9770
9842
  }
9843
+ if (this.ui().isServiceConnected && !this.ui().isSigned && this.isExtensionLocked()) {
9844
+ if (typeof document !== 'undefined') {
9845
+ document.dispatchEvent(new CustomEvent('ext:open', { detail: {} }));
9846
+ }
9847
+ return;
9848
+ }
9771
9849
  if (this.ui().isServiceConnected && !this.ui().isSigned) {
9772
9850
  // LOG-IN branch: emit the signin transaction, then open the signin modal
9773
9851
  // and flag the signing loader. The runtime clears the loader once
@@ -9781,7 +9859,7 @@ class FlowBlockAuthComponent {
9781
9859
  }
9782
9860
  }
9783
9861
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: FlowBlockAuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
9784
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: FlowBlockAuthComponent, isStandalone: true, selector: "ba-flow-block-auth", inputs: { showDropdownWhenConnected: { classPropertyName: "showDropdownWhenConnected", publicName: "showDropdownWhenConnected", isSignal: true, isRequired: false, transformFunction: null }, isInsideModal: { classPropertyName: "isInsideModal", publicName: "isInsideModal", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: false, transformFunction: null }, btnClassNames: { classPropertyName: "btnClassNames", publicName: "btnClassNames", isSignal: true, isRequired: false, transformFunction: null }, btnTextClassNames: { classPropertyName: "btnTextClassNames", publicName: "btnTextClassNames", isSignal: true, isRequired: false, transformFunction: null }, dropdownBtnSize: { classPropertyName: "dropdownBtnSize", publicName: "dropdownBtnSize", isSignal: true, isRequired: false, transformFunction: null }, dropdownBtnBgClassNames: { classPropertyName: "dropdownBtnBgClassNames", publicName: "dropdownBtnBgClassNames", isSignal: true, isRequired: false, transformFunction: null }, dropdownBtnTextColorClassNames: { classPropertyName: "dropdownBtnTextColorClassNames", publicName: "dropdownBtnTextColorClassNames", isSignal: true, isRequired: false, transformFunction: null }, dropdownBtnBorderClassNames: { classPropertyName: "dropdownBtnBorderClassNames", publicName: "dropdownBtnBorderClassNames", isSignal: true, isRequired: false, transformFunction: null }, dropdownHeight: { classPropertyName: "dropdownHeight", publicName: "dropdownHeight", isSignal: true, isRequired: false, transformFunction: null }, initializeSdk: { classPropertyName: "initializeSdk", publicName: "initializeSdk", isSignal: true, isRequired: false, transformFunction: null }, additionalDropdownItems: { classPropertyName: "additionalDropdownItems", publicName: "additionalDropdownItems", isSignal: true, isRequired: false, transformFunction: null }, buttonText: { classPropertyName: "buttonText", publicName: "buttonText", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { success: "success", errored: "errored", loggedOut: "loggedOut" }, ngImport: i0, template: `
9862
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: FlowBlockAuthComponent, isStandalone: true, selector: "ba-flow-block-auth", inputs: { showDropdownWhenConnected: { classPropertyName: "showDropdownWhenConnected", publicName: "showDropdownWhenConnected", isSignal: true, isRequired: false, transformFunction: null }, isInsideModal: { classPropertyName: "isInsideModal", publicName: "isInsideModal", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: false, transformFunction: null }, btnClassNames: { classPropertyName: "btnClassNames", publicName: "btnClassNames", isSignal: true, isRequired: false, transformFunction: null }, btnTextClassNames: { classPropertyName: "btnTextClassNames", publicName: "btnTextClassNames", isSignal: true, isRequired: false, transformFunction: null }, dropdownBtnSize: { classPropertyName: "dropdownBtnSize", publicName: "dropdownBtnSize", isSignal: true, isRequired: false, transformFunction: null }, dropdownBtnBgClassNames: { classPropertyName: "dropdownBtnBgClassNames", publicName: "dropdownBtnBgClassNames", isSignal: true, isRequired: false, transformFunction: null }, dropdownBtnTextColorClassNames: { classPropertyName: "dropdownBtnTextColorClassNames", publicName: "dropdownBtnTextColorClassNames", isSignal: true, isRequired: false, transformFunction: null }, dropdownBtnBorderClassNames: { classPropertyName: "dropdownBtnBorderClassNames", publicName: "dropdownBtnBorderClassNames", isSignal: true, isRequired: false, transformFunction: null }, dropdownHeight: { classPropertyName: "dropdownHeight", publicName: "dropdownHeight", isSignal: true, isRequired: false, transformFunction: null }, initializeSdk: { classPropertyName: "initializeSdk", publicName: "initializeSdk", isSignal: true, isRequired: false, transformFunction: null }, additionalDropdownItems: { classPropertyName: "additionalDropdownItems", publicName: "additionalDropdownItems", isSignal: true, isRequired: false, transformFunction: null }, buttonText: { classPropertyName: "buttonText", publicName: "buttonText", isSignal: true, isRequired: false, transformFunction: null }, onAuthCode: { classPropertyName: "onAuthCode", publicName: "onAuthCode", isSignal: true, isRequired: false, transformFunction: null }, user: { classPropertyName: "user", publicName: "user", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { success: "success", errored: "errored", loggedOut: "loggedOut" }, ngImport: i0, template: `
9785
9863
  <div
9786
9864
  data-testid="flow-blockauth"
9787
9865
  [class]="
@@ -9789,32 +9867,23 @@ class FlowBlockAuthComponent {
9789
9867
  (showDDP() ? 'bas-h-fit bas-flex-col bas-gap-2.5' : ' bas-h-[52px]')
9790
9868
  "
9791
9869
  >
9792
- @if (initializeSdk()) {
9793
- <ng-container
9794
- baRuntime
9795
- (success)="success.emit($event)"
9796
- (errored)="errored.emit()"
9797
- (loggedOut)="loggedOut.emit()"
9798
- />
9799
- }
9800
-
9801
- @if (!ui().isSigned || !ui().isSignedFirstCheck) {
9802
- <ba-btn-base
9803
- btnId="btn-flow-blockauth"
9804
- type="button-outlined"
9805
- size="base"
9806
- [disabled]="isLoading()"
9807
- [isLoader]="isLoading()"
9808
- loaderColor="#ffffff"
9809
- [isIcon]="ws().ready"
9810
- [text]="buttonText() || label()"
9811
- [bgClassNames]="bgClassNames()"
9812
- [textClassNames]="btnTextClassNames()"
9813
- [classNames]="'bas-justify-center ' + btnClassNames()"
9814
- [isFocusOutlinedEnabled]="false"
9815
- (action)="onFlowBAClicked()"
9816
- >
9817
- @if (ws().ready && ui().isSdkSignedIn) {
9870
+ @if (isHosted) {
9871
+ @if (!ui().isSigned) {
9872
+ <ba-btn-base
9873
+ btnId="btn-flow-blockauth"
9874
+ type="button-outlined"
9875
+ size="base"
9876
+ [disabled]="isPopupOpen()"
9877
+ [isLoader]="isPopupOpen()"
9878
+ loaderColor="#ffffff"
9879
+ [isIcon]="true"
9880
+ [text]="buttonText() || hostedLoginLabel()"
9881
+ bgClassNames="bal-ba-glass-status-btn bal-ba-glass-tone-ready"
9882
+ [textClassNames]="btnTextClassNames()"
9883
+ [classNames]="'bas-justify-center ' + btnClassNames()"
9884
+ [isFocusOutlinedEnabled]="false"
9885
+ (action)="onHostedLoginClicked()"
9886
+ >
9818
9887
  <img
9819
9888
  slot="icon"
9820
9889
  src="https://dashboard.block-auth.io/img/blockauth_logo.png"
@@ -9822,20 +9891,58 @@ class FlowBlockAuthComponent {
9822
9891
  height="26"
9823
9892
  alt="BlockAuth"
9824
9893
  />
9825
- } @else if (ws().ready) {
9826
- <svg
9827
- slot="icon"
9828
- class="bas-h-6 bas-w-6 bas-text-white"
9829
- viewBox="0 0 24 24"
9830
- fill="currentColor"
9831
- aria-hidden="true"
9832
- >
9833
- <path
9834
- d="M12 2 1 21h22L12 2Zm0 6c.55 0 1 .45 1 1v5a1 1 0 1 1-2 0V9c0-.55.45-1 1-1Zm0 9.5a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5Z"
9894
+ </ba-btn-base>
9895
+ }
9896
+ } @else {
9897
+ @if (initializeSdk()) {
9898
+ <ng-container
9899
+ baRuntime
9900
+ (success)="success.emit($event)"
9901
+ (errored)="errored.emit()"
9902
+ (loggedOut)="loggedOut.emit()"
9903
+ />
9904
+ }
9905
+
9906
+ @if (!ui().isSigned || !ui().isSignedFirstCheck) {
9907
+ <ba-btn-base
9908
+ btnId="btn-flow-blockauth"
9909
+ type="button-outlined"
9910
+ size="base"
9911
+ [disabled]="isLoading()"
9912
+ [isLoader]="isLoading()"
9913
+ loaderColor="#ffffff"
9914
+ [isIcon]="ws().ready"
9915
+ [text]="buttonText() || label()"
9916
+ [bgClassNames]="bgClassNames()"
9917
+ [textClassNames]="btnTextClassNames()"
9918
+ [classNames]="'bas-justify-center ' + btnClassNames()"
9919
+ [isFocusOutlinedEnabled]="false"
9920
+ (action)="onFlowBAClicked()"
9921
+ >
9922
+ @if (ws().ready && ui().isSdkSignedIn) {
9923
+ <img
9924
+ slot="icon"
9925
+ src="https://dashboard.block-auth.io/img/blockauth_logo.png"
9926
+ width="26"
9927
+ height="26"
9928
+ alt="BlockAuth"
9835
9929
  />
9836
- </svg>
9837
- }
9838
- </ba-btn-base>
9930
+ } @else if (ws().ready) {
9931
+ <svg
9932
+ slot="icon"
9933
+ class="bas-h-6 bas-w-6 bas-text-white"
9934
+ viewBox="0 0 24 24"
9935
+ fill="currentColor"
9936
+ aria-hidden="true"
9937
+ >
9938
+ <path
9939
+ d="M12 2 1 21h22L12 2Zm0 6c.55 0 1 .45 1 1v5a1 1 0 1 1-2 0V9c0-.55.45-1 1-1Zm0 9.5a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5Z"
9940
+ />
9941
+ </svg>
9942
+ }
9943
+ </ba-btn-base>
9944
+ }
9945
+
9839
9946
  }
9840
9947
 
9841
9948
  @if (showDDP()) {
@@ -9852,13 +9959,15 @@ class FlowBlockAuthComponent {
9852
9959
  />
9853
9960
  }
9854
9961
 
9855
- <!-- Orden fijo: signin (modal de txn) se renderiza por encima de signup;
9856
- la card de signup queda detrás. Cada modal se auto-oculta según el
9857
- stack openModals del core. -->
9858
- <ba-modal-signup />
9859
- <ba-modal-restore />
9860
- <ba-modal-restoration-expired />
9861
- <ba-modal-signin />
9962
+ @if (!isHosted) {
9963
+ <!-- Orden fijo: signin (modal de txn) se renderiza por encima de signup;
9964
+ la card de signup queda detrás. Cada modal se auto-oculta según el
9965
+ stack openModals del core. -->
9966
+ <ba-modal-signup />
9967
+ <ba-modal-restore />
9968
+ <ba-modal-restoration-expired />
9969
+ <ba-modal-signin />
9970
+ }
9862
9971
  </div>
9863
9972
  `, isInline: true, dependencies: [{ kind: "component", type: BtnBaseComponent, selector: "ba-btn-base", inputs: ["btnId", "text", "size", "type", "btnType", "ringClassNames", "offsetClassNames", "commonClassNames", "classNames", "bgClassNames", "borderClassNames", "paddingClassNames", "textClassNames", "isIcon", "iconUrl", "iconWidth", "iconHeight", "iconClassNames", "isLoader", "loaderColor", "loaderWidth", "loaderContainerClassNames", "isFocusOutlinedEnabled", "disabled", "applyDisabledStyles"], outputs: ["action"] }, { kind: "directive", type: BlockAuthRuntimeDirective, selector: "[baRuntime]", outputs: ["success", "errored", "loggedOut"] }, { kind: "component", type: DropdownProfileComponent, selector: "ba-dropdown-profile", inputs: ["onLogout", "onNavigate", "isInsideModal", "container", "disabled", "dropdownBtnSize", "dropdownBtnBgClassNames", "dropdownBtnTextColorClassNames", "dropdownBtnBorderClassNames", "dropdownHeight", "additionalDropdownItems"] }, { kind: "component", type: ModalSigninComponent, selector: "ba-modal-signin" }, { kind: "component", type: ModalSignupComponent, selector: "ba-modal-signup" }, { kind: "component", type: ModalRestoreComponent, selector: "ba-modal-restore" }, { kind: "component", type: ModalRestorationExpiredComponent, selector: "ba-modal-restoration-expired" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
9864
9973
  }
@@ -9885,32 +9994,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
9885
9994
  (showDDP() ? 'bas-h-fit bas-flex-col bas-gap-2.5' : ' bas-h-[52px]')
9886
9995
  "
9887
9996
  >
9888
- @if (initializeSdk()) {
9889
- <ng-container
9890
- baRuntime
9891
- (success)="success.emit($event)"
9892
- (errored)="errored.emit()"
9893
- (loggedOut)="loggedOut.emit()"
9894
- />
9895
- }
9896
-
9897
- @if (!ui().isSigned || !ui().isSignedFirstCheck) {
9898
- <ba-btn-base
9899
- btnId="btn-flow-blockauth"
9900
- type="button-outlined"
9901
- size="base"
9902
- [disabled]="isLoading()"
9903
- [isLoader]="isLoading()"
9904
- loaderColor="#ffffff"
9905
- [isIcon]="ws().ready"
9906
- [text]="buttonText() || label()"
9907
- [bgClassNames]="bgClassNames()"
9908
- [textClassNames]="btnTextClassNames()"
9909
- [classNames]="'bas-justify-center ' + btnClassNames()"
9910
- [isFocusOutlinedEnabled]="false"
9911
- (action)="onFlowBAClicked()"
9912
- >
9913
- @if (ws().ready && ui().isSdkSignedIn) {
9997
+ @if (isHosted) {
9998
+ @if (!ui().isSigned) {
9999
+ <ba-btn-base
10000
+ btnId="btn-flow-blockauth"
10001
+ type="button-outlined"
10002
+ size="base"
10003
+ [disabled]="isPopupOpen()"
10004
+ [isLoader]="isPopupOpen()"
10005
+ loaderColor="#ffffff"
10006
+ [isIcon]="true"
10007
+ [text]="buttonText() || hostedLoginLabel()"
10008
+ bgClassNames="bal-ba-glass-status-btn bal-ba-glass-tone-ready"
10009
+ [textClassNames]="btnTextClassNames()"
10010
+ [classNames]="'bas-justify-center ' + btnClassNames()"
10011
+ [isFocusOutlinedEnabled]="false"
10012
+ (action)="onHostedLoginClicked()"
10013
+ >
9914
10014
  <img
9915
10015
  slot="icon"
9916
10016
  src="https://dashboard.block-auth.io/img/blockauth_logo.png"
@@ -9918,20 +10018,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
9918
10018
  height="26"
9919
10019
  alt="BlockAuth"
9920
10020
  />
9921
- } @else if (ws().ready) {
9922
- <svg
9923
- slot="icon"
9924
- class="bas-h-6 bas-w-6 bas-text-white"
9925
- viewBox="0 0 24 24"
9926
- fill="currentColor"
9927
- aria-hidden="true"
9928
- >
9929
- <path
9930
- d="M12 2 1 21h22L12 2Zm0 6c.55 0 1 .45 1 1v5a1 1 0 1 1-2 0V9c0-.55.45-1 1-1Zm0 9.5a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5Z"
10021
+ </ba-btn-base>
10022
+ }
10023
+ } @else {
10024
+ @if (initializeSdk()) {
10025
+ <ng-container
10026
+ baRuntime
10027
+ (success)="success.emit($event)"
10028
+ (errored)="errored.emit()"
10029
+ (loggedOut)="loggedOut.emit()"
10030
+ />
10031
+ }
10032
+
10033
+ @if (!ui().isSigned || !ui().isSignedFirstCheck) {
10034
+ <ba-btn-base
10035
+ btnId="btn-flow-blockauth"
10036
+ type="button-outlined"
10037
+ size="base"
10038
+ [disabled]="isLoading()"
10039
+ [isLoader]="isLoading()"
10040
+ loaderColor="#ffffff"
10041
+ [isIcon]="ws().ready"
10042
+ [text]="buttonText() || label()"
10043
+ [bgClassNames]="bgClassNames()"
10044
+ [textClassNames]="btnTextClassNames()"
10045
+ [classNames]="'bas-justify-center ' + btnClassNames()"
10046
+ [isFocusOutlinedEnabled]="false"
10047
+ (action)="onFlowBAClicked()"
10048
+ >
10049
+ @if (ws().ready && ui().isSdkSignedIn) {
10050
+ <img
10051
+ slot="icon"
10052
+ src="https://dashboard.block-auth.io/img/blockauth_logo.png"
10053
+ width="26"
10054
+ height="26"
10055
+ alt="BlockAuth"
9931
10056
  />
9932
- </svg>
9933
- }
9934
- </ba-btn-base>
10057
+ } @else if (ws().ready) {
10058
+ <svg
10059
+ slot="icon"
10060
+ class="bas-h-6 bas-w-6 bas-text-white"
10061
+ viewBox="0 0 24 24"
10062
+ fill="currentColor"
10063
+ aria-hidden="true"
10064
+ >
10065
+ <path
10066
+ d="M12 2 1 21h22L12 2Zm0 6c.55 0 1 .45 1 1v5a1 1 0 1 1-2 0V9c0-.55.45-1 1-1Zm0 9.5a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5Z"
10067
+ />
10068
+ </svg>
10069
+ }
10070
+ </ba-btn-base>
10071
+ }
10072
+
9935
10073
  }
9936
10074
 
9937
10075
  @if (showDDP()) {
@@ -9948,17 +10086,145 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
9948
10086
  />
9949
10087
  }
9950
10088
 
9951
- <!-- Orden fijo: signin (modal de txn) se renderiza por encima de signup;
9952
- la card de signup queda detrás. Cada modal se auto-oculta según el
9953
- stack openModals del core. -->
9954
- <ba-modal-signup />
9955
- <ba-modal-restore />
9956
- <ba-modal-restoration-expired />
9957
- <ba-modal-signin />
10089
+ @if (!isHosted) {
10090
+ <!-- Orden fijo: signin (modal de txn) se renderiza por encima de signup;
10091
+ la card de signup queda detrás. Cada modal se auto-oculta según el
10092
+ stack openModals del core. -->
10093
+ <ba-modal-signup />
10094
+ <ba-modal-restore />
10095
+ <ba-modal-restoration-expired />
10096
+ <ba-modal-signin />
10097
+ }
9958
10098
  </div>
9959
10099
  `,
9960
10100
  }]
9961
- }], propDecorators: { showDropdownWhenConnected: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDropdownWhenConnected", required: false }] }], isInsideModal: [{ type: i0.Input, args: [{ isSignal: true, alias: "isInsideModal", required: false }] }], container: [{ type: i0.Input, args: [{ isSignal: true, alias: "container", required: false }] }], btnClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "btnClassNames", required: false }] }], btnTextClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "btnTextClassNames", required: false }] }], dropdownBtnSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownBtnSize", required: false }] }], dropdownBtnBgClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownBtnBgClassNames", required: false }] }], dropdownBtnTextColorClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownBtnTextColorClassNames", required: false }] }], dropdownBtnBorderClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownBtnBorderClassNames", required: false }] }], dropdownHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownHeight", required: false }] }], initializeSdk: [{ type: i0.Input, args: [{ isSignal: true, alias: "initializeSdk", required: false }] }], additionalDropdownItems: [{ type: i0.Input, args: [{ isSignal: true, alias: "additionalDropdownItems", required: false }] }], buttonText: [{ type: i0.Input, args: [{ isSignal: true, alias: "buttonText", required: false }] }], success: [{ type: i0.Output, args: ["success"] }], errored: [{ type: i0.Output, args: ["errored"] }], loggedOut: [{ type: i0.Output, args: ["loggedOut"] }] } });
10101
+ }], ctorParameters: () => [], propDecorators: { showDropdownWhenConnected: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDropdownWhenConnected", required: false }] }], isInsideModal: [{ type: i0.Input, args: [{ isSignal: true, alias: "isInsideModal", required: false }] }], container: [{ type: i0.Input, args: [{ isSignal: true, alias: "container", required: false }] }], btnClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "btnClassNames", required: false }] }], btnTextClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "btnTextClassNames", required: false }] }], dropdownBtnSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownBtnSize", required: false }] }], dropdownBtnBgClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownBtnBgClassNames", required: false }] }], dropdownBtnTextColorClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownBtnTextColorClassNames", required: false }] }], dropdownBtnBorderClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownBtnBorderClassNames", required: false }] }], dropdownHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownHeight", required: false }] }], initializeSdk: [{ type: i0.Input, args: [{ isSignal: true, alias: "initializeSdk", required: false }] }], additionalDropdownItems: [{ type: i0.Input, args: [{ isSignal: true, alias: "additionalDropdownItems", required: false }] }], buttonText: [{ type: i0.Input, args: [{ isSignal: true, alias: "buttonText", required: false }] }], onAuthCode: [{ type: i0.Input, args: [{ isSignal: true, alias: "onAuthCode", required: false }] }], user: [{ type: i0.Input, args: [{ isSignal: true, alias: "user", required: false }] }], success: [{ type: i0.Output, args: ["success"] }], errored: [{ type: i0.Output, args: ["errored"] }], loggedOut: [{ type: i0.Output, args: ["loggedOut"] }] } });
10102
+
10103
+ class LinkBlockAuthComponent {
10104
+ constructor() {
10105
+ this.buttonText = input('', ...(ngDevMode ? [{ debugName: "buttonText" }] : []));
10106
+ this.btnClassNames = input('', ...(ngDevMode ? [{ debugName: "btnClassNames" }] : []));
10107
+ this.btnTextClassNames = input('', ...(ngDevMode ? [{ debugName: "btnTextClassNames" }] : []));
10108
+ this.linked = output();
10109
+ this.errored = output();
10110
+ this.ba = inject(BlockAuthService);
10111
+ this.client = this.ba.client;
10112
+ this.locale = this.ba.locale;
10113
+ this.canLink = signal(false, ...(ngDevMode ? [{ debugName: "canLink" }] : []));
10114
+ this.isPopupOpen = signal(false, ...(ngDevMode ? [{ debugName: "isPopupOpen" }] : []));
10115
+ this.linkDefault = {
10116
+ es: 'Vincular con BlockAuth',
10117
+ en: 'Link with BlockAuth',
10118
+ };
10119
+ this.linkLabel = computed(() => this.linkDefault[this.locale()] ?? this.linkDefault['en'], ...(ngDevMode ? [{ debugName: "linkLabel" }] : []));
10120
+ }
10121
+ ngOnInit() {
10122
+ void this.refreshStatus();
10123
+ }
10124
+ onLinkClicked() {
10125
+ if (this.isPopupOpen())
10126
+ return;
10127
+ this.isPopupOpen.set(true);
10128
+ this.client
10129
+ .linkWithAuthEndpoint()
10130
+ .then(() => {
10131
+ this.canLink.set(false);
10132
+ this.linked.emit();
10133
+ })
10134
+ .catch((error) => {
10135
+ this.errored.emit(error instanceof AccountLinkError ? error.reason : 'failed');
10136
+ return this.refreshStatus();
10137
+ })
10138
+ .finally(() => this.isPopupOpen.set(false));
10139
+ }
10140
+ refreshStatus() {
10141
+ if (!this.client.hasAuthEndpoint) {
10142
+ this.canLink.set(false);
10143
+ return Promise.resolve();
10144
+ }
10145
+ return this.client
10146
+ .getAccountLinkStatus()
10147
+ .then((linked) => this.canLink.set(linked === false))
10148
+ .catch(() => {
10149
+ this.canLink.set(false);
10150
+ this.errored.emit('failed');
10151
+ });
10152
+ }
10153
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: LinkBlockAuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
10154
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: LinkBlockAuthComponent, isStandalone: true, selector: "ba-link-block-auth", inputs: { buttonText: { classPropertyName: "buttonText", publicName: "buttonText", isSignal: true, isRequired: false, transformFunction: null }, btnClassNames: { classPropertyName: "btnClassNames", publicName: "btnClassNames", isSignal: true, isRequired: false, transformFunction: null }, btnTextClassNames: { classPropertyName: "btnTextClassNames", publicName: "btnTextClassNames", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { linked: "linked", errored: "errored" }, ngImport: i0, template: `
10155
+ @if (canLink()) {
10156
+ <div
10157
+ data-testid="link-blockauth"
10158
+ class="bas-flex bas-h-[52px] bas-w-full bas-items-center bas-justify-center"
10159
+ >
10160
+ <ba-btn-base
10161
+ btnId="btn-link-blockauth"
10162
+ type="button-outlined"
10163
+ size="base"
10164
+ [disabled]="isPopupOpen()"
10165
+ [isLoader]="isPopupOpen()"
10166
+ loaderColor="#ffffff"
10167
+ [isIcon]="true"
10168
+ [text]="buttonText() || linkLabel()"
10169
+ bgClassNames="bal-ba-glass-status-btn bal-ba-glass-tone-ready"
10170
+ [textClassNames]="btnTextClassNames()"
10171
+ [classNames]="'bas-justify-center ' + btnClassNames()"
10172
+ [isFocusOutlinedEnabled]="false"
10173
+ (action)="onLinkClicked()"
10174
+ >
10175
+ <img
10176
+ slot="icon"
10177
+ src="https://dashboard.block-auth.io/img/blockauth_logo.png"
10178
+ width="26"
10179
+ height="26"
10180
+ alt="BlockAuth"
10181
+ />
10182
+ </ba-btn-base>
10183
+ </div>
10184
+ }
10185
+ `, isInline: true, dependencies: [{ kind: "component", type: BtnBaseComponent, selector: "ba-btn-base", inputs: ["btnId", "text", "size", "type", "btnType", "ringClassNames", "offsetClassNames", "commonClassNames", "classNames", "bgClassNames", "borderClassNames", "paddingClassNames", "textClassNames", "isIcon", "iconUrl", "iconWidth", "iconHeight", "iconClassNames", "isLoader", "loaderColor", "loaderWidth", "loaderContainerClassNames", "isFocusOutlinedEnabled", "disabled", "applyDisabledStyles"], outputs: ["action"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
10186
+ }
10187
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: LinkBlockAuthComponent, decorators: [{
10188
+ type: Component,
10189
+ args: [{
10190
+ selector: 'ba-link-block-auth',
10191
+ standalone: true,
10192
+ changeDetection: ChangeDetectionStrategy.OnPush,
10193
+ imports: [BtnBaseComponent],
10194
+ template: `
10195
+ @if (canLink()) {
10196
+ <div
10197
+ data-testid="link-blockauth"
10198
+ class="bas-flex bas-h-[52px] bas-w-full bas-items-center bas-justify-center"
10199
+ >
10200
+ <ba-btn-base
10201
+ btnId="btn-link-blockauth"
10202
+ type="button-outlined"
10203
+ size="base"
10204
+ [disabled]="isPopupOpen()"
10205
+ [isLoader]="isPopupOpen()"
10206
+ loaderColor="#ffffff"
10207
+ [isIcon]="true"
10208
+ [text]="buttonText() || linkLabel()"
10209
+ bgClassNames="bal-ba-glass-status-btn bal-ba-glass-tone-ready"
10210
+ [textClassNames]="btnTextClassNames()"
10211
+ [classNames]="'bas-justify-center ' + btnClassNames()"
10212
+ [isFocusOutlinedEnabled]="false"
10213
+ (action)="onLinkClicked()"
10214
+ >
10215
+ <img
10216
+ slot="icon"
10217
+ src="https://dashboard.block-auth.io/img/blockauth_logo.png"
10218
+ width="26"
10219
+ height="26"
10220
+ alt="BlockAuth"
10221
+ />
10222
+ </ba-btn-base>
10223
+ </div>
10224
+ }
10225
+ `,
10226
+ }]
10227
+ }], propDecorators: { buttonText: [{ type: i0.Input, args: [{ isSignal: true, alias: "buttonText", required: false }] }], btnClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "btnClassNames", required: false }] }], btnTextClassNames: [{ type: i0.Input, args: [{ isSignal: true, alias: "btnTextClassNames", required: false }] }], linked: [{ type: i0.Output, args: ["linked"] }], errored: [{ type: i0.Output, args: ["errored"] }] } });
9962
10228
 
9963
10229
  // Barrel de los botones de proveedor de @block-auth.io/angular (Task A7),
9964
10230
  // espejo 1:1 de packages/react/src/components/btns/*.
@@ -9972,5 +10238,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
9972
10238
  * Generated bundle index. Do not edit.
9973
10239
  */
9974
10240
 
9975
- export { BlockAuthRuntimeDirective, BlockAuthService, BtnBaseProviderComponent, BtnBlockAuthComponent, BtnGmailComponent, BtnGoogleBaseComponent, BtnMetamaskComponent, BtnMicrosoftComponent, BtnPhantomComponent, BtnSigninComponent, BtnWalletConnectComponent, ChangeAccountComponent, ContentSigninComponent, ContentSignupComponent, DropdownProfileBtnComponent, DropdownProfileComponent, DropdownProfileItemComponent, FlowBlockAuthComponent, FooterSectionComponent, LoginSectionComponent, ModalOverlayComponent, ModalRestorationExpiredComponent, ModalRestoreComponent, ModalSigninComponent, ModalSignupComponent, PermissionsRequiredModalComponent, ProvidersButtonsComponent, ProvidersFiltersComponent, ProvidersSectionComponent, SelectedButtonComponent, SolicitedDataModalComponent, TeleportBodyDirective, TxnComponent, TxnErrorComponent, TxnTypeComponent, TxnsOverviewComponent, injectBlockAuthClient, injectStore, makeWebTypeItems, provideBlockAuth };
10241
+ export { BlockAuthRuntimeDirective, BlockAuthService, BtnBaseProviderComponent, BtnBlockAuthComponent, BtnGmailComponent, BtnGoogleBaseComponent, BtnMetamaskComponent, BtnMicrosoftComponent, BtnPhantomComponent, BtnSigninComponent, BtnWalletConnectComponent, ChangeAccountComponent, ContentSigninComponent, ContentSignupComponent, DropdownProfileBtnComponent, DropdownProfileComponent, DropdownProfileItemComponent, FlowBlockAuthComponent, FooterSectionComponent, LinkBlockAuthComponent, LoginSectionComponent, ModalOverlayComponent, ModalRestorationExpiredComponent, ModalRestoreComponent, ModalSigninComponent, ModalSignupComponent, PermissionsRequiredModalComponent, ProvidersButtonsComponent, ProvidersFiltersComponent, ProvidersSectionComponent, SelectedButtonComponent, SolicitedDataModalComponent, TeleportBodyDirective, TxnComponent, TxnErrorComponent, TxnTypeComponent, TxnsOverviewComponent, injectBlockAuthClient, injectStore, makeWebTypeItems, provideBlockAuth };
9976
10242
  //# sourceMappingURL=block-auth.io-angular.mjs.map