@ampless/backend 1.0.0-alpha.50 → 1.0.0-alpha.51
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.
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// src/functions/plugin-secret-handler.ts
|
|
2
2
|
import { createCipheriv, randomBytes } from "crypto";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
DynamoDBClient,
|
|
5
|
+
UpdateItemCommand,
|
|
6
|
+
DeleteItemCommand
|
|
7
|
+
} from "@aws-sdk/client-dynamodb";
|
|
4
8
|
import { marshall } from "@aws-sdk/util-dynamodb";
|
|
5
9
|
import { isValidPluginKey, validatePluginSettingValue } from "ampless";
|
|
6
10
|
var ddb = new DynamoDBClient({});
|
|
@@ -72,15 +76,33 @@ async function handleSet(args) {
|
|
|
72
76
|
const indicatorTable = requireEnv("AMPLESS_PLUGIN_SECRET_INDICATOR_TABLE");
|
|
73
77
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
74
78
|
await ddb.send(
|
|
75
|
-
new
|
|
79
|
+
new UpdateItemCommand({
|
|
76
80
|
TableName: secretTable,
|
|
77
|
-
|
|
81
|
+
Key: marshall({ sk }),
|
|
82
|
+
UpdateExpression: "SET #value = :value, #createdAt = if_not_exists(#createdAt, :now), #updatedAt = :now",
|
|
83
|
+
ExpressionAttributeNames: {
|
|
84
|
+
"#value": "value",
|
|
85
|
+
"#createdAt": "createdAt",
|
|
86
|
+
"#updatedAt": "updatedAt"
|
|
87
|
+
},
|
|
88
|
+
ExpressionAttributeValues: marshall({
|
|
89
|
+
":value": ciphertext,
|
|
90
|
+
":now": now
|
|
91
|
+
})
|
|
78
92
|
})
|
|
79
93
|
);
|
|
80
94
|
await ddb.send(
|
|
81
|
-
new
|
|
95
|
+
new UpdateItemCommand({
|
|
82
96
|
TableName: indicatorTable,
|
|
83
|
-
|
|
97
|
+
Key: marshall({ sk }),
|
|
98
|
+
UpdateExpression: "SET lastSetAt = :now, #createdAt = if_not_exists(#createdAt, :now), #updatedAt = :now",
|
|
99
|
+
ExpressionAttributeNames: {
|
|
100
|
+
"#createdAt": "createdAt",
|
|
101
|
+
"#updatedAt": "updatedAt"
|
|
102
|
+
},
|
|
103
|
+
ExpressionAttributeValues: marshall({
|
|
104
|
+
":now": now
|
|
105
|
+
})
|
|
84
106
|
})
|
|
85
107
|
);
|
|
86
108
|
return "ok";
|
package/package.json
CHANGED