seqpulse 0.1.0 → 0.2.0
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/README.md +2 -2
- package/index.d.ts +1 -2
- package/index.js +3 -9
- package/package.json +1 -1
- package/scripts/smoke.js +1 -2
package/README.md
CHANGED
|
@@ -23,7 +23,6 @@ const seqpulse = require("seqpulse");
|
|
|
23
23
|
const app = express();
|
|
24
24
|
|
|
25
25
|
seqpulse.init({
|
|
26
|
-
apiKey: process.env.SEQPULSE_API_KEY,
|
|
27
26
|
endpoint: "/seqpulse-metrics",
|
|
28
27
|
hmacEnabled: process.env.SEQPULSE_HMAC_ENABLED === "true",
|
|
29
28
|
hmacSecret: process.env.SEQPULSE_HMAC_SECRET,
|
|
@@ -57,7 +56,8 @@ app.listen(3000, () => {
|
|
|
57
56
|
## Notes
|
|
58
57
|
|
|
59
58
|
- This SDK does not manage CI/CD trigger/finish workflow.
|
|
60
|
-
- `apiKey` is
|
|
59
|
+
- `apiKey` is optional and not used directly in metrics payload or HMAC validation.
|
|
60
|
+
- Metrics sampling window is fixed to 60 seconds (not configurable in SDK init).
|
|
61
61
|
|
|
62
62
|
## Local smoke test
|
|
63
63
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -143,26 +143,20 @@ function init(config) {
|
|
|
143
143
|
if (!config || typeof config !== "object") {
|
|
144
144
|
throw new Error("seqpulse.init(config) requires a config object");
|
|
145
145
|
}
|
|
146
|
-
if (!config.apiKey || typeof config.apiKey !== "string") {
|
|
147
|
-
throw new Error("seqpulse.init requires apiKey");
|
|
148
|
-
}
|
|
149
146
|
|
|
150
147
|
const endpoint = canonicalizePath(config.endpoint || DEFAULT_ENDPOINT);
|
|
151
|
-
const windowSeconds = Number(config.windowSeconds || DEFAULT_WINDOW_SECONDS);
|
|
152
148
|
const hmacEnabled = Boolean(config.hmacEnabled);
|
|
153
149
|
const hmacSecret = String(config.hmacSecret || "");
|
|
154
150
|
|
|
155
|
-
if (!Number.isFinite(windowSeconds) || windowSeconds <= 0) {
|
|
156
|
-
throw new Error("windowSeconds must be a positive number");
|
|
157
|
-
}
|
|
158
151
|
if (hmacEnabled && !hmacSecret) {
|
|
159
152
|
throw new Error("hmacSecret is required when hmacEnabled=true");
|
|
160
153
|
}
|
|
161
154
|
|
|
162
155
|
state.config = {
|
|
163
|
-
apiKey: config.apiKey,
|
|
156
|
+
apiKey: typeof config.apiKey === "string" ? config.apiKey : "",
|
|
164
157
|
endpoint,
|
|
165
|
-
|
|
158
|
+
// Fixed to backend contract: 60s observation window for SDK sampling.
|
|
159
|
+
windowSeconds: DEFAULT_WINDOW_SECONDS,
|
|
166
160
|
hmacEnabled,
|
|
167
161
|
hmacSecret,
|
|
168
162
|
maxSkewPastSeconds: Number(config.maxSkewPastSeconds || DEFAULT_MAX_SKEW_PAST_SECONDS),
|
package/package.json
CHANGED
package/scripts/smoke.js
CHANGED
|
@@ -42,7 +42,7 @@ function runMiddleware(mw, req, res) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async function testNoHmac() {
|
|
45
|
-
sdk.init({
|
|
45
|
+
sdk.init({ endpoint: "/seqpulse-metrics", hmacEnabled: false });
|
|
46
46
|
const mw = sdk.metrics();
|
|
47
47
|
|
|
48
48
|
const req1 = mockReq({ path: "/health" });
|
|
@@ -63,7 +63,6 @@ async function testNoHmac() {
|
|
|
63
63
|
async function testHmac() {
|
|
64
64
|
const secret = "local_hmac_secret";
|
|
65
65
|
sdk.init({
|
|
66
|
-
apiKey: "sp_local",
|
|
67
66
|
endpoint: "/seqpulse-metrics",
|
|
68
67
|
hmacEnabled: true,
|
|
69
68
|
hmacSecret: secret,
|