sst 3.0.13 → 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.js +19 -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.js
CHANGED
|
@@ -52,12 +52,20 @@ export function AuthHandler(input) {
|
|
|
52
52
|
}
|
|
53
53
|
const options = {
|
|
54
54
|
signing: {
|
|
55
|
-
privateKey: () => importPKCS8(
|
|
56
|
-
|
|
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"),
|
|
57
61
|
},
|
|
58
62
|
encryption: {
|
|
59
|
-
privateKey: () => importPKCS8(
|
|
60
|
-
|
|
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"),
|
|
61
69
|
},
|
|
62
70
|
algorithm: "RS512",
|
|
63
71
|
async success(ctx, properties) {
|
|
@@ -121,7 +129,7 @@ export function AuthHandler(input) {
|
|
|
121
129
|
});
|
|
122
130
|
},
|
|
123
131
|
};
|
|
124
|
-
app.
|
|
132
|
+
app.post("/token", async (c) => {
|
|
125
133
|
console.log("token request");
|
|
126
134
|
const form = await c.req.formData();
|
|
127
135
|
if (form.get("grant_type") !== "authorization_code") {
|
|
@@ -152,6 +160,7 @@ export function AuthHandler(input) {
|
|
|
152
160
|
const response_type = c.req.query("response_type") || getCookie(c, "response_type");
|
|
153
161
|
const redirect_uri = c.req.query("redirect_uri") || getCookie(c, "redirect_uri");
|
|
154
162
|
const state = c.req.query("state") || getCookie(c, "state");
|
|
163
|
+
const client_id = c.req.query("client_id") || getCookie(c, "client_id");
|
|
155
164
|
if (!provider) {
|
|
156
165
|
c.status(400);
|
|
157
166
|
return c.text("Missing provider");
|
|
@@ -164,10 +173,15 @@ export function AuthHandler(input) {
|
|
|
164
173
|
c.status(400);
|
|
165
174
|
return c.text("Missing response_type");
|
|
166
175
|
}
|
|
176
|
+
if (!client_id) {
|
|
177
|
+
c.status(400);
|
|
178
|
+
return c.text("Missing client_id");
|
|
179
|
+
}
|
|
167
180
|
options.cookie(c, "provider", provider, 60 * 10);
|
|
168
181
|
options.cookie(c, "response_type", response_type, 60 * 10);
|
|
169
182
|
options.cookie(c, "redirect_uri", redirect_uri, 60 * 10);
|
|
170
183
|
options.cookie(c, "state", state || "", 60 * 10);
|
|
184
|
+
options.cookie(c, "client_id", client_id || "", 60 * 10);
|
|
171
185
|
if (input.callbacks.auth.start) {
|
|
172
186
|
await input.callbacks.auth.start(c.req.raw);
|
|
173
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
|
}));
|