@palbase/backend 29.0.0 → 30.0.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/dist/bin/palbase-backend.cjs +22 -7
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +2 -2
- package/dist/{chunk-ESSQ3YML.js → chunk-5J5W75A6.js} +3 -1
- package/dist/chunk-5J5W75A6.js.map +1 -0
- package/dist/{chunk-DHJ3SYAE.js → chunk-VN7NMDUH.js} +23 -9
- package/dist/{chunk-DHJ3SYAE.js.map → chunk-VN7NMDUH.js.map} +1 -1
- package/dist/db/index.d.cts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/engine/index.cjs +22 -7
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +3 -3
- package/dist/engine/index.d.ts +3 -3
- package/dist/engine/index.js +2 -2
- package/dist/{index-BOe82fsK.d.ts → index-8qy3kIuA.d.ts} +66 -4
- package/dist/{index-ChvoVczS.d.cts → index-DtCgaZAg.d.cts} +66 -4
- package/dist/{index-BZfmdRmh.d.cts → index-Zi7MptvP.d.cts} +3 -3
- package/dist/{index-BYDUKexK.d.ts → index-b-Q3l7W5.d.ts} +3 -3
- package/dist/index.cjs +51 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -11
- package/dist/index.d.ts +51 -11
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/dist/openapi/index.d.cts +2 -2
- package/dist/openapi/index.d.ts +2 -2
- package/dist/{registry-DaqHsOq8.d.ts → registry-BGJ-Al6F.d.ts} +1 -1
- package/dist/{registry-B2KfKWv1.d.cts → registry-CEYLH-Iz.d.cts} +1 -1
- package/dist/test/index.d.cts +1 -1
- package/dist/test/index.d.ts +1 -1
- package/docs/README.md +1 -1
- package/docs/llms-full.txt +1 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
- package/dist/chunk-ESSQ3YML.js.map +0 -1
package/dist/engine/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import '../index-
|
|
2
|
-
export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-
|
|
1
|
+
import '../index-DtCgaZAg.cjs';
|
|
2
|
+
export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-Zi7MptvP.cjs';
|
|
3
3
|
import '../db/env.cjs';
|
|
4
4
|
import '../stack.cjs';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'node:async_hooks';
|
|
7
7
|
import '../module-Dl1KFVtc.cjs';
|
|
8
|
-
import '../registry-
|
|
8
|
+
import '../registry-CEYLH-Iz.cjs';
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import '../index-
|
|
2
|
-
export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-
|
|
1
|
+
import '../index-8qy3kIuA.js';
|
|
2
|
+
export { A as App, g as AuthVerifier, B as BootRefused, h as CreateAppOptions, D as DECLARATION_REFUSAL, a as DeclarationRefused, E as EgressPolicy, j as EngineConfig, M as ModuleClients, R as RateLimiter, k as RequestDatabase, l as RouteEntry, m as RuntimeHooks, S as ScrubResult, n as SqlDriver, o as SqlTx, p as buildRouteTable, q as createApp, r as createLazyTransaction, s as createOps, t as createRequestDatabase, u as effectiveAuth, v as hostAllowed, w as installEgressFence, i as isDeclarationRefused, x as loadConfig, y as makeMemoryCache, z as matchRoute, F as quoteIdent, G as scrubSecrets, H as withTables } from '../index-b-Q3l7W5.js';
|
|
3
3
|
import '../db/env.js';
|
|
4
4
|
import '../stack.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'node:async_hooks';
|
|
7
7
|
import '../module-Dl1KFVtc.js';
|
|
8
|
-
import '../registry-
|
|
8
|
+
import '../registry-BGJ-Al6F.js';
|
package/dist/engine/index.js
CHANGED
|
@@ -16,12 +16,12 @@ import {
|
|
|
16
16
|
quoteIdent,
|
|
17
17
|
scrubSecrets,
|
|
18
18
|
withTables
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-VN7NMDUH.js";
|
|
20
20
|
import {
|
|
21
21
|
DECLARATION_REFUSAL,
|
|
22
22
|
DeclarationRefused,
|
|
23
23
|
isDeclarationRefused
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-5J5W75A6.js";
|
|
25
25
|
import "../chunk-SG4UTNOP.js";
|
|
26
26
|
import "../chunk-3TUJWHC2.js";
|
|
27
27
|
import "../chunk-VVMJEVQP.js";
|
|
@@ -39,6 +39,20 @@ interface User {
|
|
|
39
39
|
*/
|
|
40
40
|
emailVerified: boolean;
|
|
41
41
|
role: string;
|
|
42
|
+
/**
|
|
43
|
+
* The caller's APPLICATION roles, as assigned in `auth.user_roles`.
|
|
44
|
+
*
|
|
45
|
+
* Not to be confused with {@link User.role}, which is the DATABASE role RLS
|
|
46
|
+
* reads and is the literal string "authenticated" for every signed-in user.
|
|
47
|
+
* These are the names a stack declares (`palbase roles`) and an operator
|
|
48
|
+
* assigns; `auth: { role }` gates on the same set.
|
|
49
|
+
*
|
|
50
|
+
* Resolved per request from the table, in the transaction the handler is
|
|
51
|
+
* about to use — never from a token claim, so a role revoked a second ago is
|
|
52
|
+
* already gone here. An empty array for a caller who holds none, never null:
|
|
53
|
+
* `user.roles.includes("agent")` needs no guard.
|
|
54
|
+
*/
|
|
55
|
+
roles: string[];
|
|
42
56
|
metadata: Record<string, unknown>;
|
|
43
57
|
/**
|
|
44
58
|
* Reserved, server-owned verified device claim. `null` on an authenticated
|
|
@@ -2080,6 +2094,37 @@ interface PalbaseAuthClient {
|
|
|
2080
2094
|
dispose(): void;
|
|
2081
2095
|
};
|
|
2082
2096
|
}
|
|
2097
|
+
/**
|
|
2098
|
+
* The `Auth` singleton a backend handler reaches — the ROLE-ASSIGNMENT surface,
|
|
2099
|
+
* and nothing else.
|
|
2100
|
+
*
|
|
2101
|
+
* Deliberately not {@link PalbaseAuthClient}: that one is a person acting on
|
|
2102
|
+
* their own account (sign-in, MFA, device attestation) and it belongs to the
|
|
2103
|
+
* client SDK. What a server needs is the operator verb — "make this user an
|
|
2104
|
+
* agent" — because the promotion usually happens inside the tenant's own
|
|
2105
|
+
* product, in a handler a supervisor triggers.
|
|
2106
|
+
*
|
|
2107
|
+
* These calls carry the SERVICE-ROLE credential: the routes behind them refuse
|
|
2108
|
+
* anon and `authenticated` alike (FR-013), which is what stops an end user from
|
|
2109
|
+
* granting themselves the permission the rest of the feature gates on.
|
|
2110
|
+
*
|
|
2111
|
+
* Unlike the other clients here these THROW rather than envelope, because two
|
|
2112
|
+
* of the three answer `void` — a refusal that came back as a value would be
|
|
2113
|
+
* indistinguishable from a write that happened. See `clients/auth.ts`.
|
|
2114
|
+
*/
|
|
2115
|
+
interface PalbaseAuthAdminClient {
|
|
2116
|
+
/**
|
|
2117
|
+
* Give a user a role. Idempotent: assigning one they already hold is not an
|
|
2118
|
+
* error and leaves one row. Throws `RoleNotDefined` when the stack declares
|
|
2119
|
+
* no role by that name.
|
|
2120
|
+
*/
|
|
2121
|
+
assignRole(userId: string, role: string): Promise<void>;
|
|
2122
|
+
/** Take a role away. Revoking one they do not hold is not an error. */
|
|
2123
|
+
revokeRole(userId: string, role: string): Promise<void>;
|
|
2124
|
+
/** What that user holds right now. `[]` for a user with no roles — a FAILED
|
|
2125
|
+
* read throws rather than answering the same thing. */
|
|
2126
|
+
rolesOf(userId: string): Promise<string[]>;
|
|
2127
|
+
}
|
|
2083
2128
|
/**
|
|
2084
2129
|
* Bucket-level file operations available via `ctx.storage.bucket(name)`.
|
|
2085
2130
|
* `getPublicUrl` is synchronous (no network call — constructs URL locally).
|
|
@@ -2539,11 +2584,14 @@ interface PalbaseLinksClient {
|
|
|
2539
2584
|
* Realtime is BROADCAST-ONLY here (a stateless handler can push an event but
|
|
2540
2585
|
* cannot hold a subscription socket — `subscribe()` lives on the client SDK).
|
|
2541
2586
|
*
|
|
2542
|
-
* EXCLUDED on purpose: Functions, Links, Analytics
|
|
2543
|
-
*
|
|
2544
|
-
*
|
|
2587
|
+
* EXCLUDED on purpose: Functions, Links, Analytics. They are not exposed as
|
|
2588
|
+
* backend handler singletons — out of scope for backend endpoints. `Auth` is
|
|
2589
|
+
* here in its ROLE-ASSIGNMENT shape only: signing in is the client SDK's job,
|
|
2590
|
+
* but granting a role is an operator verb the tenant's own handler needs
|
|
2591
|
+
* (FR-009). */
|
|
2545
2592
|
interface RuntimeServices {
|
|
2546
2593
|
Database: DBClient;
|
|
2594
|
+
Auth: PalbaseAuthAdminClient;
|
|
2547
2595
|
Secrets: SecretsService;
|
|
2548
2596
|
Documents: PalbaseDocsClient;
|
|
2549
2597
|
Storage: PalbaseStorageClient;
|
|
@@ -2753,6 +2801,20 @@ declare const Cache: CacheClient;
|
|
|
2753
2801
|
* the STACK holds, because no route returns a platform secret's value at all.
|
|
2754
2802
|
*/
|
|
2755
2803
|
declare const Secrets: SecretsService;
|
|
2804
|
+
/**
|
|
2805
|
+
* Role assignment, as an operator — `Auth.assignRole(userId, "agent")`.
|
|
2806
|
+
*
|
|
2807
|
+
* The half of auth a SERVER owns. Signing in, MFA and device attestation are a
|
|
2808
|
+
* person acting on their own account and live on the client SDK; granting a
|
|
2809
|
+
* role is the tenant's product doing something to somebody else, which is
|
|
2810
|
+
* exactly what a handler is for. It writes with the service-role credential,
|
|
2811
|
+
* because an end user who could write their own assignment would make every
|
|
2812
|
+
* permission underneath it meaningless.
|
|
2813
|
+
*
|
|
2814
|
+
* The write is visible to the very next request: authority is read from the
|
|
2815
|
+
* table on each call, never carried on a token.
|
|
2816
|
+
*/
|
|
2817
|
+
declare const Auth: PalbaseAuthAdminClient;
|
|
2756
2818
|
/** Structured logger. */
|
|
2757
2819
|
declare const Log: Logger;
|
|
2758
2820
|
/** Push / email / SMS / in-app notifications. */
|
|
@@ -5098,4 +5160,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
|
|
|
5098
5160
|
*/
|
|
5099
5161
|
type AuthSpec = boolean | Partial<AuthConfig>;
|
|
5100
5162
|
|
|
5101
|
-
export {
|
|
5163
|
+
export { NotFound as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, EXTENSION_DEPENDENCIES as E, type ErrorMap as F, type ErrorThrowers as G, HttpError as H, type FileContext as I, Flags as J, Forbidden as K, type HttpMethod as L, IndexBuilder as M, type IndexDef as N, type InsertShape as O, type PalbaseResult as P, type LifecycleHook as Q, type RateLimitConfig as R, type SchemaDef as S, type TxPlanBody as T, Log as U, type Logger as V, type Materialized as W, type Middleware as X, type MiddlewareContext as Y, type MiddlewareHandler as Z, __runWithRuntime as _, type DBOps as a, type PalbaseListLinksOptions as a$, Notifications as a0, type OnDeleteAction as a1, PALBASE_EXTENSIONS as a2, type PBRequest as a3, PalError as a4, type PalbaseAnalyticsClient as a5, type PalbaseAnalyticsManagementNamespace as a6, type PalbaseAnalyticsProperties as a7, type PalbaseAnalyticsQueryNamespace as a8, type PalbaseAttestAndroidParams as a9, type PalbaseEventsQueryInput as aA, type PalbaseEventsResult as aB, type PalbaseExtension as aC, type PalbaseFileObject as aD, type PalbaseFlag as aE, type PalbaseFlagContext as aF, type PalbaseFlagSource as aG, type PalbaseFlagValue as aH, type PalbaseFlagVariant as aI, type PalbaseFlagsClient as aJ, type PalbaseFlagsServiceClient as aK, type PalbaseFunctionsClient as aL, type PalbaseFunnelQueryInput as aM, type PalbaseFunnelResult as aN, type PalbaseIdentifyTraits as aO, type PalbaseInboxClient as aP, type PalbaseInboxListOptions as aQ, type PalbaseInboxListResult as aR, type PalbaseInboxMessage as aS, type PalbaseInboxSendParams as aT, type PalbaseInboxSendResponse as aU, type PalbaseInitialLink as aV, type PalbaseInvokeOptions as aW, type PalbaseLink as aX, type PalbaseLinkAnalytics as aY, type PalbaseLinkDetails as aZ, type PalbaseLinksClient as a_, type PalbaseAttestAndroidResult as aa, type PalbaseAttestiOSParams as ab, type PalbaseAttestiOSResult as ac, type PalbaseAuthAdminClient as ad, type PalbaseAuthClient as ae, type PalbaseBatchOverrideOperation as af, type PalbaseBatchSetOverridesResult as ag, type PalbaseBindDeviceParams as ah, type PalbaseBucketClient as ai, type PalbaseClearAllOverridesResult as aj, type PalbaseClearOverrideResult as ak, type PalbaseCohortQueryInput as al, type PalbaseCohortResult as am, type PalbaseCollectionRef as an, type PalbaseCountQueryInput as ao, type PalbaseCountResult as ap, type PalbaseCreateLinkParams as aq, type PalbaseDeviceInfo as ar, type PalbaseDeviceTokenView as as, type PalbaseDocsClient as at, type PalbaseDocumentRef as au, type PalbaseDocumentSnapshot as av, type PalbaseEmailClient as aw, type PalbaseEmailSendParams as ax, type PalbaseEmailSendResponse as ay, type PalbaseEventNamesResult as az, type TxPlanResponse as b, type TxNow as b$, type PalbaseListLinksResult as b0, type PalbaseListOptions as b1, type PalbaseMatchParams as b2, type PalbaseMultiChannelResponse as b3, type PalbaseNotificationsClient as b4, type PalbaseOverviewResult as b5, type PalbasePreferences as b6, type PalbasePreferencesClient as b7, type PalbasePushClient as b8, type PalbasePushSendParams as b9, type PolicyCommand as bA, type PolicyDef as bB, type PolicyExprCtx as bC, PolicyExprRef as bD, type PolicyMode as bE, type PolicyOperand as bF, type RawConstraintDef as bG, Realtime as bH, type Ref as bI, type RequestStore as bJ, type RowShape as bK, Secrets as bL, type SecretsService as bM, SerializationFailure as bN, type SetShape as bO, type SetValue as bP, type ShutdownRunner as bQ, type SqlFragment as bR, Storage as bS, TABLE_META as bT, type TableDef as bU, type TableHandle as bV, type TableInput as bW, TooManyRequests as bX, type TxColumnExpr as bY, type TxInsertShape as bZ, type TxInsertValue as b_, type PalbasePushSendResponse as ba, type PalbaseQrCodeOptions as bb, type PalbaseQuerySnapshot as bc, type PalbaseRealtimeClient as bd, type PalbaseRegisterDeviceParams as be, type PalbaseRetentionQueryInput as bf, type PalbaseRetentionResult as bg, type PalbaseSession as bh, type PalbaseSetOverrideResult as bi, type PalbaseSetOverridesResult as bj, type PalbaseSignedUrlResponse as bk, type PalbaseSmsClient as bl, type PalbaseSmsSendParams as bm, type PalbaseSmsSendResponse as bn, type PalbaseStorageClient as bo, type PalbaseTransformOptions as bp, type PalbaseUpdateLinkParams as bq, type PalbaseUploadOptions as br, type PalbaseUser as bs, type PalbaseUserDetailResult as bt, type PalbaseUsersQueryInput as bu, type PalbaseUsersResult as bv, type PalbaseVerifyRequestSignatureParams as bw, type PalbaseWhereOperator as bx, type PolicyBinOp as by, PolicyBuilder as bz, type RuntimeServices as c, withRetry as c$, type TxPlan as c0, TxPlanError as c1, type TxPlanHandle as c2, type TxPlanOpResult as c3, type TxPlanRejection as c4, TxRefError as c5, type TxRow as c6, type TxRows as c7, type TxSelectOptions as c8, type TxSetShape as c9, defineSchema as cA, defineTable as cB, enumType as cC, exprCtx as cD, inc as cE, increment as cF, index as cG, installationRef as cH, integer as cI, isPalbaseExtension as cJ, isRetryable as cK, jsonb as cL, makeTypedDB as cM, now as cN, numeric as cO, onShutdown as cP, onStart as cQ, openai as cR, ownedByUser as cS, policy as cT, raw as cU, sqlFragment as cV, text as cW, timestamp as cX, userRef as cY, uuid as cZ, vector as c_, type TxSetValue as ca, type TxTable as cb, type TxTables as cc, type TxWhere as cd, type TxWireExpr as ce, type TxWireGuard as cf, type TxWireOp as cg, type TxWireRef as ch, type TxWireValue as ci, type TypedDB as cj, type TypedTable as ck, type TypedTx as cl, Unauthorized as cm, UniqueViolation as cn, type User as co, type VerifiedDevice as cp, __getRuntime as cq, __resetLifecycleHooks as cr, __runStartHooks as cs, __setRuntime as ct, bigint as cu, boolean as cv, col as cw, dec as cx, decrement as cy, defineMiddleware as cz, __requestALS as d, type PolicyExpr as e, type AnyColumn as f, Auth as g, type AuthConfig as h, Cache as i, type ClientInfo as j, type ColRef as k, ColumnBuilder as l, type ColumnDef as m, type ColumnMap as n, type ColumnType as o, Conflict as p, Database as q, DeadlockDetected as r, Documents as s, type EmbeddingModelRef as t, type EnvSchemas as u, type EnvServiceDatabase as v, type EnvTables as w, type EnvTypedDatabase as x, type EnvTypedTable as y, type ErrorDef as z };
|
|
@@ -39,6 +39,20 @@ interface User {
|
|
|
39
39
|
*/
|
|
40
40
|
emailVerified: boolean;
|
|
41
41
|
role: string;
|
|
42
|
+
/**
|
|
43
|
+
* The caller's APPLICATION roles, as assigned in `auth.user_roles`.
|
|
44
|
+
*
|
|
45
|
+
* Not to be confused with {@link User.role}, which is the DATABASE role RLS
|
|
46
|
+
* reads and is the literal string "authenticated" for every signed-in user.
|
|
47
|
+
* These are the names a stack declares (`palbase roles`) and an operator
|
|
48
|
+
* assigns; `auth: { role }` gates on the same set.
|
|
49
|
+
*
|
|
50
|
+
* Resolved per request from the table, in the transaction the handler is
|
|
51
|
+
* about to use — never from a token claim, so a role revoked a second ago is
|
|
52
|
+
* already gone here. An empty array for a caller who holds none, never null:
|
|
53
|
+
* `user.roles.includes("agent")` needs no guard.
|
|
54
|
+
*/
|
|
55
|
+
roles: string[];
|
|
42
56
|
metadata: Record<string, unknown>;
|
|
43
57
|
/**
|
|
44
58
|
* Reserved, server-owned verified device claim. `null` on an authenticated
|
|
@@ -2080,6 +2094,37 @@ interface PalbaseAuthClient {
|
|
|
2080
2094
|
dispose(): void;
|
|
2081
2095
|
};
|
|
2082
2096
|
}
|
|
2097
|
+
/**
|
|
2098
|
+
* The `Auth` singleton a backend handler reaches — the ROLE-ASSIGNMENT surface,
|
|
2099
|
+
* and nothing else.
|
|
2100
|
+
*
|
|
2101
|
+
* Deliberately not {@link PalbaseAuthClient}: that one is a person acting on
|
|
2102
|
+
* their own account (sign-in, MFA, device attestation) and it belongs to the
|
|
2103
|
+
* client SDK. What a server needs is the operator verb — "make this user an
|
|
2104
|
+
* agent" — because the promotion usually happens inside the tenant's own
|
|
2105
|
+
* product, in a handler a supervisor triggers.
|
|
2106
|
+
*
|
|
2107
|
+
* These calls carry the SERVICE-ROLE credential: the routes behind them refuse
|
|
2108
|
+
* anon and `authenticated` alike (FR-013), which is what stops an end user from
|
|
2109
|
+
* granting themselves the permission the rest of the feature gates on.
|
|
2110
|
+
*
|
|
2111
|
+
* Unlike the other clients here these THROW rather than envelope, because two
|
|
2112
|
+
* of the three answer `void` — a refusal that came back as a value would be
|
|
2113
|
+
* indistinguishable from a write that happened. See `clients/auth.ts`.
|
|
2114
|
+
*/
|
|
2115
|
+
interface PalbaseAuthAdminClient {
|
|
2116
|
+
/**
|
|
2117
|
+
* Give a user a role. Idempotent: assigning one they already hold is not an
|
|
2118
|
+
* error and leaves one row. Throws `RoleNotDefined` when the stack declares
|
|
2119
|
+
* no role by that name.
|
|
2120
|
+
*/
|
|
2121
|
+
assignRole(userId: string, role: string): Promise<void>;
|
|
2122
|
+
/** Take a role away. Revoking one they do not hold is not an error. */
|
|
2123
|
+
revokeRole(userId: string, role: string): Promise<void>;
|
|
2124
|
+
/** What that user holds right now. `[]` for a user with no roles — a FAILED
|
|
2125
|
+
* read throws rather than answering the same thing. */
|
|
2126
|
+
rolesOf(userId: string): Promise<string[]>;
|
|
2127
|
+
}
|
|
2083
2128
|
/**
|
|
2084
2129
|
* Bucket-level file operations available via `ctx.storage.bucket(name)`.
|
|
2085
2130
|
* `getPublicUrl` is synchronous (no network call — constructs URL locally).
|
|
@@ -2539,11 +2584,14 @@ interface PalbaseLinksClient {
|
|
|
2539
2584
|
* Realtime is BROADCAST-ONLY here (a stateless handler can push an event but
|
|
2540
2585
|
* cannot hold a subscription socket — `subscribe()` lives on the client SDK).
|
|
2541
2586
|
*
|
|
2542
|
-
* EXCLUDED on purpose: Functions, Links, Analytics
|
|
2543
|
-
*
|
|
2544
|
-
*
|
|
2587
|
+
* EXCLUDED on purpose: Functions, Links, Analytics. They are not exposed as
|
|
2588
|
+
* backend handler singletons — out of scope for backend endpoints. `Auth` is
|
|
2589
|
+
* here in its ROLE-ASSIGNMENT shape only: signing in is the client SDK's job,
|
|
2590
|
+
* but granting a role is an operator verb the tenant's own handler needs
|
|
2591
|
+
* (FR-009). */
|
|
2545
2592
|
interface RuntimeServices {
|
|
2546
2593
|
Database: DBClient;
|
|
2594
|
+
Auth: PalbaseAuthAdminClient;
|
|
2547
2595
|
Secrets: SecretsService;
|
|
2548
2596
|
Documents: PalbaseDocsClient;
|
|
2549
2597
|
Storage: PalbaseStorageClient;
|
|
@@ -2753,6 +2801,20 @@ declare const Cache: CacheClient;
|
|
|
2753
2801
|
* the STACK holds, because no route returns a platform secret's value at all.
|
|
2754
2802
|
*/
|
|
2755
2803
|
declare const Secrets: SecretsService;
|
|
2804
|
+
/**
|
|
2805
|
+
* Role assignment, as an operator — `Auth.assignRole(userId, "agent")`.
|
|
2806
|
+
*
|
|
2807
|
+
* The half of auth a SERVER owns. Signing in, MFA and device attestation are a
|
|
2808
|
+
* person acting on their own account and live on the client SDK; granting a
|
|
2809
|
+
* role is the tenant's product doing something to somebody else, which is
|
|
2810
|
+
* exactly what a handler is for. It writes with the service-role credential,
|
|
2811
|
+
* because an end user who could write their own assignment would make every
|
|
2812
|
+
* permission underneath it meaningless.
|
|
2813
|
+
*
|
|
2814
|
+
* The write is visible to the very next request: authority is read from the
|
|
2815
|
+
* table on each call, never carried on a token.
|
|
2816
|
+
*/
|
|
2817
|
+
declare const Auth: PalbaseAuthAdminClient;
|
|
2756
2818
|
/** Structured logger. */
|
|
2757
2819
|
declare const Log: Logger;
|
|
2758
2820
|
/** Push / email / SMS / in-app notifications. */
|
|
@@ -5098,4 +5160,4 @@ type Middleware = (ctx: MiddlewareContext, next: () => Promise<void>) => Promise
|
|
|
5098
5160
|
*/
|
|
5099
5161
|
type AuthSpec = boolean | Partial<AuthConfig>;
|
|
5100
5162
|
|
|
5101
|
-
export {
|
|
5163
|
+
export { NotFound as $, type AuthSpec as A, BadRequest as B, type CacheClient as C, type DBClient as D, EXTENSION_DEPENDENCIES as E, type ErrorMap as F, type ErrorThrowers as G, HttpError as H, type FileContext as I, Flags as J, Forbidden as K, type HttpMethod as L, IndexBuilder as M, type IndexDef as N, type InsertShape as O, type PalbaseResult as P, type LifecycleHook as Q, type RateLimitConfig as R, type SchemaDef as S, type TxPlanBody as T, Log as U, type Logger as V, type Materialized as W, type Middleware as X, type MiddlewareContext as Y, type MiddlewareHandler as Z, __runWithRuntime as _, type DBOps as a, type PalbaseListLinksOptions as a$, Notifications as a0, type OnDeleteAction as a1, PALBASE_EXTENSIONS as a2, type PBRequest as a3, PalError as a4, type PalbaseAnalyticsClient as a5, type PalbaseAnalyticsManagementNamespace as a6, type PalbaseAnalyticsProperties as a7, type PalbaseAnalyticsQueryNamespace as a8, type PalbaseAttestAndroidParams as a9, type PalbaseEventsQueryInput as aA, type PalbaseEventsResult as aB, type PalbaseExtension as aC, type PalbaseFileObject as aD, type PalbaseFlag as aE, type PalbaseFlagContext as aF, type PalbaseFlagSource as aG, type PalbaseFlagValue as aH, type PalbaseFlagVariant as aI, type PalbaseFlagsClient as aJ, type PalbaseFlagsServiceClient as aK, type PalbaseFunctionsClient as aL, type PalbaseFunnelQueryInput as aM, type PalbaseFunnelResult as aN, type PalbaseIdentifyTraits as aO, type PalbaseInboxClient as aP, type PalbaseInboxListOptions as aQ, type PalbaseInboxListResult as aR, type PalbaseInboxMessage as aS, type PalbaseInboxSendParams as aT, type PalbaseInboxSendResponse as aU, type PalbaseInitialLink as aV, type PalbaseInvokeOptions as aW, type PalbaseLink as aX, type PalbaseLinkAnalytics as aY, type PalbaseLinkDetails as aZ, type PalbaseLinksClient as a_, type PalbaseAttestAndroidResult as aa, type PalbaseAttestiOSParams as ab, type PalbaseAttestiOSResult as ac, type PalbaseAuthAdminClient as ad, type PalbaseAuthClient as ae, type PalbaseBatchOverrideOperation as af, type PalbaseBatchSetOverridesResult as ag, type PalbaseBindDeviceParams as ah, type PalbaseBucketClient as ai, type PalbaseClearAllOverridesResult as aj, type PalbaseClearOverrideResult as ak, type PalbaseCohortQueryInput as al, type PalbaseCohortResult as am, type PalbaseCollectionRef as an, type PalbaseCountQueryInput as ao, type PalbaseCountResult as ap, type PalbaseCreateLinkParams as aq, type PalbaseDeviceInfo as ar, type PalbaseDeviceTokenView as as, type PalbaseDocsClient as at, type PalbaseDocumentRef as au, type PalbaseDocumentSnapshot as av, type PalbaseEmailClient as aw, type PalbaseEmailSendParams as ax, type PalbaseEmailSendResponse as ay, type PalbaseEventNamesResult as az, type TxPlanResponse as b, type TxNow as b$, type PalbaseListLinksResult as b0, type PalbaseListOptions as b1, type PalbaseMatchParams as b2, type PalbaseMultiChannelResponse as b3, type PalbaseNotificationsClient as b4, type PalbaseOverviewResult as b5, type PalbasePreferences as b6, type PalbasePreferencesClient as b7, type PalbasePushClient as b8, type PalbasePushSendParams as b9, type PolicyCommand as bA, type PolicyDef as bB, type PolicyExprCtx as bC, PolicyExprRef as bD, type PolicyMode as bE, type PolicyOperand as bF, type RawConstraintDef as bG, Realtime as bH, type Ref as bI, type RequestStore as bJ, type RowShape as bK, Secrets as bL, type SecretsService as bM, SerializationFailure as bN, type SetShape as bO, type SetValue as bP, type ShutdownRunner as bQ, type SqlFragment as bR, Storage as bS, TABLE_META as bT, type TableDef as bU, type TableHandle as bV, type TableInput as bW, TooManyRequests as bX, type TxColumnExpr as bY, type TxInsertShape as bZ, type TxInsertValue as b_, type PalbasePushSendResponse as ba, type PalbaseQrCodeOptions as bb, type PalbaseQuerySnapshot as bc, type PalbaseRealtimeClient as bd, type PalbaseRegisterDeviceParams as be, type PalbaseRetentionQueryInput as bf, type PalbaseRetentionResult as bg, type PalbaseSession as bh, type PalbaseSetOverrideResult as bi, type PalbaseSetOverridesResult as bj, type PalbaseSignedUrlResponse as bk, type PalbaseSmsClient as bl, type PalbaseSmsSendParams as bm, type PalbaseSmsSendResponse as bn, type PalbaseStorageClient as bo, type PalbaseTransformOptions as bp, type PalbaseUpdateLinkParams as bq, type PalbaseUploadOptions as br, type PalbaseUser as bs, type PalbaseUserDetailResult as bt, type PalbaseUsersQueryInput as bu, type PalbaseUsersResult as bv, type PalbaseVerifyRequestSignatureParams as bw, type PalbaseWhereOperator as bx, type PolicyBinOp as by, PolicyBuilder as bz, type RuntimeServices as c, withRetry as c$, type TxPlan as c0, TxPlanError as c1, type TxPlanHandle as c2, type TxPlanOpResult as c3, type TxPlanRejection as c4, TxRefError as c5, type TxRow as c6, type TxRows as c7, type TxSelectOptions as c8, type TxSetShape as c9, defineSchema as cA, defineTable as cB, enumType as cC, exprCtx as cD, inc as cE, increment as cF, index as cG, installationRef as cH, integer as cI, isPalbaseExtension as cJ, isRetryable as cK, jsonb as cL, makeTypedDB as cM, now as cN, numeric as cO, onShutdown as cP, onStart as cQ, openai as cR, ownedByUser as cS, policy as cT, raw as cU, sqlFragment as cV, text as cW, timestamp as cX, userRef as cY, uuid as cZ, vector as c_, type TxSetValue as ca, type TxTable as cb, type TxTables as cc, type TxWhere as cd, type TxWireExpr as ce, type TxWireGuard as cf, type TxWireOp as cg, type TxWireRef as ch, type TxWireValue as ci, type TypedDB as cj, type TypedTable as ck, type TypedTx as cl, Unauthorized as cm, UniqueViolation as cn, type User as co, type VerifiedDevice as cp, __getRuntime as cq, __resetLifecycleHooks as cr, __runStartHooks as cs, __setRuntime as ct, bigint as cu, boolean as cv, col as cw, dec as cx, decrement as cy, defineMiddleware as cz, __requestALS as d, type PolicyExpr as e, type AnyColumn as f, Auth as g, type AuthConfig as h, Cache as i, type ClientInfo as j, type ColRef as k, ColumnBuilder as l, type ColumnDef as m, type ColumnMap as n, type ColumnType as o, Conflict as p, Database as q, DeadlockDetected as r, Documents as s, type EmbeddingModelRef as t, type EnvSchemas as u, type EnvServiceDatabase as v, type EnvTables as w, type EnvTypedDatabase as x, type EnvTypedTable as y, type ErrorDef as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DBClient, a as DBOps, T as TxPlanBody, b as TxPlanResponse, A as AuthSpec, C as CacheClient, c as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-
|
|
1
|
+
import { D as DBClient, a as DBOps, T as TxPlanBody, b as TxPlanResponse, A as AuthSpec, C as CacheClient, c as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-DtCgaZAg.cjs';
|
|
2
2
|
import { T as Token } from './module-Dl1KFVtc.cjs';
|
|
3
|
-
import { R as RouteMeta } from './registry-
|
|
3
|
+
import { R as RouteMeta } from './registry-CEYLH-Iz.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* engine/config.ts — settings from the environment, and the gate that refuses
|
|
@@ -998,7 +998,7 @@ interface RuntimeHooks {
|
|
|
998
998
|
__requestALS: typeof __requestALS;
|
|
999
999
|
}
|
|
1000
1000
|
/** The module singletons the engine injects, minus the two it owns itself. */
|
|
1001
|
-
type ModuleClients = Partial<Pick<RuntimeServices, "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
|
|
1001
|
+
type ModuleClients = Partial<Pick<RuntimeServices, "Auth" | "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
|
|
1002
1002
|
interface CreateAppOptions {
|
|
1003
1003
|
/**
|
|
1004
1004
|
* Vault'tan TEK secret okuma (FR-025): sorgu-anı embedding'in anahtarı
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DBClient, a as DBOps, T as TxPlanBody, b as TxPlanResponse, A as AuthSpec, C as CacheClient, c as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-
|
|
1
|
+
import { D as DBClient, a as DBOps, T as TxPlanBody, b as TxPlanResponse, A as AuthSpec, C as CacheClient, c as RuntimeServices, _ as __runWithRuntime, d as __requestALS } from './index-8qy3kIuA.js';
|
|
2
2
|
import { T as Token } from './module-Dl1KFVtc.js';
|
|
3
|
-
import { R as RouteMeta } from './registry-
|
|
3
|
+
import { R as RouteMeta } from './registry-BGJ-Al6F.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* engine/config.ts — settings from the environment, and the gate that refuses
|
|
@@ -998,7 +998,7 @@ interface RuntimeHooks {
|
|
|
998
998
|
__requestALS: typeof __requestALS;
|
|
999
999
|
}
|
|
1000
1000
|
/** The module singletons the engine injects, minus the two it owns itself. */
|
|
1001
|
-
type ModuleClients = Partial<Pick<RuntimeServices, "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
|
|
1001
|
+
type ModuleClients = Partial<Pick<RuntimeServices, "Auth" | "Documents" | "Storage" | "Notifications" | "Flags" | "Realtime" | "Secrets">>;
|
|
1002
1002
|
interface CreateAppOptions {
|
|
1003
1003
|
/**
|
|
1004
1004
|
* Vault'tan TEK secret okuma (FR-025): sorgu-anı embedding'in anahtarı
|
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
|
+
Auth: () => Auth,
|
|
24
25
|
BadRequest: () => BadRequest,
|
|
25
26
|
Body: () => Body,
|
|
26
27
|
Cache: () => Cache,
|
|
@@ -71,6 +72,7 @@ __export(src_exports, {
|
|
|
71
72
|
Realtime: () => Realtime,
|
|
72
73
|
Req: () => Req,
|
|
73
74
|
RequestId: () => RequestId,
|
|
75
|
+
RoleNotDefined: () => RoleNotDefined,
|
|
74
76
|
Room: () => Room,
|
|
75
77
|
Secrets: () => Secrets,
|
|
76
78
|
SerializationFailure: () => SerializationFailure,
|
|
@@ -1520,6 +1522,7 @@ var Storage = Object.assign({
|
|
|
1520
1522
|
});
|
|
1521
1523
|
var Cache = makeServiceProxy("Cache");
|
|
1522
1524
|
var Secrets = makeServiceProxy("Secrets");
|
|
1525
|
+
var Auth = makeServiceProxy("Auth");
|
|
1523
1526
|
var Log = makeServiceProxy("Log");
|
|
1524
1527
|
var Notifications = makeServiceProxy("Notifications");
|
|
1525
1528
|
var rawFlags = makeServiceProxy("Flags");
|
|
@@ -1647,6 +1650,48 @@ function makeHttpClient(cfg) {
|
|
|
1647
1650
|
}
|
|
1648
1651
|
__name(makeHttpClient, "makeHttpClient");
|
|
1649
1652
|
|
|
1653
|
+
// src/clients/auth.ts
|
|
1654
|
+
var RoleNotDefined = class extends Error {
|
|
1655
|
+
static {
|
|
1656
|
+
__name(this, "RoleNotDefined");
|
|
1657
|
+
}
|
|
1658
|
+
role;
|
|
1659
|
+
constructor(role, message) {
|
|
1660
|
+
super(message ?? `No role named "${role}" is defined for this stack`);
|
|
1661
|
+
this.name = "RoleNotDefined";
|
|
1662
|
+
this.role = role;
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
function refuse(error, role) {
|
|
1666
|
+
if (error.code === "role_not_defined") throw new RoleNotDefined(role, error.message);
|
|
1667
|
+
if (error instanceof PalbaseModuleError) throw error;
|
|
1668
|
+
throw new PalbaseModuleError(error.code ?? "unknown_error", error.message ?? "request failed", 0);
|
|
1669
|
+
}
|
|
1670
|
+
__name(refuse, "refuse");
|
|
1671
|
+
function rolesPath(userId, role) {
|
|
1672
|
+
const base = `/admin/users/${encodeURIComponent(userId)}/roles`;
|
|
1673
|
+
return role === void 0 ? base : `${base}/${encodeURIComponent(role)}`;
|
|
1674
|
+
}
|
|
1675
|
+
__name(rolesPath, "rolesPath");
|
|
1676
|
+
function buildAuthClient(http) {
|
|
1677
|
+
return {
|
|
1678
|
+
async assignRole(userId, role) {
|
|
1679
|
+
const { error } = await http.request("PUT", rolesPath(userId, role));
|
|
1680
|
+
if (error) refuse(error, role);
|
|
1681
|
+
},
|
|
1682
|
+
async revokeRole(userId, role) {
|
|
1683
|
+
const { error } = await http.request("DELETE", rolesPath(userId, role));
|
|
1684
|
+
if (error) refuse(error, role);
|
|
1685
|
+
},
|
|
1686
|
+
async rolesOf(userId) {
|
|
1687
|
+
const { data, error } = await http.request("GET", rolesPath(userId));
|
|
1688
|
+
if (error) refuse(error, "");
|
|
1689
|
+
return data?.roles ?? [];
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
__name(buildAuthClient, "buildAuthClient");
|
|
1694
|
+
|
|
1650
1695
|
// src/clients/documents.ts
|
|
1651
1696
|
var SEGMENT_RE = /^[A-Za-z0-9_-]+$/;
|
|
1652
1697
|
function validateSegment(segment, label) {
|
|
@@ -2631,6 +2676,10 @@ function buildModuleClients(cfg) {
|
|
|
2631
2676
|
fetchImpl: cfg.fetchImpl
|
|
2632
2677
|
});
|
|
2633
2678
|
return {
|
|
2679
|
+
// The ROLE half of auth only (`clients/auth.ts` says why the rest is not
|
|
2680
|
+
// here). It rides the same service-role transport, which is exactly the
|
|
2681
|
+
// credential the assignment routes demand.
|
|
2682
|
+
Auth: buildAuthClient(http),
|
|
2634
2683
|
Documents: buildDocumentsClient(http),
|
|
2635
2684
|
Storage: buildStorageClient(http, cfg.publicOrigin),
|
|
2636
2685
|
Notifications: buildNotificationsClient(http),
|
|
@@ -5280,6 +5329,7 @@ __name(getJobConfig, "getJobConfig");
|
|
|
5280
5329
|
var import_zod2 = require("zod");
|
|
5281
5330
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5282
5331
|
0 && (module.exports = {
|
|
5332
|
+
Auth,
|
|
5283
5333
|
BadRequest,
|
|
5284
5334
|
Body,
|
|
5285
5335
|
Cache,
|
|
@@ -5330,6 +5380,7 @@ var import_zod2 = require("zod");
|
|
|
5330
5380
|
Realtime,
|
|
5331
5381
|
Req,
|
|
5332
5382
|
RequestId,
|
|
5383
|
+
RoleNotDefined,
|
|
5333
5384
|
Room,
|
|
5334
5385
|
Secrets,
|
|
5335
5386
|
SerializationFailure,
|