@fuzdev/fuz_app 0.186.0 → 0.187.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/auth/CLAUDE.md +10 -5
- package/dist/auth/account_queries.d.ts +8 -5
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +8 -5
- package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +2 -1
- package/dist/auth/role_grant_offer_actions.d.ts +12 -0
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +48 -20
- package/dist/auth/role_grant_offer_queries.d.ts +16 -3
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +24 -4
- package/dist/auth/role_grant_queries.d.ts +102 -11
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +129 -15
- package/dist/db/migrate.d.ts +46 -22
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +103 -85
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +1 -4
- package/dist/testing/CLAUDE.md +35 -0
- package/dist/testing/cross_backend/backend_both_live.d.ts +47 -0
- package/dist/testing/cross_backend/backend_both_live.d.ts.map +1 -0
- package/dist/testing/cross_backend/backend_both_live.js +566 -0
- package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -1
- package/dist/testing/cross_backend/backend_swap.js +37 -201
- package/dist/testing/cross_backend/shared_database_backends.d.ts +175 -0
- package/dist/testing/cross_backend/shared_database_backends.d.ts.map +1 -0
- package/dist/testing/cross_backend/shared_database_backends.js +298 -0
- package/dist/testing/cross_backend/spine_suites.d.ts +1 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +1 -0
- package/package.json +4 -3
package/dist/auth/CLAUDE.md
CHANGED
|
@@ -251,11 +251,16 @@ cannot disagree.
|
|
|
251
251
|
### Row locks
|
|
252
252
|
|
|
253
253
|
One class order in every transaction — accounts, then offers, then grants and
|
|
254
|
-
actors — and id order within a class
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
actors — and id order within a class, behind a scope's advisory lock where one
|
|
255
|
+
is taken (`query_scope_lock_shared` / `query_scope_lock_exclusive`: a scope's
|
|
256
|
+
teardown exclusive, the scoped offer, assign, grant and accept writes shared;
|
|
257
|
+
every spine path takes it before any row, a later re-take in the same
|
|
258
|
+
transaction being free, and a direct caller of these queries must too, unless
|
|
259
|
+
its transaction already holds the scope lock). Every writer of an account takes its row first (two mints of one
|
|
260
|
+
account take turns there, so the caps hold) — a delete and a purge after their
|
|
261
|
+
last-admin guard, which an admin target's row is locked within, then the
|
|
262
|
+
guards again; a multi-row write locks its rows in one id-ordered statement
|
|
263
|
+
before writing.
|
|
259
264
|
Each lock's strength and reason is on its query's TSDoc; the rule set:
|
|
260
265
|
../../../docs/security.md §Row Locks. `lock_pins.cross.test.ts` pins them on
|
|
261
266
|
both spines (../../test/CLAUDE.md).
|
|
@@ -127,8 +127,8 @@ export declare const query_update_account_password: (deps: QueryDeps, id: string
|
|
|
127
127
|
* account does not conflict with it, so no write that merely references the
|
|
128
128
|
* account waits on a login. Besides the writers it orders against, it
|
|
129
129
|
* conflicts with `query_account_lock_live` (the token mint, the same
|
|
130
|
-
* strength), the `FOR SHARE` of `query_account_lock_live_many` (an offer
|
|
131
|
-
* invite create), an offer accept's locks (`query_account_lock_for_offer_accept`,
|
|
130
|
+
* strength), the `FOR SHARE` of `query_account_lock_live_many` (an offer,
|
|
131
|
+
* invite or assign create), an offer accept's locks (`query_account_lock_for_offer_accept`,
|
|
132
132
|
* the recipient's at this strength, a grantor's shared), and the last-admin
|
|
133
133
|
* guard's `FOR NO KEY UPDATE`. None of
|
|
134
134
|
* those waits on an account row while holding a session row, and once a mint
|
|
@@ -173,8 +173,10 @@ export declare const query_account_lock_live: (deps: QueryDeps, id: string) => P
|
|
|
173
173
|
* (`query_account_purge_advisory_lock`): the ASCII of `fuz_` and `purg`.
|
|
174
174
|
*
|
|
175
175
|
* The two-`int4` form, `pg_advisory_xact_lock(int4, int4)`, a key space apart
|
|
176
|
-
* from the single
|
|
177
|
-
* `
|
|
176
|
+
* from the single `bigint` key the migration runner's per-namespace
|
|
177
|
+
* `pg_advisory_xact_lock(bigint)` takes, so no namespace's hash can collide with it.
|
|
178
|
+
* Its first half is reserved to this lock; the scope locks take `fuzs`
|
|
179
|
+
* (`SCOPE_ADVISORY_LOCK_CLASS` in `auth/role_grant_queries.ts`).
|
|
178
180
|
* Twin of the Rust `fuz_auth::account_queries::ACCOUNT_PURGE_ADVISORY_LOCK_KEY`.
|
|
179
181
|
*/
|
|
180
182
|
export declare const ACCOUNT_PURGE_ADVISORY_LOCK_KEY: readonly [number, number];
|
|
@@ -252,7 +254,8 @@ export declare const query_account_lock_for_purge: (deps: QueryDeps, id: string)
|
|
|
252
254
|
* be ordered against a delete of any of them.
|
|
253
255
|
*
|
|
254
256
|
* An offer locks its two parties (`query_role_grant_offer_create`), an invite
|
|
255
|
-
* its issuer (`query_create_invite`, one id)
|
|
257
|
+
* its issuer (`query_create_invite`, one id), a `role_grant_assign` its
|
|
258
|
+
* recipient and its caller (`create_role_grant_offer_actions`).
|
|
256
259
|
*
|
|
257
260
|
* `FOR SHARE`: the weakest lock that conflicts with a delete's `UPDATE` of the
|
|
258
261
|
* row, so these writes don't wait on one another. It also waits on a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQrD,OAAO,EAEN,KAAK,OAAO,EACZ,KAAK,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AAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAC1C,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAKtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC7B,MAAM,SAAS,EACf,IAAI,MAAM,KACR,OAAO,CAAC,KAAK,GAAG,SAAS,CAK3B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,GAC3C,MAAM,SAAS,EACf,OAAO,kBAAkB,KACvB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAI5C,CAAC;AAgDF,8CAA8C;AAC9C,MAAM,WAAW,uBAAuB;IACvC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,SAAS,EACf,UAAU,uBAAuB,KAC/B,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAkHtC,CAAC"}
|
|
@@ -189,8 +189,8 @@ export const query_update_account_password = async (deps, id, password_hash, upd
|
|
|
189
189
|
* account does not conflict with it, so no write that merely references the
|
|
190
190
|
* account waits on a login. Besides the writers it orders against, it
|
|
191
191
|
* conflicts with `query_account_lock_live` (the token mint, the same
|
|
192
|
-
* strength), the `FOR SHARE` of `query_account_lock_live_many` (an offer
|
|
193
|
-
* invite create), an offer accept's locks (`query_account_lock_for_offer_accept`,
|
|
192
|
+
* strength), the `FOR SHARE` of `query_account_lock_live_many` (an offer,
|
|
193
|
+
* invite or assign create), an offer accept's locks (`query_account_lock_for_offer_accept`,
|
|
194
194
|
* the recipient's at this strength, a grantor's shared), and the last-admin
|
|
195
195
|
* guard's `FOR NO KEY UPDATE`. None of
|
|
196
196
|
* those waits on an account row while holding a session row, and once a mint
|
|
@@ -243,8 +243,10 @@ export const query_account_lock_live = async (deps, id) => {
|
|
|
243
243
|
* (`query_account_purge_advisory_lock`): the ASCII of `fuz_` and `purg`.
|
|
244
244
|
*
|
|
245
245
|
* The two-`int4` form, `pg_advisory_xact_lock(int4, int4)`, a key space apart
|
|
246
|
-
* from the single
|
|
247
|
-
* `
|
|
246
|
+
* from the single `bigint` key the migration runner's per-namespace
|
|
247
|
+
* `pg_advisory_xact_lock(bigint)` takes, so no namespace's hash can collide with it.
|
|
248
|
+
* Its first half is reserved to this lock; the scope locks take `fuzs`
|
|
249
|
+
* (`SCOPE_ADVISORY_LOCK_CLASS` in `auth/role_grant_queries.ts`).
|
|
248
250
|
* Twin of the Rust `fuz_auth::account_queries::ACCOUNT_PURGE_ADVISORY_LOCK_KEY`.
|
|
249
251
|
*/
|
|
250
252
|
export const ACCOUNT_PURGE_ADVISORY_LOCK_KEY = [
|
|
@@ -333,7 +335,8 @@ export const query_account_lock_for_purge = async (deps, id) => {
|
|
|
333
335
|
* be ordered against a delete of any of them.
|
|
334
336
|
*
|
|
335
337
|
* An offer locks its two parties (`query_role_grant_offer_create`), an invite
|
|
336
|
-
* its issuer (`query_create_invite`, one id)
|
|
338
|
+
* its issuer (`query_create_invite`, one id), a `role_grant_assign` its
|
|
339
|
+
* recipient and its caller (`create_role_grant_offer_actions`).
|
|
337
340
|
*
|
|
338
341
|
* `FOR SHARE`: the weakest lock that conflicts with a delete's `UPDATE` of the
|
|
339
342
|
* row, so these writes don't wait on one another. It also waits on a
|
|
@@ -684,7 +684,7 @@ export declare const role_grant_assign_action_spec: {
|
|
|
684
684
|
}>;
|
|
685
685
|
async: true;
|
|
686
686
|
description: string;
|
|
687
|
-
error_reasons: ("role_grant_offer_not_authorized" | "role_grant_offer_actor_account_mismatch" | "role_grant_builtin_scoped" | "role_not_web_grantable" | "insufficient_permissions")[];
|
|
687
|
+
error_reasons: ("role_grant_offer_not_authorized" | "role_grant_offer_actor_account_mismatch" | "role_grant_builtin_scoped" | "authentication_required" | "role_not_web_grantable" | "insufficient_permissions")[];
|
|
688
688
|
rate_limit: "account";
|
|
689
689
|
};
|
|
690
690
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_grant_offer_action_specs.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAcN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAkB3E,oEAAoE;AACpE,eAAO,MAAM,kCAAkC,EAAG,8BAAuC,CAAC;AAC1F,kEAAkE;AAClE,eAAO,MAAM,+BAA+B,EAAG,2BAAoC,CAAC;AACpF,sDAAsD;AACtD,eAAO,MAAM,8BAA8B,EAAG,0BAAmC,CAAC;AAClF,wGAAwG;AACxG,eAAO,MAAM,gCAAgC,EAAG,4BAAqC,CAAC;AACtF,uIAAuI;AACvI,eAAO,MAAM,yCAAyC,EACrD,qCAA8C,CAAC;AAChD,gKAAgK;AAChK,eAAO,MAAM,qCAAqC,EAAG,iCAA0C,CAAC;AAChG,6FAA6F;AAC7F,eAAO,MAAM,qCAAqC,EAAG,iCAA0C,CAAC;AAChG,wHAAwH;AACxH,eAAO,MAAM,6CAA6C,EACzD,yCAAkD,CAAC;AACpD;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,EAAG,2BAAoC,CAAC;AACpF;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,EAAG,4BAAqC,CAAC;AACtF;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,EAAG,0BAAmC,CAAC;AAElF;;;;;;;;;GASG;AACH,eAAO,MAAM,qB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBL,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,EAAE,KAAK,CAAC,yBAAyB,CAS9E,CAAC"}
|
|
@@ -407,7 +407,8 @@ export const role_grant_assign_action_spec = {
|
|
|
407
407
|
ERROR_ROLE_NOT_WEB_GRANTABLE,
|
|
408
408
|
ERROR_ROLE_GRANT_BUILTIN_SCOPED,
|
|
409
409
|
ERROR_ROLE_GRANT_OFFER_NOT_AUTHORIZED,
|
|
410
|
-
ERROR_ROLE_GRANT_OFFER_ACTOR_ACCOUNT_MISMATCH
|
|
410
|
+
ERROR_ROLE_GRANT_OFFER_ACTOR_ACCOUNT_MISMATCH,
|
|
411
|
+
ERROR_AUTHENTICATION_REQUIRED
|
|
411
412
|
],
|
|
412
413
|
rate_limit: 'account'
|
|
413
414
|
};
|
|
@@ -102,6 +102,18 @@ export declare const emit_supersede_audits: (ctx: ActionActorContext, audit: Aud
|
|
|
102
102
|
* check, say) reads through it. **Read-only** — the callback decides, it never
|
|
103
103
|
* writes; a write would commit or roll back with the request, and nothing
|
|
104
104
|
* enforces this but the callback.
|
|
105
|
+
*
|
|
106
|
+
* **Runs under the scope lock** when the input is scoped: both verbs take
|
|
107
|
+
* `scope_id`'s lock shared (`query_scope_lock_shared`) before calling it, so
|
|
108
|
+
* a scope-existence read sees every teardown that committed first — under READ
|
|
109
|
+
* COMMITTED, where each statement takes a fresh snapshot; under REPEATABLE
|
|
110
|
+
* READ the snapshot predates the lock's wait and the read would miss it — and
|
|
111
|
+
* a teardown still to come waits for the request to commit. That holds only
|
|
112
|
+
* for a consumer teardown that goes through
|
|
113
|
+
* `query_role_grant_revoke_for_scope` before it removes the scope row, or
|
|
114
|
+
* takes `query_scope_lock_exclusive` first; one that removes the row first
|
|
115
|
+
* leaves the window open, and one that locks the row first deadlocks with a
|
|
116
|
+
* callback that locks it.
|
|
105
117
|
*/
|
|
106
118
|
export type RoleGrantOfferCreateAuthorize = (auth: RequestContext, input: {
|
|
107
119
|
to_account_id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_grant_offer_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAEN,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAMN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGN,KAAK,eAAe,EACpB,MAAM,8BAA8B,CAAC;AA6BtC,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAQN,KAAK,6BAA6B,EAElC,MAAM,qCAAqC,CAAC;AA6C7C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GACjC,KAAK,kBAAkB,EACvB,OAAO,YAAY,EACnB,YAAY,aAAa,CAAC,eAAe,CAAC,EAC1C,QAAQ,6BAA6B,CAAC,QAAQ,CAAC,EAC/C,UAAU,IAAI,KACZ,OAAO,CAAC,IAAI,CAed,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"role_grant_offer_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,KAAK,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KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,6BAA6B,CAAC;CAC1C;AA6CD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAC3C,MAAM,yBAAyB,EAC/B,UAAS,2BAAgC,KACvC,KAAK,CAAC,SAAS,CA8tBjB,CAAC"}
|
|
@@ -63,8 +63,8 @@ import { builtin_role_specs, is_builtin_role, ROLE_ADMIN, ROLE_KEEPER, role_has_
|
|
|
63
63
|
import { GRANT_PATH_ADMIN } from './grant_path_schema.js';
|
|
64
64
|
import { ROLE_GRANT_OFFER_DEFAULT_TTL_MS, to_role_grant_offer_json } from './role_grant_offer_schema.js';
|
|
65
65
|
import { query_role_grant_offer_create, query_role_grant_offer_decline, query_role_grant_offer_retract, query_role_grant_offer_list, query_role_grant_offer_history_for_account, query_accept_offer, RoleGrantOfferActorAccountMismatchError, RoleGrantOfferActorMismatchError, RoleGrantOfferGrantorNotActiveError, RoleGrantOfferRecipientNotActiveError, RoleGrantOfferAlreadyTerminalError, RoleGrantOfferBuiltinRefusedError, RoleGrantOfferExpiredError, RoleGrantOfferNotFoundError, RoleGrantOfferSelfTargetError, query_revoke_role_grant } from './role_grant_offer_queries.js';
|
|
66
|
-
import { query_account_has_active_global_role, query_account_has_global_role, query_count_active_accounts_with_global_role_locked, query_create_role_grant, query_role_grant_find_active_role_for_actor } from './role_grant_queries.js';
|
|
67
|
-
import { query_active_actors_by_account } from './account_queries.js';
|
|
66
|
+
import { query_account_has_active_global_role, query_account_has_global_role, query_count_active_accounts_with_global_role_locked, query_create_role_grant, query_role_grant_find_active_role_for_actor, query_scope_lock_shared } from './role_grant_queries.js';
|
|
67
|
+
import { query_account_lock_live_many, query_active_actors_by_account } from './account_queries.js';
|
|
68
68
|
import { has_scoped_role } from './request_context.js';
|
|
69
69
|
import { build_role_grant_offer_accepted_notification, build_role_grant_offer_declined_notification, build_role_grant_offer_received_notification, build_role_grant_offer_retracted_notification, build_role_grant_revoked_notification, queue_offer_notification, queue_supersede_notifications } from './role_grant_offer_notifications.js';
|
|
70
70
|
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_ROLE_GRANT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE } from '../http/error_schemas.js';
|
|
@@ -215,17 +215,6 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
215
215
|
reason: ERROR_ROLE_GRANT_OFFER_ACTOR_ACCOUNT_MISMATCH
|
|
216
216
|
})
|
|
217
217
|
: jsonrpc_errors.not_found('account');
|
|
218
|
-
// The recipient's active actors, refusing a recipient that can't receive a
|
|
219
|
-
// role: a missing or soft-deleted account (no active actor), or a named
|
|
220
|
-
// actor that is not one of them. Runs after every authority gate, so a
|
|
221
|
-
// caller refused the conferral learns nothing of the recipient.
|
|
222
|
-
const require_active_recipient = async (ctx, to_account_id, to_actor_id) => {
|
|
223
|
-
const actors = await query_active_actors_by_account(ctx, to_account_id);
|
|
224
|
-
if (to_actor_id != null ? !actors.some((a) => a.id === to_actor_id) : actors.length === 0) {
|
|
225
|
-
throw recipient_not_found_error(to_actor_id);
|
|
226
|
-
}
|
|
227
|
-
return actors;
|
|
228
|
-
};
|
|
229
218
|
// Returns {offer} only — no auto-accept. Recipient must call
|
|
230
219
|
// role_grant_offer_accept; admin tests drive the full consent flow over
|
|
231
220
|
// RPC (see testing/admin_integration.ts `offer_and_accept`), or seed
|
|
@@ -257,6 +246,12 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
257
246
|
reason: ERROR_ROLE_GRANT_OFFER_NOT_AUTHORIZED
|
|
258
247
|
});
|
|
259
248
|
}
|
|
249
|
+
// A scoped offer takes the scope lock before the callback reads the scope,
|
|
250
|
+
// so a teardown that committed first is seen (the callback refuses the
|
|
251
|
+
// dead scope) and one still to come waits for this offer, then supersedes
|
|
252
|
+
// it. The query takes it again, free.
|
|
253
|
+
if (input.scope_id != null)
|
|
254
|
+
await query_scope_lock_shared(ctx, input.scope_id);
|
|
260
255
|
const authorized = await authorize(auth, {
|
|
261
256
|
to_account_id: input.to_account_id,
|
|
262
257
|
role: input.role,
|
|
@@ -599,7 +594,8 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
599
594
|
// `role_grant_offer_create`. Gated at the dispatcher on a **global** admin
|
|
600
595
|
// (`roles: ['admin']`) and re-checked here, it re-checks admin-grantability
|
|
601
596
|
// (so keeper / CLI-only roles can't be web-assigned), refuses a scoped
|
|
602
|
-
// builtin role, runs the consumer's `authorize` callback,
|
|
597
|
+
// builtin role, runs the consumer's `authorize` callback, locks both
|
|
598
|
+
// parties' account rows and refuses either one removed, resolves the
|
|
603
599
|
// target actor, writes the idempotent grant with
|
|
604
600
|
// the input's `(scope_kind, scope_id)` pair, and emits a `role_grant_create`
|
|
605
601
|
// audit row — the same event the offer-accept and self-service paths emit.
|
|
@@ -644,7 +640,12 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
644
640
|
// The consumer's offer policy binds the immediate path too: assign is an
|
|
645
641
|
// offer the grantee doesn't get to decline, so a grant the `authorize`
|
|
646
642
|
// callback would refuse as an offer (a scope that doesn't exist, a role
|
|
647
|
-
// that must be scoped) is refused here, with the offer path's reason.
|
|
643
|
+
// that must be scoped) is refused here, with the offer path's reason. A
|
|
644
|
+
// scoped grant takes the scope lock first, as offer-create does, so the
|
|
645
|
+
// callback reads the scope after any teardown that committed first, and a
|
|
646
|
+
// teardown still to come waits for this grant and then revokes it.
|
|
647
|
+
if (input.scope_id != null)
|
|
648
|
+
await query_scope_lock_shared(ctx, input.scope_id);
|
|
648
649
|
const authorized = await authorize(auth, {
|
|
649
650
|
to_account_id: input.to_account_id,
|
|
650
651
|
role: input.role,
|
|
@@ -657,11 +658,38 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
657
658
|
reason: ERROR_ROLE_GRANT_OFFER_NOT_AUTHORIZED
|
|
658
659
|
});
|
|
659
660
|
}
|
|
660
|
-
//
|
|
661
|
-
//
|
|
662
|
-
//
|
|
663
|
-
//
|
|
664
|
-
|
|
661
|
+
// Both parties' account rows, locked in one statement in id order — the
|
|
662
|
+
// lock offer-create takes (`query_role_grant_offer_create`), at its
|
|
663
|
+
// position after every authority gate, so a caller refused the conferral
|
|
664
|
+
// learns nothing of the recipient. The credential was read before this
|
|
665
|
+
// transaction and nothing held the recipient: a delete or a purge of
|
|
666
|
+
// either, committed since, is waited for and seen, and one still to come
|
|
667
|
+
// waits for the grant to commit — so no grant lands on a tombstone (an undelete would bring
|
|
668
|
+
// it back) or meets a purged actor's foreign key. Judged recipient first,
|
|
669
|
+
// then the caller, as offer-create judges them.
|
|
670
|
+
const live = await query_account_lock_live_many(ctx, [input.to_account_id, auth.account.id]);
|
|
671
|
+
// The recipient: a live account with an active actor (the named one, when
|
|
672
|
+
// an actor is named). A missing or removed recipient 404-masks.
|
|
673
|
+
const actors = live.has(input.to_account_id)
|
|
674
|
+
? await query_active_actors_by_account(ctx, input.to_account_id)
|
|
675
|
+
: [];
|
|
676
|
+
if (input.to_actor_id != null
|
|
677
|
+
? !actors.some((a) => a.id === input.to_actor_id)
|
|
678
|
+
: actors.length === 0) {
|
|
679
|
+
throw recipient_not_found_error(input.to_actor_id);
|
|
680
|
+
}
|
|
681
|
+
// The caller: a live actor of a live account. One removed since its
|
|
682
|
+
// credential was read is refused as the dead credential it now is, as
|
|
683
|
+
// offer-create refuses its grantor, with no audit row from an account
|
|
684
|
+
// that is gone.
|
|
685
|
+
if (!live.has(auth.account.id) ||
|
|
686
|
+
!(await query_active_actors_by_account(ctx, auth.account.id)).some((a) => a.id === auth.actor.id)) {
|
|
687
|
+
throw jsonrpc_errors.unauthenticated('unauthenticated', {
|
|
688
|
+
reason: ERROR_AUTHENTICATION_REQUIRED
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
// The grant's target actor: the named one, else the account's sole active
|
|
692
|
+
// actor (a multi-actor account must name one).
|
|
665
693
|
let target_actor_id;
|
|
666
694
|
if (input.to_actor_id != null) {
|
|
667
695
|
target_actor_id = input.to_actor_id;
|
|
@@ -165,6 +165,13 @@ export declare class RoleGrantOfferGrantorNotActiveError extends Error {
|
|
|
165
165
|
* spans. The self-target check comes first, so an offer to one's own account
|
|
166
166
|
* is refused as that whatever else it names.
|
|
167
167
|
*
|
|
168
|
+
* A scoped offer takes the scope lock shared before anything else
|
|
169
|
+
* (`query_scope_lock_shared`), so a teardown of the scope
|
|
170
|
+
* (`query_role_grant_revoke_for_scope`) in flight is waited for, and one that
|
|
171
|
+
* starts after it waits for this transaction and then supersedes the offer. A
|
|
172
|
+
* caller that judged the scope live takes the lock before that read, holding
|
|
173
|
+
* no row; the spine's handler does.
|
|
174
|
+
*
|
|
168
175
|
* @mutates `role_grant_offer` table - inserts a new offer or upserts the matching pending row
|
|
169
176
|
* @throws RoleGrantOfferSelfTargetError if the offering actor belongs to `to_account_id`
|
|
170
177
|
* @throws RoleGrantOfferRecipientNotActiveError if `to_account_id` is missing, soft-deleted, or has no active actor
|
|
@@ -300,8 +307,10 @@ export interface AcceptOfferResult {
|
|
|
300
307
|
* creating a duplicate or throwing — while that grant is still held. A grant
|
|
301
308
|
* revoked since the accept, or gone, makes the offer terminal.
|
|
302
309
|
*
|
|
303
|
-
* Lock order — accounts, then offers, then the grant:
|
|
304
|
-
*
|
|
310
|
+
* Lock order — the scope, then accounts, then offers, then the grant: a
|
|
311
|
+
* scoped offer's scope lock shared (`query_scope_lock_shared`), the
|
|
312
|
+
* recipient's account row (and, for an unscoped `admin` offer, the grantor's)
|
|
313
|
+
* in id order
|
|
305
314
|
* (`query_account_lock_for_offer_accept`), then the offer and the pending
|
|
306
315
|
* siblings it supersedes in one id-ordered claim, then the grant insert. The
|
|
307
316
|
* accounts first, as every removal of either account takes them first, so a
|
|
@@ -315,7 +324,11 @@ export interface AcceptOfferResult {
|
|
|
315
324
|
* `query_account_lock_for_revoke`, whether or not its last-admin guard ran; a
|
|
316
325
|
* delete through its write of the row; a purge through its last-admin guard
|
|
317
326
|
* and `query_account_lock_for_purge`; the DB browser's delete, which takes
|
|
318
|
-
* none of them, excepted).
|
|
327
|
+
* none of them, excepted). The scope lock comes first because the grant insert
|
|
328
|
+
* takes it (`query_create_role_grant`): taken there, after the claim, it would
|
|
329
|
+
* wait on a teardown that waits on the claimed offer. Taken first, a teardown
|
|
330
|
+
* in flight is waited for and the claim then finds the offer superseded, and
|
|
331
|
+
* one that starts after waits for this accept and then revokes its grant.
|
|
319
332
|
*
|
|
320
333
|
* Error map:
|
|
321
334
|
* - `RoleGrantOfferNotFoundError` — offer does not exist, or belongs to a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_grant_offer_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"role_grant_offer_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAkBrD,OAAO,KAAK,EACX,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAMjF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;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,SAAS,EACf,eAAe,IAAI,EACnB,UAAU,IAAI,EACd,YAAY,IAAI,GAAG,IAAI,EACvB,SAAS,MAAM,GAAG,IAAI,KACpB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAmDtC,CAAC"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { assert_row } from '../db/assert_row.js';
|
|
15
15
|
import { columns_sql, qualify_columns } from '../db/sql_columns.js';
|
|
16
16
|
import { ROLE_GRANT_OFFER_COLUMNS, role_grant_offer_expr, ROLE_GRANT_OFFER_SCOPE_KIND_GLOBAL_TOKEN, ROLE_GRANT_OFFER_SCOPE_SENTINEL_UUID, ROLE_GRANT_OFFER_WITH_GRANTOR_SELECT } from './role_grant_offer_ddl.js';
|
|
17
|
-
import { query_create_role_grant, query_role_grant_by_id } from './role_grant_queries.js';
|
|
17
|
+
import { query_create_role_grant, query_role_grant_by_id, query_scope_lock_shared } from './role_grant_queries.js';
|
|
18
18
|
import { offer_pending_predicate, offer_rows_locked_in_id_order, role_grant_active_sql } from './role_grant_sql.js';
|
|
19
19
|
import { query_audit_log } from './audit_log_queries.js';
|
|
20
20
|
import { query_account_lock_for_offer_accept, query_account_lock_for_revoke, query_account_lock_live_many } from './account_queries.js';
|
|
@@ -178,6 +178,13 @@ export class RoleGrantOfferGrantorNotActiveError extends Error {
|
|
|
178
178
|
* spans. The self-target check comes first, so an offer to one's own account
|
|
179
179
|
* is refused as that whatever else it names.
|
|
180
180
|
*
|
|
181
|
+
* A scoped offer takes the scope lock shared before anything else
|
|
182
|
+
* (`query_scope_lock_shared`), so a teardown of the scope
|
|
183
|
+
* (`query_role_grant_revoke_for_scope`) in flight is waited for, and one that
|
|
184
|
+
* starts after it waits for this transaction and then supersedes the offer. A
|
|
185
|
+
* caller that judged the scope live takes the lock before that read, holding
|
|
186
|
+
* no row; the spine's handler does.
|
|
187
|
+
*
|
|
181
188
|
* @mutates `role_grant_offer` table - inserts a new offer or upserts the matching pending row
|
|
182
189
|
* @throws RoleGrantOfferSelfTargetError if the offering actor belongs to `to_account_id`
|
|
183
190
|
* @throws RoleGrantOfferRecipientNotActiveError if `to_account_id` is missing, soft-deleted, or has no active actor
|
|
@@ -185,6 +192,8 @@ export class RoleGrantOfferGrantorNotActiveError extends Error {
|
|
|
185
192
|
* @throws RoleGrantOfferGrantorNotActiveError if the grantor's actor or account is missing or tombstoned
|
|
186
193
|
*/
|
|
187
194
|
export const query_role_grant_offer_create = async (deps, input) => {
|
|
195
|
+
if (input.scope_id != null)
|
|
196
|
+
await query_scope_lock_shared(deps, input.scope_id);
|
|
188
197
|
// Self-target check resolves the **grantor** actor's account and
|
|
189
198
|
// compares against to_account_id. This is multi-actor-correct:
|
|
190
199
|
// a single account may host many actors, and self-target means
|
|
@@ -418,8 +427,10 @@ const query_grantor_holds_global_admin = async (deps, grantor_actor_id) => {
|
|
|
418
427
|
* creating a duplicate or throwing — while that grant is still held. A grant
|
|
419
428
|
* revoked since the accept, or gone, makes the offer terminal.
|
|
420
429
|
*
|
|
421
|
-
* Lock order — accounts, then offers, then the grant:
|
|
422
|
-
*
|
|
430
|
+
* Lock order — the scope, then accounts, then offers, then the grant: a
|
|
431
|
+
* scoped offer's scope lock shared (`query_scope_lock_shared`), the
|
|
432
|
+
* recipient's account row (and, for an unscoped `admin` offer, the grantor's)
|
|
433
|
+
* in id order
|
|
423
434
|
* (`query_account_lock_for_offer_accept`), then the offer and the pending
|
|
424
435
|
* siblings it supersedes in one id-ordered claim, then the grant insert. The
|
|
425
436
|
* accounts first, as every removal of either account takes them first, so a
|
|
@@ -433,7 +444,11 @@ const query_grantor_holds_global_admin = async (deps, grantor_actor_id) => {
|
|
|
433
444
|
* `query_account_lock_for_revoke`, whether or not its last-admin guard ran; a
|
|
434
445
|
* delete through its write of the row; a purge through its last-admin guard
|
|
435
446
|
* and `query_account_lock_for_purge`; the DB browser's delete, which takes
|
|
436
|
-
* none of them, excepted).
|
|
447
|
+
* none of them, excepted). The scope lock comes first because the grant insert
|
|
448
|
+
* takes it (`query_create_role_grant`): taken there, after the claim, it would
|
|
449
|
+
* wait on a teardown that waits on the claimed offer. Taken first, a teardown
|
|
450
|
+
* in flight is waited for and the claim then finds the offer superseded, and
|
|
451
|
+
* one that starts after waits for this accept and then revokes its grant.
|
|
437
452
|
*
|
|
438
453
|
* Error map:
|
|
439
454
|
* - `RoleGrantOfferNotFoundError` — offer does not exist, or belongs to a
|
|
@@ -478,6 +493,11 @@ export const query_accept_offer = async (deps, input) => {
|
|
|
478
493
|
if (!head) {
|
|
479
494
|
throw new RoleGrantOfferNotFoundError(offer_id);
|
|
480
495
|
}
|
|
496
|
+
// A scoped offer's scope lock, holding nothing yet — before the claim, since
|
|
497
|
+
// the grant insert takes it again, and a teardown holding it waits on the
|
|
498
|
+
// claimed offer.
|
|
499
|
+
if (head.scope_id !== null)
|
|
500
|
+
await query_scope_lock_shared(deps, head.scope_id);
|
|
481
501
|
// An unscoped `admin` offer's grantor must still hold a global `admin` when
|
|
482
502
|
// the grant is minted.
|
|
483
503
|
const needs_grantor_admin = head.role === ROLE_ADMIN && head.scope_id === null;
|
|
@@ -19,6 +19,78 @@ import type { SupersededOffer } from './role_grant_offer_schema.js';
|
|
|
19
19
|
* `role_grant` migration chain in `auth/auth_ddl.ts`.
|
|
20
20
|
*/
|
|
21
21
|
export declare const ROLE_GRANT_COLUMNS: readonly ["id", "actor_id", "role", "scope_kind", "scope_id", "created_at", "expires_at", "revoked_at", "revoked_by", "revoked_reason", "granted_by", "source_offer_id"];
|
|
22
|
+
/**
|
|
23
|
+
* The first half of every scope lock's key (`scope_advisory_lock_key`): the
|
|
24
|
+
* ASCII of `fuzs`. Reserved for scope locks — no other lock in the spine takes it.
|
|
25
|
+
*
|
|
26
|
+
* Two-`int4` keys, `pg_advisory_xact_lock(int4, int4)`, sit a key space apart
|
|
27
|
+
* from the single `bigint` key the migration runner takes (`pg_locks.objsubid`
|
|
28
|
+
* 2 against 1), and this half differs from the purge lock's
|
|
29
|
+
* (`ACCOUNT_PURGE_ADVISORY_LOCK_KEY`, `fuz_`), so a scope lock meets neither.
|
|
30
|
+
* Twin of the Rust `fuz_auth::role_grant_offer_queries::SCOPE_ADVISORY_LOCK_CLASS`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const SCOPE_ADVISORY_LOCK_CLASS = 1718975091;
|
|
33
|
+
/**
|
|
34
|
+
* The advisory lock key of `scope_id`: `SCOPE_ADVISORY_LOCK_CLASS`, then the
|
|
35
|
+
* UUID's four big-endian 32-bit words folded by XOR into one signed `int4`.
|
|
36
|
+
*
|
|
37
|
+
* Every word counts — a UUIDv7 leads with its timestamp, so a prefix would put
|
|
38
|
+
* the scopes made in one millisecond on one key. Two scopes can still share a
|
|
39
|
+
* key; they then take turns, which costs a wait and nothing else. Twin of the
|
|
40
|
+
* Rust `fuz_auth::role_grant_offer_queries::scope_advisory_lock_key`, pinned on
|
|
41
|
+
* both sides by the same vectors.
|
|
42
|
+
*
|
|
43
|
+
* @param scope_id - the scope
|
|
44
|
+
* @returns the `(int4, int4)` pair `pg_advisory_xact_lock` takes
|
|
45
|
+
* @throws Error if `scope_id` is not a UUID's 32 hex digits
|
|
46
|
+
*/
|
|
47
|
+
export declare const scope_advisory_lock_key: (scope_id: Uuid) => [number, number];
|
|
48
|
+
/**
|
|
49
|
+
* Take `scope_id`'s scope lock shared, until the transaction ends.
|
|
50
|
+
*
|
|
51
|
+
* The lock orders a scope's teardown against every write that brings a grant
|
|
52
|
+
* or an offer into the scope: `query_role_grant_revoke_for_scope` takes it
|
|
53
|
+
* exclusive as its first statement, and the scoped writes take it shared —
|
|
54
|
+
* `query_create_role_grant` and `query_role_grant_offer_create` first thing,
|
|
55
|
+
* `query_accept_offer` after its unlocked head read, before any row, and the
|
|
56
|
+
* `role_grant_offer_create` and `role_grant_assign` handlers before the
|
|
57
|
+
* consumer's authorizer runs. A write
|
|
58
|
+
* that reads its scope after the lock sees a teardown that committed first,
|
|
59
|
+
* and one holding the lock makes a teardown wait and then end what it wrote.
|
|
60
|
+
* Writers take turns with a teardown only, not with each other. Re-entrant:
|
|
61
|
+
* a second take in one transaction is free.
|
|
62
|
+
*
|
|
63
|
+
* Take it first, holding no row: the teardown holds it while it waits on offer
|
|
64
|
+
* and grant rows and on whatever its consumer's scope delete cascades into (an
|
|
65
|
+
* invite or a request at the scope), so a transaction that waits on it holding
|
|
66
|
+
* one of those deadlocks. The scope id may come from an unlocked read of a
|
|
67
|
+
* column that never changes, as the accept's head read does. Use it on a
|
|
68
|
+
* consumer path that reads its own scope row and then brings something into the
|
|
69
|
+
* scope (an invite accept, a join decision): the lock, then the read. A
|
|
70
|
+
* transaction never takes two scope locks here; one that must should take them
|
|
71
|
+
* in key order. Twin of the Rust
|
|
72
|
+
* `fuz_auth::role_grant_offer_queries::query_scope_lock_shared`.
|
|
73
|
+
*
|
|
74
|
+
* @param deps - query dependencies (must be the writing transaction)
|
|
75
|
+
* @param scope_id - the scope
|
|
76
|
+
*/
|
|
77
|
+
export declare const query_scope_lock_shared: (deps: QueryDeps, scope_id: Uuid) => Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Take `scope_id`'s scope lock exclusive, until the transaction ends: every
|
|
80
|
+
* scoped write (`query_scope_lock_shared`) waits until then, and this waits for
|
|
81
|
+
* every one in flight.
|
|
82
|
+
*
|
|
83
|
+
* `query_role_grant_revoke_for_scope` takes it as its first statement. A
|
|
84
|
+
* consumer's teardown that must hold the lock before that — to read or lock
|
|
85
|
+
* its own scope row first — takes it here, holding no row, then calls the
|
|
86
|
+
* cascade (which takes it again, free) — never after taking it shared in the
|
|
87
|
+
* same transaction: two shared holders that both upgrade deadlock. Twin of the
|
|
88
|
+
* Rust `fuz_auth::role_grant_offer_queries::query_scope_lock_exclusive`.
|
|
89
|
+
*
|
|
90
|
+
* @param deps - query dependencies (must be the teardown's transaction)
|
|
91
|
+
* @param scope_id - the scope
|
|
92
|
+
*/
|
|
93
|
+
export declare const query_scope_lock_exclusive: (deps: QueryDeps, scope_id: Uuid) => Promise<void>;
|
|
22
94
|
/**
|
|
23
95
|
* Grant a role_grant to an actor.
|
|
24
96
|
* Idempotent — if an active (unrevoked and unexpired) role_grant already
|
|
@@ -40,6 +112,14 @@ export declare const ROLE_GRANT_COLUMNS: readonly ["id", "actor_id", "role", "sc
|
|
|
40
112
|
* `role_grant_scope_kind_paired` CHECK; mismatched pairs raise at the DB
|
|
41
113
|
* layer rather than producing silent rows.
|
|
42
114
|
*
|
|
115
|
+
* A scoped grant takes the scope lock shared first (`query_scope_lock_shared`),
|
|
116
|
+
* so a teardown of the scope (`query_role_grant_revoke_for_scope`) in flight
|
|
117
|
+
* is waited for, and one that starts after it waits for this transaction and
|
|
118
|
+
* then revokes the grant. Run it inside the caller's transaction, holding no
|
|
119
|
+
* row unless the transaction already holds this scope's lock (the lock's
|
|
120
|
+
* rule; a re-take is free); a caller that judged the scope live takes the
|
|
121
|
+
* lock before that read.
|
|
122
|
+
*
|
|
43
123
|
* @param deps - query dependencies
|
|
44
124
|
* @param input - the role_grant fields
|
|
45
125
|
* @returns the created or existing active role_grant
|
|
@@ -205,7 +285,7 @@ export declare const query_actor_has_active_global_role: (deps: QueryDeps, actor
|
|
|
205
285
|
* sort returns them: each account's row, its actors' and its grants' before
|
|
206
286
|
* the next account's. `query_account_lock_live_many` and
|
|
207
287
|
* `query_account_lock_for_offer_accept` take account rows in the same order,
|
|
208
|
-
* so an offer or an accept between two admins and an admin's removal never
|
|
288
|
+
* so an offer, an assign or an accept between two admins and an admin's removal never
|
|
209
289
|
* wait on each other's rows in opposite orders. Ids never change, so no
|
|
210
290
|
* concurrent update can move a row the sort has placed.
|
|
211
291
|
*
|
|
@@ -286,16 +366,26 @@ export interface RevokeForScopeResult {
|
|
|
286
366
|
* orphan role_grants and offers. The cascade is **role-agnostic**: anything
|
|
287
367
|
* attached to the destroyed scope is cleaned up.
|
|
288
368
|
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
369
|
+
* Its first statement takes the scope lock exclusive
|
|
370
|
+
* (`query_scope_lock_exclusive`): every write that brings a grant or an offer
|
|
371
|
+
* into the scope takes it shared (`query_scope_lock_shared` has the list), so
|
|
372
|
+
* one in flight commits first and is ended here, and one after waits for this
|
|
373
|
+
* transaction. A write whose consumer authorizer reads the scope reads it after
|
|
374
|
+
* its lock, so once this teardown has removed the scope row and committed, the
|
|
375
|
+
* write is refused. Call it before the transaction touches the scope row or
|
|
376
|
+
* any other row a writer's authorizer locks — a teardown holding such a row
|
|
377
|
+
* while it waits here on a writer that waits on that row deadlocks — or take
|
|
378
|
+
* `query_scope_lock_exclusive` first.
|
|
379
|
+
*
|
|
380
|
+
* Then the updates run as separate statements, the scope's pending offers
|
|
381
|
+
* locked in id order first, then the `role_grant` revoke, then the supersede
|
|
382
|
+
* of the offers that lock returned — offers before grants, as
|
|
383
|
+
* `query_revoke_role_grant` takes them. The supersede writes only the rows it
|
|
384
|
+
* locked; an offer written at the scope after that without the scope lock (a
|
|
385
|
+
* raw insert, which no query here makes) is left pending rather than taken
|
|
386
|
+
* out of order. The two halves are independent — orphan pending offers can
|
|
387
|
+
* exist at a scope with no active role_grants, so the supersede half always
|
|
388
|
+
* runs even when no role_grant was revoked.
|
|
299
389
|
*
|
|
300
390
|
* @param deps - query dependencies
|
|
301
391
|
* @param scope_id - the scope whose role_grants and offers to terminate
|
|
@@ -304,6 +394,7 @@ export interface RevokeForScopeResult {
|
|
|
304
394
|
* @returns the revoked role_grants (with `account_id` for fan-out) and superseded offers (with `from_account_id` for fan-out)
|
|
305
395
|
* @mutates `role_grant` table - sets `revoked_at`/`revoked_by`/`revoked_reason` on every active row at `scope_id`
|
|
306
396
|
* @mutates `role_grant_offer` table - stamps `superseded_at` on every pending row at `scope_id` its lock took
|
|
397
|
+
* @mutates the scope lock - holds `scope_id`'s advisory lock exclusive until the transaction ends
|
|
307
398
|
*/
|
|
308
399
|
export declare const query_role_grant_revoke_for_scope: (deps: QueryDeps, scope_id: Uuid, revoked_by: Uuid | null, reason?: string | null) => Promise<RevokeForScopeResult>;
|
|
309
400
|
//# sourceMappingURL=role_grant_queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_grant_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAS3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGpE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,0KAaoB,CAAC;AAcpD
|
|
1
|
+
{"version":3,"file":"role_grant_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAS3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGpE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,0KAaoB,CAAC;AAcpD;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,aAAc,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,GAAI,UAAU,IAAI,KAAG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