Merge branch 'IDTEAM-1.26.0' into 'main'
[ProtonMail-WebClient.git] / packages / shared / lib / api / memberKeys.ts
blob000ec5c89d78211a66ff28f08b359653d6bdb205
1 import type { SignedKeyList } from '../interfaces';
3 interface SetupMemberKeyAddressKeyPayload {
4     AddressID: string;
5     SignedKeyList: SignedKeyList;
6     UserKey: string;
7     MemberKey: string;
8     Token: string;
11 interface SetupMemberKeyUserKeyPayload {
12     UserKey: string;
13     MemberKey: string;
14     Token: string;
17 interface SetupMemberKeyPayload {
18     MemberID: string;
19     AddressKeys: SetupMemberKeyAddressKeyPayload[];
20     KeySalt: string;
21     PrimaryKey: SetupMemberKeyUserKeyPayload;
24 interface SetupMemberKeyUserKeyPayloadV2 {
25     PrivateKey: string;
26     OrgPrivateKey: string;
27     OrgToken: string;
30 interface SetupMemberKeyAddressKeyPayloadV2 {
31     AddressID: string;
32     PrivateKey: string;
33     Token: string;
34     Signature: string;
35     OrgSignature: string;
36     SignedKeyList: SignedKeyList;
39 interface SetupMemberKeyPayloadV2 {
40     MemberID: string;
41     AddressKeys: SetupMemberKeyAddressKeyPayloadV2[];
42     KeySalt: string;
43     UserKey: SetupMemberKeyUserKeyPayloadV2;
46 export const setupMemberKeyRoute = ({ MemberID, ...data }: SetupMemberKeyPayload | SetupMemberKeyPayloadV2) => ({
47     url: `members/${MemberID}/keys/setup`,
48     method: 'post',
49     data,
50 });
52 interface CreateMemberKeyPayload {
53     MemberID: string;
54     Activation: string;
55     Token: string;
56     AddressID: string;
57     UserKey: string;
58     MemberKey: string;
59     Primary: number;
60     SignedKeyList: SignedKeyList;
63 interface CreateMemberKeyPayloadV2 extends Omit<CreateMemberKeyPayload, 'UserKey' | 'MemberKey' | 'Activation'> {
64     Signature: string;
65     OrgSignature: string;
66     PrivateKey: string;
69 export const createMemberKeyRoute = ({ MemberID, ...data }: CreateMemberKeyPayload | CreateMemberKeyPayloadV2) => ({
70     url: `members/${MemberID}/keys`,
71     method: 'post',
72     data,
73 });
75 export interface MigrateMemberAddressKeyPayload {
76     ID: string;
77     Token: string;
78     Signature: string;
79     OrgSignature: string;
80     PrivateKey: string;
83 interface MigrateMemberAddressKeysPayload {
84     MemberID: string;
85     AddressKeys: MigrateMemberAddressKeyPayload[];
86     SignedKeyLists: { [key: string]: SignedKeyList };
89 export const migrateMembersAddressKeysRoute = ({ MemberID, ...data }: MigrateMemberAddressKeysPayload) => ({
90     url: `members/${MemberID}/keys/migrate`,
91     method: 'post',
92     data,
93 });