@router402/sdk 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 +430 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +491 -0
- package/dist/kernel.d.ts +49 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/sdk.d.ts +153 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/session-keys.d.ts +53 -0
- package/dist/session-keys.d.ts.map +1 -0
- package/dist/transactions.d.ts +12 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/types.d.ts +236 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAuBlD,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EAEX,cAAc,EACd,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAEhB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,KAAK,CAAuB;gBAExB,UAAU,EAAE,eAAe;IAOvC;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAKjC;;OAEG;IACH,SAAS,IAAI,cAAc;IAI3B;;OAEG;IACH,UAAU,IAAI,MAAM;IASpB;;OAEG;IACG,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAK1E;;OAEG;IACG,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CA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;IAS9B;;;;;;;;OAQG;IACG,uBAAuB,CAC3B,UAAU,EAAE,cAAc,EAC1B,WAAW,EAAE,OAAO,EACpB,mBAAmB,EAAE,OAAO,GAC3B,OAAO,CAAC,0BAA0B,CAAC;IAuBtC;;;;;;;;;OASG;IACG,YAAY,CAChB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC;IAgE9B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B;;;;;;;;;;;;;OAaG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;CA6CnE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,CAExE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { SmartAccountResolvedConfig as ResolvedConfig, SessionKeyData, SessionKeyForBackend } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Generate a new session key pair
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateSessionKey(smartAccountAddress: Address, ownerAddress: Address, config: ResolvedConfig): SessionKeyData;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a session key is expired
|
|
9
|
+
*/
|
|
10
|
+
export declare function isSessionKeyExpired(sessionKey: SessionKeyData): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a session key is valid (exists, not expired, and approved)
|
|
13
|
+
*/
|
|
14
|
+
export declare function isSessionKeyValid(sessionKey: SessionKeyData | undefined): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a session key can be used (approved with serialized data)
|
|
17
|
+
*/
|
|
18
|
+
export declare function canUseSessionKey(sessionKey: SessionKeyData): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Get the remaining validity time for a session key
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSessionKeyRemainingTime(sessionKey: SessionKeyData): number;
|
|
23
|
+
/**
|
|
24
|
+
* Get an account object from session key data (for signing)
|
|
25
|
+
*/
|
|
26
|
+
export declare function getSessionKeyAccount(sessionKey: SessionKeyData): {
|
|
27
|
+
address: Address;
|
|
28
|
+
nonceManager?: import("viem").NonceManager | undefined;
|
|
29
|
+
sign: (parameters: {
|
|
30
|
+
hash: import("viem").Hash;
|
|
31
|
+
}) => Promise<import("viem").Hex>;
|
|
32
|
+
signAuthorization: (parameters: import("viem").AuthorizationRequest) => Promise<import("viem/accounts").SignAuthorizationReturnType>;
|
|
33
|
+
signMessage: ({ message }: {
|
|
34
|
+
message: import("viem").SignableMessage;
|
|
35
|
+
}) => Promise<import("viem").Hex>;
|
|
36
|
+
signTransaction: <serializer extends import("viem").SerializeTransactionFn<import("viem").TransactionSerializable> = import("viem").SerializeTransactionFn<import("viem").TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
|
|
37
|
+
serializer?: serializer | undefined;
|
|
38
|
+
} | undefined) => Promise<import("viem").Hex>;
|
|
39
|
+
signTypedData: <const typedData extends import("viem").TypedData | Record<string, unknown>, primaryType extends keyof typedData | "EIP712Domain" = keyof typedData>(parameters: import("viem").TypedDataDefinition<typedData, primaryType>) => Promise<import("viem").Hex>;
|
|
40
|
+
publicKey: import("viem").Hex;
|
|
41
|
+
source: "privateKey";
|
|
42
|
+
type: "local";
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Export session key data for backend use
|
|
46
|
+
* Returns the data needed by the backend to send transactions
|
|
47
|
+
*/
|
|
48
|
+
export declare function exportSessionKeyForBackend(sessionKey: SessionKeyData, chainId: number): SessionKeyForBackend | null;
|
|
49
|
+
/**
|
|
50
|
+
* Mark a session key as approved with the serialized approval data
|
|
51
|
+
*/
|
|
52
|
+
export declare function markSessionKeyApproved(sessionKey: SessionKeyData, serializedSessionKey: string): SessionKeyData;
|
|
53
|
+
//# sourceMappingURL=session-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-keys.d.ts","sourceRoot":"","sources":["../src/session-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EACV,0BAA0B,IAAI,cAAc,EAC5C,cAAc,EACd,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,mBAAmB,EAAE,OAAO,EAC5B,YAAY,EAAE,OAAO,EACrB,MAAM,EAAE,cAAc,GACrB,cAAc,CAmBhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAEvE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,cAAc,GAAG,SAAS,GACrC,OAAO,CAKT;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAMpE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,CAG7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,cAAc;;;;;;;;;;oTAjB3D,CAAC;kBAAsB,CAAC;;;;;;EAmB3B;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,MAAM,GACd,oBAAoB,GAAG,IAAI,CAW7B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,cAAc,EAC1B,oBAAoB,EAAE,MAAM,GAC3B,cAAc,CAMhB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Hex, WalletClient } from "viem";
|
|
2
|
+
import type { CallData, SmartAccountResolvedConfig as ResolvedConfig, TransactionExecutionResult } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Send a user operation using the owner wallet.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sendOwnerTransaction(walletClient: WalletClient, calls: CallData[], config: ResolvedConfig): Promise<TransactionExecutionResult>;
|
|
7
|
+
/**
|
|
8
|
+
* Send a transaction using a session key.
|
|
9
|
+
* This can be used by both frontend and backend.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sendSessionKeyTransaction(sessionKeyPrivateKey: Hex, serializedApproval: string, calls: CallData[], config: ResolvedConfig): Promise<TransactionExecutionResult>;
|
|
12
|
+
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAM9C,OAAO,KAAK,EACV,QAAQ,EACR,0BAA0B,IAAI,cAAc,EAC5C,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,QAAQ,EAAE,EACjB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,0BAA0B,CAAC,CA4BrC;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,oBAAoB,EAAE,GAAG,EACzB,kBAAkB,EAAE,MAAM,EAC1B,KAAK,EAAE,QAAQ,EAAE,EACjB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,0BAA0B,CAAC,CA+BrC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { Address, Chain, Hash, Hex } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* SDK Configuration options
|
|
4
|
+
*
|
|
5
|
+
* For chat-only usage, only `token` (or later `setToken()`) is needed.
|
|
6
|
+
* For smart account operations, `chain` and `pimlicoApiKey` are also required.
|
|
7
|
+
*/
|
|
8
|
+
export interface Router402Config {
|
|
9
|
+
/** Target chain for smart account operations (required for smart account features) */
|
|
10
|
+
chain?: Chain;
|
|
11
|
+
/** Pimlico API key for bundler/paymaster services (required for smart account features) */
|
|
12
|
+
pimlicoApiKey?: string;
|
|
13
|
+
/** JWT token for authenticated API requests (optional — can also be set later via setToken()) */
|
|
14
|
+
token?: string;
|
|
15
|
+
/** Entry point version (default: "0.7") */
|
|
16
|
+
entryPointVersion?: "0.7";
|
|
17
|
+
/** Session key validity period in seconds (default: 1 year) */
|
|
18
|
+
sessionKeyValidityPeriod?: number;
|
|
19
|
+
/** Router402 API base URL (default: "https://api.router402.xyz") */
|
|
20
|
+
apiBaseUrl?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolved configuration with defaults applied.
|
|
24
|
+
* For chat-only usage, chain/pimlico fields may be undefined.
|
|
25
|
+
*/
|
|
26
|
+
export interface ResolvedConfig {
|
|
27
|
+
chain?: Chain;
|
|
28
|
+
chainId?: number;
|
|
29
|
+
pimlicoApiKey?: string;
|
|
30
|
+
pimlicoUrl?: string;
|
|
31
|
+
entryPointVersion: "0.7";
|
|
32
|
+
sessionKeyValidityPeriod: number;
|
|
33
|
+
apiBaseUrl: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resolved configuration with smart account fields guaranteed present.
|
|
37
|
+
* Used by internal kernel, session key, and transaction modules.
|
|
38
|
+
*/
|
|
39
|
+
export interface SmartAccountResolvedConfig extends ResolvedConfig {
|
|
40
|
+
chain: Chain;
|
|
41
|
+
chainId: number;
|
|
42
|
+
pimlicoApiKey: string;
|
|
43
|
+
pimlicoUrl: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Smart Account information
|
|
47
|
+
*/
|
|
48
|
+
export interface SmartAccountInfo {
|
|
49
|
+
/** Smart Account address (deterministic) */
|
|
50
|
+
address: Address;
|
|
51
|
+
/** Owner EOA address */
|
|
52
|
+
eoaAddress: Address;
|
|
53
|
+
/** Whether the account is deployed on-chain */
|
|
54
|
+
isDeployed: boolean;
|
|
55
|
+
/** Chain ID */
|
|
56
|
+
chainId: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Smart Account deployment result
|
|
60
|
+
*/
|
|
61
|
+
export interface DeploymentResult {
|
|
62
|
+
/** Transaction hash of deployment */
|
|
63
|
+
txHash: Hash;
|
|
64
|
+
/** User operation hash */
|
|
65
|
+
userOpHash: Hash;
|
|
66
|
+
/** Smart Account address */
|
|
67
|
+
address: Address;
|
|
68
|
+
/** Whether deployment was successful */
|
|
69
|
+
success: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Transaction result from sendTransaction
|
|
73
|
+
*/
|
|
74
|
+
export interface TransactionResult {
|
|
75
|
+
/** Transaction hash after inclusion */
|
|
76
|
+
txHash?: Hash;
|
|
77
|
+
/** Whether the operation was successful */
|
|
78
|
+
success: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* User operation result from sendUserOperation
|
|
82
|
+
*/
|
|
83
|
+
export interface UserOperationResult {
|
|
84
|
+
/** Transaction hash after inclusion */
|
|
85
|
+
txHash?: Hash;
|
|
86
|
+
/** User operation hash */
|
|
87
|
+
userOpHash?: Hash;
|
|
88
|
+
/** Whether the operation was successful */
|
|
89
|
+
success: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Session Key data - full data including private key
|
|
93
|
+
* Used for client-side storage
|
|
94
|
+
*/
|
|
95
|
+
export interface SessionKeyData {
|
|
96
|
+
/** Private key (hex string) */
|
|
97
|
+
privateKey: Hex;
|
|
98
|
+
/** Public address derived from private key */
|
|
99
|
+
publicKey: Address;
|
|
100
|
+
/** Timestamp when key was created */
|
|
101
|
+
createdAt: number;
|
|
102
|
+
/** Timestamp when key expires */
|
|
103
|
+
expiresAt: number;
|
|
104
|
+
/** Smart Account address this key is associated with */
|
|
105
|
+
smartAccountAddress: Address;
|
|
106
|
+
/** Owner EOA address (needed for account derivation) */
|
|
107
|
+
ownerAddress: Address;
|
|
108
|
+
/** Serialized permission account - contains approvals (only set after approval) */
|
|
109
|
+
serializedSessionKey?: string;
|
|
110
|
+
/** Whether the key has been approved (serializedSessionKey is set) */
|
|
111
|
+
isApproved: boolean;
|
|
112
|
+
/** Addresses allowed to use this session key (enforced on-chain via toSignatureCallerPolicy) */
|
|
113
|
+
allowedCallers?: Address[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Data to send to backend for transaction execution
|
|
117
|
+
* Contains everything needed to reconstruct the session key client
|
|
118
|
+
*/
|
|
119
|
+
export interface SessionKeyForBackend {
|
|
120
|
+
/** Private key (hex string) */
|
|
121
|
+
privateKey: Hex;
|
|
122
|
+
/** Serialized permission account */
|
|
123
|
+
serializedSessionKey: string;
|
|
124
|
+
/** Smart Account address */
|
|
125
|
+
smartAccountAddress: Address;
|
|
126
|
+
/** Chain ID */
|
|
127
|
+
chainId: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Call data for sending transactions
|
|
131
|
+
*/
|
|
132
|
+
export interface CallData {
|
|
133
|
+
/** Target contract address */
|
|
134
|
+
to: Address;
|
|
135
|
+
/** Value to send in wei */
|
|
136
|
+
value?: bigint;
|
|
137
|
+
/** Calldata to send */
|
|
138
|
+
data?: Hex;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Transaction execution result
|
|
142
|
+
*/
|
|
143
|
+
export interface TransactionExecutionResult {
|
|
144
|
+
/** Whether the transaction was successful */
|
|
145
|
+
success: boolean;
|
|
146
|
+
/** Transaction hash after inclusion */
|
|
147
|
+
txHash?: Hex;
|
|
148
|
+
/** User operation hash */
|
|
149
|
+
userOpHash?: Hex;
|
|
150
|
+
/** Error message if failed */
|
|
151
|
+
error?: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Status values emitted during the account setup flow
|
|
155
|
+
*/
|
|
156
|
+
export type SetupStatus = "initializing" | "deploying" | "creating_session_key" | "approving_session_key" | "enabling_session_key" | "complete";
|
|
157
|
+
/**
|
|
158
|
+
* Callbacks for setup progress reporting
|
|
159
|
+
*/
|
|
160
|
+
export interface SetupCallbacks {
|
|
161
|
+
/** Called when the setup status changes */
|
|
162
|
+
onStatus?: (status: SetupStatus) => void;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Options for the setupAccount flow
|
|
166
|
+
*/
|
|
167
|
+
export interface SetupAccountOptions extends SetupCallbacks {
|
|
168
|
+
/** USDC contract address on the target chain (required for session key enablement) */
|
|
169
|
+
usdcAddress: Address;
|
|
170
|
+
/** If provided, skip deployment and session key creation when already done */
|
|
171
|
+
existingSessionKey?: SessionKeyData;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Result of the setupAccount flow
|
|
175
|
+
*/
|
|
176
|
+
export interface SetupAccountResult {
|
|
177
|
+
/** Smart account info (address, deployment status, etc.) */
|
|
178
|
+
info: SmartAccountInfo;
|
|
179
|
+
/** The approved and on-chain-enabled session key */
|
|
180
|
+
sessionKey: SessionKeyData;
|
|
181
|
+
/** Result of the session key enablement transaction */
|
|
182
|
+
enableResult: TransactionExecutionResult;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Chat message for completions API
|
|
186
|
+
*/
|
|
187
|
+
export interface ChatMessage {
|
|
188
|
+
role: "system" | "user" | "assistant";
|
|
189
|
+
content: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Options for the chat method
|
|
193
|
+
*/
|
|
194
|
+
export interface ChatOptions {
|
|
195
|
+
/** Model to use (default: "anthropic/claude-sonnet-4.5") */
|
|
196
|
+
model?: string;
|
|
197
|
+
/** Sampling temperature (0-2) */
|
|
198
|
+
temperature?: number;
|
|
199
|
+
/** Maximum tokens to generate */
|
|
200
|
+
max_tokens?: number;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Usage data from chat completions
|
|
204
|
+
*/
|
|
205
|
+
export interface ChatUsage {
|
|
206
|
+
prompt_tokens: number;
|
|
207
|
+
completion_tokens: number;
|
|
208
|
+
total_tokens: number;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Response from the chat completions API
|
|
212
|
+
*/
|
|
213
|
+
export interface ChatResponse {
|
|
214
|
+
id: string;
|
|
215
|
+
object: string;
|
|
216
|
+
created: number;
|
|
217
|
+
model: string;
|
|
218
|
+
choices: {
|
|
219
|
+
index: number;
|
|
220
|
+
message: ChatMessage;
|
|
221
|
+
finish_reason: string;
|
|
222
|
+
}[];
|
|
223
|
+
usage: ChatUsage;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Error types for Smart Account operations
|
|
227
|
+
*/
|
|
228
|
+
export type SmartAccountErrorType = "NOT_CONFIGURED" | "DEPLOYMENT_FAILED" | "INSUFFICIENT_FUNDS" | "USER_REJECTED" | "NETWORK_ERROR" | "SESSION_KEY_NOT_APPROVED" | "INVALID_SESSION_KEY" | "SESSION_KEY_EXPIRED" | "UNKNOWN_ERROR";
|
|
229
|
+
/**
|
|
230
|
+
* Smart Account error
|
|
231
|
+
*/
|
|
232
|
+
export declare class SmartAccountError extends Error {
|
|
233
|
+
type: SmartAccountErrorType;
|
|
234
|
+
constructor(type: SmartAccountErrorType, message: string);
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,iGAAiG;IACj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AC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,WAAW,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;KACvB,EAAE,CAAC;IACJ,KAAK,EAAE,SAAS,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,gBAAgB,GAChB,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,eAAe,GACf,0BAA0B,GAC1B,qBAAqB,GACrB,qBAAqB,GACrB,eAAe,CAAC;AAEpB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,IAAI,EAAE,qBAAqB,CAAC;gBAEhB,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM;CAKzD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@router402/sdk",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Router402 SDK for Kernel smart accounts with session keys",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/itublockchain/hackmoney-route402.git",
|
|
9
|
+
"directory": "packages/sdk"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/itublockchain/hackmoney-route402/tree/master/packages/sdk",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/itublockchain/hackmoney-route402/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"router402",
|
|
17
|
+
"x402",
|
|
18
|
+
"smart-accounts",
|
|
19
|
+
"session-keys",
|
|
20
|
+
"zerodev",
|
|
21
|
+
"kernel",
|
|
22
|
+
"erc-4337",
|
|
23
|
+
"account-abstraction",
|
|
24
|
+
"micropayments",
|
|
25
|
+
"usdc"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "bun build ./src/index.ts --outdir ./dist --target node --format esm --external @zerodev/ecdsa-validator --external @zerodev/permissions --external @zerodev/sdk --external permissionless --external viem && tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
38
|
+
"declarations": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
39
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"clean": "rm -rf dist"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"viem": "^2.0.0"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@zerodev/ecdsa-validator": "^5.4.9",
|
|
48
|
+
"@zerodev/permissions": "^5.6.3",
|
|
49
|
+
"@zerodev/sdk": "^5.5.7",
|
|
50
|
+
"permissionless": "^0.3.4"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"typescript": "^5.7.3",
|
|
54
|
+
"viem": "^2.23.7"
|
|
55
|
+
}
|
|
56
|
+
}
|