@plitzi/sdk-kernel 0.0.0-stage → 0.39.3

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +80 -2
  3. package/dist/build/esbuild.d.ts +16 -0
  4. package/dist/build/index.d.ts +1 -0
  5. package/dist/build/index.mjs +35 -0
  6. package/dist/cache/CompressedFileCache.d.ts +18 -0
  7. package/dist/cache/TtlCache.d.ts +65 -0
  8. package/dist/cache/index.d.ts +3 -0
  9. package/dist/cache/index.mjs +1 -0
  10. package/dist/chunks/TtlCache-J_jG9oL9.mjs +200 -0
  11. package/dist/chunks/channel-DnVf7PJB.mjs +190 -0
  12. package/dist/chunks/csrf-BLWcaYOV.mjs +295 -0
  13. package/dist/chunks/link-C9wyDS9H.mjs +124 -0
  14. package/dist/chunks/query-DGbrN3mN.mjs +20 -0
  15. package/dist/chunks/scopes-Co6ZjhAm.mjs +46 -0
  16. package/dist/chunks/serverLog-BKaKjjc4.mjs +137 -0
  17. package/dist/chunks/session-B-dTEjeG.mjs +253 -0
  18. package/dist/chunks/sessionActivity-Ch7xuQ_o.mjs +43 -0
  19. package/dist/chunks/spaceDeployment-J2IMLfij.mjs +76 -0
  20. package/dist/chunks/stage-y6deE9LJ.mjs +345 -0
  21. package/dist/chunks/supervisor-Dh34v1vq.mjs +117 -0
  22. package/dist/chunks/tail-D-USrZIR.mjs +55 -0
  23. package/dist/chunks/tokens-BAV5YeT9.mjs +273 -0
  24. package/dist/data/index.d.ts +2 -0
  25. package/dist/data/index.mjs +68 -0
  26. package/dist/data/projectData.d.ts +21 -0
  27. package/dist/deployment/hostDeployment.d.ts +8 -0
  28. package/dist/deployment/index.d.ts +3 -0
  29. package/dist/deployment/index.mjs +19 -0
  30. package/dist/deployment/spaceDeployment.d.ts +11 -0
  31. package/dist/engine/index.d.ts +2 -0
  32. package/dist/engine/index.mjs +1 -0
  33. package/dist/engine/page.d.ts +49 -0
  34. package/dist/engine/rsc.d.ts +32 -0
  35. package/dist/files/atomicFile.d.ts +10 -0
  36. package/dist/files/index.d.ts +1 -0
  37. package/dist/files/index.mjs +32 -0
  38. package/dist/http/bearer.d.ts +5 -0
  39. package/dist/http/buildResponseHelpers.d.ts +23 -0
  40. package/dist/http/closeOnSignals.d.ts +28 -0
  41. package/dist/http/compress.d.ts +20 -0
  42. package/dist/http/dispatcher.d.ts +15 -0
  43. package/dist/http/drain.d.ts +18 -0
  44. package/dist/http/fleet/channel.d.ts +103 -0
  45. package/dist/http/fleet/link.d.ts +28 -0
  46. package/dist/http/fleet/role.d.ts +46 -0
  47. package/dist/http/fleet/supervisor.d.ts +29 -0
  48. package/dist/http/freePort.d.ts +24 -0
  49. package/dist/http/health.d.ts +21 -0
  50. package/dist/http/index.d.ts +48 -0
  51. package/dist/http/index.mjs +1313 -0
  52. package/dist/http/middlewares/auth.d.ts +2 -0
  53. package/dist/http/middlewares/basicAuth.d.ts +6 -0
  54. package/dist/http/mimeTypes.d.ts +13 -0
  55. package/dist/http/navigation.d.ts +14 -0
  56. package/dist/http/onAbort.d.ts +12 -0
  57. package/dist/http/probes.d.ts +4 -0
  58. package/dist/http/requestParser.d.ts +22 -0
  59. package/dist/http/runMiddlewares.d.ts +6 -0
  60. package/dist/http/securityHeaders.d.ts +18 -0
  61. package/dist/http/server.d.ts +39 -0
  62. package/dist/http/socketResponse.d.ts +18 -0
  63. package/dist/http/sse.d.ts +26 -0
  64. package/dist/http/stages/crossSiteWrites.d.ts +24 -0
  65. package/dist/http/stages/health.d.ts +11 -0
  66. package/dist/http/stages/middlewares.d.ts +3 -0
  67. package/dist/http/stages/static.d.ts +4 -0
  68. package/dist/http/staticFiles.d.ts +3 -0
  69. package/dist/http/stopping.d.ts +11 -0
  70. package/dist/http/transports.d.ts +31 -0
  71. package/dist/http/types.d.ts +29 -0
  72. package/dist/http/unusedPort.d.ts +10 -0
  73. package/dist/http/webExchange.d.ts +18 -0
  74. package/dist/http/wsFrame.d.ts +3 -0
  75. package/dist/identity/accounts.d.ts +278 -0
  76. package/dist/identity/authorize.d.ts +96 -0
  77. package/dist/identity/credentials.d.ts +40 -0
  78. package/dist/identity/csrf.d.ts +139 -0
  79. package/dist/identity/debugAuthorization.d.ts +24 -0
  80. package/dist/identity/domains.d.ts +41 -0
  81. package/dist/identity/identity.d.ts +119 -0
  82. package/dist/identity/index.d.ts +21 -0
  83. package/dist/identity/index.mjs +731 -0
  84. package/dist/identity/passwords.d.ts +15 -0
  85. package/dist/identity/previewToken.d.ts +21 -0
  86. package/dist/identity/requestIdentity.d.ts +14 -0
  87. package/dist/identity/scopes.d.ts +56 -0
  88. package/dist/identity/session.d.ts +185 -0
  89. package/dist/identity/sessionActivity.d.ts +11 -0
  90. package/dist/identity/spaceTokens.d.ts +174 -0
  91. package/dist/index.d.ts +17 -0
  92. package/dist/index.mjs +1 -0
  93. package/dist/log/index.d.ts +3 -0
  94. package/dist/log/index.mjs +3 -0
  95. package/dist/log/serverLog.d.ts +49 -0
  96. package/dist/log/tail.d.ts +43 -0
  97. package/dist/mysql/accounts.d.ts +4 -0
  98. package/dist/mysql/admin.d.ts +58 -0
  99. package/dist/mysql/config.d.ts +82 -0
  100. package/dist/mysql/identities.d.ts +35 -0
  101. package/dist/mysql/index.d.ts +7 -0
  102. package/dist/mysql/index.mjs +1203 -0
  103. package/dist/mysql/pool.d.ts +3 -0
  104. package/dist/mysql/query.d.ts +12 -0
  105. package/dist/mysql/schema.d.ts +43 -0
  106. package/dist/mysql/sessions.d.ts +23 -0
  107. package/dist/mysql/spaceTokens.d.ts +11 -0
  108. package/dist/mysql/store.d.ts +66 -0
  109. package/dist/outbound/index.d.ts +4 -0
  110. package/dist/outbound/index.mjs +314 -0
  111. package/dist/outbound/inside.d.ts +36 -0
  112. package/dist/outbound/outboundGuard.d.ts +69 -0
  113. package/dist/pubsub/index.d.ts +3 -0
  114. package/dist/pubsub/index.mjs +76 -0
  115. package/dist/pubsub/memoryPubSub.d.ts +10 -0
  116. package/dist/pubsub/redisPubSub.d.ts +24 -0
  117. package/dist/stats/index.d.ts +9 -0
  118. package/dist/stats/index.mjs +228 -0
  119. package/dist/stats/load.d.ts +31 -0
  120. package/dist/stats/memory.d.ts +20 -0
  121. package/dist/stats/pools.d.ts +15 -0
  122. package/dist/stats/recorder.d.ts +34 -0
  123. package/dist/stats/stage.d.ts +15 -0
  124. package/dist/stats/types.d.ts +309 -0
  125. package/dist/testing/certificates.d.ts +21 -0
  126. package/dist/testing/fleet.d.ts +28 -0
  127. package/dist/testing/goneRuns.d.ts +5 -0
  128. package/dist/testing/index.d.ts +5 -0
  129. package/dist/testing/index.mjs +270 -0
  130. package/dist/testing/keys.d.ts +2 -0
  131. package/dist/testing/runNames.d.ts +10 -0
  132. package/dist/tokens/index.d.ts +2 -0
  133. package/dist/tokens/index.mjs +1 -0
  134. package/dist/tokens/tokens.d.ts +195 -0
  135. package/dist/types/adapters.d.ts +388 -0
  136. package/dist/types/config.d.ts +240 -0
  137. package/dist/types/index.d.ts +5 -0
  138. package/dist/types/index.mjs +1 -0
  139. package/dist/types/log.d.ts +119 -0
  140. package/dist/types/oauth.d.ts +246 -0
  141. package/dist/types/pipeline.d.ts +239 -0
  142. package/package.json +67 -3
@@ -0,0 +1,119 @@
1
+ import { CredentialCarrier } from './credentials';
2
+ import { AuthFailure, SpaceScope } from './scopes';
3
+ import { Tokens } from '../tokens/tokens';
4
+ /** A Plitzi-style account, as whatever stores accounts reports it. `permissions` are its GLOBAL capabilities. */
5
+ export interface Actor {
6
+ id: number;
7
+ username: string;
8
+ email: string;
9
+ verified: boolean;
10
+ roles: string[];
11
+ permissions: string[];
12
+ token: string;
13
+ /** Unix seconds the presented credential dies at, off the stored row rather than the claim. */
14
+ expiresAt: number;
15
+ /**
16
+ * The administrator behind this session, when somebody is acting AS this account — see `admin.impersonate`. Off
17
+ * the credential's `act` claim, so it survives into anything that reads an actor: an audit line that says who
18
+ * really did it, a UI banner, a flow that declines to run while borrowed.
19
+ */
20
+ impersonatedBy?: number;
21
+ }
22
+ /** A space token, resolved. `userId` is set for `agent` grants and names the member who consented. */
23
+ export interface Grant {
24
+ spaceId: number;
25
+ scope: SpaceScope;
26
+ userId?: number;
27
+ /** For an `agent` grant, the application the member connected, as it registered (`Claude`): who writes for them. */
28
+ client?: string;
29
+ origins: string[];
30
+ }
31
+ /** What an account may do inside ONE space. */
32
+ export interface SpaceMembership {
33
+ spaceId: number;
34
+ isOwner: boolean;
35
+ role: string;
36
+ permissions: string[];
37
+ }
38
+ /** The stored side of a space token — the row that makes a signature revocable. */
39
+ export interface StoredSpaceToken {
40
+ spaceId: number;
41
+ scope: SpaceScope;
42
+ userId?: number;
43
+ /** For an `agent` grant, the application the member connected (`Claude`). */
44
+ client?: string;
45
+ }
46
+ /**
47
+ * What identity resolution cannot work out on its own: where accounts, space tokens and memberships are kept. This
48
+ * is the whole database surface authorization needs, and the reason a deployment can bring any store it likes.
49
+ */
50
+ export interface IdentityAdapters {
51
+ /**
52
+ * The account a session token belongs to, looked up **by the token**. The row is the revocation switch: issuing a
53
+ * new session overwrites it, which is what makes rotation effective, so a token that no longer matches a row is
54
+ * revoked however valid its signature still is.
55
+ */
56
+ findAccountByToken: (token: string) => Promise<Actor | undefined>;
57
+ /**
58
+ * The stored space token. No row, no grant — which is also what its absence means: a deployment that serves only
59
+ * its own pages issues no space credentials, and omitting this refuses every grant instead of forcing a stub that
60
+ * returns undefined.
61
+ */
62
+ findSpaceToken?: (token: string) => Promise<StoredSpaceToken | undefined>;
63
+ /** Membership of one space. Without it, every space-level permission check refuses. */
64
+ findMembership?: (userId: number, spaceId: number) => Promise<SpaceMembership | undefined>;
65
+ }
66
+ export interface IdentityConfig {
67
+ /** This deployment's own hosts, which serve first-party traffic for every space. */
68
+ platformHosts?: string[];
69
+ /** Origins always accepted regardless of what a token declares — the deployment's own apps. */
70
+ platformOrigins?: string[];
71
+ /** Whether a request with no `Origin` at all may carry a space token. */
72
+ allowWithoutOrigin?: boolean;
73
+ log?: (message: string, meta: Record<string, unknown>) => void;
74
+ }
75
+ export type ActorResult = {
76
+ ok: true;
77
+ actor: Actor;
78
+ } | {
79
+ ok: false;
80
+ reason: AuthFailure;
81
+ };
82
+ export type GrantResult = {
83
+ ok: true;
84
+ grant: Grant;
85
+ } | {
86
+ ok: false;
87
+ reason: AuthFailure;
88
+ };
89
+ export interface GrantOptions {
90
+ /**
91
+ * Skips the Origin/embed check. Correct for non-browser transports (MCP, analytics ingest, WS upgrade). It does
92
+ * NOT skip the domain binding below — that one is the point.
93
+ */
94
+ skipOrigin?: boolean;
95
+ /**
96
+ * The host the request actually arrived on. A render token is only valid on the domains it declares, and unlike
97
+ * `Origin` the host cannot be chosen by the caller — it is where the request was routed.
98
+ */
99
+ host?: string;
100
+ }
101
+ export interface Carriers {
102
+ userTokenCandidates: (carrier: CredentialCarrier) => string[];
103
+ spaceTokenCandidates: (carrier: CredentialCarrier) => string[];
104
+ }
105
+ export declare const createIdentity: ({ tokens, carriers, adapters, config, presentedOrigin }: {
106
+ tokens: Tokens;
107
+ carriers: Carriers;
108
+ adapters: IdentityAdapters;
109
+ config?: IdentityConfig;
110
+ presentedOrigin: (carrier: CredentialCarrier) => string;
111
+ }) => {
112
+ resolveActor: (carrier: CredentialCarrier) => Promise<ActorResult>;
113
+ resolveActorFromToken: (token: string) => Promise<ActorResult>;
114
+ resolveGrant: (carrier: CredentialCarrier, options?: GrantOptions) => Promise<GrantResult>;
115
+ resolveGrantFromToken: (token: string, origin: string, { skipOrigin, host }?: GrantOptions) => Promise<GrantResult>;
116
+ can: (actor: Actor, spaceId: number, permission: string) => Promise<boolean>;
117
+ grantCan: (grant: Grant, permission: string) => Promise<boolean>;
118
+ };
119
+ export type Identity = ReturnType<typeof createIdentity>;
@@ -0,0 +1,21 @@
1
+ export { requirementFor, createAuthorizer, checkPermission, checkSpaceAccess } from './authorize';
2
+ export { readCookies, SPACE_TOKEN_PARAM, createCarriers, presentedOrigin } from './credentials';
3
+ export { csrfFailureMessage, carrierOf, crossSiteRequest, createCsrf } from './csrf';
4
+ export { authorizesDebugging, resolveDebugAuthorization } from './debugAuthorization';
5
+ export { hostnameOf, ANY_DOMAIN, domainAllowed, normalizeDomain, frameAncestors, corsOrigins } from './domains';
6
+ export { createIdentity } from './identity';
7
+ export { hashPassword, verifyPassword, generateToken } from './passwords';
8
+ export { PREVIEW_TOKEN_PARAM, PREVIEW_COOKIE, readDraftToken } from './previewToken';
9
+ export { SCOPES, OFF_BROWSER_SPACE_SCOPES, authFailureMessage } from './scopes';
10
+ export { isLocalHost, isPrivateNetworkHost, registrableDomain, sessionCookieParams, sessionHintCookieName, sessionHintValue, parseSessionHint, appendCookies, writeSessionCookies, clearSessionCookies, writeFlowCookie, clearFlowCookie, readFlowCookie, readSessionToken, readRefreshToken, readSessionHint, RENEWAL_GUARD_SECONDS, writeRenewalGuard, sessionReturnTarget, readRenewalGuard, createSessionCookies } from './session';
11
+ export { SESSION_ACTIVITY_RESOLUTION_SECONDS, activityDue } from './sessionActivity';
12
+ export { createSpaceTokenApi } from './spaceTokens';
13
+ export type { AccountRecord, AccountAccess, SessionClient, SessionApp, AccountStatus, SessionSummary, MfaRecord, SecurityEvent, AccountQuery, SessionContext, AccountAdapters } from './accounts';
14
+ export type { PathMatcher, Requirement, AuthPolicy, AuthorizeResult, Authorizer, PermissionCheck, MembershipFacts, SpaceAccessCheck } from './authorize';
15
+ export type { CredentialCarrier } from './credentials';
16
+ export type { CsrfConfig, CsrfSubject, CsrfFailure, CsrfResult, CsrfCarrier, Csrf } from './csrf';
17
+ export type { Actor, Grant, SpaceMembership, StoredSpaceToken, IdentityAdapters, IdentityConfig, ActorResult, GrantResult, GrantOptions, Carriers, Identity } from './identity';
18
+ export type { RequestIdentity } from './requestIdentity';
19
+ export type { TokenScope, SpaceScope, AuthFailure } from './scopes';
20
+ export type { CookieSink, SessionCookieParams, CookieRequest, SessionHint, CookieCarrier, SessionCookies } from './session';
21
+ export type { SpaceTokenRecord, SpaceTokenAdapters, SpaceTokenContext, SpaceTokenOutcome, SpaceTokenSummary, SpaceTokenApi } from './spaceTokens';