-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathStore.ts
More file actions
202 lines (175 loc) · 5.33 KB
/
Copy pathStore.ts
File metadata and controls
202 lines (175 loc) · 5.33 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { Idp } from '@canton-network/core-wallet-auth'
import { Network } from './config/schema'
export enum AddressType {
PaperAddress = 'PaperAddress',
CCSPAddress = 'CCSPAddress',
}
export type PartyId = string
export interface SigningDriver {
signingDriverId: string
}
export interface SigningProvider {
signingProviderId: string
privateKey?: string
addressType: AddressType
}
export interface WalletFilter {
networkIds?: string[]
signingProviderIds?: string[]
}
export type CurrentNetworkWalletFilter = Omit<WalletFilter, 'networkIds'>
export enum PartyLevelRight {
CanActAs = 'CanActAs',
CanReadAs = 'CanReadAs',
CanExecuteAs = 'CanExecuteAs',
}
export enum UserLevelRight {
CanReadAsAnyParty = 'CanReadAsAnyParty',
CanExecuteAsAnyParty = 'CanExecuteAsAnyParty',
}
export interface UpdateWallet {
partyId: PartyId
networkId?: string
status?: WalletStatus
externalTxId?: string
topologyTransactions?: string
disabled?: boolean
reason?: string
primary?: boolean
rights?: PartyLevelRight[]
}
export type WalletStatus = 'initialized' | 'allocated' | 'removed'
export interface Wallet {
primary: boolean
status: WalletStatus
partyId: PartyId
hint: string
publicKey: string
namespace: string
networkId: string
signingProviderId: string
externalTxId?: string
topologyTransactions?: string
disabled?: boolean
reason?: string
rights: PartyLevelRight[]
// hosted: [network]
}
// Session management
export interface Session {
id: string
network: string
accessToken: string
}
export interface Transaction {
id: string
status: 'pending' | 'signed' | 'executed' | 'failed'
commandId: string
preparedTransaction: string
preparedTransactionHash: string
payload?: unknown
origin: string | null
createdAt?: Date
signedAt?: Date
externalTxId?: string
}
export interface TransactionStatusUpdate {
payload?: unknown
signedAt?: Date
externalTxId?: string
}
export interface MessageRaw {
id: string
status: 'pending' | 'signed' | 'failed'
userId: string
partyId: PartyId
publicKey: string
message: string
origin: string | null
createdAt: Date
signedAt?: Date
signature?: string
}
export interface MessageRawStatusUpdate {
signedAt?: Date
signature?: string
}
// API keys
export interface ApiKey {
id: string
name: string
digest: string
createdAt: Date
lastUsedAt?: Date | undefined
userId: string
email: string | null
networkId: string
}
// Store interface for managing wallets, sessions, networks, and transactions
export interface Store {
// Wallet methods
getWallets(filter?: CurrentNetworkWalletFilter): Promise<Array<Wallet>>
getAllWallets(filter?: WalletFilter): Promise<Array<Wallet>>
getPrimaryWallet(): Promise<Wallet | undefined>
setPrimaryWallet(partyId: PartyId): Promise<void>
addWallet(wallet: Wallet): Promise<void>
updateWallet(params: UpdateWallet): Promise<void>
removeWallet(partyId: PartyId): Promise<void>
getUserRights(networkId?: string): Promise<Array<UserLevelRight>>
setUserRights(
networkId: string,
rights: Array<UserLevelRight>
): Promise<void>
// Session methods
getSession(): Promise<Session | undefined>
setSession(session: Session): Promise<void>
removeSession(): Promise<void>
// IDP methods
getIdp(idpId: string): Promise<Idp>
listIdps(): Promise<Array<Idp>>
updateIdp(idp: Idp): Promise<void>
addIdp(idp: Idp): Promise<void>
removeIdp(idpId: string): Promise<void>
// Network methods
getNetwork(networkId: string): Promise<Network>
getCurrentNetwork(): Promise<Network>
listNetworks(): Promise<Array<Network>>
updateNetwork(network: Network): Promise<void>
addNetwork(network: Network): Promise<void>
removeNetwork(networkId: string): Promise<void>
// Transaction methods
setTransaction(tx: Transaction): Promise<void>
setTransactionSigned(
transactionId: string,
signedAt: Date,
externalTxId?: string
): Promise<void>
setTransactionStatus(
transactionId: string,
status: Transaction['status'],
updates?: TransactionStatusUpdate
): Promise<void>
getTransaction(transactionId: string): Promise<Transaction | undefined>
getLatestTransactionByCommandId(
commandId: string
): Promise<Transaction | undefined>
listTransactions(): Promise<Array<Transaction>>
removeTransaction(transactionId: string): Promise<void>
// Message signing request methods
setMessageRaw(message: MessageRaw): Promise<void>
setMessageRawStatus(
messageId: string,
status: MessageRaw['status'],
updates?: MessageRawStatusUpdate
): Promise<void>
getMessageRaw(messageId: string): Promise<MessageRaw | undefined>
listMessageRaws(): Promise<Array<MessageRaw>>
removeMessageRaw(messageId: string): Promise<void>
// API Key methods
addApiKey(apiKey: ApiKey): Promise<void>
listApiKeys(): Promise<Array<ApiKey>>
getApiKey(digest: string): Promise<ApiKey | undefined>
removeApiKey(apiKeyId: string): Promise<void>
}