-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathic_siwe_provider.did.js
95 lines (95 loc) · 2.91 KB
/
ic_siwe_provider.did.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
export const idlFactory = ({ IDL }) => {
const RuntimeFeature = IDL.Variant({
IncludeUriInSeed: IDL.Null,
DisableEthToPrincipalMapping: IDL.Null,
DisablePrincipalToEthMapping: IDL.Null,
});
const SettingsInput = IDL.Record({
uri: IDL.Text,
runtime_features: IDL.Opt(IDL.Vec(RuntimeFeature)),
domain: IDL.Text,
statement: IDL.Opt(IDL.Text),
scheme: IDL.Opt(IDL.Text),
salt: IDL.Text,
session_expires_in: IDL.Opt(IDL.Nat64),
targets: IDL.Opt(IDL.Vec(IDL.Text)),
chain_id: IDL.Opt(IDL.Nat),
sign_in_expires_in: IDL.Opt(IDL.Nat64),
});
const Principal = IDL.Vec(IDL.Nat8);
const Address = IDL.Text;
const GetAddressResponse = IDL.Variant({ Ok: Address, Err: IDL.Text });
const GetPrincipalResponse = IDL.Variant({
Ok: Principal,
Err: IDL.Text,
});
const PublicKey = IDL.Vec(IDL.Nat8);
const SessionKey = PublicKey;
const Timestamp = IDL.Nat64;
const Delegation = IDL.Record({
pubkey: PublicKey,
targets: IDL.Opt(IDL.Vec(IDL.Principal)),
expiration: Timestamp,
});
const SignedDelegation = IDL.Record({
signature: IDL.Vec(IDL.Nat8),
delegation: Delegation,
});
const GetDelegationResponse = IDL.Variant({
Ok: SignedDelegation,
Err: IDL.Text,
});
const SiweSignature = IDL.Text;
const Nonce = IDL.Text;
const CanisterPublicKey = PublicKey;
const LoginDetails = IDL.Record({
user_canister_pubkey: CanisterPublicKey,
expiration: Timestamp,
});
const LoginResponse = IDL.Variant({ Ok: LoginDetails, Err: IDL.Text });
const SiweMessage = IDL.Text;
const PrepareLoginOkResponse = IDL.Record({
nonce: IDL.Text,
siwe_message: SiweMessage,
});
const PrepareLoginResponse = IDL.Variant({
Ok: PrepareLoginOkResponse,
Err: IDL.Text,
});
return IDL.Service({
get_address: IDL.Func([Principal], [GetAddressResponse], ["query"]),
get_caller_address: IDL.Func([], [GetAddressResponse], ["query"]),
get_principal: IDL.Func([Address], [GetPrincipalResponse], ["query"]),
siwe_get_delegation: IDL.Func(
[Address, SessionKey, Timestamp],
[GetDelegationResponse],
["query"],
),
siwe_login: IDL.Func(
[SiweSignature, Address, SessionKey, Nonce],
[LoginResponse],
[],
),
siwe_prepare_login: IDL.Func([Address], [PrepareLoginResponse], []),
});
};
export const init = ({ IDL }) => {
const RuntimeFeature = IDL.Variant({
IncludeUriInSeed: IDL.Null,
DisableEthToPrincipalMapping: IDL.Null,
DisablePrincipalToEthMapping: IDL.Null,
});
const SettingsInput = IDL.Record({
uri: IDL.Text,
runtime_features: IDL.Opt(IDL.Vec(RuntimeFeature)),
domain: IDL.Text,
statement: IDL.Opt(IDL.Text),
scheme: IDL.Opt(IDL.Text),
salt: IDL.Text,
session_expires_in: IDL.Opt(IDL.Nat64),
targets: IDL.Opt(IDL.Vec(IDL.Text)),
chain_id: IDL.Opt(IDL.Nat),
sign_in_expires_in: IDL.Opt(IDL.Nat64),
});
return [SettingsInput];
};