sst 4.7.4 → 4.7.5
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/handler.js +1 -1
- package/dist/auth/session.js +1 -1
- package/dist/aws/bus.d.ts +1 -1
- package/dist/aws/bus.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/resource/cloudflare.d.ts +4 -0
- package/dist/resource/cloudflare.js +28 -0
- package/dist/resource/index.d.ts +1 -0
- package/dist/resource/index.js +1 -0
- package/dist/resource/node.d.ts +2 -0
- package/dist/resource/node.js +33 -0
- package/dist/resource/shared.d.ts +10 -0
- package/dist/resource/shared.js +50 -0
- package/dist/resource.d.ts +1 -9
- package/dist/resource.js +1 -96
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.js +1 -1
- package/package.json +19 -9
package/dist/auth/handler.js
CHANGED
|
@@ -36,7 +36,7 @@ export class InvalidSessionError extends Error {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
import process from "node:process";
|
|
39
|
-
import { Resource } from "../resource.js";
|
|
39
|
+
import { Resource } from "../resource/index.js";
|
|
40
40
|
export const aws = awsHandle;
|
|
41
41
|
export function AuthHandler(input) {
|
|
42
42
|
const app = input.basePath ? new Hono().basePath(input.basePath) : new Hono();
|
package/dist/auth/session.js
CHANGED
package/dist/aws/bus.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { aws } from "./client.js";
|
|
2
|
-
import { Resource } from "../resource.js";
|
|
2
|
+
import { Resource } from "../resource/index.js";
|
|
3
3
|
import { event } from "../event/index.js";
|
|
4
4
|
import { EventBridgeEvent, EventBridgeHandler, Context } from "aws-lambda";
|
|
5
5
|
export declare namespace bus {
|
package/dist/aws/bus.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { env } from "cloudflare:workers";
|
|
2
|
+
import { loadFromCloudflareEnv, Resource } from "./shared.js";
|
|
3
|
+
loadFromCloudflareEnv(env);
|
|
4
|
+
export function fromCloudflareEnv(input) {
|
|
5
|
+
loadFromCloudflareEnv(input);
|
|
6
|
+
}
|
|
7
|
+
export function wrapCloudflareHandler(handler) {
|
|
8
|
+
if (typeof handler === "function" && handler.hasOwnProperty("prototype")) {
|
|
9
|
+
return class extends handler {
|
|
10
|
+
constructor(ctx, env) {
|
|
11
|
+
loadFromCloudflareEnv(env);
|
|
12
|
+
super(ctx, env);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function wrap(fn) {
|
|
17
|
+
return function (req, env, ...rest) {
|
|
18
|
+
loadFromCloudflareEnv(env);
|
|
19
|
+
return fn(req, env, ...rest);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const result = {};
|
|
23
|
+
for (const [key, value] of Object.entries(handler)) {
|
|
24
|
+
result[key] = wrap(value);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
export { Resource };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./node.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./node.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { env } from "process";
|
|
4
|
+
import { loadResourceData, loadResourceEnvironment, Resource, } from "./shared.js";
|
|
5
|
+
const environment = {
|
|
6
|
+
...env,
|
|
7
|
+
...globalThis.process?.env,
|
|
8
|
+
};
|
|
9
|
+
loadResourceEnvironment(environment);
|
|
10
|
+
if (environment.SST_RESOURCES_JSON) {
|
|
11
|
+
try {
|
|
12
|
+
loadResourceData(JSON.parse(environment.SST_RESOURCES_JSON));
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
console.error("Failed to parse SST_RESOURCES_JSON:", error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (environment.SST_KEY_FILE && environment.SST_KEY && !globalThis.SST_KEY_FILE_DATA) {
|
|
19
|
+
const key = Buffer.from(environment.SST_KEY, "base64");
|
|
20
|
+
const encryptedData = readFileSync(environment.SST_KEY_FILE);
|
|
21
|
+
const nonce = Buffer.alloc(12, 0);
|
|
22
|
+
const decipher = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
23
|
+
const authTag = encryptedData.subarray(-16);
|
|
24
|
+
const actualCiphertext = encryptedData.subarray(0, -16);
|
|
25
|
+
decipher.setAuthTag(authTag);
|
|
26
|
+
let decrypted = decipher.update(actualCiphertext);
|
|
27
|
+
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
28
|
+
loadResourceData(JSON.parse(decrypted.toString()));
|
|
29
|
+
}
|
|
30
|
+
if (globalThis.SST_KEY_FILE_DATA) {
|
|
31
|
+
loadResourceData(globalThis.SST_KEY_FILE_DATA);
|
|
32
|
+
}
|
|
33
|
+
export { Resource };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Resource {
|
|
2
|
+
App: {
|
|
3
|
+
name: string;
|
|
4
|
+
stage: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export declare function loadResourceEnvironment(input?: Record<string, any>): void;
|
|
8
|
+
export declare function loadResourceData(input?: Record<string, any>): void;
|
|
9
|
+
export declare function loadFromCloudflareEnv(input: any): void;
|
|
10
|
+
export declare const Resource: Resource;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const state = globalThis;
|
|
2
|
+
const raw = (state.__SST_RESOURCE_RAW__ ??= {
|
|
3
|
+
// @ts-expect-error
|
|
4
|
+
...globalThis.$SST_LINKS,
|
|
5
|
+
});
|
|
6
|
+
const environment = (state.__SST_RESOURCE_ENVIRONMENT__ ??= {});
|
|
7
|
+
export function loadResourceEnvironment(input) {
|
|
8
|
+
for (const [key, value] of Object.entries(input ?? {})) {
|
|
9
|
+
if (typeof value === "string") {
|
|
10
|
+
environment[key] = value;
|
|
11
|
+
}
|
|
12
|
+
if (!key.startsWith("SST_RESOURCE_") || !value) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
raw[key.slice("SST_RESOURCE_".length)] = JSON.parse(value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function loadResourceData(input) {
|
|
19
|
+
Object.assign(raw, input ?? {});
|
|
20
|
+
}
|
|
21
|
+
export function loadFromCloudflareEnv(input) {
|
|
22
|
+
for (let [key, value] of Object.entries(input)) {
|
|
23
|
+
if (typeof value === "string") {
|
|
24
|
+
environment[key] = value;
|
|
25
|
+
try {
|
|
26
|
+
value = JSON.parse(value);
|
|
27
|
+
}
|
|
28
|
+
catch { }
|
|
29
|
+
}
|
|
30
|
+
raw[key] = value;
|
|
31
|
+
if (key.startsWith("SST_RESOURCE_")) {
|
|
32
|
+
raw[key.replace("SST_RESOURCE_", "")] = value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const Resource = new Proxy(raw, {
|
|
37
|
+
get(_target, prop) {
|
|
38
|
+
if (prop in raw) {
|
|
39
|
+
return raw[prop];
|
|
40
|
+
}
|
|
41
|
+
if (!environment.SST_RESOURCE_App) {
|
|
42
|
+
throw new Error("It does not look like SST links are active. If this is in local development and you are not starting this process through the multiplexer, wrap your command with `sst dev -- <command>`");
|
|
43
|
+
}
|
|
44
|
+
let msg = `"${prop}" is not linked in your sst.config.ts`;
|
|
45
|
+
if (environment.AWS_LAMBDA_FUNCTION_NAME) {
|
|
46
|
+
msg += ` to ${environment.AWS_LAMBDA_FUNCTION_NAME}`;
|
|
47
|
+
}
|
|
48
|
+
throw new Error(msg);
|
|
49
|
+
},
|
|
50
|
+
});
|
package/dist/resource.d.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
App: {
|
|
3
|
-
name: string;
|
|
4
|
-
stage: string;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export declare function fromCloudflareEnv(input: any): void;
|
|
8
|
-
export declare function wrapCloudflareHandler(handler: any): any;
|
|
9
|
-
export declare const Resource: Resource;
|
|
1
|
+
export * from "./resource/index.js";
|
package/dist/resource.js
CHANGED
|
@@ -1,96 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { readFileSync } from "fs";
|
|
3
|
-
import crypto from "crypto";
|
|
4
|
-
const raw = {
|
|
5
|
-
// @ts-expect-error,
|
|
6
|
-
...globalThis.$SST_LINKS,
|
|
7
|
-
};
|
|
8
|
-
const environment = {
|
|
9
|
-
...env,
|
|
10
|
-
...globalThis.process?.env,
|
|
11
|
-
};
|
|
12
|
-
// Handle consolidated resources JSON (for Windows with many resources)
|
|
13
|
-
if (environment.SST_RESOURCES_JSON) {
|
|
14
|
-
try {
|
|
15
|
-
const allResources = JSON.parse(environment.SST_RESOURCES_JSON);
|
|
16
|
-
Object.assign(raw, allResources);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
console.error("Failed to parse SST_RESOURCES_JSON:", error);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// Handle individual SST_RESOURCE_ environment variables
|
|
23
|
-
for (const [key, value] of Object.entries(environment)) {
|
|
24
|
-
if (key.startsWith("SST_RESOURCE_") && value) {
|
|
25
|
-
raw[key.slice("SST_RESOURCE_".length)] = JSON.parse(value);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// @ts-expect-error
|
|
29
|
-
if (env.SST_KEY_FILE && env.SST_KEY && !globalThis.SST_KEY_FILE_DATA) {
|
|
30
|
-
const key = Buffer.from(env.SST_KEY, "base64");
|
|
31
|
-
const encryptedData = readFileSync(env.SST_KEY_FILE);
|
|
32
|
-
const nonce = Buffer.alloc(12, 0);
|
|
33
|
-
const decipher = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
34
|
-
const authTag = encryptedData.subarray(-16);
|
|
35
|
-
const actualCiphertext = encryptedData.subarray(0, -16);
|
|
36
|
-
decipher.setAuthTag(authTag);
|
|
37
|
-
let decrypted = decipher.update(actualCiphertext);
|
|
38
|
-
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
|
39
|
-
const decryptedData = JSON.parse(decrypted.toString());
|
|
40
|
-
Object.assign(raw, decryptedData);
|
|
41
|
-
}
|
|
42
|
-
// @ts-expect-error
|
|
43
|
-
if (globalThis.SST_KEY_FILE_DATA) {
|
|
44
|
-
// @ts-expect-error
|
|
45
|
-
Object.assign(raw, globalThis.SST_KEY_FILE_DATA);
|
|
46
|
-
}
|
|
47
|
-
export function fromCloudflareEnv(input) {
|
|
48
|
-
for (let [key, value] of Object.entries(input)) {
|
|
49
|
-
if (typeof value === "string") {
|
|
50
|
-
try {
|
|
51
|
-
value = JSON.parse(value);
|
|
52
|
-
}
|
|
53
|
-
catch { }
|
|
54
|
-
}
|
|
55
|
-
raw[key] = value;
|
|
56
|
-
if (key.startsWith("SST_RESOURCE_")) {
|
|
57
|
-
raw[key.replace("SST_RESOURCE_", "")] = value;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export function wrapCloudflareHandler(handler) {
|
|
62
|
-
if (typeof handler === "function" && handler.hasOwnProperty("prototype")) {
|
|
63
|
-
return class extends handler {
|
|
64
|
-
constructor(ctx, env) {
|
|
65
|
-
fromCloudflareEnv(env);
|
|
66
|
-
super(ctx, env);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function wrap(fn) {
|
|
71
|
-
return function (req, env, ...rest) {
|
|
72
|
-
fromCloudflareEnv(env);
|
|
73
|
-
return fn(req, env, ...rest);
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const result = {};
|
|
77
|
-
for (const [key, value] of Object.entries(handler)) {
|
|
78
|
-
result[key] = wrap(value);
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
export const Resource = new Proxy(raw, {
|
|
83
|
-
get(_target, prop) {
|
|
84
|
-
if (prop in raw) {
|
|
85
|
-
return raw[prop];
|
|
86
|
-
}
|
|
87
|
-
if (!env.SST_RESOURCE_App) {
|
|
88
|
-
throw new Error("It does not look like SST links are active. If this is in local development and you are not starting this process through the multiplexer, wrap your command with `sst dev -- <command>`");
|
|
89
|
-
}
|
|
90
|
-
let msg = `"${prop}" is not linked in your sst.config.ts`;
|
|
91
|
-
if (env.AWS_LAMBDA_FUNCTION_NAME) {
|
|
92
|
-
msg += ` to ${env.AWS_LAMBDA_FUNCTION_NAME}`;
|
|
93
|
-
}
|
|
94
|
-
throw new Error(msg);
|
|
95
|
-
},
|
|
96
|
-
});
|
|
1
|
+
export * from "./resource/index.js";
|
package/dist/vector/index.d.ts
CHANGED
package/dist/vector/index.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "sst",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
-
"version": "4.7.
|
|
6
|
+
"version": "4.7.5",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -12,6 +12,16 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": "./dist/index.js",
|
|
15
|
+
"./resource": {
|
|
16
|
+
"types": "./dist/resource/index.d.ts",
|
|
17
|
+
"workerd": "./dist/resource/cloudflare.js",
|
|
18
|
+
"worker": "./dist/resource/cloudflare.js",
|
|
19
|
+
"default": "./dist/resource/node.js"
|
|
20
|
+
},
|
|
21
|
+
"./resource/cloudflare": {
|
|
22
|
+
"types": "./dist/resource/cloudflare.d.ts",
|
|
23
|
+
"default": "./dist/resource/cloudflare.js"
|
|
24
|
+
},
|
|
15
25
|
"./auth": "./dist/auth/index.js",
|
|
16
26
|
"./auth/adapter": "./dist/auth/adapter/index.js",
|
|
17
27
|
"./event": "./dist/event/index.js",
|
|
@@ -45,14 +55,14 @@
|
|
|
45
55
|
"sst": "./bin/sst.mjs"
|
|
46
56
|
},
|
|
47
57
|
"optionalDependencies": {
|
|
48
|
-
"sst-linux-x64": "4.7.
|
|
49
|
-
"sst-linux-x86": "4.7.
|
|
50
|
-
"sst-darwin-x64": "4.7.
|
|
51
|
-
"sst-linux-arm64": "4.7.
|
|
52
|
-
"sst-darwin-arm64": "4.7.
|
|
53
|
-
"sst-win32-x64": "4.7.
|
|
54
|
-
"sst-win32-x86": "4.7.
|
|
55
|
-
"sst-win32-arm64": "4.7.
|
|
58
|
+
"sst-linux-x64": "4.7.5",
|
|
59
|
+
"sst-linux-x86": "4.7.5",
|
|
60
|
+
"sst-darwin-x64": "4.7.5",
|
|
61
|
+
"sst-linux-arm64": "4.7.5",
|
|
62
|
+
"sst-darwin-arm64": "4.7.5",
|
|
63
|
+
"sst-win32-x64": "4.7.5",
|
|
64
|
+
"sst-win32-x86": "4.7.5",
|
|
65
|
+
"sst-win32-arm64": "4.7.5"
|
|
56
66
|
},
|
|
57
67
|
"dependencies": {
|
|
58
68
|
"@aws/durable-execution-sdk-js": "1.0.2",
|