@segmentstream/ontology 0.94.1 → 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 +52 -7
- package/dist/analyze.d.ts +15 -3
- package/dist/analyze.js +217 -5
- package/dist/authoring.js +3 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +5 -5
- package/dist/manifest-compatibility.d.ts +7 -0
- package/dist/manifest-compatibility.js +12 -0
- package/dist/manifest.d.ts +102 -18
- package/dist/manifest.js +41 -2
- package/dist/migrate/apply.d.ts +3 -2
- package/dist/migrate/apply.js +11 -3
- package/dist/migrate/model.d.ts +60 -12
- package/dist/migrate/plan.js +9 -1
- package/dist/migrate/storage.d.ts +7 -0
- package/dist/migrate/storage.js +24 -12
- package/dist/ontology.d.ts +2 -2
- package/dist/permissions.d.ts +9 -0
- package/dist/permissions.js +8 -0
- package/dist/runtime/channel-identity-admin.d.ts +41 -0
- package/dist/runtime/channel-identity-admin.js +223 -0
- package/dist/runtime/generated-actions.d.ts +2 -1
- package/dist/runtime/generated-actions.js +71 -3
- 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 +37 -3
- package/dist/runtime/principals.js +140 -36
- package/dist/runtime/resolve-agent-identity.js +43 -12
- package/dist/runtime/service-binding.js +11 -4
- package/dist/runtime/sql-runtime.d.ts +14 -1
- package/dist/runtime/sql-runtime.js +9 -0
- package/dist/runtime/user-identities.d.ts +5 -3
- package/dist/runtime/user-identities.js +9 -4
- package/dist/runtime/user-identity-sql.d.ts +4 -1
- package/dist/runtime/user-identity-sql.js +5 -2
- package/dist/runtime-source.d.ts +6 -0
- package/dist/runtime-source.js +11 -0
- package/dist/service/agent/attachments.js +4 -0
- package/dist/service/agent/authentication.d.ts +74 -2
- package/dist/service/agent/authentication.js +93 -11
- package/dist/service/agent/files.js +8 -1
- package/dist/service/agent/server.js +13 -2
- package/dist/service/authentication.js +58 -2
- package/dist/service/caller-context.d.ts +16 -0
- package/dist/service/chat/envelope.d.ts +20 -2
- package/dist/service/chat/envelope.js +10 -0
- package/dist/service/runtime-contract.d.ts +9 -0
- 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/storage/attachments.d.ts +11 -0
- package/dist/user-identity.d.ts +14 -5
- package/dist/user-identity.js +25 -5
- 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.
|
|
@@ -1230,6 +1253,19 @@ The agent acts for a member by adding `X-SegmentStream-Act-As: <user id>` on any
|
|
|
1230
1253
|
`/mcp` included: the request runs with the member's current roles and history names the
|
|
1231
1254
|
member, as if they had called. A member who is inactive or has no live pairing is a 403.
|
|
1232
1255
|
|
|
1256
|
+
An agent runtime outside the deployment acts for members the same way with an API key with
|
|
1257
|
+
delegation (`createServiceUser(ontology, { name, roles: [], keyLabel, delegation: true })`, or
|
|
1258
|
+
`segmentstream ontology api-key create NAME --delegation`): `Authorization: Bearer ssk_…`, the
|
|
1259
|
+
member in `X-SegmentStream-Act-As` and, required here, the provider of the account they wrote
|
|
1260
|
+
from in `X-SegmentStream-Identity-Provider`. The member must hold a live chat account of that
|
|
1261
|
+
provider; the key's own service user holds no role and grants nothing. Such a key reaches the
|
|
1262
|
+
routes that accept the runtime's act-as header, `GET /api/ontology/agent/identities/{provider}/{external_id}`
|
|
1263
|
+
and the agent's attachment and file routes, and no other agent route; it never presents
|
|
1264
|
+
`X-SegmentStream-Agent-Task`. Its `_segmentstream` source must name the member's own account as
|
|
1265
|
+
`sender`. The caller is `{ kind: "runtime", delegatedBy: { id, account } }`, and the service logs
|
|
1266
|
+
`ontology.delegation.authenticated` or `ontology.delegation.refused`. An ordinary key ignores
|
|
1267
|
+
both headers. `resolveApiKeyCredential` returns a key's principal and whether it delegates.
|
|
1268
|
+
|
|
1233
1269
|
Running a task a workflow handed it (see [Agent tasks](#agent-tasks)), the agent instead presents
|
|
1234
1270
|
the task's secret in `X-SegmentStream-Agent-Task: <secret>`, on `/mcp` and the two task routes
|
|
1235
1271
|
only. While the task is live, neither ended nor past its deadline, the request runs as the
|
|
@@ -1288,8 +1324,9 @@ These values are platform defaults **and ceilings**; trusted overrides can only
|
|
|
1288
1324
|
limits persist in `_channel_limits`; omitted limits reuse them, or defaults before the first submission.
|
|
1289
1325
|
Only trusted agent configuration may submit limits; browser assertions must never supply them.
|
|
1290
1326
|
Counters are durable in `_agent_counters`. Sender counters use user ids, so adding/replacing an identity
|
|
1291
|
-
cannot reset them. Turn caps apply
|
|
1292
|
-
|
|
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.
|
|
1293
1330
|
`turn: false` never creates or counts; groups never create. Capped registration writes roll back, with a
|
|
1294
1331
|
separate durable refusal counter. Each cap notifies on its first rejection per effective threshold
|
|
1295
1332
|
within the fixed window, including after configured limits change. A `notify` response leases
|
|
@@ -1476,7 +1513,13 @@ maintained in its own repository.
|
|
|
1476
1513
|
### Member identity inspection
|
|
1477
1514
|
|
|
1478
1515
|
Platform member summaries include optional live `identities` with `provider`, `subject` and
|
|
1479
|
-
`username` metadata, and a `blocked` flag.
|
|
1516
|
+
`username` metadata, and a `blocked` flag. An administrator whose role names
|
|
1517
|
+
`user_identity:attach` attaches a known Telegram, WhatsApp or Slack account to an active member
|
|
1518
|
+
with the built-in action `user_identity.attach({ user, provider, subject, username?, display? })`
|
|
1519
|
+
(origin `attach`), and one naming `user_identity:revoke` revokes any chat account with
|
|
1520
|
+
`user_identity.revoke({ id })`. Attaching grants no role, is idempotent for the member's own
|
|
1521
|
+
account, and is a conflict for another member's live account or a second account of the
|
|
1522
|
+
provider. No other action writes `user_identity`. Revoked bindings are omitted; identity subjects are
|
|
1480
1523
|
stable and usernames are mutable display metadata. Older databases without channel tables
|
|
1481
1524
|
remain readable. Use `segmentstream ontology member list --via PROVIDER` to find a member UUID.
|
|
1482
1525
|
|
|
@@ -1680,8 +1723,10 @@ cannot undo the originating action. Workspaces own recursion prevention, deliver
|
|
|
1680
1723
|
any retry policy.
|
|
1681
1724
|
|
|
1682
1725
|
Authenticated runtime actions can read `context.runtime?.source`. It is populated only from
|
|
1683
|
-
verified runtime metadata, including Telegram source
|
|
1684
|
-
|
|
1726
|
+
verified runtime metadata, including Telegram source, staged attachment bindings and a shared
|
|
1727
|
+
`location` (`latitude`, `longitude`, optional `horizontal_accuracy` and `live_period`), and is
|
|
1728
|
+
absent for ordinary OAuth/API-key input. An API key with delegation sends it only for messages
|
|
1729
|
+
of the member's own account. Do not trust an action input property named `source`.
|
|
1685
1730
|
|
|
1686
1731
|
### Replication lifecycle and freshness
|
|
1687
1732
|
|
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
|
@@ -8,10 +8,10 @@ import { CONNECTION_KEY, isConnection } from "./connection.js";
|
|
|
8
8
|
import { isEntity } from "./entity.js";
|
|
9
9
|
import { QUERY_METRICS_ROUTE, LEGACY_MEMBER_NAME, ENTITY_ID, GENERATED_ACTIONS, GENERATED_UPSERT_PREFIX, HISTORY_SUFFIX, MCP_METRIC_TOOLS, MCP_READ_TOOLS, MCP_TOOL_NAME_MAX_LENGTH, MEMBER_ROLE, FEEDBACK_REPORTER_ROLE, mcpToolName, RESERVED_ENTITY_NAMES, RESERVED_MEMBER_NAMES, RESERVED_RELATIONSHIP_NAMES, SNAKE_CASE_NAME, SYSTEM_PROPERTIES, isSystemProperty, toCamelCase, } from "./names.js";
|
|
10
10
|
import { REFERENCE_ANNOTATION, propertyDefinition, propertyOptionNames, unknownPropertyOptions, referenceTarget, } from "./property.js";
|
|
11
|
-
import { generatedActionPermissions, grants, isAllowed, normalizePermission, parsePermission, parseWorkflowPermission, permissionOf, READ_VERB, rolesGranting, USER_MEMBER_VERBS, WILDCARD, wildcardEntityCovers, } from "./permissions.js";
|
|
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) &&
|
|
@@ -790,6 +797,7 @@ function toolOperations(candidate) {
|
|
|
790
797
|
: []),
|
|
791
798
|
...(permissions.link !== undefined ? ["link", "unlink"] : []),
|
|
792
799
|
...(candidate.builtIn && candidate.name === User.name ? USER_MEMBER_VERBS : []),
|
|
800
|
+
...(candidate.builtIn && candidate.name === UserIdentity.name ? USER_IDENTITY_VERBS : []),
|
|
793
801
|
];
|
|
794
802
|
return [
|
|
795
803
|
...[...MCP_READ_TOOLS, ...generated].map((operation) => ({ operation, path: candidate.name })),
|
|
@@ -990,6 +998,7 @@ function signInOptions(config, report) {
|
|
|
990
998
|
'(only people invited as members) or "open" (anyone who signs in becomes a member).');
|
|
991
999
|
return fallback;
|
|
992
1000
|
}
|
|
1001
|
+
// @legacy ontology.legacy-channel-admission
|
|
993
1002
|
const channels = {};
|
|
994
1003
|
if (options.channels !== undefined) {
|
|
995
1004
|
if (!isPlainObject(options.channels)) {
|
|
@@ -1039,6 +1048,200 @@ function signInOptions(config, report) {
|
|
|
1039
1048
|
...(typeof codeLink === "boolean" ? { codeLink } : {}),
|
|
1040
1049
|
};
|
|
1041
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
|
+
}
|
|
1042
1245
|
function collectRoles(config, report) {
|
|
1043
1246
|
const roles = [memberRole(config, report)];
|
|
1044
1247
|
(config.roles ?? []).forEach((candidate, index) => {
|
|
@@ -1823,7 +2026,8 @@ function ownMembers(candidate, entitiesByName) {
|
|
|
1823
2026
|
}
|
|
1824
2027
|
/**
|
|
1825
2028
|
* The verbs each entity has: `read`, its generated actions, and what its actions require. The
|
|
1826
|
-
* built-in user also has its member management verbs,
|
|
2029
|
+
* built-in user also has its member management verbs, and the built-in sign-in identities their
|
|
2030
|
+
* attach and revoke, which roles may grant.
|
|
1827
2031
|
*/
|
|
1828
2032
|
function knownVerbs(entities) {
|
|
1829
2033
|
const verbs = new Map();
|
|
@@ -1840,6 +2044,11 @@ function knownVerbs(entities) {
|
|
|
1840
2044
|
own.add(verb);
|
|
1841
2045
|
}
|
|
1842
2046
|
}
|
|
2047
|
+
if (candidate.builtIn && candidate.name === UserIdentity.name) {
|
|
2048
|
+
for (const verb of USER_IDENTITY_VERBS) {
|
|
2049
|
+
own.add(verb);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
1843
2052
|
verbs.set(candidate.name, own);
|
|
1844
2053
|
}
|
|
1845
2054
|
for (const candidate of entities) {
|
|
@@ -1914,6 +2123,7 @@ function checkRolePermissions(candidate, verbs, workflows, report) {
|
|
|
1914
2123
|
}
|
|
1915
2124
|
});
|
|
1916
2125
|
}
|
|
2126
|
+
// @legacy ontology.legacy-channel-admission
|
|
1917
2127
|
/**
|
|
1918
2128
|
* Under the open policy anyone who signs in holds `member`. Warehouse-backed entities hold company
|
|
1919
2129
|
* figures, such as revenue or stock, that metric queries read with `<entity>:read`; a wildcard of
|
|
@@ -1945,6 +2155,7 @@ function checkOpenWarehouseReads(input) {
|
|
|
1945
2155
|
`(${warehouseBacked.join(", ")}). Grant them to member by name, such as ` +
|
|
1946
2156
|
`${warehouseBacked[0]}:read, or use the invited policy.`);
|
|
1947
2157
|
}
|
|
2158
|
+
// @legacy ontology.legacy-channel-admission
|
|
1948
2159
|
/** Public channels admit strangers with explicitly reviewed baseline grants. */
|
|
1949
2160
|
function checkOpenChannels(input) {
|
|
1950
2161
|
const { config, entities, roles, signIn, report } = input;
|
|
@@ -1981,6 +2192,7 @@ function checkOpenChannels(input) {
|
|
|
1981
2192
|
}
|
|
1982
2193
|
}
|
|
1983
2194
|
}
|
|
2195
|
+
// @legacy ontology.legacy-channel-admission
|
|
1984
2196
|
/** The hook has only member authority and cannot enter the external preparation phase. */
|
|
1985
2197
|
function checkNewUserAction(input) {
|
|
1986
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";
|
|
@@ -31,7 +31,7 @@ export { check, defineOntology } from "./ontology.js";
|
|
|
31
31
|
export { webhookDeliveryJsonSchema } from "./analyze.js";
|
|
32
32
|
export { webhookToken, webhookTokenMatches, WEBHOOK_TOKEN_CONTEXT } from "./webhook-token.js";
|
|
33
33
|
export type { Ontology } from "./ontology.js";
|
|
34
|
-
export { DEFAULT_MEMBER_PERMISSIONS, effectiveScope, generatedActionPermissions, grants, isAllowed, parsePermission, permissionsOf, principalScopes, READ_VERB, readScope, rolesGranting, scopesOf, USER_MEMBER_VERBS, WILDCARD, WILDCARD_ENTITY_VERBS, } from "./permissions.js";
|
|
34
|
+
export { DEFAULT_MEMBER_PERMISSIONS, effectiveScope, generatedActionPermissions, grants, isAllowed, parsePermission, permissionsOf, principalScopes, READ_VERB, readScope, rolesGranting, scopesOf, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, WILDCARD_ENTITY_VERBS, } from "./permissions.js";
|
|
35
35
|
export type { ParsedPermission, PermissionHolder, RolePermissions, ScopedPermission, ScopeFilter, ScopeValue, ScopeWhere, UserMemberVerb, } from "./permissions.js";
|
|
36
36
|
export { p, PROPERTY_TYPES, propertyDefinition } from "./property.js";
|
|
37
37
|
export type { AnyProperty, NumberOptions, Property, PropertyDefinition, PropertyOf, PropertyOptions, BlobOptions, ListOptions, PropertyType, ReferenceOptions, SelectOption, SelectOptionInput, TextOptions, } from "./property.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";
|
|
@@ -55,8 +55,8 @@ export type { BatchOptions, BatchRecordResult, BatchResult, BatchReturning, Batc
|
|
|
55
55
|
export { User } from "./user.js";
|
|
56
56
|
export type { UserHandle, UserMemberWrites } from "./user.js";
|
|
57
57
|
export { AgentChat } from "./agent-chat.js";
|
|
58
|
-
export { UserIdentity, USER_IDENTITY_ORIGINS } from "./user-identity.js";
|
|
59
|
-
export type { UserIdentityOrigin } from "./user-identity.js";
|
|
58
|
+
export { ATTACHABLE_IDENTITY_PROVIDERS, UserIdentity, USER_IDENTITY_ORIGINS, } from "./user-identity.js";
|
|
59
|
+
export type { AttachableIdentityProvider, UserIdentityOrigin } from "./user-identity.js";
|
|
60
60
|
export { AppFeedback, AppFeedbackFile, APP_FEEDBACK_ENTITIES, APP_FEEDBACK_FILE_MAX_BYTES, } from "./app-feedback.js";
|
|
61
61
|
export { ChatDelivery, ChatPostInput, ChatPostResult } from "./chat.js";
|
|
62
62
|
export { DEFAULT_QUERY_LIMIT, entityQueryResultSchema, entityQuerySchema, entityQuerySchemas, entityRecordSchema, FILTER_OPERATORS, LIST_FILTER_OPERATORS, MANY_QUANTIFIERS, MAX_IN_VALUES, MAX_QUERY_LIMIT, OrderBy, Query, queryFields, queryJsonSchema, queryLinks, QueryResult, queryResultJsonSchema, queryResultSchema, SortDirection, WHERE_COMBINATORS, } from "./query.js";
|
|
@@ -67,8 +67,8 @@ export type { GeneratedActionManifest, GeneratedActions } from "./runtime/genera
|
|
|
67
67
|
export { Change, Edit, EditKind, HistoryEntry } from "./runtime/history.js";
|
|
68
68
|
export { ActionOutcome, ActionValidation, findAction, PREPARE_TIMEOUT, resolveAction, runAction, } from "./runtime/pipeline.js";
|
|
69
69
|
export type { ActionRequest, AfterCommit, CommittedAction, FoundAction, } from "./runtime/pipeline.js";
|
|
70
|
-
export { API_KEY_ITERATIONS, API_KEY_PREFIX, checkSignIn, createApiKey, createServiceUser, findApiKey, generateApiKey, grantMemberRoles, hashApiKeySecret, listApiKeys, listMembers, countUsersWithoutEmailIdentity, countUsersWithoutSegmentStreamIdentity, MEMBER_HISTORY_ACTIONS, parseApiKey, principalsOntology, resolvePrincipalByApiKey, resolvePrincipalByIdentity, reconcileWorkflowUsers, resolveWorkflowUser, revokeApiKey, WORKFLOW_USER_PROVIDER, workflowSubject, revokeMemberRoles, setMemberActive, setMemberBlocked, revokeMemberSessions, setUserRoles, SIGN_IN_RECORD_INTERVAL_MS, updateMemberRoles, } from "./runtime/principals.js";
|
|
71
|
-
export type { ApiKeyParts, ApiKeySummary, CreatedApiKey, IdentityClaims, MemberKey, MemberRolesChange, MemberStatus, MemberSummary, PrincipalsManifest, } from "./runtime/principals.js";
|
|
70
|
+
export { API_KEY_ITERATIONS, API_KEY_PREFIX, checkSignIn, createApiKey, createServiceUser, findApiKey, generateApiKey, grantMemberRoles, hashApiKeySecret, listApiKeys, listMembers, countUsersWithoutEmailIdentity, countUsersWithoutSegmentStreamIdentity, MEMBER_HISTORY_ACTIONS, parseApiKey, principalsOntology, resolveApiKeyCredential, resolvePrincipalByApiKey, resolvePrincipalByIdentity, reconcileWorkflowUsers, resolveWorkflowUser, revokeApiKey, WORKFLOW_USER_PROVIDER, workflowSubject, revokeMemberRoles, setMemberActive, setMemberBlocked, revokeMemberSessions, setUserRoles, SIGN_IN_RECORD_INTERVAL_MS, updateMemberRoles, } from "./runtime/principals.js";
|
|
71
|
+
export type { ApiKeyCredential, ApiKeyParts, ApiKeySummary, CreatedApiKey, IdentityClaims, MemberKey, MemberRolesChange, MemberStatus, MemberSummary, PrincipalsManifest, } from "./runtime/principals.js";
|
|
72
72
|
export { backendLayer, postgresLayer, sqlServiceRuntime } from "./runtime/service-binding.js";
|
|
73
73
|
export { makeOntologyRuntime } from "./runtime/sql-runtime.js";
|
|
74
74
|
export type { SqlOntologyRuntime, WriteScope } from "./runtime/sql-runtime.js";
|
package/dist/index.js
CHANGED
|
@@ -12,24 +12,24 @@ 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";
|
|
19
19
|
export { webhookDeliveryJsonSchema } from "./analyze.js";
|
|
20
20
|
export { webhookToken, webhookTokenMatches, WEBHOOK_TOKEN_CONTEXT } from "./webhook-token.js";
|
|
21
|
-
export { DEFAULT_MEMBER_PERMISSIONS, effectiveScope, generatedActionPermissions, grants, isAllowed, parsePermission, permissionsOf, principalScopes, READ_VERB, readScope, rolesGranting, scopesOf, USER_MEMBER_VERBS, WILDCARD, WILDCARD_ENTITY_VERBS, } from "./permissions.js";
|
|
21
|
+
export { DEFAULT_MEMBER_PERMISSIONS, effectiveScope, generatedActionPermissions, grants, isAllowed, parsePermission, permissionsOf, principalScopes, READ_VERB, readScope, rolesGranting, scopesOf, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, WILDCARD_ENTITY_VERBS, } from "./permissions.js";
|
|
22
22
|
export { p, PROPERTY_TYPES, propertyDefinition } from "./property.js";
|
|
23
23
|
export { ON_DELETE, rel } from "./relationship.js";
|
|
24
24
|
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";
|
|
32
|
-
export { UserIdentity, USER_IDENTITY_ORIGINS } from "./user-identity.js";
|
|
32
|
+
export { ATTACHABLE_IDENTITY_PROVIDERS, UserIdentity, USER_IDENTITY_ORIGINS, } from "./user-identity.js";
|
|
33
33
|
export { AppFeedback, AppFeedbackFile, APP_FEEDBACK_ENTITIES, APP_FEEDBACK_FILE_MAX_BYTES, } from "./app-feedback.js";
|
|
34
34
|
export { ChatDelivery, ChatPostInput, ChatPostResult } from "./chat.js";
|
|
35
35
|
// The query language of `find` and of the service's list, query and traversal routes.
|
|
@@ -39,7 +39,7 @@ export { InvalidQuery, InvalidValues, MemberNotFound, PrincipalRejected, StoredR
|
|
|
39
39
|
export { generatedActionManifests, generatedActions, upsertActionName, } from "./runtime/generated-actions.js";
|
|
40
40
|
export { Change, Edit, EditKind, HistoryEntry } from "./runtime/history.js";
|
|
41
41
|
export { ActionOutcome, ActionValidation, findAction, PREPARE_TIMEOUT, resolveAction, runAction, } from "./runtime/pipeline.js";
|
|
42
|
-
export { API_KEY_ITERATIONS, API_KEY_PREFIX, checkSignIn, createApiKey, createServiceUser, findApiKey, generateApiKey, grantMemberRoles, hashApiKeySecret, listApiKeys, listMembers, countUsersWithoutEmailIdentity, countUsersWithoutSegmentStreamIdentity, MEMBER_HISTORY_ACTIONS, parseApiKey, principalsOntology, resolvePrincipalByApiKey, resolvePrincipalByIdentity, reconcileWorkflowUsers, resolveWorkflowUser, revokeApiKey, WORKFLOW_USER_PROVIDER, workflowSubject, revokeMemberRoles, setMemberActive, setMemberBlocked, revokeMemberSessions, setUserRoles, SIGN_IN_RECORD_INTERVAL_MS, updateMemberRoles, } from "./runtime/principals.js";
|
|
42
|
+
export { API_KEY_ITERATIONS, API_KEY_PREFIX, checkSignIn, createApiKey, createServiceUser, findApiKey, generateApiKey, grantMemberRoles, hashApiKeySecret, listApiKeys, listMembers, countUsersWithoutEmailIdentity, countUsersWithoutSegmentStreamIdentity, MEMBER_HISTORY_ACTIONS, parseApiKey, principalsOntology, resolveApiKeyCredential, resolvePrincipalByApiKey, resolvePrincipalByIdentity, reconcileWorkflowUsers, resolveWorkflowUser, revokeApiKey, WORKFLOW_USER_PROVIDER, workflowSubject, revokeMemberRoles, setMemberActive, setMemberBlocked, revokeMemberSessions, setUserRoles, SIGN_IN_RECORD_INTERVAL_MS, updateMemberRoles, } from "./runtime/principals.js";
|
|
43
43
|
export { backendLayer, postgresLayer, sqlServiceRuntime } from "./runtime/service-binding.js";
|
|
44
44
|
export { makeOntologyRuntime } from "./runtime/sql-runtime.js";
|
|
45
45
|
// The HTTP service derived from the ontology.
|
|
@@ -6,3 +6,10 @@ import { type OntologyManifest } from "./manifest.js";
|
|
|
6
6
|
* live users, exact roles and revocations still apply.
|
|
7
7
|
*/
|
|
8
8
|
export declare function browserAuthenticationCompatible(left: OntologyManifest, right: OntologyManifest): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a deployed manifest comes from an ontology SDK whose service acts for members with API
|
|
11
|
+
* keys with delegation, and whose migration gave `_api_keys` its `delegation` column. That SDK
|
|
12
|
+
* also introduced the `attach` origin of the built-in sign-in identities, which its manifest lists:
|
|
13
|
+
* the platform reads that, as any reader of any manifest version can, instead of a version.
|
|
14
|
+
*/
|
|
15
|
+
export declare function supportsDelegatedApiKeys(manifest: OntologyManifest): boolean;
|
|
@@ -85,3 +85,15 @@ export function browserAuthenticationCompatible(left, right) {
|
|
|
85
85
|
const b = withoutPresentation(right);
|
|
86
86
|
return a !== undefined && b !== undefined && canonicalJson(a) === canonicalJson(b);
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Whether a deployed manifest comes from an ontology SDK whose service acts for members with API
|
|
90
|
+
* keys with delegation, and whose migration gave `_api_keys` its `delegation` column. That SDK
|
|
91
|
+
* also introduced the `attach` origin of the built-in sign-in identities, which its manifest lists:
|
|
92
|
+
* the platform reads that, as any reader of any manifest version can, instead of a version.
|
|
93
|
+
*/
|
|
94
|
+
export function supportsDelegatedApiKeys(manifest) {
|
|
95
|
+
return (manifest.entities
|
|
96
|
+
.find((entity) => entity.name === "user_identity")
|
|
97
|
+
?.properties.find((property) => property.name === "origin")
|
|
98
|
+
?.options?.some((option) => option.value === "attach") === true);
|
|
99
|
+
}
|