UNPKG

2.71 kBTypeScriptView Raw
1import { SdmGoalEvent } from "../goal/SdmGoalEvent";
2import { SdmGoalMessage } from "../goal/SdmGoalMessage";
3export interface VerificationKey<T> {
4 name: string;
5 publicKey: T;
6 algorithm?: string;
7}
8/**
9 * Private/public key pair to use for SDM goal signing and verification
10 */
11export interface SigningKey<T> extends VerificationKey<T> {
12 privateKey: T;
13 passphrase?: string;
14}
15/**
16 * Defines the scope of which goes get signed and validated
17 */
18export declare enum GoalSigningScope {
19 /**
20 * Only verify incoming goals for fulfillment
21 */
22 Fulfillment = "fulfillment",
23 /**
24 * Verify each incoming goal into any of the SDM event handlers
25 */
26 All = "all"
27}
28/**
29 * Strategy for implementing different signature algorithms
30 */
31export interface GoalSigningAlgorithm<T> {
32 /**
33 * Return the name of this algorithm
34 */
35 name: string;
36 /**
37 * Sign the provided goal with the given key
38 */
39 sign(goal: SdmGoalMessage, key: SigningKey<T>): Promise<string>;
40 /**
41 * Verify the provided goal against the signature
42 */
43 verify(goal: SdmGoalEvent, signature: string, key: VerificationKey<T>): Promise<SdmGoalEvent>;
44}
45export interface GoalSigningConfiguration {
46 /**
47 * Enable goal signature verification on this SDM.
48 */
49 enabled: boolean;
50 /**
51 * Scope for goal signing:
52 *
53 * Fulfillment: only verify goals before fulfillment
54 * All: verify goals during all phases of a goal set execution
55 */
56 scope: GoalSigningScope;
57 /**
58 * Public/Private key pair to use for goal signing.
59 * The public key will also be used to verify incoming goals.
60 */
61 signingKey?: SigningKey<any>;
62 /**
63 * Public keys to verify incoming goals
64 */
65 verificationKeys?: VerificationKey<any> | Array<VerificationKey<any>>;
66 /**
67 * Algorithms to use for signing and verification
68 *
69 * Default RSA-SHA512 algorithm will always be available
70 */
71 algorithms?: GoalSigningAlgorithm<any> | Array<GoalSigningAlgorithm<any>>;
72}
73export interface EventSigningConfiguration {
74 /**
75 * Enable event signature verification on this SDM.
76 */
77 enabled: boolean;
78 /**
79 * Regular expressions matching subscription and mutation names
80 * to identify events that should be verified.
81 */
82 events: string[];
83 /**
84 * Public/Private key pair to use for event signing.
85 * The public key will also be used to verify incoming events.
86 */
87 signingKey?: SigningKey<any>;
88 /**
89 * Public keys to verify incoming events
90 */
91 verificationKeys?: VerificationKey<any> | Array<VerificationKey<any>>;
92}
93//# sourceMappingURL=SigningKeys.d.ts.map
\No newline at end of file