@keelcodes/sdk 2.1.2 → 2.2.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/dist/http.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { KeelConfig } from './types';
2
- /** SDK 版本(契约 §5,基线 2.1.2,随包版本同步)。 */
3
- export declare const SDK_VERSION = "2.1.2";
2
+ /** SDK 版本(契约 §5,随包版本同步)。 */
3
+ export declare const SDK_VERSION = "2.2.0";
4
4
  export declare class HttpClient {
5
5
  private baseUrl;
6
6
  private headers;
package/dist/http.js CHANGED
@@ -5,8 +5,8 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HttpClient = exports.SDK_VERSION = void 0;
7
7
  const errors_1 = require("./errors");
8
- /** SDK 版本(契约 §5,基线 2.1.2,随包版本同步)。 */
9
- exports.SDK_VERSION = '2.1.2';
8
+ /** SDK 版本(契约 §5,随包版本同步)。 */
9
+ exports.SDK_VERSION = '2.2.0';
10
10
  /**
11
11
  * 钱包签名的复用时长(ms):首次签名后在该窗口内复用,避免每个请求都触发钱包弹窗。
12
12
  * 服务端会话 TTL 为 24h,此处取 1h 留足余量。
@@ -10,6 +10,56 @@ export interface MpcBalanceParams {
10
10
  chain?: string;
11
11
  tokenAddress?: string;
12
12
  }
13
+ /** 注册参数:`curve='ed25519'` 时创建 Solana 钱包(可选 seed 导入存量私钥)。 */
14
+ export interface MpcRegisterParams extends MpcVerifyParams {
15
+ /** 签名曲线,默认 `secp256k1`(EVM)。 */
16
+ curve?: 'secp256k1' | 'ed25519';
17
+ /** 仅 ed25519:32B 种子 hex(可带 0x);导入后 base58 地址与导入前逐字节一致。 */
18
+ seed?: string;
19
+ walletAddress?: string;
20
+ }
21
+ /** 注册结果。 */
22
+ export interface MpcRegisterResult {
23
+ walletId: string;
24
+ email: string;
25
+ /** EVM 为 0x 地址;ed25519 为 base58 地址。 */
26
+ walletAddress: string;
27
+ curve: string;
28
+ createdAt: string;
29
+ }
30
+ /** Solana 签名参数。 */
31
+ export interface MpcSolanaSignParams {
32
+ token: string;
33
+ /** Solana 交易 message **原文**(hex,可带 0x),不是 32B 摘要(Ed25519ph 不被 Solana 支持)。 */
34
+ message: string;
35
+ /** 2-of-3 选片,默认 1。 */
36
+ partnerIndex?: number;
37
+ }
38
+ /** Solana 签名结果(Ed25519 无 `v` 恢复 id)。 */
39
+ export interface MpcSolanaSignResult {
40
+ curve: 'ed25519';
41
+ /** 64B `R‖z`,128 hex,无 0x。 */
42
+ signature: string;
43
+ publicKey: string;
44
+ address: string;
45
+ }
46
+ /** Solana 广播参数。 */
47
+ export interface MpcSolanaSendParams {
48
+ token: string;
49
+ /** base64 编码的**已签名**交易(交易构建与签名组装由客户端完成)。 */
50
+ transaction: string;
51
+ /** 是否等待确认,默认 true。 */
52
+ wait?: boolean;
53
+ }
54
+ /** Solana 广播结果。 */
55
+ export interface MpcSolanaSendResult {
56
+ chain: 'solana';
57
+ txHash: string | null;
58
+ from: string;
59
+ confirmed: boolean;
60
+ reason: string | null;
61
+ signatureStatus: string | null;
62
+ }
13
63
  export interface MpcSignMessageParams {
14
64
  token: string;
15
65
  message: string;
@@ -48,6 +48,45 @@ export interface ChainResult {
48
48
  result?: unknown;
49
49
  txHash?: string;
50
50
  }
51
+ /** session key 托管模式:`client` = 客户自持(relay 不生成、不落库私钥);`relay` = relay 生成并持久化。 */
52
+ export type SessionKeyCustody = 'client' | 'relay';
53
+ export interface SessionCreateParams {
54
+ chain: string;
55
+ /** 智能账户 owner EOA 地址。 */
56
+ owner: string;
57
+ /** 权限声明(由链上 session validator 解释)。 */
58
+ permissions: Array<Record<string, unknown>>;
59
+ /** 生效截止时间(Unix 秒)。 */
60
+ validUntil: number;
61
+ /** 生效起始时间(Unix 秒,缺省 0)。 */
62
+ validAfter?: number;
63
+ /** 客户自持的 session key 地址;传入则 relay 不生成、不落库私钥(`/execute` 不可用)。 */
64
+ signer?: string;
65
+ /** 租户/产品标识,缺省 `default`。 */
66
+ product?: string;
67
+ }
68
+ export interface SessionCreated {
69
+ product: string;
70
+ accountAddress: string;
71
+ isDeployed: boolean;
72
+ isBound: boolean;
73
+ sessionId: string;
74
+ /** session key 地址(自持模式即传入的 `signer`)。 */
75
+ signer: string;
76
+ /** 仅 `keyCustody: 'relay'` 返回私钥;客户自持模式为 `null`。 */
77
+ sessionKey: string | null;
78
+ keyCustody: SessionKeyCustody;
79
+ /** 十进制字符串(Unix 秒)。 */
80
+ validAfter: string;
81
+ /** 十进制字符串(Unix 秒)。 */
82
+ validUntil: string;
83
+ permissions: unknown[];
84
+ /** 链上 validator 副本槽位。 */
85
+ slot: number;
86
+ moduleVersion: string;
87
+ /** owner 侧启用 session 的 calldata。 */
88
+ enableCallData: string;
89
+ }
51
90
  export interface WalletBalanceParams {
52
91
  address: string;
53
92
  chain?: string;
@@ -1,8 +1,9 @@
1
1
  import { HttpClient } from '../http';
2
- import type { CreateWalletParams, WalletCreated, ImportWalletParams, SignParams, SignResult, SendParams, SendResult, ChainParams, ChainResult, WalletBalanceParams, WalletBalanceResult } from './types';
2
+ import type { KeelEnvelope } from '../types';
3
+ import type { CreateWalletParams, WalletCreated, ImportWalletParams, SignParams, SignResult, SendParams, SendResult, ChainParams, ChainResult, WalletBalanceParams, WalletBalanceResult, SessionCreateParams, SessionCreated } from './types';
3
4
  import type { SolanaDeriveAccountParams, SolanaDerivedAccount, SolanaCreateAccountParams, SolanaInstallPolicyParams, SolanaCreatePolicyTransactionParams, SolanaCreateProposalParams, SolanaApproveProposalParams, SolanaExecutePolicyTransactionParams, SolanaRemovePolicyParams } from './solana-account-types';
4
5
  import type { SolanaExecutePolicyPayloadParams, SolanaCloseSettingsParams, SolanaCloseTransactionParams, SolanaExecutePolicyParams, SolanaExecuteParams, SolanaRemoveSignerParams, SolanaSubmitParams, SolanaUnsignedTransaction, SolanaSubmitResult } from './solana-execution-types';
5
- import type { MpcSendCodeParams, MpcVerifyParams, MpcBalanceParams, MpcSignMessageParams, MpcSignTypedDataParams, MpcSendTransactionParams, MpcContractCallParams, MpcContractWriteParams, MpcGasEstimateParams } from './mpc-types';
6
+ import type { MpcSendCodeParams, MpcVerifyParams, MpcBalanceParams, MpcSignMessageParams, MpcSignTypedDataParams, MpcSendTransactionParams, MpcContractCallParams, MpcContractWriteParams, MpcGasEstimateParams, MpcRegisterParams, MpcRegisterResult, MpcSolanaSignParams, MpcSolanaSignResult, MpcSolanaSendParams, MpcSolanaSendResult } from './mpc-types';
6
7
  export declare class WalletAPI {
7
8
  private http;
8
9
  constructor(http: HttpClient);
@@ -133,7 +134,8 @@ export declare class WalletAPI {
133
134
  }) => Promise<unknown>;
134
135
  };
135
136
  session: {
136
- create: (p: Record<string, unknown>) => Promise<unknown>;
137
+ /** 创建链上 session;传 `signer` 为客户自持 session key(relay 不生成、不落库私钥)。 */
138
+ create: (p: SessionCreateParams) => Promise<KeelEnvelope<SessionCreated>>;
137
139
  revoke: (sessionId: string) => Promise<unknown>;
138
140
  execute: (p: Record<string, unknown>) => Promise<unknown>;
139
141
  /** Solana(Squads Smart Account):构建未签名交易 + 广播已签名交易。 */
@@ -166,7 +168,7 @@ export declare class WalletAPI {
166
168
  /** MPC(email 分片钱包)子域:canonical `/v1/wallet/mpc/*`。 */
167
169
  mpc: {
168
170
  sendCode: (p: MpcSendCodeParams) => Promise<unknown>;
169
- register: (p: MpcVerifyParams) => Promise<unknown>;
171
+ register: (p: MpcRegisterParams) => Promise<KeelEnvelope<MpcRegisterResult>>;
170
172
  recover: (p: MpcVerifyParams) => Promise<unknown>;
171
173
  status: (email: string) => Promise<unknown>;
172
174
  wallets: (email?: string) => Promise<unknown>;
@@ -182,5 +184,13 @@ export declare class WalletAPI {
182
184
  contractRead: (p: MpcContractCallParams) => Promise<unknown>;
183
185
  contractWrite: (p: MpcContractWriteParams) => Promise<unknown>;
184
186
  gasEstimate: (p: MpcGasEstimateParams) => Promise<unknown>;
187
+ /**
188
+ * 签 Solana 交易 message **原文**(hex,可带 0x)。
189
+ * ⚠️ 不能传 32B 摘要:Solana 只认对原文的 Ed25519 签名(Ed25519ph 不被支持)。
190
+ * 返回 64B `R‖z`(128 hex,**无 0x**),无 `v` 恢复 id,用 `publicKey` 对账。
191
+ */
192
+ signSolana: (p: MpcSolanaSignParams) => Promise<KeelEnvelope<MpcSolanaSignResult>>;
193
+ /** 广播 base64 编码的**已签名**交易(经 chain-rpc `sendTransaction` + `getSignatureStatuses`)。 */
194
+ sendSolanaTransaction: (p: MpcSolanaSendParams) => Promise<KeelEnvelope<MpcSolanaSendResult>>;
185
195
  };
186
196
  }
@@ -50,6 +50,7 @@ class WalletAPI {
50
50
  riskCheck: (p) => this.http.post('/v1/wallet/safe/risk/check', p),
51
51
  };
52
52
  this.session = {
53
+ /** 创建链上 session;传 `signer` 为客户自持 session key(relay 不生成、不落库私钥)。 */
53
54
  create: (p) => this.http.post('/v1/wallet/session/create', p),
54
55
  revoke: (sessionId) => this.http.post('/v1/wallet/session/revoke', { sessionId }),
55
56
  execute: (p) => this.http.post('/v1/wallet/session/execute', p),
@@ -97,6 +98,15 @@ class WalletAPI {
97
98
  contractRead: (p) => this.http.post('/v1/wallet/mpc/contract-read', p),
98
99
  contractWrite: (p) => this.http.post('/v1/wallet/mpc/contract-write', p),
99
100
  gasEstimate: (p) => this.http.post('/v1/wallet/mpc/gas-estimate', p),
101
+ // ── Solana(Ed25519 / FROST 2-of-3)──────────────────────────────────
102
+ /**
103
+ * 签 Solana 交易 message **原文**(hex,可带 0x)。
104
+ * ⚠️ 不能传 32B 摘要:Solana 只认对原文的 Ed25519 签名(Ed25519ph 不被支持)。
105
+ * 返回 64B `R‖z`(128 hex,**无 0x**),无 `v` 恢复 id,用 `publicKey` 对账。
106
+ */
107
+ signSolana: (p) => this.http.post('/v1/wallet/mpc/solana/sign', p),
108
+ /** 广播 base64 编码的**已签名**交易(经 chain-rpc `sendTransaction` + `getSignatureStatuses`)。 */
109
+ sendSolanaTransaction: (p) => this.http.post('/v1/wallet/mpc/solana/send-transaction', p),
100
110
  };
101
111
  }
102
112
  create(params) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keelcodes/sdk",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "Keel SDK — unified access to payment / wallet / data / account modules over https://keel.codes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",