@block-auth.io/angular 0.4.0 → 0.5.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.
- package/fesm2022/block-auth.io-angular.mjs +9976 -0
- package/fesm2022/block-auth.io-angular.mjs.map +1 -0
- package/index.d.ts +1155 -0
- package/package.json +16 -37
- package/.turbo/turbo-build.log +0 -37
- package/.turbo/turbo-lint.log +0 -4
- package/.turbo/turbo-test.log +0 -1400
- package/.turbo/turbo-typecheck.log +0 -19
- package/CHANGELOG.md +0 -273
- package/ng-package.json +0 -6
- package/scripts/css-to-ts.mjs +0 -14
- package/src/lib/__tests__/integration.test.ts +0 -45
- package/src/lib/block-auth.service.test.ts +0 -69
- package/src/lib/block-auth.service.ts +0 -81
- package/src/lib/components/btns/btn-base-provider.component.test.ts +0 -36
- package/src/lib/components/btns/btn-base-provider.component.ts +0 -61
- package/src/lib/components/btns/btn-block-auth.component.test.ts +0 -105
- package/src/lib/components/btns/btn-block-auth.component.ts +0 -117
- package/src/lib/components/btns/btn-gmail.component.test.ts +0 -16
- package/src/lib/components/btns/btn-gmail.component.ts +0 -41
- package/src/lib/components/btns/btn-google-base.component.test.ts +0 -16
- package/src/lib/components/btns/btn-google-base.component.ts +0 -73
- package/src/lib/components/btns/btn-metamask.component.test.ts +0 -20
- package/src/lib/components/btns/btn-metamask.component.ts +0 -98
- package/src/lib/components/btns/btn-microsoft.component.test.ts +0 -16
- package/src/lib/components/btns/btn-microsoft.component.ts +0 -77
- package/src/lib/components/btns/btn-phantom.component.test.ts +0 -20
- package/src/lib/components/btns/btn-phantom.component.ts +0 -93
- package/src/lib/components/btns/btn-signin.component.test.ts +0 -55
- package/src/lib/components/btns/btn-signin.component.ts +0 -108
- package/src/lib/components/btns/btn-wallet-connect.component.test.ts +0 -20
- package/src/lib/components/btns/btn-wallet-connect.component.ts +0 -109
- package/src/lib/components/btns/index.ts +0 -11
- package/src/lib/components/contents/content-signin.component.test.ts +0 -33
- package/src/lib/components/contents/content-signin.component.ts +0 -68
- package/src/lib/components/contents/content-signup.component.test.ts +0 -86
- package/src/lib/components/contents/content-signup.component.ts +0 -222
- package/src/lib/components/dds/change-account.component.test.ts +0 -66
- package/src/lib/components/dds/change-account.component.ts +0 -112
- package/src/lib/components/dds/dropdown-profile-btn.component.test.ts +0 -66
- package/src/lib/components/dds/dropdown-profile-btn.component.ts +0 -172
- package/src/lib/components/dds/dropdown-profile-item.component.test.ts +0 -75
- package/src/lib/components/dds/dropdown-profile-item.component.ts +0 -74
- package/src/lib/components/dds/dropdown-profile.component.test.ts +0 -110
- package/src/lib/components/dds/dropdown-profile.component.ts +0 -264
- package/src/lib/components/flow-block-auth.component.test.ts +0 -95
- package/src/lib/components/flow-block-auth.component.ts +0 -228
- package/src/lib/components/modals/modal-overlay.component.test.ts +0 -81
- package/src/lib/components/modals/modal-overlay.component.ts +0 -43
- package/src/lib/components/modals/modal-restoration-expired.component.test.ts +0 -71
- package/src/lib/components/modals/modal-restoration-expired.component.ts +0 -83
- package/src/lib/components/modals/modal-restore.component.test.ts +0 -74
- package/src/lib/components/modals/modal-restore.component.ts +0 -104
- package/src/lib/components/modals/modal-signin.component.test.ts +0 -66
- package/src/lib/components/modals/modal-signin.component.ts +0 -44
- package/src/lib/components/modals/modal-signup.component.test.ts +0 -56
- package/src/lib/components/modals/modal-signup.component.ts +0 -40
- package/src/lib/components/sections/footer-section.component.test.ts +0 -19
- package/src/lib/components/sections/footer-section.component.ts +0 -49
- package/src/lib/components/sections/internals/providers-buttons.component.test.ts +0 -27
- package/src/lib/components/sections/internals/providers-buttons.component.ts +0 -280
- package/src/lib/components/sections/internals/providers-filters.component.test.ts +0 -25
- package/src/lib/components/sections/internals/providers-filters.component.ts +0 -139
- package/src/lib/components/sections/internals/selected-button.component.test.ts +0 -36
- package/src/lib/components/sections/internals/selected-button.component.ts +0 -92
- package/src/lib/components/sections/login-section.component.test.ts +0 -49
- package/src/lib/components/sections/login-section.component.ts +0 -119
- package/src/lib/components/sections/providers-section.component.test.ts +0 -22
- package/src/lib/components/sections/providers-section.component.ts +0 -187
- package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +0 -36
- package/src/lib/components/txns/internals/permissions-required-modal.component.ts +0 -43
- package/src/lib/components/txns/internals/phone-input.component.test.ts +0 -119
- package/src/lib/components/txns/internals/phone-input.component.ts +0 -301
- package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +0 -700
- package/src/lib/components/txns/internals/solicited-data-modal.component.ts +0 -430
- package/src/lib/components/txns/internals/txn-error.component.test.ts +0 -127
- package/src/lib/components/txns/internals/txn-error.component.ts +0 -144
- package/src/lib/components/txns/internals/txn-type.component.test.ts +0 -52
- package/src/lib/components/txns/internals/txn-type.component.ts +0 -51
- package/src/lib/components/txns/internals/txn.component.test.ts +0 -593
- package/src/lib/components/txns/internals/txn.component.ts +0 -453
- package/src/lib/components/txns/txns-overview.component.test.ts +0 -421
- package/src/lib/components/txns/txns-overview.component.ts +0 -461
- package/src/lib/icons/ai-outline-disconnect.component.ts +0 -21
- package/src/lib/icons/bi-logo-gmail.component.ts +0 -21
- package/src/lib/icons/cg-profile.component.ts +0 -31
- package/src/lib/icons/check-icon.component.ts +0 -27
- package/src/lib/icons/ci-clock2.component.ts +0 -31
- package/src/lib/icons/fa-arrow-right.component.ts +0 -21
- package/src/lib/icons/fa-times.component.ts +0 -21
- package/src/lib/icons/fa-undo.component.ts +0 -21
- package/src/lib/icons/icons.test.ts +0 -25
- package/src/lib/icons/index.ts +0 -22
- package/src/lib/icons/io-ios-arrow-back.component.ts +0 -21
- package/src/lib/icons/io-ios-arrow-forward.component.ts +0 -21
- package/src/lib/icons/io-md-arrow-back.component.ts +0 -19
- package/src/lib/icons/io-md-arrow-forward.component.ts +0 -19
- package/src/lib/icons/pi-warning-fill.component.ts +0 -21
- package/src/lib/icons/tb-arrows-exchange2.component.ts +0 -30
- package/src/lib/icons/tb-copy-check-filled.component.ts +0 -21
- package/src/lib/icons/tb-copy.component.ts +0 -34
- package/src/lib/icons/ti-vendor-microsoft.component.ts +0 -21
- package/src/lib/inject-store.test.ts +0 -26
- package/src/lib/inject-store.ts +0 -16
- package/src/lib/primitives/arrow-icon.component.test.ts +0 -25
- package/src/lib/primitives/arrow-icon.component.ts +0 -45
- package/src/lib/primitives/btn-arrow-dir.component.test.ts +0 -22
- package/src/lib/primitives/btn-arrow-dir.component.ts +0 -65
- package/src/lib/primitives/btn-base.component.test.ts +0 -38
- package/src/lib/primitives/btn-base.component.ts +0 -140
- package/src/lib/primitives/divider-base.component.test.ts +0 -12
- package/src/lib/primitives/divider-base.component.ts +0 -74
- package/src/lib/primitives/dropdown-arrow.component.test.ts +0 -12
- package/src/lib/primitives/dropdown-arrow.component.ts +0 -46
- package/src/lib/primitives/dropdown-base.component.test.ts +0 -49
- package/src/lib/primitives/dropdown-base.component.ts +0 -329
- package/src/lib/primitives/helpers.ts +0 -151
- package/src/lib/primitives/horizontal-loader.component.test.ts +0 -20
- package/src/lib/primitives/horizontal-loader.component.ts +0 -46
- package/src/lib/primitives/icon-base.component.test.ts +0 -19
- package/src/lib/primitives/icon-base.component.ts +0 -58
- package/src/lib/primitives/img-loader.component.test.ts +0 -22
- package/src/lib/primitives/img-loader.component.ts +0 -121
- package/src/lib/primitives/index.ts +0 -29
- package/src/lib/primitives/input-base.component.test.ts +0 -20
- package/src/lib/primitives/input-base.component.ts +0 -210
- package/src/lib/primitives/lifetime-slider-base.component.test.ts +0 -88
- package/src/lib/primitives/lifetime-slider-base.component.ts +0 -75
- package/src/lib/primitives/oval-spinner.component.test.ts +0 -17
- package/src/lib/primitives/oval-spinner.component.ts +0 -136
- package/src/lib/primitives/pickers/dropdown-picker-animated-base.component.ts +0 -220
- package/src/lib/primitives/pickers/picker-button.component.ts +0 -74
- package/src/lib/primitives/pickers/time-picker-dropdown-selector.component.ts +0 -188
- package/src/lib/primitives/pickers/time-picker.component.ts +0 -124
- package/src/lib/primitives/pickers/time-unit-selector.component.ts +0 -82
- package/src/lib/primitives/progressbar.component.test.ts +0 -34
- package/src/lib/primitives/progressbar.component.ts +0 -36
- package/src/lib/primitives/providersStyles.ts +0 -218
- package/src/lib/primitives/slider-base.component.ts +0 -56
- package/src/lib/provide-block-auth.test.ts +0 -43
- package/src/lib/provide-block-auth.ts +0 -43
- package/src/lib/runtime/block-auth-runtime.directive.test.ts +0 -89
- package/src/lib/runtime/block-auth-runtime.directive.ts +0 -68
- package/src/lib/teleport-body.directive.test.ts +0 -29
- package/src/lib/teleport-body.directive.ts +0 -21
- package/src/lib/testing.ts +0 -15
- package/src/lib/transitions.css +0 -19
- package/src/public-api.ts +0 -86
- package/src/vitest.setup.ts +0 -8
- package/tailwind.config.cjs +0 -6
- package/tsconfig.json +0 -15
- package/tsconfig.lib.json +0 -9
- package/vite.config.mts +0 -44
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
|
|
2
|
-
import { BtnBaseComponent } from '../../primitives/btn-base.component';
|
|
3
|
-
import { imgUrlByService } from '../../primitives/helpers';
|
|
4
|
-
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
5
|
-
import { injectStore } from '../../inject-store';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Botón de conexión Phantom (Solana). El click delega en
|
|
9
|
-
* `client.web3.signup('phantom')`.
|
|
10
|
-
*/
|
|
11
|
-
const styles = {
|
|
12
|
-
bgClassNames: 'bas-bg-[#9092e7] hover:bas-bg-[#7b7de2]',
|
|
13
|
-
disabledBgClassNames: 'bas-bg-[rgba(144,146,231,0.75)] hover:bas-bg-[rgba(123,125,226,0.75)]',
|
|
14
|
-
ringClassNames: 'bal-ba-hover-ring-puple-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-phantom',
|
|
23
|
-
standalone: true,
|
|
24
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
25
|
-
imports: [BtnBaseComponent],
|
|
26
|
-
template: `
|
|
27
|
-
@if (isDropdownProfile()) {
|
|
28
|
-
<button
|
|
29
|
-
id="btn-provider-phantom-dropdown"
|
|
30
|
-
class="bas-h-full bas-w-full bas-border-0 bas-bg-transparent bas-p-0"
|
|
31
|
-
(click)="onPhantomSignin()"
|
|
32
|
-
><ng-content /></button>
|
|
33
|
-
} @else {
|
|
34
|
-
<ba-btn-base
|
|
35
|
-
btnId="btn-provider-phantom"
|
|
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)="onPhantomSignin()"
|
|
50
|
-
>
|
|
51
|
-
<img slot="icon" [src]="phantomIconSrc" height="24" width="24" alt="Phantom" />
|
|
52
|
-
</ba-btn-base>
|
|
53
|
-
}
|
|
54
|
-
`,
|
|
55
|
-
})
|
|
56
|
-
export class BtnPhantomComponent {
|
|
57
|
-
isDropdownProfile = input(false);
|
|
58
|
-
text = input('Phantom');
|
|
59
|
-
isTextInsteadOfAccount = input(false);
|
|
60
|
-
iconEnabled = input(true);
|
|
61
|
-
disabled = input(false);
|
|
62
|
-
isEditable = input(false);
|
|
63
|
-
|
|
64
|
-
clicked = output<void>();
|
|
65
|
-
|
|
66
|
-
private client = injectBlockAuthClient();
|
|
67
|
-
wallet = injectStore(this.client.state.$wallet);
|
|
68
|
-
|
|
69
|
-
bg = styles.bgClassNames;
|
|
70
|
-
disabledBg = styles.disabledBgClassNames;
|
|
71
|
-
ring = styles.ringClassNames;
|
|
72
|
-
padding = styles.paddingClassNames;
|
|
73
|
-
textCls = styles.textClassNames;
|
|
74
|
-
loaderWidth = styles.loaderWidth;
|
|
75
|
-
loaderColor = styles.loaderColor;
|
|
76
|
-
phantomIconSrc = imgUrlByService('phantom-white');
|
|
77
|
-
|
|
78
|
-
btnText = computed(() => {
|
|
79
|
-
const short = (a: string | null) => (a ? `${a.slice(0, 6)}…${a.slice(-4)}` : '');
|
|
80
|
-
return this.isTextInsteadOfAccount() ? this.text() : short(this.wallet().address) || this.text();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
async onPhantomSignin(): Promise<void> {
|
|
84
|
-
if (this.isEditable()) return;
|
|
85
|
-
if (this.wallet().isConnecting) return;
|
|
86
|
-
try {
|
|
87
|
-
await this.client.web3.signup('phantom');
|
|
88
|
-
} catch {
|
|
89
|
-
/* conexión/firma cancelada o fallida */
|
|
90
|
-
}
|
|
91
|
-
this.clicked.emit();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { Component } from '@angular/core';
|
|
3
|
-
import { render, screen, fireEvent } from '@testing-library/angular';
|
|
4
|
-
import { map } from 'nanostores';
|
|
5
|
-
import { BtnSigninComponent } from './btn-signin.component';
|
|
6
|
-
import { provideBlockAuthClientForTest } from '../../testing';
|
|
7
|
-
|
|
8
|
-
function makeClient(ui: Record<string, unknown> = {}) {
|
|
9
|
-
const requestSignin = vi.fn();
|
|
10
|
-
const openModal = vi.fn();
|
|
11
|
-
const $ui = map({ isSigning: false, serviceName: null, uiConfig: null, ...ui });
|
|
12
|
-
const client = { requestSignin, openModal, state: { $ui } } as any;
|
|
13
|
-
return { client, requestSignin, openModal, $ui };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe('BtnSignin', () => {
|
|
17
|
-
it('renderiza con el id correcto', async () => {
|
|
18
|
-
const { client } = makeClient();
|
|
19
|
-
await render(BtnSigninComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
20
|
-
expect(screen.getByRole('button').id).toBe('btn-login-signup');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('al hacer click llama requestSignin y NO openModal si enabled es falsy', async () => {
|
|
24
|
-
const { client, requestSignin, openModal } = makeClient();
|
|
25
|
-
await render(BtnSigninComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
26
|
-
await fireEvent.click(screen.getByRole('button'));
|
|
27
|
-
expect(requestSignin).toHaveBeenCalledOnce();
|
|
28
|
-
expect(openModal).not.toHaveBeenCalled();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('abre el modal signin si uiConfig.config[serviceName].enabled es true', async () => {
|
|
32
|
-
const { client, requestSignin, openModal } = makeClient({
|
|
33
|
-
serviceName: 'blockauth',
|
|
34
|
-
uiConfig: { config: { blockauth: { enabled: true } } },
|
|
35
|
-
});
|
|
36
|
-
await render(BtnSigninComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
37
|
-
await fireEvent.click(screen.getByRole('button'));
|
|
38
|
-
expect(requestSignin).toHaveBeenCalled();
|
|
39
|
-
expect(openModal).toHaveBeenCalledWith('signin');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('no llama requestSignin ni openModal si isEditable es true', async () => {
|
|
43
|
-
const { client, requestSignin, openModal } = makeClient();
|
|
44
|
-
@Component({
|
|
45
|
-
standalone: true,
|
|
46
|
-
imports: [BtnSigninComponent],
|
|
47
|
-
template: `<ba-btn-signin [isEditable]="true" />`,
|
|
48
|
-
})
|
|
49
|
-
class HostComponent {}
|
|
50
|
-
await render(HostComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
51
|
-
await fireEvent.click(screen.getByRole('button'));
|
|
52
|
-
expect(requestSignin).not.toHaveBeenCalled();
|
|
53
|
-
expect(openModal).not.toHaveBeenCalled();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
DestroyRef,
|
|
5
|
-
computed,
|
|
6
|
-
effect,
|
|
7
|
-
inject,
|
|
8
|
-
input,
|
|
9
|
-
output,
|
|
10
|
-
signal,
|
|
11
|
-
} from '@angular/core';
|
|
12
|
-
import { BtnBaseComponent } from '../../primitives/btn-base.component';
|
|
13
|
-
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
14
|
-
import { injectStore } from '../../inject-store';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Botón "Log In" genérico que dispara el flujo de firma vía
|
|
18
|
-
* `client.requestSignin()`.
|
|
19
|
-
*
|
|
20
|
-
* En click: guarda contra reentrada mientras hay una firma en curso
|
|
21
|
-
* (`isConnecting || isSigning`), marca `isSigning` + el loader del botón, llama
|
|
22
|
-
* a `requestSignin()` (emite `user:txns:create`) y abre el modal de signin con
|
|
23
|
-
* `isSigningLoader = true` para que se abra cubierto por el spinner mientras
|
|
24
|
-
* llegan las txns pendientes (`ContentSignin` lo limpia al recibirlas).
|
|
25
|
-
*
|
|
26
|
-
* Escucha en `document` los eventos `ext:txn:response` / `ext:txn:closed`
|
|
27
|
-
* (listeners registrados en el constructor, limpiados con `DestroyRef`), y un
|
|
28
|
-
* `effect()` sobre `ui().isSigning`.
|
|
29
|
-
*/
|
|
30
|
-
@Component({
|
|
31
|
-
selector: 'ba-btn-signin',
|
|
32
|
-
standalone: true,
|
|
33
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
34
|
-
imports: [BtnBaseComponent],
|
|
35
|
-
template: `
|
|
36
|
-
<ba-btn-base
|
|
37
|
-
btnId="btn-login-signup"
|
|
38
|
-
type="button-outlined"
|
|
39
|
-
[text]="text()"
|
|
40
|
-
size="small"
|
|
41
|
-
[isIcon]="false"
|
|
42
|
-
paddingClassNames="bas-px-8"
|
|
43
|
-
[disabled]="isDisabled() || isConnecting() || ui().isSigning"
|
|
44
|
-
[applyDisabledStyles]="false"
|
|
45
|
-
[isFocusOutlinedEnabled]="false"
|
|
46
|
-
textClassNames="bas-text-white bas-font-semibold bas-leading-6 bas-text-base"
|
|
47
|
-
[bgClassNames]="bgClassNames()"
|
|
48
|
-
[isLoader]="isConnecting() || ui().isSigning"
|
|
49
|
-
(action)="onBtnSigninClicked()"
|
|
50
|
-
/>
|
|
51
|
-
`,
|
|
52
|
-
})
|
|
53
|
-
export class BtnSigninComponent {
|
|
54
|
-
text = input('Log In');
|
|
55
|
-
isDisabled = input(false);
|
|
56
|
-
isEditable = input(false);
|
|
57
|
-
|
|
58
|
-
clicked = output<void>();
|
|
59
|
-
|
|
60
|
-
private client = injectBlockAuthClient();
|
|
61
|
-
ui = injectStore(this.client.state.$ui);
|
|
62
|
-
isConnecting = signal(false);
|
|
63
|
-
|
|
64
|
-
bgClassNames = computed(() =>
|
|
65
|
-
this.isDisabled()
|
|
66
|
-
? 'bas-bg-[var(--bal-primary-500)] hover:bas-bg-[var(--bal-primary-700)]'
|
|
67
|
-
: 'bas-bg-[rgba(0,78,152,0.8)] hover:bas-bg-[rgba(0,62,121,0.8)]',
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
constructor() {
|
|
71
|
-
const destroyRef = inject(DestroyRef);
|
|
72
|
-
const handleTxnResponse = () => this.isConnecting.set(false);
|
|
73
|
-
const handleTxnClosed = () => {
|
|
74
|
-
this.client.state.$ui.setKey('isSigning', false);
|
|
75
|
-
this.isConnecting.set(false);
|
|
76
|
-
};
|
|
77
|
-
document.addEventListener('ext:txn:response', handleTxnResponse);
|
|
78
|
-
document.addEventListener('ext:txn:closed', handleTxnClosed);
|
|
79
|
-
destroyRef.onDestroy(() => {
|
|
80
|
-
document.removeEventListener('ext:txn:response', handleTxnResponse);
|
|
81
|
-
document.removeEventListener('ext:txn:closed', handleTxnClosed);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
effect(() => {
|
|
85
|
-
if (!this.ui().isSigning) this.isConnecting.set(false);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
onBtnSigninClicked(): void {
|
|
90
|
-
if (this.isEditable()) return;
|
|
91
|
-
if (this.isConnecting() || this.ui().isSigning) return;
|
|
92
|
-
|
|
93
|
-
this.isConnecting.set(true);
|
|
94
|
-
this.client.state.$ui.setKey('isSigning', true);
|
|
95
|
-
|
|
96
|
-
this.client.requestSignin();
|
|
97
|
-
|
|
98
|
-
const uiState = this.client.state.$ui.get();
|
|
99
|
-
const serviceName = uiState.serviceName ?? 'blockauth';
|
|
100
|
-
const enabled = (uiState.uiConfig as { config?: Record<string, { enabled?: boolean }> } | null)
|
|
101
|
-
?.config?.[serviceName]?.enabled;
|
|
102
|
-
if (enabled) {
|
|
103
|
-
this.client.openModal('signin');
|
|
104
|
-
this.client.state.$ui.setKey('isSigningLoader', true);
|
|
105
|
-
}
|
|
106
|
-
this.clicked.emit();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -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 { BtnWalletConnectComponent } from './btn-wallet-connect.component';
|
|
5
|
-
import { provideBlockAuthClientForTest } from '../../testing';
|
|
6
|
-
|
|
7
|
-
describe('BtnWalletConnect', () => {
|
|
8
|
-
it('al hacer click delega en client.wallet.evm.connectWalletConnect()', async () => {
|
|
9
|
-
const connectSpy = vi.fn(async () => undefined);
|
|
10
|
-
const fakeClient = {
|
|
11
|
-
wallet: { evm: { connectWalletConnect: connectSpy } },
|
|
12
|
-
state: { $wallet: map({ address: null, isConnecting: false }) },
|
|
13
|
-
} as any;
|
|
14
|
-
await render(BtnWalletConnectComponent, {
|
|
15
|
-
providers: [provideBlockAuthClientForTest(fakeClient)],
|
|
16
|
-
});
|
|
17
|
-
await fireEvent.click(screen.getByRole('button'));
|
|
18
|
-
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
|
|
2
|
-
import { BtnBaseComponent } from '../../primitives/btn-base.component';
|
|
3
|
-
import { providersStyles } from '../../primitives/providersStyles';
|
|
4
|
-
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
5
|
-
import { injectStore } from '../../inject-store';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Botón WalletConnect. El click delega en
|
|
9
|
-
* `client.wallet.evm.connectWalletConnect()`. Los colores/iconos de marca por
|
|
10
|
-
* wallet salen del primitivo `providersStyles` indexado por `walletService`.
|
|
11
|
-
*/
|
|
12
|
-
const bgByWallet: Record<string, string> = {
|
|
13
|
-
trustwallet: 'bas-bg-[#140dda] hover:bas-bg-[#140dda]',
|
|
14
|
-
binance: 'bas-bg-[#464646] hover:bas-bg-[#191919]',
|
|
15
|
-
uniswap: 'bas-bg-[#f64399] hover:bas-bg-[#d76fa1]',
|
|
16
|
-
};
|
|
17
|
-
const styles = {
|
|
18
|
-
disabledBgClassNames: 'bas-bg-[rgba(235,89,0,0.75)] hover:bas-bg-[rgba(216,81,0,0.75)]',
|
|
19
|
-
ringClassNames: 'bal-ba-hover-ring-gray-400',
|
|
20
|
-
paddingClassNames: 'bas-px-12',
|
|
21
|
-
textClassNames: 'bas-text-white bas-font-semibold bas-leading-6 bas-text-base',
|
|
22
|
-
loaderWidth: 70,
|
|
23
|
-
loaderColor: '#fefefe',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
@Component({
|
|
27
|
-
selector: 'ba-btn-wallet-connect',
|
|
28
|
-
standalone: true,
|
|
29
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
30
|
-
imports: [BtnBaseComponent],
|
|
31
|
-
template: `
|
|
32
|
-
@if (isDropdownProfile()) {
|
|
33
|
-
<button
|
|
34
|
-
[id]="'btn-provider-' + walletServiceFormatted() + '-dropdown'"
|
|
35
|
-
class="bas-h-full bas-w-full bas-border-0 bas-bg-transparent bas-p-0"
|
|
36
|
-
(click)="onWalletSigning()"
|
|
37
|
-
><ng-content /></button>
|
|
38
|
-
} @else {
|
|
39
|
-
<ba-btn-base
|
|
40
|
-
[btnId]="'btn-provider-' + walletServiceFormatted()"
|
|
41
|
-
[text]="btnText()"
|
|
42
|
-
type="button-outlined"
|
|
43
|
-
size="small"
|
|
44
|
-
[bgClassNames]="wallet().isConnecting ? disabledBg : bgClassNames()"
|
|
45
|
-
[ringClassNames]="ring"
|
|
46
|
-
[paddingClassNames]="padding"
|
|
47
|
-
[textClassNames]="textCls"
|
|
48
|
-
[isLoader]="wallet().isConnecting"
|
|
49
|
-
[loaderWidth]="loaderWidth"
|
|
50
|
-
[loaderColor]="loaderColor"
|
|
51
|
-
[isIcon]="iconEnabled()"
|
|
52
|
-
[isFocusOutlinedEnabled]="false"
|
|
53
|
-
[disabled]="disabled()"
|
|
54
|
-
(action)="onWalletSigning()"
|
|
55
|
-
>
|
|
56
|
-
<img
|
|
57
|
-
slot="icon"
|
|
58
|
-
[src]="style()?.imgSrc ?? ''"
|
|
59
|
-
height="24"
|
|
60
|
-
width="24"
|
|
61
|
-
class="bas-rounded-lg"
|
|
62
|
-
[alt]="style()?.name ?? walletService()"
|
|
63
|
-
/>
|
|
64
|
-
</ba-btn-base>
|
|
65
|
-
}
|
|
66
|
-
`,
|
|
67
|
-
})
|
|
68
|
-
export class BtnWalletConnectComponent {
|
|
69
|
-
isDropdownProfile = input(false);
|
|
70
|
-
text = input('Connect Wallet');
|
|
71
|
-
isTextInsteadOfAccount = input(false);
|
|
72
|
-
iconEnabled = input(true);
|
|
73
|
-
disabled = input(false);
|
|
74
|
-
isEditable = input(false);
|
|
75
|
-
walletService = input('Trust Wallet');
|
|
76
|
-
|
|
77
|
-
clicked = output<void>();
|
|
78
|
-
|
|
79
|
-
private client = injectBlockAuthClient();
|
|
80
|
-
wallet = injectStore(this.client.state.$wallet);
|
|
81
|
-
|
|
82
|
-
ring = styles.ringClassNames;
|
|
83
|
-
padding = styles.paddingClassNames;
|
|
84
|
-
textCls = styles.textClassNames;
|
|
85
|
-
disabledBg = styles.disabledBgClassNames;
|
|
86
|
-
loaderWidth = styles.loaderWidth;
|
|
87
|
-
loaderColor = styles.loaderColor;
|
|
88
|
-
|
|
89
|
-
walletServiceFormatted = computed(() => this.walletService().toLowerCase().replace(' ', ''));
|
|
90
|
-
style = computed(() => providersStyles[this.walletServiceFormatted()]);
|
|
91
|
-
bgClassNames = computed(
|
|
92
|
-
() => bgByWallet[this.walletServiceFormatted()] ?? 'bas-bg-[#140dda] hover:bas-bg-[#140dda]',
|
|
93
|
-
);
|
|
94
|
-
btnText = computed(() => {
|
|
95
|
-
const short = (a: string | null) => (a ? `${a.slice(0, 6)}…${a.slice(-4)}` : '');
|
|
96
|
-
return this.isTextInsteadOfAccount() ? this.text() : short(this.wallet().address) || this.text();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
async onWalletSigning(): Promise<void> {
|
|
100
|
-
if (this.isEditable()) return;
|
|
101
|
-
if (this.wallet().isConnecting) return;
|
|
102
|
-
try {
|
|
103
|
-
await this.client.wallet.evm.connectWalletConnect();
|
|
104
|
-
} catch {
|
|
105
|
-
/* connection cancelled/failed */
|
|
106
|
-
}
|
|
107
|
-
this.clicked.emit();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Barrel de los botones de proveedor de @block-auth.io/angular (Task A7),
|
|
2
|
-
// espejo 1:1 de packages/react/src/components/btns/*.
|
|
3
|
-
export { BtnBaseProviderComponent } from './btn-base-provider.component';
|
|
4
|
-
export { BtnBlockAuthComponent } from './btn-block-auth.component';
|
|
5
|
-
export { BtnGmailComponent } from './btn-gmail.component';
|
|
6
|
-
export { BtnGoogleBaseComponent } from './btn-google-base.component';
|
|
7
|
-
export { BtnMetamaskComponent } from './btn-metamask.component';
|
|
8
|
-
export { BtnMicrosoftComponent } from './btn-microsoft.component';
|
|
9
|
-
export { BtnPhantomComponent } from './btn-phantom.component';
|
|
10
|
-
export { BtnSigninComponent } from './btn-signin.component';
|
|
11
|
-
export { BtnWalletConnectComponent } from './btn-wallet-connect.component';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/angular';
|
|
3
|
-
import { map } from 'nanostores';
|
|
4
|
-
import { ContentSigninComponent } from './content-signin.component';
|
|
5
|
-
import { provideBlockAuthClientForTest } from '../../testing';
|
|
6
|
-
|
|
7
|
-
vi.mock('@wagmi/core', () => ({
|
|
8
|
-
createConfig: vi.fn(() => ({ connectors: [] })),
|
|
9
|
-
connect: vi.fn(), disconnect: vi.fn(), getAccount: vi.fn(() => ({})),
|
|
10
|
-
signMessage: vi.fn(), watchAccount: vi.fn(() => () => undefined), http: vi.fn(),
|
|
11
|
-
}));
|
|
12
|
-
vi.mock('@wagmi/connectors', () => ({
|
|
13
|
-
injected: vi.fn(() => ({ id: 'injected' })), walletConnect: vi.fn(() => ({ id: 'walletConnect' })),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
function makeClient() {
|
|
17
|
-
return { state: { $ws: map({}), $ui: map({}) } } as any;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Port de packages/react/src/components/contents/ContentSignin.test.tsx (con
|
|
21
|
-
// el cross-check del port Vue que verifica el overview real: A10 cableó el
|
|
22
|
-
// placeholder de A9 al `<ba-txns-overview>` real).
|
|
23
|
-
describe('ContentSignin', () => {
|
|
24
|
-
it('renderiza el contenido de signin', async () => {
|
|
25
|
-
await render(ContentSigninComponent, { providers: [provideBlockAuthClientForTest(makeClient())] });
|
|
26
|
-
expect(screen.getByTestId('content-signin')).toBeDefined();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('sin spinner (estado por defecto) renderiza el overview de txns real', async () => {
|
|
30
|
-
await render(ContentSigninComponent, { providers: [provideBlockAuthClientForTest(makeClient())] });
|
|
31
|
-
expect(screen.getByTestId('txns-overview')).toBeDefined();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, computed, effect, input, signal } from '@angular/core';
|
|
2
|
-
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
3
|
-
import { injectStore } from '../../inject-store';
|
|
4
|
-
import { OvalSpinnerComponent } from '../../primitives/oval-spinner.component';
|
|
5
|
-
import { TxnsOverviewComponent } from '../txns/txns-overview.component';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Contenido de sign-in dirigido por el core (overview de transacciones).
|
|
9
|
-
* Muestra un `<ba-oval-spinner>` mientras `isAcceptingTxn || isSigningLoader`,
|
|
10
|
-
* luego el overview de transacciones. En el montaje emite `user:txns { token }`
|
|
11
|
-
* y auto-limpia el signing loader al recibir transacciones (debounce 200ms) o
|
|
12
|
-
* tras 1.5s.
|
|
13
|
-
*
|
|
14
|
-
* El `effect()` reprograma los timers cada vez que cambian `ws.requests` (o
|
|
15
|
-
* `isLoaded`), y emite `user:txns` una única vez guardado en `isLoaded`.
|
|
16
|
-
* Escribir `isLoaded.set(true)` dentro del propio effect que lee `isLoaded`
|
|
17
|
-
* dispara una segunda ejecución inmediata (limpieza+reprogramación de timers).
|
|
18
|
-
*/
|
|
19
|
-
@Component({
|
|
20
|
-
selector: 'ba-content-signin',
|
|
21
|
-
standalone: true,
|
|
22
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
23
|
-
imports: [OvalSpinnerComponent, TxnsOverviewComponent],
|
|
24
|
-
template: `
|
|
25
|
-
<div data-testid="content-signin" class="bas-flex bas-h-full bas-w-full">
|
|
26
|
-
@if (showSpinner()) {
|
|
27
|
-
<ba-oval-spinner [showLogo]="true" [animateBg]="false" />
|
|
28
|
-
} @else {
|
|
29
|
-
<ba-txns-overview [closeTxns]="closeTxns()" />
|
|
30
|
-
}
|
|
31
|
-
</div>
|
|
32
|
-
`,
|
|
33
|
-
})
|
|
34
|
-
export class ContentSigninComponent {
|
|
35
|
-
closeTxns = input<() => void>(() => {});
|
|
36
|
-
|
|
37
|
-
private readonly client = injectBlockAuthClient();
|
|
38
|
-
private readonly ws = injectStore(this.client.state.$ws);
|
|
39
|
-
private readonly ui = injectStore(this.client.state.$ui);
|
|
40
|
-
private readonly isLoaded = signal(false);
|
|
41
|
-
|
|
42
|
-
protected showSpinner = computed(() => {
|
|
43
|
-
const ui = this.ui() as Record<string, any>;
|
|
44
|
-
return !!ui.isAcceptingTxn || !!ui.isSigningLoader;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
constructor() {
|
|
48
|
-
effect((onCleanup) => {
|
|
49
|
-
const requests = (this.ws() as Record<string, any>).requests ?? [];
|
|
50
|
-
const loaded = this.isLoaded();
|
|
51
|
-
const t1 = setTimeout(() => {
|
|
52
|
-
if (requests.length > 0) this.client.state.$ui.setKey('isSigningLoader', false);
|
|
53
|
-
}, 200);
|
|
54
|
-
const t2 = setTimeout(() => {
|
|
55
|
-
this.client.state.$ui.setKey('isSigningLoader', false);
|
|
56
|
-
}, 1500);
|
|
57
|
-
if (!loaded && this.client.provider?.wsc) {
|
|
58
|
-
const s = this.client.state.$ws.get();
|
|
59
|
-
this.client.provider.wsc.emit('user:txns', { token: (s as Record<string, any>).token });
|
|
60
|
-
this.isLoaded.set(true);
|
|
61
|
-
}
|
|
62
|
-
onCleanup(() => {
|
|
63
|
-
clearTimeout(t1);
|
|
64
|
-
clearTimeout(t2);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/angular';
|
|
3
|
-
import { map } from 'nanostores';
|
|
4
|
-
|
|
5
|
-
vi.mock('@wagmi/core', () => ({
|
|
6
|
-
createConfig: vi.fn(() => ({ connectors: [] })),
|
|
7
|
-
connect: vi.fn(), disconnect: vi.fn(), getAccount: vi.fn(() => ({})),
|
|
8
|
-
signMessage: vi.fn(), watchAccount: vi.fn(() => () => undefined), http: vi.fn(),
|
|
9
|
-
}));
|
|
10
|
-
vi.mock('@wagmi/connectors', () => ({
|
|
11
|
-
injected: vi.fn(() => ({ id: 'injected' })), walletConnect: vi.fn(() => ({ id: 'walletConnect' })),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
// Espía makeQrDataUrl para evitar canvas/qrcode en jsdom y verificar el
|
|
15
|
-
// cableado selección de servicio -> QR. deepLinkFor se deja real (función pura).
|
|
16
|
-
const FAKE_QR_DATA_URL = 'data:image/png;base64,FAKEQR==';
|
|
17
|
-
vi.mock('@block-auth.io/core', async (importOriginal) => {
|
|
18
|
-
const actual = await importOriginal<typeof import('@block-auth.io/core')>();
|
|
19
|
-
return { ...actual, makeQrDataUrl: vi.fn(async () => FAKE_QR_DATA_URL) };
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
import { ContentSignupComponent } from './content-signup.component';
|
|
23
|
-
import { makeQrDataUrl } from '@block-auth.io/core';
|
|
24
|
-
import { provideBlockAuthClientForTest } from '../../testing';
|
|
25
|
-
|
|
26
|
-
// El $ui es propio del client falso (no el singleton del core), así que el
|
|
27
|
-
// uiConfig se fija directamente en el map, sin setUiConfig ni reset global.
|
|
28
|
-
function makeClient(ui: Record<string, unknown> = {}) {
|
|
29
|
-
return {
|
|
30
|
-
state: {
|
|
31
|
-
$ui: map<Record<string, unknown>>({ ...ui }),
|
|
32
|
-
$ws: map({}),
|
|
33
|
-
$wallet: map({}),
|
|
34
|
-
$openModals: map({}),
|
|
35
|
-
},
|
|
36
|
-
} as any;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
vi.clearAllMocks();
|
|
41
|
-
(makeQrDataUrl as ReturnType<typeof vi.fn>).mockResolvedValue(FAKE_QR_DATA_URL);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// Port de packages/react/src/components/contents/ContentSignup.test.tsx.
|
|
45
|
-
describe('ContentSignup', () => {
|
|
46
|
-
it('renderiza el contenido de signup', async () => {
|
|
47
|
-
await render(ContentSignupComponent, { providers: [provideBlockAuthClientForTest(makeClient())] });
|
|
48
|
-
expect(screen.getByTestId('content-signup')).toBeDefined();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('no llama a makeQrDataUrl cuando el servicio inicial no es web3', async () => {
|
|
52
|
-
// El servicio por defecto es 'blockauth' (FALLBACK_PROVIDERS[0]), no web3.
|
|
53
|
-
const client = makeClient({ uiConfig: { domain: 'app.com' } });
|
|
54
|
-
await render(ContentSignupComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
55
|
-
expect(makeQrDataUrl).not.toHaveBeenCalled();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('solo muestra los proveedores Web2 (google/microsoft/blockauth), no web3', async () => {
|
|
59
|
-
const client = makeClient({
|
|
60
|
-
uiConfig: {
|
|
61
|
-
domain: 'app.com',
|
|
62
|
-
config: {
|
|
63
|
-
blockauth: { enabled: true, orderIndex: 0 },
|
|
64
|
-
google: { enabled: true, orderIndex: 1 },
|
|
65
|
-
microsoft: { enabled: true, orderIndex: 2 },
|
|
66
|
-
metamask: { enabled: true, orderIndex: 3 },
|
|
67
|
-
phantom: { enabled: true, orderIndex: 4 },
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
await render(ContentSignupComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
72
|
-
expect(screen.getByAltText('BlockAuth')).toBeDefined();
|
|
73
|
-
expect(screen.getByAltText('Google')).toBeDefined();
|
|
74
|
-
expect(screen.getByAltText('Microsoft')).toBeDefined();
|
|
75
|
-
expect(screen.queryByAltText('MetaMask')).toBeNull();
|
|
76
|
-
expect(screen.queryByAltText('Phantom')).toBeNull();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('con blockauth conectada pero sin did muestra el botón del proveedor, no el perfil', async () => {
|
|
80
|
-
// La sesión de la extensión espera su OTP: todavía no ha llegado el did.
|
|
81
|
-
const client = makeClient({ isServiceConnected: true, serviceName: 'blockauth' });
|
|
82
|
-
await render(ContentSignupComponent, { providers: [provideBlockAuthClientForTest(client)] });
|
|
83
|
-
expect(document.getElementById('btn-provider-blockauth')).not.toBeNull();
|
|
84
|
-
expect(screen.queryByTestId('dropdown-profile')).toBeNull();
|
|
85
|
-
});
|
|
86
|
-
});
|