sst 2.43.1 → 2.43.2
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/node/auth/session.d.ts +13 -0
- package/node/auth/session.js +26 -5
- package/node/future/auth/index.d.ts +1 -3
- package/node/future/auth/index.js +1 -2
- package/node/future/auth/proxy.d.ts +3 -0
- package/node/future/auth/proxy.js +2 -0
- package/node/future/auth/session.js +1 -1
- package/package.json +2 -2
- package/runtime/handlers/node.js +1 -0
package/node/auth/session.d.ts
CHANGED
|
@@ -28,6 +28,18 @@ declare function create<T extends keyof SessionTypes>(input: {
|
|
|
28
28
|
properties: SessionTypes[T];
|
|
29
29
|
options?: Partial<SignerOptions>;
|
|
30
30
|
}): string;
|
|
31
|
+
/**
|
|
32
|
+
* Verifies a session token and returns the session data
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```js
|
|
36
|
+
* Session.verify()
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function verify<T = SessionValue>(token: string): T | {
|
|
40
|
+
type: string;
|
|
41
|
+
properties: {};
|
|
42
|
+
};
|
|
31
43
|
/**
|
|
32
44
|
* Returns a 302 redirect with an auth-token cookie set with the provided session information
|
|
33
45
|
*
|
|
@@ -70,6 +82,7 @@ export declare function parameter<T extends keyof SessionTypes>(input: {
|
|
|
70
82
|
}): APIGatewayProxyStructuredResultV2;
|
|
71
83
|
export declare const Session: {
|
|
72
84
|
create: typeof create;
|
|
85
|
+
verify: typeof verify;
|
|
73
86
|
cookie: typeof cookie;
|
|
74
87
|
parameter: typeof parameter;
|
|
75
88
|
};
|
package/node/auth/session.js
CHANGED
|
@@ -23,11 +23,7 @@ const SessionMemo = /* @__PURE__ */ Context.memo(() => {
|
|
|
23
23
|
if (wsProtocol)
|
|
24
24
|
token = wsProtocol.split(",")[0].trim();
|
|
25
25
|
if (token) {
|
|
26
|
-
|
|
27
|
-
algorithms: ["RS512"],
|
|
28
|
-
key: getPublicKey(),
|
|
29
|
-
})(token);
|
|
30
|
-
return jwt;
|
|
26
|
+
return Session.verify(token);
|
|
31
27
|
}
|
|
32
28
|
return {
|
|
33
29
|
type: "public",
|
|
@@ -64,6 +60,30 @@ function create(input) {
|
|
|
64
60
|
});
|
|
65
61
|
return token;
|
|
66
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Verifies a session token and returns the session data
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```js
|
|
68
|
+
* Session.verify()
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
function verify(token) {
|
|
72
|
+
if (token) {
|
|
73
|
+
try {
|
|
74
|
+
const jwt = createVerifier({
|
|
75
|
+
algorithms: ["RS512"],
|
|
76
|
+
key: getPublicKey(),
|
|
77
|
+
})(token);
|
|
78
|
+
return jwt;
|
|
79
|
+
}
|
|
80
|
+
catch (e) { }
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
type: "public",
|
|
84
|
+
properties: {},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
67
87
|
/**
|
|
68
88
|
* Returns a 302 redirect with an auth-token cookie set with the provided session information
|
|
69
89
|
*
|
|
@@ -116,6 +136,7 @@ export function parameter(input) {
|
|
|
116
136
|
}
|
|
117
137
|
export const Session = {
|
|
118
138
|
create,
|
|
139
|
+
verify,
|
|
119
140
|
cookie,
|
|
120
141
|
parameter,
|
|
121
142
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSigner, createVerifier } from "fast-jwt";
|
|
2
2
|
import { Context } from "../../../context/context2.js";
|
|
3
3
|
import { useCookie, useHeader } from "../../api/index.js";
|
|
4
|
-
import { Auth } from "
|
|
4
|
+
import { Auth } from "./proxy.js";
|
|
5
5
|
import { Config } from "../../config/index.js";
|
|
6
6
|
import { useContextType } from "../../../context/handler.js";
|
|
7
7
|
const SessionMemo = /* @__PURE__ */ Context.memo(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.43.
|
|
4
|
+
"version": "2.43.2",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@types/ws": "^8.5.3",
|
|
119
119
|
"@types/yargs": "^17.0.13",
|
|
120
120
|
"archiver": "^5.3.1",
|
|
121
|
-
"astro-sst": "2.43.
|
|
121
|
+
"astro-sst": "2.43.2",
|
|
122
122
|
"async": "^3.2.4",
|
|
123
123
|
"tsx": "^3.12.1",
|
|
124
124
|
"typescript": "^5.2.2",
|