@capybara-hq/kernel 0.1.0-rc.58 → 0.1.0-rc.59
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/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.controller.d.ts +0 -5
- package/dist/catalog/org-catalog.controller.js +3 -17
- package/dist/catalog/org-catalog.schemas.d.ts +43 -0
- package/dist/catalog/org-catalog.schemas.js +43 -2
- package/dist/catalog/plugin-install.d.ts +2 -0
- package/dist/catalog/plugin-install.js +3 -3
- package/dist/channels/channels.schemas.d.ts +3 -0
- package/dist/channels/channels.schemas.js +8 -0
- package/dist/channels/connections.service.d.ts +17 -2
- package/dist/channels/connections.service.js +30 -5
- package/dist/channels/outbound.js +17 -0
- package/dist/conversations/events.d.ts +34 -0
- package/dist/conversations/events.js +24 -0
- package/dist/ctx/secrets.d.ts +8 -1
- package/dist/ctx/secrets.js +14 -1
- package/dist/db/kernel-schema.d.ts +19 -0
- package/dist/devices/working-root.d.ts +2 -3
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +10 -0
- package/dist/http/api.module.js +6 -0
- package/dist/identity/initial-passwords.job.d.ts +3 -3
- package/dist/identity/initial-passwords.job.js +7 -5
- package/dist/orgs/invitations.controller.d.ts +3 -11
- package/dist/orgs/invitations.controller.js +9 -10
- package/dist/orgs/invitations.service.d.ts +12 -2
- package/dist/orgs/invitations.service.js +14 -7
- package/dist/orgs/members.service.d.ts +12 -2
- package/dist/orgs/members.service.js +10 -8
- package/dist/orgs/orgs.controller.d.ts +4 -12
- package/dist/orgs/orgs.controller.js +10 -10
- package/dist/orgs/orgs.schemas.d.ts +26 -0
- package/dist/orgs/orgs.schemas.js +22 -0
- package/dist/platform/connector-person-fields.d.ts +67 -0
- package/dist/platform/connector-person-fields.js +129 -0
- package/dist/platform/exclusions.js +5 -100
- package/dist/platform/operation.d.ts +31 -0
- package/dist/platform/operation.js +3 -3
- package/dist/platform/ops/accounts.ops.js +1 -0
- package/dist/platform/ops/channels.ops.d.ts +10 -3
- package/dist/platform/ops/channels.ops.js +223 -5
- package/dist/platform/ops/connectors.ops.d.ts +22 -4
- package/dist/platform/ops/connectors.ops.js +664 -13
- package/dist/platform/ops/org-plugins.ops.d.ts +15 -2
- package/dist/platform/ops/org-plugins.ops.js +323 -4
- package/dist/platform/ops/orgs.ops.d.ts +40 -3
- package/dist/platform/ops/orgs.ops.js +293 -12
- package/dist/platform/ops/person-inputs.d.ts +30 -0
- package/dist/platform/ops/person-inputs.js +50 -0
- package/dist/platform/ops/plugins.ops.d.ts +1 -1
- package/dist/platform/ops/plugins.ops.js +6 -6
- package/dist/platform/parity.d.ts +3 -2
- package/dist/platform/parity.js +40 -15
- package/dist/platform/person-fields.d.ts +20 -4
- package/dist/platform/person-fields.js +27 -5
- package/dist/platform/platform.module.d.ts +2 -1
- package/dist/platform/platform.module.js +5 -3
- package/dist/platform/route-schemas.js +2 -0
- package/dist/platform/sealed-reveals.controller.d.ts +20 -0
- package/dist/platform/sealed-reveals.controller.js +48 -0
- package/dist/platform/sealed-reveals.d.ts +52 -0
- package/dist/platform/sealed-reveals.js +153 -0
- package/dist/runtime/project/knowledge.js +24 -19
- package/dist/sandbox/permission-facts.d.ts +5 -1
- package/dist/sandbox/permission-facts.js +8 -2
- package/dist/setup/setup-guides.service.d.ts +5 -0
- package/dist/setup/setup-guides.service.js +2 -1
- package/dist/tools/approvals.service.js +1 -1
- package/dist/tools/builtins/platform.js +48 -8
- package/dist/tools/connectors.controller.d.ts +6 -7
- package/dist/tools/connectors.controller.js +4 -44
- package/dist/tools/connectors.schemas.d.ts +170 -1
- package/dist/tools/connectors.schemas.js +82 -3
- package/dist/tools/connectors.service.d.ts +16 -6
- package/dist/tools/connectors.service.js +39 -24
- package/dist/tools/oauth/oauth.controller.d.ts +3 -6
- package/dist/tools/oauth/oauth.controller.js +3 -12
- package/dist/tools/oauth/oauth.schemas.d.ts +14 -0
- package/dist/tools/oauth/oauth.schemas.js +27 -0
- package/dist/tools/pipeline.d.ts +7 -0
- package/dist/tools/pipeline.js +13 -4
- package/dist/tools/policy.d.ts +3 -2
- package/dist/tools/policy.js +4 -2
- package/dist/tools/registry.d.ts +7 -0
- package/package.json +4 -4
- package/src/migrations/0170_platform_sealed_reveals.sql +27 -0
|
@@ -19,12 +19,15 @@ import { AccountsService } from "../../identity/accounts.js";
|
|
|
19
19
|
import { DEPLOYMENT_SETTINGS_PATCH, SettingsService } from "../../identity/settings.js";
|
|
20
20
|
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
21
21
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
22
|
+
import { InvitationsService } from "../../orgs/invitations.service.js";
|
|
22
23
|
import { MembersService } from "../../orgs/members.service.js";
|
|
23
24
|
import { OrgNetworkAllowances } from "../../orgs/network-allowances.service.js";
|
|
24
|
-
import { networkAllowanceView, OrgUpdateBody } from "../../orgs/orgs.schemas.js";
|
|
25
|
+
import { InvitationCreateBody, InvitationIdParams, MemberParams, MemberRoleBody, networkAllowanceView, OrgUpdateBody, } from "../../orgs/orgs.schemas.js";
|
|
25
26
|
import { OrgsService } from "../../orgs/orgs.service.js";
|
|
27
|
+
import { roleAtLeast } from "../../orgs/roles.js";
|
|
26
28
|
import { defineOperation } from "../operation.js";
|
|
27
29
|
import { PlatformOperations } from "../registry.js";
|
|
30
|
+
import { SEALED_REVEAL_TTL_MS, SealedReveals } from "../sealed-reveals.js";
|
|
28
31
|
import { precheckBy, viaAgent } from "./errors.js";
|
|
29
32
|
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
30
33
|
import { roleOf } from "./role.js";
|
|
@@ -45,16 +48,80 @@ async function limitsOf(settings, orgId) {
|
|
|
45
48
|
subagents: s.subagentLimitOverrides[orgId] ?? null,
|
|
46
49
|
};
|
|
47
50
|
}
|
|
51
|
+
/** The role names a card summary uses. */
|
|
52
|
+
const ROLE_WORDS = {
|
|
53
|
+
owner: { zh: "所有者", en: "owner" },
|
|
54
|
+
admin: { zh: "管理员", en: "admin" },
|
|
55
|
+
member: { zh: "成员", en: "member" },
|
|
56
|
+
guest: { zh: "访客", en: "guest" },
|
|
57
|
+
};
|
|
58
|
+
/** What `orgs.invite` returns in place of the token (model-visible English). */
|
|
59
|
+
export const INVITATION_LINK_NOTE = `The invitation link is shown once, on the web, to the person who approved this call (on the approval card); they share it with the invitee. It is not shown to you. If it is not read within ${SEALED_REVEAL_TTL_MS / 3_600_000} hours it is lost: revoke the invitation (orgs.revoke-invitation) and invite again.`;
|
|
60
|
+
/**
|
|
61
|
+
* Why a member operation through the tool is never offered (spec §7.2, maintainer decision Q2):
|
|
62
|
+
* the actor's own membership (`member.self`), an owner or granting owner
|
|
63
|
+
* (`member.owner_untouchable`), or a role above the actor's own (`member.role_above_actor`). Null:
|
|
64
|
+
* allowed here; the service's own checks still run. A target that is no member is left to the
|
|
65
|
+
* service (`member.not_found`).
|
|
66
|
+
*/
|
|
67
|
+
export function memberChangeRefusal(actor, target, role) {
|
|
68
|
+
if (target.id === actor.id) {
|
|
69
|
+
return {
|
|
70
|
+
code: "member.self",
|
|
71
|
+
message: "The Platform tool never changes or removes your own membership",
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (target.role === "owner" || role === "owner") {
|
|
75
|
+
return {
|
|
76
|
+
code: "member.owner_untouchable",
|
|
77
|
+
message: "The Platform tool never touches an owner or makes anyone an owner",
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return role === undefined ? null : roleAboveActor(actor.role, role);
|
|
81
|
+
}
|
|
82
|
+
/** `member.role_above_actor` when `role` is above the actor's own (or the actor has none). */
|
|
83
|
+
export function roleAboveActor(actorRole, role) {
|
|
84
|
+
return actorRole !== null && roleAtLeast(actorRole, role)
|
|
85
|
+
? null
|
|
86
|
+
: {
|
|
87
|
+
code: "member.role_above_actor",
|
|
88
|
+
message: `The Platform tool never gives a role above your own (${actorRole ?? "none"})`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** Throws a refusal as the {@link ApiError} of its code. */
|
|
92
|
+
function refuse(r) {
|
|
93
|
+
if (r !== null)
|
|
94
|
+
throw new ApiError(r.code, r.message);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The member service's guard (`MemberWriteOptions.guard`): {@link memberChangeRefusal} on the roles
|
|
98
|
+
* read under the org row lock, so a role that changed after the precheck is still refused.
|
|
99
|
+
*/
|
|
100
|
+
const memberGuard = (actorId, targetId, role) => (actorRole, targetRole) => refuse(memberChangeRefusal({ id: actorId, role: actorRole }, { id: targetId, role: targetRole }, role));
|
|
101
|
+
/** The invitation as the tool shows it: never a token (the list has none; create's is sealed). */
|
|
102
|
+
const invitationView = (i) => ({
|
|
103
|
+
id: i.id,
|
|
104
|
+
role: i.role,
|
|
105
|
+
...(i.status !== undefined && { status: i.status }),
|
|
106
|
+
createdBy: i.createdBy,
|
|
107
|
+
createdAt: i.createdAt,
|
|
108
|
+
expiresAt: i.expiresAt,
|
|
109
|
+
acceptedAt: i.acceptedAt,
|
|
110
|
+
revokedAt: i.revokedAt,
|
|
111
|
+
});
|
|
48
112
|
/**
|
|
49
113
|
* Org operations of the `Platform` tool (spec §14.2): the super admin's view of every org (list,
|
|
50
114
|
* get, the per-org limits) through their own private agent, and the conversation's org for its
|
|
51
|
-
* members (read, rename, member list, the org audit log for its admins)
|
|
52
|
-
*
|
|
115
|
+
* members (read, rename, member list, the org audit log for its admins), and member management for
|
|
116
|
+
* its admins (invite, revoke, role change, remove; platform web parity spec §7.2: never self, never
|
|
117
|
+
* an owner, never above the actor). Creating, deleting and transferring an org stay on the web.
|
|
53
118
|
*/
|
|
54
119
|
let OrgsOperations = class OrgsOperations {
|
|
55
120
|
registry;
|
|
56
121
|
orgs;
|
|
57
122
|
members;
|
|
123
|
+
invitations;
|
|
124
|
+
reveals;
|
|
58
125
|
settings;
|
|
59
126
|
accounts;
|
|
60
127
|
config;
|
|
@@ -62,10 +129,12 @@ let OrgsOperations = class OrgsOperations {
|
|
|
62
129
|
audit;
|
|
63
130
|
networkAdmin;
|
|
64
131
|
allowances;
|
|
65
|
-
constructor(registry, orgs, members, settings, accounts, config, kdb, audit, networkAdmin, allowances) {
|
|
132
|
+
constructor(registry, orgs, members, invitations, reveals, settings, accounts, config, kdb, audit, networkAdmin, allowances) {
|
|
66
133
|
this.registry = registry;
|
|
67
134
|
this.orgs = orgs;
|
|
68
135
|
this.members = members;
|
|
136
|
+
this.invitations = invitations;
|
|
137
|
+
this.reveals = reveals;
|
|
69
138
|
this.settings = settings;
|
|
70
139
|
this.accounts = accounts;
|
|
71
140
|
this.config = config;
|
|
@@ -87,6 +156,26 @@ let OrgsOperations = class OrgsOperations {
|
|
|
87
156
|
throw new ApiError("forbidden", "Your account no longer exists");
|
|
88
157
|
return a;
|
|
89
158
|
}
|
|
159
|
+
/** The precheck of a member operation: {@link memberChangeRefusal} on the roles read now. */
|
|
160
|
+
async memberCheck(ctx, targetId, role) {
|
|
161
|
+
const [actorRole, targetRole] = await Promise.all([
|
|
162
|
+
roleOf(this.kdb.db, ctx.orgId, ctx.actorAccountId),
|
|
163
|
+
roleOf(this.kdb.db, ctx.orgId, targetId),
|
|
164
|
+
]);
|
|
165
|
+
const refused = memberChangeRefusal({ id: ctx.actorAccountId, role: actorRole }, { id: targetId, role: targetRole }, role);
|
|
166
|
+
return refused === null ? { ok: true } : { ok: false, ...refused };
|
|
167
|
+
}
|
|
168
|
+
/** The precheck of `orgs.invite`, and its run's check: never a role above the actor's. */
|
|
169
|
+
async inviteRefusal(ctx, role) {
|
|
170
|
+
return roleAboveActor(await roleOf(this.kdb.db, ctx.orgId, ctx.actorAccountId), role);
|
|
171
|
+
}
|
|
172
|
+
/** The member's display name for a card; the id when unknown. */
|
|
173
|
+
async memberName(accountId) {
|
|
174
|
+
return orElse(async () => {
|
|
175
|
+
const a = await this.accounts.get(accountId);
|
|
176
|
+
return a === undefined || a === null ? accountId : named(a.displayName);
|
|
177
|
+
}, accountId);
|
|
178
|
+
}
|
|
90
179
|
/** The org's allowance `id` (for a card and the remove precheck); none → the remove's 404. */
|
|
91
180
|
async allowance(orgId, id) {
|
|
92
181
|
const a = (await this.networkAdmin.list(orgId)).find((x) => x.id === id);
|
|
@@ -395,7 +484,7 @@ let OrgsOperations = class OrgsOperations {
|
|
|
395
484
|
}),
|
|
396
485
|
defineOperation({
|
|
397
486
|
id: "orgs.members",
|
|
398
|
-
description: "List the members of this conversation's org, one compact row each: account id, display name, role, email and when they joined.
|
|
487
|
+
description: "List the members of this conversation's org, one compact row each: account id, display name, role, email and when they joined. Org admins change roles with orgs.set-member-role and remove members with orgs.remove-member. Pages by 50: pass the returned next as params.cursor.",
|
|
399
488
|
input: z.object({ cursor: Cursor.optional() }).strict(),
|
|
400
489
|
example: {},
|
|
401
490
|
authz: { orgAction: "org.members.read" },
|
|
@@ -411,6 +500,196 @@ let OrgsOperations = class OrgsOperations {
|
|
|
411
500
|
...(m.anonymous && { anonymous: true }),
|
|
412
501
|
})), startOf(input.cursor), PAGE),
|
|
413
502
|
}),
|
|
503
|
+
defineOperation({
|
|
504
|
+
id: "orgs.invitations",
|
|
505
|
+
description: "List the invitations of this conversation's org (org admins), oldest first: id, role, status (pending, accepted, expired or revoked), who created it and when, when it expires. Never the link: an invitation's link is shown only once, to the person who approved its creation.",
|
|
506
|
+
input: z.object({ cursor: Cursor.optional() }).strict(),
|
|
507
|
+
example: {},
|
|
508
|
+
authz: { orgAction: "org.invitations.manage" },
|
|
509
|
+
mirrors: ["GET /api/v1/orgs/:orgId/invitations"],
|
|
510
|
+
extras: ["cursor"],
|
|
511
|
+
confirm: "read",
|
|
512
|
+
run: async (input, ctx) => pageOf((await this.invitations.list(ctx.orgId)).map(invitationView), startOf(input.cursor), PAGE),
|
|
513
|
+
}),
|
|
514
|
+
defineOperation({
|
|
515
|
+
id: "orgs.invite",
|
|
516
|
+
description: "Invite a person into this conversation's org (org admins) with a role: admin, member or guest (never owner; never above your own role). expiresInHours is 1 to 720 (default 168). You never see the link: it is shown once, on the web, to the person who approves this call (on the approval card), who shares it with the invitee. If it is not read within 24 hours it is lost: revoke the invitation (orgs.revoke-invitation) and invite again.",
|
|
517
|
+
input: InvitationCreateBody.strict(),
|
|
518
|
+
example: { role: "member" },
|
|
519
|
+
authz: { orgAction: "org.invitations.manage" },
|
|
520
|
+
mirrors: ["POST /api/v1/orgs/:orgId/invitations"],
|
|
521
|
+
confirm: "org",
|
|
522
|
+
rememberable: false,
|
|
523
|
+
revealsToApprover: true,
|
|
524
|
+
errors: [
|
|
525
|
+
{
|
|
526
|
+
code: "member.role_above_actor",
|
|
527
|
+
next: "Invite with a role no higher than your own, or ask an owner to invite on the web.",
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
code: "invitation.create_needs_approval",
|
|
531
|
+
next: "Call it from a conversation where you approve the call yourself, or invite on the web (the org's Members page).",
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
code: "validation_failed",
|
|
535
|
+
next: "Pass role admin, member or guest and expiresInHours from 1 to 720.",
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
precheck: async (i, ctx) => {
|
|
539
|
+
const refused = await this.inviteRefusal(ctx, i.role);
|
|
540
|
+
return refused === null ? { ok: true } : { ok: false, ...refused };
|
|
541
|
+
},
|
|
542
|
+
summary: (i) => {
|
|
543
|
+
const h = i.expiresInHours;
|
|
544
|
+
return {
|
|
545
|
+
zh: `邀请一位${ROLE_WORDS[i.role].zh}加入本组织${h === undefined ? "" : `,${h} 小时后过期`};批准后邀请链接仅向你显示一次`,
|
|
546
|
+
en: `Invite a new ${ROLE_WORDS[i.role].en} into this org${h === undefined ? "" : `, expiring in ${h} hours`}; the invitation link is shown once to you after approval`,
|
|
547
|
+
};
|
|
548
|
+
},
|
|
549
|
+
run: async (input, ctx) => {
|
|
550
|
+
if (ctx.callId === undefined || ctx.runId === null) {
|
|
551
|
+
// the link reaches the approver through the approved call; without one it could never
|
|
552
|
+
// be shown, so nothing is created
|
|
553
|
+
throw new ApiError("invitation.create_needs_approval", "orgs.invite runs only as a Platform call you approve in a conversation");
|
|
554
|
+
}
|
|
555
|
+
// the service re-checks the role under the org row lock (`forbidden`)
|
|
556
|
+
refuse(await this.inviteRefusal(ctx, input.role));
|
|
557
|
+
const to = {
|
|
558
|
+
conversationId: ctx.conversationId,
|
|
559
|
+
runId: ctx.runId,
|
|
560
|
+
callId: ctx.callId,
|
|
561
|
+
recipientAccountId: ctx.actorAccountId,
|
|
562
|
+
};
|
|
563
|
+
const { invitation } = await this.invitations.create(ctx.orgId, input, ctx.actorAccountId, undefined, {
|
|
564
|
+
auditDetail: viaAgent("orgs.invite", ctx),
|
|
565
|
+
inTransaction: (inv, token) => this.reveals.sealIn(ctx.orgId, inv.id, token, to),
|
|
566
|
+
});
|
|
567
|
+
return { invitation: invitationView(invitation), link: INVITATION_LINK_NOTE };
|
|
568
|
+
},
|
|
569
|
+
}),
|
|
570
|
+
defineOperation({
|
|
571
|
+
id: "orgs.revoke-invitation",
|
|
572
|
+
description: "Revoke an invitation of this conversation's org (org admins) by its id (orgs.invitations): its link stops working at once. An accepted invitation cannot be revoked (remove the member instead); revoking one already revoked does nothing.",
|
|
573
|
+
input: z.object({ invitationId: InvitationIdParams.shape.id }).strict(),
|
|
574
|
+
example: { invitationId: "00000000-0000-4000-8000-000000000000" },
|
|
575
|
+
authz: { orgAction: "org.invitations.manage" },
|
|
576
|
+
mirrors: ["DELETE /api/v1/orgs/:orgId/invitations/:id"],
|
|
577
|
+
renames: { invitationId: "id" },
|
|
578
|
+
confirm: "org",
|
|
579
|
+
rememberable: false,
|
|
580
|
+
errors: [
|
|
581
|
+
{
|
|
582
|
+
code: "invitation.invalid",
|
|
583
|
+
next: "List the invitations with orgs.invitations and pass one of their ids.",
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
code: "invitation.used",
|
|
587
|
+
next: "The invitation was accepted; remove the member with orgs.remove-member if they should leave.",
|
|
588
|
+
},
|
|
589
|
+
],
|
|
590
|
+
summary: async (i, ctx) => {
|
|
591
|
+
const inv = await orElse(async () => (await this.invitations.list(ctx.orgId)).find((x) => x.id === i.invitationId), undefined);
|
|
592
|
+
const role = inv === undefined ? undefined : ROLE_WORDS[inv.role];
|
|
593
|
+
return {
|
|
594
|
+
zh: `撤销${role === undefined ? "" : `${role.zh}`}邀请 ${i.invitationId},它的链接将立即失效`,
|
|
595
|
+
en: `Revoke the ${role === undefined ? "" : `${role.en} `}invitation ${i.invitationId}; its link stops working at once`,
|
|
596
|
+
};
|
|
597
|
+
},
|
|
598
|
+
run: async (input, ctx) => {
|
|
599
|
+
await this.invitations.revoke(ctx.orgId, input.invitationId, ctx.actorAccountId, undefined, viaAgent("orgs.revoke-invitation", ctx));
|
|
600
|
+
return { id: input.invitationId, revoked: true };
|
|
601
|
+
},
|
|
602
|
+
}),
|
|
603
|
+
defineOperation({
|
|
604
|
+
id: "orgs.set-member-role",
|
|
605
|
+
description: "Change a member's role in this conversation's org (org admins): guest, member or admin, never above your own role. Never offered: changing your own role, changing an owner's role or making anyone an owner (an owner does that on the web).",
|
|
606
|
+
input: MemberParams.extend(MemberRoleBody.shape).strict(),
|
|
607
|
+
example: { accountId: "00000000-0000-4000-8000-000000000000", role: "member" },
|
|
608
|
+
authz: { orgAction: "org.members.manage" },
|
|
609
|
+
mirrors: ["PATCH /api/v1/orgs/:orgId/members/:accountId"],
|
|
610
|
+
confirm: "org",
|
|
611
|
+
rememberable: false,
|
|
612
|
+
errors: [
|
|
613
|
+
{
|
|
614
|
+
code: "member.role_above_actor",
|
|
615
|
+
next: "Choose a role no higher than your own, or ask an owner to change it on the web.",
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
code: "member.self",
|
|
619
|
+
next: "Your own membership is changed by you on the web, never through this tool.",
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
code: "member.owner_untouchable",
|
|
623
|
+
next: "Owners and ownership are changed by an owner on the web (the org's Members page), never through this tool.",
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
code: "member.not_found",
|
|
627
|
+
next: "List the members with orgs.members and pass one of their ids.",
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
code: "member.anonymous_guest",
|
|
631
|
+
next: "The anonymous guest has no role to change; switch the channel connection back to binding on the web if it is no longer wanted.",
|
|
632
|
+
},
|
|
633
|
+
],
|
|
634
|
+
precheck: (i, ctx) => this.memberCheck(ctx, i.accountId, i.role),
|
|
635
|
+
summary: async (i) => {
|
|
636
|
+
const name = await this.memberName(i.accountId);
|
|
637
|
+
return {
|
|
638
|
+
zh: `将成员「${name}」的角色改为${ROLE_WORDS[i.role].zh}`,
|
|
639
|
+
en: `Change the role of member "${name}" to ${ROLE_WORDS[i.role].en}`,
|
|
640
|
+
};
|
|
641
|
+
},
|
|
642
|
+
run: async (input, ctx) => {
|
|
643
|
+
await this.members.changeRole(ctx.orgId, input.accountId, input.role, ctx.actorAccountId, undefined, {
|
|
644
|
+
auditDetail: viaAgent("orgs.set-member-role", ctx),
|
|
645
|
+
guard: memberGuard(ctx.actorAccountId, input.accountId, input.role),
|
|
646
|
+
});
|
|
647
|
+
return { accountId: input.accountId, role: input.role };
|
|
648
|
+
},
|
|
649
|
+
}),
|
|
650
|
+
defineOperation({
|
|
651
|
+
id: "orgs.remove-member",
|
|
652
|
+
description: "Remove a member from this conversation's org (org admins): they lose access at once; every session and personal access token of the account is revoked, their runs in the org stop, their devices and file shares in the org are removed, and the org agents they own pass to an owner for reassignment. Never offered: removing yourself or an owner.",
|
|
653
|
+
input: MemberParams.strict(),
|
|
654
|
+
example: { accountId: "00000000-0000-4000-8000-000000000000" },
|
|
655
|
+
authz: { orgAction: "org.members.manage" },
|
|
656
|
+
mirrors: ["DELETE /api/v1/orgs/:orgId/members/:accountId"],
|
|
657
|
+
confirm: "org",
|
|
658
|
+
rememberable: false,
|
|
659
|
+
errors: [
|
|
660
|
+
{
|
|
661
|
+
code: "member.self",
|
|
662
|
+
next: "Your own membership is changed by you on the web, never through this tool.",
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
code: "member.owner_untouchable",
|
|
666
|
+
next: "Owners and ownership are changed by an owner on the web (the org's Members page), never through this tool.",
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
code: "member.not_found",
|
|
670
|
+
next: "List the members with orgs.members and pass one of their ids.",
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
code: "member.anonymous_guest",
|
|
674
|
+
next: "The anonymous guest cannot be removed; switch the channel connection back to binding on the web if anonymous access is no longer wanted.",
|
|
675
|
+
},
|
|
676
|
+
],
|
|
677
|
+
precheck: (i, ctx) => this.memberCheck(ctx, i.accountId),
|
|
678
|
+
summary: async (i) => {
|
|
679
|
+
const name = await this.memberName(i.accountId);
|
|
680
|
+
return {
|
|
681
|
+
zh: `将成员「${name}」移出本组织,其访问权限立即失效`,
|
|
682
|
+
en: `Remove member "${name}" from this org; their access ends at once`,
|
|
683
|
+
};
|
|
684
|
+
},
|
|
685
|
+
run: async (input, ctx) => {
|
|
686
|
+
await this.members.remove(ctx.orgId, input.accountId, ctx.actorAccountId, undefined, {
|
|
687
|
+
auditDetail: viaAgent("orgs.remove-member", ctx),
|
|
688
|
+
guard: memberGuard(ctx.actorAccountId, input.accountId),
|
|
689
|
+
});
|
|
690
|
+
return { accountId: input.accountId, removed: true };
|
|
691
|
+
},
|
|
692
|
+
}),
|
|
414
693
|
defineOperation({
|
|
415
694
|
id: "orgs.audit",
|
|
416
695
|
description: "The audit log of this conversation's org (org admins), newest first: members and invitations, settings, agents, connectors, skills, plugins and extensions in the org, channels, schedules. Each event has its id, time, actor (id, name, email; null for the kernel itself), viaToken (done with a personal access token), viaAgent (done through the Platform tool), action and target; never the event's details. action filters by an action name or its prefix (e.g. org.member.). limit is 1 to 100 (default 20); pages by keyset: pass the returned next as params.after (null: no more).",
|
|
@@ -429,12 +708,14 @@ OrgsOperations = __decorate([
|
|
|
429
708
|
__param(0, Inject(PlatformOperations)),
|
|
430
709
|
__param(1, Inject(OrgsService)),
|
|
431
710
|
__param(2, Inject(MembersService)),
|
|
432
|
-
__param(3, Inject(
|
|
433
|
-
__param(4, Inject(
|
|
434
|
-
__param(5, Inject(
|
|
435
|
-
__param(6, Inject(
|
|
436
|
-
__param(7, Inject(
|
|
437
|
-
__param(8, Inject(
|
|
438
|
-
__param(9, Inject(
|
|
711
|
+
__param(3, Inject(InvitationsService)),
|
|
712
|
+
__param(4, Inject(SealedReveals)),
|
|
713
|
+
__param(5, Inject(SettingsService)),
|
|
714
|
+
__param(6, Inject(AccountsService)),
|
|
715
|
+
__param(7, Inject(KernelConfigService)),
|
|
716
|
+
__param(8, Inject(KernelDb)),
|
|
717
|
+
__param(9, Inject(AuditLogService)),
|
|
718
|
+
__param(10, Inject(OrgNetworkAdmin)),
|
|
719
|
+
__param(11, Inject(OrgNetworkAllowances))
|
|
439
720
|
], OrgsOperations);
|
|
440
721
|
export { OrgsOperations };
|
|
@@ -7,6 +7,36 @@ import type { OperationContext } from "../operation.js";
|
|
|
7
7
|
* paths, never the values) when the person entered any (spec §10).
|
|
8
8
|
*/
|
|
9
9
|
export declare function withPersonInputs<T>(operation: string, ctx: OperationContext, write: (entered: Readonly<Record<string, string>>, auditDetail: Record<string, unknown>) => Promise<T>): Promise<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Ruling R11 (platform web parity plan): the one exception to "the write runs inside
|
|
12
|
+
* `personInputs.apply`". The catalog install runs `requires_new` steps that take the org row lock;
|
|
13
|
+
* inside `apply`, `connectors.create` would take that lock in the consuming transaction and the
|
|
14
|
+
* next step would wait on it for good. Such a write takes the values first and runs outside.
|
|
15
|
+
*
|
|
16
|
+
* The person's card values for a write that cannot run inside the consuming transaction: one made
|
|
17
|
+
* of several transactions of its own (`requires_new` steps under the org row lock, such as the
|
|
18
|
+
* catalog install), which would wait on a lock the consuming transaction holds. The values are
|
|
19
|
+
* consumed in a short transaction of their own and returned with the audit detail
|
|
20
|
+
* ({@link withPersonInputs}'s); the write then runs outside it. A write that fails after this
|
|
21
|
+
* leaves nothing to retry with: the call is made again, with a new card, like any failed call.
|
|
22
|
+
*/
|
|
23
|
+
export declare function takePersonInputs(operation: string, ctx: OperationContext): Promise<{
|
|
24
|
+
entered: Readonly<Record<string, string>>;
|
|
25
|
+
auditDetail: Record<string, unknown>;
|
|
26
|
+
}>;
|
|
27
|
+
/** What the model is told after a failed write consumed the person's values. */
|
|
28
|
+
export declare const VALUES_USED_UP_TEXT = "The values the person entered were used up: calling the operation again shows a new card where the person enters them again.";
|
|
29
|
+
/**
|
|
30
|
+
* The error of a write that failed after {@link takePersonInputs} consumed the values: the same
|
|
31
|
+
* error (an `ApiError` keeps its code and details, a `ToolError` its kind), its message saying the
|
|
32
|
+
* values are gone and the person enters them again on a new card. Any other error becomes a
|
|
33
|
+
* `ToolError` naming only its class (as the pipeline would), with the original as `cause`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function afterTaken(e: unknown, entered: Readonly<Record<string, string>>): unknown;
|
|
36
|
+
/**
|
|
37
|
+
* The values under `prefix` (`connectors.<templateId>.`), keyed by the rest of their path.
|
|
38
|
+
*/
|
|
39
|
+
export declare function enteredUnder(entered: Readonly<Record<string, string>>, prefix: string): Record<string, string>;
|
|
10
40
|
/**
|
|
11
41
|
* The `values` of a config route keyed by field dot path (deployment config, the org's copy): the
|
|
12
42
|
* model's non-secret values, the person's entered secrets, and `null` (clear) for each path in
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ToolError } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { ApiError } from "../../errors.js";
|
|
1
3
|
import { setDeep } from "../../extensions/deployment-config-store.js";
|
|
2
4
|
import { viaAgent } from "./errors.js";
|
|
3
5
|
import { named } from "./summary.js";
|
|
@@ -14,6 +16,54 @@ export function withPersonInputs(operation, ctx, write) {
|
|
|
14
16
|
return write({}, base);
|
|
15
17
|
return ctx.personInputs.apply((values) => write(values, { ...base, inputsProvided: Object.keys(values).sort() }));
|
|
16
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Ruling R11 (platform web parity plan): the one exception to "the write runs inside
|
|
21
|
+
* `personInputs.apply`". The catalog install runs `requires_new` steps that take the org row lock;
|
|
22
|
+
* inside `apply`, `connectors.create` would take that lock in the consuming transaction and the
|
|
23
|
+
* next step would wait on it for good. Such a write takes the values first and runs outside.
|
|
24
|
+
*
|
|
25
|
+
* The person's card values for a write that cannot run inside the consuming transaction: one made
|
|
26
|
+
* of several transactions of its own (`requires_new` steps under the org row lock, such as the
|
|
27
|
+
* catalog install), which would wait on a lock the consuming transaction holds. The values are
|
|
28
|
+
* consumed in a short transaction of their own and returned with the audit detail
|
|
29
|
+
* ({@link withPersonInputs}'s); the write then runs outside it. A write that fails after this
|
|
30
|
+
* leaves nothing to retry with: the call is made again, with a new card, like any failed call.
|
|
31
|
+
*/
|
|
32
|
+
export async function takePersonInputs(operation, ctx) {
|
|
33
|
+
return withPersonInputs(operation, ctx, async (entered, auditDetail) => ({
|
|
34
|
+
entered: { ...entered },
|
|
35
|
+
auditDetail,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
/** What the model is told after a failed write consumed the person's values. */
|
|
39
|
+
export const VALUES_USED_UP_TEXT = "The values the person entered were used up: calling the operation again shows a new card where the person enters them again.";
|
|
40
|
+
/**
|
|
41
|
+
* The error of a write that failed after {@link takePersonInputs} consumed the values: the same
|
|
42
|
+
* error (an `ApiError` keeps its code and details, a `ToolError` its kind), its message saying the
|
|
43
|
+
* values are gone and the person enters them again on a new card. Any other error becomes a
|
|
44
|
+
* `ToolError` naming only its class (as the pipeline would), with the original as `cause`.
|
|
45
|
+
*/
|
|
46
|
+
export function afterTaken(e, entered) {
|
|
47
|
+
if (Object.keys(entered).length === 0)
|
|
48
|
+
return e;
|
|
49
|
+
const told = (message) => `${message.trim().replace(/\.?$/, ".")} ${VALUES_USED_UP_TEXT}`;
|
|
50
|
+
if (e instanceof ApiError)
|
|
51
|
+
return new ApiError(e.code, told(e.message), e.details);
|
|
52
|
+
if (e instanceof ToolError)
|
|
53
|
+
return new ToolError(told(e.message), { kind: e.kind });
|
|
54
|
+
const name = e instanceof Error ? e.name : "Error";
|
|
55
|
+
const out = new ToolError(told(`The write failed (${name})`));
|
|
56
|
+
Object.defineProperty(out, "cause", { value: e });
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The values under `prefix` (`connectors.<templateId>.`), keyed by the rest of their path.
|
|
61
|
+
*/
|
|
62
|
+
export function enteredUnder(entered, prefix) {
|
|
63
|
+
return Object.fromEntries(Object.entries(entered)
|
|
64
|
+
.filter(([p]) => p.startsWith(prefix))
|
|
65
|
+
.map(([p, v]) => [p.slice(prefix.length), v]));
|
|
66
|
+
}
|
|
17
67
|
/**
|
|
18
68
|
* The `values` of a config route keyed by field dot path (deployment config, the org's copy): the
|
|
19
69
|
* model's non-secret values, the person's entered secrets, and `null` (clear) for each path in
|
|
@@ -8,7 +8,7 @@ import { ExtensionAvailability } from "../../extensions/unavailable.js";
|
|
|
8
8
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
9
9
|
import { PlatformOperations } from "../registry.js";
|
|
10
10
|
export { OTHER_ORG } from "./other-orgs.js";
|
|
11
|
-
export declare const NEEDS_INPUT = "This plugin needs
|
|
11
|
+
export declare const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials on the confirmation card.";
|
|
12
12
|
/** `plugin.needs_input` when what is missing is its extension's org config (an agent can set it). */
|
|
13
13
|
export declare const needsOrgConfig: (extension: string) => string;
|
|
14
14
|
/**
|
|
@@ -40,7 +40,7 @@ export { OTHER_ORG } from "./other-orgs.js";
|
|
|
40
40
|
const LOCKED = "This plugin is on for every org (or shipped with the platform) and cannot be switched off in one org.";
|
|
41
41
|
/** The confirm value of switching off a plugin with nothing installed in the org. */
|
|
42
42
|
const NOTHING_INSTALLED = "nothing-installed";
|
|
43
|
-
export const NEEDS_INPUT = "This plugin needs
|
|
43
|
+
export const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials on the confirmation card.";
|
|
44
44
|
/** `plugin.needs_input` when what is missing is its extension's org config (an agent can set it). */
|
|
45
45
|
export const needsOrgConfig = (extension) => `This plugin's extension ${extension} needs its org config first: read what is missing with extensions.org-config, fill it in with extensions.set-org-config (the person enters secrets on the confirmation card; the org's own copy of overridable platform fields is extensions.save-org-config), then call plugins.set-enabled again.`;
|
|
46
46
|
/** The English name of a plugin as next steps and messages name it. */
|
|
@@ -89,12 +89,12 @@ const hasConfigFields = (schema) => {
|
|
|
89
89
|
* Why switching the plugin on needs input first, as the `plugin.needs_input` message, or null: its
|
|
90
90
|
* extension's org config misses required values (an agent fills it in with
|
|
91
91
|
* `extensions.set-org-config`), or connector templates without their connector, or anything else
|
|
92
|
-
* the item's `needs_config` stands for (
|
|
92
|
+
* the item's `needs_config` stands for (connector input: `plugins.install`, `plugins.configure-connectors`). Unlike the web's
|
|
93
93
|
* install wizard, an org config form whose required values are all stored does not stop the switch.
|
|
94
94
|
*/
|
|
95
95
|
function needsInput(item, extensions) {
|
|
96
96
|
const own = extensions.find((e) => e.catalogItem?.itemId === item.id);
|
|
97
|
-
// `needs_config` also means connector templates without their connector
|
|
97
|
+
// `needs_config` also means connector templates without their connector
|
|
98
98
|
if (item.state === "needs_config") {
|
|
99
99
|
return own?.needsConfig === true ? needsOrgConfig(own.plugin) : NEEDS_INPUT;
|
|
100
100
|
}
|
|
@@ -222,7 +222,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
222
222
|
}),
|
|
223
223
|
defineOperation({
|
|
224
224
|
id: "plugins.set-enabled",
|
|
225
|
-
description: "Switch a plugin on or off in this org. Switching on installs it; a plugin whose enabling needs
|
|
225
|
+
description: "Switch a plugin on or off in this org. Switching on installs it; a plugin whose enabling needs connector input is refused: install it with plugins.install instead. Switching off removes what the plugin brought and needs confirm: the value plugins.disable-preview returned with the preview the person saw.",
|
|
226
226
|
input: z.discriminatedUnion("enabled", [
|
|
227
227
|
z.object({ itemId: ItemId, enabled: z.literal(true) }).strict(),
|
|
228
228
|
z.object({ itemId: ItemId, enabled: z.literal(false), confirm: Confirm }).strict(),
|
|
@@ -233,8 +233,8 @@ let PluginsOperations = class PluginsOperations {
|
|
|
233
233
|
authz: { orgAction: "org.extensions.manage" },
|
|
234
234
|
authzNote: "service-enforced",
|
|
235
235
|
mirrors: ["PUT /api/v1/orgs/:orgId/catalog/:itemId/switch"],
|
|
236
|
-
// install inputs a person enters on the web (a plugin that needs them is refused)
|
|
237
236
|
omits: ["inputs"],
|
|
237
|
+
withoutSecrets: "a plugin that needs install inputs is refused here; plugins.install takes them, its secrets entered by the person on the card",
|
|
238
238
|
loosens: {
|
|
239
239
|
confirm: "also takes `nothing-installed` (plugins.disable-preview's value when nothing is installed), which the route's hash pattern rejects; the service checks confirm only when something is installed",
|
|
240
240
|
},
|
|
@@ -262,7 +262,7 @@ let PluginsOperations = class PluginsOperations {
|
|
|
262
262
|
},
|
|
263
263
|
{
|
|
264
264
|
code: "plugin.needs_input",
|
|
265
|
-
next: "When its extension's org config is missing, fill it in with extensions.set-org-config (secrets in askPerson), then call again; connector
|
|
265
|
+
next: "When its extension's org config is missing, fill it in with extensions.set-org-config (secrets in askPerson), then call again; a plugin that needs connector input is installed with plugins.install (or plugins.configure-connectors once installed), the person entering the credentials on the card.",
|
|
266
266
|
},
|
|
267
267
|
{
|
|
268
268
|
code: "catalog.approval_required",
|
|
@@ -11,7 +11,7 @@ export interface ParityFinding {
|
|
|
11
11
|
message: string;
|
|
12
12
|
}
|
|
13
13
|
/** What {@link inputParity} reads of an operation. */
|
|
14
|
-
export type ParityOperation = Pick<PlatformOperation, "id" | "input" | "mirrors"> & Partial<Pick<PlatformOperation, "omits" | "extras" | "renames" | "loosens" | "personFields">>;
|
|
14
|
+
export type ParityOperation = Pick<PlatformOperation, "id" | "input" | "mirrors"> & Partial<Pick<PlatformOperation, "omits" | "extras" | "renames" | "loosens" | "personFields" | "withoutSecrets">>;
|
|
15
15
|
/**
|
|
16
16
|
* Compares an operation's input with one mirrored route's body + query + path params (spec
|
|
17
17
|
* §14.5 item 3), on their input JSON Schemas:
|
|
@@ -27,7 +27,8 @@ export type ParityOperation = Pick<PlatformOperation, "id" | "input" | "mirrors"
|
|
|
27
27
|
* - a top-level route field the input neither has nor renames into is listed in `omits`, an input
|
|
28
28
|
* field with no route counterpart in `extras`; stale entries of either are findings;
|
|
29
29
|
* - rule `platform-op-secret-param`: a route field holding the SDK's `secret()` meta anywhere is
|
|
30
|
-
* never an input field (it is in `omits`), and the operation defines `personFields
|
|
30
|
+
* never an input field (it is in `omits`), and the operation defines `personFields`, or says in
|
|
31
|
+
* `withoutSecrets` why it takes none of them and asks for none (a preview without the credential).
|
|
31
32
|
*/
|
|
32
33
|
export declare function inputParity(op: ParityOperation, route: RouteSchemas): ParityFinding[];
|
|
33
34
|
/**
|
package/dist/platform/parity.js
CHANGED
|
@@ -187,7 +187,8 @@ function fieldMismatch(op, route, path, top) {
|
|
|
187
187
|
* - a top-level route field the input neither has nor renames into is listed in `omits`, an input
|
|
188
188
|
* field with no route counterpart in `extras`; stale entries of either are findings;
|
|
189
189
|
* - rule `platform-op-secret-param`: a route field holding the SDK's `secret()` meta anywhere is
|
|
190
|
-
* never an input field (it is in `omits`), and the operation defines `personFields
|
|
190
|
+
* never an input field (it is in `omits`), and the operation defines `personFields`, or says in
|
|
191
|
+
* `withoutSecrets` why it takes none of them and asks for none (a preview without the credential).
|
|
191
192
|
*/
|
|
192
193
|
export function inputParity(op, route) {
|
|
193
194
|
const out = [];
|
|
@@ -259,8 +260,8 @@ export function inputParity(op, route) {
|
|
|
259
260
|
if (covered.has(k)) {
|
|
260
261
|
secretRule(`\`${k}\` of ${r} carries a secret (\`secret()\` meta): leave it out of the input, list it in \`omits\`, and have the person enter it on the card (\`personFields\`)`);
|
|
261
262
|
}
|
|
262
|
-
else if (op.personFields === undefined) {
|
|
263
|
-
secretRule(`\`${k}\` of ${r} carries a secret (\`secret()\` meta): the operation must define \`personFields\`, so the person enters secrets on the card`);
|
|
263
|
+
else if (op.personFields === undefined && !op.withoutSecrets?.trim()) {
|
|
264
|
+
secretRule(`\`${k}\` of ${r} carries a secret (\`secret()\` meta): the operation must define \`personFields\`, so the person enters secrets on the card, or say in \`withoutSecrets\` why it takes none`);
|
|
264
265
|
}
|
|
265
266
|
}
|
|
266
267
|
for (const k of routeFields.keys()) {
|
|
@@ -294,16 +295,40 @@ export function inputParity(op, route) {
|
|
|
294
295
|
*/
|
|
295
296
|
export function checkInputParity(ops, routes) {
|
|
296
297
|
const byRoute = new Map(routes.map((r) => [r.route, r]));
|
|
297
|
-
return ops.flatMap((op) =>
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
298
|
+
return ops.flatMap((op) => [
|
|
299
|
+
...staleWithoutSecrets(op, byRoute),
|
|
300
|
+
...op.mirrors.flatMap((m) => {
|
|
301
|
+
const r = byRoute.get(m);
|
|
302
|
+
return r !== undefined
|
|
303
|
+
? inputParity(op, r)
|
|
304
|
+
: [
|
|
305
|
+
{
|
|
306
|
+
op: op.id,
|
|
307
|
+
route: m,
|
|
308
|
+
message: `${op.id} mirrors \`${m}\`, whose schemas are not in ROUTE_SCHEMAS: export them from the controller's <domain>.schemas.ts and list them there`,
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
}),
|
|
312
|
+
]);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Rule `platform-op-secret-param`: a `withoutSecrets` reason on an operation none of whose
|
|
316
|
+
* registered mirrored routes carries a secret field is stale (it would hide a later secret).
|
|
317
|
+
*/
|
|
318
|
+
function staleWithoutSecrets(op, byRoute) {
|
|
319
|
+
if (op.withoutSecrets === undefined)
|
|
320
|
+
return [];
|
|
321
|
+
const routes = op.mirrors.flatMap((m) => byRoute.get(m) ?? []);
|
|
322
|
+
const secret = routes.some((r) => [r.params, r.query, r.body].some((part) => part !== undefined && holdsSecret(toJson(part))));
|
|
323
|
+
if (secret || routes.length === 0)
|
|
324
|
+
return [];
|
|
325
|
+
return [
|
|
326
|
+
{
|
|
327
|
+
op: op.id,
|
|
328
|
+
route: op.mirrors.join(", "),
|
|
329
|
+
field: "withoutSecrets",
|
|
330
|
+
rule: "platform-op-secret-param",
|
|
331
|
+
message: `${op.id}: platform-op-secret-param: \`withoutSecrets\` is stale: no mirrored route carries a secret field; remove it`,
|
|
332
|
+
},
|
|
333
|
+
];
|
|
309
334
|
}
|