@block-auth.io/angular 0.3.1 → 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.
@@ -1,19 +1,19 @@
1
-
2
- > @block-auth.io/angular@0.3.0 pretypecheck /home/wenqi/Documents/blockauthio/blockauth-sdk/packages/angular
3
- > pnpm build:css
4
-
5
-
6
- > @block-auth.io/angular@0.3.0 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 3222ms.
16
-
17
- > @block-auth.io/angular@0.3.0 typecheck /home/wenqi/Documents/blockauthio/blockauth-sdk/packages/angular
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,23 @@
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
+
3
21
  ## 0.3.1
4
22
 
5
23
  ### Patch Changes
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@block-auth.io/angular",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "dependencies": {
5
5
  "nanostores": "^0.10.0",
6
6
  "tslib": "^2.6.0",
7
- "@block-auth.io/core": "0.11.0",
7
+ "@block-auth.io/core": "0.11.1",
8
8
  "@block-auth.io/ui-styles": "0.5.0"
9
9
  },
10
10
  "peerDependencies": {
@@ -13,7 +13,12 @@ import { provideBlockAuthClientForTest } from '../../testing';
13
13
 
14
14
  function makeClient() {
15
15
  const connectBlockAuth = vi.fn();
16
- const $ui = map({ isSdkSignedIn: false, uiConfig: null });
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 → despacha el evento DOM `ext:open`,
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
- if (!ext.isUser || !ext.isUserActive || ext.isLocked) {
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
- protected isServiceConnected = computed(() => !!(this.ui() as Record<string, any>)?.isServiceConnected);
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
  );