@atcn/sdk 1.3.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/LICENSE +202 -0
- package/README.md +25 -0
- package/bin/atcn.js +2 -0
- package/dist/builders.d.ts +44 -0
- package/dist/builders.js +61 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2 -0
- package/dist/client.d.ts +395 -0
- package/dist/client.js +167 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/init.d.ts +14 -0
- package/dist/init.js +45 -0
- package/dist/signer.d.ts +16 -0
- package/dist/signer.js +28 -0
- package/dist/subledger.d.ts +670 -0
- package/dist/subledger.js +300 -0
- package/package.json +45 -0
package/dist/signer.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { newId, signPayload } from "@atcn/schema";
|
|
2
|
+
/** Signs ATCN events for one actor. Keys stay with the caller; ATCN only ever sees public keys. */
|
|
3
|
+
export class EventSigner {
|
|
4
|
+
identity;
|
|
5
|
+
constructor(identity) {
|
|
6
|
+
this.identity = identity;
|
|
7
|
+
}
|
|
8
|
+
get actorId() {
|
|
9
|
+
return this.identity.actorId;
|
|
10
|
+
}
|
|
11
|
+
get platformId() {
|
|
12
|
+
return this.identity.platformId;
|
|
13
|
+
}
|
|
14
|
+
sign(eventType, obligationId, data = {}, causationIds = []) {
|
|
15
|
+
const payload = {
|
|
16
|
+
schema_version: "1.0",
|
|
17
|
+
event_id: newId("event"),
|
|
18
|
+
event_type: eventType,
|
|
19
|
+
obligation_id: obligationId,
|
|
20
|
+
actor_id: this.identity.actorId,
|
|
21
|
+
actor_platform_id: this.identity.platformId,
|
|
22
|
+
event_time: new Date().toISOString(),
|
|
23
|
+
causation_ids: causationIds,
|
|
24
|
+
data,
|
|
25
|
+
};
|
|
26
|
+
return signPayload(payload, { keyId: this.identity.keyId, keyVersion: this.identity.keyVersion ?? 1, privateKey: this.identity.privateKey });
|
|
27
|
+
}
|
|
28
|
+
}
|