@andrewkimjoseph/celina 0.2.18 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/build/abis/self-registry.d.ts +194 -0
- package/build/abis/self-registry.js +120 -0
- package/build/abis/self-registry.js.map +1 -0
- package/build/clients/self-api.d.ts +82 -0
- package/build/clients/self-api.js +242 -0
- package/build/clients/self-api.js.map +1 -0
- package/build/config/env.d.ts +1 -0
- package/build/config/env.js +1 -0
- package/build/config/env.js.map +1 -1
- package/build/config/self.d.ts +22 -0
- package/build/config/self.js +27 -0
- package/build/config/self.js.map +1 -0
- package/build/context/app-context.d.ts +4 -1
- package/build/context/app-context.js +4 -1
- package/build/context/app-context.js.map +1 -1
- package/build/server/create-server.js +1 -1
- package/build/server/create-server.js.map +1 -1
- package/build/server/instructions.js +6 -2
- package/build/server/instructions.js.map +1 -1
- package/build/services/self-session-store.d.ts +19 -0
- package/build/services/self-session-store.js +28 -0
- package/build/services/self-session-store.js.map +1 -0
- package/build/services/self.service.d.ts +250 -0
- package/build/services/self.service.js +689 -0
- package/build/services/self.service.js.map +1 -0
- package/build/tools/index.js +2 -0
- package/build/tools/index.js.map +1 -1
- package/build/tools/self.tools.d.ts +2 -0
- package/build/tools/self.tools.js +256 -0
- package/build/tools/self.tools.js.map +1 -0
- package/build/utils/self-format.d.ts +16 -0
- package/build/utils/self-format.js +59 -0
- package/build/utils/self-format.js.map +1 -0
- package/build/utils/self-signing.d.ts +4 -0
- package/build/utils/self-signing.js +38 -0
- package/build/utils/self-signing.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { type Hex } from "viem";
|
|
2
|
+
import type { SelfRegistrationMode } from "../config/self.js";
|
|
3
|
+
import type { CeloClientFactory } from "../clients/celo-client.js";
|
|
4
|
+
export interface SelfAgentKeyParams {
|
|
5
|
+
encryptedSelfAgentPrivateKey?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface VerifySelfAgentParams {
|
|
8
|
+
agentAddress: `0x${string}`;
|
|
9
|
+
requireAge?: 0 | 18 | 21;
|
|
10
|
+
requireOfac?: boolean;
|
|
11
|
+
requireSelfProvider?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface VerifySelfRequestParams {
|
|
14
|
+
agentSignature: Hex;
|
|
15
|
+
agentTimestamp: string;
|
|
16
|
+
method: string;
|
|
17
|
+
path: string;
|
|
18
|
+
body?: string;
|
|
19
|
+
keytype?: string;
|
|
20
|
+
agentKey?: Hex;
|
|
21
|
+
}
|
|
22
|
+
export interface RegisterSelfAgentParams {
|
|
23
|
+
mode?: SelfRegistrationMode;
|
|
24
|
+
minimumAge?: 0 | 18 | 21;
|
|
25
|
+
ofac?: boolean;
|
|
26
|
+
humanAddress?: `0x${string}`;
|
|
27
|
+
agentName?: string;
|
|
28
|
+
agentDescription?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class SelfService {
|
|
31
|
+
private readonly clientFactory;
|
|
32
|
+
private readonly envSelfAgentPrivateKey?;
|
|
33
|
+
constructor(clientFactory: CeloClientFactory, envSelfAgentPrivateKey?: `0x${string}` | undefined);
|
|
34
|
+
private resolveAgentPrivateKey;
|
|
35
|
+
private registryClient;
|
|
36
|
+
private assertProofRefreshEligible;
|
|
37
|
+
verifyAgent(params: VerifySelfAgentParams): Promise<{
|
|
38
|
+
verified: boolean;
|
|
39
|
+
agent_address: `0x${string}`;
|
|
40
|
+
reason: string;
|
|
41
|
+
network: "mainnet";
|
|
42
|
+
} | {
|
|
43
|
+
verification_strength: string;
|
|
44
|
+
network: "mainnet";
|
|
45
|
+
sibling_agent_ids: number[];
|
|
46
|
+
proof_expires_at: string | null;
|
|
47
|
+
days_until_expiry: number;
|
|
48
|
+
is_expiring_soon: boolean;
|
|
49
|
+
verified: boolean;
|
|
50
|
+
agent_address: `0x${string}`;
|
|
51
|
+
agent_id: number;
|
|
52
|
+
reason: string;
|
|
53
|
+
credentials: {
|
|
54
|
+
nationality: string | undefined;
|
|
55
|
+
older_than: number;
|
|
56
|
+
ofac_clear: boolean;
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
verification_strength: string;
|
|
60
|
+
registered_at: number;
|
|
61
|
+
agent_count: number;
|
|
62
|
+
is_proof_fresh: boolean;
|
|
63
|
+
network: "mainnet";
|
|
64
|
+
sibling_agent_ids: number[];
|
|
65
|
+
proof_expires_at: string | null;
|
|
66
|
+
days_until_expiry: number;
|
|
67
|
+
is_expiring_soon: boolean;
|
|
68
|
+
verified: boolean;
|
|
69
|
+
agent_address: `0x${string}`;
|
|
70
|
+
agent_id: number;
|
|
71
|
+
credentials: {
|
|
72
|
+
nationality: string | undefined;
|
|
73
|
+
older_than: number;
|
|
74
|
+
ofac_clear: boolean;
|
|
75
|
+
};
|
|
76
|
+
reason?: undefined;
|
|
77
|
+
}>;
|
|
78
|
+
lookupAgent(agentId: number): Promise<{
|
|
79
|
+
is_expired: boolean;
|
|
80
|
+
network: "mainnet";
|
|
81
|
+
proof_expires_at: string | null;
|
|
82
|
+
days_until_expiry: number;
|
|
83
|
+
is_expiring_soon: boolean;
|
|
84
|
+
credentialsSummary: string;
|
|
85
|
+
}>;
|
|
86
|
+
verifyRequest(params: VerifySelfRequestParams): Promise<{
|
|
87
|
+
valid: boolean;
|
|
88
|
+
reason: string;
|
|
89
|
+
agent_address?: undefined;
|
|
90
|
+
agent_id?: undefined;
|
|
91
|
+
agent_count?: undefined;
|
|
92
|
+
nullifier?: undefined;
|
|
93
|
+
credentials?: undefined;
|
|
94
|
+
note?: undefined;
|
|
95
|
+
} | {
|
|
96
|
+
valid: boolean;
|
|
97
|
+
agent_address: `0x${string}`;
|
|
98
|
+
reason: string;
|
|
99
|
+
agent_id?: undefined;
|
|
100
|
+
agent_count?: undefined;
|
|
101
|
+
nullifier?: undefined;
|
|
102
|
+
credentials?: undefined;
|
|
103
|
+
note?: undefined;
|
|
104
|
+
} | {
|
|
105
|
+
valid: boolean;
|
|
106
|
+
agent_address: `0x${string}`;
|
|
107
|
+
agent_id: number;
|
|
108
|
+
reason: string;
|
|
109
|
+
agent_count?: undefined;
|
|
110
|
+
nullifier?: undefined;
|
|
111
|
+
credentials?: undefined;
|
|
112
|
+
note?: undefined;
|
|
113
|
+
} | {
|
|
114
|
+
valid: boolean;
|
|
115
|
+
agent_address: `0x${string}`;
|
|
116
|
+
agent_id: number;
|
|
117
|
+
agent_count: number;
|
|
118
|
+
nullifier: number;
|
|
119
|
+
credentials: {
|
|
120
|
+
nationality: string | undefined;
|
|
121
|
+
older_than: number;
|
|
122
|
+
ofac_clear: boolean;
|
|
123
|
+
};
|
|
124
|
+
note: string;
|
|
125
|
+
reason?: undefined;
|
|
126
|
+
}>;
|
|
127
|
+
private getAgentInfoFromKey;
|
|
128
|
+
getIdentity(params?: SelfAgentKeyParams): Promise<{
|
|
129
|
+
expiry_warning?: string | undefined;
|
|
130
|
+
is_expired: boolean;
|
|
131
|
+
sibling_agent_ids: number[];
|
|
132
|
+
network: "mainnet";
|
|
133
|
+
proof_expires_at: string | null;
|
|
134
|
+
days_until_expiry: number;
|
|
135
|
+
is_expiring_soon: boolean;
|
|
136
|
+
registered: true;
|
|
137
|
+
address: `0x${string}`;
|
|
138
|
+
agentKey: `0x${string}`;
|
|
139
|
+
agentId: number;
|
|
140
|
+
isVerified: boolean;
|
|
141
|
+
nullifier: number;
|
|
142
|
+
agentCount: number;
|
|
143
|
+
verificationStrength: string;
|
|
144
|
+
credentials_summary: string;
|
|
145
|
+
} | {
|
|
146
|
+
message: string;
|
|
147
|
+
registered: false;
|
|
148
|
+
address: `0x${string}`;
|
|
149
|
+
network: "mainnet";
|
|
150
|
+
}>;
|
|
151
|
+
registerAgent(params?: RegisterSelfAgentParams): Promise<{
|
|
152
|
+
session_id: string;
|
|
153
|
+
agent_address: string;
|
|
154
|
+
qr_url: string;
|
|
155
|
+
deep_link: string;
|
|
156
|
+
expires_at: string;
|
|
157
|
+
instructions: string;
|
|
158
|
+
next_step: string;
|
|
159
|
+
}>;
|
|
160
|
+
checkRegistration(sessionId: string): Promise<{
|
|
161
|
+
status: "deregistered";
|
|
162
|
+
message: string;
|
|
163
|
+
proof_expires_at?: undefined;
|
|
164
|
+
agent_id?: undefined;
|
|
165
|
+
agent_address?: undefined;
|
|
166
|
+
private_key_hex?: undefined;
|
|
167
|
+
tx_hash?: undefined;
|
|
168
|
+
} | {
|
|
169
|
+
status: "refreshed";
|
|
170
|
+
proof_expires_at: string;
|
|
171
|
+
message: string;
|
|
172
|
+
agent_id?: undefined;
|
|
173
|
+
agent_address?: undefined;
|
|
174
|
+
private_key_hex?: undefined;
|
|
175
|
+
tx_hash?: undefined;
|
|
176
|
+
} | {
|
|
177
|
+
status: "verified";
|
|
178
|
+
agent_id: number;
|
|
179
|
+
agent_address: string;
|
|
180
|
+
private_key_hex: string;
|
|
181
|
+
tx_hash: string | undefined;
|
|
182
|
+
message: string;
|
|
183
|
+
proof_expires_at?: undefined;
|
|
184
|
+
} | {
|
|
185
|
+
status: "pending";
|
|
186
|
+
message: string;
|
|
187
|
+
proof_expires_at?: undefined;
|
|
188
|
+
agent_id?: undefined;
|
|
189
|
+
agent_address?: undefined;
|
|
190
|
+
private_key_hex?: undefined;
|
|
191
|
+
tx_hash?: undefined;
|
|
192
|
+
} | {
|
|
193
|
+
status: "expired";
|
|
194
|
+
message: string;
|
|
195
|
+
proof_expires_at?: undefined;
|
|
196
|
+
agent_id?: undefined;
|
|
197
|
+
agent_address?: undefined;
|
|
198
|
+
private_key_hex?: undefined;
|
|
199
|
+
tx_hash?: undefined;
|
|
200
|
+
}>;
|
|
201
|
+
refreshProof(params: SelfAgentKeyParams & {
|
|
202
|
+
agentId?: number;
|
|
203
|
+
}): Promise<{
|
|
204
|
+
next_step: string;
|
|
205
|
+
is_expired: boolean;
|
|
206
|
+
is_proof_fresh: false;
|
|
207
|
+
proof_expires_at: string | null;
|
|
208
|
+
days_until_expiry: number;
|
|
209
|
+
is_expiring_soon: boolean;
|
|
210
|
+
session_id: string;
|
|
211
|
+
agent_id: number;
|
|
212
|
+
qr_url: string;
|
|
213
|
+
deep_link: string;
|
|
214
|
+
expires_at: string;
|
|
215
|
+
instructions: string;
|
|
216
|
+
}>;
|
|
217
|
+
deregisterAgent(params?: SelfAgentKeyParams): Promise<{
|
|
218
|
+
session_id: string;
|
|
219
|
+
qr_url: string;
|
|
220
|
+
deep_link: string;
|
|
221
|
+
expires_at: string;
|
|
222
|
+
instructions: string;
|
|
223
|
+
warning: string;
|
|
224
|
+
next_step: string;
|
|
225
|
+
}>;
|
|
226
|
+
signRequest(params: SelfAgentKeyParams & {
|
|
227
|
+
method: string;
|
|
228
|
+
url: string;
|
|
229
|
+
body?: string;
|
|
230
|
+
}): Promise<{
|
|
231
|
+
headers: {
|
|
232
|
+
"x-self-agent-address": `0x${string}`;
|
|
233
|
+
"x-self-agent-signature": `0x${string}`;
|
|
234
|
+
"x-self-agent-timestamp": string;
|
|
235
|
+
};
|
|
236
|
+
instructions: string;
|
|
237
|
+
}>;
|
|
238
|
+
authenticatedFetch(params: SelfAgentKeyParams & {
|
|
239
|
+
method: string;
|
|
240
|
+
url: string;
|
|
241
|
+
body?: string;
|
|
242
|
+
contentType?: string;
|
|
243
|
+
}): Promise<{
|
|
244
|
+
status: number;
|
|
245
|
+
body: string;
|
|
246
|
+
truncated: boolean;
|
|
247
|
+
}>;
|
|
248
|
+
/** Reserved for future on-chain Self writes (e.g. metadata updates). */
|
|
249
|
+
protected taggedCalldata(data: Hex): Hex;
|
|
250
|
+
}
|