@bananalink-sdk/protocol 1.2.7

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.
Files changed (158) hide show
  1. package/README.md +604 -0
  2. package/dist/chunk-32OWUOZ3.js +308 -0
  3. package/dist/chunk-32OWUOZ3.js.map +1 -0
  4. package/dist/chunk-65HNHRJK.cjs +123 -0
  5. package/dist/chunk-65HNHRJK.cjs.map +1 -0
  6. package/dist/chunk-7KYDLL3B.js +480 -0
  7. package/dist/chunk-7KYDLL3B.js.map +1 -0
  8. package/dist/chunk-A6FLEJ7R.cjs +62 -0
  9. package/dist/chunk-A6FLEJ7R.cjs.map +1 -0
  10. package/dist/chunk-CUJK7ZTS.js +217 -0
  11. package/dist/chunk-CUJK7ZTS.js.map +1 -0
  12. package/dist/chunk-GI3BUPIH.cjs +236 -0
  13. package/dist/chunk-GI3BUPIH.cjs.map +1 -0
  14. package/dist/chunk-JXHV66Q4.js +106 -0
  15. package/dist/chunk-JXHV66Q4.js.map +1 -0
  16. package/dist/chunk-KNGZKGRS.cjs +552 -0
  17. package/dist/chunk-KNGZKGRS.cjs.map +1 -0
  18. package/dist/chunk-LELPCIE7.js +840 -0
  19. package/dist/chunk-LELPCIE7.js.map +1 -0
  20. package/dist/chunk-MCZG7QEM.cjs +310 -0
  21. package/dist/chunk-MCZG7QEM.cjs.map +1 -0
  22. package/dist/chunk-TCVKC227.js +56 -0
  23. package/dist/chunk-TCVKC227.js.map +1 -0
  24. package/dist/chunk-VXLUSU5B.cjs +856 -0
  25. package/dist/chunk-VXLUSU5B.cjs.map +1 -0
  26. package/dist/chunk-WCQVDF3K.js +12 -0
  27. package/dist/chunk-WCQVDF3K.js.map +1 -0
  28. package/dist/chunk-WGEGR3DF.cjs +15 -0
  29. package/dist/chunk-WGEGR3DF.cjs.map +1 -0
  30. package/dist/client-session-claim-3QF3noOr.d.ts +197 -0
  31. package/dist/client-session-claim-C4lUik3b.d.cts +197 -0
  32. package/dist/core-DMhuNfoz.d.cts +62 -0
  33. package/dist/core-DMhuNfoz.d.ts +62 -0
  34. package/dist/crypto/providers/noble-provider.cjs +14 -0
  35. package/dist/crypto/providers/noble-provider.cjs.map +1 -0
  36. package/dist/crypto/providers/noble-provider.d.cts +30 -0
  37. package/dist/crypto/providers/noble-provider.d.ts +30 -0
  38. package/dist/crypto/providers/noble-provider.js +5 -0
  39. package/dist/crypto/providers/noble-provider.js.map +1 -0
  40. package/dist/crypto/providers/node-provider.cjs +308 -0
  41. package/dist/crypto/providers/node-provider.cjs.map +1 -0
  42. package/dist/crypto/providers/node-provider.d.cts +32 -0
  43. package/dist/crypto/providers/node-provider.d.ts +32 -0
  44. package/dist/crypto/providers/node-provider.js +306 -0
  45. package/dist/crypto/providers/node-provider.js.map +1 -0
  46. package/dist/crypto/providers/quickcrypto-provider.cjs +339 -0
  47. package/dist/crypto/providers/quickcrypto-provider.cjs.map +1 -0
  48. package/dist/crypto/providers/quickcrypto-provider.d.cts +34 -0
  49. package/dist/crypto/providers/quickcrypto-provider.d.ts +34 -0
  50. package/dist/crypto/providers/quickcrypto-provider.js +337 -0
  51. package/dist/crypto/providers/quickcrypto-provider.js.map +1 -0
  52. package/dist/crypto/providers/webcrypto-provider.cjs +310 -0
  53. package/dist/crypto/providers/webcrypto-provider.cjs.map +1 -0
  54. package/dist/crypto/providers/webcrypto-provider.d.cts +30 -0
  55. package/dist/crypto/providers/webcrypto-provider.d.ts +30 -0
  56. package/dist/crypto/providers/webcrypto-provider.js +308 -0
  57. package/dist/crypto/providers/webcrypto-provider.js.map +1 -0
  58. package/dist/crypto-BUS06Qz-.d.cts +40 -0
  59. package/dist/crypto-BUS06Qz-.d.ts +40 -0
  60. package/dist/crypto-export.cjs +790 -0
  61. package/dist/crypto-export.cjs.map +1 -0
  62. package/dist/crypto-export.d.cts +257 -0
  63. package/dist/crypto-export.d.ts +257 -0
  64. package/dist/crypto-export.js +709 -0
  65. package/dist/crypto-export.js.map +1 -0
  66. package/dist/crypto-provider-deYoVIxi.d.cts +36 -0
  67. package/dist/crypto-provider-deYoVIxi.d.ts +36 -0
  68. package/dist/index.cjs +615 -0
  69. package/dist/index.cjs.map +1 -0
  70. package/dist/index.d.cts +379 -0
  71. package/dist/index.d.ts +379 -0
  72. package/dist/index.js +504 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/schemas-export.cjs +294 -0
  75. package/dist/schemas-export.cjs.map +1 -0
  76. package/dist/schemas-export.d.cts +1598 -0
  77. package/dist/schemas-export.d.ts +1598 -0
  78. package/dist/schemas-export.js +5 -0
  79. package/dist/schemas-export.js.map +1 -0
  80. package/dist/siwe-export.cjs +237 -0
  81. package/dist/siwe-export.cjs.map +1 -0
  82. package/dist/siwe-export.d.cts +27 -0
  83. package/dist/siwe-export.d.ts +27 -0
  84. package/dist/siwe-export.js +228 -0
  85. package/dist/siwe-export.js.map +1 -0
  86. package/dist/testing.cjs +54 -0
  87. package/dist/testing.cjs.map +1 -0
  88. package/dist/testing.d.cts +20 -0
  89. package/dist/testing.d.ts +20 -0
  90. package/dist/testing.js +51 -0
  91. package/dist/testing.js.map +1 -0
  92. package/dist/validation-export.cjs +359 -0
  93. package/dist/validation-export.cjs.map +1 -0
  94. package/dist/validation-export.d.cts +3 -0
  95. package/dist/validation-export.d.ts +3 -0
  96. package/dist/validation-export.js +6 -0
  97. package/dist/validation-export.js.map +1 -0
  98. package/dist/validators-export.cjs +73 -0
  99. package/dist/validators-export.cjs.map +1 -0
  100. package/dist/validators-export.d.cts +37 -0
  101. package/dist/validators-export.d.ts +37 -0
  102. package/dist/validators-export.js +4 -0
  103. package/dist/validators-export.js.map +1 -0
  104. package/package.json +140 -0
  105. package/src/constants/index.ts +205 -0
  106. package/src/crypto/context.ts +228 -0
  107. package/src/crypto/diagnostics.ts +772 -0
  108. package/src/crypto/errors.ts +114 -0
  109. package/src/crypto/index.ts +89 -0
  110. package/src/crypto/payload-handler.ts +102 -0
  111. package/src/crypto/providers/compliance-provider.ts +579 -0
  112. package/src/crypto/providers/factory.ts +204 -0
  113. package/src/crypto/providers/index.ts +44 -0
  114. package/src/crypto/providers/noble-provider.ts +392 -0
  115. package/src/crypto/providers/node-provider.ts +433 -0
  116. package/src/crypto/providers/quickcrypto-provider.ts +483 -0
  117. package/src/crypto/providers/registry.ts +129 -0
  118. package/src/crypto/providers/webcrypto-provider.ts +364 -0
  119. package/src/crypto/session-security.ts +185 -0
  120. package/src/crypto/types.ts +93 -0
  121. package/src/crypto/utils.ts +190 -0
  122. package/src/crypto-export.ts +21 -0
  123. package/src/index.ts +38 -0
  124. package/src/schemas/auth.ts +60 -0
  125. package/src/schemas/client-messages.ts +57 -0
  126. package/src/schemas/core.ts +144 -0
  127. package/src/schemas/crypto.ts +65 -0
  128. package/src/schemas/discovery.ts +79 -0
  129. package/src/schemas/index.ts +239 -0
  130. package/src/schemas/relay-messages.ts +45 -0
  131. package/src/schemas/wallet-messages.ts +177 -0
  132. package/src/schemas-export.ts +23 -0
  133. package/src/siwe-export.ts +27 -0
  134. package/src/testing.ts +71 -0
  135. package/src/types/auth.ts +60 -0
  136. package/src/types/client-messages.ts +84 -0
  137. package/src/types/core.ts +131 -0
  138. package/src/types/crypto-provider.ts +264 -0
  139. package/src/types/crypto.ts +90 -0
  140. package/src/types/discovery.ts +50 -0
  141. package/src/types/errors.ts +87 -0
  142. package/src/types/index.ts +197 -0
  143. package/src/types/post-auth-operations.ts +363 -0
  144. package/src/types/providers.ts +72 -0
  145. package/src/types/relay-messages.ts +60 -0
  146. package/src/types/request-lifecycle.ts +161 -0
  147. package/src/types/signing-operations.ts +99 -0
  148. package/src/types/wallet-messages.ts +251 -0
  149. package/src/utils/client-session-claim.ts +188 -0
  150. package/src/utils/index.ts +54 -0
  151. package/src/utils/public-keys.ts +49 -0
  152. package/src/utils/siwe.ts +362 -0
  153. package/src/utils/url-decoding.ts +126 -0
  154. package/src/utils/url-encoding.ts +144 -0
  155. package/src/utils/wallet-session-claim.ts +188 -0
  156. package/src/validation-export.ts +32 -0
  157. package/src/validators/index.ts +222 -0
  158. package/src/validators-export.ts +8 -0
@@ -0,0 +1,379 @@
1
+ import { D as DAppMetadata, S as SessionConfig } from './core-DMhuNfoz.js';
2
+ export { C as CreateSessionRequest, e as CreateSessionResponse, a as SIWEFields, c as SecurityPolicy, d as SessionMetadata, b as SessionOptions } from './core-DMhuNfoz.js';
3
+ export { C as CryptoParameters, b as CryptoPayload, E as Encryption, a as KeyDerivation, K as KeyExchange, P as PublicKeyJWK } from './crypto-BUS06Qz-.js';
4
+ import { Q as QRPayload } from './client-session-claim-3QF3noOr.js';
5
+ export { A as AuthenticateConnectionPayload, j as AuthenticationData, e as ClaimSessionPayload, F as ClientMessageEnvelope, B as ClientMessagePayload, y as ClientReconnectPayload, C as ClientSessionClaim, N as ClientSessionClaimManager, b as ClientSessionClaimStorage, z as CloseSessionPayload, n as ConnectionAuthenticatedMessage, m as ConnectionRejectedMessage, f as ConnectionRejectedPayload, D as DisplayInfo, E as EncryptedPayload, P as PrefetchMetadataPayload, o as PrefetchMetadataResponse, i as RejectionData, c as RelayMessage, R as RelayMessageType, p as RelayToDAppMessage, l as WalletHandshakeMessage, d as WalletMessageEnvelope, h as WalletMessagePayload, k as WalletMetadata, g as WalletReconnectPayload, W as WalletSessionClaim, I as WalletSessionClaimManager, a as WalletSessionClaimStorage, O as createClientMessageEnvelope, J as createWalletMessageEnvelope, t as isAuthenticateConnectionPayload, q as isClaimSessionPayload, G as isClientReconnectPayload, H as isCloseSessionPayload, x as isConnectionAuthenticatedMessage, w as isConnectionRejectedMessage, s as isConnectionRejectedPayload, r as isPrefetchMetadataPayload, v as isWalletHandshakeMessage, u as isWalletReconnectPayload, S as stripClientSessionClaim, K as stripWalletSessionClaim, L as validateClaimTimestamp, T as validateClientClaimTimestamp, U as validateClientMessageEnvelope, M as validateWalletMessageEnvelope } from './client-session-claim-3QF3noOr.js';
6
+ export { SIWEMessageOptions } from './siwe-export.js';
7
+
8
+ type ProviderType = 'uwebsockets' | 'websocket' | 'pusher' | 'ably';
9
+ interface ProviderConfig {
10
+ providerId: string;
11
+ type: ProviderType;
12
+ enabled: boolean;
13
+ priority: number;
14
+ config: UWebSocketConfig | PusherConfig | AblyConfig;
15
+ features?: string[];
16
+ }
17
+ interface ProviderConfigResponse {
18
+ providers: ProviderConfig[];
19
+ ttl: number;
20
+ lastUpdated: string;
21
+ }
22
+ interface UWebSocketConfig {
23
+ relayUrl: string;
24
+ maxConnections?: number;
25
+ reconnectInterval?: number;
26
+ heartbeatInterval?: number;
27
+ maxPayloadLength?: number;
28
+ idleTimeout?: number;
29
+ fallbackUrl?: string;
30
+ }
31
+ interface PusherConfig {
32
+ appKey: string;
33
+ key?: string;
34
+ cluster: string;
35
+ encrypted?: boolean;
36
+ authEndpoint?: string;
37
+ useTLS?: boolean;
38
+ host?: string;
39
+ timeout?: number;
40
+ }
41
+ interface AblyConfig {
42
+ apiKey: string;
43
+ key?: string;
44
+ clientId?: string;
45
+ authUrl?: string;
46
+ environment?: string;
47
+ tls?: boolean;
48
+ timeout?: number;
49
+ clientOptions?: Record<string, unknown>;
50
+ }
51
+
52
+ interface SessionClosedAck {
53
+ type: 'session_closed_ack';
54
+ timestamp: number;
55
+ }
56
+ interface SessionClosedNotification {
57
+ type: 'session_closed_notification';
58
+ closedBy: 'client' | 'wallet';
59
+ reason?: string;
60
+ timestamp: number;
61
+ }
62
+ interface ReconnectedMessage {
63
+ type: 'reconnected';
64
+ queuedMessages: number;
65
+ timestamp: number;
66
+ }
67
+ type RelayNotificationMessage = SessionClosedAck | SessionClosedNotification | ReconnectedMessage;
68
+ declare function isSessionClosedAck(message: RelayNotificationMessage): message is SessionClosedAck;
69
+ declare function isSessionClosedNotification(message: RelayNotificationMessage): message is SessionClosedNotification;
70
+ declare function isReconnectedMessage(message: RelayNotificationMessage): message is ReconnectedMessage;
71
+
72
+ type BananaLinkErrorCode = 'SESSION_EXPIRED' | 'SESSION_NOT_FOUND' | 'SESSION_ALREADY_CLAIMED' | 'INVALID_SESSION_CLAIM' | 'INVALID_CLIENT_CLAIM' | 'SESSION_TOKEN_EXPIRED' | 'SESSION_CLOSED' | 'ENCRYPTION_FAILED' | 'DECRYPTION_FAILED' | 'INVALID_SIGNATURE' | 'NETWORK_ERROR' | 'RELAY_ERROR' | 'MESSAGE_QUEUE_FULL' | 'RATE_LIMIT_EXCEEDED' | 'ORIGIN_MISMATCH' | 'REQUEST_PENDING' | 'REQUEST_NOT_FOUND' | 'REQUEST_EXPIRED' | 'REQUEST_INVALID' | 'REQUEST_TIMEOUT' | 'SIGNING_FAILED' | 'SIGNING_REJECTED' | 'TRANSACTION_INVALID' | 'CHAIN_MISMATCH';
73
+ interface ProtocolErrorResponse {
74
+ type: 'error';
75
+ code: string;
76
+ message: string;
77
+ details?: unknown;
78
+ }
79
+ type WalletRejectionReason = 'user_declined' | 'untrusted_dapp' | 'unsupported_chain' | 'insufficient_balance' | 'wallet_locked' | 'timeout' | 'security_warning' | 'rate_limited';
80
+ type RelayRejectionReason = 'session_already_claimed' | 'invalid_credentials' | 'session_expired' | 'session_closed' | 'dapp_metadata_missing' | 'encryption_mismatch' | 'relay_overloaded';
81
+ type RejectionReason = WalletRejectionReason | RelayRejectionReason;
82
+
83
+ type SessionState = 'created' | 'claimed' | 'authenticated' | 'active' | 'disconnected' | 'closed' | 'expired' | 'rejected';
84
+ interface SessionInfo {
85
+ sessionId: string;
86
+ state: SessionState;
87
+ address?: string;
88
+ dappId: string;
89
+ dappInfo: Pick<DAppMetadata, 'name' | 'url'>;
90
+ sessionConfig?: SessionConfig;
91
+ createdAt: string;
92
+ lastActivity: string;
93
+ expiresAt?: string;
94
+ }
95
+ interface SessionSecurity {
96
+ sharedSecret: CryptoKey;
97
+ sessionId: string;
98
+ }
99
+ interface OriginProof {
100
+ domain: string;
101
+ timestamp: number;
102
+ signature: string;
103
+ }
104
+
105
+ declare const PROTOCOL_VERSION = 1;
106
+ declare const DEEPLINK_SCHEME = "bananalink";
107
+ declare const DEFAULT_RELAY_URL = "wss://relay.banana.link/v1";
108
+ declare const FRUITS: readonly ["🍌", "🍎", "🍊", "🍇", "🍓", "🍑", "🍒", "🍉", "🥝", "🍍", "🥭", "🥥", "🫐", "🍈", "🍋", "🥑"];
109
+ declare const DEFAULT_TIMEOUTS: {
110
+ readonly sessionTimeout: number;
111
+ readonly requestTimeout: number;
112
+ readonly connectionTimeout: number;
113
+ readonly qrCodeTimeout: number;
114
+ };
115
+ declare const PROTOCOL_V2_TIMEOUTS: {
116
+ readonly sessionCreation: number;
117
+ readonly claimSession: number;
118
+ readonly prefetchMetadata: number;
119
+ readonly userApproval: number;
120
+ readonly authentication: number;
121
+ readonly sessionTTL: number;
122
+ readonly reconnectionWindow: number;
123
+ readonly messageQueueRetention: number;
124
+ readonly websocketHeartbeat: number;
125
+ readonly gracefulCloseTimeout: number;
126
+ readonly signMessage: number;
127
+ readonly signTypedData: number;
128
+ readonly signTransaction: number;
129
+ };
130
+ declare const MESSAGE_QUEUE_CONFIG: {
131
+ readonly maxQueueSize: 100;
132
+ readonly retentionTime: number;
133
+ readonly overflowStrategy: "drop_oldest";
134
+ };
135
+ declare const SECURITY_LIMITS: {
136
+ readonly maxConcurrentSessions: 5;
137
+ readonly maxSessionAge: number;
138
+ readonly minNonceLength: 8;
139
+ readonly maxMessageSize: number;
140
+ readonly maxResourcesCount: 10;
141
+ readonly rateLimit: {
142
+ readonly requestsPerMinute: 60;
143
+ readonly sessionsPerHour: 100;
144
+ };
145
+ };
146
+ declare const CRYPTO_CONSTANTS: {
147
+ readonly keyLength: 256;
148
+ readonly ivLength: 12;
149
+ readonly tagLength: 16;
150
+ readonly curve: "P-256";
151
+ readonly algorithm: "AES-GCM";
152
+ readonly hashAlgorithm: "SHA-256";
153
+ };
154
+ declare const MESSAGE_FORMAT: {
155
+ readonly version: "1";
156
+ readonly encoding: "utf8";
157
+ readonly lineBreak: "\n";
158
+ readonly resourcePrefix: "- ";
159
+ };
160
+ declare const WS_MESSAGE_TYPES: {
161
+ readonly subscribe: "sub";
162
+ readonly publish: "pub";
163
+ readonly acknowledge: "ack";
164
+ readonly error: "error";
165
+ };
166
+ declare const HTTP_ENDPOINTS: {
167
+ readonly messages: "/v1/messages";
168
+ readonly session: "/v1/session";
169
+ readonly health: "/v1/health";
170
+ };
171
+ declare const ERROR_MESSAGES: {
172
+ readonly SESSION_EXPIRED: "Session has expired";
173
+ readonly SESSION_NOT_FOUND: "Session ID invalid or expired";
174
+ readonly SESSION_ALREADY_CLAIMED: "Session already claimed by another wallet";
175
+ readonly INVALID_SESSION_CLAIM: "Wallet does not own this session";
176
+ readonly INVALID_CLIENT_CLAIM: "Client session claim does not match";
177
+ readonly SESSION_TOKEN_EXPIRED: "Session token TTL exceeded";
178
+ readonly SESSION_CLOSED: "Session has been closed";
179
+ readonly ENCRYPTION_FAILED: "Message encryption failed";
180
+ readonly DECRYPTION_FAILED: "Cannot decrypt message";
181
+ readonly INVALID_SIGNATURE: "Invalid signature";
182
+ readonly NETWORK_ERROR: "Network connection error";
183
+ readonly RELAY_ERROR: "Internal relay server error";
184
+ readonly MESSAGE_QUEUE_FULL: "Too many queued messages (>100)";
185
+ readonly RATE_LIMIT_EXCEEDED: "Rate limit exceeded";
186
+ readonly ORIGIN_MISMATCH: "Origin verification failed";
187
+ readonly REQUEST_PENDING: "Another signing request is already pending";
188
+ readonly REQUEST_NOT_FOUND: "Request ID not found or already processed";
189
+ readonly REQUEST_EXPIRED: "Request expired before completion";
190
+ readonly REQUEST_INVALID: "Request data is invalid or malformed";
191
+ readonly REQUEST_TIMEOUT: "Request timed out waiting for wallet response";
192
+ readonly SIGNING_FAILED: "Cryptographic signing operation failed";
193
+ readonly SIGNING_REJECTED: "User rejected the signing request";
194
+ readonly TRANSACTION_INVALID: "Transaction parameters validation failed";
195
+ readonly CHAIN_MISMATCH: "Requested chain ID does not match wallet chain";
196
+ };
197
+ declare const QR_CONFIG: {
198
+ readonly size: 256;
199
+ readonly margin: 4;
200
+ readonly errorCorrectionLevel: "M";
201
+ readonly type: "image/png";
202
+ };
203
+ declare const DEEP_LINK_CONFIG: {
204
+ readonly scheme: "bananalink";
205
+ readonly host: "connect";
206
+ readonly universal: "https://bananalink.app";
207
+ };
208
+ declare const NETWORK_CONFIG: {
209
+ readonly SUPPORTED_CHAINS: readonly [1, 5, 137, 80001, 42161, 421613, 10, 420];
210
+ readonly DEFAULT_CHAIN_ID: 1;
211
+ readonly CHAIN_NAMES: {
212
+ readonly 1: "Ethereum Mainnet";
213
+ readonly 5: "Goerli Testnet";
214
+ readonly 137: "Polygon Mainnet";
215
+ readonly 80001: "Polygon Mumbai";
216
+ readonly 42161: "Arbitrum One";
217
+ readonly 421613: "Arbitrum Goerli";
218
+ readonly 10: "Optimism";
219
+ readonly 420: "Optimism Goerli";
220
+ };
221
+ };
222
+ declare const DEV_CONFIG: {
223
+ readonly logLevel: "debug";
224
+ readonly enableMocks: false;
225
+ readonly skipValidation: false;
226
+ readonly allowLocalhost: true;
227
+ };
228
+ declare const BANANALINK_CONSTANTS: {
229
+ readonly PROTOCOL_VERSION: 1;
230
+ readonly PACKAGE_NAME: "@bananalink-sdk/protocol";
231
+ readonly DEEPLINK_SCHEME: "bananalink";
232
+ readonly DEFAULT_RELAY_URL: "wss://relay.banana.link/v1";
233
+ readonly FRUITS: readonly ["🍌", "🍎", "🍊", "🍇", "🍓", "🍑", "🍒", "🍉", "🥝", "🍍", "🥭", "🥥", "🫐", "🍈", "🍋", "🥑"];
234
+ readonly DEFAULT_TIMEOUTS: {
235
+ readonly sessionTimeout: number;
236
+ readonly requestTimeout: number;
237
+ readonly connectionTimeout: number;
238
+ readonly qrCodeTimeout: number;
239
+ };
240
+ readonly PROTOCOL_V2_TIMEOUTS: {
241
+ readonly sessionCreation: number;
242
+ readonly claimSession: number;
243
+ readonly prefetchMetadata: number;
244
+ readonly userApproval: number;
245
+ readonly authentication: number;
246
+ readonly sessionTTL: number;
247
+ readonly reconnectionWindow: number;
248
+ readonly messageQueueRetention: number;
249
+ readonly websocketHeartbeat: number;
250
+ readonly gracefulCloseTimeout: number;
251
+ readonly signMessage: number;
252
+ readonly signTypedData: number;
253
+ readonly signTransaction: number;
254
+ };
255
+ readonly MESSAGE_QUEUE_CONFIG: {
256
+ readonly maxQueueSize: 100;
257
+ readonly retentionTime: number;
258
+ readonly overflowStrategy: "drop_oldest";
259
+ };
260
+ readonly SECURITY_LIMITS: {
261
+ readonly maxConcurrentSessions: 5;
262
+ readonly maxSessionAge: number;
263
+ readonly minNonceLength: 8;
264
+ readonly maxMessageSize: number;
265
+ readonly maxResourcesCount: 10;
266
+ readonly rateLimit: {
267
+ readonly requestsPerMinute: 60;
268
+ readonly sessionsPerHour: 100;
269
+ };
270
+ };
271
+ readonly CRYPTO_CONSTANTS: {
272
+ readonly keyLength: 256;
273
+ readonly ivLength: 12;
274
+ readonly tagLength: 16;
275
+ readonly curve: "P-256";
276
+ readonly algorithm: "AES-GCM";
277
+ readonly hashAlgorithm: "SHA-256";
278
+ };
279
+ readonly MESSAGE_FORMAT: {
280
+ readonly version: "1";
281
+ readonly encoding: "utf8";
282
+ readonly lineBreak: "\n";
283
+ readonly resourcePrefix: "- ";
284
+ };
285
+ readonly WS_MESSAGE_TYPES: {
286
+ readonly subscribe: "sub";
287
+ readonly publish: "pub";
288
+ readonly acknowledge: "ack";
289
+ readonly error: "error";
290
+ };
291
+ readonly HTTP_ENDPOINTS: {
292
+ readonly messages: "/v1/messages";
293
+ readonly session: "/v1/session";
294
+ readonly health: "/v1/health";
295
+ };
296
+ readonly ERROR_MESSAGES: {
297
+ readonly SESSION_EXPIRED: "Session has expired";
298
+ readonly SESSION_NOT_FOUND: "Session ID invalid or expired";
299
+ readonly SESSION_ALREADY_CLAIMED: "Session already claimed by another wallet";
300
+ readonly INVALID_SESSION_CLAIM: "Wallet does not own this session";
301
+ readonly INVALID_CLIENT_CLAIM: "Client session claim does not match";
302
+ readonly SESSION_TOKEN_EXPIRED: "Session token TTL exceeded";
303
+ readonly SESSION_CLOSED: "Session has been closed";
304
+ readonly ENCRYPTION_FAILED: "Message encryption failed";
305
+ readonly DECRYPTION_FAILED: "Cannot decrypt message";
306
+ readonly INVALID_SIGNATURE: "Invalid signature";
307
+ readonly NETWORK_ERROR: "Network connection error";
308
+ readonly RELAY_ERROR: "Internal relay server error";
309
+ readonly MESSAGE_QUEUE_FULL: "Too many queued messages (>100)";
310
+ readonly RATE_LIMIT_EXCEEDED: "Rate limit exceeded";
311
+ readonly ORIGIN_MISMATCH: "Origin verification failed";
312
+ readonly REQUEST_PENDING: "Another signing request is already pending";
313
+ readonly REQUEST_NOT_FOUND: "Request ID not found or already processed";
314
+ readonly REQUEST_EXPIRED: "Request expired before completion";
315
+ readonly REQUEST_INVALID: "Request data is invalid or malformed";
316
+ readonly REQUEST_TIMEOUT: "Request timed out waiting for wallet response";
317
+ readonly SIGNING_FAILED: "Cryptographic signing operation failed";
318
+ readonly SIGNING_REJECTED: "User rejected the signing request";
319
+ readonly TRANSACTION_INVALID: "Transaction parameters validation failed";
320
+ readonly CHAIN_MISMATCH: "Requested chain ID does not match wallet chain";
321
+ };
322
+ readonly QR_CONFIG: {
323
+ readonly size: 256;
324
+ readonly margin: 4;
325
+ readonly errorCorrectionLevel: "M";
326
+ readonly type: "image/png";
327
+ };
328
+ readonly DEEP_LINK_CONFIG: {
329
+ readonly scheme: "bananalink";
330
+ readonly host: "connect";
331
+ readonly universal: "https://bananalink.app";
332
+ };
333
+ readonly NETWORK_CONFIG: {
334
+ readonly SUPPORTED_CHAINS: readonly [1, 5, 137, 80001, 42161, 421613, 10, 420];
335
+ readonly DEFAULT_CHAIN_ID: 1;
336
+ readonly CHAIN_NAMES: {
337
+ readonly 1: "Ethereum Mainnet";
338
+ readonly 5: "Goerli Testnet";
339
+ readonly 137: "Polygon Mainnet";
340
+ readonly 80001: "Polygon Mumbai";
341
+ readonly 42161: "Arbitrum One";
342
+ readonly 421613: "Arbitrum Goerli";
343
+ readonly 10: "Optimism";
344
+ readonly 420: "Optimism Goerli";
345
+ };
346
+ };
347
+ readonly DEV_CONFIG: {
348
+ readonly logLevel: "debug";
349
+ readonly enableMocks: false;
350
+ readonly skipValidation: false;
351
+ readonly allowLocalhost: true;
352
+ };
353
+ };
354
+
355
+ declare function compressPublicKey(publicKey: string): string;
356
+ declare function decompressPublicKey(compressedKey: string): string;
357
+
358
+ declare function encodeUrlParameter(value: string): string;
359
+ declare function buildQueryString(params: Record<string, string | undefined>): string;
360
+ declare function encodeCompactConnectionString(payload: QRPayload): string;
361
+ declare function encodeConnectionString(payload: QRPayload): string;
362
+ declare function encodeUniversalLink(payload: QRPayload, options?: {
363
+ baseUrl?: string;
364
+ fallbackUrl?: string;
365
+ }): string;
366
+
367
+ declare function decodeUrlParameter(value: string): string;
368
+ declare function parseQueryString(query: string): Record<string, string>;
369
+ declare function decodeConnectionString(connectionString: string): QRPayload;
370
+ declare function isValidConnectionString(connectionString: string): boolean;
371
+
372
+ declare function generateSessionId(): string;
373
+ declare function isValidProtocolVersion(version: string): boolean;
374
+ declare function isValidSessionId(sessionId: string): boolean;
375
+
376
+ declare const VERSION: string;
377
+ declare const PACKAGE_NAME = "@bananalink-sdk/protocol";
378
+
379
+ export { type AblyConfig, BANANALINK_CONSTANTS, type BananaLinkErrorCode, CRYPTO_CONSTANTS, DAppMetadata, DEEPLINK_SCHEME, DEEP_LINK_CONFIG, DEFAULT_RELAY_URL, DEFAULT_TIMEOUTS, DEV_CONFIG, ERROR_MESSAGES, FRUITS, HTTP_ENDPOINTS, MESSAGE_FORMAT, MESSAGE_QUEUE_CONFIG, NETWORK_CONFIG, type OriginProof, PACKAGE_NAME, PROTOCOL_V2_TIMEOUTS, PROTOCOL_VERSION, type ProtocolErrorResponse, type ProviderConfig, type ProviderConfigResponse, type ProviderType, type PusherConfig, QRPayload, QR_CONFIG, type ReconnectedMessage, type RejectionReason, type RelayNotificationMessage, type RelayRejectionReason, SECURITY_LIMITS, type SessionClosedAck, type SessionClosedNotification, SessionConfig, type SessionInfo, type SessionSecurity, type SessionState, type UWebSocketConfig, VERSION, WS_MESSAGE_TYPES, type WalletRejectionReason, buildQueryString, compressPublicKey, decodeConnectionString, decodeUrlParameter, decompressPublicKey, encodeCompactConnectionString, encodeConnectionString, encodeUniversalLink, encodeUrlParameter, generateSessionId, isReconnectedMessage, isSessionClosedAck, isSessionClosedNotification, isValidConnectionString, isValidProtocolVersion, isValidSessionId, parseQueryString };