@decentrys/sentinel-sdk 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +110 -24
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # @decentrys/sentinel-sdk
2
2
 
3
- Monitoring for deployed contracts, wallets and treasuries.
3
+ **Watches contracts, wallets and treasuries you already deployed, and tells you when something changes.**
4
+
5
+ An audit is a point-in-time review. Sentinel is what happens afterwards: you
6
+ register what you own, write rules about what would worry you, and get alerts
7
+ when those conditions actually occur.
4
8
 
5
9
  ## Install
6
10
 
@@ -8,46 +12,128 @@ Monitoring for deployed contracts, wallets and treasuries.
8
12
  npm install @decentrys/sentinel-sdk
9
13
  ```
10
14
 
11
- ## Use
15
+ ## Getting an API key
16
+
17
+ Sign in at [decentrys.com/developers](https://decentrys.com/developers) and create a key.
18
+
19
+ There are two kinds, and picking the wrong one is the mistake that matters:
20
+
21
+ | Prefix | Where it belongs | Why |
22
+ |---|---|---|
23
+ | `dk_pub_live_…` | **Publishable.** Ships inside a wallet, extension or mobile app. | Bounded to the origins you register and to read-only Protect endpoints. Anyone can extract it from your bundle; that's expected, and it's why it can't do anything dangerous. |
24
+ | `dk_live_…` | **Secret.** Server-side only. | Full scope access. If this ends up in a client bundle it is a leaked credential the moment it ships. |
25
+
26
+ **Sentinel needs a secret key.** A publishable key is refused at construction —
27
+ configuring detection is not something a credential shipped inside a client may do.
28
+
29
+ ## Quick start
12
30
 
13
31
  ```ts
14
- import { Sentinel, rulesFromAudit } from '@decentrys/sentinel-sdk';
32
+ import { Sentinel } from '@decentrys/sentinel-sdk';
15
33
 
16
34
  const sentinel = new Sentinel({ apiKey: 'dk_live_...' });
17
35
 
18
- await sentinel.registerContract({ projectId, chain: 'ethereum', address });
36
+ // 1. What do you want watched?
37
+ await sentinel.registerContract({ projectId, chain: 'ethereum', address: '0xabc...', label: 'Vault v2' });
38
+ await sentinel.registerTreasury({ projectId, chain: 'ethereum', address: '0xdef...' });
39
+
40
+ // 2. What would worry you?
41
+ await sentinel.createRule({
42
+ projectId,
43
+ name: 'Large treasury outflow',
44
+ severity: 'HIGH',
45
+ triggerType: 'treasury.transfer',
46
+ conditions: {
47
+ op: 'AND',
48
+ conditions: [
49
+ { op: 'eq', field: 'transfer.direction', value: 'OUT' },
50
+ { op: 'gt', field: 'transfer.valueUsd', value: 50000 },
51
+ ],
52
+ },
53
+ actions: [{ type: 'ALERT', config: {} }, { type: 'SLACK', config: { webhookUrl } }],
54
+ cooldownSeconds: 300,
55
+ });
56
+
57
+ // 3. Read what fired
58
+ const { data: alerts } = await sentinel.listAlerts({ status: 'NEW' });
59
+ await sentinel.acknowledgeAlert(alerts[0].id, 'Expected — scheduled rebalance.');
60
+ ```
61
+
62
+ `await sentinel.catalog()` returns every fact field, operator and action you can
63
+ build a rule from, so you can generate a rule builder rather than hardcode one.
64
+
65
+ ## Test a rule before you arm it
66
+
67
+ ```ts
68
+ const result = await sentinel.testRule(ruleId, { 'transfer.direction': 'OUT', 'transfer.valueUsd': 75000 });
69
+ // result.matched -> true, with the comparison that decided it
70
+ ```
71
+
72
+ A rule nobody has tested is a rule whose behaviour you'll discover during an
73
+ incident.
74
+
75
+ ## Report events we can't see
76
+
77
+ Some things only your system knows: a deploy pipeline running, an internally
78
+ approved treasury movement, an off-chain governance action.
19
79
 
20
- // Turn what an audit learned into what the system watches.
21
- for (const { rule } of rulesFromAudit({ projectId, capabilities })) {
80
+ ```ts
81
+ await sentinel.reportEvent({ projectId, eventName: 'governance.executed', chain: 'ethereum', txHash, facts: {...} });
82
+ ```
83
+
84
+ **This is the one method that never throws.** It runs on your hot path, and a
85
+ monitoring call must not be able to fail the thing it's monitoring. It returns
86
+ a boolean instead.
87
+
88
+ ## Turn an audit into monitoring
89
+
90
+ The most valuable thing here. An audit identifies what a contract can do; this
91
+ converts that into what gets watched.
92
+
93
+ ```ts
94
+ import { rulesFromAudit, unmappedCapabilities } from '@decentrys/sentinel-sdk';
95
+
96
+ const capabilities = [{ type: 'UPGRADEABLE', grantedBy: 'EIP1967' }, { type: 'MINT_AUTHORITY' }];
97
+
98
+ for (const { rule } of rulesFromAudit({ projectId, capabilities, treasuryThresholdUsd: 50000 })) {
22
99
  await sentinel.createRule(rule);
23
100
  }
101
+
102
+ // Told, not hidden: which capabilities produced no rule.
103
+ console.log(unmappedCapabilities(capabilities));
24
104
  ```
25
105
 
26
- ## It throws, deliberately
106
+ It watches the upgrade **happening**, never the contract **being** upgradeable —
107
+ a capability is not a fault. Capabilities with no plausible response generate no
108
+ rule, because a rule nobody can act on trains a team to close alerts unread.
27
109
 
28
- Unlike `@decentrys/protect`, this client raises errors. It is management —
29
- registering a contract, writing a rule. Swallowing a failure would leave an
30
- operator believing they are monitored when they are not, which is the more
31
- dangerous silence.
110
+ ## It throws
32
111
 
33
- `reportEvent()` is the exception: it runs on your hot path and returns a
34
- boolean, because a monitoring call must not be able to fail the thing it is
35
- monitoring.
112
+ Unlike `@decentrys/protect`, this client raises errors. It's management if
113
+ registering a contract fails, you must know, or you'll believe you're monitored
114
+ when you aren't.
36
115
 
37
- ## Audit handover
116
+ ```ts
117
+ try {
118
+ await sentinel.registerContract({ ... });
119
+ } catch (e) {
120
+ if (e instanceof SentinelError) console.error(e.status, e.message);
121
+ }
122
+ ```
38
123
 
39
- `rulesFromAudit()` watches the upgrade *happening*, never the contract *being*
40
- upgradeable. A capability is not a fault. Capabilities with no plausible
41
- response generate no rule, and `unmappedCapabilities()` tells you which — a
42
- rule nobody can act on trains a team to close alerts unread.
124
+ ## The rest of the SDK
43
125
 
44
- **Secret keys only.** A publishable key is refused at construction.
126
+ | Package | For |
127
+ |---|---|
128
+ | [`@decentrys/protect`](https://www.npmjs.com/package/@decentrys/protect) | Pre-sign risk assessment for wallets and dapps |
129
+ | [`@decentrys/ui-sdk`](https://www.npmjs.com/package/@decentrys/ui-sdk) | React components that render Protect results |
130
+ | [`@decentrys/sentinel-sdk`](https://www.npmjs.com/package/@decentrys/sentinel-sdk) | Monitoring deployed contracts and treasuries |
131
+ | [`@decentrys/risk-sdk`](https://www.npmjs.com/package/@decentrys/risk-sdk) | Screening for exchanges and custodians |
132
+ | [`@decentrys/dri-sdk`](https://www.npmjs.com/package/@decentrys/dri-sdk) | Fund tracing and recovery intelligence |
133
+ | [`@decentrys/agent`](https://www.npmjs.com/package/@decentrys/agent) | Policy enforcement for autonomous agents |
45
134
 
46
135
  ## Licence
47
136
 
48
137
  MIT © Decentrys Labs
49
138
 
50
- ## Links
51
-
52
- - [decentrys.com](https://decentrys.com) · [SDK overview](https://decentrys.com/sdk) · [Developer API](https://decentrys.com/developers)
53
- - Source: [github.com/teamdecentrys-byte/Decentrys](https://github.com/teamdecentrys-byte/Decentrys)
139
+ [decentrys.com](https://decentrys.com) · [SDK overview](https://decentrys.com/sdk) · [Developer API](https://decentrys.com/developers) · [Source](https://github.com/teamdecentrys-byte/Decentrys)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentrys/sentinel-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Monitoring for deployed contracts, wallets and treasuries: targets, detection rules, alerts, and audit-to-monitoring handover.",
5
5
  "license": "MIT",
6
6
  "author": "Decentrys Labs",