@stigmer/enterprise 0.1.3 → 0.2.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/editions/enterprise.d.ts.map +1 -1
- package/dist/editions/enterprise.js +9 -1
- package/dist/editions/enterprise.js.map +1 -1
- package/dist/iam/invitation/handlers.d.ts +6 -3
- package/dist/iam/invitation/handlers.d.ts.map +1 -1
- package/dist/iam/invitation/handlers.js +41 -8
- package/dist/iam/invitation/handlers.js.map +1 -1
- package/dist/postgres/pool.d.ts +11 -40
- package/dist/postgres/pool.d.ts.map +1 -1
- package/dist/postgres/pool.js +44 -41
- package/dist/postgres/pool.js.map +1 -1
- package/package.json +4 -4
- package/src/editions/__tests__/enterprise.wiring.test.ts +3 -0
- package/src/editions/enterprise.ts +9 -1
- package/src/iam/invitation/__tests__/handlers.test.ts +72 -6
- package/src/iam/invitation/handlers.ts +53 -10
- package/src/postgres/__tests__/pool.test.ts +61 -3
- package/src/postgres/pool.ts +55 -43
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enterprise.d.ts","sourceRoot":"","sources":["../../src/editions/enterprise.ts"],"names":[],"mappings":"AA8FA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAI/B,OAAO,KAAK,EAEV,gBAAgB,EAEhB,UAAU,EACV,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAsBzB,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGtF,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAK5D,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,0DAA0D,CAAC;AAEjG,MAAM,WAAW,iBAAiB;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,4FAA4F;IAC5F,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU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AC;IAChD,qEAAqE;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,wFAAwF;IACxF,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,2HAA2H;IAC3H,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAClC,wGAAwG;IACxG,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACtC,gGAAgG;IAChG,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,iEAAiE;IACjE,QAAQ,CAAC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IAC7C,4FAA4F;IAC5F,QAAQ,CAAC,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACrD;AAED,gEAAgE;AAChE,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAqGzC"}
|
|
@@ -35,7 +35,15 @@ export async function composeEnterprise(boot, options) {
|
|
|
35
35
|
}
|
|
36
36
|
const clock = options.clock ?? (() => new Date());
|
|
37
37
|
const pool = options.pool ??
|
|
38
|
-
newCompositionPool({
|
|
38
|
+
newCompositionPool({
|
|
39
|
+
name: "enterprise",
|
|
40
|
+
connectionString: config.databaseUrl,
|
|
41
|
+
logger,
|
|
42
|
+
// The store's two bounds, so an operator's DATABASE_POOL_MAX and
|
|
43
|
+
// DATABASE_POOL_CHECKOUT_TIMEOUT_MS bound this pool too.
|
|
44
|
+
max: config.databasePoolMax,
|
|
45
|
+
checkoutTimeoutMs: config.databasePoolCheckoutTimeoutMs,
|
|
46
|
+
});
|
|
39
47
|
const postgres = newEnterprisePostgres(pool);
|
|
40
48
|
const accounts = newEnterpriseAccounts();
|
|
41
49
|
const growthGate = newLicenseGrowthGate({ claims: verdict.claims, clock });
|
|
@@ -1 +1 @@
|
|
|
1
|
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b";
|
|
3
3
|
import { InvitationQueryController } from "@stigmer/apis/ai/stigmer/iam/invitation/v1/query_pb";
|
|
4
4
|
import type { AuthorizationQueryEngine, Authorizer, CredentialBinding, ExtensionServiceRegistration, ListReadScope, Logger, ResourceAuthorizationLifecycle } from "@stigmer/server";
|
|
5
|
-
import type {
|
|
5
|
+
import type { AccountsByCaller } from "@stigmer/server";
|
|
6
6
|
import type { OrganizationLookup } from "../organization-links.js";
|
|
7
7
|
import type { GrantPathClient } from "../grant/grant-path-client.js";
|
|
8
8
|
import type { InvitationStore } from "./store.js";
|
|
@@ -27,8 +27,11 @@ export interface InvitationLaneDeps {
|
|
|
27
27
|
* refused here when the invitation is another's.
|
|
28
28
|
*/
|
|
29
29
|
readonly credentialBinding: Pick<CredentialBinding, "admitsOrganization">;
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The identity-account port: whether the caller is a service account,
|
|
32
|
+
* which invites nobody, and which account a redeemer stands for.
|
|
33
|
+
*/
|
|
34
|
+
readonly accounts: AccountsByCaller;
|
|
32
35
|
}
|
|
33
36
|
type Commands = ServiceImpl<typeof InvitationCommandController>;
|
|
34
37
|
type Queries = ServiceImpl<typeof InvitationQueryController>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/iam/invitation/handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/iam/invitation/handlers.ts"],"names":[],"mappings":"AA2GA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAYvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,uDAAuD,CAAC;AAOpG,OAAO,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAC;AAEhG,OAAO,KAAK,EACV,wBAAwB,EACxB,UAAU,EAEV,iBAAiB,EACjB,4BAA4B,EAC5B,aAAa,EACb,MAAM,EAEN,8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E,kBAAkB,GAAG,OAAO,CAmDnE;AAED,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,kBAAkB,GACvB,aAAa,CAAC,4BAA4B,CAAC,CAK7C;AAkaD;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAYhD"}
|
|
@@ -36,7 +36,11 @@
|
|
|
36
36
|
* organization refused (the composition's credential
|
|
37
37
|
* binding: such a credential joins nothing), the membership
|
|
38
38
|
* check, then the guarded atomic redemption (store.ts)
|
|
39
|
-
* before the grant
|
|
39
|
+
* before the grant, both naming the account the person
|
|
40
|
+
* stands for or will (`accountIdForCaller`: the invite page
|
|
41
|
+
* redeems a first-time visitor's link before their account
|
|
42
|
+
* is made, and a grant naming their raw subject would
|
|
43
|
+
* belong to nobody once it is); a lost slot has granted nothing and
|
|
40
44
|
* refuses with the honest copy re-read from the row, and a
|
|
41
45
|
* failed grant releases its own record
|
|
42
46
|
* get Authorize (`can_view` on the invitation) → LoadTarget
|
|
@@ -108,7 +112,7 @@ import { InvitationState } from "@stigmer/apis/ai/stigmer/iam/invitation/v1/enum
|
|
|
108
112
|
import { InvitationPreviewSchema, InvitationsSchema, } from "@stigmer/apis/ai/stigmer/iam/invitation/v1/io_pb";
|
|
109
113
|
import { InvitationQueryController } from "@stigmer/apis/ai/stigmer/iam/invitation/v1/query_pb";
|
|
110
114
|
import { IamPermission, IamRole } from "@stigmer/apis/ai/stigmer/iam/v1/enum_pb";
|
|
111
|
-
import { internalError, notFoundError, listPageFingerprint, matchesAllLabels, sortedLabels, OWNER_ASSIGNMENT_DENIED_MESSAGE, newBuildNewStateStep, newRefuseServiceAccountCallerStep, readPage, resolveResourceCreatedEvent, restrictListByReadScope, TARGET_RESOURCE_KEY, } from "@stigmer/server";
|
|
115
|
+
import { accountIdForCaller, internalError, notFoundError, listPageFingerprint, matchesAllLabels, sortedLabels, OWNER_ASSIGNMENT_DENIED_MESSAGE, newBuildNewStateStep, newRefuseServiceAccountCallerStep, readPage, resolveResourceCreatedEvent, restrictListByReadScope, TARGET_RESOURCE_KEY, } from "@stigmer/server";
|
|
112
116
|
import { runUnaryChain } from "../../rpc/unary-chain.js";
|
|
113
117
|
import { orphanReason } from "../organization-links.js";
|
|
114
118
|
import { grantableRolesFor } from "../grant/roles.js";
|
|
@@ -240,11 +244,23 @@ async function redeemInvitation(reqCtx, deps) {
|
|
|
240
244
|
throw new ConnectError(CREATOR_NO_LONGER_GRANTS, Code.FailedPrecondition);
|
|
241
245
|
}
|
|
242
246
|
await refuseBoundElsewhere(deps.credentialBinding, caller, org);
|
|
243
|
-
|
|
247
|
+
// The account the redeemer stands for, or the one their first sign-in
|
|
248
|
+
// will make (the header's redeem row).
|
|
249
|
+
const redeemer = await accountIdForCaller(deps.accounts, caller);
|
|
250
|
+
if (redeemer === caller.identityId) {
|
|
251
|
+
await refuseExistingMember(deps.authorizer, caller, org);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
// A person not yet provisioned: the Authorizer knows them only by their
|
|
255
|
+
// subject, which no row names, so a second redeem before their account
|
|
256
|
+
// is made would pass it and take a second seat. Their membership is
|
|
257
|
+
// asked of the account the earlier redeem granted.
|
|
258
|
+
await refuseExistingAccountMember(deps.authorizationQueries, redeemer, org);
|
|
259
|
+
}
|
|
244
260
|
// Record before grant: a lost slot then has nothing to undo, so no
|
|
245
261
|
// redemption ever revokes a role row another one stands on (the header).
|
|
246
262
|
const redeemedAt = new Date();
|
|
247
|
-
const recorded = await deps.store.recordRedemption(invitationId,
|
|
263
|
+
const recorded = await deps.store.recordRedemption(invitationId, redeemer, redeemedAt);
|
|
248
264
|
if (recorded.kind === "refused") {
|
|
249
265
|
const current = await deps.store.findById(invitationId);
|
|
250
266
|
const currentState = current?.status?.state ?? InvitationState.invitation_state_unspecified;
|
|
@@ -253,7 +269,7 @@ async function redeemInvitation(reqCtx, deps) {
|
|
|
253
269
|
const role = create(GrantSpecSchema, {
|
|
254
270
|
principal: create(ApiResourceRefSchema, {
|
|
255
271
|
kind: "identity_account",
|
|
256
|
-
id:
|
|
272
|
+
id: redeemer,
|
|
257
273
|
}),
|
|
258
274
|
relation: IamRole[invitation.spec?.role ?? IamRole.iam_role_unspecified],
|
|
259
275
|
resource: create(ApiResourceRefSchema, { kind: "organization", id: org }),
|
|
@@ -267,14 +283,14 @@ async function redeemInvitation(reqCtx, deps) {
|
|
|
267
283
|
}
|
|
268
284
|
catch (grantError) {
|
|
269
285
|
try {
|
|
270
|
-
const released = await deps.store.releaseRedemption(invitationId,
|
|
286
|
+
const released = await deps.store.releaseRedemption(invitationId, redeemer, redeemedAt);
|
|
271
287
|
if (released.kind === "absent") {
|
|
272
288
|
// The row, or this redemption's entry, went away between the
|
|
273
289
|
// record and the release (a delete, a hand edit): nothing to undo,
|
|
274
290
|
// but the trace is what finds a ledger that disagrees.
|
|
275
291
|
deps.logger.warn("a failed grant found no redemption to release", {
|
|
276
292
|
invitationId,
|
|
277
|
-
caller:
|
|
293
|
+
caller: redeemer,
|
|
278
294
|
org,
|
|
279
295
|
});
|
|
280
296
|
}
|
|
@@ -282,7 +298,7 @@ async function redeemInvitation(reqCtx, deps) {
|
|
|
282
298
|
catch (releaseError) {
|
|
283
299
|
deps.logger.error("releasing a redemption FAILED after its grant failed — reconcile manually", {
|
|
284
300
|
invitationId,
|
|
285
|
-
caller:
|
|
301
|
+
caller: redeemer,
|
|
286
302
|
org,
|
|
287
303
|
grantError: grantError instanceof Error ? grantError.message : String(grantError),
|
|
288
304
|
error: releaseError instanceof Error ? releaseError.message : String(releaseError),
|
|
@@ -473,6 +489,23 @@ async function refuseExistingMember(authorizer, caller, org) {
|
|
|
473
489
|
}
|
|
474
490
|
}
|
|
475
491
|
}
|
|
492
|
+
/** `refuseExistingMember` for an account not yet provisioned, asked of the engine by its id. */
|
|
493
|
+
async function refuseExistingAccountMember(queries, accountId, org) {
|
|
494
|
+
let holds;
|
|
495
|
+
try {
|
|
496
|
+
holds = await queries.check(create(GrantSpecSchema, {
|
|
497
|
+
principal: create(ApiResourceRefSchema, { kind: "identity_account", id: accountId }),
|
|
498
|
+
relation: IamPermission[IamPermission.can_view],
|
|
499
|
+
resource: create(ApiResourceRefSchema, { kind: "organization", id: org }),
|
|
500
|
+
}), []);
|
|
501
|
+
}
|
|
502
|
+
catch (error) {
|
|
503
|
+
throw internalError(error, "failed to verify organization membership");
|
|
504
|
+
}
|
|
505
|
+
if (holds) {
|
|
506
|
+
throw new ConnectError("You are already a member of this organization", Code.AlreadyExists);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
476
509
|
/** The create's business rules, with the lane's pinned copy. */
|
|
477
510
|
function validateInvitationSpec(invitation) {
|
|
478
511
|
const spec = invitation.spec;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../../src/iam/invitation/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,mFAAmF,CAAC;AACpH,OAAO,EACL,oBAAoB,EACpB,eAAe,GAChB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,uDAAuD,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAErF,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,kDAAkD,CAAC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M,IAAI,YAAY,CACpB,sDAAsD,EACtD,IAAI,CAAC,eAAe,CACrB,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,IAAI,EAAE,cAAc,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,YAAY,CACpB,6DAA6D,EAC7D,IAAI,CAAC,eAAe,CACrB,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,QAAQ,GAAG,gEAAgE,CAAC;IAClF,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC3D,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,OAAO,KAAK,GAAG,EAAE,EAAE,CAAC;QAClB,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAC9C,KAAK,IAAI,GAAG,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/postgres/pool.d.ts
CHANGED
|
@@ -1,41 +1,8 @@
|
|
|
1
|
+
import type { BoundedPool, Logger } from "@stigmer/server";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* error as its own `'error'` event, and an EventEmitter with no `'error'`
|
|
5
|
-
* listener turns that emit into a throw from the event loop: not a
|
|
6
|
-
* rejected promise anything awaits, a process crash: a database that
|
|
7
|
-
* terminates its idle backends (`terminating connection due to
|
|
8
|
-
* administrator command`) would take the server with it. The OSS store's
|
|
9
|
-
* pool carries the listener (@stigmer/server, store/postgres/store.ts);
|
|
10
|
-
* this module gives a composition's pools the same posture, once.
|
|
11
|
-
*
|
|
12
|
-
* Why warn-only and not a reconnect or a shutdown: the pool has already
|
|
13
|
-
* dropped the dead client by the time it emits, and the next checkout
|
|
14
|
-
* opens a fresh connection on its own. There is nothing to repair and
|
|
15
|
-
* nothing to stop; the line exists so an operator reading the log can
|
|
16
|
-
* tell an idle-connection churn from a request failure. The message is
|
|
17
|
-
* the OSS store's, byte for byte, so one search finds every pool's
|
|
18
|
-
* report; the `pool` field says which pool it was.
|
|
19
|
-
*
|
|
20
|
-
* Why a checkout deadline: pg's default waits for a free client forever,
|
|
21
|
-
* so a pool whose clients are all held turns every later query into a
|
|
22
|
-
* request that never answers, and nothing in the log says why. With
|
|
23
|
-
* `connectionTimeoutMillis` a starved checkout fails with `timeout exceeded
|
|
24
|
-
* when trying to connect`, through the request's own error path. Ten
|
|
25
|
-
* seconds is far past any healthy wait for a client and well inside a
|
|
26
|
-
* caller's patience. The bound covers waiting for a client and opening a
|
|
27
|
-
* new connection, never how long a client is held, so a long migration or
|
|
28
|
-
* a lock's transaction is untouched.
|
|
29
|
-
*
|
|
30
|
-
* Why a name: each composition owns its pools by design (a self-hosted
|
|
31
|
-
* Enterprise server one over its database, `enterprise`). A new pool is a
|
|
32
|
-
* design act that each composition's guard reviews as a new name, rather
|
|
33
|
-
* than appearing as another bare `new pg.Pool` somewhere in a unit; the
|
|
34
|
-
* same guard refuses the bare form anywhere else.
|
|
3
|
+
* How long a query waits for a client before it fails instead of hanging:
|
|
4
|
+
* the store's own deadline, so there is one number.
|
|
35
5
|
*/
|
|
36
|
-
import pg from "pg";
|
|
37
|
-
import type { Logger } from "@stigmer/server";
|
|
38
|
-
/** How long a query waits for a client before it fails instead of hanging. */
|
|
39
6
|
export declare const POOL_CHECKOUT_TIMEOUT_MS = 10000;
|
|
40
7
|
/** A pool's name, in its log lines; each composition's guard pins the names it builds. */
|
|
41
8
|
export type CompositionPoolName = string;
|
|
@@ -43,12 +10,16 @@ export interface CompositionPoolOptions {
|
|
|
43
10
|
readonly name: CompositionPoolName;
|
|
44
11
|
readonly connectionString: string;
|
|
45
12
|
readonly logger: Logger;
|
|
13
|
+
/** The most connections the pool holds; the server's default (20) when unset. */
|
|
14
|
+
readonly max?: number;
|
|
15
|
+
/** How long a checkout may wait; `POOL_CHECKOUT_TIMEOUT_MS` when unset. */
|
|
16
|
+
readonly checkoutTimeoutMs?: number;
|
|
46
17
|
}
|
|
47
18
|
/**
|
|
48
|
-
* A
|
|
19
|
+
* A bounded pool over `connectionString` whose idle-connection errors are a
|
|
49
20
|
* WARN line carrying `pool: name`, never an unhandled `'error'` event, and
|
|
50
|
-
* whose checkouts
|
|
51
|
-
* forever.
|
|
21
|
+
* whose failed checkouts reject with `DatabaseUnavailableError` after at
|
|
22
|
+
* most `POOL_CHECKOUT_TIMEOUT_MS` instead of waiting forever.
|
|
52
23
|
*/
|
|
53
|
-
export declare function newCompositionPool(options: CompositionPoolOptions):
|
|
24
|
+
export declare function newCompositionPool(options: CompositionPoolOptions): BoundedPool;
|
|
54
25
|
//# sourceMappingURL=pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/postgres/pool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/postgres/pool.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,QAAmC,CAAC;AAEzE,0FAA0F;AAC1F,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEzC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iFAAiF;IACjF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,sBAAsB,GAC9B,WAAW,CAYb"}
|
package/dist/postgres/pool.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The one constructor for a Postgres pool a composition owns. It
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
2
|
+
* The one constructor for a Postgres pool a composition owns. It builds on
|
|
3
|
+
* `@stigmer/server`'s bounded pool (`newBoundedPool`, the store's own pool
|
|
4
|
+
* constructor), so a composition's pools and the store's share one size,
|
|
5
|
+
* one checkout deadline and one failure type: a checkout that waits past
|
|
6
|
+
* the deadline, or a database that cannot be reached, rejects with
|
|
7
|
+
* `DatabaseUnavailableError`, which every RPC answers as Unavailable ("try
|
|
8
|
+
* again") rather than Internal. That module's header gives the reasons for
|
|
9
|
+
* the size (20) and the deadline (ten seconds, covering the wait for a
|
|
10
|
+
* client and the opening of one, never how long a client is held). This
|
|
11
|
+
* module adds the two things a composition's pool needs beyond that. A
|
|
12
|
+
* composition may pass its own size and deadline; the self-hosted
|
|
13
|
+
* Enterprise server passes the operator's DATABASE_POOL_MAX and
|
|
14
|
+
* DATABASE_POOL_CHECKOUT_TIMEOUT_MS, so one setting bounds both of its
|
|
15
|
+
* pools (editions/enterprise.ts).
|
|
11
16
|
*
|
|
12
|
-
* Why warn-only
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* `
|
|
24
|
-
* when trying to connect`, through the request's own error path. Ten
|
|
25
|
-
* seconds is far past any healthy wait for a client and well inside a
|
|
26
|
-
* caller's patience. The bound covers waiting for a client and opening a
|
|
27
|
-
* new connection, never how long a client is held, so a long migration or
|
|
28
|
-
* a lock's transaction is untouched.
|
|
17
|
+
* Why a warn-only idle-error listener with a name: a `pg.Pool` is an
|
|
18
|
+
* EventEmitter that re-emits an idle client's error as its own `'error'`
|
|
19
|
+
* event, and an EventEmitter with no `'error'` listener turns that emit
|
|
20
|
+
* into a throw from the event loop: not a rejected promise anything awaits,
|
|
21
|
+
* a process crash: a database that terminates its idle backends
|
|
22
|
+
* (`terminating connection due to administrator command`) would take the
|
|
23
|
+
* server with it. The pool has already dropped the dead client by the time
|
|
24
|
+
* it emits, and the next checkout opens a fresh connection on its own.
|
|
25
|
+
* There is nothing to repair and nothing to stop; the line exists so an
|
|
26
|
+
* operator reading the log can tell an idle-connection churn from a request
|
|
27
|
+
* failure. The message is the OSS store's, byte for byte, so one search
|
|
28
|
+
* finds every pool's report; the `pool` field says which pool it was.
|
|
29
29
|
*
|
|
30
30
|
* Why a name: each composition owns its pools by design (a self-hosted
|
|
31
31
|
* Enterprise server one over its database, `enterprise`). A new pool is a
|
|
@@ -33,26 +33,29 @@
|
|
|
33
33
|
* than appearing as another bare `new pg.Pool` somewhere in a unit; the
|
|
34
34
|
* same guard refuses the bare form anywhere else.
|
|
35
35
|
*/
|
|
36
|
-
import
|
|
37
|
-
/**
|
|
38
|
-
|
|
36
|
+
import { DEFAULT_POOL_CHECKOUT_TIMEOUT_MS, newBoundedPool, } from "@stigmer/server";
|
|
37
|
+
/**
|
|
38
|
+
* How long a query waits for a client before it fails instead of hanging:
|
|
39
|
+
* the store's own deadline, so there is one number.
|
|
40
|
+
*/
|
|
41
|
+
export const POOL_CHECKOUT_TIMEOUT_MS = DEFAULT_POOL_CHECKOUT_TIMEOUT_MS;
|
|
39
42
|
/**
|
|
40
|
-
* A
|
|
43
|
+
* A bounded pool over `connectionString` whose idle-connection errors are a
|
|
41
44
|
* WARN line carrying `pool: name`, never an unhandled `'error'` event, and
|
|
42
|
-
* whose checkouts
|
|
43
|
-
* forever.
|
|
45
|
+
* whose failed checkouts reject with `DatabaseUnavailableError` after at
|
|
46
|
+
* most `POOL_CHECKOUT_TIMEOUT_MS` instead of waiting forever.
|
|
44
47
|
*/
|
|
45
48
|
export function newCompositionPool(options) {
|
|
46
|
-
|
|
49
|
+
return newBoundedPool({
|
|
47
50
|
connectionString: options.connectionString,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
max: options.max,
|
|
52
|
+
checkoutTimeoutMs: options.checkoutTimeoutMs,
|
|
53
|
+
onIdleError: (error) => {
|
|
54
|
+
options.logger.warn("postgres pool idle-connection error", {
|
|
55
|
+
pool: options.name,
|
|
56
|
+
error: error.message,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
55
59
|
});
|
|
56
|
-
return pool;
|
|
57
60
|
}
|
|
58
61
|
//# sourceMappingURL=pool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/postgres/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/postgres/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EACL,gCAAgC,EAChC,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,gCAAgC,CAAC;AAezE;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAA+B;IAE/B,OAAO,cAAc,CAAC;QACpB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;QAC5C,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE;gBACzD,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,KAAK,CAAC,OAAO;aACrB,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stigmer/enterprise",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Stigmer Enterprise: many organizations, federation with the platforms whose tokens it trusts, teams and invitations, on the open-source Stigmer server, turned on by a license key.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"@bufbuild/protobuf": "2.12.0",
|
|
54
54
|
"@bufbuild/protovalidate": "^1.1.1",
|
|
55
55
|
"@connectrpc/connect": "^2.0.0",
|
|
56
|
-
"@stigmer/apis": "0.
|
|
57
|
-
"@stigmer/outbound": "0.
|
|
58
|
-
"@stigmer/server": "0.
|
|
56
|
+
"@stigmer/apis": "0.2.0",
|
|
57
|
+
"@stigmer/outbound": "0.2.0",
|
|
58
|
+
"@stigmer/server": "0.2.0",
|
|
59
59
|
"pg": "8.23.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
@@ -55,6 +55,9 @@ describe("the self-hosted Enterprise server's wiring", () => {
|
|
|
55
55
|
expect(enterprise.match(/\bnewCompositionPool\(/g) ?? [], "newCompositionPool calls").toHaveLength(1);
|
|
56
56
|
const names = [...enterprise.matchAll(/newCompositionPool\(\{[^}]*?\bname:\s*"([^"]+)"/g)].map((match) => match[1]);
|
|
57
57
|
expect(names).toEqual(["enterprise"]);
|
|
58
|
+
// The operator's two pool settings bound this pool as they bound the store's.
|
|
59
|
+
expect(enterprise).toMatch(/max: config\.databasePoolMax,/);
|
|
60
|
+
expect(enterprise).toMatch(/checkoutTimeoutMs: config\.databasePoolCheckoutTimeoutMs,/);
|
|
58
61
|
expect(enterprise).not.toMatch(/\bnew\s+(?:pg\.)?Pool\s*\(/);
|
|
59
62
|
});
|
|
60
63
|
});
|
|
@@ -177,7 +177,15 @@ export async function composeEnterprise(
|
|
|
177
177
|
const clock = options.clock ?? ((): Date => new Date());
|
|
178
178
|
const pool =
|
|
179
179
|
options.pool ??
|
|
180
|
-
newCompositionPool({
|
|
180
|
+
newCompositionPool({
|
|
181
|
+
name: "enterprise",
|
|
182
|
+
connectionString: config.databaseUrl,
|
|
183
|
+
logger,
|
|
184
|
+
// The store's two bounds, so an operator's DATABASE_POOL_MAX and
|
|
185
|
+
// DATABASE_POOL_CHECKOUT_TIMEOUT_MS bound this pool too.
|
|
186
|
+
max: config.databasePoolMax,
|
|
187
|
+
checkoutTimeoutMs: config.databasePoolCheckoutTimeoutMs,
|
|
188
|
+
});
|
|
181
189
|
const postgres = newEnterprisePostgres(pool);
|
|
182
190
|
const accounts = newEnterpriseAccounts();
|
|
183
191
|
const growthGate = newLicenseGrowthGate({ claims: verdict.claims, clock });
|
|
@@ -46,6 +46,11 @@
|
|
|
46
46
|
* logged for a hand;
|
|
47
47
|
* - an app user, whose minted token the library binds to the
|
|
48
48
|
* organization it is for, redeems only into that organization;
|
|
49
|
+
* - a person admitted before their account exists (the invite page
|
|
50
|
+
* redeems a first visit's link) is recorded and granted as the account
|
|
51
|
+
* provisionMyAccount will give them, never as their raw subject, and
|
|
52
|
+
* redeeming again before that account is made is ALREADY_EXISTS, the
|
|
53
|
+
* account's role asked of the engine, with no second seat taken;
|
|
49
54
|
* - the preview answers the organization's display and the link's
|
|
50
55
|
* validity, asking what redeem asks before it grants, so a link whose
|
|
51
56
|
* creator can no longer grant its role previews invalid with redeem's
|
|
@@ -71,6 +76,7 @@ import type {
|
|
|
71
76
|
ResourceCreatedEvent,
|
|
72
77
|
} from "@stigmer/server";
|
|
73
78
|
import {
|
|
79
|
+
accountIdFor,
|
|
74
80
|
boundOrgOf,
|
|
75
81
|
callerIdentityKey,
|
|
76
82
|
createLogger,
|
|
@@ -116,17 +122,24 @@ const ORG_CREATED = new Date("2026-09-01T00:00:00Z");
|
|
|
116
122
|
|
|
117
123
|
const silent: Logger = createLogger({ level: "error", pretty: false, write: () => {} });
|
|
118
124
|
|
|
125
|
+
/** An unsigned token naming `sub`: the chain verified it before the lane reads it. */
|
|
126
|
+
function tokenNaming(sub: string): string {
|
|
127
|
+
const segment = (value: unknown): string => Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
128
|
+
return `${segment({ alg: "none" })}.${segment({ sub })}.unsigned`;
|
|
129
|
+
}
|
|
130
|
+
|
|
119
131
|
function identityInterceptor(
|
|
120
132
|
callerClass: string,
|
|
121
133
|
boundOrg: string | undefined,
|
|
122
134
|
mintedBy: string | undefined,
|
|
135
|
+
unprovisionedSubject: string | undefined,
|
|
123
136
|
): Interceptor {
|
|
124
137
|
return (next) => (request) => {
|
|
125
138
|
request.contextValues.set(callerIdentityKey, {
|
|
126
|
-
identityId: CALLER,
|
|
139
|
+
identityId: unprovisionedSubject ?? CALLER,
|
|
127
140
|
callerClass,
|
|
128
141
|
issuer: "https://issuer.invalid",
|
|
129
|
-
rawToken: "tok",
|
|
142
|
+
rawToken: unprovisionedSubject === undefined ? "tok" : tokenNaming(unprovisionedSubject),
|
|
130
143
|
...(boundOrg === undefined ? {} : { boundOrg }),
|
|
131
144
|
...(mintedBy === undefined ? {} : { mintedBy }),
|
|
132
145
|
});
|
|
@@ -173,10 +186,14 @@ function rig(
|
|
|
173
186
|
boundOrg?: string;
|
|
174
187
|
/** The service account that minted the caller's token; none unless a case says otherwise. */
|
|
175
188
|
mintedBy?: string;
|
|
189
|
+
/** A caller admitted idp-shaped (identity = this subject, no account yet); a provisioned one unless a case says otherwise. */
|
|
190
|
+
unprovisionedSubject?: string;
|
|
176
191
|
/** What the engine answers about a row's creator; every relation held unless a case says otherwise. */
|
|
177
192
|
creatorHolds?: (relation: string) => boolean;
|
|
178
193
|
/** A fault the engine answers every creator question with, over `creatorHolds`. */
|
|
179
194
|
creatorFault?: Error;
|
|
195
|
+
/** A fault the engine answers a redeemer's membership question with. */
|
|
196
|
+
memberFault?: Error;
|
|
180
197
|
/** Where the lane's warnings go, when a case reads them; silent otherwise. */
|
|
181
198
|
warnings?: string[];
|
|
182
199
|
/** Where the lane's errors go, when a case reads them; silent otherwise. */
|
|
@@ -236,8 +253,12 @@ function rig(
|
|
|
236
253
|
},
|
|
237
254
|
};
|
|
238
255
|
const deps: InvitationLaneDeps = {
|
|
239
|
-
// Nobody here is a service account
|
|
240
|
-
|
|
256
|
+
// Nobody here is a service account (the refusal reads a person), and no
|
|
257
|
+
// account is stored: a provisioned caller's stamp stands as it is.
|
|
258
|
+
accounts: {
|
|
259
|
+
findById: () => Promise.resolve(undefined),
|
|
260
|
+
findDirectByIdpId: () => Promise.resolve(undefined),
|
|
261
|
+
},
|
|
241
262
|
authorizer,
|
|
242
263
|
logger:
|
|
243
264
|
options.warnings === undefined && options.errors === undefined
|
|
@@ -271,7 +292,17 @@ function rig(
|
|
|
271
292
|
},
|
|
272
293
|
authorizationQueries: {
|
|
273
294
|
check: (grant) => {
|
|
274
|
-
|
|
295
|
+
const principal = grant.principal?.id ?? "";
|
|
296
|
+
if (principal !== CREATOR) {
|
|
297
|
+
if (options.memberFault !== undefined) {
|
|
298
|
+
return Promise.reject(options.memberFault);
|
|
299
|
+
}
|
|
300
|
+
// A redeemer's membership: any role row this suite's grants left.
|
|
301
|
+
const prefix = `${principal}#`;
|
|
302
|
+
const suffix = `@${grant.resource?.id ?? ""}`;
|
|
303
|
+
return Promise.resolve([...held].some((row) => row.startsWith(prefix) && row.endsWith(suffix)));
|
|
304
|
+
}
|
|
305
|
+
creatorChecks.push(`${grant.relation} ${principal}`);
|
|
275
306
|
if (options.creatorFault !== undefined) {
|
|
276
307
|
return Promise.reject(options.creatorFault);
|
|
277
308
|
}
|
|
@@ -288,7 +319,12 @@ function rig(
|
|
|
288
319
|
{
|
|
289
320
|
router: {
|
|
290
321
|
interceptors: [
|
|
291
|
-
identityInterceptor(
|
|
322
|
+
identityInterceptor(
|
|
323
|
+
options.callerClass ?? "user",
|
|
324
|
+
options.boundOrg,
|
|
325
|
+
options.mintedBy,
|
|
326
|
+
options.unprovisionedSubject,
|
|
327
|
+
),
|
|
292
328
|
],
|
|
293
329
|
},
|
|
294
330
|
},
|
|
@@ -670,6 +706,36 @@ describe("redeem", () => {
|
|
|
670
706
|
).toEqual([CREATOR]);
|
|
671
707
|
});
|
|
672
708
|
|
|
709
|
+
it("records and grants a person not yet provisioned as the account their first sign-in makes, never their raw subject", async () => {
|
|
710
|
+
const r = rig({ decide: outsider, unprovisionedSubject: "auth0|first-visit" });
|
|
711
|
+
await r.store.save(stored({ id: "inv_a", token: "Go" }));
|
|
712
|
+
|
|
713
|
+
const redeemed = await r.commands.redeem({ token: "Go" });
|
|
714
|
+
|
|
715
|
+
const account = accountIdFor("auth0|first-visit");
|
|
716
|
+
expect(redeemed.status?.redemptions.map((entry) => entry.identityAccountId)).toEqual([account]);
|
|
717
|
+
expect(r.granted[0]?.principal).toMatchObject({ kind: "identity_account", id: account });
|
|
718
|
+
|
|
719
|
+
// Again before their account is made: the role the first redeem granted
|
|
720
|
+
// refuses it, and no second seat is taken.
|
|
721
|
+
const again = await failure(r.commands.redeem({ token: "Go" }));
|
|
722
|
+
expect(again.code).toBe(Code.AlreadyExists);
|
|
723
|
+
expect(again.rawMessage).toBe("You are already a member of this organization");
|
|
724
|
+
expect((await r.store.findById("inv_a"))?.status?.redemptionCount).toBe(1);
|
|
725
|
+
expect(r.granted).toHaveLength(1);
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
it("refuses INTERNAL, granting and recording nothing, when a person not yet provisioned cannot be asked about membership", async () => {
|
|
729
|
+
const r = rig({ decide: outsider, unprovisionedSubject: "auth0|first-visit", memberFault: new Error("engine unavailable") });
|
|
730
|
+
await r.store.save(stored({ id: "inv_a", token: "Go" }));
|
|
731
|
+
|
|
732
|
+
const error = await failure(r.commands.redeem({ token: "Go" }));
|
|
733
|
+
|
|
734
|
+
expect(error.code).toBe(Code.Internal);
|
|
735
|
+
expect(r.granted).toHaveLength(0);
|
|
736
|
+
expect((await r.store.findById("inv_a"))?.status?.redemptionCount).toBe(0);
|
|
737
|
+
});
|
|
738
|
+
|
|
673
739
|
// Only `user` redeems: open source's own non-person classes, a class a
|
|
674
740
|
// host mints for a lane of its own (a host's guest lane, say,
|
|
675
741
|
// `guest`), and one no host has minted yet are all refused alike.
|
|
@@ -36,7 +36,11 @@
|
|
|
36
36
|
* organization refused (the composition's credential
|
|
37
37
|
* binding: such a credential joins nothing), the membership
|
|
38
38
|
* check, then the guarded atomic redemption (store.ts)
|
|
39
|
-
* before the grant
|
|
39
|
+
* before the grant, both naming the account the person
|
|
40
|
+
* stands for or will (`accountIdForCaller`: the invite page
|
|
41
|
+
* redeems a first-time visitor's link before their account
|
|
42
|
+
* is made, and a grant naming their raw subject would
|
|
43
|
+
* belong to nobody once it is); a lost slot has granted nothing and
|
|
40
44
|
* refuses with the honest copy re-read from the row, and a
|
|
41
45
|
* failed grant releases its own record
|
|
42
46
|
* get Authorize (`can_view` on the invitation) → LoadTarget
|
|
@@ -133,8 +137,9 @@ import type {
|
|
|
133
137
|
RequestContext,
|
|
134
138
|
ResourceAuthorizationLifecycle,
|
|
135
139
|
} from "@stigmer/server";
|
|
136
|
-
import type {
|
|
140
|
+
import type { AccountsByCaller } from "@stigmer/server";
|
|
137
141
|
import {
|
|
142
|
+
accountIdForCaller,
|
|
138
143
|
internalError,
|
|
139
144
|
notFoundError,
|
|
140
145
|
listPageFingerprint,
|
|
@@ -193,8 +198,11 @@ export interface InvitationLaneDeps {
|
|
|
193
198
|
* refused here when the invitation is another's.
|
|
194
199
|
*/
|
|
195
200
|
readonly credentialBinding: Pick<CredentialBinding, "admitsOrganization">;
|
|
196
|
-
/**
|
|
197
|
-
|
|
201
|
+
/**
|
|
202
|
+
* The identity-account port: whether the caller is a service account,
|
|
203
|
+
* which invites nobody, and which account a redeemer stands for.
|
|
204
|
+
*/
|
|
205
|
+
readonly accounts: AccountsByCaller;
|
|
198
206
|
}
|
|
199
207
|
|
|
200
208
|
type Commands = ServiceImpl<typeof InvitationCommandController>;
|
|
@@ -388,12 +396,23 @@ async function redeemInvitation(
|
|
|
388
396
|
}
|
|
389
397
|
|
|
390
398
|
await refuseBoundElsewhere(deps.credentialBinding, caller, org);
|
|
391
|
-
|
|
399
|
+
// The account the redeemer stands for, or the one their first sign-in
|
|
400
|
+
// will make (the header's redeem row).
|
|
401
|
+
const redeemer = await accountIdForCaller(deps.accounts, caller);
|
|
402
|
+
if (redeemer === caller.identityId) {
|
|
403
|
+
await refuseExistingMember(deps.authorizer, caller, org);
|
|
404
|
+
} else {
|
|
405
|
+
// A person not yet provisioned: the Authorizer knows them only by their
|
|
406
|
+
// subject, which no row names, so a second redeem before their account
|
|
407
|
+
// is made would pass it and take a second seat. Their membership is
|
|
408
|
+
// asked of the account the earlier redeem granted.
|
|
409
|
+
await refuseExistingAccountMember(deps.authorizationQueries, redeemer, org);
|
|
410
|
+
}
|
|
392
411
|
|
|
393
412
|
// Record before grant: a lost slot then has nothing to undo, so no
|
|
394
413
|
// redemption ever revokes a role row another one stands on (the header).
|
|
395
414
|
const redeemedAt = new Date();
|
|
396
|
-
const recorded = await deps.store.recordRedemption(invitationId,
|
|
415
|
+
const recorded = await deps.store.recordRedemption(invitationId, redeemer, redeemedAt);
|
|
397
416
|
if (recorded.kind === "refused") {
|
|
398
417
|
const current = await deps.store.findById(invitationId);
|
|
399
418
|
const currentState = current?.status?.state ?? InvitationState.invitation_state_unspecified;
|
|
@@ -408,7 +427,7 @@ async function redeemInvitation(
|
|
|
408
427
|
const role = create(GrantSpecSchema, {
|
|
409
428
|
principal: create(ApiResourceRefSchema, {
|
|
410
429
|
kind: "identity_account",
|
|
411
|
-
id:
|
|
430
|
+
id: redeemer,
|
|
412
431
|
}),
|
|
413
432
|
relation: IamRole[invitation.spec?.role ?? IamRole.iam_role_unspecified],
|
|
414
433
|
resource: create(ApiResourceRefSchema, { kind: "organization", id: org }),
|
|
@@ -421,14 +440,14 @@ async function redeemInvitation(
|
|
|
421
440
|
await deps.grants.create(role, inviter);
|
|
422
441
|
} catch (grantError) {
|
|
423
442
|
try {
|
|
424
|
-
const released = await deps.store.releaseRedemption(invitationId,
|
|
443
|
+
const released = await deps.store.releaseRedemption(invitationId, redeemer, redeemedAt);
|
|
425
444
|
if (released.kind === "absent") {
|
|
426
445
|
// The row, or this redemption's entry, went away between the
|
|
427
446
|
// record and the release (a delete, a hand edit): nothing to undo,
|
|
428
447
|
// but the trace is what finds a ledger that disagrees.
|
|
429
448
|
deps.logger.warn("a failed grant found no redemption to release", {
|
|
430
449
|
invitationId,
|
|
431
|
-
caller:
|
|
450
|
+
caller: redeemer,
|
|
432
451
|
org,
|
|
433
452
|
});
|
|
434
453
|
}
|
|
@@ -437,7 +456,7 @@ async function redeemInvitation(
|
|
|
437
456
|
"releasing a redemption FAILED after its grant failed — reconcile manually",
|
|
438
457
|
{
|
|
439
458
|
invitationId,
|
|
440
|
-
caller:
|
|
459
|
+
caller: redeemer,
|
|
441
460
|
org,
|
|
442
461
|
grantError: grantError instanceof Error ? grantError.message : String(grantError),
|
|
443
462
|
error: releaseError instanceof Error ? releaseError.message : String(releaseError),
|
|
@@ -669,6 +688,30 @@ async function refuseExistingMember(
|
|
|
669
688
|
}
|
|
670
689
|
}
|
|
671
690
|
|
|
691
|
+
/** `refuseExistingMember` for an account not yet provisioned, asked of the engine by its id. */
|
|
692
|
+
async function refuseExistingAccountMember(
|
|
693
|
+
queries: Pick<AuthorizationQueryEngine, "check">,
|
|
694
|
+
accountId: string,
|
|
695
|
+
org: string,
|
|
696
|
+
): Promise<void> {
|
|
697
|
+
let holds: boolean;
|
|
698
|
+
try {
|
|
699
|
+
holds = await queries.check(
|
|
700
|
+
create(GrantSpecSchema, {
|
|
701
|
+
principal: create(ApiResourceRefSchema, { kind: "identity_account", id: accountId }),
|
|
702
|
+
relation: IamPermission[IamPermission.can_view],
|
|
703
|
+
resource: create(ApiResourceRefSchema, { kind: "organization", id: org }),
|
|
704
|
+
}),
|
|
705
|
+
[],
|
|
706
|
+
);
|
|
707
|
+
} catch (error) {
|
|
708
|
+
throw internalError(error, "failed to verify organization membership");
|
|
709
|
+
}
|
|
710
|
+
if (holds) {
|
|
711
|
+
throw new ConnectError("You are already a member of this organization", Code.AlreadyExists);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
672
715
|
/** The create's business rules, with the lane's pinned copy. */
|
|
673
716
|
function validateInvitationSpec(invitation: Invitation): void {
|
|
674
717
|
const spec = invitation.spec;
|
|
@@ -8,12 +8,24 @@
|
|
|
8
8
|
* absorbing the same emit into exactly one WARN that names the pool and
|
|
9
9
|
* carries the message. A last case pins that every composition pool
|
|
10
10
|
* carries the checkout deadline, which bounds a starved checkout instead
|
|
11
|
-
* of letting it wait forever
|
|
12
|
-
*
|
|
11
|
+
* of letting it wait forever, and is `@stigmer/server`'s bounded pool: the
|
|
12
|
+
* same deadline constant, the same size unless its composition passes its
|
|
13
|
+
* own (as the self-hosted server passes the operator's), and a checkout
|
|
14
|
+
* that cannot open a
|
|
15
|
+
* connection rejects with `DatabaseUnavailableError`, which every RPC
|
|
16
|
+
* answers as Unavailable (stigmer/stigmer#3086). The starved checkout
|
|
17
|
+
* itself is proven on a real database in the server's
|
|
18
|
+
* store/postgres/__tests__/pool.postgres.test.ts. No database is involved: `emit` is how pg-pool itself reports the idle
|
|
13
19
|
* client's error, so driving the emitter is driving the real path. A pool
|
|
14
20
|
* that never connected ends cleanly, so each test closes what it opened.
|
|
15
21
|
*/
|
|
16
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
BoundedPool,
|
|
24
|
+
DEFAULT_POOL_CHECKOUT_TIMEOUT_MS,
|
|
25
|
+
DEFAULT_POOL_MAX,
|
|
26
|
+
DatabaseUnavailableError,
|
|
27
|
+
createLogger,
|
|
28
|
+
} from "@stigmer/server";
|
|
17
29
|
import pg from "pg";
|
|
18
30
|
import { describe, expect, it } from "vitest";
|
|
19
31
|
|
|
@@ -116,3 +128,49 @@ describe("a composition pool and a starved checkout", () => {
|
|
|
116
128
|
}
|
|
117
129
|
});
|
|
118
130
|
});
|
|
131
|
+
|
|
132
|
+
describe("a composition pool is the server's bounded pool", () => {
|
|
133
|
+
it("shares the store's deadline and size", async () => {
|
|
134
|
+
const pool = newCompositionPool({
|
|
135
|
+
name: "enterprise",
|
|
136
|
+
connectionString: CONNECTION_STRING,
|
|
137
|
+
logger: logCapture().logger,
|
|
138
|
+
});
|
|
139
|
+
try {
|
|
140
|
+
expect(pool).toBeInstanceOf(BoundedPool);
|
|
141
|
+
expect(POOL_CHECKOUT_TIMEOUT_MS).toBe(DEFAULT_POOL_CHECKOUT_TIMEOUT_MS);
|
|
142
|
+
expect(pool.options.max).toBe(DEFAULT_POOL_MAX);
|
|
143
|
+
} finally {
|
|
144
|
+
await pool.end();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("takes the size and deadline its composition passes", async () => {
|
|
149
|
+
const pool = newCompositionPool({
|
|
150
|
+
name: "enterprise",
|
|
151
|
+
connectionString: CONNECTION_STRING,
|
|
152
|
+
logger: logCapture().logger,
|
|
153
|
+
max: 7,
|
|
154
|
+
checkoutTimeoutMs: 1_500,
|
|
155
|
+
});
|
|
156
|
+
try {
|
|
157
|
+
expect(pool.options.max).toBe(7);
|
|
158
|
+
expect(pool.options.connectionTimeoutMillis).toBe(1_500);
|
|
159
|
+
} finally {
|
|
160
|
+
await pool.end();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("rejects a checkout it cannot open with DatabaseUnavailableError", async () => {
|
|
165
|
+
const pool = newCompositionPool({
|
|
166
|
+
name: "enterprise",
|
|
167
|
+
connectionString: CONNECTION_STRING,
|
|
168
|
+
logger: logCapture().logger,
|
|
169
|
+
});
|
|
170
|
+
try {
|
|
171
|
+
await expect(pool.query("SELECT 1")).rejects.toBeInstanceOf(DatabaseUnavailableError);
|
|
172
|
+
} finally {
|
|
173
|
+
await pool.end();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
package/src/postgres/pool.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The one constructor for a Postgres pool a composition owns. It
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
2
|
+
* The one constructor for a Postgres pool a composition owns. It builds on
|
|
3
|
+
* `@stigmer/server`'s bounded pool (`newBoundedPool`, the store's own pool
|
|
4
|
+
* constructor), so a composition's pools and the store's share one size,
|
|
5
|
+
* one checkout deadline and one failure type: a checkout that waits past
|
|
6
|
+
* the deadline, or a database that cannot be reached, rejects with
|
|
7
|
+
* `DatabaseUnavailableError`, which every RPC answers as Unavailable ("try
|
|
8
|
+
* again") rather than Internal. That module's header gives the reasons for
|
|
9
|
+
* the size (20) and the deadline (ten seconds, covering the wait for a
|
|
10
|
+
* client and the opening of one, never how long a client is held). This
|
|
11
|
+
* module adds the two things a composition's pool needs beyond that. A
|
|
12
|
+
* composition may pass its own size and deadline; the self-hosted
|
|
13
|
+
* Enterprise server passes the operator's DATABASE_POOL_MAX and
|
|
14
|
+
* DATABASE_POOL_CHECKOUT_TIMEOUT_MS, so one setting bounds both of its
|
|
15
|
+
* pools (editions/enterprise.ts).
|
|
11
16
|
*
|
|
12
|
-
* Why warn-only
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* `
|
|
24
|
-
* when trying to connect`, through the request's own error path. Ten
|
|
25
|
-
* seconds is far past any healthy wait for a client and well inside a
|
|
26
|
-
* caller's patience. The bound covers waiting for a client and opening a
|
|
27
|
-
* new connection, never how long a client is held, so a long migration or
|
|
28
|
-
* a lock's transaction is untouched.
|
|
17
|
+
* Why a warn-only idle-error listener with a name: a `pg.Pool` is an
|
|
18
|
+
* EventEmitter that re-emits an idle client's error as its own `'error'`
|
|
19
|
+
* event, and an EventEmitter with no `'error'` listener turns that emit
|
|
20
|
+
* into a throw from the event loop: not a rejected promise anything awaits,
|
|
21
|
+
* a process crash: a database that terminates its idle backends
|
|
22
|
+
* (`terminating connection due to administrator command`) would take the
|
|
23
|
+
* server with it. The pool has already dropped the dead client by the time
|
|
24
|
+
* it emits, and the next checkout opens a fresh connection on its own.
|
|
25
|
+
* There is nothing to repair and nothing to stop; the line exists so an
|
|
26
|
+
* operator reading the log can tell an idle-connection churn from a request
|
|
27
|
+
* failure. The message is the OSS store's, byte for byte, so one search
|
|
28
|
+
* finds every pool's report; the `pool` field says which pool it was.
|
|
29
29
|
*
|
|
30
30
|
* Why a name: each composition owns its pools by design (a self-hosted
|
|
31
31
|
* Enterprise server one over its database, `enterprise`). A new pool is a
|
|
@@ -33,11 +33,17 @@
|
|
|
33
33
|
* than appearing as another bare `new pg.Pool` somewhere in a unit; the
|
|
34
34
|
* same guard refuses the bare form anywhere else.
|
|
35
35
|
*/
|
|
36
|
-
import
|
|
37
|
-
|
|
36
|
+
import {
|
|
37
|
+
DEFAULT_POOL_CHECKOUT_TIMEOUT_MS,
|
|
38
|
+
newBoundedPool,
|
|
39
|
+
} from "@stigmer/server";
|
|
40
|
+
import type { BoundedPool, Logger } from "@stigmer/server";
|
|
38
41
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
42
|
+
/**
|
|
43
|
+
* How long a query waits for a client before it fails instead of hanging:
|
|
44
|
+
* the store's own deadline, so there is one number.
|
|
45
|
+
*/
|
|
46
|
+
export const POOL_CHECKOUT_TIMEOUT_MS = DEFAULT_POOL_CHECKOUT_TIMEOUT_MS;
|
|
41
47
|
|
|
42
48
|
/** A pool's name, in its log lines; each composition's guard pins the names it builds. */
|
|
43
49
|
export type CompositionPoolName = string;
|
|
@@ -46,24 +52,30 @@ export interface CompositionPoolOptions {
|
|
|
46
52
|
readonly name: CompositionPoolName;
|
|
47
53
|
readonly connectionString: string;
|
|
48
54
|
readonly logger: Logger;
|
|
55
|
+
/** The most connections the pool holds; the server's default (20) when unset. */
|
|
56
|
+
readonly max?: number;
|
|
57
|
+
/** How long a checkout may wait; `POOL_CHECKOUT_TIMEOUT_MS` when unset. */
|
|
58
|
+
readonly checkoutTimeoutMs?: number;
|
|
49
59
|
}
|
|
50
60
|
|
|
51
61
|
/**
|
|
52
|
-
* A
|
|
62
|
+
* A bounded pool over `connectionString` whose idle-connection errors are a
|
|
53
63
|
* WARN line carrying `pool: name`, never an unhandled `'error'` event, and
|
|
54
|
-
* whose checkouts
|
|
55
|
-
* forever.
|
|
64
|
+
* whose failed checkouts reject with `DatabaseUnavailableError` after at
|
|
65
|
+
* most `POOL_CHECKOUT_TIMEOUT_MS` instead of waiting forever.
|
|
56
66
|
*/
|
|
57
|
-
export function newCompositionPool(
|
|
58
|
-
|
|
67
|
+
export function newCompositionPool(
|
|
68
|
+
options: CompositionPoolOptions,
|
|
69
|
+
): BoundedPool {
|
|
70
|
+
return newBoundedPool({
|
|
59
71
|
connectionString: options.connectionString,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
max: options.max,
|
|
73
|
+
checkoutTimeoutMs: options.checkoutTimeoutMs,
|
|
74
|
+
onIdleError: (error) => {
|
|
75
|
+
options.logger.warn("postgres pool idle-connection error", {
|
|
76
|
+
pool: options.name,
|
|
77
|
+
error: error.message,
|
|
78
|
+
});
|
|
79
|
+
},
|
|
67
80
|
});
|
|
68
|
-
return pool;
|
|
69
81
|
}
|