Skip to main content

Function: withPlatformScope()

withPlatformScope<DB, R>(db, scope, work): Promise<R>

Defined in: packages/persistence/src/platform.ts:64

Opens a transaction for a platform scope: oktoid.platform is on and oktoid.scope_path is /, for the life of the transaction only. A tenant row-level-security policy reads / as matching nothing, so only a policy that names the platform setting admits these rows.

Used by bootstrap and by principal resolution, and nowhere else. This entry point is @oktoid/persistence/platform so that the import is visible in a review.

Type Parameters​

DB​

DB

R​

R

Parameters​

db​

Database<DB>

The module's pool.

scope​

PlatformScope

A platform scope minted for a principal holding a platform grant.

work​

(tx) => Promise<R>

Runs in the transaction; a throw rolls it back.

Returns​

Promise<R>

What work returned, after commit.

Throws​

forged_scope when scope was not minted.