@avacuscc/sdk 0.1.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 +216 -0
- package/package.json +37 -0
- package/packages/sdk/dist/chunk-T5BAFYHX.mjs +342 -0
- package/packages/sdk/dist/index.d.mts +53 -0
- package/packages/sdk/dist/index.d.ts +53 -0
- package/packages/sdk/dist/index.js +460 -0
- package/packages/sdk/dist/index.mjs +104 -0
- package/packages/sdk/dist/sns-D0rtlsZp.d.mts +267 -0
- package/packages/sdk/dist/sns-D0rtlsZp.d.ts +267 -0
- package/packages/sdk/dist/sns.d.mts +1 -0
- package/packages/sdk/dist/sns.d.ts +1 -0
- package/packages/sdk/dist/sns.js +367 -0
- package/packages/sdk/dist/sns.mjs +16 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
type AvacusEnvironment = 'prod' | 'dev' | 'stg';
|
|
2
|
+
declare const AVACUS_ENDPOINTS: Record<AvacusEnvironment, string>;
|
|
3
|
+
interface BaseClientOptions {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
env?: AvacusEnvironment;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
interface ResolvedClientSettings {
|
|
9
|
+
env: AvacusEnvironment;
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
declare function resolveAvacusBaseUrl(options: BaseClientOptions): string;
|
|
14
|
+
declare function resolveClientSettings(options?: BaseClientOptions): ResolvedClientSettings;
|
|
15
|
+
declare function isKnownAvacusBaseUrl(baseUrl: string): boolean;
|
|
16
|
+
declare function resolveServiceUrl(baseUrl: string, servicePath: string): string;
|
|
17
|
+
|
|
18
|
+
interface AuthState {
|
|
19
|
+
accessToken?: string;
|
|
20
|
+
}
|
|
21
|
+
interface RequestOptions {
|
|
22
|
+
/**
|
|
23
|
+
* When `true`, the adapter requires a previously stored JWT access token and
|
|
24
|
+
* automatically sends it as `Authorization: Bearer <token>`.
|
|
25
|
+
*/
|
|
26
|
+
auth?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Optional per-request headers merged on top of adapter default headers.
|
|
29
|
+
*/
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
declare class HttpAdapter {
|
|
33
|
+
private readonly baseUrl;
|
|
34
|
+
private readonly headers;
|
|
35
|
+
private readonly authState;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a reusable HTTP transport bound to one service base URL.
|
|
38
|
+
*
|
|
39
|
+
* @param baseUrl Absolute base URL for the target service namespace.
|
|
40
|
+
* @param headers Default headers sent with every request.
|
|
41
|
+
* @param authState Shared mutable auth state so multiple adapters can reuse the same JWT.
|
|
42
|
+
*/
|
|
43
|
+
constructor(baseUrl: string, headers?: Record<string, string>, authState?: AuthState);
|
|
44
|
+
/**
|
|
45
|
+
* Stores the JWT access token used by authenticated requests.
|
|
46
|
+
*
|
|
47
|
+
* @param accessToken JWT returned by the authentication flow.
|
|
48
|
+
*/
|
|
49
|
+
setAccessToken(accessToken: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Removes the currently stored JWT access token from shared auth state.
|
|
52
|
+
*/
|
|
53
|
+
clearAccessToken(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the currently stored JWT access token, if any.
|
|
56
|
+
*/
|
|
57
|
+
getAccessToken(): string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Sends an HTTP GET request to a path relative to this adapter base URL.
|
|
60
|
+
*
|
|
61
|
+
* @param path Relative endpoint path.
|
|
62
|
+
* @param options Request behavior such as auth requirement and extra headers.
|
|
63
|
+
*/
|
|
64
|
+
get<T = unknown>(path: string, options?: RequestOptions): Promise<T>;
|
|
65
|
+
/**
|
|
66
|
+
* Sends an HTTP POST request with a JSON body to a path relative to this adapter base URL.
|
|
67
|
+
*
|
|
68
|
+
* @param path Relative endpoint path.
|
|
69
|
+
* @param body Serializable request payload.
|
|
70
|
+
* @param options Request behavior such as auth requirement and extra headers.
|
|
71
|
+
*/
|
|
72
|
+
post<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Builds the final request headers by combining default headers, per-request
|
|
75
|
+
* headers, and an authorization header when the request requires auth.
|
|
76
|
+
*/
|
|
77
|
+
private buildHeaders;
|
|
78
|
+
/**
|
|
79
|
+
* Resolves a relative path against the adapter base URL.
|
|
80
|
+
*/
|
|
81
|
+
private buildUrl;
|
|
82
|
+
/**
|
|
83
|
+
* Parses a JSON response and converts non-2xx responses into descriptive errors.
|
|
84
|
+
*/
|
|
85
|
+
private parseResponse;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type SignMessageFn = (message: string) => Promise<string>;
|
|
89
|
+
interface SnsLoginParams {
|
|
90
|
+
walletAddress: string;
|
|
91
|
+
signMessage: SignMessageFn;
|
|
92
|
+
}
|
|
93
|
+
interface SnsGetNonceParams {
|
|
94
|
+
walletAddress: string;
|
|
95
|
+
}
|
|
96
|
+
interface SnsAuthenticateParams {
|
|
97
|
+
walletAddress: string;
|
|
98
|
+
message: string;
|
|
99
|
+
signature: string;
|
|
100
|
+
}
|
|
101
|
+
interface SnsAuthTokenPayload {
|
|
102
|
+
wallet_address: string;
|
|
103
|
+
message: string;
|
|
104
|
+
signature: string;
|
|
105
|
+
}
|
|
106
|
+
interface SnsGetProfilesParams {
|
|
107
|
+
wallets?: string[];
|
|
108
|
+
userIds?: string[];
|
|
109
|
+
includeDevices?: boolean;
|
|
110
|
+
}
|
|
111
|
+
interface SnsAvatar {
|
|
112
|
+
id: string;
|
|
113
|
+
url: string;
|
|
114
|
+
}
|
|
115
|
+
interface SnsDevice {
|
|
116
|
+
id: string;
|
|
117
|
+
device_token: string;
|
|
118
|
+
app_name: string;
|
|
119
|
+
app_version: string;
|
|
120
|
+
platform: string;
|
|
121
|
+
}
|
|
122
|
+
interface SnsProfile {
|
|
123
|
+
id: string;
|
|
124
|
+
wallet_address: string;
|
|
125
|
+
display_name?: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
unread_count?: string;
|
|
128
|
+
avatar?: SnsAvatar;
|
|
129
|
+
devices?: SnsDevice[];
|
|
130
|
+
}
|
|
131
|
+
interface SnsCreateUserDeviceParams {
|
|
132
|
+
deviceToken?: string;
|
|
133
|
+
appName?: string;
|
|
134
|
+
appVersion?: string;
|
|
135
|
+
platform?: string;
|
|
136
|
+
}
|
|
137
|
+
interface SnsCreateUserParams {
|
|
138
|
+
walletAddress: string;
|
|
139
|
+
signMessage: SignMessageFn;
|
|
140
|
+
publicKey?: string;
|
|
141
|
+
displayName?: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
device?: SnsCreateUserDeviceParams;
|
|
144
|
+
}
|
|
145
|
+
interface SnsCreateUserWithSignatureParams {
|
|
146
|
+
walletAddress: string;
|
|
147
|
+
message: string;
|
|
148
|
+
signature: string;
|
|
149
|
+
publicKey?: string;
|
|
150
|
+
displayName?: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
device?: SnsCreateUserDeviceParams;
|
|
153
|
+
}
|
|
154
|
+
interface SnsCreateUserPayload {
|
|
155
|
+
wallet_address: string;
|
|
156
|
+
message: string;
|
|
157
|
+
signature: string;
|
|
158
|
+
public_key?: string;
|
|
159
|
+
display_name?: string;
|
|
160
|
+
description?: string;
|
|
161
|
+
device?: {
|
|
162
|
+
device_token?: string;
|
|
163
|
+
app_name?: string;
|
|
164
|
+
app_version?: string;
|
|
165
|
+
platform?: string;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
type SnsCreateUserResult = Record<string, unknown>;
|
|
169
|
+
interface SnsNonceResponse {
|
|
170
|
+
nonce: string;
|
|
171
|
+
}
|
|
172
|
+
type SnsLoginResult = Record<string, unknown>;
|
|
173
|
+
interface SnsServiceOptions {
|
|
174
|
+
baseSignedMessage?: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare const DEFAULT_BASE_SIGNED_MESSAGE = "Hi there from Avacus Wallet! Please sign this message to prove that you can access to secure chat. To stop hackers access to your secure chat, do not sign this message outside Avacus Wallet, and here's a unique message ID they can't guess: ";
|
|
178
|
+
/**
|
|
179
|
+
* Base path for all SNS endpoints. The client composes this with the resolved
|
|
180
|
+
* environment host before injecting the HTTP adapter into the service.
|
|
181
|
+
*/
|
|
182
|
+
declare const SNS_SERVICE_PATH = "1/secure-chat/";
|
|
183
|
+
declare class SnsService {
|
|
184
|
+
private readonly http;
|
|
185
|
+
private readonly options;
|
|
186
|
+
/**
|
|
187
|
+
* Creates the SNS service using a service-scoped HTTP adapter.
|
|
188
|
+
*
|
|
189
|
+
* @param http Adapter already configured for the SNS base path.
|
|
190
|
+
* @param options Optional SNS-specific behavior.
|
|
191
|
+
*/
|
|
192
|
+
constructor(http: HttpAdapter, options?: SnsServiceOptions);
|
|
193
|
+
/**
|
|
194
|
+
* Requests a one-time nonce used to construct the login signature message.
|
|
195
|
+
* This endpoint is public and does not require a JWT token.
|
|
196
|
+
*
|
|
197
|
+
* @param params Wallet identity used by the backend to mint a nonce.
|
|
198
|
+
*/
|
|
199
|
+
getNonce(params: SnsGetNonceParams): Promise<SnsNonceResponse>;
|
|
200
|
+
/**
|
|
201
|
+
* Exchanges a signed message payload for an SNS auth token.
|
|
202
|
+
* This is the low-level authentication endpoint behind `login()`.
|
|
203
|
+
*
|
|
204
|
+
* @param params Payload expected by the SNS auth API.
|
|
205
|
+
*/
|
|
206
|
+
requestAuthToken(params: SnsAuthTokenPayload): Promise<SnsLoginResult>;
|
|
207
|
+
/**
|
|
208
|
+
* Returns public user profiles for a batch of wallet addresses and/or user IDs.
|
|
209
|
+
* This endpoint is public and does not require authentication.
|
|
210
|
+
*
|
|
211
|
+
* @param params Query payload with wallet addresses and/or user IDs.
|
|
212
|
+
*/
|
|
213
|
+
getPublicProfiles(params: SnsGetProfilesParams): Promise<SnsProfile[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Creates a new SNS user account using only the inputs the application already knows:
|
|
216
|
+
* wallet address, signer callback, and optional user profile metadata.
|
|
217
|
+
* The SDK internally fetches a nonce, builds the canonical message, requests
|
|
218
|
+
* the signature, and submits the create-user payload.
|
|
219
|
+
*
|
|
220
|
+
* @param params User creation payload in SDK-friendly camelCase format.
|
|
221
|
+
*/
|
|
222
|
+
createUser(params: SnsCreateUserParams): Promise<SnsCreateUserResult>;
|
|
223
|
+
/**
|
|
224
|
+
* Low-level create-user API for callers that already have a prepared message
|
|
225
|
+
* and signature and want direct control over the exact payload.
|
|
226
|
+
*
|
|
227
|
+
* @param params Signed create-user payload.
|
|
228
|
+
*/
|
|
229
|
+
createUserWithSignature(params: SnsCreateUserWithSignatureParams): Promise<SnsCreateUserResult>;
|
|
230
|
+
/**
|
|
231
|
+
* Adapts camelCase SDK parameters to the snake_case payload expected by the backend.
|
|
232
|
+
*
|
|
233
|
+
* @param params Wallet address, signed message, and signature returned by the signer.
|
|
234
|
+
*/
|
|
235
|
+
authenticate(params: SnsAuthenticateParams): Promise<SnsLoginResult>;
|
|
236
|
+
/**
|
|
237
|
+
* Executes the full SNS login flow:
|
|
238
|
+
* 1. fetch nonce
|
|
239
|
+
* 2. build login message
|
|
240
|
+
* 3. sign message via injected signer callback
|
|
241
|
+
* 4. exchange signature for JWT
|
|
242
|
+
* 5. persist token in shared HTTP auth state
|
|
243
|
+
*
|
|
244
|
+
* @param params Wallet address and async signing callback.
|
|
245
|
+
*/
|
|
246
|
+
login(params: SnsLoginParams): Promise<SnsLoginResult>;
|
|
247
|
+
/**
|
|
248
|
+
* Builds the exact message string that the wallet must sign during login.
|
|
249
|
+
*/
|
|
250
|
+
private buildLoginMessage;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Convenience helper mirroring `sns.login(params)` for functional-style usage.
|
|
254
|
+
*/
|
|
255
|
+
declare function loginWithSns(sns: SnsService, params: SnsLoginParams): Promise<SnsLoginResult>;
|
|
256
|
+
|
|
257
|
+
interface SnsAuthClientOptions extends SnsServiceOptions, BaseClientOptions {
|
|
258
|
+
}
|
|
259
|
+
declare class SnsAuthClient extends SnsService {
|
|
260
|
+
private readonly settings;
|
|
261
|
+
private readonly usingCustomBaseUrl;
|
|
262
|
+
constructor(options?: SnsAuthClientOptions);
|
|
263
|
+
getSettings(): ResolvedClientSettings;
|
|
264
|
+
isUsingCustomBaseUrl(): boolean;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export { AVACUS_ENDPOINTS as A, type BaseClientOptions as B, resolveClientSettings as C, DEFAULT_BASE_SIGNED_MESSAGE as D, resolveServiceUrl as E, HttpAdapter as H, type RequestOptions as R, SnsService as S, type AuthState as a, type AvacusEnvironment as b, type ResolvedClientSettings as c, SNS_SERVICE_PATH as d, type SignMessageFn as e, SnsAuthClient as f, type SnsAuthClientOptions as g, type SnsAuthTokenPayload as h, type SnsAuthenticateParams as i, type SnsAvatar as j, type SnsCreateUserDeviceParams as k, type SnsCreateUserParams as l, type SnsCreateUserPayload as m, type SnsCreateUserResult as n, type SnsCreateUserWithSignatureParams as o, type SnsDevice as p, type SnsGetNonceParams as q, type SnsGetProfilesParams as r, type SnsLoginParams as s, type SnsLoginResult as t, type SnsNonceResponse as u, type SnsProfile as v, type SnsServiceOptions as w, isKnownAvacusBaseUrl as x, loginWithSns as y, resolveAvacusBaseUrl as z };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
type AvacusEnvironment = 'prod' | 'dev' | 'stg';
|
|
2
|
+
declare const AVACUS_ENDPOINTS: Record<AvacusEnvironment, string>;
|
|
3
|
+
interface BaseClientOptions {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
env?: AvacusEnvironment;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
interface ResolvedClientSettings {
|
|
9
|
+
env: AvacusEnvironment;
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
declare function resolveAvacusBaseUrl(options: BaseClientOptions): string;
|
|
14
|
+
declare function resolveClientSettings(options?: BaseClientOptions): ResolvedClientSettings;
|
|
15
|
+
declare function isKnownAvacusBaseUrl(baseUrl: string): boolean;
|
|
16
|
+
declare function resolveServiceUrl(baseUrl: string, servicePath: string): string;
|
|
17
|
+
|
|
18
|
+
interface AuthState {
|
|
19
|
+
accessToken?: string;
|
|
20
|
+
}
|
|
21
|
+
interface RequestOptions {
|
|
22
|
+
/**
|
|
23
|
+
* When `true`, the adapter requires a previously stored JWT access token and
|
|
24
|
+
* automatically sends it as `Authorization: Bearer <token>`.
|
|
25
|
+
*/
|
|
26
|
+
auth?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Optional per-request headers merged on top of adapter default headers.
|
|
29
|
+
*/
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
declare class HttpAdapter {
|
|
33
|
+
private readonly baseUrl;
|
|
34
|
+
private readonly headers;
|
|
35
|
+
private readonly authState;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a reusable HTTP transport bound to one service base URL.
|
|
38
|
+
*
|
|
39
|
+
* @param baseUrl Absolute base URL for the target service namespace.
|
|
40
|
+
* @param headers Default headers sent with every request.
|
|
41
|
+
* @param authState Shared mutable auth state so multiple adapters can reuse the same JWT.
|
|
42
|
+
*/
|
|
43
|
+
constructor(baseUrl: string, headers?: Record<string, string>, authState?: AuthState);
|
|
44
|
+
/**
|
|
45
|
+
* Stores the JWT access token used by authenticated requests.
|
|
46
|
+
*
|
|
47
|
+
* @param accessToken JWT returned by the authentication flow.
|
|
48
|
+
*/
|
|
49
|
+
setAccessToken(accessToken: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Removes the currently stored JWT access token from shared auth state.
|
|
52
|
+
*/
|
|
53
|
+
clearAccessToken(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the currently stored JWT access token, if any.
|
|
56
|
+
*/
|
|
57
|
+
getAccessToken(): string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Sends an HTTP GET request to a path relative to this adapter base URL.
|
|
60
|
+
*
|
|
61
|
+
* @param path Relative endpoint path.
|
|
62
|
+
* @param options Request behavior such as auth requirement and extra headers.
|
|
63
|
+
*/
|
|
64
|
+
get<T = unknown>(path: string, options?: RequestOptions): Promise<T>;
|
|
65
|
+
/**
|
|
66
|
+
* Sends an HTTP POST request with a JSON body to a path relative to this adapter base URL.
|
|
67
|
+
*
|
|
68
|
+
* @param path Relative endpoint path.
|
|
69
|
+
* @param body Serializable request payload.
|
|
70
|
+
* @param options Request behavior such as auth requirement and extra headers.
|
|
71
|
+
*/
|
|
72
|
+
post<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Builds the final request headers by combining default headers, per-request
|
|
75
|
+
* headers, and an authorization header when the request requires auth.
|
|
76
|
+
*/
|
|
77
|
+
private buildHeaders;
|
|
78
|
+
/**
|
|
79
|
+
* Resolves a relative path against the adapter base URL.
|
|
80
|
+
*/
|
|
81
|
+
private buildUrl;
|
|
82
|
+
/**
|
|
83
|
+
* Parses a JSON response and converts non-2xx responses into descriptive errors.
|
|
84
|
+
*/
|
|
85
|
+
private parseResponse;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type SignMessageFn = (message: string) => Promise<string>;
|
|
89
|
+
interface SnsLoginParams {
|
|
90
|
+
walletAddress: string;
|
|
91
|
+
signMessage: SignMessageFn;
|
|
92
|
+
}
|
|
93
|
+
interface SnsGetNonceParams {
|
|
94
|
+
walletAddress: string;
|
|
95
|
+
}
|
|
96
|
+
interface SnsAuthenticateParams {
|
|
97
|
+
walletAddress: string;
|
|
98
|
+
message: string;
|
|
99
|
+
signature: string;
|
|
100
|
+
}
|
|
101
|
+
interface SnsAuthTokenPayload {
|
|
102
|
+
wallet_address: string;
|
|
103
|
+
message: string;
|
|
104
|
+
signature: string;
|
|
105
|
+
}
|
|
106
|
+
interface SnsGetProfilesParams {
|
|
107
|
+
wallets?: string[];
|
|
108
|
+
userIds?: string[];
|
|
109
|
+
includeDevices?: boolean;
|
|
110
|
+
}
|
|
111
|
+
interface SnsAvatar {
|
|
112
|
+
id: string;
|
|
113
|
+
url: string;
|
|
114
|
+
}
|
|
115
|
+
interface SnsDevice {
|
|
116
|
+
id: string;
|
|
117
|
+
device_token: string;
|
|
118
|
+
app_name: string;
|
|
119
|
+
app_version: string;
|
|
120
|
+
platform: string;
|
|
121
|
+
}
|
|
122
|
+
interface SnsProfile {
|
|
123
|
+
id: string;
|
|
124
|
+
wallet_address: string;
|
|
125
|
+
display_name?: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
unread_count?: string;
|
|
128
|
+
avatar?: SnsAvatar;
|
|
129
|
+
devices?: SnsDevice[];
|
|
130
|
+
}
|
|
131
|
+
interface SnsCreateUserDeviceParams {
|
|
132
|
+
deviceToken?: string;
|
|
133
|
+
appName?: string;
|
|
134
|
+
appVersion?: string;
|
|
135
|
+
platform?: string;
|
|
136
|
+
}
|
|
137
|
+
interface SnsCreateUserParams {
|
|
138
|
+
walletAddress: string;
|
|
139
|
+
signMessage: SignMessageFn;
|
|
140
|
+
publicKey?: string;
|
|
141
|
+
displayName?: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
device?: SnsCreateUserDeviceParams;
|
|
144
|
+
}
|
|
145
|
+
interface SnsCreateUserWithSignatureParams {
|
|
146
|
+
walletAddress: string;
|
|
147
|
+
message: string;
|
|
148
|
+
signature: string;
|
|
149
|
+
publicKey?: string;
|
|
150
|
+
displayName?: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
device?: SnsCreateUserDeviceParams;
|
|
153
|
+
}
|
|
154
|
+
interface SnsCreateUserPayload {
|
|
155
|
+
wallet_address: string;
|
|
156
|
+
message: string;
|
|
157
|
+
signature: string;
|
|
158
|
+
public_key?: string;
|
|
159
|
+
display_name?: string;
|
|
160
|
+
description?: string;
|
|
161
|
+
device?: {
|
|
162
|
+
device_token?: string;
|
|
163
|
+
app_name?: string;
|
|
164
|
+
app_version?: string;
|
|
165
|
+
platform?: string;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
type SnsCreateUserResult = Record<string, unknown>;
|
|
169
|
+
interface SnsNonceResponse {
|
|
170
|
+
nonce: string;
|
|
171
|
+
}
|
|
172
|
+
type SnsLoginResult = Record<string, unknown>;
|
|
173
|
+
interface SnsServiceOptions {
|
|
174
|
+
baseSignedMessage?: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare const DEFAULT_BASE_SIGNED_MESSAGE = "Hi there from Avacus Wallet! Please sign this message to prove that you can access to secure chat. To stop hackers access to your secure chat, do not sign this message outside Avacus Wallet, and here's a unique message ID they can't guess: ";
|
|
178
|
+
/**
|
|
179
|
+
* Base path for all SNS endpoints. The client composes this with the resolved
|
|
180
|
+
* environment host before injecting the HTTP adapter into the service.
|
|
181
|
+
*/
|
|
182
|
+
declare const SNS_SERVICE_PATH = "1/secure-chat/";
|
|
183
|
+
declare class SnsService {
|
|
184
|
+
private readonly http;
|
|
185
|
+
private readonly options;
|
|
186
|
+
/**
|
|
187
|
+
* Creates the SNS service using a service-scoped HTTP adapter.
|
|
188
|
+
*
|
|
189
|
+
* @param http Adapter already configured for the SNS base path.
|
|
190
|
+
* @param options Optional SNS-specific behavior.
|
|
191
|
+
*/
|
|
192
|
+
constructor(http: HttpAdapter, options?: SnsServiceOptions);
|
|
193
|
+
/**
|
|
194
|
+
* Requests a one-time nonce used to construct the login signature message.
|
|
195
|
+
* This endpoint is public and does not require a JWT token.
|
|
196
|
+
*
|
|
197
|
+
* @param params Wallet identity used by the backend to mint a nonce.
|
|
198
|
+
*/
|
|
199
|
+
getNonce(params: SnsGetNonceParams): Promise<SnsNonceResponse>;
|
|
200
|
+
/**
|
|
201
|
+
* Exchanges a signed message payload for an SNS auth token.
|
|
202
|
+
* This is the low-level authentication endpoint behind `login()`.
|
|
203
|
+
*
|
|
204
|
+
* @param params Payload expected by the SNS auth API.
|
|
205
|
+
*/
|
|
206
|
+
requestAuthToken(params: SnsAuthTokenPayload): Promise<SnsLoginResult>;
|
|
207
|
+
/**
|
|
208
|
+
* Returns public user profiles for a batch of wallet addresses and/or user IDs.
|
|
209
|
+
* This endpoint is public and does not require authentication.
|
|
210
|
+
*
|
|
211
|
+
* @param params Query payload with wallet addresses and/or user IDs.
|
|
212
|
+
*/
|
|
213
|
+
getPublicProfiles(params: SnsGetProfilesParams): Promise<SnsProfile[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Creates a new SNS user account using only the inputs the application already knows:
|
|
216
|
+
* wallet address, signer callback, and optional user profile metadata.
|
|
217
|
+
* The SDK internally fetches a nonce, builds the canonical message, requests
|
|
218
|
+
* the signature, and submits the create-user payload.
|
|
219
|
+
*
|
|
220
|
+
* @param params User creation payload in SDK-friendly camelCase format.
|
|
221
|
+
*/
|
|
222
|
+
createUser(params: SnsCreateUserParams): Promise<SnsCreateUserResult>;
|
|
223
|
+
/**
|
|
224
|
+
* Low-level create-user API for callers that already have a prepared message
|
|
225
|
+
* and signature and want direct control over the exact payload.
|
|
226
|
+
*
|
|
227
|
+
* @param params Signed create-user payload.
|
|
228
|
+
*/
|
|
229
|
+
createUserWithSignature(params: SnsCreateUserWithSignatureParams): Promise<SnsCreateUserResult>;
|
|
230
|
+
/**
|
|
231
|
+
* Adapts camelCase SDK parameters to the snake_case payload expected by the backend.
|
|
232
|
+
*
|
|
233
|
+
* @param params Wallet address, signed message, and signature returned by the signer.
|
|
234
|
+
*/
|
|
235
|
+
authenticate(params: SnsAuthenticateParams): Promise<SnsLoginResult>;
|
|
236
|
+
/**
|
|
237
|
+
* Executes the full SNS login flow:
|
|
238
|
+
* 1. fetch nonce
|
|
239
|
+
* 2. build login message
|
|
240
|
+
* 3. sign message via injected signer callback
|
|
241
|
+
* 4. exchange signature for JWT
|
|
242
|
+
* 5. persist token in shared HTTP auth state
|
|
243
|
+
*
|
|
244
|
+
* @param params Wallet address and async signing callback.
|
|
245
|
+
*/
|
|
246
|
+
login(params: SnsLoginParams): Promise<SnsLoginResult>;
|
|
247
|
+
/**
|
|
248
|
+
* Builds the exact message string that the wallet must sign during login.
|
|
249
|
+
*/
|
|
250
|
+
private buildLoginMessage;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Convenience helper mirroring `sns.login(params)` for functional-style usage.
|
|
254
|
+
*/
|
|
255
|
+
declare function loginWithSns(sns: SnsService, params: SnsLoginParams): Promise<SnsLoginResult>;
|
|
256
|
+
|
|
257
|
+
interface SnsAuthClientOptions extends SnsServiceOptions, BaseClientOptions {
|
|
258
|
+
}
|
|
259
|
+
declare class SnsAuthClient extends SnsService {
|
|
260
|
+
private readonly settings;
|
|
261
|
+
private readonly usingCustomBaseUrl;
|
|
262
|
+
constructor(options?: SnsAuthClientOptions);
|
|
263
|
+
getSettings(): ResolvedClientSettings;
|
|
264
|
+
isUsingCustomBaseUrl(): boolean;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export { AVACUS_ENDPOINTS as A, type BaseClientOptions as B, resolveClientSettings as C, DEFAULT_BASE_SIGNED_MESSAGE as D, resolveServiceUrl as E, HttpAdapter as H, type RequestOptions as R, SnsService as S, type AuthState as a, type AvacusEnvironment as b, type ResolvedClientSettings as c, SNS_SERVICE_PATH as d, type SignMessageFn as e, SnsAuthClient as f, type SnsAuthClientOptions as g, type SnsAuthTokenPayload as h, type SnsAuthenticateParams as i, type SnsAvatar as j, type SnsCreateUserDeviceParams as k, type SnsCreateUserParams as l, type SnsCreateUserPayload as m, type SnsCreateUserResult as n, type SnsCreateUserWithSignatureParams as o, type SnsDevice as p, type SnsGetNonceParams as q, type SnsGetProfilesParams as r, type SnsLoginParams as s, type SnsLoginResult as t, type SnsNonceResponse as u, type SnsProfile as v, type SnsServiceOptions as w, isKnownAvacusBaseUrl as x, loginWithSns as y, resolveAvacusBaseUrl as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { A as AVACUS_ENDPOINTS, a as AuthState, b as AvacusEnvironment, D as DEFAULT_BASE_SIGNED_MESSAGE, H as HttpAdapter, R as RequestOptions, c as ResolvedClientSettings, e as SignMessageFn, f as SnsAuthClient, g as SnsAuthClientOptions, h as SnsAuthTokenPayload, i as SnsAuthenticateParams, j as SnsAvatar, k as SnsCreateUserDeviceParams, l as SnsCreateUserParams, m as SnsCreateUserPayload, n as SnsCreateUserResult, o as SnsCreateUserWithSignatureParams, p as SnsDevice, q as SnsGetNonceParams, r as SnsGetProfilesParams, s as SnsLoginParams, t as SnsLoginResult, u as SnsNonceResponse, v as SnsProfile, S as SnsService, w as SnsServiceOptions, y as loginWithSns } from './sns-D0rtlsZp.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { A as AVACUS_ENDPOINTS, a as AuthState, b as AvacusEnvironment, D as DEFAULT_BASE_SIGNED_MESSAGE, H as HttpAdapter, R as RequestOptions, c as ResolvedClientSettings, e as SignMessageFn, f as SnsAuthClient, g as SnsAuthClientOptions, h as SnsAuthTokenPayload, i as SnsAuthenticateParams, j as SnsAvatar, k as SnsCreateUserDeviceParams, l as SnsCreateUserParams, m as SnsCreateUserPayload, n as SnsCreateUserResult, o as SnsCreateUserWithSignatureParams, p as SnsDevice, q as SnsGetNonceParams, r as SnsGetProfilesParams, s as SnsLoginParams, t as SnsLoginResult, u as SnsNonceResponse, v as SnsProfile, S as SnsService, w as SnsServiceOptions, y as loginWithSns } from './sns-D0rtlsZp.js';
|