@plitzi/sdk-server 0.33.2 → 0.34.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/CHANGELOG.md +44 -0
- package/README.md +283 -8
- package/dist/actions.d.ts +62 -0
- package/dist/actions.js +12 -0
- package/dist/adapters/cloudAdapters.d.ts +72 -0
- package/dist/adapters/cloudAdapters.js +303 -0
- package/dist/adapters/space/index.d.ts +93 -0
- package/dist/adapters/space/index.js +122 -0
- package/dist/adapters/space/resolvers.d.ts +69 -0
- package/dist/adapters/space/resolvers.js +79 -0
- package/dist/adapters/space/space.test.d.ts +1 -0
- package/dist/adapters/space/types.d.ts +64 -0
- package/dist/adapters/space/types.js +41 -0
- package/dist/auth.d.ts +50 -0
- package/dist/auth.js +19 -0
- package/dist/core/auth/api.d.ts +400 -11
- package/dist/core/auth/api.js +1044 -50
- package/dist/core/auth/createAuth.d.ts +135 -30
- package/dist/core/auth/createAuth.js +96 -24
- package/dist/core/auth/credentials.d.ts +9 -3
- package/dist/core/auth/credentials.js +10 -4
- package/dist/core/auth/csrf.d.ts +89 -0
- package/dist/core/auth/csrf.js +234 -0
- package/dist/core/auth/csrf.test.d.ts +1 -0
- package/dist/core/auth/identity.d.ts +6 -0
- package/dist/core/auth/identity.js +37 -8
- package/dist/core/auth/lifecycle.test.d.ts +1 -0
- package/dist/core/auth/oauth/index.d.ts +8 -0
- package/dist/core/auth/oauth/index.js +13 -15
- package/dist/core/auth/passwords.d.ts +15 -0
- package/dist/core/auth/passwords.js +32 -0
- package/dist/core/auth/redirects.d.ts +18 -0
- package/dist/core/auth/redirects.js +31 -0
- package/dist/core/auth/redirects.test.d.ts +1 -0
- package/dist/core/auth/routes.d.ts +4 -2
- package/dist/core/auth/routes.js +234 -9
- package/dist/core/auth/session.d.ts +11 -0
- package/dist/core/auth/session.js +1 -1
- package/dist/core/auth/spaceTokens.d.ts +38 -2
- package/dist/core/auth/spaceTokens.js +54 -2
- package/dist/core/auth/throttle.d.ts +5 -0
- package/dist/core/auth/throttle.js +81 -0
- package/dist/core/auth/throttle.test.d.ts +1 -0
- package/dist/core/auth/tokens.d.ts +83 -12
- package/dist/core/auth/tokens.js +51 -9
- package/dist/core/auth/totp.d.ts +48 -0
- package/dist/core/auth/totp.js +118 -0
- package/dist/core/auth/totp.test.d.ts +1 -0
- package/dist/core/createServer.d.ts +0 -6
- package/dist/core/createServer.js +35 -3
- package/dist/core/fontStore.d.ts +33 -0
- package/dist/core/fontStore.js +53 -0
- package/dist/core/fontStore.test.d.ts +1 -0
- package/dist/core/handlers/authMiddleware.js +1 -1
- package/dist/core/handlers/authRouteHandlers.d.ts +9 -1
- package/dist/core/handlers/authRouteHandlers.js +4 -3
- package/dist/core/handlers/csrfMiddleware.d.ts +20 -0
- package/dist/core/handlers/csrfMiddleware.js +32 -0
- package/dist/core/handlers/oauthRouteHandlers.d.ts +46 -0
- package/dist/core/handlers/oauthRouteHandlers.js +159 -0
- package/dist/core/handlers/socialRouteHandlers.d.ts +40 -0
- package/dist/core/handlers/socialRouteHandlers.js +129 -0
- package/dist/core/handlers/socialRouteHandlers.test.d.ts +1 -0
- package/dist/core/handlers/types.d.ts +22 -5
- package/dist/core/health.d.ts +11 -1
- package/dist/core/health.js +27 -3
- package/dist/core/http/dispatcher.d.ts +1 -1
- package/dist/core/http/dispatcher.js +20 -1
- package/dist/core/http/stages/authApi.js +1 -1
- package/dist/core/http/stages/fontAssets.d.ts +9 -0
- package/dist/core/http/stages/fontAssets.js +27 -0
- package/dist/core/http/stages/oauth.d.ts +19 -0
- package/dist/core/http/stages/oauth.js +118 -0
- package/dist/core/http/types.d.ts +12 -0
- package/dist/core/oauth/authorize.d.ts +22 -0
- package/dist/core/oauth/authorize.js +254 -0
- package/dist/core/oauth/authorize.test.d.ts +1 -0
- package/dist/core/oauth/challenge.d.ts +11 -0
- package/dist/core/oauth/challenge.js +33 -0
- package/dist/core/oauth/consentPage.d.ts +12 -0
- package/dist/core/oauth/consentPage.js +131 -0
- package/dist/core/oauth/metadata.d.ts +41 -0
- package/dist/core/oauth/metadata.js +71 -0
- package/dist/core/oauth/params.d.ts +5 -0
- package/dist/core/oauth/params.js +5 -0
- package/dist/core/oauth/pkce.d.ts +6 -0
- package/dist/core/oauth/pkce.js +15 -0
- package/dist/core/oauth/records.d.ts +72 -0
- package/dist/core/oauth/records.js +49 -0
- package/dist/core/oauth/register.d.ts +5 -0
- package/dist/core/oauth/register.js +55 -0
- package/dist/core/oauth/respond.d.ts +21 -0
- package/dist/core/oauth/respond.js +59 -0
- package/dist/core/oauth/token.d.ts +14 -0
- package/dist/core/oauth/token.js +130 -0
- package/dist/core/previewToken.d.ts +20 -0
- package/dist/core/previewToken.js +29 -1
- package/dist/core/server/pageServer.js +4 -1
- package/dist/core/services/action.d.ts +6 -4
- package/dist/core/services/action.js +103 -10
- package/dist/core/services/registry.js +2 -0
- package/dist/core/services/resolve.d.ts +8 -0
- package/dist/core/services/resolve.js +12 -1
- package/dist/core/staticFiles.js +1 -2
- package/dist/handlers.d.ts +7 -1
- package/dist/handlers.js +4 -1
- package/dist/helpers/buildResponseHelpers.d.ts +8 -0
- package/dist/helpers/buildResponseHelpers.js +9 -1
- package/dist/helpers/buildServerInfo.d.ts +8 -3
- package/dist/helpers/buildServerInfo.js +18 -14
- package/dist/helpers/cache/keys.d.ts +13 -0
- package/dist/helpers/cache/keys.js +12 -1
- package/dist/helpers/onAbort.d.ts +12 -0
- package/dist/helpers/onAbort.js +22 -0
- package/dist/helpers/onAbort.test.d.ts +1 -0
- package/dist/helpers/outboundGuard.d.ts +27 -0
- package/dist/helpers/outboundGuard.js +49 -0
- package/dist/helpers/outboundGuard.test.d.ts +1 -0
- package/dist/helpers/serverLog.d.ts +6 -3
- package/dist/helpers/serverLog.js +20 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -4
- package/dist/kernel.d.ts +5 -22
- package/dist/kernel.js +1 -14
- package/dist/modules/actions/{handler.js → connectorWrite.js} +5 -2
- package/dist/modules/actions/connectorWrite.test.d.ts +1 -0
- package/dist/modules/actions/index.d.ts +40 -0
- package/dist/modules/actions/index.js +46 -0
- package/dist/modules/actions/moduleFor.d.ts +3 -0
- package/dist/modules/actions/moduleFor.js +35 -0
- package/dist/modules/actions/moduleFor.test.d.ts +1 -0
- package/dist/modules/actions/runtime/check.d.ts +24 -0
- package/dist/modules/actions/runtime/check.js +111 -0
- package/dist/modules/actions/runtime/check.test.d.ts +1 -0
- package/dist/modules/actions/runtime/errors.d.ts +11 -0
- package/dist/modules/actions/runtime/errors.js +17 -0
- package/dist/modules/actions/runtime/guards.d.ts +126 -0
- package/dist/modules/actions/runtime/guards.js +246 -0
- package/dist/modules/actions/runtime/guards.test.d.ts +1 -0
- package/dist/modules/actions/runtime/kvStore.d.ts +27 -0
- package/dist/modules/actions/runtime/kvStore.js +41 -0
- package/dist/modules/actions/runtime/kvStore.test.d.ts +1 -0
- package/dist/modules/actions/runtime/limits.d.ts +11 -0
- package/dist/modules/actions/runtime/limits.js +35 -0
- package/dist/modules/actions/runtime/memoryKv.d.ts +2 -0
- package/dist/modules/actions/runtime/memoryKv.js +77 -0
- package/dist/modules/actions/runtime/namespaceKv.d.ts +9 -0
- package/dist/modules/actions/runtime/namespaceKv.js +19 -0
- package/dist/modules/actions/runtime/precheck.d.ts +27 -0
- package/dist/modules/actions/runtime/precheck.js +45 -0
- package/dist/modules/actions/runtime/renderResolver.d.ts +15 -0
- package/dist/modules/actions/runtime/renderResolver.js +130 -0
- package/dist/modules/actions/runtime/renderResolver.test.d.ts +1 -0
- package/dist/modules/actions/runtime/renderShare.d.ts +29 -0
- package/dist/modules/actions/runtime/renderShare.js +36 -0
- package/dist/modules/actions/runtime/renderShare.test.d.ts +1 -0
- package/dist/modules/actions/runtime/report.d.ts +14 -0
- package/dist/modules/actions/runtime/report.js +22 -0
- package/dist/modules/actions/runtime/runAction.d.ts +12 -0
- package/dist/modules/actions/runtime/runAction.js +405 -0
- package/dist/modules/actions/runtime/runAction.test.d.ts +1 -0
- package/dist/modules/actions/runtime/runLogger.d.ts +31 -0
- package/dist/modules/actions/runtime/runLogger.js +66 -0
- package/dist/modules/actions/runtime/runLogger.test.d.ts +1 -0
- package/dist/modules/actions/runtime/schedule.d.ts +35 -0
- package/dist/modules/actions/runtime/schedule.js +76 -0
- package/dist/modules/actions/runtime/schedule.test.d.ts +1 -0
- package/dist/modules/actions/runtime/scope.d.ts +40 -0
- package/dist/modules/actions/runtime/scope.js +103 -0
- package/dist/modules/actions/runtime/triggers.d.ts +12 -0
- package/dist/modules/actions/runtime/triggers.js +14 -0
- package/dist/modules/actions/taskCatalog.d.ts +26 -0
- package/dist/modules/actions/taskCatalog.js +24 -0
- package/dist/modules/actions/taskCatalog.test.d.ts +1 -0
- package/dist/modules/actions/tasks/auth.d.ts +2 -0
- package/dist/modules/actions/tasks/auth.js +40 -0
- package/dist/modules/actions/tasks/builtins.d.ts +8 -0
- package/dist/modules/actions/tasks/builtins.js +24 -0
- package/dist/modules/actions/tasks/connector.d.ts +2 -0
- package/dist/modules/actions/tasks/connector.js +141 -0
- package/dist/modules/actions/tasks/db.d.ts +2 -0
- package/dist/modules/actions/tasks/db.js +59 -0
- package/dist/modules/actions/tasks/db.test.d.ts +1 -0
- package/dist/modules/actions/tasks/flow.d.ts +3 -0
- package/dist/modules/actions/tasks/flow.js +109 -0
- package/dist/modules/actions/tasks/helpers.d.ts +16 -0
- package/dist/modules/actions/tasks/helpers.js +30 -0
- package/dist/modules/actions/tasks/http.d.ts +2 -0
- package/dist/modules/actions/tasks/http.js +111 -0
- package/dist/modules/actions/tasks/http.test.d.ts +1 -0
- package/dist/modules/actions/tasks/kv.d.ts +2 -0
- package/dist/modules/actions/tasks/kv.js +102 -0
- package/dist/modules/actions/tasks/kv.test.d.ts +1 -0
- package/dist/modules/actions/tasks/registry.d.ts +10 -0
- package/dist/modules/actions/tasks/registry.js +36 -0
- package/dist/modules/actions/tasks/transform.d.ts +2 -0
- package/dist/modules/actions/tasks/transform.js +34 -0
- package/dist/modules/actions/transport/callHandler.d.ts +24 -0
- package/dist/modules/actions/transport/callHandler.js +233 -0
- package/dist/modules/actions/transport/callHandler.test.d.ts +1 -0
- package/dist/modules/actions/transport/cancelHandler.d.ts +23 -0
- package/dist/modules/actions/transport/cancelHandler.js +23 -0
- package/dist/modules/actions/transport/catalogHandler.d.ts +18 -0
- package/dist/modules/actions/transport/catalogHandler.js +21 -0
- package/dist/modules/actions/transport/stream.d.ts +23 -0
- package/dist/modules/actions/transport/stream.js +100 -0
- package/dist/modules/actions/transport/verifySignature.d.ts +16 -0
- package/dist/modules/actions/transport/verifySignature.js +72 -0
- package/dist/modules/actions/transport/webhookHandler.d.ts +25 -0
- package/dist/modules/actions/transport/webhookHandler.js +206 -0
- package/dist/modules/actions/transport/webhookHandler.test.d.ts +1 -0
- package/dist/modules/actions/types.d.ts +234 -0
- package/dist/modules/connectors/engine.js +4 -1
- package/dist/modules/connectors/resolver.d.ts +10 -2
- package/dist/modules/connectors/resolver.js +8 -3
- package/dist/modules/mysql/accounts.d.ts +5 -0
- package/dist/modules/mysql/accounts.js +365 -0
- package/dist/modules/mysql/accounts.test.d.ts +1 -0
- package/dist/modules/mysql/admin.d.ts +58 -0
- package/dist/modules/mysql/admin.js +133 -0
- package/dist/modules/mysql/config.d.ts +82 -0
- package/dist/modules/mysql/config.js +30 -0
- package/dist/modules/mysql/identities.d.ts +35 -0
- package/dist/modules/mysql/identities.js +43 -0
- package/dist/modules/mysql/index.d.ts +67 -0
- package/dist/modules/mysql/index.js +62 -0
- package/dist/modules/mysql/pool.d.ts +3 -0
- package/dist/modules/mysql/pool.js +88 -0
- package/dist/modules/mysql/query.d.ts +12 -0
- package/dist/modules/mysql/query.js +21 -0
- package/dist/modules/mysql/schema.d.ts +43 -0
- package/dist/modules/mysql/schema.js +340 -0
- package/dist/modules/mysql/schema.test.d.ts +1 -0
- package/dist/modules/mysql/sessions.d.ts +33 -0
- package/dist/modules/mysql/sessions.js +46 -0
- package/dist/modules/mysql/spaceTokens.d.ts +11 -0
- package/dist/modules/mysql/spaceTokens.js +59 -0
- package/dist/modules/mysql/store.integration.test.d.ts +1 -0
- package/dist/modules/rsc/connectorRscData.d.ts +25 -0
- package/dist/modules/rsc/connectorRscData.js +51 -0
- package/dist/modules/rsc/connectorRscData.test.d.ts +1 -0
- package/dist/modules/rsc/handler.js +16 -3
- package/dist/modules/rsc/matchRscPage.d.ts +14 -0
- package/dist/modules/rsc/matchRscPage.js +26 -0
- package/dist/modules/rsc/resolveRscData.d.ts +14 -1
- package/dist/modules/rsc/resolveRscData.js +23 -34
- package/dist/modules/ssr/Component.d.ts +6 -2
- package/dist/modules/ssr/Component.js +3 -1
- package/dist/modules/ssr/draftSession.test.d.ts +1 -0
- package/dist/modules/ssr/handler.js +15 -2
- package/dist/modules/ssr/loadPluginComponents.js +22 -5
- package/dist/modules/ssr/prepareRender.js +87 -8
- package/dist/modules/ssr/prepareRender.test.d.ts +1 -0
- package/dist/modules/ssr/preview.d.ts +21 -8
- package/dist/modules/ssr/preview.js +38 -14
- package/dist/modules/ssr/registerExternalPlugins.js +2 -2
- package/dist/modules/ssr/resolvePageSeo.d.ts +18 -0
- package/dist/modules/ssr/resolvePageSeo.js +26 -0
- package/dist/modules/ssr/resolvePageSeo.test.d.ts +1 -0
- package/dist/modules/ssr/template.test.d.ts +1 -0
- package/dist/modules/ssr/views/template.ejs +71 -5
- package/dist/mysql.d.ts +26 -0
- package/dist/mysql.js +4 -0
- package/dist/oauth.d.ts +24 -0
- package/dist/oauth.js +10 -0
- package/dist/plugins/compile.d.ts +1 -0
- package/dist/plugins/compile.js +37 -3
- package/dist/plugins/manager.d.ts +40 -0
- package/dist/plugins/manager.js +113 -13
- package/dist/plugins/manager.test.d.ts +1 -0
- package/package.json +43 -14
- package/skills/plitzi-authoring/SKILL.md +252 -0
- /package/dist/{modules/actions/handler.test.d.ts → adapters/cloudAdapters.test.d.ts} +0 -0
- /package/dist/modules/actions/{handler.d.ts → connectorWrite.d.ts} +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Environment, PluginSource, SSRCredential, SSRRequest, SSRTemplateProps } from '@plitzi/sdk-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Which space a request resolved to, before the server fills in what is the same for everybody.
|
|
4
|
+
*
|
|
5
|
+
* `SSRSpaceDeployment` minus the parts a resolver has no business deciding: `frameAncestors` is derived from the
|
|
6
|
+
* space's declared domains by one rule, and `error` is what a REFUSAL is, which is a different return.
|
|
7
|
+
*/
|
|
8
|
+
export interface SpaceResolution {
|
|
9
|
+
spaceId: number;
|
|
10
|
+
/** Defaults to `main`. */
|
|
11
|
+
environment?: Environment;
|
|
12
|
+
/** Defaults to `0` — the live snapshot. */
|
|
13
|
+
revision?: number;
|
|
14
|
+
credential?: SSRCredential;
|
|
15
|
+
/**
|
|
16
|
+
* This render is an author looking at their own work rather than a visitor being served. Metering skips it.
|
|
17
|
+
* `authoringPreview` sets it; nothing infers it, because only the resolver can tell the two apart.
|
|
18
|
+
*/
|
|
19
|
+
authoring?: boolean;
|
|
20
|
+
templateProps?: SSRTemplateProps;
|
|
21
|
+
pluginNames?: string[];
|
|
22
|
+
pluginSources?: Record<string, PluginSource>;
|
|
23
|
+
}
|
|
24
|
+
/** A resolver that has decided this request gets nothing, and that no later resolver should be asked. */
|
|
25
|
+
export interface SpaceRefusal {
|
|
26
|
+
refuse: {
|
|
27
|
+
code: number;
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One way a request becomes a space.
|
|
33
|
+
*
|
|
34
|
+
* Three returns, and the difference between two of them is the whole reason this is a list:
|
|
35
|
+
*
|
|
36
|
+
* - a `SpaceResolution` — mine, here it is;
|
|
37
|
+
* - a `SpaceRefusal` — mine, and the answer is no. **The chain stops.** A request that presented a bad credential
|
|
38
|
+
* for a space must not fall through to being served as an anonymous visitor of some other one;
|
|
39
|
+
* - `undefined` — not mine, ask the next.
|
|
40
|
+
*/
|
|
41
|
+
export type SpaceResolver = (req: SSRRequest) => Promise<SpaceResolution | SpaceRefusal | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* Somewhere to keep a lookup that every request repeats. Strings in, strings out: JSON is this module's problem,
|
|
44
|
+
* and a `get`/`set`/`delete` of strings is satisfied by Redis, Memcached, a file, or the in-memory cache below —
|
|
45
|
+
* without any of them being named here.
|
|
46
|
+
*
|
|
47
|
+
* Every method may fail without failing the request: a cache that is down is a slow deployment, not a broken one.
|
|
48
|
+
*/
|
|
49
|
+
export interface SpaceCache {
|
|
50
|
+
get: (key: string) => Promise<string | undefined>;
|
|
51
|
+
set: (key: string, value: string, ttlSeconds: number) => Promise<void>;
|
|
52
|
+
delete: (key: string) => Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
export declare const isRefusal: (value: SpaceResolution | SpaceRefusal) => value is SpaceRefusal;
|
|
55
|
+
/** A resolver's refusal, as the one-liner it deserves to be at a call site. */
|
|
56
|
+
export declare const refuse: (code: number, message: string) => SpaceRefusal;
|
|
57
|
+
/**
|
|
58
|
+
* A cache in this process's memory, for a deployment that runs one.
|
|
59
|
+
*
|
|
60
|
+
* Say that out loud before using it: each process keeps its own, so invalidating on one does not invalidate on the
|
|
61
|
+
* others, and a deployment behind more than one replica will serve a stale resolution from the replicas that were
|
|
62
|
+
* not told. That is fine for a single-process server and wrong for a cluster, which wants Redis or nothing.
|
|
63
|
+
*/
|
|
64
|
+
export declare const createMemoryCache: () => SpaceCache;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/adapters/space/types.ts
|
|
2
|
+
var isRefusal = (value) => "refuse" in value;
|
|
3
|
+
/** A resolver's refusal, as the one-liner it deserves to be at a call site. */
|
|
4
|
+
var refuse = (code, message) => ({ refuse: {
|
|
5
|
+
code,
|
|
6
|
+
message
|
|
7
|
+
} });
|
|
8
|
+
/**
|
|
9
|
+
* A cache in this process's memory, for a deployment that runs one.
|
|
10
|
+
*
|
|
11
|
+
* Say that out loud before using it: each process keeps its own, so invalidating on one does not invalidate on the
|
|
12
|
+
* others, and a deployment behind more than one replica will serve a stale resolution from the replicas that were
|
|
13
|
+
* not told. That is fine for a single-process server and wrong for a cluster, which wants Redis or nothing.
|
|
14
|
+
*/
|
|
15
|
+
var createMemoryCache = () => {
|
|
16
|
+
const entries = /* @__PURE__ */ new Map();
|
|
17
|
+
return {
|
|
18
|
+
get: (key) => {
|
|
19
|
+
const entry = entries.get(key);
|
|
20
|
+
if (!entry) return Promise.resolve(void 0);
|
|
21
|
+
if (Date.now() > entry.expiresAt) {
|
|
22
|
+
entries.delete(key);
|
|
23
|
+
return Promise.resolve(void 0);
|
|
24
|
+
}
|
|
25
|
+
return Promise.resolve(entry.value);
|
|
26
|
+
},
|
|
27
|
+
set: (key, value, ttlSeconds) => {
|
|
28
|
+
entries.set(key, {
|
|
29
|
+
value,
|
|
30
|
+
expiresAt: Date.now() + ttlSeconds * 1e3
|
|
31
|
+
});
|
|
32
|
+
return Promise.resolve();
|
|
33
|
+
},
|
|
34
|
+
delete: (key) => {
|
|
35
|
+
entries.delete(key);
|
|
36
|
+
return Promise.resolve();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { createMemoryCache, isRefusal, refuse };
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Authentication and authorization, whole. Import it as `@plitzi/sdk-server/auth`.
|
|
2
|
+
*
|
|
3
|
+
* Everything a deployment needs to answer *who is this* and *may they* — the token kernel, the session cookies,
|
|
4
|
+
* the identity resolver, the RBAC checks, the `/auth` flows, the OAuth providers and the space-token lifecycle.
|
|
5
|
+
* `createAuth` assembles the lot in one call and is what almost every deployment wants; the pieces stay exported
|
|
6
|
+
* for the one that needs to build a half of it itself.
|
|
7
|
+
*
|
|
8
|
+
* This used to live in `@plitzi/sdk-server/kernel`, next to the HTTP dispatcher. Two unrelated surfaces under one
|
|
9
|
+
* name that named neither of them: a deployment wiring up sessions had no reason to read about stages, and
|
|
10
|
+
* `@plitzi/sdk-mcp`, which wants the dispatcher and no auth at all, had to import from the same place. `/kernel`
|
|
11
|
+
* is now the HTTP kernel and nothing else.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createAuth } from '@plitzi/sdk-server/auth';
|
|
15
|
+
* import { createServer } from '@plitzi/sdk-server';
|
|
16
|
+
*
|
|
17
|
+
* const auth = createAuth({ tokens: { secret, issuer }, adapters: myAccountStore });
|
|
18
|
+
* const server = createServer({ adapters: space, auth });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* A deployment with no account store of its own can have one: `@plitzi/sdk-server/mysql` brings the tables and
|
|
22
|
+
* every adapter below already implemented. */
|
|
23
|
+
export { createAuth } from './core/auth/createAuth';
|
|
24
|
+
export { createAuthApi } from './core/auth/api';
|
|
25
|
+
export { createCsrf, csrfFailureMessage } from './core/auth/csrf';
|
|
26
|
+
export { createAuthorizer, checkPermission, checkSpaceAccess, requirementFor } from './core/auth/authorize';
|
|
27
|
+
export { createCarriers, presentedOrigin } from './core/auth/credentials';
|
|
28
|
+
export { ANY_DOMAIN, corsOrigins, domainAllowed, frameAncestors, hostnameOf, normalizeDomain } from './core/auth/domains';
|
|
29
|
+
export { createIdentity } from './core/auth/identity';
|
|
30
|
+
export { generateToken, hashPassword, verifyPassword } from './core/auth/passwords';
|
|
31
|
+
export { BUILT_IN_PROVIDERS, OAuthFailure, createSocialAuth, requestProfileJson } from './core/auth/oauth';
|
|
32
|
+
export { createRedirectPolicy } from './core/auth/redirects';
|
|
33
|
+
export type { RedirectPolicyConfig } from './core/auth/redirects';
|
|
34
|
+
export { applySessionOutcome, authPolicyRules, authRoutes } from './core/auth/routes';
|
|
35
|
+
export { appendCookies, clearFlowCookie, clearSessionCookies, createSessionCookies, isLocalHost, readFlowCookie, readRefreshToken, readSessionToken, sessionCookieParams, sessionHintValue, writeFlowCookie, writeSessionCookies } from './core/auth/session';
|
|
36
|
+
export { createMemoryRateLimit } from './core/auth/throttle';
|
|
37
|
+
export { createSpaceTokenApi } from './core/auth/spaceTokens';
|
|
38
|
+
export { SCOPES, authFailureMessage, createTokens, userIdOf } from './core/auth/tokens';
|
|
39
|
+
export { generateRecoveryCodes, generateTotpSecret, normalizeRecoveryCode, randomCode, totpCode, totpUri, verifyTotp } from './core/auth/totp';
|
|
40
|
+
export type { Auth, AuthConfig } from './core/auth/createAuth';
|
|
41
|
+
export type { AccountAccess, AccountAdapters, AccountQuery, AccountRecord, AccountStatus, AuthApi, AuthApiConfig, AuthOutcome, ExchangeResult, MfaRecord, PasswordPolicy, SecurityEvent, SessionClient, SessionContext, SessionSummary, ThrottleAttempt, ThrottledAction } from './core/auth/api';
|
|
42
|
+
export type { AuthPolicy, AuthorizeResult, Authorizer, MembershipFacts, PathMatcher, PermissionCheck, Requirement, SpaceAccessCheck } from './core/auth/authorize';
|
|
43
|
+
export type { CredentialCarrier } from './core/auth/credentials';
|
|
44
|
+
export type { Csrf, CsrfCarrier, CsrfConfig, CsrfFailure, CsrfResult, CsrfSubject } from './core/auth/csrf';
|
|
45
|
+
export type { Actor, ActorResult, Grant, GrantOptions, GrantResult, Identity, IdentityAdapters, IdentityConfig, SpaceMembership, StoredSpaceToken } from './core/auth/identity';
|
|
46
|
+
export type { CompletedFlow, OAuthFailureReason, OAuthProfile, OAuthProvider, OAuthProviderConfig, SocialAuth, SocialAuthAdapters, SocialAuthConfig, StartedFlow } from './core/auth/oauth';
|
|
47
|
+
export type { AuthRequest, AuthRoute } from './core/auth/routes';
|
|
48
|
+
export type { CookieCarrier, CookieSink, SessionCookieParams, SessionCookies } from './core/auth/session';
|
|
49
|
+
export type { SpaceTokenAdapters, SpaceTokenApi, SpaceTokenContext, SpaceTokenOutcome, SpaceTokenRecord, SpaceTokenSummary } from './core/auth/spaceTokens';
|
|
50
|
+
export type { AuthFailure, MfaChallengePayload, RefreshTokenPayload, SpaceScope, SpaceTokenOptions, SpaceTokenPayload, TokenConfig, TokenScope, Tokens, UserTokenOptions, UserTokenPayload, VerifyResult, WidgetTokenPayload } from './core/auth/tokens';
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { appendCookies, clearFlowCookie, clearSessionCookies, createSessionCookies, isLocalHost, readFlowCookie, readRefreshToken, readSessionToken, sessionCookieParams, sessionHintValue, writeFlowCookie, writeSessionCookies } from "./core/auth/session.js";
|
|
2
|
+
import { ANY_DOMAIN, corsOrigins, domainAllowed, frameAncestors, hostnameOf, normalizeDomain } from "./core/auth/domains.js";
|
|
3
|
+
import { checkPermission, checkSpaceAccess, createAuthorizer, requirementFor } from "./core/auth/authorize.js";
|
|
4
|
+
import { generateToken, hashPassword, verifyPassword } from "./core/auth/passwords.js";
|
|
5
|
+
import { createMemoryRateLimit } from "./core/auth/throttle.js";
|
|
6
|
+
import { SCOPES, authFailureMessage, createTokens, userIdOf } from "./core/auth/tokens.js";
|
|
7
|
+
import { generateRecoveryCodes, generateTotpSecret, normalizeRecoveryCode, randomCode, totpCode, totpUri, verifyTotp } from "./core/auth/totp.js";
|
|
8
|
+
import { createAuthApi } from "./core/auth/api.js";
|
|
9
|
+
import { createCarriers, presentedOrigin } from "./core/auth/credentials.js";
|
|
10
|
+
import { createCsrf, csrfFailureMessage } from "./core/auth/csrf.js";
|
|
11
|
+
import { createIdentity } from "./core/auth/identity.js";
|
|
12
|
+
import { applySessionOutcome, authPolicyRules, authRoutes } from "./core/auth/routes.js";
|
|
13
|
+
import { createAuth } from "./core/auth/createAuth.js";
|
|
14
|
+
import { OAuthFailure } from "./core/auth/oauth/types.js";
|
|
15
|
+
import { requestProfileJson } from "./core/auth/oauth/client.js";
|
|
16
|
+
import { createRedirectPolicy } from "./core/auth/redirects.js";
|
|
17
|
+
import { BUILT_IN_PROVIDERS, createSocialAuth } from "./core/auth/oauth/index.js";
|
|
18
|
+
import { createSpaceTokenApi } from "./core/auth/spaceTokens.js";
|
|
19
|
+
export { ANY_DOMAIN, BUILT_IN_PROVIDERS, OAuthFailure, SCOPES, appendCookies, applySessionOutcome, authFailureMessage, authPolicyRules, authRoutes, checkPermission, checkSpaceAccess, clearFlowCookie, clearSessionCookies, corsOrigins, createAuth, createAuthApi, createAuthorizer, createCarriers, createCsrf, createIdentity, createMemoryRateLimit, createRedirectPolicy, createSessionCookies, createSocialAuth, createSpaceTokenApi, createTokens, csrfFailureMessage, domainAllowed, frameAncestors, generateRecoveryCodes, generateToken, generateTotpSecret, hashPassword, hostnameOf, isLocalHost, normalizeDomain, normalizeRecoveryCode, presentedOrigin, randomCode, readFlowCookie, readRefreshToken, readSessionToken, requestProfileJson, requirementFor, sessionCookieParams, sessionHintValue, totpCode, totpUri, userIdOf, verifyPassword, verifyTotp, writeFlowCookie, writeSessionCookies };
|