@keelcodes/sdk 2.1.3 → 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 留足余量。
@@ -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,6 +1,6 @@
1
1
  import { HttpClient } from '../http';
2
2
  import type { KeelEnvelope } from '../types';
3
- import type { CreateWalletParams, WalletCreated, ImportWalletParams, SignParams, SignResult, SendParams, SendResult, ChainParams, ChainResult, WalletBalanceParams, WalletBalanceResult } from './types';
3
+ import type { CreateWalletParams, WalletCreated, ImportWalletParams, SignParams, SignResult, SendParams, SendResult, ChainParams, ChainResult, WalletBalanceParams, WalletBalanceResult, SessionCreateParams, SessionCreated } from './types';
4
4
  import type { SolanaDeriveAccountParams, SolanaDerivedAccount, SolanaCreateAccountParams, SolanaInstallPolicyParams, SolanaCreatePolicyTransactionParams, SolanaCreateProposalParams, SolanaApproveProposalParams, SolanaExecutePolicyTransactionParams, SolanaRemovePolicyParams } from './solana-account-types';
5
5
  import type { SolanaExecutePolicyPayloadParams, SolanaCloseSettingsParams, SolanaCloseTransactionParams, SolanaExecutePolicyParams, SolanaExecuteParams, SolanaRemoveSignerParams, SolanaSubmitParams, SolanaUnsignedTransaction, SolanaSubmitResult } from './solana-execution-types';
6
6
  import type { MpcSendCodeParams, MpcVerifyParams, MpcBalanceParams, MpcSignMessageParams, MpcSignTypedDataParams, MpcSendTransactionParams, MpcContractCallParams, MpcContractWriteParams, MpcGasEstimateParams, MpcRegisterParams, MpcRegisterResult, MpcSolanaSignParams, MpcSolanaSignResult, MpcSolanaSendParams, MpcSolanaSendResult } from './mpc-types';
@@ -134,7 +134,8 @@ export declare class WalletAPI {
134
134
  }) => Promise<unknown>;
135
135
  };
136
136
  session: {
137
- create: (p: Record<string, unknown>) => Promise<unknown>;
137
+ /** 创建链上 session;传 `signer` 为客户自持 session key(relay 不生成、不落库私钥)。 */
138
+ create: (p: SessionCreateParams) => Promise<KeelEnvelope<SessionCreated>>;
138
139
  revoke: (sessionId: string) => Promise<unknown>;
139
140
  execute: (p: Record<string, unknown>) => Promise<unknown>;
140
141
  /** Solana(Squads Smart Account):构建未签名交易 + 广播已签名交易。 */
@@ -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),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keelcodes/sdk",
3
- "version": "2.1.3",
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",