@serve.zone/dcrouter 18.5.0 → 18.6.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/deno.json +1 -1
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.dcrouter.d.ts +2 -1
- package/dist_ts/classes.dcrouter.js +4 -2
- package/dist_ts/db/documents/classes.gateway-mail-domain.doc.d.ts +16 -0
- package/dist_ts/db/documents/classes.gateway-mail-domain.doc.js +107 -0
- package/dist_ts/db/documents/index.d.ts +1 -0
- package/dist_ts/db/documents/index.js +2 -1
- package/dist_ts/email/classes.gateway-mail-domain.store.d.ts +11 -0
- package/dist_ts/email/classes.gateway-mail-domain.store.js +70 -0
- package/dist_ts/email/classes.workapp-mail-manager.d.ts +3 -23
- package/dist_ts/email/classes.workapp-mail-manager.js +18 -35
- package/dist_ts/email/gateway-mail-domain-authority.d.ts +44 -0
- package/dist_ts/email/gateway-mail-domain-authority.js +160 -0
- package/dist_ts/email/index.d.ts +2 -0
- package/dist_ts/email/index.js +3 -1
- package/dist_ts/opsserver/handlers/gatewayclient.handler.js +33 -1
- package/dist_ts/opsserver/helpers/gateway-client-auth.d.ts +2 -0
- package/dist_ts/opsserver/helpers/gateway-client-auth.js +5 -3
- package/dist_ts_migrations/index.js +196 -11
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/package.json +3 -3
- package/readme.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.dcrouter.ts +3 -1
- package/ts/db/documents/classes.gateway-mail-domain.doc.ts +42 -0
- package/ts/db/documents/index.ts +1 -0
- package/ts/email/classes.gateway-mail-domain.store.ts +89 -0
- package/ts/email/classes.workapp-mail-manager.ts +33 -70
- package/ts/email/gateway-mail-domain-authority.ts +222 -0
- package/ts/email/index.ts +2 -0
- package/ts/opsserver/handlers/gatewayclient.handler.ts +43 -1
- package/ts/opsserver/helpers/gateway-client-auth.ts +6 -2
- package/ts_web/00_commitinfo_data.ts +1 -1
|
@@ -32,7 +32,7 @@ export class GatewayClientHandler {
|
|
|
32
32
|
private async requireAuth(
|
|
33
33
|
request: { identity?: interfaces.data.IIdentity; apiToken?: string },
|
|
34
34
|
requiredScope?: interfaces.data.TApiTokenScope,
|
|
35
|
-
options: { allowCandidate?: boolean } = {},
|
|
35
|
+
options: { allowCandidate?: boolean; loadManagedZoneNames?: boolean } = {},
|
|
36
36
|
): Promise<TAuthContext> {
|
|
37
37
|
return await requireGatewayMachineAuth(
|
|
38
38
|
this.opsServerRef,
|
|
@@ -351,6 +351,48 @@ export class GatewayClientHandler {
|
|
|
351
351
|
),
|
|
352
352
|
);
|
|
353
353
|
|
|
354
|
+
this.typedrouter.addTypedHandler(
|
|
355
|
+
new plugins.typedrequest.TypedHandler<plugins.servezoneInterfaces.requests.gateway.IReq_GetGatewayClientMailDomainCount>(
|
|
356
|
+
'getGatewayClientMailDomainCount',
|
|
357
|
+
async (dataArg) => {
|
|
358
|
+
const auth = await this.requireAuth(dataArg, 'gateway-clients:read', {
|
|
359
|
+
loadManagedZoneNames: false,
|
|
360
|
+
});
|
|
361
|
+
this.assertCapability(auth, 'readMail');
|
|
362
|
+
const untypedRequest = dataArg as Record<string, unknown>;
|
|
363
|
+
for (const forbiddenKey of [
|
|
364
|
+
'owner',
|
|
365
|
+
'gatewayClientId',
|
|
366
|
+
'gatewayClientType',
|
|
367
|
+
'workHosterId',
|
|
368
|
+
'workHosterType',
|
|
369
|
+
'appInstanceId',
|
|
370
|
+
]) {
|
|
371
|
+
if (Object.prototype.hasOwnProperty.call(untypedRequest, forbiddenKey)) {
|
|
372
|
+
throw new plugins.typedrequest.TypedResponseError(
|
|
373
|
+
'mail-domain count ownership is derived from the gateway-client credential',
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (
|
|
378
|
+
auth.isAdmin
|
|
379
|
+
|| auth.policy?.role !== 'gatewayClient'
|
|
380
|
+
|| !auth.gatewayClient
|
|
381
|
+
|| !auth.policy.gatewayClient
|
|
382
|
+
) {
|
|
383
|
+
throw new plugins.typedrequest.TypedResponseError('gateway-client credential required');
|
|
384
|
+
}
|
|
385
|
+
const manager = this.opsServerRef.dcRouterRef.workAppMailManager;
|
|
386
|
+
return {
|
|
387
|
+
count: await manager.countMailDomains({
|
|
388
|
+
gatewayClientType: auth.gatewayClient.type,
|
|
389
|
+
gatewayClientId: auth.gatewayClient.id,
|
|
390
|
+
}),
|
|
391
|
+
};
|
|
392
|
+
},
|
|
393
|
+
),
|
|
394
|
+
);
|
|
395
|
+
|
|
354
396
|
this.typedrouter.addTypedHandler(
|
|
355
397
|
new plugins.typedrequest.TypedHandler<plugins.servezoneInterfaces.requests.gateway.IReq_GetGatewayClientDomains>(
|
|
356
398
|
'getGatewayClientDomains',
|
|
@@ -17,6 +17,8 @@ export type TGatewayCredentialState = 'candidate' | 'active' | 'manual';
|
|
|
17
17
|
|
|
18
18
|
export interface IRequireGatewayMachineAuthOptions {
|
|
19
19
|
allowCandidate?: boolean;
|
|
20
|
+
/** Skip managed DNS-domain loading for APIs that do not evaluate hostnames. */
|
|
21
|
+
loadManagedZoneNames?: boolean;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export function getGatewayCredentialState(
|
|
@@ -124,8 +126,10 @@ export async function requireGatewayMachineAuth(
|
|
|
124
126
|
scope: scopeArg,
|
|
125
127
|
requireAdminIdentity: false,
|
|
126
128
|
});
|
|
127
|
-
const managedZoneNames =
|
|
128
|
-
|
|
129
|
+
const managedZoneNames = optionsArg.loadManagedZoneNames === false
|
|
130
|
+
? []
|
|
131
|
+
: (await opsServerRefArg.dcRouterRef.dnsManager?.listDomains() || [])
|
|
132
|
+
.map((domainArg) => domainArg.name);
|
|
129
133
|
|
|
130
134
|
if (auth.isAdmin) {
|
|
131
135
|
return {
|