@block-auth.io/angular 0.2.10 → 0.3.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.
- package/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +94 -0
- package/.turbo/turbo-typecheck.log +19 -0
- package/CHANGELOG.md +140 -0
- package/package.json +3 -3
- package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +9 -0
- package/src/lib/components/txns/internals/permissions-required-modal.component.ts +3 -3
- package/src/lib/components/txns/internals/phone-input.component.test.ts +119 -0
- package/src/lib/components/txns/internals/phone-input.component.ts +301 -0
- package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +561 -4
- package/src/lib/components/txns/internals/solicited-data-modal.component.ts +324 -129
- package/src/lib/components/txns/internals/txn-type.component.ts +2 -2
- package/src/lib/components/txns/internals/txn.component.test.ts +345 -0
- package/src/lib/components/txns/internals/txn.component.ts +157 -74
- package/src/lib/components/txns/txns-overview.component.test.ts +286 -2
- package/src/lib/components/txns/txns-overview.component.ts +178 -34
- package/src/lib/primitives/arrow-icon.component.test.ts +13 -0
- package/src/lib/primitives/arrow-icon.component.ts +8 -1
- package/src/public-api.ts +1 -0
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
effect,
|
|
6
6
|
input,
|
|
7
7
|
signal,
|
|
8
|
+
untracked,
|
|
8
9
|
} from '@angular/core';
|
|
9
10
|
import {
|
|
10
11
|
$extension,
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
openExtensionOnTxn,
|
|
13
14
|
t as translate,
|
|
14
15
|
type TextKey,
|
|
16
|
+
type TxnDataRequest,
|
|
15
17
|
} from '@block-auth.io/core';
|
|
16
18
|
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
17
19
|
import { injectStore } from '../../inject-store';
|
|
@@ -22,7 +24,22 @@ import { PermissionsRequiredModalComponent } from './internals/permissions-requi
|
|
|
22
24
|
import {
|
|
23
25
|
SolicitedDataModalComponent,
|
|
24
26
|
type ParamChange,
|
|
27
|
+
type ShareChange,
|
|
25
28
|
} from './internals/solicited-data-modal.component';
|
|
29
|
+
import { CiClock2Component, FaArrowRightComponent } from '../../icons';
|
|
30
|
+
import {
|
|
31
|
+
EMPTY_SOLICITED_DATA_FORM,
|
|
32
|
+
getSolicitedAcceptParams,
|
|
33
|
+
getSolicitedFields,
|
|
34
|
+
getSolicitedParams,
|
|
35
|
+
isSolicitedDataComplete,
|
|
36
|
+
saveSolicitedValue,
|
|
37
|
+
setSolicitedShared,
|
|
38
|
+
setSolicitedValue,
|
|
39
|
+
undoSolicitedValue,
|
|
40
|
+
type SolicitedDataForm,
|
|
41
|
+
type SolicitedParam,
|
|
42
|
+
} from '@block-auth.io/core';
|
|
26
43
|
|
|
27
44
|
// Orquestador de txns: lee las solicitudes pendientes de `$ws.requests` y la
|
|
28
45
|
// config de UI de `$ui.uiConfig` (vía injectStore). Se conserva la navegación
|
|
@@ -63,13 +80,15 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
63
80
|
TxnErrorComponent,
|
|
64
81
|
PermissionsRequiredModalComponent,
|
|
65
82
|
SolicitedDataModalComponent,
|
|
83
|
+
CiClock2Component,
|
|
84
|
+
FaArrowRightComponent,
|
|
66
85
|
],
|
|
67
86
|
template: `
|
|
68
87
|
<div
|
|
69
88
|
data-testid="txns-overview"
|
|
70
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"
|
|
71
90
|
>
|
|
72
|
-
@if (isEmpty() && isSigning()) {
|
|
91
|
+
@if (isEmpty() && isSigning() && !isOtpRequired()) {
|
|
73
92
|
<ba-txn-error
|
|
74
93
|
[errorMessageTxt]="t('noTransactionsFound')"
|
|
75
94
|
errorMessageSlug="no_transactions_found"
|
|
@@ -83,14 +102,18 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
83
102
|
[closeTxns]="closeTxns()"
|
|
84
103
|
[isCountdown]="false"
|
|
85
104
|
/>
|
|
86
|
-
} @else if (!isEmpty()) {
|
|
87
|
-
|
|
105
|
+
} @else if (!isEmpty() || isOtpRequired()) {
|
|
106
|
+
<!-- No txn yet when the session expired before it was created. -->
|
|
107
|
+
@if (!isEmpty()) {
|
|
108
|
+
<div
|
|
109
|
+
class="bal-ba-glass-rise bas-flex bas-flex-col bas-items-center bas-gap-3"
|
|
110
|
+
>
|
|
88
111
|
<img
|
|
89
112
|
[src]="
|
|
90
113
|
preParams().iconUrl ||
|
|
91
114
|
'https://dashboard.block-auth.io/img/blockauth_logo.png'
|
|
92
115
|
"
|
|
93
|
-
class="bas-h-16"
|
|
116
|
+
class="bal-ba-glass-logo bas-h-16"
|
|
94
117
|
alt="app logo"
|
|
95
118
|
/>
|
|
96
119
|
<h2 class="bas-m-0 bas-text-base bas-text-[var(--bal-primary-600)]">
|
|
@@ -110,26 +133,35 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
110
133
|
(prevTxnClicked)="onPrevTxnClicked()"
|
|
111
134
|
(nextTxnClicked)="onNextTxnClicked()"
|
|
112
135
|
/>
|
|
136
|
+
}
|
|
113
137
|
<!-- The server refuses this page's accept while the OTP window is
|
|
114
138
|
over: the code is entered in the extension, which approves. -->
|
|
115
139
|
@if (isOtpRequired()) {
|
|
116
140
|
<div
|
|
117
|
-
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"
|
|
118
142
|
>
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
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>
|
|
122
156
|
@if (ext().installed) {
|
|
123
157
|
<button
|
|
124
158
|
type="button"
|
|
125
159
|
id="btn-txn-open-extension"
|
|
126
160
|
(click)="openExtensionOnTxn()"
|
|
127
|
-
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)]"
|
|
128
162
|
>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
>{{ t('openExtension') }}</span
|
|
132
|
-
>
|
|
163
|
+
{{ t('openExtension') }}
|
|
164
|
+
<ba-fa-arrow-right class="bas-h-4 bas-w-4" />
|
|
133
165
|
</button>
|
|
134
166
|
}
|
|
135
167
|
</div>
|
|
@@ -138,9 +170,12 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
138
170
|
<ba-txn
|
|
139
171
|
[hasSolicitedData]="hasSolicitedData()"
|
|
140
172
|
[allRequiredFilled]="allRequiredFilled()"
|
|
173
|
+
[solicitedDataPending]="solicitedDataPending()"
|
|
141
174
|
[closeTxns]="closeTxns()"
|
|
142
175
|
[selectedTxnPreParams]="preParams()"
|
|
143
|
-
[userParamValues]="
|
|
176
|
+
[userParamValues]="acceptParams().userParams"
|
|
177
|
+
[grantedParams]="acceptParams().grantedParams"
|
|
178
|
+
[revokedParams]="acceptParams().revokedParams"
|
|
144
179
|
[addError]="addError"
|
|
145
180
|
(permissionsRequiredClicked)="showPermissions.set(true)"
|
|
146
181
|
(solicitedDataClicked)="showSolicitedData.set(true)"
|
|
@@ -148,7 +183,7 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
148
183
|
</div>
|
|
149
184
|
} } @if (showPermissions()) {
|
|
150
185
|
<div
|
|
151
|
-
class="bal-ba-
|
|
186
|
+
class="bal-ba-glass-backdrop bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-z-30 bas-box-border bas-h-full bas-w-full"
|
|
152
187
|
(click)="showPermissions.set(false)"
|
|
153
188
|
></div>
|
|
154
189
|
<div class="bas-absolute bas-top-44 bas-z-40">
|
|
@@ -156,18 +191,27 @@ const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
|
156
191
|
</div>
|
|
157
192
|
} @if (showSolicitedData()) {
|
|
158
193
|
<div
|
|
159
|
-
class="bal-ba-
|
|
194
|
+
class="bal-ba-glass-backdrop bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-z-30 bas-box-border bas-h-full bas-w-full"
|
|
160
195
|
(click)="showSolicitedData.set(false)"
|
|
161
196
|
></div>
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
197
|
+
<ba-solicited-data-modal
|
|
198
|
+
class="bal-ba-glass-modal-slot bas-absolute bas-inset-y-6 bas-z-40"
|
|
199
|
+
[requiredParams]="requiredParams()"
|
|
200
|
+
[optionalParams]="optionalParams()"
|
|
201
|
+
[params]="txnData()?.params"
|
|
202
|
+
[userParamValues]="solicitedForm().values"
|
|
203
|
+
[sharedParams]="solicitedForm().shared"
|
|
204
|
+
[savedParams]="solicitedForm().saved"
|
|
205
|
+
[errorTxt]="acceptTxnError() ? t('requiredDataError') : undefined"
|
|
206
|
+
[closable]="true"
|
|
207
|
+
[acceptable]="true"
|
|
208
|
+
(paramChange)="handleParamChange($event)"
|
|
209
|
+
(shareChange)="handleShareChange($event)"
|
|
210
|
+
(saveParam)="handleSaveParam($event)"
|
|
211
|
+
(undoParam)="handleUndoParam($event)"
|
|
212
|
+
(closed)="showSolicitedData.set(false)"
|
|
213
|
+
(accepted)="showSolicitedData.set(false)"
|
|
214
|
+
/>
|
|
171
215
|
}
|
|
172
216
|
</div>
|
|
173
217
|
`,
|
|
@@ -187,8 +231,12 @@ export class TxnsOverviewComponent {
|
|
|
187
231
|
protected readonly selectedIndex = signal(0);
|
|
188
232
|
protected readonly showPermissions = signal(false);
|
|
189
233
|
protected readonly showSolicitedData = signal(false);
|
|
190
|
-
protected readonly
|
|
191
|
-
|
|
234
|
+
protected readonly solicitedForm = signal<SolicitedDataForm>(
|
|
235
|
+
EMPTY_SOLICITED_DATA_FORM,
|
|
236
|
+
);
|
|
237
|
+
protected readonly txnData = signal<TxnDataRequest | null>(null);
|
|
238
|
+
private readonly isLoadingTxnData = signal(false);
|
|
239
|
+
private readonly txnDataReload = signal(0);
|
|
192
240
|
protected readonly error = signal<{ value: boolean; messageSlug: string }>({
|
|
193
241
|
value: false,
|
|
194
242
|
messageSlug: '',
|
|
@@ -198,6 +246,7 @@ export class TxnsOverviewComponent {
|
|
|
198
246
|
protected readonly did = computed(() => this.ws().did);
|
|
199
247
|
protected readonly isSigning = computed(() => this.ui().isSigning);
|
|
200
248
|
protected readonly isOtpRequired = computed(() => this.ui().isOtpRequired);
|
|
249
|
+
protected readonly acceptTxnError = computed(() => this.ui().acceptTxnError);
|
|
201
250
|
protected readonly openExtensionOnTxn = openExtensionOnTxn;
|
|
202
251
|
protected readonly isEmpty = computed(() => this.txns().length === 0);
|
|
203
252
|
protected readonly errorText = computed(() =>
|
|
@@ -244,16 +293,86 @@ export class TxnsOverviewComponent {
|
|
|
244
293
|
protected readonly optionalParams = computed(
|
|
245
294
|
() => this.requiredOptionalParams().optionalParams,
|
|
246
295
|
);
|
|
247
|
-
|
|
248
|
-
() => this.
|
|
296
|
+
private readonly selectedTxnId = computed(
|
|
297
|
+
() => this.selectedTxn()?.['id'] as number | string | undefined,
|
|
298
|
+
);
|
|
299
|
+
private readonly solicitedParams = computed(() =>
|
|
300
|
+
getSolicitedParams({
|
|
301
|
+
params: this.txnData()?.params,
|
|
302
|
+
requiredParams: this.requiredParams(),
|
|
303
|
+
optionalParams: this.optionalParams(),
|
|
304
|
+
}),
|
|
305
|
+
);
|
|
306
|
+
protected readonly hasSolicitedData = computed(() =>
|
|
307
|
+
this.txnData()
|
|
308
|
+
? this.solicitedParams().length > 0
|
|
309
|
+
: this.requiredParams().length > 0 || this.optionalParams().length > 0,
|
|
310
|
+
);
|
|
311
|
+
private readonly solicitedFields = computed(() =>
|
|
312
|
+
getSolicitedFields(
|
|
313
|
+
this.solicitedParams(),
|
|
314
|
+
this.solicitedForm(),
|
|
315
|
+
!!this.txnData(),
|
|
316
|
+
),
|
|
317
|
+
);
|
|
318
|
+
private readonly isSolicitedComplete = computed(() =>
|
|
319
|
+
isSolicitedDataComplete(this.solicitedFields()),
|
|
320
|
+
);
|
|
321
|
+
protected readonly allRequiredFilled = computed(
|
|
322
|
+
() =>
|
|
323
|
+
(!this.isLoadingTxnData() || this.solicitedParams().length === 0) &&
|
|
324
|
+
this.isSolicitedComplete(),
|
|
325
|
+
);
|
|
326
|
+
protected readonly solicitedDataPending = computed(
|
|
327
|
+
() =>
|
|
328
|
+
this.hasSolicitedData() &&
|
|
329
|
+
!this.isLoadingTxnData() &&
|
|
330
|
+
!this.isSolicitedComplete(),
|
|
331
|
+
);
|
|
332
|
+
protected readonly acceptParams = computed(() =>
|
|
333
|
+
getSolicitedAcceptParams(this.solicitedFields()),
|
|
249
334
|
);
|
|
250
335
|
|
|
251
336
|
constructor() {
|
|
252
|
-
|
|
253
|
-
|
|
337
|
+
effect((onCleanup) => {
|
|
338
|
+
const txnId = this.selectedTxnId();
|
|
339
|
+
this.txnDataReload();
|
|
340
|
+
untracked(() => {
|
|
341
|
+
this.txnData.set(null);
|
|
342
|
+
if (txnId == null) {
|
|
343
|
+
this.isLoadingTxnData.set(false);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
let active = true;
|
|
347
|
+
this.isLoadingTxnData.set(true);
|
|
348
|
+
Promise.resolve()
|
|
349
|
+
.then(() => this.client.txns.dataRequest(txnId))
|
|
350
|
+
.catch(() => null)
|
|
351
|
+
.then((result) => {
|
|
352
|
+
if (!active) return;
|
|
353
|
+
this.txnData.set(result ?? null);
|
|
354
|
+
this.isLoadingTxnData.set(false);
|
|
355
|
+
});
|
|
356
|
+
onCleanup(() => {
|
|
357
|
+
active = false;
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
effect(() => {
|
|
363
|
+
if (!this.acceptTxnError()) return;
|
|
364
|
+
untracked(() => {
|
|
365
|
+
this.showSolicitedData.set(true);
|
|
366
|
+
this.txnDataReload.update((n) => n + 1);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
|
|
254
370
|
effect(() => {
|
|
255
|
-
|
|
256
|
-
|
|
371
|
+
this.selectedTxnId();
|
|
372
|
+
untracked(() => {
|
|
373
|
+
this.solicitedForm.set(EMPTY_SOLICITED_DATA_FORM);
|
|
374
|
+
this.client.state.$ui.setKey('acceptTxnError', null);
|
|
375
|
+
});
|
|
257
376
|
});
|
|
258
377
|
}
|
|
259
378
|
|
|
@@ -263,8 +382,33 @@ export class TxnsOverviewComponent {
|
|
|
263
382
|
this.client.state.$ui.setKey('isAcceptingTxn', false);
|
|
264
383
|
};
|
|
265
384
|
|
|
385
|
+
private updateParam(
|
|
386
|
+
slug: string,
|
|
387
|
+
update: (
|
|
388
|
+
form: SolicitedDataForm,
|
|
389
|
+
item: SolicitedParam,
|
|
390
|
+
) => SolicitedDataForm,
|
|
391
|
+
): void {
|
|
392
|
+
const item = this.solicitedParams().find((param) => param.slug === slug);
|
|
393
|
+
if (item) this.solicitedForm.update((prev) => update(prev, item));
|
|
394
|
+
}
|
|
395
|
+
|
|
266
396
|
handleParamChange({ slug, value }: ParamChange): void {
|
|
267
|
-
this.
|
|
397
|
+
this.updateParam(slug, (form, item) =>
|
|
398
|
+
setSolicitedValue(form, item, value),
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
handleShareChange({ slug, shared }: ShareChange): void {
|
|
403
|
+
this.solicitedForm.update((prev) => setSolicitedShared(prev, slug, shared));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
handleSaveParam(slug: string): void {
|
|
407
|
+
this.solicitedForm.update((prev) => saveSolicitedValue(prev, slug));
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
handleUndoParam(slug: string): void {
|
|
411
|
+
this.updateParam(slug, undoSolicitedValue);
|
|
268
412
|
}
|
|
269
413
|
|
|
270
414
|
onPrevTxnClicked(): void {
|
|
@@ -9,4 +9,17 @@ describe('ArrowIconComponent', () => {
|
|
|
9
9
|
const { container } = await render(Host);
|
|
10
10
|
expect(container.querySelector('.bal-ba-arrow-left')).toBeTruthy();
|
|
11
11
|
});
|
|
12
|
+
|
|
13
|
+
it('es visible por defecto y se oculta con visible=false', async () => {
|
|
14
|
+
@Component({
|
|
15
|
+
standalone: true,
|
|
16
|
+
imports: [ArrowIconComponent],
|
|
17
|
+
template: `<ba-arrow-icon direction="right" /><ba-arrow-icon direction="left" [visible]="false" />`,
|
|
18
|
+
})
|
|
19
|
+
class Host {}
|
|
20
|
+
const { container } = await render(Host);
|
|
21
|
+
const wrappers = container.querySelectorAll('[aria-hidden="true"]');
|
|
22
|
+
expect(wrappers[0].className).not.toContain('bas-invisible');
|
|
23
|
+
expect(wrappers[1].className).toContain('bas-invisible');
|
|
24
|
+
});
|
|
12
25
|
});
|
|
@@ -7,7 +7,13 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
|
|
|
7
7
|
standalone: true,
|
|
8
8
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
9
|
template: `
|
|
10
|
-
<div
|
|
10
|
+
<div
|
|
11
|
+
aria-hidden="true"
|
|
12
|
+
[class]="
|
|
13
|
+
'bal-ba-transition-3 bas-flex bas-h-[30px] bas-w-[65px] bas-items-center bas-justify-center ' +
|
|
14
|
+
(visible() ? 'bas-opacity-100' : 'bas-invisible bas-opacity-0')
|
|
15
|
+
"
|
|
16
|
+
>
|
|
11
17
|
<div
|
|
12
18
|
[class]="
|
|
13
19
|
'bal-ba-arrow bas-relative bas-flex bas-h-[65px] bas-w-[65px] bas-cursor-pointer bas-justify-center ' +
|
|
@@ -25,6 +31,7 @@ import { ChangeDetectionStrategy, Component, computed, input } from '@angular/co
|
|
|
25
31
|
})
|
|
26
32
|
export class ArrowIconComponent {
|
|
27
33
|
direction = input<'right' | 'left'>('right');
|
|
34
|
+
visible = input(true);
|
|
28
35
|
|
|
29
36
|
spanClassNames = computed(
|
|
30
37
|
() =>
|
package/src/public-api.ts
CHANGED