@teamscala/service-boot 0.23.529 → 0.23.531
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/package.json +4 -1
- package/src/attach-proposal-accept.ts +1 -1
- package/src/attach-proposal-magic.ts +1 -1
- package/src/auth/sign-out.ts +1 -1
- package/src/auth-gate.ts +2 -2
- package/src/content-gate/config-types.ts +1 -1
- package/src/gpt-gate.ts +1 -1
- package/src/mount-orpc-router.ts +34 -0
- package/src/orpc-openapi-document.ts +1 -1
- package/src/proposal-gate.ts +1 -1
- package/src/quiz-gate.ts +1 -1
package/package.json
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
"edit": "edit src/ — dependencies and exports derive from imports; everything else preserved"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@orpc/openapi": "*",
|
|
8
9
|
"@orpc/server": "*",
|
|
9
10
|
"@teamscala/agreement-generation": "*",
|
|
10
11
|
"@teamscala/auth": "*",
|
|
12
|
+
"@teamscala/auth-factory": "*",
|
|
11
13
|
"@teamscala/cache": "*",
|
|
14
|
+
"@teamscala/content-gate-token": "*",
|
|
12
15
|
"@teamscala/db": "*",
|
|
13
16
|
"@teamscala/db-validation": "*",
|
|
14
17
|
"@teamscala/document-signing": "*",
|
|
@@ -290,5 +293,5 @@
|
|
|
290
293
|
"repository": "https://github.com/teamgbg/service-boot",
|
|
291
294
|
"sideEffects": false,
|
|
292
295
|
"type": "module",
|
|
293
|
-
"version": "0.23.
|
|
296
|
+
"version": "0.23.531"
|
|
294
297
|
}
|
|
@@ -7,7 +7,7 @@ import type { Hono } from "hono";
|
|
|
7
7
|
import { getAppLogger } from "@teamscala/logger/app-loggers";
|
|
8
8
|
import { signAgreementAccessToken } from "@teamscala/document-signing/agreement-access-token";
|
|
9
9
|
import { parseCookie } from "./content-gate/parse-cookie.ts";
|
|
10
|
-
import { verifyAccessToken } from "@teamscala/
|
|
10
|
+
import { verifyAccessToken } from "@teamscala/content-gate-token";
|
|
11
11
|
import { agTtlMs } from "./gate-ttls.ts";
|
|
12
12
|
import { createAgreementFromProposal } from "@teamscala/agreement-generation/create-agreement-from-proposal";
|
|
13
13
|
import { getCookieDomain } from "@teamscala/db/registry/cookie-domain";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { Hono } from "hono";
|
|
7
7
|
import { getAppLogger } from "@teamscala/logger/app-loggers";
|
|
8
|
-
import { verifyAccessToken } from "@teamscala/
|
|
8
|
+
import { verifyAccessToken } from "@teamscala/content-gate-token";
|
|
9
9
|
import { propTtlMs } from "./gate-ttls.ts";
|
|
10
10
|
|
|
11
11
|
const PROP_COOKIE = "prop_token";
|
package/src/auth/sign-out.ts
CHANGED
|
@@ -20,7 +20,7 @@ export async function signOut(context: SignOutContext): Promise<SignOutResult> {
|
|
|
20
20
|
// call, so a per-request registration would rebuild the whole better-auth
|
|
21
21
|
// module graph on each sign-out. getAuth() throws if no factory is
|
|
22
22
|
// registered, which the authed middleware has already excluded.
|
|
23
|
-
const { getAuth } = await import("@teamscala/auth/auth-registry.ts");
|
|
23
|
+
const { getAuth } = await import("@teamscala/auth-factory/auth-registry.ts");
|
|
24
24
|
const auth = await getAuth();
|
|
25
25
|
const headers = context?.headers ?? new Headers();
|
|
26
26
|
|
package/src/auth-gate.ts
CHANGED
|
@@ -75,9 +75,9 @@ export async function attachAuthGate(
|
|
|
75
75
|
// never pulled from a singleton inside a per-request handler.
|
|
76
76
|
const { prisma: gatePrisma } = initGateDependencies();
|
|
77
77
|
const { registerAuthFactory, getAuth } = await import(
|
|
78
|
-
"@teamscala/auth/auth-registry.ts"
|
|
78
|
+
"@teamscala/auth-factory/auth-registry.ts"
|
|
79
79
|
);
|
|
80
|
-
const { createAuth } = await import("@teamscala/auth/auth-factory.ts");
|
|
80
|
+
const { createAuth } = await import("@teamscala/auth-factory/auth-factory.ts");
|
|
81
81
|
registerAuthFactory(createAuth);
|
|
82
82
|
|
|
83
83
|
// Bridge the SAME factory into @teamscala/orpc's configure surface so the ORPC
|
package/src/gpt-gate.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { AccessConfig, ContentGateConfig } from "./content-gate/config-types.ts";
|
|
7
|
-
import { signAccessToken, verifyAccessTokenIdentity } from "@teamscala/
|
|
7
|
+
import { signAccessToken, verifyAccessTokenIdentity } from "@teamscala/content-gate-token";
|
|
8
8
|
import { gptTtlMs } from "./gate-ttls.ts";
|
|
9
9
|
|
|
10
10
|
const GPT_COOKIE = "gpt_token";
|
package/src/mount-orpc-router.ts
CHANGED
|
@@ -89,6 +89,10 @@ export async function mountOrpcRouter(
|
|
|
89
89
|
const handler = new RPCHandler(router as never, {
|
|
90
90
|
interceptors: [procedureErrorReportInterceptor()] as never,
|
|
91
91
|
});
|
|
92
|
+
const { OpenAPIHandler } = await import("@orpc/openapi/fetch");
|
|
93
|
+
const openApiHandler = new OpenAPIHandler(router as never, {
|
|
94
|
+
interceptors: [procedureErrorReportInterceptor()] as never,
|
|
95
|
+
});
|
|
92
96
|
|
|
93
97
|
const { getPrisma: getConfiguredPrisma } = await import(
|
|
94
98
|
"@teamscala/orpc/configure"
|
|
@@ -146,6 +150,21 @@ export async function mountOrpcRouter(
|
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
const resolveUser = async (headers: Headers) => {
|
|
153
|
+
if (
|
|
154
|
+
openApiContractAuthorised({
|
|
155
|
+
authorization: headers.get("authorization"),
|
|
156
|
+
key: process.env.SCALA_DEV_KEY,
|
|
157
|
+
forwardedProto: headers.get("x-forwarded-proto"),
|
|
158
|
+
forwardedFor: headers.get("x-forwarded-for"),
|
|
159
|
+
})
|
|
160
|
+
) {
|
|
161
|
+
return {
|
|
162
|
+
id: "service",
|
|
163
|
+
role: "super_admin" as const,
|
|
164
|
+
isSuperAdmin: true,
|
|
165
|
+
organisationId: null,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
149
168
|
if (isLocalhostRequest(headers)) {
|
|
150
169
|
return {
|
|
151
170
|
id: "localhost",
|
|
@@ -196,6 +215,21 @@ export async function mountOrpcRouter(
|
|
|
196
215
|
},
|
|
197
216
|
);
|
|
198
217
|
|
|
218
|
+
app.all(
|
|
219
|
+
"/api/openapi/*",
|
|
220
|
+
bodyLimit({
|
|
221
|
+
maxSize: 10 * 1024 * 1024,
|
|
222
|
+
onError: (c) => c.json({ error: "Request body too large" }, 413),
|
|
223
|
+
}),
|
|
224
|
+
async (c) => {
|
|
225
|
+
const result = await openApiHandler.handle(c.req.raw, {
|
|
226
|
+
prefix: "/api/openapi",
|
|
227
|
+
context: { prisma: getConfiguredPrisma(), db8, headers: c.req.raw.headers, resolveUser },
|
|
228
|
+
});
|
|
229
|
+
return result.matched ? result.response : c.notFound();
|
|
230
|
+
},
|
|
231
|
+
);
|
|
232
|
+
|
|
199
233
|
app.get("/api/rpc/openapi.json", async (c) => {
|
|
200
234
|
const header = (name: string) => c.req.header(name) ?? null;
|
|
201
235
|
if (
|
|
@@ -17,7 +17,7 @@ export function openApiContractOptions(
|
|
|
17
17
|
title: `${serviceSlug} oRPC procedures`,
|
|
18
18
|
servers: [
|
|
19
19
|
{
|
|
20
|
-
url: `${forwardedProto || FALLBACK_PROTO}://${host || FALLBACK_HOST}/api/
|
|
20
|
+
url: `${forwardedProto || FALLBACK_PROTO}://${host || FALLBACK_HOST}/api/openapi`,
|
|
21
21
|
},
|
|
22
22
|
],
|
|
23
23
|
};
|
package/src/proposal-gate.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { AccessConfig, ContentGateConfig } from "./content-gate/config-types.ts";
|
|
7
|
-
import { signAccessToken, verifyAccessToken } from "@teamscala/
|
|
7
|
+
import { signAccessToken, verifyAccessToken } from "@teamscala/content-gate-token";
|
|
8
8
|
import { resolveProposalAuthorizedEmails } from "./proposal-authorized-emails.ts";
|
|
9
9
|
import { propTtlMs } from "./gate-ttls.ts";
|
|
10
10
|
import { getAppLogger } from "@teamscala/logger/app-loggers";
|
package/src/quiz-gate.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { AccessConfig, ContentGateConfig } from "./content-gate/config-types.ts";
|
|
7
|
-
import { signAccessToken, verifyAccessTokenIdentity } from "@teamscala/
|
|
7
|
+
import { signAccessToken, verifyAccessTokenIdentity } from "@teamscala/content-gate-token";
|
|
8
8
|
import { quizTtlMs } from "./gate-ttls.ts";
|
|
9
9
|
|
|
10
10
|
const QUIZ_COOKIE = "quiz_token";
|