@segmentstream/ontology 0.95.0 → 0.96.0
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/README.md +28 -4
- package/dist/analyze.d.ts +15 -3
- package/dist/analyze.js +208 -3
- package/dist/authoring.js +3 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/manifest.d.ts +102 -18
- package/dist/manifest.js +41 -2
- package/dist/migrate/apply.js +5 -1
- package/dist/migrate/model.d.ts +60 -12
- package/dist/migrate/storage.js +2 -0
- package/dist/ontology.d.ts +2 -2
- package/dist/runtime/member-tables.d.ts +7 -2
- package/dist/runtime/member-tables.js +18 -3
- package/dist/runtime/new-user-hook.d.ts +11 -1
- package/dist/runtime/new-user-hook.js +69 -29
- package/dist/runtime/pipeline.d.ts +2 -0
- package/dist/runtime/pipeline.js +11 -3
- package/dist/runtime/principals.d.ts +13 -0
- package/dist/runtime/principals.js +98 -28
- package/dist/runtime/resolve-agent-identity.js +43 -12
- package/dist/runtime/service-binding.js +10 -4
- package/dist/service/chat/envelope.d.ts +2 -2
- package/dist/service/schemas.d.ts +12 -0
- package/dist/sign-in.d.ts +32 -1
- package/dist/sign-in.js +12 -1
- package/dist/user-identity.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -407,14 +407,37 @@ export default defineOntology({
|
|
|
407
407
|
affected member has linked email before restoring an email-only deployment. `User.sendSignInLink`
|
|
408
408
|
preserves Neon links in compatibility and dual mode; sole SegmentStream uses interactive central
|
|
409
409
|
sign-in, preserving templates, reply routing and the requested landing path.
|
|
410
|
+
- `signUp: { channels, roles, byChannel? }` opens sign-up to strangers on each listed channel:
|
|
411
|
+
`email` (signing in to the app by email code), `telegram` (a first private message to the bot,
|
|
412
|
+
or opening the Mini App) and `whatsapp` (a first message to the number). The new user holds
|
|
413
|
+
exactly `roles`, declared roles passed as role objects or names, or the channel's own list in
|
|
414
|
+
`byChannel`; `[]` grants nothing beyond what is later granted or shared. Sign-up writes them as
|
|
415
|
+
ordinary role assignments in its own transaction, so one person's roles can be revoked or added
|
|
416
|
+
to like anyone's. A user sign-up created never holds `member`, the baseline of invited people,
|
|
417
|
+
nor the implicit feedback reporter role, and the platform records that they signed up (`_channel_users.signed_up`) whatever roles they
|
|
418
|
+
hold later: turn limits always count them. A channel not listed admits only invited or paired
|
|
419
|
+
people; a workspace without `signUp` is internal. `check` refuses in sign-up roles an
|
|
420
|
+
undeclared role, `member`, an entity wildcard, and a generated create, update, delete, link or
|
|
421
|
+
unlink that is not scoped (`{ permission, where: { createdBy: me } }`); an unscoped read of a
|
|
422
|
+
stored entity warns for review. Telegram and WhatsApp need a matching `chat.<channel>` adapter.
|
|
423
|
+
A channel opened both here and by `signIn.channels` or `signIn.policy: "open"` is refused.
|
|
424
|
+
`onSignUp: "contact:ensureMine"` names an idempotent, input-free action without `prepare` or
|
|
425
|
+
connections, run as each new user with the roles their channel granted, after admission
|
|
426
|
+
commits: before the first agent turn or Mini App session, and before an email user's first
|
|
427
|
+
request. Every channel's roles must be able to run it, it cannot grant roles, and a failure
|
|
428
|
+
leaves it pending for the next contact. Promote a person with an ordinary action that calls
|
|
429
|
+
`User.grantRoles`. The manifest carries `sign_in.sign_up` (each channel's role wire names) and
|
|
430
|
+
`sign_in.on_sign_up` only when declared; `signUpRolesOf(manifest, channel)` reads them and
|
|
431
|
+
keeps unknown or malformed channels closed.
|
|
410
432
|
- `signIn: { policy }` decides who may become a member by signing in. `invited`, the
|
|
411
433
|
default, admits only people whose email a member already has, from an invitation or a
|
|
412
434
|
role grant; anyone else is answered 403 `not_invited`. `open` makes anyone who signs in a
|
|
413
|
-
member holding only `member`. The manifest carries the policy.
|
|
435
|
+
member holding only `member`. The manifest carries the policy. <!-- @legacy ontology.legacy-channel-admission -->
|
|
414
436
|
`signIn.codeLink: true` makes the platform's sign-in code emails also link to the app's
|
|
415
437
|
`/sign-in` page with the code in the URL fragment; the app SDK's `useSignIn()` fills it in and
|
|
416
438
|
waits for the person to confirm. Off when omitted; see the app authentication guide.
|
|
417
|
-
|
|
439
|
+
The earlier channel opt-in, kept until `signUp` replaces it: <!-- @legacy ontology.legacy-channel-admission -->
|
|
440
|
+
`signIn: { policy: "invited", channels: { telegram: "open" } }`
|
|
418
441
|
lets private channel senders become email-less members. Missing channels require pairing; email
|
|
419
442
|
`policy: "open"` never opens a channel. `CHANNEL_PROVIDERS` lists supported providers (`telegram`).
|
|
420
443
|
Every configured channel requires a matching `chat.<provider>` adapter; object values are reserved.
|
|
@@ -1301,8 +1324,9 @@ These values are platform defaults **and ceilings**; trusted overrides can only
|
|
|
1301
1324
|
limits persist in `_channel_limits`; omitted limits reuse them, or defaults before the first submission.
|
|
1302
1325
|
Only trusted agent configuration may submit limits; browser assertions must never supply them.
|
|
1303
1326
|
Counters are durable in `_agent_counters`. Sender counters use user ids, so adding/replacing an identity
|
|
1304
|
-
cannot reset them. Turn caps apply
|
|
1305
|
-
|
|
1327
|
+
cannot reset them. Turn caps apply to every user `signUp` created, whatever roles they hold, and to
|
|
1328
|
+
users an open `signIn.channels` created while they hold exactly `["member"]`; invited and paired-only
|
|
1329
|
+
members are exempt. Every new registration consumes the hourly cap.
|
|
1306
1330
|
`turn: false` never creates or counts; groups never create. Capped registration writes roll back, with a
|
|
1307
1331
|
separate durable refusal counter. Each cap notifies on its first rejection per effective threshold
|
|
1308
1332
|
within the fixed window, including after configured limits change. A `notify` response leases
|
package/dist/analyze.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type AnyEntity, type EntityWrites } from "./entity.js";
|
|
|
7
7
|
import { type PropertyDefinition } from "./property.js";
|
|
8
8
|
import { type AnyRelationship } from "./relationship.js";
|
|
9
9
|
import { type Role, type RolePermission } from "./role.js";
|
|
10
|
-
import { type SignInOptions } from "./sign-in.js";
|
|
10
|
+
import { type ResolvedSignInOptions, type SignInOptions, type SignUpOptions } from "./sign-in.js";
|
|
11
11
|
import { type EmailTemplate } from "./emails.js";
|
|
12
12
|
import { type FeedbackOptions, type ResolvedFeedback } from "./feedback-config.js";
|
|
13
13
|
import { type ModelMetricManifest, type WorkflowManifest } from "./manifest.js";
|
|
@@ -46,6 +46,18 @@ export interface OntologyConfig<Entities extends ReadonlyArray<AnyEntity> = Read
|
|
|
46
46
|
readonly member?: MemberOptions;
|
|
47
47
|
/** Who may become a member by signing in. Only invited people by default. */
|
|
48
48
|
readonly signIn?: SignInOptions;
|
|
49
|
+
/**
|
|
50
|
+
* Where a stranger may sign up, and the declared roles they get: `{ channels: ["whatsapp"],
|
|
51
|
+
* roles: [lead] }`. Absent, only invited or paired people get in. A user created by sign-up holds
|
|
52
|
+
* exactly these roles and never `member`.
|
|
53
|
+
*/
|
|
54
|
+
readonly signUp?: SignUpOptions<Role | string>;
|
|
55
|
+
/**
|
|
56
|
+
* An idempotent, input-free action, as `<entity>:<action>`, run as each user created by sign-up
|
|
57
|
+
* with the roles their channel granted, before their first agent turn or app session. It cannot
|
|
58
|
+
* grant roles.
|
|
59
|
+
*/
|
|
60
|
+
readonly onSignUp?: string;
|
|
49
61
|
/**
|
|
50
62
|
* How the MCP `discover` tool finds a request's entities. By default it matches words in their
|
|
51
63
|
* names and descriptions. `{ model }` asks that decision model on AI Gateway, such as
|
|
@@ -204,8 +216,8 @@ export interface Analysis {
|
|
|
204
216
|
readonly entities: ReadonlyArray<ResolvedEntity>;
|
|
205
217
|
/** The workspace-owned `member` role and declared roles, then the implicit reporter when enabled. */
|
|
206
218
|
readonly roles: ReadonlyArray<Role>;
|
|
207
|
-
/** The sign-in options, with the default policy when the definition sets none. */
|
|
208
|
-
readonly signIn:
|
|
219
|
+
/** The sign-in options, with the default policy when the definition sets none, and sign-up. */
|
|
220
|
+
readonly signIn: ResolvedSignInOptions;
|
|
209
221
|
/** The declared emails that passed `check`, by wire name. */
|
|
210
222
|
readonly emails: Readonly<Record<string, EmailTemplate>>;
|
|
211
223
|
/** The declared connections, in order. */
|
package/dist/analyze.js
CHANGED
|
@@ -11,7 +11,7 @@ import { REFERENCE_ANNOTATION, propertyDefinition, propertyOptionNames, unknownP
|
|
|
11
11
|
import { generatedActionPermissions, grants, isAllowed, normalizePermission, parsePermission, parseWorkflowPermission, permissionOf, READ_VERB, rolesGranting, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, wildcardEntityCovers, } from "./permissions.js";
|
|
12
12
|
import { ON_DELETE, isRelationship } from "./relationship.js";
|
|
13
13
|
import { isRole, member, role } from "./role.js";
|
|
14
|
-
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isSignInPolicy, } from "./sign-in.js";
|
|
14
|
+
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_UP_CHANNELS, SIGN_UP_CHAT_CHANNELS, isSignInPolicy, isSignUpChannel, } from "./sign-in.js";
|
|
15
15
|
import { emailOptions } from "./emails.js";
|
|
16
16
|
import { AgentChat } from "./agent-chat.js";
|
|
17
17
|
import { APP_FEEDBACK_ENTITIES } from "./app-feedback.js";
|
|
@@ -70,7 +70,11 @@ export function analyze(config, options = {}) {
|
|
|
70
70
|
!declaredRoles.some((candidate) => candidate.name === nameToWire(config.hooks.role)))) {
|
|
71
71
|
report("invalid-permission", "hooks.role", "hooks.role must name a declared ontology role.");
|
|
72
72
|
}
|
|
73
|
-
const
|
|
73
|
+
const signInDeclared = signInOptions(config, report);
|
|
74
|
+
const signIn = {
|
|
75
|
+
...signInDeclared,
|
|
76
|
+
...signUpOptions(config, signInDeclared, declaredRoles, report),
|
|
77
|
+
};
|
|
74
78
|
const discovery = config.discovery;
|
|
75
79
|
if (discovery !== undefined &&
|
|
76
80
|
(!isPlainObject(discovery) ||
|
|
@@ -216,10 +220,13 @@ export function analyze(config, options = {}) {
|
|
|
216
220
|
checkOpenWarehouseReads({ entities: resolved, roles, signIn, report });
|
|
217
221
|
checkOpenChannels({ config, entities: resolved, roles, signIn, report });
|
|
218
222
|
checkNewUserAction({ entities: resolved, roles, signIn, report });
|
|
223
|
+
checkSignUpRoles({ entities: resolved, roles, signIn, report });
|
|
224
|
+
checkSignUpAction({ entities: resolved, roles, signIn, report });
|
|
219
225
|
if (feedback.enabled) {
|
|
220
226
|
checkFeedbackResponders(roles, report);
|
|
221
227
|
}
|
|
222
|
-
if (Object.values(signIn.channels ?? {}).includes("open")
|
|
228
|
+
if ((Object.values(signIn.channels ?? {}).includes("open") ||
|
|
229
|
+
SIGN_UP_CHAT_CHANNELS.some((channel) => signIn.signUp?.channels[channel] !== undefined)) &&
|
|
223
230
|
options.agentConfig !== undefined) {
|
|
224
231
|
const contact = options.agentConfig.firstContact;
|
|
225
232
|
const hasNotice = isPlainObject(contact) &&
|
|
@@ -991,6 +998,7 @@ function signInOptions(config, report) {
|
|
|
991
998
|
'(only people invited as members) or "open" (anyone who signs in becomes a member).');
|
|
992
999
|
return fallback;
|
|
993
1000
|
}
|
|
1001
|
+
// @legacy ontology.legacy-channel-admission
|
|
994
1002
|
const channels = {};
|
|
995
1003
|
if (options.channels !== undefined) {
|
|
996
1004
|
if (!isPlainObject(options.channels)) {
|
|
@@ -1040,6 +1048,200 @@ function signInOptions(config, report) {
|
|
|
1040
1048
|
...(typeof codeLink === "boolean" ? { codeLink } : {}),
|
|
1041
1049
|
};
|
|
1042
1050
|
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Where strangers may sign up and the wire names of the roles each open channel grants, and the
|
|
1053
|
+
* `onSignUp` action. Every role must be a declared one other than `member`. A channel opened both
|
|
1054
|
+
* here and by the earlier `signIn.channels` or `signIn.policy: "open"` is refused.
|
|
1055
|
+
*/
|
|
1056
|
+
function signUpOptions(config, signIn, declaredRoles, report) {
|
|
1057
|
+
const options = config.signUp;
|
|
1058
|
+
const hook = config.onSignUp;
|
|
1059
|
+
const result = {};
|
|
1060
|
+
if (hook !== undefined &&
|
|
1061
|
+
(typeof hook !== "string" || !parsePermission(hook) || hook.includes("*"))) {
|
|
1062
|
+
report("invalid-sign-in", "onSignUp", "Use an action name: <entity>:<action>.");
|
|
1063
|
+
}
|
|
1064
|
+
else if (typeof hook === "string") {
|
|
1065
|
+
if (options === undefined) {
|
|
1066
|
+
report("invalid-sign-in", "onSignUp", "onSignUp runs after sign-up; declare signUp.");
|
|
1067
|
+
}
|
|
1068
|
+
result.onSignUp = hook;
|
|
1069
|
+
}
|
|
1070
|
+
if (options === undefined) {
|
|
1071
|
+
return result;
|
|
1072
|
+
}
|
|
1073
|
+
if (!isPlainObject(options)) {
|
|
1074
|
+
report("invalid-sign-in", "signUp", 'signUp takes { channels: ["telegram", "whatsapp", "email"], roles: [...] }.');
|
|
1075
|
+
return result;
|
|
1076
|
+
}
|
|
1077
|
+
for (const key of Object.keys(options)) {
|
|
1078
|
+
if (!["channels", "roles", "byChannel"].includes(key)) {
|
|
1079
|
+
report("invalid-sign-in", `signUp.${key}`, `Unknown signUp key: ${key}.`);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
const declared = new Set(declaredRoles.map((candidate) => candidate.name).filter((name) => name !== MEMBER_ROLE));
|
|
1083
|
+
const roleNames = (value, path) => {
|
|
1084
|
+
if (!Array.isArray(value)) {
|
|
1085
|
+
report("invalid-sign-in", path, "Use a list of declared roles; [] grants none.");
|
|
1086
|
+
return undefined;
|
|
1087
|
+
}
|
|
1088
|
+
const names = [];
|
|
1089
|
+
value.forEach((candidate, index) => {
|
|
1090
|
+
const name = isRole(candidate)
|
|
1091
|
+
? nameToWire(candidate.name)
|
|
1092
|
+
: typeof candidate === "string"
|
|
1093
|
+
? nameToWire(candidate)
|
|
1094
|
+
: undefined;
|
|
1095
|
+
if (name === MEMBER_ROLE) {
|
|
1096
|
+
report("invalid-sign-in", `${path}[${index}]`, "member is the baseline of invited people; sign-up grants declared roles only.");
|
|
1097
|
+
}
|
|
1098
|
+
else if (name === undefined || !declared.has(name)) {
|
|
1099
|
+
report("invalid-sign-in", `${path}[${index}]`, "Use a role the ontology declares.");
|
|
1100
|
+
}
|
|
1101
|
+
else if (!names.includes(name)) {
|
|
1102
|
+
names.push(name);
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
return names;
|
|
1106
|
+
};
|
|
1107
|
+
const channels = [];
|
|
1108
|
+
if (!Array.isArray(options.channels) || options.channels.length === 0) {
|
|
1109
|
+
report("invalid-sign-in", "signUp.channels", `List the channels strangers may sign up through: ${SIGN_UP_CHANNELS.join(", ")}.`);
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
options.channels.forEach((channel, index) => {
|
|
1113
|
+
const path = `signUp.channels[${index}]`;
|
|
1114
|
+
if (!isSignUpChannel(channel)) {
|
|
1115
|
+
report("invalid-sign-in", path, `Unsupported sign-up channel: ${String(channel)}. Use ${SIGN_UP_CHANNELS.join(", ")}.`);
|
|
1116
|
+
}
|
|
1117
|
+
else if (channels.includes(channel)) {
|
|
1118
|
+
report("invalid-sign-in", path, `${channel} is listed twice.`);
|
|
1119
|
+
}
|
|
1120
|
+
else {
|
|
1121
|
+
channels.push(channel);
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
const roles = roleNames(options.roles, "signUp.roles");
|
|
1126
|
+
const byChannel = {};
|
|
1127
|
+
if (options.byChannel !== undefined) {
|
|
1128
|
+
if (!isPlainObject(options.byChannel)) {
|
|
1129
|
+
report("invalid-sign-in", "signUp.byChannel", "byChannel maps a listed channel to its roles.");
|
|
1130
|
+
}
|
|
1131
|
+
else {
|
|
1132
|
+
for (const [channel, value] of Object.entries(options.byChannel)) {
|
|
1133
|
+
const path = `signUp.byChannel.${channel}`;
|
|
1134
|
+
if (!isSignUpChannel(channel) || !channels.includes(channel)) {
|
|
1135
|
+
report("invalid-sign-in", path, "byChannel names only channels listed in channels.");
|
|
1136
|
+
continue;
|
|
1137
|
+
}
|
|
1138
|
+
const names = roleNames(value, path);
|
|
1139
|
+
if (names !== undefined) {
|
|
1140
|
+
byChannel[channel] = names;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
for (const channel of channels) {
|
|
1146
|
+
// @legacy ontology.legacy-channel-admission
|
|
1147
|
+
const legacyOpen = channel === "email"
|
|
1148
|
+
? signIn.policy === "open"
|
|
1149
|
+
: signIn.channels?.[channel] === "open";
|
|
1150
|
+
if (legacyOpen) {
|
|
1151
|
+
report("invalid-sign-in", `signUp.channels`, channel === "email"
|
|
1152
|
+
? 'email is opened by signIn.policy "open" too; declare it in signUp only.'
|
|
1153
|
+
: `${channel} is opened by signIn.channels too; declare it in signUp only.`);
|
|
1154
|
+
}
|
|
1155
|
+
if (SIGN_UP_CHAT_CHANNELS.includes(channel)) {
|
|
1156
|
+
const adapters = config.chat;
|
|
1157
|
+
if (adapters?.[channel] === undefined) {
|
|
1158
|
+
report("invalid-sign-in", `signUp.channels`, `Signing up on ${channel} needs a matching chat.${channel} adapter.`);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (channels.length > 0 && roles !== undefined) {
|
|
1163
|
+
result.signUp = {
|
|
1164
|
+
channels: Object.fromEntries(channels.map((channel) => [channel, byChannel[channel] ?? roles])),
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
return result;
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* The roles sign-up grants admit strangers. Each must be explicitly reviewed: no entity wildcard,
|
|
1171
|
+
* and no generated create, update, delete, link or unlink that is not scoped to the person's own
|
|
1172
|
+
* records. An unscoped read of a stored entity is a shared read, warned about for review.
|
|
1173
|
+
*/
|
|
1174
|
+
function checkSignUpRoles(input) {
|
|
1175
|
+
const { entities, roles, signIn, report } = input;
|
|
1176
|
+
const granted = new Set(Object.values(signIn.signUp?.channels ?? {}).flat());
|
|
1177
|
+
const hint = "Scope it to the person's own records or use an ownership-checked action.";
|
|
1178
|
+
for (const name of granted) {
|
|
1179
|
+
const candidate = roles.find((declared) => declared.name === name);
|
|
1180
|
+
if (candidate === undefined || !Array.isArray(candidate.permissions)) {
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
const scoped = new Set((candidate.scopes ?? []).map((scope) => scope.permission));
|
|
1184
|
+
const path = `roles.${name}.permissions`;
|
|
1185
|
+
for (const permission of candidate.permissions) {
|
|
1186
|
+
const parsed = parsePermission(permission);
|
|
1187
|
+
const entity = entities.find((resolved) => resolved.name === parsed?.entity);
|
|
1188
|
+
if (parsed?.entity === WILDCARD) {
|
|
1189
|
+
report("invalid-sign-in", path, `${name} is granted on sign-up and cannot hold ${permission}; name the entities it may use.`);
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
if (entity === undefined || scoped.has(permission)) {
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1195
|
+
const generatedWrite = [
|
|
1196
|
+
entity.permissions.create,
|
|
1197
|
+
entity.permissions.update,
|
|
1198
|
+
entity.permissions.delete,
|
|
1199
|
+
entity.permissions.link,
|
|
1200
|
+
entity.permissions.unlink,
|
|
1201
|
+
].some((required) => required !== undefined && isAllowed(required, { permissions: [permission] }));
|
|
1202
|
+
if (generatedWrite) {
|
|
1203
|
+
report("invalid-sign-in", path, `${name} is granted on sign-up and cannot hold ${permission} on every record. ${hint}`);
|
|
1204
|
+
}
|
|
1205
|
+
else if (isAllowed(entity.permissions.read, { permissions: [permission] })) {
|
|
1206
|
+
report("invalid-sign-in", path, `${name} is granted on sign-up; ${permission} lets anyone who signs up read every ` +
|
|
1207
|
+
`${entity.name}. Review it, or scope it to the person's own records.`, "warning");
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
/** The sign-up hook runs with each channel's roles and cannot enter the external preparation phase. */
|
|
1213
|
+
function checkSignUpAction(input) {
|
|
1214
|
+
const { entities, roles, signIn, report } = input;
|
|
1215
|
+
if (signIn.onSignUp === undefined) {
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
const parsed = parsePermission(signIn.onSignUp);
|
|
1219
|
+
const found = entities
|
|
1220
|
+
.find((entity) => entity.name === parsed?.entity)
|
|
1221
|
+
?.actions.find((candidate) => candidate.name === parsed?.verb);
|
|
1222
|
+
const fail = (message) => report("invalid-sign-in", "onSignUp", message);
|
|
1223
|
+
if (found === undefined) {
|
|
1224
|
+
fail("onSignUp must name an existing authored action.");
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
if (Result.isFailure(Schema.decodeUnknownResult(found.action.input)({}))) {
|
|
1228
|
+
fail("onSignUp cannot have required input; it is called with {}.");
|
|
1229
|
+
}
|
|
1230
|
+
for (const [channel, granted] of Object.entries(signIn.signUp?.channels ?? {})) {
|
|
1231
|
+
const permissions = roles
|
|
1232
|
+
.filter((candidate) => granted.includes(candidate.name))
|
|
1233
|
+
.flatMap((candidate) => (Array.isArray(candidate.permissions) ? candidate.permissions : []));
|
|
1234
|
+
if (!isAllowed(found.permission, { permissions })) {
|
|
1235
|
+
fail(`onSignUp must be runnable by the roles ${channel} sign-up grants.`);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
if (found.action.hints?.idempotent !== true) {
|
|
1239
|
+
fail("onSignUp must declare hints.idempotent: true.");
|
|
1240
|
+
}
|
|
1241
|
+
if (found.action.prepare !== undefined || found.action.connections.length > 0) {
|
|
1242
|
+
fail("onSignUp cannot prepare or use external connections.");
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1043
1245
|
function collectRoles(config, report) {
|
|
1044
1246
|
const roles = [memberRole(config, report)];
|
|
1045
1247
|
(config.roles ?? []).forEach((candidate, index) => {
|
|
@@ -1921,6 +2123,7 @@ function checkRolePermissions(candidate, verbs, workflows, report) {
|
|
|
1921
2123
|
}
|
|
1922
2124
|
});
|
|
1923
2125
|
}
|
|
2126
|
+
// @legacy ontology.legacy-channel-admission
|
|
1924
2127
|
/**
|
|
1925
2128
|
* Under the open policy anyone who signs in holds `member`. Warehouse-backed entities hold company
|
|
1926
2129
|
* figures, such as revenue or stock, that metric queries read with `<entity>:read`; a wildcard of
|
|
@@ -1952,6 +2155,7 @@ function checkOpenWarehouseReads(input) {
|
|
|
1952
2155
|
`(${warehouseBacked.join(", ")}). Grant them to member by name, such as ` +
|
|
1953
2156
|
`${warehouseBacked[0]}:read, or use the invited policy.`);
|
|
1954
2157
|
}
|
|
2158
|
+
// @legacy ontology.legacy-channel-admission
|
|
1955
2159
|
/** Public channels admit strangers with explicitly reviewed baseline grants. */
|
|
1956
2160
|
function checkOpenChannels(input) {
|
|
1957
2161
|
const { config, entities, roles, signIn, report } = input;
|
|
@@ -1988,6 +2192,7 @@ function checkOpenChannels(input) {
|
|
|
1988
2192
|
}
|
|
1989
2193
|
}
|
|
1990
2194
|
}
|
|
2195
|
+
// @legacy ontology.legacy-channel-admission
|
|
1991
2196
|
/** The hook has only member authority and cannot enter the external preparation phase. */
|
|
1992
2197
|
function checkNewUserAction(input) {
|
|
1993
2198
|
const { entities, roles, signIn, report } = input;
|
package/dist/authoring.js
CHANGED
|
@@ -321,6 +321,9 @@ export function authoringToWire(config, builtIns, report) {
|
|
|
321
321
|
if (isRecord(config.signIn) && typeof config.signIn.onNewUser === "string") {
|
|
322
322
|
normalized.signIn = { ...config.signIn, onNewUser: permissionToWire(config.signIn.onNewUser) };
|
|
323
323
|
}
|
|
324
|
+
if (typeof config.onSignUp === "string") {
|
|
325
|
+
normalized.onSignUp = permissionToWire(config.onSignUp);
|
|
326
|
+
}
|
|
324
327
|
if (isRecord(config.member) && Array.isArray(config.member.permissions)) {
|
|
325
328
|
normalized.member = {
|
|
326
329
|
...config.member,
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type { ActionsBuilder, AnyEntity, ActionHandle, ActionInvoker, MetricQuer
|
|
|
22
22
|
export { ActionRejected, BatchErrorDetails, Conflict, DeploymentInterrupted, DeploymentSwitching, LimitErrorDetails, NotFound, PermissionDenied, ScopeViolated, } from "./errors.js";
|
|
23
23
|
export type { ActionError } from "./errors.js";
|
|
24
24
|
export { browserAuthenticationCompatible } from "./manifest-compatibility.js";
|
|
25
|
-
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, signInPolicyOf, channelPolicyOf, } from "./manifest.js";
|
|
25
|
+
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, signInPolicyOf, channelPolicyOf, signUpRolesOf, } from "./manifest.js";
|
|
26
26
|
export { SYSTEM_PROPERTIES } from "./names.js";
|
|
27
27
|
export type { SystemProperty } from "./names.js";
|
|
28
28
|
export { isMe, isMeMarker, MAX_ME_HOPS, me, ME_KEY, MeMarker, mePathOf, meToWire, MeTypeId, } from "./me.js";
|
|
@@ -46,8 +46,8 @@ export { after, changed, cron, cronNeverFires, cronProblem, isWorkflow, isWorkfl
|
|
|
46
46
|
export { MAX_WEBHOOK_BODY_BYTES, MAX_META_WEBHOOK_BODY_BYTES, MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, WEBHOOK_BASE_PATH, WEBHOOK_SIGNATURE_SCHEMES, webhookDelivery, webhookHeaderProblem, webhookPath, } from "./webhooks.js";
|
|
47
47
|
export type { WebhookDelivery, WebhookSignatureScheme } from "./webhooks.js";
|
|
48
48
|
export type { ActionEvent, ActionTrigger, AfterOptions, AnyActionHandle, AnyWorkflow, ChangedBounds, CronOptions, CronProblem, CronTrigger, TriggerFunction, TriggerRecord, WebhookOptions, WebhookSignature, WebhookVerification, WebhookTrigger, Workflow, WorkflowFunction, WorkflowOptions, WorkflowRunContext, WorkflowTrigger, } from "./workflow.js";
|
|
49
|
-
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, } from "./sign-in.js";
|
|
50
|
-
export type { ChannelProvider, SignInCheck, SignInMethod, SignInOptions, SignInPolicy, } from "./sign-in.js";
|
|
49
|
+
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, } from "./sign-in.js";
|
|
50
|
+
export type { ChannelProvider, ResolvedSignInOptions, ResolvedSignUp, SignInCheck, SignInMethod, SignInOptions, SignInPolicy, SignUpChannel, SignUpOptions, } from "./sign-in.js";
|
|
51
51
|
export type { EmailTemplate } from "./emails.js";
|
|
52
52
|
export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
|
|
53
53
|
export type { ActionRunOptions } from "./runtime.js";
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { Diagnostic, DIAGNOSTIC_CODES, formatDiagnostics, InvalidOntology } from
|
|
|
12
12
|
export { entity, isEntity } from "./entity.js";
|
|
13
13
|
export { ActionRejected, BatchErrorDetails, Conflict, DeploymentInterrupted, DeploymentSwitching, LimitErrorDetails, NotFound, PermissionDenied, ScopeViolated, } from "./errors.js";
|
|
14
14
|
export { browserAuthenticationCompatible } from "./manifest-compatibility.js";
|
|
15
|
-
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, signInPolicyOf, channelPolicyOf, } from "./manifest.js";
|
|
15
|
+
export { ActionManifest, actionConnectionKeys, canonicalJson, ConnectionManifest, EntityManifest, EntityPermissionsManifest, decodeManifestDocument, encodeManifest, formatManifest, IndexManifest, isValueMatched, MANIFEST_VERSION, manifestHash, ModelMetricManifest, OntologyManifest, OntologyManifestWire, PropertyManifest, RelationshipManifest, RoleManifest, ActionTriggerManifest, ScopeManifest, CronTriggerManifest, isActionTrigger, isCronTrigger, isWebhookTrigger, OtherTriggerManifest, WebhookTriggerManifest, WorkflowManifest, WorkflowTriggerManifest, SelectOptionManifest, SignInManifest, signInPolicyOf, channelPolicyOf, signUpRolesOf, } from "./manifest.js";
|
|
16
16
|
export { SYSTEM_PROPERTIES } from "./names.js";
|
|
17
17
|
export { isMe, isMeMarker, MAX_ME_HOPS, me, ME_KEY, MeMarker, mePathOf, meToWire, MeTypeId, } from "./me.js";
|
|
18
18
|
export { check, defineOntology } from "./ontology.js";
|
|
@@ -25,7 +25,7 @@ export { renderCatalog } from "./render.js";
|
|
|
25
25
|
export { member, role, roleEntries, rolePermissions } from "./role.js";
|
|
26
26
|
export { after, changed, cron, cronNeverFires, cronProblem, isWorkflow, isWorkflowTrigger, MAX_ACTION_TRIGGERS, MAX_WORKFLOWS, nextCronTime, webhook, workflow, } from "./workflow.js";
|
|
27
27
|
export { MAX_WEBHOOK_BODY_BYTES, MAX_META_WEBHOOK_BODY_BYTES, MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, WEBHOOK_BASE_PATH, WEBHOOK_SIGNATURE_SCHEMES, webhookDelivery, webhookHeaderProblem, webhookPath, } from "./webhooks.js";
|
|
28
|
-
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, } from "./sign-in.js";
|
|
28
|
+
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, } from "./sign-in.js";
|
|
29
29
|
export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
|
|
30
30
|
export { User } from "./user.js";
|
|
31
31
|
export { AgentChat } from "./agent-chat.js";
|