@block-auth.io/angular 0.1.0 → 0.1.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 +7 -7
- package/.turbo/turbo-lint.log +4 -4
- package/.turbo/turbo-test.log +1037 -82
- package/.turbo/turbo-typecheck.log +19 -4
- package/CHANGELOG.md +7 -0
- package/LICENSE +15 -0
- package/package.json +15 -15
- package/src/lib/components/txns/internals/permissions-required-modal.component.test.ts +16 -3
- package/src/lib/components/txns/internals/permissions-required-modal.component.ts +24 -16
- package/src/lib/components/txns/internals/solicited-data-modal.component.test.ts +37 -5
- package/src/lib/components/txns/internals/solicited-data-modal.component.ts +98 -65
- package/src/lib/components/txns/internals/txn-error.component.test.ts +33 -6
- package/src/lib/components/txns/internals/txn-error.component.ts +52 -29
- package/src/lib/components/txns/internals/txn.component.test.ts +63 -16
- package/src/lib/components/txns/internals/txn.component.ts +141 -61
- package/src/lib/components/txns/txns-overview.component.ts +109 -91
|
@@ -6,19 +6,23 @@ import {
|
|
|
6
6
|
input,
|
|
7
7
|
signal,
|
|
8
8
|
} from '@angular/core';
|
|
9
|
+
import { $locale, t as translate, type TextKey } from '@block-auth.io/core';
|
|
9
10
|
import { injectBlockAuthClient } from '../../provide-block-auth';
|
|
10
11
|
import { injectStore } from '../../inject-store';
|
|
11
12
|
import { TxnComponent } from './internals/txn.component';
|
|
12
13
|
import { TxnTypeComponent } from './internals/txn-type.component';
|
|
13
14
|
import { TxnErrorComponent } from './internals/txn-error.component';
|
|
14
15
|
import { PermissionsRequiredModalComponent } from './internals/permissions-required-modal.component';
|
|
15
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
SolicitedDataModalComponent,
|
|
18
|
+
type ParamChange,
|
|
19
|
+
} from './internals/solicited-data-modal.component';
|
|
16
20
|
|
|
17
21
|
// Orquestador de txns: lee las solicitudes pendientes de `$ws.requests` y la
|
|
18
22
|
// config de UI de `$ui.uiConfig` (vía injectStore). Se conserva la navegación
|
|
19
23
|
// prev/next, la composición de overlays permisos/datos-solicitados, la
|
|
20
24
|
// derivación de required/optional params desde `uiConfig` y las clases `bas-`.
|
|
21
|
-
// Se elimina
|
|
25
|
+
// Se elimina los wrappers framer-motion.
|
|
22
26
|
interface TxnPreParams {
|
|
23
27
|
iconUrl?: string;
|
|
24
28
|
domain?: string;
|
|
@@ -31,14 +35,16 @@ interface TxnPreParams {
|
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
const accountShort = (addr: string | null | undefined): string =>
|
|
34
|
-
addr && addr.length > 10
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
addr && addr.length > 10
|
|
39
|
+
? `${addr.slice(0, 6)}…${addr.slice(-4)}`
|
|
40
|
+
: addr ?? '';
|
|
41
|
+
|
|
42
|
+
const TXN_ERROR_TEXT_KEYS: Record<string, TextKey> = {
|
|
43
|
+
no_transactions_found: 'noTransactionsFound',
|
|
44
|
+
no_app_key_found: 'noAppKeyFound',
|
|
45
|
+
no_contract_address_found: 'noContractAddressFound',
|
|
46
|
+
no_transactions_params_found: 'noTransactionsParamsFound',
|
|
47
|
+
unknown: 'somethingWentWrong',
|
|
42
48
|
};
|
|
43
49
|
|
|
44
50
|
@Component({
|
|
@@ -58,79 +64,80 @@ const TXN_ERROR_TEXTS: Record<string, string> = {
|
|
|
58
64
|
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"
|
|
59
65
|
>
|
|
60
66
|
@if (isEmpty() && isSigning()) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
<ba-txn-error
|
|
68
|
+
[errorMessageTxt]="t('noTransactionsFound')"
|
|
69
|
+
errorMessageSlug="no_transactions_found"
|
|
70
|
+
[closeTxns]="closeTxns()"
|
|
71
|
+
[isCountdown]="false"
|
|
72
|
+
/>
|
|
67
73
|
} @else if (!isEmpty() && error().value) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
<ba-txn-error
|
|
75
|
+
[errorMessageTxt]="errorText()"
|
|
76
|
+
[errorMessageSlug]="error().messageSlug"
|
|
77
|
+
[closeTxns]="closeTxns()"
|
|
78
|
+
[isCountdown]="false"
|
|
79
|
+
/>
|
|
80
|
+
} @else if (!isEmpty()) {
|
|
81
|
+
<div class="bas-flex bas-flex-col bas-items-center bas-gap-3">
|
|
82
|
+
<img
|
|
83
|
+
[src]="
|
|
84
|
+
preParams().iconUrl ||
|
|
85
|
+
'https://dashboard.block-auth.io/img/blockauth_logo.png'
|
|
86
|
+
"
|
|
87
|
+
class="bas-h-16"
|
|
88
|
+
alt="app logo"
|
|
89
|
+
/>
|
|
90
|
+
<h2 class="bas-m-0 bas-text-base bas-text-[var(--bal-primary-600)]">
|
|
91
|
+
{{ preParams().domain || 'dashboard.block-auth.io' }}
|
|
92
|
+
</h2>
|
|
93
|
+
<p class="bas-m-0 bas-text-lg bas-text-[var(--bal-primary-800)]">
|
|
94
|
+
{{ preParams().appName || 'Block-Auth' }}
|
|
95
|
+
<span class="bas-text-base bas-text-[var(--bal-primary-500)]">{{
|
|
96
|
+
t('solicitsTo')
|
|
97
|
+
}}</span>
|
|
98
|
+
{{ accountShort(did()) }}
|
|
99
|
+
</p>
|
|
100
|
+
</div>
|
|
101
|
+
<ba-txn-type
|
|
102
|
+
[txnType]="preParams().txnType || t('login')"
|
|
103
|
+
[txnsLength]="txns().length"
|
|
104
|
+
(prevTxnClicked)="onPrevTxnClicked()"
|
|
105
|
+
(nextTxnClicked)="onNextTxnClicked()"
|
|
106
|
+
/>
|
|
107
|
+
<div class="bas-h-[334px] bas-w-full bas-max-w-[330px]">
|
|
108
|
+
<ba-txn
|
|
109
|
+
[hasSolicitedData]="hasSolicitedData()"
|
|
110
|
+
[allRequiredFilled]="allRequiredFilled()"
|
|
71
111
|
[closeTxns]="closeTxns()"
|
|
72
|
-
[
|
|
112
|
+
[selectedTxnPreParams]="preParams()"
|
|
113
|
+
[userParamValues]="userParamValues()"
|
|
114
|
+
[addError]="addError"
|
|
115
|
+
(permissionsRequiredClicked)="showPermissions.set(true)"
|
|
116
|
+
(solicitedDataClicked)="showSolicitedData.set(true)"
|
|
73
117
|
/>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
[
|
|
92
|
-
[
|
|
93
|
-
(
|
|
94
|
-
(
|
|
118
|
+
</div>
|
|
119
|
+
} @if (showPermissions()) {
|
|
120
|
+
<div
|
|
121
|
+
class="bal-ba-transition-2 bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-z-30 bas-box-border bas-h-full bas-w-full"
|
|
122
|
+
(click)="showPermissions.set(false)"
|
|
123
|
+
></div>
|
|
124
|
+
<div class="bas-absolute bas-top-44 bas-z-40">
|
|
125
|
+
<ba-permissions-required-modal />
|
|
126
|
+
</div>
|
|
127
|
+
} @if (showSolicitedData()) {
|
|
128
|
+
<div
|
|
129
|
+
class="bal-ba-transition-2 bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-z-30 bas-box-border bas-h-full bas-w-full"
|
|
130
|
+
(click)="showSolicitedData.set(false)"
|
|
131
|
+
></div>
|
|
132
|
+
<div class="bas-absolute bas-top-32 bas-z-40">
|
|
133
|
+
<ba-solicited-data-modal
|
|
134
|
+
[requiredParams]="requiredParams()"
|
|
135
|
+
[optionalParams]="optionalParams()"
|
|
136
|
+
[userParamValues]="userParamValues()"
|
|
137
|
+
(paramChange)="handleParamChange($event)"
|
|
138
|
+
(validationChange)="allRequiredFilled.set($event)"
|
|
95
139
|
/>
|
|
96
|
-
|
|
97
|
-
<ba-txn
|
|
98
|
-
[hasSolicitedData]="hasSolicitedData()"
|
|
99
|
-
[allRequiredFilled]="allRequiredFilled()"
|
|
100
|
-
[closeTxns]="closeTxns()"
|
|
101
|
-
[selectedTxnPreParams]="preParams()"
|
|
102
|
-
[userParamValues]="userParamValues()"
|
|
103
|
-
[addError]="addError"
|
|
104
|
-
(permissionsRequiredClicked)="showPermissions.set(true)"
|
|
105
|
-
(solicitedDataClicked)="showSolicitedData.set(true)"
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
@if (showPermissions()) {
|
|
111
|
-
<div
|
|
112
|
-
class="bal-ba-transition-2 bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-z-30 bas-box-border bas-h-full bas-w-full"
|
|
113
|
-
(click)="showPermissions.set(false)"
|
|
114
|
-
></div>
|
|
115
|
-
<div class="bas-absolute bas-top-44 bas-z-40">
|
|
116
|
-
<ba-permissions-required-modal />
|
|
117
|
-
</div>
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
@if (showSolicitedData()) {
|
|
121
|
-
<div
|
|
122
|
-
class="bal-ba-transition-2 bal-ba-backdrop-blur-base bal-ba-backdrop-blur-sm bas-absolute bas-z-30 bas-box-border bas-h-full bas-w-full"
|
|
123
|
-
(click)="showSolicitedData.set(false)"
|
|
124
|
-
></div>
|
|
125
|
-
<div class="bas-absolute bas-top-32 bas-z-40">
|
|
126
|
-
<ba-solicited-data-modal
|
|
127
|
-
[requiredParams]="requiredParams()"
|
|
128
|
-
[optionalParams]="optionalParams()"
|
|
129
|
-
[userParamValues]="userParamValues()"
|
|
130
|
-
(paramChange)="handleParamChange($event)"
|
|
131
|
-
(validationChange)="allRequiredFilled.set($event)"
|
|
132
|
-
/>
|
|
133
|
-
</div>
|
|
140
|
+
</div>
|
|
134
141
|
}
|
|
135
142
|
</div>
|
|
136
143
|
`,
|
|
@@ -141,6 +148,8 @@ export class TxnsOverviewComponent {
|
|
|
141
148
|
private readonly client = injectBlockAuthClient();
|
|
142
149
|
private readonly ws = injectStore(this.client.state.$ws);
|
|
143
150
|
private readonly ui = injectStore(this.client.state.$ui);
|
|
151
|
+
private readonly locale = injectStore($locale);
|
|
152
|
+
protected t = (key: TextKey): string => translate(key, this.locale());
|
|
144
153
|
|
|
145
154
|
protected readonly accountShort = accountShort;
|
|
146
155
|
|
|
@@ -158,8 +167,11 @@ export class TxnsOverviewComponent {
|
|
|
158
167
|
protected readonly did = computed(() => this.ws().did);
|
|
159
168
|
protected readonly isSigning = computed(() => this.ui().isSigning);
|
|
160
169
|
protected readonly isEmpty = computed(() => this.txns().length === 0);
|
|
161
|
-
protected readonly errorText = computed(
|
|
162
|
-
|
|
170
|
+
protected readonly errorText = computed(() =>
|
|
171
|
+
this.t(
|
|
172
|
+
TXN_ERROR_TEXT_KEYS[this.error().messageSlug] ??
|
|
173
|
+
TXN_ERROR_TEXT_KEYS['unknown'],
|
|
174
|
+
),
|
|
163
175
|
);
|
|
164
176
|
|
|
165
177
|
private readonly selectedTxn = computed(
|
|
@@ -177,22 +189,28 @@ export class TxnsOverviewComponent {
|
|
|
177
189
|
|
|
178
190
|
private readonly requiredOptionalParams = computed(() => {
|
|
179
191
|
const cfg =
|
|
180
|
-
(this.ui().uiConfig as { config?: Record<string, unknown> } | null)
|
|
192
|
+
(this.ui().uiConfig as { config?: Record<string, unknown> } | null)
|
|
193
|
+
?.config ?? {};
|
|
181
194
|
const required: string[] = [];
|
|
182
195
|
const optional: string[] = [];
|
|
183
|
-
const kycMode = (cfg['modules'] as { kyc?: { mode?: string } } | undefined)
|
|
196
|
+
const kycMode = (cfg['modules'] as { kyc?: { mode?: string } } | undefined)
|
|
197
|
+
?.kyc?.mode;
|
|
184
198
|
if (kycMode === 'required') required.push('modules-kyc');
|
|
185
199
|
else if (kycMode === 'optional') optional.push('modules-kyc');
|
|
186
|
-
Object.entries(
|
|
187
|
-
([
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
);
|
|
200
|
+
Object.entries(
|
|
201
|
+
(cfg['params'] as Record<string, { mode?: string }>) || {},
|
|
202
|
+
).forEach(([slug, paramCfg]) => {
|
|
203
|
+
if (paramCfg.mode === 'required') required.push(slug);
|
|
204
|
+
else if (paramCfg.mode === 'optional') optional.push(slug);
|
|
205
|
+
});
|
|
192
206
|
return { requiredParams: required, optionalParams: optional };
|
|
193
207
|
});
|
|
194
|
-
protected readonly requiredParams = computed(
|
|
195
|
-
|
|
208
|
+
protected readonly requiredParams = computed(
|
|
209
|
+
() => this.requiredOptionalParams().requiredParams,
|
|
210
|
+
);
|
|
211
|
+
protected readonly optionalParams = computed(
|
|
212
|
+
() => this.requiredOptionalParams().optionalParams,
|
|
213
|
+
);
|
|
196
214
|
protected readonly hasSolicitedData = computed(
|
|
197
215
|
() => this.requiredParams().length > 0 || this.optionalParams().length > 0,
|
|
198
216
|
);
|