@onesub/server 0.19.0 → 0.20.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 +1 -0
- package/dist/__tests__/apple-jws-cache.test.d.ts +16 -0
- package/dist/__tests__/apple-jws-cache.test.d.ts.map +1 -0
- package/dist/__tests__/metrics-aggregate.test.d.ts +10 -0
- package/dist/__tests__/metrics-aggregate.test.d.ts.map +1 -0
- package/dist/__tests__/metrics-cache.test.d.ts +11 -0
- package/dist/__tests__/metrics-cache.test.d.ts.map +1 -0
- package/dist/__tests__/verified-key-cache.test.d.ts +18 -0
- package/dist/__tests__/verified-key-cache.test.d.ts.map +1 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/index.cjs +287 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +288 -192
- package/dist/index.js.map +1 -1
- package/dist/metrics-aggregate.d.ts +82 -0
- package/dist/metrics-aggregate.d.ts.map +1 -0
- package/dist/metrics-cache.d.ts +20 -0
- package/dist/metrics-cache.d.ts.map +1 -0
- package/dist/providers/apple.d.ts +2 -0
- package/dist/providers/apple.d.ts.map +1 -1
- package/dist/providers/verified-key-cache.d.ts +75 -0
- package/dist/providers/verified-key-cache.d.ts.map +1 -0
- package/dist/routes/admin.d.ts.map +1 -1
- package/dist/routes/entitlements.d.ts +18 -1
- package/dist/routes/entitlements.d.ts.map +1 -1
- package/dist/routes/metrics.d.ts +8 -3
- package/dist/routes/metrics.d.ts.map +1 -1
- package/dist/store.d.ts +3 -2
- package/dist/store.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ app.use(createOneSubMiddleware({
|
|
|
47
47
|
adminSecret: process.env.ADMIN_SECRET, // enables admin + metrics routes
|
|
48
48
|
logger: require('pino')(), // any { info, warn, error } logger
|
|
49
49
|
refundPolicy: 'immediate', // 'immediate' (default) | 'until_expiry'
|
|
50
|
+
metricsCacheTtlSeconds: 30, // 30 (default) | 0 to disable
|
|
50
51
|
}));
|
|
51
52
|
|
|
52
53
|
app.listen(4100);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* decodeJws — the cached chain-verification wiring.
|
|
3
|
+
*
|
|
4
|
+
* The success path cannot be exercised here: a chain that passes
|
|
5
|
+
* `verifyAppleCertChain` must be signed by Apple's private keys, and the
|
|
6
|
+
* verifier correctly refuses everything else. The cache's own behaviour is
|
|
7
|
+
* tested in isolation in `verified-key-cache.test.ts` (with an injected
|
|
8
|
+
* verifier). What this file pins down is the part that only the real function
|
|
9
|
+
* can show — that introducing a cache did not weaken rejection:
|
|
10
|
+
*
|
|
11
|
+
* - a chain that fails verification is rejected EVERY time, not remembered
|
|
12
|
+
* - a missing x5c is still rejected
|
|
13
|
+
* - `skipVerification` still bypasses the whole path
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=apple-jws-cache.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apple-jws-cache.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/apple-jws-cache.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* metrics-aggregate — the reduction behind every /onesub/metrics/* response.
|
|
3
|
+
*
|
|
4
|
+
* These semantics were previously only reachable through four HTTP handlers, so
|
|
5
|
+
* the fiddly parts (inclusive window edges, UTC bucket assignment, which records
|
|
6
|
+
* a distribution counts) had no direct coverage. They do now, and they are the
|
|
7
|
+
* contract any future SQL-side aggregation has to reproduce.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=metrics-aggregate.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics-aggregate.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/metrics-aggregate.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createMetricsCache — the freshness bound on aggregate metrics responses.
|
|
3
|
+
*
|
|
4
|
+
* Every metrics endpoint reduces the whole store, so this cache is what stops a
|
|
5
|
+
* dashboard refresh loop from re-scanning it. The behaviours worth pinning down
|
|
6
|
+
* are the ones that would either defeat the purpose (a key that never repeats)
|
|
7
|
+
* or serve something wrong (a stale hit past its TTL, a shared entry between
|
|
8
|
+
* unrelated stores, a remembered failure).
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=metrics-cache.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics-cache.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/metrics-cache.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VerifiedKeyCache — the memo behind Apple x5c chain verification.
|
|
3
|
+
*
|
|
4
|
+
* This cache sits directly on a security boundary: it decides when an
|
|
5
|
+
* expensive chain verification may be skipped. The real Apple path cannot be
|
|
6
|
+
* driven end-to-end in tests (a passing chain must be signed by Apple's private
|
|
7
|
+
* keys, and `verifyAppleCertChain` correctly refuses anything else), so the
|
|
8
|
+
* cache takes its verification as an injected function and the invariants are
|
|
9
|
+
* tested here directly:
|
|
10
|
+
*
|
|
11
|
+
* - a hit skips verification, a miss does not
|
|
12
|
+
* - every input participates in the entry identity (chain AND alg)
|
|
13
|
+
* - a failed verification is never remembered
|
|
14
|
+
* - no entry outlives the certificate chain that produced it
|
|
15
|
+
* - eviction never hands back a stale key
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=verified-key-cache.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verified-key-cache.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/verified-key-cache.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oDAAoD;AACpD,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,EAClB,SAAS,SAA2B,GACnC,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oDAAoD;AACpD,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,EAClB,SAAS,SAA2B,GACnC,OAAO,CAAC,QAAQ,CAAC,CA2BnB"}
|