@adonis-agora/authkit-server 1.0.0-rc.1 → 1.0.0-rc.11
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/CHANGELOG.md +107 -0
- package/README.md +4 -5
- package/build/commands/agora_doctor.d.ts +22 -0
- package/build/commands/agora_doctor.js +109 -0
- package/build/commands/clients_create.d.ts +4 -0
- package/build/commands/clients_create.js +97 -0
- package/build/commands/commands.json +78 -0
- package/build/commands/doctor.js +8 -74
- package/build/host/views/account/apps.edge +1 -5
- package/build/host/views/account/extension.edge +77 -0
- package/build/host/views/account/mfa.edge +2 -0
- package/build/host/views/account/partials/extension_actions.edge +14 -0
- package/build/host/views/account/partials/extension_block.edge +197 -0
- package/build/host/views/account/partials/extension_value.edge +8 -0
- package/build/host/views/account/partials/nav.edge +14 -0
- package/build/host/views/account/security.edge +1 -5
- package/build/host/views/account/tokens.edge +2 -2
- package/build/host/views/agents/consent.edge +11 -2
- package/build/host/views/agents/done.edge +1 -1
- package/build/host/views/partials/styles.edge +1 -1
- package/build/index.d.ts +12 -12
- package/build/index.js +7 -9
- package/build/providers/authkit_server_provider.js +29 -8
- package/build/src/account/extension.d.ts +10 -0
- package/build/src/account/extension.js +9 -0
- package/build/src/account/http.d.ts +77 -0
- package/build/src/account/http.js +381 -0
- package/build/src/account/mount.d.ts +40 -0
- package/build/src/account/mount.js +171 -0
- package/build/src/account/registry.d.ts +41 -0
- package/build/src/account/registry.js +81 -0
- package/build/src/account/remote.d.ts +72 -0
- package/build/src/account/remote.js +406 -0
- package/build/src/account/runtime.d.ts +289 -0
- package/build/src/account/runtime.js +641 -0
- package/build/src/accounts/account_store.d.ts +13 -7
- package/build/src/accounts/lucid_account_store.d.ts +3 -3
- package/build/src/accounts/lucid_account_store.js +42 -17
- package/build/src/accounts/lucid_store/mfa.js +3 -3
- package/build/src/accounts/lucid_store/organization_models.d.ts +14 -3
- package/build/src/accounts/lucid_store/organization_models.js +31 -3
- package/build/src/accounts/lucid_store/organizations.d.ts +2 -2
- package/build/src/accounts/lucid_store/organizations.js +40 -31
- package/build/src/accounts/lucid_store/shared.d.ts +11 -3
- package/build/src/accounts/lucid_store/shared.js +7 -5
- package/build/src/accounts/lucid_store/webauthn.js +1 -1
- package/build/src/adapters/factory.d.ts +13 -2
- package/build/src/adapters/factory.js +2 -2
- package/build/src/agents/config.d.ts +9 -13
- package/build/src/agents/config.js +17 -11
- package/build/src/agents/delegation_service.js +3 -3
- package/build/src/agents/delegation_store.d.ts +3 -2
- package/build/src/agents/delegation_store.js +6 -5
- package/build/src/agents/extension.d.ts +261 -0
- package/build/src/agents/extension.js +40 -0
- package/build/src/agents/middleware.js +1 -1
- package/build/src/agents/protocol.d.ts +4 -4
- package/build/src/agents/registry_store.d.ts +3 -2
- package/build/src/agents/registry_store.js +1 -1
- package/build/src/agents/runtime.d.ts +26 -7
- package/build/src/agents/runtime.js +110 -75
- package/build/src/audit/audit_sink.d.ts +1 -1
- package/build/src/audit/audit_sink.js +10 -1
- package/build/src/commands/expire_scan_command.js +1 -1
- package/build/src/commands/settings_commands.js +2 -2
- package/build/src/console_switcher.d.ts +132 -0
- package/build/src/console_switcher.js +206 -0
- package/build/src/define_config.d.ts +38 -13
- package/build/src/define_config.js +32 -10
- package/build/src/dev_tools/contract.d.ts +72 -0
- package/build/src/dev_tools/contract.js +10 -0
- package/build/src/dev_tools/gate.d.ts +17 -0
- package/build/src/dev_tools/gate.js +69 -0
- package/build/src/dev_tools/register.d.ts +11 -0
- package/build/src/dev_tools/register.js +25 -0
- package/build/src/dev_tools/tools.d.ts +24 -0
- package/build/src/dev_tools/tools.js +384 -0
- package/build/src/doctor/agora_checks.d.ts +15 -0
- package/build/src/doctor/agora_checks.js +150 -0
- package/build/src/doctor/agora_doctor.d.ts +115 -0
- package/build/src/doctor/agora_doctor.js +692 -0
- package/build/src/doctor/checks.js +2 -2
- package/build/src/doctor/doctor_input.d.ts +27 -0
- package/build/src/doctor/doctor_input.js +86 -0
- package/build/src/doctor/index.d.ts +5 -0
- package/build/src/doctor/index.js +4 -0
- package/build/src/host/access_token_verifier.js +7 -0
- package/build/src/host/account_api/account_api_controller.js +8 -6
- package/build/src/host/account_session_sign_in.d.ts +12 -0
- package/build/src/host/account_session_sign_in.js +19 -0
- package/build/src/host/admin_api/admin_users_service.d.ts +5 -2
- package/build/src/host/admin_api/api_clients_controller.d.ts +37 -0
- package/build/src/host/admin_api/api_clients_controller.js +31 -1
- package/build/src/host/admin_api/dto.d.ts +3 -1
- package/build/src/host/admin_api/dto.js +2 -0
- package/build/src/host/admin_authorize.d.ts +8 -0
- package/build/src/host/admin_authorize.js +25 -0
- package/build/src/host/admin_clients_service.d.ts +20 -0
- package/build/src/host/admin_clients_service.js +55 -0
- package/build/src/host/admin_console/admin_console_entry.d.ts +14 -0
- package/build/src/host/admin_console/admin_console_entry.js +80 -0
- package/build/src/host/admin_console/admin_shell_controller.js +8 -0
- package/build/src/host/admin_console/console_clients_controller.d.ts +41 -0
- package/build/src/host/admin_console/console_clients_controller.js +34 -1
- package/build/src/host/admin_console/console_personal_agents_controller.d.ts +1 -6
- package/build/src/host/admin_console/console_personal_agents_controller.js +50 -30
- package/build/src/host/admin_console/console_switcher_controller.d.ts +11 -0
- package/build/src/host/admin_console/console_switcher_controller.js +23 -0
- package/build/src/host/admin_sessions_service.js +8 -5
- package/build/src/host/admin_validators.d.ts +29 -0
- package/build/src/host/admin_validators.js +30 -0
- package/build/src/host/auth_host_config.d.ts +9 -2
- package/build/src/host/controllers/account_apps_controller.js +15 -11
- package/build/src/host/csrf.d.ts +3 -3
- package/build/src/host/csrf.js +3 -13
- package/build/src/host/default_mailer.d.ts +11 -6
- package/build/src/host/default_mailer.js +16 -12
- package/build/src/host/i18n.d.ts +41 -14
- package/build/src/host/i18n.js +55 -13
- package/build/src/host/rate_limit.d.ts +8 -0
- package/build/src/host/rate_limit.js +9 -0
- package/build/src/host/register_auth_host.d.ts +14 -0
- package/build/src/host/register_auth_host.js +167 -106
- package/build/src/host/renderers/edge_renderer.js +5 -0
- package/build/src/host/renderers/inertia_renderer.js +7 -1
- package/build/src/host/runtime_settings.d.ts +6 -6
- package/build/src/host/runtime_settings.js +4 -3
- package/build/src/host/screen_props.d.ts +39 -8
- package/build/src/host/ui-dist/assets/index-Dq3dJVBv.js +67 -0
- package/build/src/host/ui-dist/assets/{index-DTSmD4RU.css → index-WNIyCEPA.css} +1 -1
- package/build/src/host/ui-dist/index.html +2 -2
- package/build/src/provider/build_provider.js +37 -6
- package/build/src/provider/oidc_service.d.ts +1 -1
- package/build/src/provider/oidc_service.js +1 -1
- package/build/src/schema/ensure.d.ts +24 -1
- package/build/src/schema/ensure.js +44 -154
- package/build/src/schema/tables_location.d.ts +27 -0
- package/build/src/schema/tables_location.js +22 -0
- package/build/src/service_tenants/client_metadata.d.ts +39 -0
- package/build/src/service_tenants/client_metadata.js +80 -0
- package/build/src/service_tenants/config.d.ts +44 -0
- package/build/src/service_tenants/config.js +44 -0
- package/build/src/service_tenants/provider_hooks.d.ts +52 -0
- package/build/src/service_tenants/provider_hooks.js +124 -0
- package/build/src/service_tenants/tenant_verifier.d.ts +73 -0
- package/build/src/service_tenants/tenant_verifier.js +104 -0
- package/build/src/tenancy/tenant_labels.d.ts +30 -0
- package/build/src/tenancy/tenant_labels.js +64 -0
- package/build/types.d.ts +3 -1
- package/package.json +9 -6
- package/build/src/agents/poppy/client_registry.d.ts +0 -50
- package/build/src/agents/poppy/client_registry.js +0 -260
- package/build/src/agents/poppy/config.d.ts +0 -396
- package/build/src/agents/poppy/config.js +0 -228
- package/build/src/agents/poppy/dpop.d.ts +0 -61
- package/build/src/agents/poppy/dpop.js +0 -158
- package/build/src/agents/poppy/email_code_sign_in.d.ts +0 -27
- package/build/src/agents/poppy/email_code_sign_in.js +0 -140
- package/build/src/agents/poppy/errors.d.ts +0 -25
- package/build/src/agents/poppy/errors.js +0 -25
- package/build/src/agents/poppy/replay.d.ts +0 -25
- package/build/src/agents/poppy/replay.js +0 -106
- package/build/src/agents/poppy/resource.d.ts +0 -100
- package/build/src/agents/poppy/resource.js +0 -129
- package/build/src/agents/poppy/safe_fetch.d.ts +0 -48
- package/build/src/agents/poppy/safe_fetch.js +0 -262
- package/build/src/agents/poppy/service.d.ts +0 -293
- package/build/src/agents/poppy/service.js +0 -1458
- package/build/src/agents/poppy/session_jwt.d.ts +0 -30
- package/build/src/agents/poppy/session_jwt.js +0 -133
- package/build/src/agents/poppy/store.d.ts +0 -106
- package/build/src/agents/poppy/store.js +0 -261
- package/build/src/agents/poppy/web_session.d.ts +0 -39
- package/build/src/agents/poppy/web_session.js +0 -122
- package/build/src/host/controllers/poppy_consent_controller.d.ts +0 -19
- package/build/src/host/controllers/poppy_consent_controller.js +0 -199
- package/build/src/host/controllers/poppy_controller.d.ts +0 -33
- package/build/src/host/controllers/poppy_controller.js +0 -219
- package/build/src/host/poppy_session_key.d.ts +0 -9
- package/build/src/host/poppy_session_key.js +0 -9
- package/build/src/host/ui-dist/assets/index-D0EIeyKK.js +0 -67
|
@@ -38,16 +38,19 @@ export default class AccountAppsController {
|
|
|
38
38
|
scopes: g.scopes,
|
|
39
39
|
})))
|
|
40
40
|
: null;
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
// Conexões das `personalAgents.extensions`: desconectadas pela mesma lista.
|
|
42
|
+
let extensionAgents = null;
|
|
43
|
+
for (const { runtime } of agentsRuntime?.extensions.values() ?? []) {
|
|
44
|
+
extensionAgents ??= [];
|
|
45
|
+
for (const g of await runtime.listAccountGrants(accountId)) {
|
|
46
|
+
extensionAgents.push({
|
|
47
|
+
id: g.id,
|
|
48
|
+
name: await runtime.displayName(g.clientId),
|
|
49
|
+
scopes: g.scopes,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const agents = pactAgents || extensionAgents ? [...(pactAgents ?? []), ...(extensionAgents ?? [])] : null;
|
|
51
54
|
return render(ctx, 'account/apps', {
|
|
52
55
|
csrfToken: ctx.request.csrfToken,
|
|
53
56
|
supported,
|
|
@@ -89,8 +92,9 @@ export default class AccountAppsController {
|
|
|
89
92
|
/** POST /account/apps/agents/:grantId/revoke — revoga a delegação de um personal agent. */
|
|
90
93
|
async revokeAgent(ctx) {
|
|
91
94
|
const runtime = await personalAgentsFor(ctx);
|
|
92
|
-
if (!runtime
|
|
95
|
+
if (!runtime || (!runtime.delegation && runtime.extensions.size === 0)) {
|
|
93
96
|
return ctx.response.notFound();
|
|
97
|
+
}
|
|
94
98
|
const service = await ctx.containerResolver.make('authkit.server');
|
|
95
99
|
const cfg = service.config;
|
|
96
100
|
const accountId = ctx.session.get(ACCOUNT_SESSION_KEY);
|
package/build/src/host/csrf.d.ts
CHANGED
|
@@ -11,10 +11,10 @@ export interface AuthkitCsrfOptions {
|
|
|
11
11
|
*/
|
|
12
12
|
personalAgentsPrefix?: string | false;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Isenta os `csrfExemptPaths` das `personalAgents.extensions` do config. Default: true.
|
|
15
|
+
* `false` desliga.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
personalAgentExtensions?: boolean;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Retorna `true` quando `url` é uma rota AuthKit que deve ser ISENTA de CSRF
|
package/build/src/host/csrf.js
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
import { normalizePersonalAgentsPrefix } from '../agents/config.js';
|
|
19
|
-
import { normalizePoppyPrefix } from '../agents/poppy/config.js';
|
|
20
19
|
import { getAuthHostConfig } from './auth_host_config.js';
|
|
21
20
|
/**
|
|
22
21
|
* Retorna `true` quando `url` é uma rota AuthKit que deve ser ISENTA de CSRF
|
|
@@ -34,21 +33,12 @@ export function authkitCsrfExceptions(url, options = {}) {
|
|
|
34
33
|
? normalizePersonalAgentsPrefix(options.personalAgentsPrefix)
|
|
35
34
|
: getAuthHostConfig()?.personalAgents?.prefix;
|
|
36
35
|
const agentsOAuth = agentsPrefix ? `${agentsPrefix}/oauth/` : null;
|
|
37
|
-
const poppyPrefix = options.poppyPrefix === false
|
|
38
|
-
? undefined
|
|
39
|
-
: options.poppyPrefix !== undefined
|
|
40
|
-
? normalizePoppyPrefix(options.poppyPrefix)
|
|
41
|
-
: getAuthHostConfig()?.personalAgents?.poppyPrefix;
|
|
42
36
|
const path = url.split('?')[0];
|
|
43
|
-
const
|
|
44
|
-
(
|
|
45
|
-
path === `${poppyPrefix}/oauth/revoke` ||
|
|
46
|
-
path === `${poppyPrefix}/oauth/device` ||
|
|
47
|
-
path === `${poppyPrefix}/browser-session` ||
|
|
48
|
-
path === `${poppyPrefix}/browser-session/authorize`);
|
|
37
|
+
const extensionExempt = options.personalAgentExtensions !== false &&
|
|
38
|
+
(getAuthHostConfig()?.personalAgents?.extensions ?? []).some((e) => e.csrfExemptPaths?.includes(path));
|
|
49
39
|
return (url.includes(mountPath) ||
|
|
50
40
|
url.includes('/authkit/pat') ||
|
|
51
41
|
(backchannel !== null && url === backchannel) ||
|
|
52
42
|
(agentsOAuth !== null && url.startsWith(agentsOAuth)) ||
|
|
53
|
-
|
|
43
|
+
extensionExempt);
|
|
54
44
|
}
|
|
@@ -67,15 +67,20 @@ export declare function sendMagicLinkEmail(ctx: HttpContext, data: {
|
|
|
67
67
|
channel?: 'code' | 'link';
|
|
68
68
|
}): Promise<void>;
|
|
69
69
|
/**
|
|
70
|
-
* Envia
|
|
71
|
-
*
|
|
72
|
-
*
|
|
70
|
+
* Envia um e-mail só com um código (sem link: quem digita é a pessoa, em outro lugar) pelo mailer
|
|
71
|
+
* default do host, com o branding e o i18n do authkit. Os textos saem do catálogo pelas chaves
|
|
72
|
+
* `{messages}.subject`, `.heading`, `.intro`, `.code_label` e `.fallback`, com `params`
|
|
73
|
+
* interpolados — uma extension registra as dela em `messages`. Best-effort: sem `@adonisjs/mail`
|
|
74
|
+
* loga o código (dev); nunca lança.
|
|
75
|
+
*
|
|
76
|
+
* Estável no 1.x (é o mailer das `personalAgents.extensions`).
|
|
73
77
|
*/
|
|
74
|
-
export declare function
|
|
78
|
+
export declare function sendAuthkitCodeEmail(ctx: HttpContext, data: {
|
|
75
79
|
email: string;
|
|
76
80
|
code: string;
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
/** Prefixo das chaves no catálogo (`'mail.poppy_sign_in'`). */
|
|
82
|
+
messages: string;
|
|
83
|
+
params?: Record<string, string | number>;
|
|
79
84
|
}): Promise<void>;
|
|
80
85
|
/**
|
|
81
86
|
* Envia o link de CONFIRMAÇÃO DE IDENTIDADE (sudo) pelo mailer default do host.
|
|
@@ -295,32 +295,36 @@ export async function sendMagicLinkEmail(ctx, data) {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
|
-
* Envia
|
|
299
|
-
*
|
|
300
|
-
*
|
|
298
|
+
* Envia um e-mail só com um código (sem link: quem digita é a pessoa, em outro lugar) pelo mailer
|
|
299
|
+
* default do host, com o branding e o i18n do authkit. Os textos saem do catálogo pelas chaves
|
|
300
|
+
* `{messages}.subject`, `.heading`, `.intro`, `.code_label` e `.fallback`, com `params`
|
|
301
|
+
* interpolados — uma extension registra as dela em `messages`. Best-effort: sem `@adonisjs/mail`
|
|
302
|
+
* loga o código (dev); nunca lança.
|
|
303
|
+
*
|
|
304
|
+
* Estável no 1.x (é o mailer das `personalAgents.extensions`).
|
|
301
305
|
*/
|
|
302
|
-
export async function
|
|
306
|
+
export async function sendAuthkitCodeEmail(ctx, data) {
|
|
303
307
|
try {
|
|
304
308
|
const brand = resolveBrand(ctx);
|
|
305
309
|
const { messages: t, locale } = resolveMailMessages(ctx);
|
|
306
|
-
const
|
|
310
|
+
const key = (name) => `${data.messages}.${name}`;
|
|
307
311
|
const content = renderTransactionalEmail({
|
|
308
312
|
brand,
|
|
309
313
|
locale,
|
|
310
|
-
subject: translate(t, '
|
|
311
|
-
heading: translate(t, '
|
|
312
|
-
intro: translate(t, '
|
|
313
|
-
footnote: translate(t, '
|
|
314
|
+
subject: translate(t, key('subject'), data.params),
|
|
315
|
+
heading: translate(t, key('heading'), data.params),
|
|
316
|
+
intro: translate(t, key('intro'), data.params),
|
|
317
|
+
footnote: translate(t, key('fallback'), data.params),
|
|
314
318
|
code: data.code,
|
|
315
|
-
codeLabel: translate(t, '
|
|
319
|
+
codeLabel: translate(t, key('code_label'), data.params),
|
|
316
320
|
});
|
|
317
321
|
const sent = await sendEmail(ctx, data.email, content);
|
|
318
322
|
if (!sent) {
|
|
319
|
-
ctx.logger.info({ email: data.email,
|
|
323
|
+
ctx.logger.info({ email: data.email, code: data.code, messages: data.messages, ...(data.params ?? {}) }, 'authkit: código por e-mail (dev — @adonisjs/mail ausente)');
|
|
320
324
|
}
|
|
321
325
|
}
|
|
322
326
|
catch (error) {
|
|
323
|
-
ctx.logger.error({ err: error, email: data.email }, 'authkit: falha ao enviar o
|
|
327
|
+
ctx.logger.error({ err: error, email: data.email, messages: data.messages }, 'authkit: falha ao enviar o e-mail com código');
|
|
324
328
|
}
|
|
325
329
|
}
|
|
326
330
|
/**
|
package/build/src/host/i18n.d.ts
CHANGED
|
@@ -174,6 +174,24 @@ export declare const DEFAULT_MESSAGES: {
|
|
|
174
174
|
'account.delete.deleted': string;
|
|
175
175
|
'account.delete.invalid_confirmation': string;
|
|
176
176
|
'account.delete.not_supported': string;
|
|
177
|
+
'account.extension.logout': string;
|
|
178
|
+
'account.extension.nav_label': string;
|
|
179
|
+
'account.extension.unknown_block': string;
|
|
180
|
+
'account.extension.unsafe_link': string;
|
|
181
|
+
'account.extension.unsafe_script': string;
|
|
182
|
+
'account.extension.load_failed': string;
|
|
183
|
+
'account.extension.next_page': string;
|
|
184
|
+
'account.extension.confirm_title': string;
|
|
185
|
+
'account.extension.confirm_submit': string;
|
|
186
|
+
'account.extension.cancel': string;
|
|
187
|
+
'account.extension.action_failed': string;
|
|
188
|
+
'account.extension.action_not_found': string;
|
|
189
|
+
'account.extension.impersonation_refused': string;
|
|
190
|
+
'account.extension.field_required': string;
|
|
191
|
+
'account.extension.field_too_long': string;
|
|
192
|
+
'account.extension.field_invalid': string;
|
|
193
|
+
'account.extension.done': string;
|
|
194
|
+
'account.extension.provider_loading': string;
|
|
177
195
|
'account.apps.page_title': string;
|
|
178
196
|
'account.apps.title': string;
|
|
179
197
|
'account.apps.intro': string;
|
|
@@ -191,6 +209,7 @@ export declare const DEFAULT_MESSAGES: {
|
|
|
191
209
|
'agents.consent.body': string;
|
|
192
210
|
'agents.consent.signed_in_as': string;
|
|
193
211
|
'agents.consent.scopes_label': string;
|
|
212
|
+
'agents.consent.opt_in_hint': string;
|
|
194
213
|
'agents.consent.code': string;
|
|
195
214
|
'agents.consent.allow': string;
|
|
196
215
|
'agents.consent.deny': string;
|
|
@@ -560,11 +579,6 @@ export declare const DEFAULT_MESSAGES: {
|
|
|
560
579
|
'mail.magic_link.code_subject': string;
|
|
561
580
|
'mail.magic_link.code_intro': string;
|
|
562
581
|
'mail.magic_link.code_only_label': string;
|
|
563
|
-
'mail.poppy_sign_in.subject': string;
|
|
564
|
-
'mail.poppy_sign_in.heading': string;
|
|
565
|
-
'mail.poppy_sign_in.intro': string;
|
|
566
|
-
'mail.poppy_sign_in.code_label': string;
|
|
567
|
-
'mail.poppy_sign_in.fallback': string;
|
|
568
582
|
'mail.sudo_link.subject': string;
|
|
569
583
|
'mail.sudo_link.heading': string;
|
|
570
584
|
'mail.sudo_link.intro': string;
|
|
@@ -932,6 +946,24 @@ export declare const PT_BR_MESSAGES: {
|
|
|
932
946
|
'account.delete.deleted': string;
|
|
933
947
|
'account.delete.invalid_confirmation': string;
|
|
934
948
|
'account.delete.not_supported': string;
|
|
949
|
+
'account.extension.logout': string;
|
|
950
|
+
'account.extension.nav_label': string;
|
|
951
|
+
'account.extension.unknown_block': string;
|
|
952
|
+
'account.extension.unsafe_link': string;
|
|
953
|
+
'account.extension.unsafe_script': string;
|
|
954
|
+
'account.extension.load_failed': string;
|
|
955
|
+
'account.extension.next_page': string;
|
|
956
|
+
'account.extension.confirm_title': string;
|
|
957
|
+
'account.extension.confirm_submit': string;
|
|
958
|
+
'account.extension.cancel': string;
|
|
959
|
+
'account.extension.action_failed': string;
|
|
960
|
+
'account.extension.action_not_found': string;
|
|
961
|
+
'account.extension.impersonation_refused': string;
|
|
962
|
+
'account.extension.field_required': string;
|
|
963
|
+
'account.extension.field_too_long': string;
|
|
964
|
+
'account.extension.field_invalid': string;
|
|
965
|
+
'account.extension.done': string;
|
|
966
|
+
'account.extension.provider_loading': string;
|
|
935
967
|
'account.apps.page_title': string;
|
|
936
968
|
'account.apps.title': string;
|
|
937
969
|
'account.apps.intro': string;
|
|
@@ -949,6 +981,7 @@ export declare const PT_BR_MESSAGES: {
|
|
|
949
981
|
'agents.consent.body': string;
|
|
950
982
|
'agents.consent.signed_in_as': string;
|
|
951
983
|
'agents.consent.scopes_label': string;
|
|
984
|
+
'agents.consent.opt_in_hint': string;
|
|
952
985
|
'agents.consent.code': string;
|
|
953
986
|
'agents.consent.allow': string;
|
|
954
987
|
'agents.consent.deny': string;
|
|
@@ -1318,11 +1351,6 @@ export declare const PT_BR_MESSAGES: {
|
|
|
1318
1351
|
'mail.magic_link.code_subject': string;
|
|
1319
1352
|
'mail.magic_link.code_intro': string;
|
|
1320
1353
|
'mail.magic_link.code_only_label': string;
|
|
1321
|
-
'mail.poppy_sign_in.subject': string;
|
|
1322
|
-
'mail.poppy_sign_in.heading': string;
|
|
1323
|
-
'mail.poppy_sign_in.intro': string;
|
|
1324
|
-
'mail.poppy_sign_in.code_label': string;
|
|
1325
|
-
'mail.poppy_sign_in.fallback': string;
|
|
1326
1354
|
'mail.sudo_link.subject': string;
|
|
1327
1355
|
'mail.sudo_link.heading': string;
|
|
1328
1356
|
'mail.sudo_link.intro': string;
|
|
@@ -1547,11 +1575,10 @@ export declare const PT_BR_MESSAGES: {
|
|
|
1547
1575
|
*/
|
|
1548
1576
|
export declare const BUILTIN_MESSAGES: Record<string, AuthMessages>;
|
|
1549
1577
|
/**
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
* overrides do host por cima. Sem config, retorna o default `en` intacto.
|
|
1553
|
-
* Chaves omitidas caem no default `en` (fallback de cobertura).
|
|
1578
|
+
* Soma os catálogos de uma extension (`messages`) aos embutidos. Chamado quando o config resolve;
|
|
1579
|
+
* os overrides do host (`i18n.messages`) continuam vencendo.
|
|
1554
1580
|
*/
|
|
1581
|
+
export declare function registerExtensionMessages(catalogs: Readonly<Record<string, Readonly<Record<string, string>>>>): void;
|
|
1555
1582
|
export declare function resolveMessages(i18n?: I18nConfig): AuthMessages;
|
|
1556
1583
|
/**
|
|
1557
1584
|
* Retorna a string para `key` (cai na própria `key` quando ausente) com
|
package/build/src/host/i18n.js
CHANGED
|
@@ -182,6 +182,25 @@ export const DEFAULT_MESSAGES = {
|
|
|
182
182
|
'account.delete.deleted': 'Your account has been permanently deleted.',
|
|
183
183
|
'account.delete.invalid_confirmation': 'Confirmation failed. Your account was not deleted.',
|
|
184
184
|
'account.delete.not_supported': 'Account deletion is not available in this installation.',
|
|
185
|
+
// Console de conta — páginas de extensions (account/extension).
|
|
186
|
+
'account.extension.logout': 'Log out',
|
|
187
|
+
'account.extension.nav_label': 'Account',
|
|
188
|
+
'account.extension.unknown_block': 'This section cannot be shown here.',
|
|
189
|
+
'account.extension.unsafe_link': 'This link was hidden because its address is not allowed.',
|
|
190
|
+
'account.extension.unsafe_script': 'This section was hidden because it loads a script from an address that is not allowed.',
|
|
191
|
+
'account.extension.load_failed': 'This page could not be loaded right now. Try again in a moment.',
|
|
192
|
+
'account.extension.next_page': 'Next page',
|
|
193
|
+
'account.extension.confirm_title': 'Confirm',
|
|
194
|
+
'account.extension.confirm_submit': 'Continue',
|
|
195
|
+
'account.extension.cancel': 'Cancel',
|
|
196
|
+
'account.extension.action_failed': 'That did not work. Try again in a moment.',
|
|
197
|
+
'account.extension.action_not_found': 'This action is not available.',
|
|
198
|
+
'account.extension.impersonation_refused': 'This action is not available while acting as another user.',
|
|
199
|
+
'account.extension.field_required': '{field} is required.',
|
|
200
|
+
'account.extension.field_too_long': '{field} is too long.',
|
|
201
|
+
'account.extension.field_invalid': '{field} has an invalid value.',
|
|
202
|
+
'account.extension.done': 'Done.',
|
|
203
|
+
'account.extension.provider_loading': 'Loading…',
|
|
185
204
|
// Console de conta — apps com acesso (account/apps).
|
|
186
205
|
'account.apps.page_title': 'Apps with access',
|
|
187
206
|
'account.apps.title': 'Apps with access',
|
|
@@ -200,6 +219,7 @@ export const DEFAULT_MESSAGES = {
|
|
|
200
219
|
'agents.consent.body': 'The request came from {origin}. Choose what it can do — you can revoke access at any time.',
|
|
201
220
|
'agents.consent.signed_in_as': 'Signed in as {email}',
|
|
202
221
|
'agents.consent.scopes_label': 'Allow it to:',
|
|
222
|
+
'agents.consent.opt_in_hint': 'Not selected for you: tick it only if you want to allow it.',
|
|
203
223
|
'agents.consent.code': 'Request code: {code}. Make sure it matches the code your assistant shows.',
|
|
204
224
|
'agents.consent.allow': 'Allow',
|
|
205
225
|
'agents.consent.deny': 'Deny',
|
|
@@ -603,12 +623,6 @@ export const DEFAULT_MESSAGES = {
|
|
|
603
623
|
'mail.magic_link.code_subject': 'Your login code',
|
|
604
624
|
'mail.magic_link.code_intro': 'Use the code below to sign in. It expires shortly and can be used once.',
|
|
605
625
|
'mail.magic_link.code_only_label': 'Enter this code to sign in:',
|
|
606
|
-
// Código do Mediated Sign-In do Poppy: um personal agent pede para entrar na conta.
|
|
607
|
-
'mail.poppy_sign_in.subject': 'Your code to connect {agent}',
|
|
608
|
-
'mail.poppy_sign_in.heading': 'Connect {agent} to your account',
|
|
609
|
-
'mail.poppy_sign_in.intro': '{agent} asked to sign in to your account. If that was you, give it the code below. It expires in {minutes} minutes and works once.',
|
|
610
|
-
'mail.poppy_sign_in.code_label': 'Your code:',
|
|
611
|
-
'mail.poppy_sign_in.fallback': 'If you did not ask for this, ignore this email — nobody gets in without the code. Never share it with anyone else.',
|
|
612
626
|
// Link de CONFIRMAÇÃO DE IDENTIDADE (sudo). Copy DISTINTA da do magic link de
|
|
613
627
|
// login de propósito: este link não autentica ninguém — quem o abre já está
|
|
614
628
|
// logado e só reprova que é quem diz ser. Prometer "entre na sua conta" num
|
|
@@ -1028,6 +1042,25 @@ export const PT_BR_MESSAGES = {
|
|
|
1028
1042
|
'account.delete.deleted': 'Sua conta foi deletada permanentemente.',
|
|
1029
1043
|
'account.delete.invalid_confirmation': 'Confirmação falhou. Sua conta NÃO foi deletada.',
|
|
1030
1044
|
'account.delete.not_supported': 'A deleção de conta não está disponível nesta instalação.',
|
|
1045
|
+
// Console de conta — páginas de extensions (account/extension).
|
|
1046
|
+
'account.extension.logout': 'Sair',
|
|
1047
|
+
'account.extension.nav_label': 'Conta',
|
|
1048
|
+
'account.extension.unknown_block': 'Esta seção não pode ser exibida aqui.',
|
|
1049
|
+
'account.extension.unsafe_link': 'Este link foi ocultado porque o endereço não é permitido.',
|
|
1050
|
+
'account.extension.unsafe_script': 'Esta seção foi ocultada porque carrega um script de um endereço não permitido.',
|
|
1051
|
+
'account.extension.load_failed': 'Não foi possível carregar esta página agora. Tente de novo em instantes.',
|
|
1052
|
+
'account.extension.next_page': 'Próxima página',
|
|
1053
|
+
'account.extension.confirm_title': 'Confirmar',
|
|
1054
|
+
'account.extension.confirm_submit': 'Continuar',
|
|
1055
|
+
'account.extension.cancel': 'Cancelar',
|
|
1056
|
+
'account.extension.action_failed': 'Não deu certo. Tente de novo em instantes.',
|
|
1057
|
+
'account.extension.action_not_found': 'Esta ação não está disponível.',
|
|
1058
|
+
'account.extension.impersonation_refused': 'Esta ação não está disponível enquanto você age como outro usuário.',
|
|
1059
|
+
'account.extension.field_required': '{field} é obrigatório.',
|
|
1060
|
+
'account.extension.field_too_long': '{field} é longo demais.',
|
|
1061
|
+
'account.extension.field_invalid': '{field} tem um valor inválido.',
|
|
1062
|
+
'account.extension.done': 'Feito.',
|
|
1063
|
+
'account.extension.provider_loading': 'Carregando…',
|
|
1031
1064
|
// Console de conta — apps com acesso (account/apps).
|
|
1032
1065
|
'account.apps.page_title': 'Apps com acesso',
|
|
1033
1066
|
'account.apps.title': 'Apps com acesso',
|
|
@@ -1046,6 +1079,7 @@ export const PT_BR_MESSAGES = {
|
|
|
1046
1079
|
'agents.consent.body': 'O pedido veio de {origin}. Escolha o que ele pode fazer — você pode revogar o acesso quando quiser.',
|
|
1047
1080
|
'agents.consent.signed_in_as': 'Conectado como {email}',
|
|
1048
1081
|
'agents.consent.scopes_label': 'Permitir que ele:',
|
|
1082
|
+
'agents.consent.opt_in_hint': 'Não vem marcado: marque só se quiser permitir.',
|
|
1049
1083
|
'agents.consent.code': 'Código do pedido: {code}. Confira se é o mesmo que o seu assistente mostra.',
|
|
1050
1084
|
'agents.consent.allow': 'Permitir',
|
|
1051
1085
|
'agents.consent.deny': 'Negar',
|
|
@@ -1447,12 +1481,6 @@ export const PT_BR_MESSAGES = {
|
|
|
1447
1481
|
'mail.magic_link.code_subject': 'Seu código de login',
|
|
1448
1482
|
'mail.magic_link.code_intro': 'Use o código abaixo para entrar. Ele expira em instantes e serve para um único acesso.',
|
|
1449
1483
|
'mail.magic_link.code_only_label': 'Digite este código para entrar:',
|
|
1450
|
-
// Código do Mediated Sign-In do Poppy — ver o comentário no catálogo `en`.
|
|
1451
|
-
'mail.poppy_sign_in.subject': 'Seu código para conectar {agent}',
|
|
1452
|
-
'mail.poppy_sign_in.heading': 'Conecte {agent} à sua conta',
|
|
1453
|
-
'mail.poppy_sign_in.intro': '{agent} pediu para entrar na sua conta. Se foi você, informe o código abaixo. Ele expira em {minutes} minutos e serve uma única vez.',
|
|
1454
|
-
'mail.poppy_sign_in.code_label': 'Seu código:',
|
|
1455
|
-
'mail.poppy_sign_in.fallback': 'Se não foi você, ignore este e-mail — ninguém entra sem o código. Nunca o compartilhe com outra pessoa.',
|
|
1456
1484
|
// Link de CONFIRMAÇÃO DE IDENTIDADE (sudo) — ver o comentário no catálogo `en`.
|
|
1457
1485
|
'mail.sudo_link.subject': 'Confirme que é você',
|
|
1458
1486
|
'mail.sudo_link.heading': 'Confirme sua identidade',
|
|
@@ -1713,13 +1741,27 @@ export const BUILTIN_MESSAGES = {
|
|
|
1713
1741
|
* overrides do host por cima. Sem config, retorna o default `en` intacto.
|
|
1714
1742
|
* Chaves omitidas caem no default `en` (fallback de cobertura).
|
|
1715
1743
|
*/
|
|
1744
|
+
/** Catálogos das `personalAgents.extensions`, por locale (ver {@link registerExtensionMessages}). */
|
|
1745
|
+
const extensionMessages = {};
|
|
1746
|
+
/**
|
|
1747
|
+
* Soma os catálogos de uma extension (`messages`) aos embutidos. Chamado quando o config resolve;
|
|
1748
|
+
* os overrides do host (`i18n.messages`) continuam vencendo.
|
|
1749
|
+
*/
|
|
1750
|
+
export function registerExtensionMessages(catalogs) {
|
|
1751
|
+
for (const [locale, messages] of Object.entries(catalogs)) {
|
|
1752
|
+
extensionMessages[locale] = { ...(extensionMessages[locale] ?? {}), ...messages };
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1716
1755
|
export function resolveMessages(i18n) {
|
|
1717
1756
|
const locale = i18n?.locale ?? DEFAULT_LOCALE;
|
|
1718
1757
|
// Base: sempre o default `en` para garantir cobertura total das chaves; o
|
|
1719
|
-
// catálogo embutido do locale (ex.: pt-BR) é mesclado por cima.
|
|
1758
|
+
// catálogo embutido do locale (ex.: pt-BR) é mesclado por cima. Os das extensions entram
|
|
1759
|
+
// em cada camada, abaixo dos overrides do host.
|
|
1720
1760
|
const base = {
|
|
1721
1761
|
...DEFAULT_MESSAGES,
|
|
1762
|
+
...(extensionMessages[DEFAULT_LOCALE] ?? {}),
|
|
1722
1763
|
...(BUILTIN_MESSAGES[locale] ?? {}),
|
|
1764
|
+
...(locale === DEFAULT_LOCALE ? {} : (extensionMessages[locale] ?? {})),
|
|
1723
1765
|
};
|
|
1724
1766
|
const overrides = i18n?.messages?.[locale];
|
|
1725
1767
|
if (!overrides)
|
|
@@ -36,6 +36,14 @@ export interface AuthThrottles {
|
|
|
36
36
|
* anti-brute-force do código adivinhável, ANTES do lockout por interaction.
|
|
37
37
|
*/
|
|
38
38
|
otpLogin: ThrottleMiddleware;
|
|
39
|
+
/**
|
|
40
|
+
* Actions das páginas de extension do console de conta, keyed pela CONTA da sessão
|
|
41
|
+
* (bucket `authkit_account_actions`). `accountActions` responde 429 com a tela
|
|
42
|
+
* `throttled` (formulários); `accountActionsJson` responde o 429 cru (JSON API) —
|
|
43
|
+
* mesmo bucket, mesma contagem.
|
|
44
|
+
*/
|
|
45
|
+
accountActions: ThrottleMiddleware;
|
|
46
|
+
accountActionsJson: ThrottleMiddleware;
|
|
39
47
|
}
|
|
40
48
|
/**
|
|
41
49
|
* Service do `@adonisjs/limiter` resolvido de forma preguiçosa. Tipado como `any`
|
|
@@ -6,6 +6,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
6
6
|
}
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
|
+
import { ACCOUNT_SESSION_KEY } from './account_session_key.js';
|
|
9
10
|
import { brandFor } from './branding.js';
|
|
10
11
|
let limiterServicePromise;
|
|
11
12
|
/**
|
|
@@ -73,6 +74,12 @@ function buildThrottle(name, bucket, store, keyOf) {
|
|
|
73
74
|
export function createAuthThrottles(config) {
|
|
74
75
|
if (!config.enabled)
|
|
75
76
|
return undefined;
|
|
77
|
+
const accountActions = buildThrottle('authkit_account_actions', config.accountActions ?? { points: 30, duration: '1 min' }, config.store, (ctx) => {
|
|
78
|
+
const accountId = ctx.session?.get?.(ACCOUNT_SESSION_KEY);
|
|
79
|
+
return typeof accountId === 'string' && accountId !== ''
|
|
80
|
+
? `account:${accountId}`
|
|
81
|
+
: `account-ip:${ctx.request.ip?.() ?? 'unknown'}`;
|
|
82
|
+
});
|
|
76
83
|
return {
|
|
77
84
|
// Login/signup/forgot/reset: keyed por IP (default do HttpLimiter).
|
|
78
85
|
// `friendly`: rota de BROWSER — 429 vira a tela themeável `throttled`
|
|
@@ -102,6 +109,8 @@ export function createAuthThrottles(config) {
|
|
|
102
109
|
// Verificação de código OTP: keyed por IP (default), bucket próprio e mais
|
|
103
110
|
// apertado que o login. O namespace do nome mantém a contagem separada.
|
|
104
111
|
otpLogin: withFriendly429(buildThrottle('authkit_otp_login', config.otpLogin, config.store)),
|
|
112
|
+
accountActions: withFriendly429(accountActions),
|
|
113
|
+
accountActionsJson: accountActions,
|
|
105
114
|
};
|
|
106
115
|
}
|
|
107
116
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Router } from '@adonisjs/core/http';
|
|
2
|
+
import { type AccountExtensionRouteEntry } from '../account/mount.js';
|
|
2
3
|
import type { AuthSocialConfig, RateLimitConfigInput } from '../define_config.js';
|
|
3
4
|
import { type AccountPathKey, type AccountPathsOptions } from './account_paths.js';
|
|
4
5
|
import type { PolicyRouteOption } from './config_locks.js';
|
|
@@ -25,6 +26,14 @@ export declare function wantsJson(ctx: any): boolean;
|
|
|
25
26
|
* As roles permitidas são resolvidas em runtime do `authkit.server` (config lazy).
|
|
26
27
|
*/
|
|
27
28
|
export declare const adminGuard: (ctx: any, next: () => Promise<void>) => Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* The admin console gate as the console switcher reads it: `{ allowed }`, never a response, never a
|
|
31
|
+
* throw. Used as the `authorize` of the admin console's `'agora.consoles'` entry.
|
|
32
|
+
*/
|
|
33
|
+
export declare function adminConsoleDecision(ctx: any): Promise<{
|
|
34
|
+
allowed: boolean;
|
|
35
|
+
reason?: 'unauthenticated' | 'forbidden';
|
|
36
|
+
}>;
|
|
28
37
|
/**
|
|
29
38
|
* Opções de montagem das rotas do host-kit.
|
|
30
39
|
*
|
|
@@ -304,6 +313,11 @@ export interface AuthHostRouteMap {
|
|
|
304
313
|
loginUrl: string;
|
|
305
314
|
/** Quais telas foram efetivamente montadas. */
|
|
306
315
|
screens: Record<keyof AccountScreensOptions, boolean>;
|
|
316
|
+
/**
|
|
317
|
+
* Account console extension pages (filled once every provider booted): id, path, label (a
|
|
318
|
+
* literal, or the message key) and order. `useAccountExtensions()` gives the localized nav.
|
|
319
|
+
*/
|
|
320
|
+
extensions: AccountExtensionRouteEntry[];
|
|
307
321
|
};
|
|
308
322
|
/** Console admin: prefixo resolvido, ou `null` quando não foi montado. */
|
|
309
323
|
admin: {
|