@block-auth.io/angular 0.3.0 → 0.3.2
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/.turbo/turbo-build.log +37 -40
- package/.turbo/turbo-lint.log +4 -4
- package/.turbo/turbo-test.log +2001 -102
- package/.turbo/turbo-typecheck.log +19 -19
- package/CHANGELOG.md +45 -0
- package/package.json +3 -3
- package/src/lib/components/btns/btn-block-auth.component.test.ts +27 -1
- package/src/lib/components/btns/btn-block-auth.component.ts +6 -2
- package/src/lib/components/contents/content-signup.component.test.ts +8 -0
- package/src/lib/components/contents/content-signup.component.ts +10 -1
- package/src/lib/components/txns/txns-overview.component.test.ts +16 -0
- package/src/lib/components/txns/txns-overview.component.ts +25 -11
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
> @block-auth.io/angular@0.3.
|
|
3
|
-
> pnpm build:css
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
> @block-auth.io/angular@0.3.
|
|
7
|
-
> tailwindcss -i ../ui-styles/src/input.css -c ./tailwind.config.cjs -o ./src/styles.generated.css --minify && node scripts/css-to-ts.mjs
|
|
8
|
-
|
|
9
|
-
Browserslist: caniuse-lite is outdated. Please run:
|
|
10
|
-
npx update-browserslist-db@latest
|
|
11
|
-
Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
|
12
|
-
|
|
13
|
-
Rebuilding...
|
|
14
|
-
|
|
15
|
-
Done in
|
|
16
|
-
|
|
17
|
-
> @block-auth.io/angular@0.3.
|
|
18
|
-
> tsc -p tsconfig.lib.json --noEmit
|
|
19
|
-
|
|
1
|
+
|
|
2
|
+
> @block-auth.io/angular@0.3.1 pretypecheck /home/wenqi/Documents/blockauthio/blockauth-sdk/packages/angular
|
|
3
|
+
> pnpm build:css
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> @block-auth.io/angular@0.3.1 build:css /home/wenqi/Documents/blockauthio/blockauth-sdk/packages/angular
|
|
7
|
+
> tailwindcss -i ../ui-styles/src/input.css -c ./tailwind.config.cjs -o ./src/styles.generated.css --minify && node scripts/css-to-ts.mjs
|
|
8
|
+
|
|
9
|
+
Browserslist: caniuse-lite is outdated. Please run:
|
|
10
|
+
npx update-browserslist-db@latest
|
|
11
|
+
Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
|
12
|
+
|
|
13
|
+
Rebuilding...
|
|
14
|
+
|
|
15
|
+
Done in 3821ms.
|
|
16
|
+
|
|
17
|
+
> @block-auth.io/angular@0.3.1 typecheck /home/wenqi/Documents/blockauthio/blockauth-sdk/packages/angular
|
|
18
|
+
> tsc -p tsconfig.lib.json --noEmit
|
|
19
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @block-auth.io/angular
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1daf2df: Con la extensión conectada pero su sesión pendiente del OTP, la tarjeta de
|
|
8
|
+
registro ya no muestra el perfil sin `did` y el botón "Log In". La página solo
|
|
9
|
+
recibe el `did` cuando la extensión le pasa su sesión, y con el token caducado
|
|
10
|
+
eso no ocurre hasta que el usuario mete el OTP en la extensión. Ahora
|
|
11
|
+
`ContentSignup` (react, vue y angular) trata esa cuenta como todavía no
|
|
12
|
+
conectada y muestra el botón de Block-Auth ("Desbloquear OTP" cuando la
|
|
13
|
+
extensión avisa de que está bloqueada), que abre la extensión. `BtnBlockAuth`
|
|
14
|
+
también abre la extensión en vez de reconectar cuando el servicio `blockauth`
|
|
15
|
+
ya está conectado sin `did`, porque reconectar no devuelve la sesión.
|
|
16
|
+
`@block-auth.io/core` exporta el helper
|
|
17
|
+
`needsExtensionUnlock(serviceName, did, isLocked)` que decide este caso.
|
|
18
|
+
- Updated dependencies [1daf2df]
|
|
19
|
+
- @block-auth.io/core@0.11.1
|
|
20
|
+
|
|
21
|
+
## 0.3.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 1b962a8: Una sesión caducada ya no deja la web atascada. Cuando el servidor responde
|
|
26
|
+
a cualquier evento con `code: 'USER_SESSION_REQUIRED'`, el runtime primero
|
|
27
|
+
pide una sola vez un ticket nuevo (`refreshAuth()` devuelve ahora
|
|
28
|
+
`'renewed' | 'refused' | 'unavailable'`): si lo obtiene, deja la página como
|
|
29
|
+
está, sin reintentar nada automáticamente; si falla de forma pasajera, no
|
|
30
|
+
cambia nada; y solo si el API lo rechaza (401) reacciona según el proveedor:
|
|
31
|
+
|
|
32
|
+
- **Extensión, durante un login:** el modal de login muestra el aviso
|
|
33
|
+
"Verificación caducada" y abre la extensión.
|
|
34
|
+
Cuando llega la sesión renovada (`blockauth:session-bridged`), retoma el
|
|
35
|
+
login (`requestSignin`).
|
|
36
|
+
- **Extensión, fuera de un login:** quita solo el estado de firma y conserva
|
|
37
|
+
"conectado". La app lleva a su login, y desde ahí "Log In" lleva al aviso.
|
|
38
|
+
- **Otros proveedores:** `applyLocalLogout()`. Durante un login se abre
|
|
39
|
+
`signup` para volver a entrar con el mismo proveedor.
|
|
40
|
+
|
|
41
|
+
Una marca en sessionStorage evita que la página de login entre en bucle
|
|
42
|
+
comprobando la sesión. `TxnsOverview` (react, vue y angular) muestra el aviso
|
|
43
|
+
del OTP también cuando la transacción no llegó a crearse.
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [1b962a8]
|
|
46
|
+
- @block-auth.io/core@0.11.0
|
|
47
|
+
|
|
3
48
|
## 0.3.0
|
|
4
49
|
|
|
5
50
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@block-auth.io/angular",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"nanostores": "^0.10.0",
|
|
6
6
|
"tslib": "^2.6.0",
|
|
7
|
-
"@block-auth.io/
|
|
8
|
-
"@block-auth.io/
|
|
7
|
+
"@block-auth.io/core": "0.11.1",
|
|
8
|
+
"@block-auth.io/ui-styles": "0.5.0"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@angular/core": ">=20.0.0",
|
|
@@ -13,7 +13,12 @@ import { provideBlockAuthClientForTest } from '../../testing';
|
|
|
13
13
|
|
|
14
14
|
function makeClient() {
|
|
15
15
|
const connectBlockAuth = vi.fn();
|
|
16
|
-
const $ui = map({
|
|
16
|
+
const $ui = map({
|
|
17
|
+
isSdkSignedIn: false,
|
|
18
|
+
uiConfig: null,
|
|
19
|
+
isServiceConnected: false,
|
|
20
|
+
serviceName: null as string | null,
|
|
21
|
+
});
|
|
17
22
|
const $ws = map({ ready: false });
|
|
18
23
|
const client = { connectBlockAuth, state: { $ui, $ws } } as any;
|
|
19
24
|
return { client, connectBlockAuth, $ui, $ws };
|
|
@@ -76,4 +81,25 @@ describe('BtnBlockAuth', () => {
|
|
|
76
81
|
await fireEvent.click(screen.getByRole('button'));
|
|
77
82
|
expect(connectBlockAuth).toHaveBeenCalledOnce();
|
|
78
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
|
+
});
|
|
79
105
|
});
|
|
@@ -14,7 +14,8 @@ import { injectStore } from '../../inject-store';
|
|
|
14
14
|
* que no está envuelto por `BlockAuthService`, se lee aquí con `injectStore`).
|
|
15
15
|
* Según el estado (installed/isUser/isUserActive/isLocked):
|
|
16
16
|
* - no instalada → abre la Chrome Web Store,
|
|
17
|
-
* - no user / no activo / bloqueada
|
|
17
|
+
* - no user / no activo / bloqueada, o conectada sin sesión (OTP pendiente
|
|
18
|
+
* en la extensión) → despacha el evento DOM `ext:open`,
|
|
18
19
|
* - conectable → `client.connectBlockAuth()`.
|
|
19
20
|
* El label sale del mapa localizado `uiConfig.config.content.btns`.
|
|
20
21
|
*/
|
|
@@ -102,7 +103,10 @@ export class BtnBlockAuthComponent {
|
|
|
102
103
|
window.open(getExtensionStoreUrl(), '_blank');
|
|
103
104
|
return;
|
|
104
105
|
}
|
|
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) {
|
|
106
110
|
if (typeof document !== 'undefined') {
|
|
107
111
|
document.dispatchEvent(new CustomEvent('ext:open', { detail: {} }));
|
|
108
112
|
}
|
|
@@ -75,4 +75,12 @@ describe('ContentSignup', () => {
|
|
|
75
75
|
expect(screen.queryByAltText('MetaMask')).toBeNull();
|
|
76
76
|
expect(screen.queryByAltText('Phantom')).toBeNull();
|
|
77
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
|
+
});
|
|
78
86
|
});
|
|
@@ -8,9 +8,11 @@ import {
|
|
|
8
8
|
untracked,
|
|
9
9
|
} from '@angular/core';
|
|
10
10
|
import {
|
|
11
|
+
$extension,
|
|
11
12
|
$locale,
|
|
12
13
|
deepLinkFor,
|
|
13
14
|
makeQrDataUrl,
|
|
15
|
+
needsExtensionUnlock,
|
|
14
16
|
t as translate,
|
|
15
17
|
type TextKey,
|
|
16
18
|
} from '@block-auth.io/core';
|
|
@@ -117,6 +119,8 @@ export class ContentSignupComponent {
|
|
|
117
119
|
|
|
118
120
|
private readonly client = injectBlockAuthClient();
|
|
119
121
|
private readonly ui = injectStore(this.client.state.$ui);
|
|
122
|
+
private readonly ws = injectStore(this.client.state.$ws);
|
|
123
|
+
private readonly ext = injectStore($extension);
|
|
120
124
|
private readonly locale = injectStore($locale);
|
|
121
125
|
private readonly t = (key: TextKey): string => translate(key, this.locale());
|
|
122
126
|
|
|
@@ -130,7 +134,12 @@ export class ContentSignupComponent {
|
|
|
130
134
|
protected footerHref = computed(() => this.content()?.footer?.url ?? 'https://block-auth.io');
|
|
131
135
|
|
|
132
136
|
protected serviceName = computed(() => (this.ui() as Record<string, any>)?.serviceName);
|
|
133
|
-
|
|
137
|
+
// An extension account still waiting for its OTP is not connected yet.
|
|
138
|
+
protected isServiceConnected = computed(
|
|
139
|
+
() =>
|
|
140
|
+
!!(this.ui() as Record<string, any>)?.isServiceConnected &&
|
|
141
|
+
!needsExtensionUnlock(this.serviceName(), this.ws().did, this.ext().isLocked),
|
|
142
|
+
);
|
|
134
143
|
private readonly domain = computed(
|
|
135
144
|
() => (this.ui() as Record<string, any>)?.uiConfig?.domain as string | undefined,
|
|
136
145
|
);
|
|
@@ -401,5 +401,21 @@ describe('TxnsOverview', () => {
|
|
|
401
401
|
expect(screen.getByText(/Enter your code in the Block-Auth app/)).toBeDefined();
|
|
402
402
|
expect(screen.queryByText('Open extension')).toBeNull();
|
|
403
403
|
});
|
|
404
|
+
|
|
405
|
+
// A login whose session expired never gets its txn created: the same
|
|
406
|
+
// notice must show on its own, not "No transactions found".
|
|
407
|
+
it('sin transacción muestra el mismo aviso en lugar de "No transactions found"', async () => {
|
|
408
|
+
setExtensionInstalled(true);
|
|
409
|
+
await render(TxnsOverviewComponent, {
|
|
410
|
+
providers: [
|
|
411
|
+
provideBlockAuthClientForTest(
|
|
412
|
+
makeClient({ requests: [] }, { isOtpRequired: true, isSigning: true }),
|
|
413
|
+
),
|
|
414
|
+
],
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
expect(screen.getByText(/Enter your code in the Block-Auth extension/)).toBeDefined();
|
|
418
|
+
expect(screen.queryByText('No transactions found')).toBeNull();
|
|
419
|
+
});
|
|
404
420
|
});
|
|
405
421
|
});
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
type ParamChange,
|
|
27
27
|
type ShareChange,
|
|
28
28
|
} from './internals/solicited-data-modal.component';
|
|
29
|
+
import { CiClock2Component, FaArrowRightComponent } from '../../icons';
|
|
29
30
|
import {
|
|
30
31
|
EMPTY_SOLICITED_DATA_FORM,
|
|
31
32
|
getSolicitedAcceptParams,
|
|
@@ -79,13 +80,15 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
79
80
|
TxnErrorComponent,
|
|
80
81
|
PermissionsRequiredModalComponent,
|
|
81
82
|
SolicitedDataModalComponent,
|
|
83
|
+
CiClock2Component,
|
|
84
|
+
FaArrowRightComponent,
|
|
82
85
|
],
|
|
83
86
|
template: `
|
|
84
87
|
<div
|
|
85
88
|
data-testid="txns-overview"
|
|
86
89
|
class="bas-flex bas-box-border bas-relative bas-h-full bas-w-full bas-gap-6 bas-flex-col bas-items-center bas-p-6 bas-font-medium bas-justify-center"
|
|
87
90
|
>
|
|
88
|
-
@if (isEmpty() && isSigning()) {
|
|
91
|
+
@if (isEmpty() && isSigning() && !isOtpRequired()) {
|
|
89
92
|
<ba-txn-error
|
|
90
93
|
[errorMessageTxt]="t('noTransactionsFound')"
|
|
91
94
|
errorMessageSlug="no_transactions_found"
|
|
@@ -99,7 +102,9 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
99
102
|
[closeTxns]="closeTxns()"
|
|
100
103
|
[isCountdown]="false"
|
|
101
104
|
/>
|
|
102
|
-
} @else if (!isEmpty()) {
|
|
105
|
+
} @else if (!isEmpty() || isOtpRequired()) {
|
|
106
|
+
<!-- No txn yet when the session expired before it was created. -->
|
|
107
|
+
@if (!isEmpty()) {
|
|
103
108
|
<div
|
|
104
109
|
class="bal-ba-glass-rise bas-flex bas-flex-col bas-items-center bas-gap-3"
|
|
105
110
|
>
|
|
@@ -128,26 +133,35 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
128
133
|
(prevTxnClicked)="onPrevTxnClicked()"
|
|
129
134
|
(nextTxnClicked)="onNextTxnClicked()"
|
|
130
135
|
/>
|
|
136
|
+
}
|
|
131
137
|
<!-- The server refuses this page's accept while the OTP window is
|
|
132
138
|
over: the code is entered in the extension, which approves. -->
|
|
133
139
|
@if (isOtpRequired()) {
|
|
134
140
|
<div
|
|
135
|
-
class="bas-flex bas-w-full bas-max-w-[
|
|
141
|
+
class="bas-flex bas-w-full bas-max-w-[300px] bas-flex-col bas-items-center bas-gap-6 bas-text-center"
|
|
136
142
|
>
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
<span
|
|
144
|
+
class="bas-flex bas-h-16 bas-w-16 bas-items-center bas-justify-center bas-rounded-full bas-border bas-border-solid bas-border-[var(--bal-primary-50)] bas-bg-[var(--bal-primary-10)]"
|
|
145
|
+
>
|
|
146
|
+
<ba-ci-clock2 class="bas-h-8 bas-w-8 bas-text-[var(--bal-primary-600)]" />
|
|
147
|
+
</span>
|
|
148
|
+
<div class="bas-flex bas-flex-col bas-gap-2">
|
|
149
|
+
<h3 class="bas-m-0 bas-text-lg bas-font-semibold bas-text-[var(--bal-primary-900)]">
|
|
150
|
+
{{ t('otpExpiredTitle') }}
|
|
151
|
+
</h3>
|
|
152
|
+
<p class="bas-m-0 bas-text-sm bas-leading-relaxed bas-text-[#475569]">
|
|
153
|
+
{{ t(ext().installed ? 'otpExpiredExtension' : 'otpExpiredApp') }}
|
|
154
|
+
</p>
|
|
155
|
+
</div>
|
|
140
156
|
@if (ext().installed) {
|
|
141
157
|
<button
|
|
142
158
|
type="button"
|
|
143
159
|
id="btn-txn-open-extension"
|
|
144
160
|
(click)="openExtensionOnTxn()"
|
|
145
|
-
class="
|
|
161
|
+
class="bas-flex bas-h-11 bas-w-full bas-cursor-pointer bas-items-center bas-justify-center bas-gap-2 bas-rounded-xl bas-border-none bas-bg-[var(--bal-primary-600)] bas-px-4 bas-text-base bas-font-semibold bas-text-white bas-transition-colors bas-duration-200 hover:bas-bg-[var(--bal-primary-800)] focus-visible:bas-outline focus-visible:bas-outline-2 focus-visible:bas-outline-offset-2 focus-visible:bas-outline-[var(--bal-primary-500)]"
|
|
146
162
|
>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
>{{ t('openExtension') }}</span
|
|
150
|
-
>
|
|
163
|
+
{{ t('openExtension') }}
|
|
164
|
+
<ba-fa-arrow-right class="bas-h-4 bas-w-4" />
|
|
151
165
|
</button>
|
|
152
166
|
}
|
|
153
167
|
</div>
|