@block-auth.io/angular 0.4.0 → 0.4.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.
Files changed (153) hide show
  1. package/fesm2022/block-auth.io-angular.mjs +9828 -0
  2. package/fesm2022/block-auth.io-angular.mjs.map +1 -0
  3. package/index.d.ts +1144 -0
  4. package/package.json +16 -37
  5. package/.turbo/turbo-build.log +0 -37
  6. package/.turbo/turbo-lint.log +0 -4
  7. package/.turbo/turbo-test.log +0 -1400
  8. package/.turbo/turbo-typecheck.log +0 -19
  9. package/CHANGELOG.md +0 -273
  10. package/ng-package.json +0 -6
  11. package/scripts/css-to-ts.mjs +0 -14
  12. package/src/lib/__tests__/integration.test.ts +0 -45
  13. package/src/lib/block-auth.service.test.ts +0 -69
  14. package/src/lib/block-auth.service.ts +0 -81
  15. package/src/lib/components/btns/btn-base-provider.component.test.ts +0 -36
  16. package/src/lib/components/btns/btn-base-provider.component.ts +0 -61
  17. package/src/lib/components/btns/btn-block-auth.component.test.ts +0 -105
  18. package/src/lib/components/btns/btn-block-auth.component.ts +0 -117
  19. package/src/lib/components/btns/btn-gmail.component.test.ts +0 -16
  20. package/src/lib/components/btns/btn-gmail.component.ts +0 -41
  21. package/src/lib/components/btns/btn-google-base.component.test.ts +0 -16
  22. package/src/lib/components/btns/btn-google-base.component.ts +0 -73
  23. package/src/lib/components/btns/btn-metamask.component.test.ts +0 -20
  24. package/src/lib/components/btns/btn-metamask.component.ts +0 -98
  25. package/src/lib/components/btns/btn-microsoft.component.test.ts +0 -16
  26. package/src/lib/components/btns/btn-microsoft.component.ts +0 -77
  27. package/src/lib/components/btns/btn-phantom.component.test.ts +0 -20
  28. package/src/lib/components/btns/btn-phantom.component.ts +0 -93
  29. package/src/lib/components/btns/btn-signin.component.test.ts +0 -55
  30. package/src/lib/components/btns/btn-signin.component.ts +0 -108
  31. package/src/lib/components/btns/btn-wallet-connect.component.test.ts +0 -20
  32. package/src/lib/components/btns/btn-wallet-connect.component.ts +0 -109
  33. package/src/lib/components/btns/index.ts +0 -11
  34. package/src/lib/components/contents/content-signin.component.test.ts +0 -33
  35. package/src/lib/components/contents/content-signin.component.ts +0 -68
  36. package/src/lib/components/contents/content-signup.component.test.ts +0 -86
  37. package/src/lib/components/contents/content-signup.component.ts +0 -222
  38. package/src/lib/components/dds/change-account.component.test.ts +0 -66
  39. package/src/lib/components/dds/change-account.component.ts +0 -112
  40. package/src/lib/components/dds/dropdown-profile-btn.component.test.ts +0 -66
  41. package/src/lib/components/dds/dropdown-profile-btn.component.ts +0 -172
  42. package/src/lib/components/dds/dropdown-profile-item.component.test.ts +0 -75
  43. package/src/lib/components/dds/dropdown-profile-item.component.ts +0 -74
  44. package/src/lib/components/dds/dropdown-profile.component.test.ts +0 -110
  45. package/src/lib/components/dds/dropdown-profile.component.ts +0 -264
  46. package/src/lib/components/flow-block-auth.component.test.ts +0 -95
  47. package/src/lib/components/flow-block-auth.component.ts +0 -228
  48. package/src/lib/components/modals/modal-overlay.component.test.ts +0 -81
  49. package/src/lib/components/modals/modal-overlay.component.ts +0 -43
  50. package/src/lib/components/modals/modal-restoration-expired.component.test.ts +0 -71
  51. package/src/lib/components/modals/modal-restoration-expired.component.ts +0 -83
  52. package/src/lib/components/modals/modal-restore.component.test.ts +0 -74
  53. package/src/lib/components/modals/modal-restore.component.ts +0 -104
  54. package/src/lib/components/modals/modal-signin.component.test.ts +0 -66
  55. package/src/lib/components/modals/modal-signin.component.ts +0 -44
  56. package/src/lib/components/modals/modal-signup.component.test.ts +0 -56
  57. package/src/lib/components/modals/modal-signup.component.ts +0 -40
  58. package/src/lib/components/sections/footer-section.component.test.ts +0 -19
  59. package/src/lib/components/sections/footer-section.component.ts +0 -49
  60. package/src/lib/components/sections/internals/providers-buttons.component.test.ts +0 -27
  61. package/src/lib/components/sections/internals/providers-buttons.component.ts +0 -280
  62. package/src/lib/components/sections/internals/providers-filters.component.test.ts +0 -25
  63. package/src/lib/components/sections/internals/providers-filters.component.ts +0 -139
  64. package/src/lib/components/sections/internals/selected-button.component.test.ts +0 -36
  65. package/src/lib/components/sections/internals/selected-button.component.ts +0 -92
  66. package/src/lib/components/sections/login-section.component.test.ts +0 -49
  67. package/src/lib/components/sections/login-section.component.ts +0 -119
  68. package/src/lib/components/sections/providers-section.component.test.ts +0 -22
  69. package/src/lib/components/sections/providers-section.component.ts +0 -187
  70. package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +0 -36
  71. package/src/lib/components/txns/internals/permissions-required-modal.component.ts +0 -43
  72. package/src/lib/components/txns/internals/phone-input.component.test.ts +0 -119
  73. package/src/lib/components/txns/internals/phone-input.component.ts +0 -301
  74. package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +0 -700
  75. package/src/lib/components/txns/internals/solicited-data-modal.component.ts +0 -430
  76. package/src/lib/components/txns/internals/txn-error.component.test.ts +0 -127
  77. package/src/lib/components/txns/internals/txn-error.component.ts +0 -144
  78. package/src/lib/components/txns/internals/txn-type.component.test.ts +0 -52
  79. package/src/lib/components/txns/internals/txn-type.component.ts +0 -51
  80. package/src/lib/components/txns/internals/txn.component.test.ts +0 -593
  81. package/src/lib/components/txns/internals/txn.component.ts +0 -453
  82. package/src/lib/components/txns/txns-overview.component.test.ts +0 -421
  83. package/src/lib/components/txns/txns-overview.component.ts +0 -461
  84. package/src/lib/icons/ai-outline-disconnect.component.ts +0 -21
  85. package/src/lib/icons/bi-logo-gmail.component.ts +0 -21
  86. package/src/lib/icons/cg-profile.component.ts +0 -31
  87. package/src/lib/icons/check-icon.component.ts +0 -27
  88. package/src/lib/icons/ci-clock2.component.ts +0 -31
  89. package/src/lib/icons/fa-arrow-right.component.ts +0 -21
  90. package/src/lib/icons/fa-times.component.ts +0 -21
  91. package/src/lib/icons/fa-undo.component.ts +0 -21
  92. package/src/lib/icons/icons.test.ts +0 -25
  93. package/src/lib/icons/index.ts +0 -22
  94. package/src/lib/icons/io-ios-arrow-back.component.ts +0 -21
  95. package/src/lib/icons/io-ios-arrow-forward.component.ts +0 -21
  96. package/src/lib/icons/io-md-arrow-back.component.ts +0 -19
  97. package/src/lib/icons/io-md-arrow-forward.component.ts +0 -19
  98. package/src/lib/icons/pi-warning-fill.component.ts +0 -21
  99. package/src/lib/icons/tb-arrows-exchange2.component.ts +0 -30
  100. package/src/lib/icons/tb-copy-check-filled.component.ts +0 -21
  101. package/src/lib/icons/tb-copy.component.ts +0 -34
  102. package/src/lib/icons/ti-vendor-microsoft.component.ts +0 -21
  103. package/src/lib/inject-store.test.ts +0 -26
  104. package/src/lib/inject-store.ts +0 -16
  105. package/src/lib/primitives/arrow-icon.component.test.ts +0 -25
  106. package/src/lib/primitives/arrow-icon.component.ts +0 -45
  107. package/src/lib/primitives/btn-arrow-dir.component.test.ts +0 -22
  108. package/src/lib/primitives/btn-arrow-dir.component.ts +0 -65
  109. package/src/lib/primitives/btn-base.component.test.ts +0 -38
  110. package/src/lib/primitives/btn-base.component.ts +0 -140
  111. package/src/lib/primitives/divider-base.component.test.ts +0 -12
  112. package/src/lib/primitives/divider-base.component.ts +0 -74
  113. package/src/lib/primitives/dropdown-arrow.component.test.ts +0 -12
  114. package/src/lib/primitives/dropdown-arrow.component.ts +0 -46
  115. package/src/lib/primitives/dropdown-base.component.test.ts +0 -49
  116. package/src/lib/primitives/dropdown-base.component.ts +0 -329
  117. package/src/lib/primitives/helpers.ts +0 -151
  118. package/src/lib/primitives/horizontal-loader.component.test.ts +0 -20
  119. package/src/lib/primitives/horizontal-loader.component.ts +0 -46
  120. package/src/lib/primitives/icon-base.component.test.ts +0 -19
  121. package/src/lib/primitives/icon-base.component.ts +0 -58
  122. package/src/lib/primitives/img-loader.component.test.ts +0 -22
  123. package/src/lib/primitives/img-loader.component.ts +0 -121
  124. package/src/lib/primitives/index.ts +0 -29
  125. package/src/lib/primitives/input-base.component.test.ts +0 -20
  126. package/src/lib/primitives/input-base.component.ts +0 -210
  127. package/src/lib/primitives/lifetime-slider-base.component.test.ts +0 -88
  128. package/src/lib/primitives/lifetime-slider-base.component.ts +0 -75
  129. package/src/lib/primitives/oval-spinner.component.test.ts +0 -17
  130. package/src/lib/primitives/oval-spinner.component.ts +0 -136
  131. package/src/lib/primitives/pickers/dropdown-picker-animated-base.component.ts +0 -220
  132. package/src/lib/primitives/pickers/picker-button.component.ts +0 -74
  133. package/src/lib/primitives/pickers/time-picker-dropdown-selector.component.ts +0 -188
  134. package/src/lib/primitives/pickers/time-picker.component.ts +0 -124
  135. package/src/lib/primitives/pickers/time-unit-selector.component.ts +0 -82
  136. package/src/lib/primitives/progressbar.component.test.ts +0 -34
  137. package/src/lib/primitives/progressbar.component.ts +0 -36
  138. package/src/lib/primitives/providersStyles.ts +0 -218
  139. package/src/lib/primitives/slider-base.component.ts +0 -56
  140. package/src/lib/provide-block-auth.test.ts +0 -43
  141. package/src/lib/provide-block-auth.ts +0 -43
  142. package/src/lib/runtime/block-auth-runtime.directive.test.ts +0 -89
  143. package/src/lib/runtime/block-auth-runtime.directive.ts +0 -68
  144. package/src/lib/teleport-body.directive.test.ts +0 -29
  145. package/src/lib/teleport-body.directive.ts +0 -21
  146. package/src/lib/testing.ts +0 -15
  147. package/src/lib/transitions.css +0 -19
  148. package/src/public-api.ts +0 -86
  149. package/src/vitest.setup.ts +0 -8
  150. package/tailwind.config.cjs +0 -6
  151. package/tsconfig.json +0 -15
  152. package/tsconfig.lib.json +0 -9
  153. package/vite.config.mts +0 -44
@@ -1,105 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { render, screen, fireEvent } from '@testing-library/angular';
3
- import { map } from 'nanostores';
4
- import {
5
- resetExtension,
6
- setExtensionInstalled,
7
- setExtensionIsUser,
8
- setExtensionIsUserActive,
9
- setExtensionIsLocked,
10
- } from '@block-auth.io/core';
11
- import { BtnBlockAuthComponent } from './btn-block-auth.component';
12
- import { provideBlockAuthClientForTest } from '../../testing';
13
-
14
- function makeClient() {
15
- const connectBlockAuth = vi.fn();
16
- const $ui = map({
17
- isSdkSignedIn: false,
18
- uiConfig: null,
19
- isServiceConnected: false,
20
- serviceName: null as string | null,
21
- });
22
- const $ws = map({ ready: false });
23
- const client = { connectBlockAuth, state: { $ui, $ws } } as any;
24
- return { client, connectBlockAuth, $ui, $ws };
25
- }
26
-
27
- function ready(c: ReturnType<typeof makeClient>): void {
28
- c.$ws.setKey('ready', true);
29
- c.$ui.setKey('isSdkSignedIn', true);
30
- }
31
-
32
- describe('BtnBlockAuth', () => {
33
- beforeEach(() => resetExtension());
34
-
35
- it('renderiza con el id de provider y es clickable', async () => {
36
- const { client } = makeClient();
37
- await render(BtnBlockAuthComponent, { providers: [provideBlockAuthClientForTest(client)] });
38
- expect(screen.getByRole('button').id).toBe('btn-provider-blockauth');
39
- });
40
-
41
- it('abre la Chrome Web Store cuando la extensión no está instalada', async () => {
42
- const c = makeClient();
43
- const { client, connectBlockAuth } = c;
44
- ready(c);
45
- const openSpy = vi.spyOn(window, 'open').mockImplementation(() => null);
46
- await render(BtnBlockAuthComponent, { providers: [provideBlockAuthClientForTest(client)] });
47
- setExtensionInstalled(false);
48
- await fireEvent.click(screen.getByRole('button'));
49
- expect(openSpy).toHaveBeenCalledWith(expect.stringContaining('chromewebstore'), '_blank');
50
- expect(connectBlockAuth).not.toHaveBeenCalled();
51
- openSpy.mockRestore();
52
- });
53
-
54
- it('despacha ext:open cuando está instalada pero el usuario aún no está activo', async () => {
55
- const c = makeClient();
56
- const { client, connectBlockAuth } = c;
57
- ready(c);
58
- const dispatchSpy = vi.spyOn(document, 'dispatchEvent');
59
- await render(BtnBlockAuthComponent, { providers: [provideBlockAuthClientForTest(client)] });
60
- setExtensionInstalled(true);
61
- setExtensionIsUser(true);
62
- setExtensionIsUserActive(false);
63
- await fireEvent.click(screen.getByRole('button'));
64
- const dispatchedExtOpen = dispatchSpy.mock.calls.some(
65
- (c) => (c[0] as Event).type === 'ext:open',
66
- );
67
- expect(dispatchedExtOpen).toBe(true);
68
- expect(connectBlockAuth).not.toHaveBeenCalled();
69
- dispatchSpy.mockRestore();
70
- });
71
-
72
- it('llama client.connectBlockAuth cuando está lista, activa y no conectada', async () => {
73
- const c = makeClient();
74
- const { client, connectBlockAuth } = c;
75
- ready(c);
76
- await render(BtnBlockAuthComponent, { providers: [provideBlockAuthClientForTest(client)] });
77
- setExtensionInstalled(true);
78
- setExtensionIsUser(true);
79
- setExtensionIsUserActive(true);
80
- setExtensionIsLocked(false);
81
- await fireEvent.click(screen.getByRole('button'));
82
- expect(connectBlockAuth).toHaveBeenCalledOnce();
83
- });
84
-
85
- it('despacha ext:open en vez de reconectar cuando está conectada sin did', async () => {
86
- const c = makeClient();
87
- const { client, connectBlockAuth } = c;
88
- ready(c);
89
- c.$ui.setKey('isServiceConnected', true);
90
- c.$ui.setKey('serviceName', 'blockauth');
91
- const dispatchSpy = vi.spyOn(document, 'dispatchEvent');
92
- await render(BtnBlockAuthComponent, { providers: [provideBlockAuthClientForTest(client)] });
93
- setExtensionInstalled(true);
94
- setExtensionIsUser(true);
95
- setExtensionIsUserActive(true);
96
- setExtensionIsLocked(false);
97
- await fireEvent.click(screen.getByRole('button'));
98
- const dispatchedExtOpen = dispatchSpy.mock.calls.some(
99
- (c) => (c[0] as Event).type === 'ext:open',
100
- );
101
- expect(dispatchedExtOpen).toBe(true);
102
- expect(connectBlockAuth).not.toHaveBeenCalled();
103
- dispatchSpy.mockRestore();
104
- });
105
- });
@@ -1,117 +0,0 @@
1
- import {
2
- ChangeDetectionStrategy,
3
- Component,
4
- computed,
5
- input,
6
- } from '@angular/core';
7
- import { $extension, $locale, getExtensionStoreUrl } from '@block-auth.io/core';
8
- import { BtnBaseComponent } from '../../primitives/btn-base.component';
9
- import { injectBlockAuthClient } from '../../provide-block-auth';
10
- import { injectStore } from '../../inject-store';
11
-
12
- /**
13
- * El único botón que ramifica sobre el estado de la extensión (`$extension`,
14
- * que no está envuelto por `BlockAuthService`, se lee aquí con `injectStore`).
15
- * Según el estado (installed/isUser/isUserActive/isLocked):
16
- * - no instalada → abre la Chrome Web Store,
17
- * - no user / no activo / bloqueada, o conectada sin sesión (OTP pendiente
18
- * en la extensión) → despacha el evento DOM `ext:open`,
19
- * - conectable → `client.connectBlockAuth()`.
20
- * El label sale del mapa localizado `uiConfig.config.content.btns`.
21
- */
22
- @Component({
23
- selector: 'ba-btn-block-auth',
24
- standalone: true,
25
- changeDetection: ChangeDetectionStrategy.OnPush,
26
- imports: [BtnBaseComponent],
27
- template: `
28
- @if (isDropdownProfile()) {
29
- <button
30
- id="btn-provider-blockauth-dropdown"
31
- class="bas-h-full bas-w-full bas-border-0 bas-bg-transparent bas-p-0"
32
- (click)="onBtnBlockAuthClicked()"
33
- >
34
- <ng-content />
35
- </button>
36
- } @else {
37
- <ba-btn-base
38
- btnId="btn-provider-blockauth"
39
- [text]="getBtnText() || text()"
40
- type="button-outlined"
41
- size="small"
42
- paddingClassNames="bas-px-12"
43
- [isIcon]="true"
44
- textClassNames="bas-text-white bas-font-semibold bas-leading-6 bas-text-base"
45
- [disabled]="disabled()"
46
- [applyDisabledStyles]="false"
47
- [isLoader]="false"
48
- [isFocusOutlinedEnabled]="false"
49
- (action)="onBtnBlockAuthClicked()"
50
- >
51
- <img
52
- slot="icon"
53
- src="https://dashboard.block-auth.io/img/blockauth_logo.png"
54
- width="24"
55
- height="24"
56
- alt="Block-Auth"
57
- />
58
- </ba-btn-base>
59
- }
60
- `,
61
- })
62
- export class BtnBlockAuthComponent {
63
- isDropdownProfile = input(false);
64
- disabled = input(false);
65
- isEditable = input(false);
66
- text = input('Conectar');
67
-
68
- private client = injectBlockAuthClient();
69
- private ui = injectStore(this.client.state.$ui);
70
- private ws = injectStore(this.client.state.$ws);
71
- private ext = injectStore($extension);
72
- private locale = injectStore($locale);
73
-
74
- private btnsTexts = computed(
75
- () =>
76
- (
77
- this.ui().uiConfig as {
78
- config?: {
79
- content?: { btns?: Record<string, Record<string, string>> };
80
- };
81
- } | null
82
- )?.config?.content?.btns,
83
- );
84
- private txt = (key: string): string =>
85
- this.btnsTexts()?.[key]?.[this.locale()] ?? this.text();
86
-
87
- getBtnText = computed((): string => {
88
- if (!(this.ws().ready && this.ui().isSdkSignedIn)) return '';
89
- const ext = this.ext();
90
- if (!ext.installed) return this.txt('download');
91
- if (!ext.isUser) return this.txt('createAccount');
92
- if (!ext.isUserActive) return this.txt('completeRegister');
93
- if (ext.isLocked) return this.txt('unlockOtp');
94
- return this.txt('connect');
95
- });
96
-
97
- onBtnBlockAuthClicked(): void {
98
- if (this.isEditable()) return;
99
- if (!this.ws().ready || !this.ui().isSdkSignedIn) return;
100
- const ext = this.ext();
101
- if (!ext.installed) {
102
- if (typeof window !== 'undefined')
103
- window.open(getExtensionStoreUrl(), '_blank');
104
- return;
105
- }
106
- // Connected but without a did: only the OTP in the extension brings the session back.
107
- const ui = this.ui();
108
- const isPendingOtp = ui.isServiceConnected && ui.serviceName === 'blockauth' && !this.ws().did;
109
- if (!ext.isUser || !ext.isUserActive || ext.isLocked || isPendingOtp) {
110
- if (typeof document !== 'undefined') {
111
- document.dispatchEvent(new CustomEvent('ext:open', { detail: {} }));
112
- }
113
- return;
114
- }
115
- this.client.connectBlockAuth();
116
- }
117
- }
@@ -1,16 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, screen, fireEvent, waitFor } from '@testing-library/angular';
3
- import { BtnGmailComponent } from './btn-gmail.component';
4
- import { provideBlockAuthClientForTest } from '../../testing';
5
-
6
- describe('BtnGmail', () => {
7
- it('compone BtnGoogleBase: al hacer click dispara oauth.signupGoogle', async () => {
8
- const signupGoogleSpy = vi.fn(async () => undefined);
9
- const fakeClient = { oauth: { signupGoogle: signupGoogleSpy } } as any;
10
- await render(BtnGmailComponent, {
11
- providers: [provideBlockAuthClientForTest(fakeClient)],
12
- });
13
- await fireEvent.click(screen.getByRole('button'));
14
- await waitFor(() => expect(signupGoogleSpy).toHaveBeenCalledWith('auth-code'));
15
- });
16
- });
@@ -1,41 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
2
- import { BtnGoogleBaseComponent } from './btn-google-base.component';
3
- import { BiLogoGmailComponent } from '../../icons';
4
-
5
- /**
6
- * Envuelve `BtnGoogleBase` con la paleta roja de Gmail y el icono `BiLogoGmail`
7
- * inline como icono por defecto.
8
- */
9
- @Component({
10
- selector: 'ba-btn-gmail',
11
- standalone: true,
12
- changeDetection: ChangeDetectionStrategy.OnPush,
13
- imports: [BtnGoogleBaseComponent, BiLogoGmailComponent],
14
- template: `
15
- <ba-btn-google-base
16
- [isDropdownProfile]="isDropdownProfile()"
17
- [text]="text()"
18
- bgClassNames="bas-bg-[#ed2d2d] hover:bas-bg-[#eb1515]"
19
- ringClassNames="bal-ba-hover-ring-red-400"
20
- paddingClassNames="bas-px-12"
21
- textClassNames="bas-text-white bas-font-semibold bas-leading-6 bas-text-base"
22
- [iconEnabled]="iconEnabled()"
23
- [disabled]="disabled()"
24
- [isFocusOutlinedEnabled]="false"
25
- [isEditable]="isEditable()"
26
- (clicked)="clicked.emit()"
27
- >
28
- <ba-bi-logo-gmail slot="icon" class="bas-h-6 bas-w-6 bas-text-white" />
29
- <ng-content />
30
- </ba-btn-google-base>
31
- `,
32
- })
33
- export class BtnGmailComponent {
34
- isDropdownProfile = input(false);
35
- text = input('Gmail');
36
- iconEnabled = input(true);
37
- disabled = input(false);
38
- isEditable = input(false);
39
-
40
- clicked = output<void>();
41
- }
@@ -1,16 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, screen, fireEvent, waitFor } from '@testing-library/angular';
3
- import { BtnGoogleBaseComponent } from './btn-google-base.component';
4
- import { provideBlockAuthClientForTest } from '../../testing';
5
-
6
- describe('BtnGoogleBase', () => {
7
- it('al hacer click dispara client.oauth.signupGoogle("auth-code")', async () => {
8
- const signupGoogleSpy = vi.fn(async () => undefined);
9
- const fakeClient = { oauth: { signupGoogle: signupGoogleSpy } } as any;
10
- await render(BtnGoogleBaseComponent, {
11
- providers: [provideBlockAuthClientForTest(fakeClient)],
12
- });
13
- await fireEvent.click(screen.getByRole('button'));
14
- await waitFor(() => expect(signupGoogleSpy).toHaveBeenCalledWith('auth-code'));
15
- });
16
- });
@@ -1,73 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
2
- import { BtnBaseComponent } from '../../primitives/btn-base.component';
3
- import { injectBlockAuthClient } from '../../provide-block-auth';
4
-
5
- /**
6
- * Botón Google base (icono + label). Toda la lógica OAuth vive en el core;
7
- * aquí solo se renderiza y el click delega en `client.oauth.signupGoogle(mode)`.
8
- * Los estilos son inputs reales (con los mismos defaults) para que `BtnGmail`
9
- * pueda sobrescribirlos.
10
- *
11
- * El icono se proyecta con `[slot=icon]` y se re-proyecta hacia `BtnBase`
12
- * (`ngProjectAs`).
13
- */
14
- @Component({
15
- selector: 'ba-btn-google-base',
16
- standalone: true,
17
- changeDetection: ChangeDetectionStrategy.OnPush,
18
- imports: [BtnBaseComponent],
19
- template: `
20
- @if (isDropdownProfile()) {
21
- <button
22
- id="btn-provider-google-dropdown"
23
- class="bas-h-full bas-w-full bas-border-0 bas-bg-transparent bas-p-0"
24
- (click)="onBtnGmailClicked()"
25
- ><ng-content /></button>
26
- } @else {
27
- <ba-btn-base
28
- btnId="btn-provider-google"
29
- [text]="text()"
30
- type="button-outlined"
31
- size="small"
32
- [bgClassNames]="bgClassNames()"
33
- [ringClassNames]="ringClassNames()"
34
- [paddingClassNames]="paddingClassNames()"
35
- [textClassNames]="textClassNames()"
36
- [isIcon]="iconEnabled()"
37
- [isFocusOutlinedEnabled]="isFocusOutlinedEnabled()"
38
- [disabled]="disabled()"
39
- (action)="onBtnGmailClicked()"
40
- ><ng-content select="[slot=icon]" ngProjectAs="[slot=icon]" /></ba-btn-base>
41
- }
42
- `,
43
- })
44
- export class BtnGoogleBaseComponent {
45
- isDropdownProfile = input(false);
46
- mode = input<'auth-code' | 'implicit'>('auth-code');
47
- text = input('Google');
48
- bgClassNames = input('bas-bg-[#ed2d2d] hover:bas-bg-[#eb1515]');
49
- ringClassNames = input('bal-ba-hover-ring-red-400');
50
- paddingClassNames = input('bas-px-12');
51
- textClassNames = input('bas-text-white bas-font-semibold bas-leading-6 bas-text-base');
52
- iconEnabled = input(false);
53
- disabled = input(false);
54
- isFocusOutlinedEnabled = input(false);
55
- isEditable = input(false);
56
-
57
- clicked = output<void>();
58
-
59
- private client = injectBlockAuthClient();
60
-
61
- async onBtnGmailClicked(): Promise<void> {
62
- if (this.isEditable()) return;
63
- try {
64
- await this.client.oauth.signupGoogle(this.mode());
65
- } catch (err) {
66
- // Exponer la mala configuración (clientId ausente, script GIS no cargado)
67
- // y las cancelaciones en vez de tragárnoslas: un catch silencioso haría
68
- // que el botón pareciera inerte cuando en realidad falló.
69
- console.warn('[blockauth] Google sign-in failed:', err);
70
- }
71
- this.clicked.emit();
72
- }
73
- }
@@ -1,20 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, screen, fireEvent, waitFor } from '@testing-library/angular';
3
- import { map } from 'nanostores';
4
- import { BtnMetamaskComponent } from './btn-metamask.component';
5
- import { provideBlockAuthClientForTest } from '../../testing';
6
-
7
- describe('BtnMetamask', () => {
8
- it('al hacer click dispara client.web3.signup("metamask")', async () => {
9
- const signupSpy = vi.fn(async () => undefined);
10
- const fakeClient = {
11
- web3: { signup: signupSpy },
12
- state: { $wallet: map({ address: null, isConnecting: false }) },
13
- } as any;
14
- await render(BtnMetamaskComponent, {
15
- providers: [provideBlockAuthClientForTest(fakeClient)],
16
- });
17
- await fireEvent.click(screen.getByRole('button'));
18
- await waitFor(() => expect(signupSpy).toHaveBeenCalledWith('metamask'));
19
- });
20
- });
@@ -1,98 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
2
- import { BtnBaseComponent } from '../../primitives/btn-base.component';
3
- import { injectBlockAuthClient } from '../../provide-block-auth';
4
- import { injectStore } from '../../inject-store';
5
-
6
- /**
7
- * Botón de conexión MetaMask (EVM). El click delega en
8
- * `client.web3.signup('metamask')`, que conecta la wallet inyectada y corre
9
- * todo el handshake de signup en el core.
10
- */
11
- const styles = {
12
- bgClassNames: 'bas-bg-[#eb5900] hover:bas-bg-[#d85100]',
13
- disabledBgClassNames: 'bas-bg-[rgba(235,89,0,0.75)] hover:bas-bg-[rgba(216,81,0,0.75)]',
14
- ringClassNames: 'bal-ba-hover-ring-orange-400',
15
- paddingClassNames: 'bas-px-12',
16
- textClassNames: 'bas-text-white bas-font-semibold bas-leading-6 bas-text-base',
17
- loaderWidth: 70,
18
- loaderColor: '#fefefe',
19
- };
20
-
21
- @Component({
22
- selector: 'ba-btn-metamask',
23
- standalone: true,
24
- changeDetection: ChangeDetectionStrategy.OnPush,
25
- imports: [BtnBaseComponent],
26
- template: `
27
- @if (isDropdownProfile()) {
28
- <button
29
- id="btn-provider-metamask-dropdown"
30
- class="bas-h-full bas-w-full bas-border-0 bas-bg-transparent bas-p-0"
31
- (click)="onMetamaskSigning()"
32
- ><ng-content /></button>
33
- } @else {
34
- <ba-btn-base
35
- btnId="btn-provider-metamask"
36
- [text]="btnText()"
37
- type="button-outlined"
38
- size="small"
39
- [bgClassNames]="wallet().isConnecting ? disabledBg : bg"
40
- [ringClassNames]="ring"
41
- [paddingClassNames]="padding"
42
- [textClassNames]="textCls"
43
- [isLoader]="wallet().isConnecting"
44
- [loaderWidth]="loaderWidth"
45
- [loaderColor]="loaderColor"
46
- [isIcon]="iconEnabled()"
47
- [isFocusOutlinedEnabled]="false"
48
- [disabled]="disabled()"
49
- (action)="onMetamaskSigning()"
50
- >
51
- <img
52
- slot="icon"
53
- src="https://img.icons8.com/ios-filled/48/ffffff/metamask-logo.png"
54
- height="24"
55
- width="24"
56
- alt="MetaMask"
57
- />
58
- </ba-btn-base>
59
- }
60
- `,
61
- })
62
- export class BtnMetamaskComponent {
63
- isDropdownProfile = input(false);
64
- text = input('MetaMask');
65
- isTextInsteadOfAccount = input(false);
66
- iconEnabled = input(true);
67
- disabled = input(false);
68
- isEditable = input(false);
69
-
70
- clicked = output<void>();
71
-
72
- private client = injectBlockAuthClient();
73
- wallet = injectStore(this.client.state.$wallet);
74
-
75
- bg = styles.bgClassNames;
76
- disabledBg = styles.disabledBgClassNames;
77
- ring = styles.ringClassNames;
78
- padding = styles.paddingClassNames;
79
- textCls = styles.textClassNames;
80
- loaderWidth = styles.loaderWidth;
81
- loaderColor = styles.loaderColor;
82
-
83
- btnText = computed(() => {
84
- const short = (a: string | null) => (a ? `${a.slice(0, 6)}…${a.slice(-4)}` : '');
85
- return this.isTextInsteadOfAccount() ? this.text() : short(this.wallet().address) || this.text();
86
- });
87
-
88
- async onMetamaskSigning(): Promise<void> {
89
- if (this.isEditable()) return;
90
- if (this.wallet().isConnecting) return;
91
- try {
92
- await this.client.web3.signup('metamask');
93
- } catch {
94
- /* conexión/firma cancelada o fallida */
95
- }
96
- this.clicked.emit();
97
- }
98
- }
@@ -1,16 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, screen, fireEvent, waitFor } from '@testing-library/angular';
3
- import { BtnMicrosoftComponent } from './btn-microsoft.component';
4
- import { provideBlockAuthClientForTest } from '../../testing';
5
-
6
- describe('BtnMicrosoft', () => {
7
- it('al hacer click dispara client.oauth.signupMicrosoft()', async () => {
8
- const signupMicrosoftSpy = vi.fn(async () => undefined);
9
- const fakeClient = { oauth: { signupMicrosoft: signupMicrosoftSpy } } as any;
10
- await render(BtnMicrosoftComponent, {
11
- providers: [provideBlockAuthClientForTest(fakeClient)],
12
- });
13
- await fireEvent.click(screen.getByRole('button'));
14
- await waitFor(() => expect(signupMicrosoftSpy).toHaveBeenCalled());
15
- });
16
- });
@@ -1,77 +0,0 @@
1
- import { ChangeDetectionStrategy, Component, input, output } from '@angular/core';
2
- import { BtnBaseComponent } from '../../primitives/btn-base.component';
3
- import { injectBlockAuthClient } from '../../provide-block-auth';
4
- import { TiVendorMicrosoftComponent } from '../../icons';
5
-
6
- /**
7
- * Botón Microsoft (glifo + label). El click delega en
8
- * `client.oauth.signupMicrosoft()` (la config MSAL + el handshake de signup
9
- * viven en el core).
10
- */
11
- const msStyles = {
12
- bgClassNames: 'bas-bg-[#2b88d8] hover:bas-bg-[#0078d4]',
13
- ringClassNames: 'bal-ba-hover-ring-blue-400',
14
- textClassNames: 'bas-text-white bas-font-semibold bas-leading-6 bas-text-base',
15
- paddingClassNames: 'bas-px-12',
16
- };
17
-
18
- @Component({
19
- selector: 'ba-btn-microsoft',
20
- standalone: true,
21
- changeDetection: ChangeDetectionStrategy.OnPush,
22
- imports: [BtnBaseComponent, TiVendorMicrosoftComponent],
23
- template: `
24
- @if (isDropdownProfile()) {
25
- <button
26
- id="btn-provider-microsoft-dropdown"
27
- class="bas-h-full bas-w-full bas-border-0 bas-bg-transparent bas-p-0"
28
- (click)="microsoftSignin()"
29
- ><ng-content /></button>
30
- } @else {
31
- <ba-btn-base
32
- btnId="btn-provider-microsoft"
33
- [text]="text()"
34
- type="button-outlined"
35
- size="small"
36
- [bgClassNames]="bg"
37
- [ringClassNames]="ring"
38
- [paddingClassNames]="padding"
39
- [textClassNames]="textCls"
40
- [isIcon]="iconEnabled()"
41
- [isFocusOutlinedEnabled]="false"
42
- [disabled]="disabled()"
43
- (action)="microsoftSignin()"
44
- >
45
- <ba-ti-vendor-microsoft slot="icon" class="bas-h-6 bas-w-6 bas-text-white" />
46
- </ba-btn-base>
47
- }
48
- `,
49
- })
50
- export class BtnMicrosoftComponent {
51
- isDropdownProfile = input(false);
52
- text = input('Microsoft');
53
- iconEnabled = input(true);
54
- disabled = input(false);
55
- isEditable = input(false);
56
-
57
- clicked = output<void>();
58
-
59
- private client = injectBlockAuthClient();
60
-
61
- bg = msStyles.bgClassNames;
62
- ring = msStyles.ringClassNames;
63
- padding = msStyles.paddingClassNames;
64
- textCls = msStyles.textClassNames;
65
-
66
- async microsoftSignin(): Promise<void> {
67
- if (this.isEditable()) return;
68
- try {
69
- await this.client.oauth.signupMicrosoft();
70
- } catch (err) {
71
- // Exponer mala configuración (clientId ausente, errores MSAL) y
72
- // cancelaciones en vez de tragárnoslas.
73
- console.warn('[blockauth] Microsoft sign-in failed:', err);
74
- }
75
- this.clicked.emit();
76
- }
77
- }
@@ -1,20 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, screen, fireEvent, waitFor } from '@testing-library/angular';
3
- import { map } from 'nanostores';
4
- import { BtnPhantomComponent } from './btn-phantom.component';
5
- import { provideBlockAuthClientForTest } from '../../testing';
6
-
7
- describe('BtnPhantom', () => {
8
- it('al hacer click dispara client.web3.signup("phantom")', async () => {
9
- const signupSpy = vi.fn(async () => undefined);
10
- const fakeClient = {
11
- web3: { signup: signupSpy },
12
- state: { $wallet: map({ address: null, isConnecting: false }) },
13
- } as any;
14
- await render(BtnPhantomComponent, {
15
- providers: [provideBlockAuthClientForTest(fakeClient)],
16
- });
17
- await fireEvent.click(screen.getByRole('button'));
18
- await waitFor(() => expect(signupSpy).toHaveBeenCalledWith('phantom'));
19
- });
20
- });