gora8-signer 0.1.4 → 0.1.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/ipc-server.js +12 -1
- package/dist/policy.d.ts +1 -0
- package/dist/policy.js +8 -0
- package/package.json +1 -1
package/dist/ipc-server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createServer } from "node:net";
|
|
2
|
-
import { unlink } from "node:fs/promises";
|
|
2
|
+
import { mkdir, unlink } from "node:fs/promises";
|
|
3
|
+
import { dirname } from "node:path";
|
|
3
4
|
export class SignerIpcServer {
|
|
4
5
|
signer;
|
|
5
6
|
socketPath;
|
|
@@ -9,6 +10,16 @@ export class SignerIpcServer {
|
|
|
9
10
|
this.socketPath = socketPath;
|
|
10
11
|
}
|
|
11
12
|
async start() {
|
|
13
|
+
// The socket's directory (~/.gora8/signer/<name>/) doesn't exist yet
|
|
14
|
+
// on a brand-new signer name — nothing else in this package creates
|
|
15
|
+
// it (audit-log.ts/keystore.ts/rate-limit-backend.ts each lazily
|
|
16
|
+
// create their own file's directory, none of which is guaranteed to
|
|
17
|
+
// run before this does). Without this, server.listen() below fails
|
|
18
|
+
// with EACCES on macOS — libuv/Node report a missing parent
|
|
19
|
+
// directory as EACCES rather than ENOENT for a Unix domain socket
|
|
20
|
+
// bind, which reads exactly like a real permissions problem and
|
|
21
|
+
// isn't one.
|
|
22
|
+
await mkdir(dirname(this.socketPath), { recursive: true, mode: 0o700 });
|
|
12
23
|
// Remove a stale socket file from an unclean previous shutdown —
|
|
13
24
|
// net.createServer refuses to bind over an existing path otherwise.
|
|
14
25
|
await unlink(this.socketPath).catch(() => { });
|
package/dist/policy.d.ts
CHANGED
package/dist/policy.js
CHANGED
|
@@ -30,6 +30,14 @@ export class PolicyEngine {
|
|
|
30
30
|
if (new Date(mandate.validUntil).getTime() < Date.now()) {
|
|
31
31
|
return { allowed: false, reason: `Mandate ${mandate.mandateId} expired at ${mandate.validUntil}.` };
|
|
32
32
|
}
|
|
33
|
+
// Independent enforcement of the same rule api/src/lib/
|
|
34
|
+
// policy-enforcement.ts's checkSpendingLimit() applies server-side —
|
|
35
|
+
// real defense-in-depth per this class's own doc comment: even a
|
|
36
|
+
// gora8 API that somehow let an Advisory-mode hire through still gets
|
|
37
|
+
// refused here, at the signature itself, before anything is signed.
|
|
38
|
+
if (request.amount !== null && mandate.mode === "advisory") {
|
|
39
|
+
return { allowed: false, reason: `Mandate ${mandate.mandateId} is in Advisory mode — this signer refuses to sign a value-moving transaction without explicit owner confirmation outside this flow.` };
|
|
40
|
+
}
|
|
33
41
|
if (request.amount !== null) {
|
|
34
42
|
const { perTransactionLimit, dailyCap, monthlyCap } = mandate.spending;
|
|
35
43
|
if (perTransactionLimit !== null && request.amount > perTransactionLimit) {
|