@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.
- package/README.md +604 -0
- package/dist/chunk-32OWUOZ3.js +308 -0
- package/dist/chunk-32OWUOZ3.js.map +1 -0
- package/dist/chunk-65HNHRJK.cjs +123 -0
- package/dist/chunk-65HNHRJK.cjs.map +1 -0
- package/dist/chunk-7KYDLL3B.js +480 -0
- package/dist/chunk-7KYDLL3B.js.map +1 -0
- package/dist/chunk-A6FLEJ7R.cjs +62 -0
- package/dist/chunk-A6FLEJ7R.cjs.map +1 -0
- package/dist/chunk-CUJK7ZTS.js +217 -0
- package/dist/chunk-CUJK7ZTS.js.map +1 -0
- package/dist/chunk-GI3BUPIH.cjs +236 -0
- package/dist/chunk-GI3BUPIH.cjs.map +1 -0
- package/dist/chunk-JXHV66Q4.js +106 -0
- package/dist/chunk-JXHV66Q4.js.map +1 -0
- package/dist/chunk-KNGZKGRS.cjs +552 -0
- package/dist/chunk-KNGZKGRS.cjs.map +1 -0
- package/dist/chunk-LELPCIE7.js +840 -0
- package/dist/chunk-LELPCIE7.js.map +1 -0
- package/dist/chunk-MCZG7QEM.cjs +310 -0
- package/dist/chunk-MCZG7QEM.cjs.map +1 -0
- package/dist/chunk-TCVKC227.js +56 -0
- package/dist/chunk-TCVKC227.js.map +1 -0
- package/dist/chunk-VXLUSU5B.cjs +856 -0
- package/dist/chunk-VXLUSU5B.cjs.map +1 -0
- package/dist/chunk-WCQVDF3K.js +12 -0
- package/dist/chunk-WCQVDF3K.js.map +1 -0
- package/dist/chunk-WGEGR3DF.cjs +15 -0
- package/dist/chunk-WGEGR3DF.cjs.map +1 -0
- package/dist/client-session-claim-3QF3noOr.d.ts +197 -0
- package/dist/client-session-claim-C4lUik3b.d.cts +197 -0
- package/dist/core-DMhuNfoz.d.cts +62 -0
- package/dist/core-DMhuNfoz.d.ts +62 -0
- package/dist/crypto/providers/noble-provider.cjs +14 -0
- package/dist/crypto/providers/noble-provider.cjs.map +1 -0
- package/dist/crypto/providers/noble-provider.d.cts +30 -0
- package/dist/crypto/providers/noble-provider.d.ts +30 -0
- package/dist/crypto/providers/noble-provider.js +5 -0
- package/dist/crypto/providers/noble-provider.js.map +1 -0
- package/dist/crypto/providers/node-provider.cjs +308 -0
- package/dist/crypto/providers/node-provider.cjs.map +1 -0
- package/dist/crypto/providers/node-provider.d.cts +32 -0
- package/dist/crypto/providers/node-provider.d.ts +32 -0
- package/dist/crypto/providers/node-provider.js +306 -0
- package/dist/crypto/providers/node-provider.js.map +1 -0
- package/dist/crypto/providers/quickcrypto-provider.cjs +339 -0
- package/dist/crypto/providers/quickcrypto-provider.cjs.map +1 -0
- package/dist/crypto/providers/quickcrypto-provider.d.cts +34 -0
- package/dist/crypto/providers/quickcrypto-provider.d.ts +34 -0
- package/dist/crypto/providers/quickcrypto-provider.js +337 -0
- package/dist/crypto/providers/quickcrypto-provider.js.map +1 -0
- package/dist/crypto/providers/webcrypto-provider.cjs +310 -0
- package/dist/crypto/providers/webcrypto-provider.cjs.map +1 -0
- package/dist/crypto/providers/webcrypto-provider.d.cts +30 -0
- package/dist/crypto/providers/webcrypto-provider.d.ts +30 -0
- package/dist/crypto/providers/webcrypto-provider.js +308 -0
- package/dist/crypto/providers/webcrypto-provider.js.map +1 -0
- package/dist/crypto-BUS06Qz-.d.cts +40 -0
- package/dist/crypto-BUS06Qz-.d.ts +40 -0
- package/dist/crypto-export.cjs +790 -0
- package/dist/crypto-export.cjs.map +1 -0
- package/dist/crypto-export.d.cts +257 -0
- package/dist/crypto-export.d.ts +257 -0
- package/dist/crypto-export.js +709 -0
- package/dist/crypto-export.js.map +1 -0
- package/dist/crypto-provider-deYoVIxi.d.cts +36 -0
- package/dist/crypto-provider-deYoVIxi.d.ts +36 -0
- package/dist/index.cjs +615 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +379 -0
- package/dist/index.d.ts +379 -0
- package/dist/index.js +504 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas-export.cjs +294 -0
- package/dist/schemas-export.cjs.map +1 -0
- package/dist/schemas-export.d.cts +1598 -0
- package/dist/schemas-export.d.ts +1598 -0
- package/dist/schemas-export.js +5 -0
- package/dist/schemas-export.js.map +1 -0
- package/dist/siwe-export.cjs +237 -0
- package/dist/siwe-export.cjs.map +1 -0
- package/dist/siwe-export.d.cts +27 -0
- package/dist/siwe-export.d.ts +27 -0
- package/dist/siwe-export.js +228 -0
- package/dist/siwe-export.js.map +1 -0
- package/dist/testing.cjs +54 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +20 -0
- package/dist/testing.d.ts +20 -0
- package/dist/testing.js +51 -0
- package/dist/testing.js.map +1 -0
- package/dist/validation-export.cjs +359 -0
- package/dist/validation-export.cjs.map +1 -0
- package/dist/validation-export.d.cts +3 -0
- package/dist/validation-export.d.ts +3 -0
- package/dist/validation-export.js +6 -0
- package/dist/validation-export.js.map +1 -0
- package/dist/validators-export.cjs +73 -0
- package/dist/validators-export.cjs.map +1 -0
- package/dist/validators-export.d.cts +37 -0
- package/dist/validators-export.d.ts +37 -0
- package/dist/validators-export.js +4 -0
- package/dist/validators-export.js.map +1 -0
- package/package.json +140 -0
- package/src/constants/index.ts +205 -0
- package/src/crypto/context.ts +228 -0
- package/src/crypto/diagnostics.ts +772 -0
- package/src/crypto/errors.ts +114 -0
- package/src/crypto/index.ts +89 -0
- package/src/crypto/payload-handler.ts +102 -0
- package/src/crypto/providers/compliance-provider.ts +579 -0
- package/src/crypto/providers/factory.ts +204 -0
- package/src/crypto/providers/index.ts +44 -0
- package/src/crypto/providers/noble-provider.ts +392 -0
- package/src/crypto/providers/node-provider.ts +433 -0
- package/src/crypto/providers/quickcrypto-provider.ts +483 -0
- package/src/crypto/providers/registry.ts +129 -0
- package/src/crypto/providers/webcrypto-provider.ts +364 -0
- package/src/crypto/session-security.ts +185 -0
- package/src/crypto/types.ts +93 -0
- package/src/crypto/utils.ts +190 -0
- package/src/crypto-export.ts +21 -0
- package/src/index.ts +38 -0
- package/src/schemas/auth.ts +60 -0
- package/src/schemas/client-messages.ts +57 -0
- package/src/schemas/core.ts +144 -0
- package/src/schemas/crypto.ts +65 -0
- package/src/schemas/discovery.ts +79 -0
- package/src/schemas/index.ts +239 -0
- package/src/schemas/relay-messages.ts +45 -0
- package/src/schemas/wallet-messages.ts +177 -0
- package/src/schemas-export.ts +23 -0
- package/src/siwe-export.ts +27 -0
- package/src/testing.ts +71 -0
- package/src/types/auth.ts +60 -0
- package/src/types/client-messages.ts +84 -0
- package/src/types/core.ts +131 -0
- package/src/types/crypto-provider.ts +264 -0
- package/src/types/crypto.ts +90 -0
- package/src/types/discovery.ts +50 -0
- package/src/types/errors.ts +87 -0
- package/src/types/index.ts +197 -0
- package/src/types/post-auth-operations.ts +363 -0
- package/src/types/providers.ts +72 -0
- package/src/types/relay-messages.ts +60 -0
- package/src/types/request-lifecycle.ts +161 -0
- package/src/types/signing-operations.ts +99 -0
- package/src/types/wallet-messages.ts +251 -0
- package/src/utils/client-session-claim.ts +188 -0
- package/src/utils/index.ts +54 -0
- package/src/utils/public-keys.ts +49 -0
- package/src/utils/siwe.ts +362 -0
- package/src/utils/url-decoding.ts +126 -0
- package/src/utils/url-encoding.ts +144 -0
- package/src/utils/wallet-session-claim.ts +188 -0
- package/src/validation-export.ts +32 -0
- package/src/validators/index.ts +222 -0
- package/src/validators-export.ts +8 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for the BananaLink protocol
|
|
3
|
+
* Based on ERC-4361 SIWE format with BananaLink extensions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Re-export QR Code payload from discovery types
|
|
7
|
+
export type { QRPayload } from './discovery';
|
|
8
|
+
// Re-export provider configuration types
|
|
9
|
+
export type {
|
|
10
|
+
ProviderType,
|
|
11
|
+
ProviderConfig,
|
|
12
|
+
ProviderConfigResponse,
|
|
13
|
+
UWebSocketConfig,
|
|
14
|
+
PusherConfig,
|
|
15
|
+
AblyConfig
|
|
16
|
+
} from './providers';
|
|
17
|
+
|
|
18
|
+
// Re-export v2.0 wallet message types
|
|
19
|
+
export type {
|
|
20
|
+
WalletSessionClaim,
|
|
21
|
+
WalletMessageEnvelope,
|
|
22
|
+
ClaimSessionPayload,
|
|
23
|
+
PrefetchMetadataPayload,
|
|
24
|
+
ConnectionRejectedPayload,
|
|
25
|
+
AuthenticateConnectionPayload,
|
|
26
|
+
WalletReconnectPayload,
|
|
27
|
+
WalletMessagePayload,
|
|
28
|
+
RejectionData,
|
|
29
|
+
AuthenticationData,
|
|
30
|
+
WalletMetadata,
|
|
31
|
+
WalletHandshakeMessage,
|
|
32
|
+
ConnectionRejectedMessage,
|
|
33
|
+
ConnectionAuthenticatedMessage,
|
|
34
|
+
RelayToDAppMessage,
|
|
35
|
+
PrefetchMetadataResponse,
|
|
36
|
+
} from './wallet-messages';
|
|
37
|
+
|
|
38
|
+
// Re-export v2.1+ request lifecycle types
|
|
39
|
+
export type {
|
|
40
|
+
BaseRequestMetadata,
|
|
41
|
+
BaseResponseMetadata,
|
|
42
|
+
BaseRejectionMetadata,
|
|
43
|
+
RequestRejectionReason,
|
|
44
|
+
RequestState,
|
|
45
|
+
} from './request-lifecycle';
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
isValidRejectionReason,
|
|
49
|
+
} from './request-lifecycle';
|
|
50
|
+
|
|
51
|
+
// Re-export v2.1+ signing operation types
|
|
52
|
+
export type {
|
|
53
|
+
BaseSigningRequest,
|
|
54
|
+
BaseSigningResponse,
|
|
55
|
+
SigningRejection,
|
|
56
|
+
} from './signing-operations';
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
isValidSignature,
|
|
60
|
+
isValidAddress,
|
|
61
|
+
} from './signing-operations';
|
|
62
|
+
|
|
63
|
+
// Re-export v2.1+ post-authentication operation types
|
|
64
|
+
export type {
|
|
65
|
+
SignMessageRequest,
|
|
66
|
+
SignMessageResponse,
|
|
67
|
+
SignTypedDataRequest,
|
|
68
|
+
SignTypedDataResponse,
|
|
69
|
+
EIP712Domain,
|
|
70
|
+
EIP712TypeDefinition,
|
|
71
|
+
SignTransactionRequest,
|
|
72
|
+
SignTransactionResponse,
|
|
73
|
+
LegacyTransaction,
|
|
74
|
+
EIP1559Transaction,
|
|
75
|
+
TransactionRequest,
|
|
76
|
+
AccessListEntry,
|
|
77
|
+
SignMessageRequestPayload,
|
|
78
|
+
SignTypedDataRequestPayload,
|
|
79
|
+
SignTransactionRequestPayload,
|
|
80
|
+
RequestFulfilledPayload,
|
|
81
|
+
RequestRejectedPayload,
|
|
82
|
+
RequestFulfilledData,
|
|
83
|
+
RequestRejectedData,
|
|
84
|
+
} from './post-auth-operations';
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
isSignMessageRequest,
|
|
88
|
+
isSignTypedDataRequest,
|
|
89
|
+
isSignTransactionRequest,
|
|
90
|
+
isLegacyTransaction,
|
|
91
|
+
isEIP1559Transaction,
|
|
92
|
+
isSignMessageRequestPayload,
|
|
93
|
+
isSignTypedDataRequestPayload,
|
|
94
|
+
isSignTransactionRequestPayload,
|
|
95
|
+
isRequestFulfilledPayload,
|
|
96
|
+
isRequestRejectedPayload,
|
|
97
|
+
} from './post-auth-operations';
|
|
98
|
+
|
|
99
|
+
// Re-export wallet message type guards
|
|
100
|
+
export {
|
|
101
|
+
isClaimSessionPayload,
|
|
102
|
+
isPrefetchMetadataPayload,
|
|
103
|
+
isConnectionRejectedPayload,
|
|
104
|
+
isAuthenticateConnectionPayload,
|
|
105
|
+
isWalletReconnectPayload,
|
|
106
|
+
isWalletHandshakeMessage,
|
|
107
|
+
isConnectionRejectedMessage,
|
|
108
|
+
isConnectionAuthenticatedMessage,
|
|
109
|
+
} from './wallet-messages';
|
|
110
|
+
|
|
111
|
+
// Re-export v2.0 client message types
|
|
112
|
+
export type {
|
|
113
|
+
ClientSessionClaim,
|
|
114
|
+
ClientMessageEnvelope,
|
|
115
|
+
ClientReconnectPayload,
|
|
116
|
+
CloseSessionPayload,
|
|
117
|
+
ClientMessagePayload,
|
|
118
|
+
} from './client-messages';
|
|
119
|
+
|
|
120
|
+
// Re-export client message type guards
|
|
121
|
+
export {
|
|
122
|
+
isClientReconnectPayload,
|
|
123
|
+
isCloseSessionPayload,
|
|
124
|
+
} from './client-messages';
|
|
125
|
+
|
|
126
|
+
// Re-export v2.0 relay notification message types
|
|
127
|
+
export type {
|
|
128
|
+
SessionClosedAck,
|
|
129
|
+
SessionClosedNotification,
|
|
130
|
+
ReconnectedMessage,
|
|
131
|
+
RelayNotificationMessage,
|
|
132
|
+
} from './relay-messages';
|
|
133
|
+
|
|
134
|
+
// Re-export relay notification message type guards
|
|
135
|
+
export {
|
|
136
|
+
isSessionClosedAck,
|
|
137
|
+
isSessionClosedNotification,
|
|
138
|
+
isReconnectedMessage,
|
|
139
|
+
} from './relay-messages';
|
|
140
|
+
|
|
141
|
+
// Re-export core types from core.ts (Protocol v2.0 only)
|
|
142
|
+
export type {
|
|
143
|
+
SIWEFields,
|
|
144
|
+
DAppMetadata,
|
|
145
|
+
SessionConfig,
|
|
146
|
+
SessionOptions,
|
|
147
|
+
SecurityPolicy,
|
|
148
|
+
SessionMetadata,
|
|
149
|
+
CreateSessionRequest,
|
|
150
|
+
CreateSessionResponse,
|
|
151
|
+
} from './core';
|
|
152
|
+
|
|
153
|
+
// Re-export discovery and relay types
|
|
154
|
+
export type { RelayMessageType, EncryptedPayload, RelayMessage, DisplayInfo } from './discovery';
|
|
155
|
+
|
|
156
|
+
// Re-export auth types
|
|
157
|
+
export type { SessionState, SessionInfo, SessionSecurity, OriginProof } from './auth';
|
|
158
|
+
|
|
159
|
+
// Re-export error types
|
|
160
|
+
export type {
|
|
161
|
+
BananaLinkErrorCode,
|
|
162
|
+
WalletRejectionReason,
|
|
163
|
+
RelayRejectionReason,
|
|
164
|
+
RejectionReason,
|
|
165
|
+
} from './errors';
|
|
166
|
+
|
|
167
|
+
// Re-export crypto provider types
|
|
168
|
+
export type {
|
|
169
|
+
CryptoKeyLike,
|
|
170
|
+
KeyPairLike,
|
|
171
|
+
ProviderKeyPair,
|
|
172
|
+
CryptoProvider,
|
|
173
|
+
CryptoProviderFactory,
|
|
174
|
+
CryptoProviderType,
|
|
175
|
+
PlatformDetectionResult,
|
|
176
|
+
ProviderDetectionResult,
|
|
177
|
+
} from './crypto-provider';
|
|
178
|
+
|
|
179
|
+
// Re-export crypto runtime types
|
|
180
|
+
export type {
|
|
181
|
+
EncryptionAlgorithm,
|
|
182
|
+
EncryptedMessage,
|
|
183
|
+
KeyPair,
|
|
184
|
+
SessionKeys,
|
|
185
|
+
CryptoConfig,
|
|
186
|
+
CreatePayloadOptions,
|
|
187
|
+
} from '../crypto/types';
|
|
188
|
+
|
|
189
|
+
// Re-export crypto payload types (from crypto.ts)
|
|
190
|
+
export type {
|
|
191
|
+
KeyExchange,
|
|
192
|
+
Encryption,
|
|
193
|
+
PublicKeyJWK,
|
|
194
|
+
CryptoParameters,
|
|
195
|
+
KeyDerivation,
|
|
196
|
+
CryptoPayload,
|
|
197
|
+
} from './crypto';
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-Authentication Operations Types for BananaLink Protocol v2.0
|
|
3
|
+
*
|
|
4
|
+
* This module defines concrete operation types for post-authentication requests:
|
|
5
|
+
* - Message signing (personal_sign)
|
|
6
|
+
* - Typed data signing (eth_signTypedData_v4)
|
|
7
|
+
* - Transaction signing (legacy + EIP-1559)
|
|
8
|
+
*
|
|
9
|
+
* All operations follow the request lifecycle defined in request-lifecycle.ts
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { EncryptedPayload } from './discovery';
|
|
13
|
+
import type {
|
|
14
|
+
BaseSigningRequest,
|
|
15
|
+
BaseSigningResponse,
|
|
16
|
+
SigningRejection
|
|
17
|
+
} from './signing-operations';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* ========================================
|
|
21
|
+
* MESSAGE SIGNING OPERATIONS
|
|
22
|
+
* ========================================
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Personal sign request (personal_sign / eth_sign)
|
|
27
|
+
* Used for signing arbitrary messages
|
|
28
|
+
*
|
|
29
|
+
* Security Note: personal_sign is recommended over eth_sign
|
|
30
|
+
* eth_sign is dangerous and should only be used with explicit user consent
|
|
31
|
+
*/
|
|
32
|
+
export interface SignMessageRequest extends BaseSigningRequest {
|
|
33
|
+
/**
|
|
34
|
+
* Message to sign (UTF-8 string or hex-encoded bytes)
|
|
35
|
+
* Wallet MUST display raw message to user
|
|
36
|
+
* @example "Sign this message to authenticate"
|
|
37
|
+
* @example "0x48656c6c6f20576f726c64" (hex-encoded "Hello World")
|
|
38
|
+
*/
|
|
39
|
+
data: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Signing method
|
|
43
|
+
* - personal_sign: Prefixes message with "\x19Ethereum Signed Message:\n{length}"
|
|
44
|
+
* - eth_sign: Direct signing without prefix (DANGEROUS - wallet should warn user)
|
|
45
|
+
*/
|
|
46
|
+
method: 'personal_sign';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Sign message response
|
|
51
|
+
*/
|
|
52
|
+
export interface SignMessageResponse extends BaseSigningResponse {
|
|
53
|
+
/** Discriminator for union type matching */
|
|
54
|
+
requestType: 'sign_message';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* ========================================
|
|
59
|
+
* TYPED DATA SIGNING OPERATIONS (EIP-712)
|
|
60
|
+
* ========================================
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* EIP-712 Domain Separator
|
|
65
|
+
* Defines the context for typed data signing
|
|
66
|
+
*/
|
|
67
|
+
export interface EIP712Domain {
|
|
68
|
+
/** Human-readable name of signing domain */
|
|
69
|
+
name?: string;
|
|
70
|
+
|
|
71
|
+
/** Current version of signing domain */
|
|
72
|
+
version?: string;
|
|
73
|
+
|
|
74
|
+
/** Chain ID where signature is valid (EIP-155) */
|
|
75
|
+
chainId?: number;
|
|
76
|
+
|
|
77
|
+
/** Address of contract that will verify signature */
|
|
78
|
+
verifyingContract?: string;
|
|
79
|
+
|
|
80
|
+
/** Salt for domain separation (optional) */
|
|
81
|
+
salt?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* EIP-712 Type Definition
|
|
86
|
+
* Defines structure of a custom type
|
|
87
|
+
*/
|
|
88
|
+
export interface EIP712TypeDefinition {
|
|
89
|
+
name: string;
|
|
90
|
+
type: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Typed data sign request (EIP-712)
|
|
95
|
+
* Used for structured data signing (permits, orders, etc.)
|
|
96
|
+
*/
|
|
97
|
+
export interface SignTypedDataRequest extends BaseSigningRequest {
|
|
98
|
+
/**
|
|
99
|
+
* EIP-712 typed data object
|
|
100
|
+
* Wallet MUST validate structure and display human-readable form
|
|
101
|
+
*/
|
|
102
|
+
data: {
|
|
103
|
+
/** Domain separator for signature context */
|
|
104
|
+
domain: EIP712Domain;
|
|
105
|
+
|
|
106
|
+
/** Type definitions (excluding EIP712Domain) */
|
|
107
|
+
types: Record<string, EIP712TypeDefinition[]>;
|
|
108
|
+
|
|
109
|
+
/** Primary type name (must be defined in types) */
|
|
110
|
+
primaryType: string;
|
|
111
|
+
|
|
112
|
+
/** Message data matching primaryType structure */
|
|
113
|
+
message: Record<string, unknown>;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Signing method version
|
|
118
|
+
* Only v4 supported (v1-v3 deprecated)
|
|
119
|
+
*/
|
|
120
|
+
method: 'eth_signTypedData_v4';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Sign typed data response
|
|
125
|
+
*/
|
|
126
|
+
export interface SignTypedDataResponse extends BaseSigningResponse {
|
|
127
|
+
/** Discriminator for union type matching */
|
|
128
|
+
requestType: 'sign_typed_data';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* ========================================
|
|
133
|
+
* TRANSACTION SIGNING OPERATIONS
|
|
134
|
+
* ========================================
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Transaction access list entry (EIP-2930)
|
|
139
|
+
* Specifies accounts and storage slots accessed by transaction
|
|
140
|
+
*/
|
|
141
|
+
export interface AccessListEntry {
|
|
142
|
+
/** Account address */
|
|
143
|
+
address: string;
|
|
144
|
+
|
|
145
|
+
/** Storage keys accessed in this account */
|
|
146
|
+
storageKeys: string[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Legacy transaction (pre-EIP-1559)
|
|
151
|
+
* Uses fixed gas price model
|
|
152
|
+
*/
|
|
153
|
+
export interface LegacyTransaction {
|
|
154
|
+
/** Transaction type discriminator */
|
|
155
|
+
type: 'legacy';
|
|
156
|
+
|
|
157
|
+
/** Recipient address (0x-prefixed, 42 chars) */
|
|
158
|
+
to: string;
|
|
159
|
+
|
|
160
|
+
/** Value in wei (hex-encoded, 0x-prefixed) */
|
|
161
|
+
value: string;
|
|
162
|
+
|
|
163
|
+
/** Transaction data (hex-encoded, 0x-prefixed, optional) */
|
|
164
|
+
data?: string;
|
|
165
|
+
|
|
166
|
+
/** Transaction nonce (hex-encoded, 0x-prefixed) */
|
|
167
|
+
nonce: string;
|
|
168
|
+
|
|
169
|
+
/** Gas limit (hex-encoded, 0x-prefixed) */
|
|
170
|
+
gasLimit: string;
|
|
171
|
+
|
|
172
|
+
/** Gas price in wei (hex-encoded, 0x-prefixed) */
|
|
173
|
+
gasPrice: string;
|
|
174
|
+
|
|
175
|
+
/** Chain ID (EIP-155) */
|
|
176
|
+
chainId: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* EIP-1559 transaction
|
|
181
|
+
* Uses base fee + priority fee model
|
|
182
|
+
*/
|
|
183
|
+
export interface EIP1559Transaction {
|
|
184
|
+
/** Transaction type discriminator */
|
|
185
|
+
type: 'eip1559';
|
|
186
|
+
|
|
187
|
+
/** Recipient address */
|
|
188
|
+
to: string;
|
|
189
|
+
|
|
190
|
+
/** Value in wei (hex-encoded) */
|
|
191
|
+
value: string;
|
|
192
|
+
|
|
193
|
+
/** Transaction data (hex-encoded, optional) */
|
|
194
|
+
data?: string;
|
|
195
|
+
|
|
196
|
+
/** Transaction nonce (hex-encoded) */
|
|
197
|
+
nonce: string;
|
|
198
|
+
|
|
199
|
+
/** Gas limit (hex-encoded) */
|
|
200
|
+
gasLimit: string;
|
|
201
|
+
|
|
202
|
+
/** Max priority fee per gas in wei (hex-encoded) */
|
|
203
|
+
maxPriorityFeePerGas: string;
|
|
204
|
+
|
|
205
|
+
/** Max fee per gas in wei (hex-encoded) */
|
|
206
|
+
maxFeePerGas: string;
|
|
207
|
+
|
|
208
|
+
/** Chain ID (EIP-155) */
|
|
209
|
+
chainId: number;
|
|
210
|
+
|
|
211
|
+
/** Access list (EIP-2930, optional) */
|
|
212
|
+
accessList?: AccessListEntry[];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Transaction request union type
|
|
217
|
+
*/
|
|
218
|
+
export type TransactionRequest = LegacyTransaction | EIP1559Transaction;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Sign transaction request
|
|
222
|
+
* Used for signing transactions (NOT broadcasting)
|
|
223
|
+
*/
|
|
224
|
+
export interface SignTransactionRequest extends Omit<BaseSigningRequest, 'data'> {
|
|
225
|
+
/**
|
|
226
|
+
* Transaction parameters
|
|
227
|
+
* Wallet MUST validate all fields before signing
|
|
228
|
+
*/
|
|
229
|
+
data: TransactionRequest;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Signing method (always eth_signTransaction)
|
|
233
|
+
*/
|
|
234
|
+
method: 'eth_signTransaction';
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Sign transaction response
|
|
239
|
+
*/
|
|
240
|
+
export interface SignTransactionResponse extends BaseSigningResponse {
|
|
241
|
+
/** Discriminator for union type matching */
|
|
242
|
+
requestType: 'sign_transaction';
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* RLP-encoded signed transaction
|
|
246
|
+
* Format: 0x-prefixed hex string
|
|
247
|
+
* Can be broadcast to network via eth_sendRawTransaction
|
|
248
|
+
*/
|
|
249
|
+
signedTransaction: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* ========================================
|
|
254
|
+
* PAYLOAD TYPES (ENCRYPTED WRAPPERS)
|
|
255
|
+
* ========================================
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Sign message request payload (dApp → Wallet)
|
|
260
|
+
*/
|
|
261
|
+
export interface SignMessageRequestPayload {
|
|
262
|
+
type: 'sign_message_request';
|
|
263
|
+
encrypted: EncryptedPayload;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Sign typed data request payload (dApp → Wallet)
|
|
268
|
+
*/
|
|
269
|
+
export interface SignTypedDataRequestPayload {
|
|
270
|
+
type: 'sign_typed_data_request';
|
|
271
|
+
encrypted: EncryptedPayload;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Sign transaction request payload (dApp → Wallet)
|
|
276
|
+
*/
|
|
277
|
+
export interface SignTransactionRequestPayload {
|
|
278
|
+
type: 'sign_transaction_request';
|
|
279
|
+
encrypted: EncryptedPayload;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Request fulfilled response payload (Wallet → dApp)
|
|
284
|
+
* Used for all successful request completions
|
|
285
|
+
*/
|
|
286
|
+
export interface RequestFulfilledPayload {
|
|
287
|
+
type: 'request_fulfilled';
|
|
288
|
+
encrypted: EncryptedPayload;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Request rejected response payload (Wallet → dApp)
|
|
293
|
+
* Used when wallet rejects a request
|
|
294
|
+
*/
|
|
295
|
+
export interface RequestRejectedPayload {
|
|
296
|
+
type: 'request_rejected';
|
|
297
|
+
encrypted: EncryptedPayload;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Union type for request fulfilled data (decrypted)
|
|
302
|
+
*/
|
|
303
|
+
export type RequestFulfilledData =
|
|
304
|
+
| SignMessageResponse
|
|
305
|
+
| SignTypedDataResponse
|
|
306
|
+
| SignTransactionResponse;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Request rejected data (decrypted)
|
|
310
|
+
*/
|
|
311
|
+
export interface RequestRejectedData extends SigningRejection {
|
|
312
|
+
/** Original request type being rejected */
|
|
313
|
+
requestType: 'sign_message' | 'sign_typed_data' | 'sign_transaction';
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* ========================================
|
|
318
|
+
* TYPE GUARDS
|
|
319
|
+
* ========================================
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
export function isSignMessageRequest(req: unknown): req is SignMessageRequest {
|
|
323
|
+
const r = req as SignMessageRequest;
|
|
324
|
+
return r?.method === 'personal_sign' && typeof r?.data === 'string';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export function isSignTypedDataRequest(req: unknown): req is SignTypedDataRequest {
|
|
328
|
+
const r = req as SignTypedDataRequest;
|
|
329
|
+
return r?.method === 'eth_signTypedData_v4' && typeof r?.data === 'object';
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export function isSignTransactionRequest(req: unknown): req is SignTransactionRequest {
|
|
333
|
+
const r = req as SignTransactionRequest;
|
|
334
|
+
return r?.method === 'eth_signTransaction' && typeof r?.data === 'object';
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export function isLegacyTransaction(tx: TransactionRequest): tx is LegacyTransaction {
|
|
338
|
+
return tx.type === 'legacy';
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function isEIP1559Transaction(tx: TransactionRequest): tx is EIP1559Transaction {
|
|
342
|
+
return tx.type === 'eip1559';
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function isSignMessageRequestPayload(payload: unknown): payload is SignMessageRequestPayload {
|
|
346
|
+
return (payload as SignMessageRequestPayload)?.type === 'sign_message_request';
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function isSignTypedDataRequestPayload(payload: unknown): payload is SignTypedDataRequestPayload {
|
|
350
|
+
return (payload as SignTypedDataRequestPayload)?.type === 'sign_typed_data_request';
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export function isSignTransactionRequestPayload(payload: unknown): payload is SignTransactionRequestPayload {
|
|
354
|
+
return (payload as SignTransactionRequestPayload)?.type === 'sign_transaction_request';
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export function isRequestFulfilledPayload(payload: unknown): payload is RequestFulfilledPayload {
|
|
358
|
+
return (payload as RequestFulfilledPayload)?.type === 'request_fulfilled';
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export function isRequestRejectedPayload(payload: unknown): payload is RequestRejectedPayload {
|
|
362
|
+
return (payload as RequestRejectedPayload)?.type === 'request_rejected';
|
|
363
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Configuration Types
|
|
3
|
+
* Types for transport provider configuration and management
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Supported transport provider types (API response format)
|
|
8
|
+
* Note: 'uwebsockets' is maintained for API compatibility but SDKs normalize to 'websocket'
|
|
9
|
+
*/
|
|
10
|
+
export type ProviderType = 'uwebsockets' | 'websocket' | 'pusher' | 'ably';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Base provider configuration
|
|
14
|
+
*/
|
|
15
|
+
export interface ProviderConfig {
|
|
16
|
+
providerId: string;
|
|
17
|
+
type: ProviderType;
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
priority: number;
|
|
20
|
+
config: UWebSocketConfig | PusherConfig | AblyConfig;
|
|
21
|
+
features?: string[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Provider configuration response from API Gateway
|
|
26
|
+
*/
|
|
27
|
+
export interface ProviderConfigResponse {
|
|
28
|
+
providers: ProviderConfig[];
|
|
29
|
+
ttl: number;
|
|
30
|
+
lastUpdated: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* UWebSocket provider configuration
|
|
35
|
+
*/
|
|
36
|
+
export interface UWebSocketConfig {
|
|
37
|
+
relayUrl: string;
|
|
38
|
+
maxConnections?: number;
|
|
39
|
+
reconnectInterval?: number;
|
|
40
|
+
heartbeatInterval?: number;
|
|
41
|
+
maxPayloadLength?: number;
|
|
42
|
+
idleTimeout?: number;
|
|
43
|
+
fallbackUrl?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Pusher provider configuration
|
|
48
|
+
*/
|
|
49
|
+
export interface PusherConfig {
|
|
50
|
+
appKey: string;
|
|
51
|
+
key?: string;
|
|
52
|
+
cluster: string;
|
|
53
|
+
encrypted?: boolean;
|
|
54
|
+
authEndpoint?: string;
|
|
55
|
+
useTLS?: boolean;
|
|
56
|
+
host?: string;
|
|
57
|
+
timeout?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Ably provider configuration
|
|
62
|
+
*/
|
|
63
|
+
export interface AblyConfig {
|
|
64
|
+
apiKey: string;
|
|
65
|
+
key?: string;
|
|
66
|
+
clientId?: string;
|
|
67
|
+
authUrl?: string;
|
|
68
|
+
environment?: string;
|
|
69
|
+
tls?: boolean;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
clientOptions?: Record<string, unknown>;
|
|
72
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay notification message types for BananaLink protocol v2.0
|
|
3
|
+
* These are messages sent from relay server to clients/wallets
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Session closed acknowledgment
|
|
8
|
+
* Sent to acknowledge a close_session request
|
|
9
|
+
*/
|
|
10
|
+
export interface SessionClosedAck {
|
|
11
|
+
type: 'session_closed_ack';
|
|
12
|
+
timestamp: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Session closed notification
|
|
17
|
+
* Sent to notify the other party that peer closed the session
|
|
18
|
+
*/
|
|
19
|
+
export interface SessionClosedNotification {
|
|
20
|
+
type: 'session_closed_notification';
|
|
21
|
+
/** Which party closed the session */
|
|
22
|
+
closedBy: 'client' | 'wallet';
|
|
23
|
+
/** Optional reason for closure */
|
|
24
|
+
reason?: string;
|
|
25
|
+
timestamp: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Reconnected confirmation message
|
|
30
|
+
* Sent after successful reconnection
|
|
31
|
+
*/
|
|
32
|
+
export interface ReconnectedMessage {
|
|
33
|
+
type: 'reconnected';
|
|
34
|
+
/** Number of messages that were queued during disconnection */
|
|
35
|
+
queuedMessages: number;
|
|
36
|
+
timestamp: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Union type for relay notification messages
|
|
41
|
+
*/
|
|
42
|
+
export type RelayNotificationMessage =
|
|
43
|
+
| SessionClosedAck
|
|
44
|
+
| SessionClosedNotification
|
|
45
|
+
| ReconnectedMessage;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Type guards for relay notification messages
|
|
49
|
+
*/
|
|
50
|
+
export function isSessionClosedAck(message: RelayNotificationMessage): message is SessionClosedAck {
|
|
51
|
+
return message?.type === 'session_closed_ack';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function isSessionClosedNotification(message: RelayNotificationMessage): message is SessionClosedNotification {
|
|
55
|
+
return message?.type === 'session_closed_notification';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function isReconnectedMessage(message: RelayNotificationMessage): message is ReconnectedMessage {
|
|
59
|
+
return message?.type === 'reconnected';
|
|
60
|
+
}
|