sst 3.0.12 → 3.0.14
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/auth/adapter/oauth.js +1 -1
- package/dist/auth/adapter/oidc.js +2 -2
- package/dist/auth/handler.d.ts +1 -0
- package/dist/auth/handler.js +21 -5
- package/dist/auth/session.js +3 -1
- package/dist/resource.d.ts +4 -1
- package/dist/resource.js +8 -0
- package/dist/vector-client.js +3 -0
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ export const OauthAdapter =
|
|
|
8
8
|
(config) => {
|
|
9
9
|
return async function (routes, ctx) {
|
|
10
10
|
function getClient(c) {
|
|
11
|
-
const callback = c.req.url.replace(/authorize
|
|
11
|
+
const callback = c.req.url.replace(/authorize\/.*$/, "callback");
|
|
12
12
|
return [
|
|
13
13
|
callback,
|
|
14
14
|
new config.issuer.Client({
|
|
@@ -3,7 +3,7 @@ import { getCookie } from "hono/cookie";
|
|
|
3
3
|
export const OidcAdapter = /* @__PURE__ */ (config) => {
|
|
4
4
|
return async function (routes, ctx) {
|
|
5
5
|
routes.get("/authorize", async (c) => {
|
|
6
|
-
const callback = c.req.url.replace(/authorize
|
|
6
|
+
const callback = c.req.url.replace(/authorize\/.*$/, "callback");
|
|
7
7
|
const client = new config.issuer.Client({
|
|
8
8
|
client_id: config.clientID,
|
|
9
9
|
redirect_uris: [callback],
|
|
@@ -23,7 +23,7 @@ export const OidcAdapter = /* @__PURE__ */ (config) => {
|
|
|
23
23
|
return c.redirect(url);
|
|
24
24
|
});
|
|
25
25
|
routes.post("/callback", async (c) => {
|
|
26
|
-
const callback = c.req.url.replace(/authorize
|
|
26
|
+
const callback = c.req.url.replace(/authorize\/.*$/, "callback");
|
|
27
27
|
const client = new config.issuer.Client({
|
|
28
28
|
client_id: config.clientID,
|
|
29
29
|
redirect_uris: [callback],
|
package/dist/auth/handler.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare class InvalidSessionError extends Error {
|
|
|
31
31
|
export type Prettify<T> = {
|
|
32
32
|
[K in keyof T]: T[K];
|
|
33
33
|
} & {};
|
|
34
|
+
export declare const aws: <E extends import("hono").Env = import("hono").Env, S extends import("hono").Schema = {}, BasePath extends string = "/">(app: import("hono").Hono<E, S, BasePath>) => (event: import("hono/aws-lambda").LambdaEvent, lambdaContext?: import("hono/aws-lambda").LambdaContext | undefined) => Promise<import("hono/aws-lambda").APIGatewayProxyResult>;
|
|
34
35
|
export declare function AuthHandler<Providers extends Record<string, Adapter<any>>, Sessions extends SessionBuilder = SessionBuilder, Result = {
|
|
35
36
|
[key in keyof Providers]: Prettify<{
|
|
36
37
|
provider: key;
|
package/dist/auth/handler.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SignJWT, importPKCS8, importSPKI, jwtVerify } from "jose";
|
|
2
2
|
import { Hono } from "hono/tiny";
|
|
3
|
+
import { handle as awsHandle } from "hono/aws-lambda";
|
|
3
4
|
import { deleteCookie, getCookie, setCookie } from "hono/cookie";
|
|
4
5
|
export class UnknownProviderError extends Error {
|
|
5
6
|
provider;
|
|
@@ -36,6 +37,7 @@ export class InvalidSessionError extends Error {
|
|
|
36
37
|
}
|
|
37
38
|
import process from "node:process";
|
|
38
39
|
import { Resource } from "../resource.js";
|
|
40
|
+
export const aws = awsHandle;
|
|
39
41
|
export function AuthHandler(input) {
|
|
40
42
|
const app = new Hono();
|
|
41
43
|
if (!input.callbacks.auth.error) {
|
|
@@ -50,12 +52,20 @@ export function AuthHandler(input) {
|
|
|
50
52
|
}
|
|
51
53
|
const options = {
|
|
52
54
|
signing: {
|
|
53
|
-
privateKey: () => importPKCS8(
|
|
54
|
-
|
|
55
|
+
privateKey: () => importPKCS8(
|
|
56
|
+
// @ts-expect-error
|
|
57
|
+
process.env.AUTH_PRIVATE_KEY || Resource.AUTH_PRIVATE_KEY, "RS512"),
|
|
58
|
+
publicKey: () => importSPKI(
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
process.env.AUTH_PUBLIC_KEY || Resource.AUTH_PUBLIC_KEY, "RS512"),
|
|
55
61
|
},
|
|
56
62
|
encryption: {
|
|
57
|
-
privateKey: () => importPKCS8(
|
|
58
|
-
|
|
63
|
+
privateKey: () => importPKCS8(
|
|
64
|
+
// @ts-expect-error
|
|
65
|
+
process.env.AUTH_PRIVATE_KEY || Resource.AUTH_PRIVATE_KEY, "RSA-OAEP-512"),
|
|
66
|
+
publicKey: () => importSPKI(
|
|
67
|
+
// @ts-expect-error
|
|
68
|
+
process.env.AUTH_PUBLIC_KEY || Resource.AUTH_PUBLIC_KEY, "RSA-OAEP-512"),
|
|
59
69
|
},
|
|
60
70
|
algorithm: "RS512",
|
|
61
71
|
async success(ctx, properties) {
|
|
@@ -119,7 +129,7 @@ export function AuthHandler(input) {
|
|
|
119
129
|
});
|
|
120
130
|
},
|
|
121
131
|
};
|
|
122
|
-
app.
|
|
132
|
+
app.post("/token", async (c) => {
|
|
123
133
|
console.log("token request");
|
|
124
134
|
const form = await c.req.formData();
|
|
125
135
|
if (form.get("grant_type") !== "authorization_code") {
|
|
@@ -150,6 +160,7 @@ export function AuthHandler(input) {
|
|
|
150
160
|
const response_type = c.req.query("response_type") || getCookie(c, "response_type");
|
|
151
161
|
const redirect_uri = c.req.query("redirect_uri") || getCookie(c, "redirect_uri");
|
|
152
162
|
const state = c.req.query("state") || getCookie(c, "state");
|
|
163
|
+
const client_id = c.req.query("client_id") || getCookie(c, "client_id");
|
|
153
164
|
if (!provider) {
|
|
154
165
|
c.status(400);
|
|
155
166
|
return c.text("Missing provider");
|
|
@@ -162,10 +173,15 @@ export function AuthHandler(input) {
|
|
|
162
173
|
c.status(400);
|
|
163
174
|
return c.text("Missing response_type");
|
|
164
175
|
}
|
|
176
|
+
if (!client_id) {
|
|
177
|
+
c.status(400);
|
|
178
|
+
return c.text("Missing client_id");
|
|
179
|
+
}
|
|
165
180
|
options.cookie(c, "provider", provider, 60 * 10);
|
|
166
181
|
options.cookie(c, "response_type", response_type, 60 * 10);
|
|
167
182
|
options.cookie(c, "redirect_uri", redirect_uri, 60 * 10);
|
|
168
183
|
options.cookie(c, "state", state || "", 60 * 10);
|
|
184
|
+
options.cookie(c, "client_id", client_id || "", 60 * 10);
|
|
169
185
|
if (input.callbacks.auth.start) {
|
|
170
186
|
await input.callbacks.auth.start(c.req.raw);
|
|
171
187
|
}
|
package/dist/auth/session.js
CHANGED
|
@@ -13,7 +13,9 @@ export function createSessionBuilder() {
|
|
|
13
13
|
return result.payload;
|
|
14
14
|
},
|
|
15
15
|
async create(session) {
|
|
16
|
-
const privateKey = await importPKCS8(
|
|
16
|
+
const privateKey = await importPKCS8(
|
|
17
|
+
// @ts-expect-error
|
|
18
|
+
process.env.AUTH_PRIVATE_KEY || Resource.AUTH_PRIVATE_KEY, "RS512");
|
|
17
19
|
const token = await new SignJWT(session)
|
|
18
20
|
.setProtectedHeader({ alg: "RS512" })
|
|
19
21
|
.setExpirationTime("1yr")
|
package/dist/resource.d.ts
CHANGED
package/dist/resource.js
CHANGED
|
@@ -20,6 +20,14 @@ export function fromCloudflareEnv(input) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
export function wrapCloudflareHandler(handler) {
|
|
23
|
+
if (typeof handler === "function" && handler.hasOwnProperty("prototype")) {
|
|
24
|
+
return class extends handler {
|
|
25
|
+
constructor(ctx, env) {
|
|
26
|
+
fromCloudflareEnv(env);
|
|
27
|
+
super(ctx, env);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
23
31
|
function wrap(fn) {
|
|
24
32
|
return function (req, env, ...rest) {
|
|
25
33
|
fromCloudflareEnv(env);
|
package/dist/vector-client.js
CHANGED
|
@@ -5,6 +5,7 @@ export function VectorClient(name) {
|
|
|
5
5
|
return {
|
|
6
6
|
ingest: async (event) => {
|
|
7
7
|
const ret = await lambda.send(new InvokeCommand({
|
|
8
|
+
// @ts-expect-error
|
|
8
9
|
FunctionName: Resource[name].ingestor,
|
|
9
10
|
Payload: JSON.stringify(event),
|
|
10
11
|
}));
|
|
@@ -12,6 +13,7 @@ export function VectorClient(name) {
|
|
|
12
13
|
},
|
|
13
14
|
retrieve: async (event) => {
|
|
14
15
|
const ret = await lambda.send(new InvokeCommand({
|
|
16
|
+
// @ts-expect-error
|
|
15
17
|
FunctionName: Resource[name].retriever,
|
|
16
18
|
Payload: JSON.stringify(event),
|
|
17
19
|
}));
|
|
@@ -19,6 +21,7 @@ export function VectorClient(name) {
|
|
|
19
21
|
},
|
|
20
22
|
remove: async (event) => {
|
|
21
23
|
const ret = await lambda.send(new InvokeCommand({
|
|
24
|
+
// @ts-expect-error
|
|
22
25
|
FunctionName: Resource[name].remover,
|
|
23
26
|
Payload: JSON.stringify(event),
|
|
24
27
|
}));
|