@keelcodes/sdk 2.1.1 → 2.1.3

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/account.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { HttpClient } from './http';
2
- import type { KeelModule } from './types';
2
+ import type { KeelEnvelope, KeelModule } from './types';
3
3
  export interface TenantCreateParams {
4
4
  name: string;
5
5
  metadata?: Record<string, unknown>;
@@ -10,14 +10,24 @@ export interface TenantResult {
10
10
  apiKey: string;
11
11
  }
12
12
  export interface ApikeyCreateParams {
13
- tenantId: string;
14
13
  module: KeelModule;
15
- /** 幂等键(同 reference 不重复签发)。 */
16
- reference?: string;
14
+ /** 幂等键(同 reference 不重复签发)。必填,≤100 字符。 */
15
+ reference: string;
16
+ /** 可选备注名。 */
17
+ name?: string;
18
+ /** @deprecated 租户由钱包签名解析,服务端忽略该字段;保留仅为兼容旧调用。 */
19
+ tenantId?: string;
17
20
  }
18
21
  export interface ApikeyResult {
19
- apiKey: string;
22
+ /** key id(撤销 / 轮换用,非明文)。 */
23
+ id: string;
20
24
  module: KeelModule;
25
+ /** 首次签发明文;命中 reference 幂等时为 null。 */
26
+ apiKey: string | null;
27
+ /** 掩码后的 key(幂等重放时用于识别)。 */
28
+ apiKeyMasked?: string;
29
+ /** true 表示命中幂等,未重新签发。 */
30
+ reused?: boolean;
21
31
  }
22
32
  export interface SubscriptionParams {
23
33
  module: KeelModule;
@@ -39,7 +49,7 @@ export declare class AccountAPI {
39
49
  };
40
50
  /** 按模块签发 key(用户订阅哪个模块,就为哪个模块签发)。 */
41
51
  apikey: {
42
- create: (p: ApikeyCreateParams) => Promise<ApikeyResult>;
52
+ create: (p: ApikeyCreateParams) => Promise<KeelEnvelope<ApikeyResult>>;
43
53
  /** 撤销 key;`id` 为 `GET /v1/account/apikey` 返回的 key id(非明文)。 */
44
54
  revoke: (id: string) => Promise<unknown>;
45
55
  };
package/dist/http.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { KeelConfig } from './types';
2
- /** SDK 版本(契约 §5,基线 2.1.1,随包版本同步)。 */
3
- export declare const SDK_VERSION = "2.1.1";
2
+ /** SDK 版本(契约 §5,基线 2.1.2,随包版本同步)。 */
3
+ export declare const SDK_VERSION = "2.1.2";
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.1,随包版本同步)。 */
9
- exports.SDK_VERSION = '2.1.1';
8
+ /** SDK 版本(契约 §5,基线 2.1.2,随包版本同步)。 */
9
+ exports.SDK_VERSION = '2.1.2';
10
10
  /**
11
11
  * 钱包签名的复用时长(ms):首次签名后在该窗口内复用,避免每个请求都触发钱包弹窗。
12
12
  * 服务端会话 TTL 为 24h,此处取 1h 留足余量。
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { DataAPI } from './data';
4
4
  import { AccountAPI } from './account';
5
5
  import type { KeelConfig } from './types';
6
6
  export { KeelApiError, isKeelApiError } from './errors';
7
- export type { KeelConfig, KeelModule, KeelErrorBody, KeelWalletAuth } from './types';
7
+ export type { KeelConfig, KeelModule, KeelErrorBody, KeelWalletAuth, KeelEnvelope } from './types';
8
8
  export declare class Keel {
9
9
  readonly payment: PaymentAPI;
10
10
  readonly wallet: WalletAPI;
package/dist/types.d.ts CHANGED
@@ -22,6 +22,12 @@ export interface KeelConfig {
22
22
  /** 钱包签名鉴权;设置后自动附加 x-wallet-address/signature/timestamp 请求头。 */
23
23
  wallet?: KeelWalletAuth;
24
24
  }
25
+ /** 统一信封(WAAS / MPC / Vault / aa-relay / data 自助面 2xx 响应)。 */
26
+ export interface KeelEnvelope<T> {
27
+ code: number | string;
28
+ message: string;
29
+ data: T;
30
+ }
25
31
  /** 统一错误体(契约 §3)。 */
26
32
  export interface KeelErrorBody {
27
33
  code: string;
@@ -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;
@@ -1,8 +1,9 @@
1
1
  import { HttpClient } from '../http';
2
+ import type { KeelEnvelope } from '../types';
2
3
  import type { CreateWalletParams, WalletCreated, ImportWalletParams, SignParams, SignResult, SendParams, SendResult, ChainParams, ChainResult, WalletBalanceParams, WalletBalanceResult } 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);
@@ -166,7 +167,7 @@ export declare class WalletAPI {
166
167
  /** MPC(email 分片钱包)子域:canonical `/v1/wallet/mpc/*`。 */
167
168
  mpc: {
168
169
  sendCode: (p: MpcSendCodeParams) => Promise<unknown>;
169
- register: (p: MpcVerifyParams) => Promise<unknown>;
170
+ register: (p: MpcRegisterParams) => Promise<KeelEnvelope<MpcRegisterResult>>;
170
171
  recover: (p: MpcVerifyParams) => Promise<unknown>;
171
172
  status: (email: string) => Promise<unknown>;
172
173
  wallets: (email?: string) => Promise<unknown>;
@@ -182,5 +183,13 @@ export declare class WalletAPI {
182
183
  contractRead: (p: MpcContractCallParams) => Promise<unknown>;
183
184
  contractWrite: (p: MpcContractWriteParams) => Promise<unknown>;
184
185
  gasEstimate: (p: MpcGasEstimateParams) => Promise<unknown>;
186
+ /**
187
+ * 签 Solana 交易 message **原文**(hex,可带 0x)。
188
+ * ⚠️ 不能传 32B 摘要:Solana 只认对原文的 Ed25519 签名(Ed25519ph 不被支持)。
189
+ * 返回 64B `R‖z`(128 hex,**无 0x**),无 `v` 恢复 id,用 `publicKey` 对账。
190
+ */
191
+ signSolana: (p: MpcSolanaSignParams) => Promise<KeelEnvelope<MpcSolanaSignResult>>;
192
+ /** 广播 base64 编码的**已签名**交易(经 chain-rpc `sendTransaction` + `getSignatureStatuses`)。 */
193
+ sendSolanaTransaction: (p: MpcSolanaSendParams) => Promise<KeelEnvelope<MpcSolanaSendResult>>;
185
194
  };
186
195
  }
@@ -97,6 +97,15 @@ class WalletAPI {
97
97
  contractRead: (p) => this.http.post('/v1/wallet/mpc/contract-read', p),
98
98
  contractWrite: (p) => this.http.post('/v1/wallet/mpc/contract-write', p),
99
99
  gasEstimate: (p) => this.http.post('/v1/wallet/mpc/gas-estimate', p),
100
+ // ── Solana(Ed25519 / FROST 2-of-3)──────────────────────────────────
101
+ /**
102
+ * 签 Solana 交易 message **原文**(hex,可带 0x)。
103
+ * ⚠️ 不能传 32B 摘要:Solana 只认对原文的 Ed25519 签名(Ed25519ph 不被支持)。
104
+ * 返回 64B `R‖z`(128 hex,**无 0x**),无 `v` 恢复 id,用 `publicKey` 对账。
105
+ */
106
+ signSolana: (p) => this.http.post('/v1/wallet/mpc/solana/sign', p),
107
+ /** 广播 base64 编码的**已签名**交易(经 chain-rpc `sendTransaction` + `getSignatureStatuses`)。 */
108
+ sendSolanaTransaction: (p) => this.http.post('/v1/wallet/mpc/solana/send-transaction', p),
100
109
  };
101
110
  }
102
111
  create(params) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keelcodes/sdk",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
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",