Skip to content

Commit 98c8e43

Browse files
nikolay-komarevskiysa-idx-adminr-birkner
authored
chore(boundary): salt canister interface (dfinity#3587)
Co-authored-by: IDX GitLab Automation <[email protected]> Co-authored-by: r-birkner <[email protected]>
1 parent 8b198f6 commit 98c8e43

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Represents timestamp in milliseconds since the epoch (1970-01-01)
2+
type Timestamp = nat64;
3+
// Structured HTTP header representation
4+
type HeaderField = record { text; text; };
5+
6+
// Detailed salt retrieval response
7+
type GetSaltResponse = variant {
8+
Ok: SaltResponse;
9+
Err: GetSaltError;
10+
};
11+
12+
// Comprehensive error for salt retrieval
13+
type GetSaltError = variant {
14+
// Indicates an unauthorized attempt to get the salt
15+
Unauthorized;
16+
// Captures all unexpected internal errors during process
17+
Internal: text;
18+
};
19+
20+
// Salt response containing salt itself and additional metadata
21+
type SaltResponse = record {
22+
salt: blob;
23+
salt_id: Timestamp;
24+
};
25+
26+
type HttpRequest = record {
27+
method: text;
28+
url: text;
29+
headers: vec HeaderField;
30+
body: blob;
31+
};
32+
33+
type HttpResponse = record {
34+
status_code: nat16;
35+
headers: vec HeaderField;
36+
body: blob;
37+
};
38+
39+
// Salt generation strategies
40+
type SaltGenerationStrategy = variant {
41+
// Generates a new salt at 00:00:00 UTC on the first day of the next calendar month
42+
// Handles calendar edge cases including: transitions between months (December-January), leap years
43+
StartOfMonth;
44+
// Generates a new salt at fixed intervals from an unspecified reference point
45+
FixedIntervalSecs: nat64;
46+
};
47+
48+
// Initialization arguments used when installing/upgrading/reinstalling the canister
49+
type InitArgs = record {
50+
// Strategy defining salt generation
51+
// If specified:
52+
// - salt is regenerated immediately
53+
// - subsequent strategy is based on the variant
54+
// If not specified:
55+
// - preserve previously configured strategy
56+
// - no immediate salt regeneration
57+
salt_generation_strategy: opt SaltGenerationStrategy;
58+
// Interval (in seconds) for polling API boundary node IDs from the registry
59+
// The first polling operation occurs immediately
60+
registry_polling_interval_secs: nat64;
61+
};
62+
63+
service : (InitArgs) -> {
64+
// Fetches the current salt (randomly generated value to be added to data before hashing)
65+
get_salt: () -> (GetSaltResponse) query;
66+
// Canister metrics (Http Interface)
67+
http_request: (HttpRequest) -> (HttpResponse) query;
68+
}

0 commit comments

Comments
 (0)