@chipi-stack/backend 11.5.0 → 11.7.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/index.d.mts +104 -14
- package/dist/index.d.ts +104 -14
- package/dist/index.js +275 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +275 -86
- package/dist/index.mjs.map +1 -1
- package/dist/skuTransactions.d.mts +24 -0
- package/dist/skuTransactions.d.ts +24 -0
- package/dist/skuTransactions.js +311 -0
- package/dist/skuTransactions.js.map +1 -0
- package/dist/skuTransactions.mjs +305 -0
- package/dist/skuTransactions.mjs.map +1 -0
- package/dist/skus.d.mts +8 -1
- package/dist/skus.d.ts +8 -1
- package/dist/skus.js +16 -0
- package/dist/skus.js.map +1 -1
- package/dist/skus.mjs +16 -0
- package/dist/skus.mjs.map +1 -1
- package/dist/transactions.d.mts +7 -6
- package/dist/transactions.d.ts +7 -6
- package/dist/transactions.js +50 -30
- package/dist/transactions.js.map +1 -1
- package/dist/transactions.mjs +50 -30
- package/dist/transactions.mjs.map +1 -1
- package/package.json +19 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as _chipi_stack_types from '@chipi-stack/types';
|
|
2
|
-
import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse } from '@chipi-stack/types';
|
|
2
|
+
import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse, CreateSkuTransactionParams, SkuTransaction, ChipiServerSDKConfig, ChipiBrowserSDKConfig } from '@chipi-stack/types';
|
|
3
3
|
export * from '@chipi-stack/types';
|
|
4
4
|
import { ChipiWallets } from './wallets.mjs';
|
|
5
5
|
import { ChipiTransactions } from './transactions.mjs';
|
|
6
|
+
import { ChipiSkuTransactions } from './skuTransactions.mjs';
|
|
6
7
|
import { ChipiSkus } from './skus.mjs';
|
|
7
8
|
export { C as ChipiClient } from './client-D4ZnPqgQ.mjs';
|
|
8
9
|
|
|
@@ -12,67 +13,156 @@ export { C as ChipiClient } from './client-D4ZnPqgQ.mjs';
|
|
|
12
13
|
declare class ChipiSDK {
|
|
13
14
|
private client;
|
|
14
15
|
private nodeUrl;
|
|
16
|
+
private apiSecretKey?;
|
|
15
17
|
readonly wallets: ChipiWallets;
|
|
16
18
|
readonly transactions: ChipiTransactions;
|
|
19
|
+
readonly skuTransactions: ChipiSkuTransactions;
|
|
17
20
|
readonly skus: ChipiSkus;
|
|
18
21
|
constructor(config: ChipiSDKConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Resolve bearer token - uses provided token or falls back to apiSecretKey
|
|
24
|
+
*/
|
|
25
|
+
private resolveBearerToken;
|
|
19
26
|
/**
|
|
20
27
|
* Execute a gasless transaction
|
|
21
28
|
*/
|
|
22
|
-
executeTransaction(params
|
|
29
|
+
executeTransaction({ params, bearerToken, }: {
|
|
30
|
+
params: ExecuteTransactionParams;
|
|
31
|
+
bearerToken?: string;
|
|
32
|
+
}): Promise<string>;
|
|
23
33
|
/**
|
|
24
34
|
* Transfer tokens
|
|
25
35
|
*/
|
|
26
36
|
transfer({ params, bearerToken, }: {
|
|
27
37
|
params: TransferParams;
|
|
28
|
-
bearerToken
|
|
38
|
+
bearerToken?: string;
|
|
29
39
|
}): Promise<string>;
|
|
30
40
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
* Approve token spending
|
|
42
|
+
*/
|
|
33
43
|
approve({ params, bearerToken, }: {
|
|
34
44
|
params: ApproveParams;
|
|
35
|
-
bearerToken
|
|
45
|
+
bearerToken?: string;
|
|
36
46
|
}): Promise<string>;
|
|
37
47
|
/**
|
|
38
48
|
* Stake USDC in Vesu protocol
|
|
39
49
|
*/
|
|
40
50
|
stakeVesuUsdc({ params, bearerToken, }: {
|
|
41
51
|
params: StakeVesuUsdcParams;
|
|
42
|
-
bearerToken
|
|
52
|
+
bearerToken?: string;
|
|
43
53
|
}): Promise<string>;
|
|
44
54
|
/**
|
|
45
55
|
* Withdraw USDC from Vesu protocol
|
|
46
56
|
*/
|
|
47
57
|
withdrawVesuUsdc({ params, bearerToken, }: {
|
|
48
58
|
params: WithdrawVesuUsdcParams;
|
|
49
|
-
bearerToken
|
|
59
|
+
bearerToken?: string;
|
|
50
60
|
}): Promise<string>;
|
|
51
61
|
/**
|
|
52
62
|
* Call any contract method
|
|
53
63
|
*/
|
|
54
64
|
callAnyContract({ params, bearerToken, }: {
|
|
55
65
|
params: CallAnyContractParams;
|
|
56
|
-
bearerToken
|
|
66
|
+
bearerToken?: string;
|
|
57
67
|
}): Promise<string>;
|
|
58
68
|
/**
|
|
59
69
|
* Create a new wallet
|
|
60
70
|
*/
|
|
61
71
|
createWallet({ params, bearerToken, }: {
|
|
62
72
|
params: CreateWalletParams;
|
|
63
|
-
bearerToken
|
|
73
|
+
bearerToken?: string;
|
|
64
74
|
}): Promise<CreateWalletResponse>;
|
|
65
75
|
recordSendTransaction({ params, bearerToken, }: {
|
|
66
76
|
params: RecordSendTransactionParams;
|
|
67
|
-
bearerToken
|
|
77
|
+
bearerToken?: string;
|
|
68
78
|
}): Promise<Transaction>;
|
|
69
|
-
getWallet(params: GetWalletParams, bearerToken
|
|
79
|
+
getWallet(params: GetWalletParams, bearerToken?: string): Promise<(_chipi_stack_types.GetWalletResponse & {
|
|
70
80
|
normalizedPublicKey: string;
|
|
71
81
|
}) | null>;
|
|
72
|
-
getTokenBalance(params: GetTokenBalanceParams, bearerToken
|
|
82
|
+
getTokenBalance(params: GetTokenBalanceParams, bearerToken?: string): Promise<GetTokenBalanceResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Create a SKU transaction
|
|
85
|
+
*/
|
|
86
|
+
createSkuTransaction({ params, bearerToken, }: {
|
|
87
|
+
params: CreateSkuTransactionParams;
|
|
88
|
+
bearerToken: string;
|
|
89
|
+
}): Promise<SkuTransaction>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Server-side Chipi SDK with built-in API Secret Key authentication
|
|
94
|
+
*
|
|
95
|
+
* This class is designed for server-side environments where you can safely store
|
|
96
|
+
* the API Secret Key. All methods automatically use the secret key for authentication,
|
|
97
|
+
* so you don't need to pass a bearer token with each call.
|
|
98
|
+
*
|
|
99
|
+
* The apiSecretKey is stored internally and used automatically for all authenticated requests.
|
|
100
|
+
* All methods from ChipiSDK are inherited and work without requiring a bearerToken parameter.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const chipiServer = new ChipiServerSDK({
|
|
105
|
+
* apiPublicKey: "pk_...",
|
|
106
|
+
* apiSecretKey: "sk_...",
|
|
107
|
+
* environment: "production"
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* // No bearer token needed - automatically uses apiSecretKey!
|
|
111
|
+
* const wallet = await chipiServer.createWallet({
|
|
112
|
+
* params: {
|
|
113
|
+
* encryptKey: "user-encryption-key",
|
|
114
|
+
* externalUserId: "user-123"
|
|
115
|
+
* }
|
|
116
|
+
* });
|
|
117
|
+
*
|
|
118
|
+
* const userWallet = await chipiServer.getWallet({ externalUserId: "user-123" });
|
|
119
|
+
* const txHash = await chipiServer.transfer({ params: { ... } });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
declare class ChipiServerSDK extends ChipiSDK {
|
|
123
|
+
constructor(config: ChipiServerSDKConfig);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Browser-side Chipi SDK for client-side applications
|
|
128
|
+
*
|
|
129
|
+
* This class is designed for browser environments (Vue, Svelte, Angular, vanilla JS, etc.)
|
|
130
|
+
* where you need to pass a bearer token (JWT) with each authenticated request.
|
|
131
|
+
*
|
|
132
|
+
* All methods require a bearerToken parameter since browser environments should not
|
|
133
|
+
* store API Secret Keys.
|
|
134
|
+
*
|
|
135
|
+
* ⚠️ SECURITY WARNING: DO NOT use your API Secret Key in browser environments!
|
|
136
|
+
* The secret key should only be used server-side with ChipiServerSDK.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const chipiBrowser = new ChipiBrowserSDK({
|
|
141
|
+
* apiPublicKey: "pk_...",
|
|
142
|
+
* environment: "production"
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
* // Get user's JWT token from your auth system
|
|
146
|
+
* const userToken = await getUserJWT();
|
|
147
|
+
*
|
|
148
|
+
* // Pass bearer token with each call
|
|
149
|
+
* const wallet = await chipiBrowser.createWallet({
|
|
150
|
+
* params: {
|
|
151
|
+
* encryptKey: "user-encryption-key",
|
|
152
|
+
* externalUserId: "user-123"
|
|
153
|
+
* },
|
|
154
|
+
* bearerToken: userToken
|
|
155
|
+
* });
|
|
156
|
+
*
|
|
157
|
+
* const userWallet = await chipiBrowser.getWallet({ externalUserId: "user-123" }, userToken);
|
|
158
|
+
* const txHash = await chipiBrowser.transfer({ params: {...}, bearerToken: userToken });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
declare class ChipiBrowserSDK extends ChipiSDK {
|
|
162
|
+
constructor(config: ChipiBrowserSDKConfig);
|
|
73
163
|
}
|
|
74
164
|
|
|
75
165
|
declare const encryptPrivateKey: (privateKey: string, password: string) => string;
|
|
76
166
|
declare const decryptPrivateKey: (encryptedPrivateKey: string, password: string) => string;
|
|
77
167
|
|
|
78
|
-
export { ChipiSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
|
|
168
|
+
export { ChipiBrowserSDK, ChipiSDK, ChipiServerSDK, ChipiSkuTransactions, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as _chipi_stack_types from '@chipi-stack/types';
|
|
2
|
-
import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse } from '@chipi-stack/types';
|
|
2
|
+
import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction, GetWalletParams, GetTokenBalanceParams, GetTokenBalanceResponse, CreateSkuTransactionParams, SkuTransaction, ChipiServerSDKConfig, ChipiBrowserSDKConfig } from '@chipi-stack/types';
|
|
3
3
|
export * from '@chipi-stack/types';
|
|
4
4
|
import { ChipiWallets } from './wallets.js';
|
|
5
5
|
import { ChipiTransactions } from './transactions.js';
|
|
6
|
+
import { ChipiSkuTransactions } from './skuTransactions.js';
|
|
6
7
|
import { ChipiSkus } from './skus.js';
|
|
7
8
|
export { C as ChipiClient } from './client-D4ZnPqgQ.js';
|
|
8
9
|
|
|
@@ -12,67 +13,156 @@ export { C as ChipiClient } from './client-D4ZnPqgQ.js';
|
|
|
12
13
|
declare class ChipiSDK {
|
|
13
14
|
private client;
|
|
14
15
|
private nodeUrl;
|
|
16
|
+
private apiSecretKey?;
|
|
15
17
|
readonly wallets: ChipiWallets;
|
|
16
18
|
readonly transactions: ChipiTransactions;
|
|
19
|
+
readonly skuTransactions: ChipiSkuTransactions;
|
|
17
20
|
readonly skus: ChipiSkus;
|
|
18
21
|
constructor(config: ChipiSDKConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Resolve bearer token - uses provided token or falls back to apiSecretKey
|
|
24
|
+
*/
|
|
25
|
+
private resolveBearerToken;
|
|
19
26
|
/**
|
|
20
27
|
* Execute a gasless transaction
|
|
21
28
|
*/
|
|
22
|
-
executeTransaction(params
|
|
29
|
+
executeTransaction({ params, bearerToken, }: {
|
|
30
|
+
params: ExecuteTransactionParams;
|
|
31
|
+
bearerToken?: string;
|
|
32
|
+
}): Promise<string>;
|
|
23
33
|
/**
|
|
24
34
|
* Transfer tokens
|
|
25
35
|
*/
|
|
26
36
|
transfer({ params, bearerToken, }: {
|
|
27
37
|
params: TransferParams;
|
|
28
|
-
bearerToken
|
|
38
|
+
bearerToken?: string;
|
|
29
39
|
}): Promise<string>;
|
|
30
40
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
* Approve token spending
|
|
42
|
+
*/
|
|
33
43
|
approve({ params, bearerToken, }: {
|
|
34
44
|
params: ApproveParams;
|
|
35
|
-
bearerToken
|
|
45
|
+
bearerToken?: string;
|
|
36
46
|
}): Promise<string>;
|
|
37
47
|
/**
|
|
38
48
|
* Stake USDC in Vesu protocol
|
|
39
49
|
*/
|
|
40
50
|
stakeVesuUsdc({ params, bearerToken, }: {
|
|
41
51
|
params: StakeVesuUsdcParams;
|
|
42
|
-
bearerToken
|
|
52
|
+
bearerToken?: string;
|
|
43
53
|
}): Promise<string>;
|
|
44
54
|
/**
|
|
45
55
|
* Withdraw USDC from Vesu protocol
|
|
46
56
|
*/
|
|
47
57
|
withdrawVesuUsdc({ params, bearerToken, }: {
|
|
48
58
|
params: WithdrawVesuUsdcParams;
|
|
49
|
-
bearerToken
|
|
59
|
+
bearerToken?: string;
|
|
50
60
|
}): Promise<string>;
|
|
51
61
|
/**
|
|
52
62
|
* Call any contract method
|
|
53
63
|
*/
|
|
54
64
|
callAnyContract({ params, bearerToken, }: {
|
|
55
65
|
params: CallAnyContractParams;
|
|
56
|
-
bearerToken
|
|
66
|
+
bearerToken?: string;
|
|
57
67
|
}): Promise<string>;
|
|
58
68
|
/**
|
|
59
69
|
* Create a new wallet
|
|
60
70
|
*/
|
|
61
71
|
createWallet({ params, bearerToken, }: {
|
|
62
72
|
params: CreateWalletParams;
|
|
63
|
-
bearerToken
|
|
73
|
+
bearerToken?: string;
|
|
64
74
|
}): Promise<CreateWalletResponse>;
|
|
65
75
|
recordSendTransaction({ params, bearerToken, }: {
|
|
66
76
|
params: RecordSendTransactionParams;
|
|
67
|
-
bearerToken
|
|
77
|
+
bearerToken?: string;
|
|
68
78
|
}): Promise<Transaction>;
|
|
69
|
-
getWallet(params: GetWalletParams, bearerToken
|
|
79
|
+
getWallet(params: GetWalletParams, bearerToken?: string): Promise<(_chipi_stack_types.GetWalletResponse & {
|
|
70
80
|
normalizedPublicKey: string;
|
|
71
81
|
}) | null>;
|
|
72
|
-
getTokenBalance(params: GetTokenBalanceParams, bearerToken
|
|
82
|
+
getTokenBalance(params: GetTokenBalanceParams, bearerToken?: string): Promise<GetTokenBalanceResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Create a SKU transaction
|
|
85
|
+
*/
|
|
86
|
+
createSkuTransaction({ params, bearerToken, }: {
|
|
87
|
+
params: CreateSkuTransactionParams;
|
|
88
|
+
bearerToken: string;
|
|
89
|
+
}): Promise<SkuTransaction>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Server-side Chipi SDK with built-in API Secret Key authentication
|
|
94
|
+
*
|
|
95
|
+
* This class is designed for server-side environments where you can safely store
|
|
96
|
+
* the API Secret Key. All methods automatically use the secret key for authentication,
|
|
97
|
+
* so you don't need to pass a bearer token with each call.
|
|
98
|
+
*
|
|
99
|
+
* The apiSecretKey is stored internally and used automatically for all authenticated requests.
|
|
100
|
+
* All methods from ChipiSDK are inherited and work without requiring a bearerToken parameter.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const chipiServer = new ChipiServerSDK({
|
|
105
|
+
* apiPublicKey: "pk_...",
|
|
106
|
+
* apiSecretKey: "sk_...",
|
|
107
|
+
* environment: "production"
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* // No bearer token needed - automatically uses apiSecretKey!
|
|
111
|
+
* const wallet = await chipiServer.createWallet({
|
|
112
|
+
* params: {
|
|
113
|
+
* encryptKey: "user-encryption-key",
|
|
114
|
+
* externalUserId: "user-123"
|
|
115
|
+
* }
|
|
116
|
+
* });
|
|
117
|
+
*
|
|
118
|
+
* const userWallet = await chipiServer.getWallet({ externalUserId: "user-123" });
|
|
119
|
+
* const txHash = await chipiServer.transfer({ params: { ... } });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
declare class ChipiServerSDK extends ChipiSDK {
|
|
123
|
+
constructor(config: ChipiServerSDKConfig);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Browser-side Chipi SDK for client-side applications
|
|
128
|
+
*
|
|
129
|
+
* This class is designed for browser environments (Vue, Svelte, Angular, vanilla JS, etc.)
|
|
130
|
+
* where you need to pass a bearer token (JWT) with each authenticated request.
|
|
131
|
+
*
|
|
132
|
+
* All methods require a bearerToken parameter since browser environments should not
|
|
133
|
+
* store API Secret Keys.
|
|
134
|
+
*
|
|
135
|
+
* ⚠️ SECURITY WARNING: DO NOT use your API Secret Key in browser environments!
|
|
136
|
+
* The secret key should only be used server-side with ChipiServerSDK.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const chipiBrowser = new ChipiBrowserSDK({
|
|
141
|
+
* apiPublicKey: "pk_...",
|
|
142
|
+
* environment: "production"
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
* // Get user's JWT token from your auth system
|
|
146
|
+
* const userToken = await getUserJWT();
|
|
147
|
+
*
|
|
148
|
+
* // Pass bearer token with each call
|
|
149
|
+
* const wallet = await chipiBrowser.createWallet({
|
|
150
|
+
* params: {
|
|
151
|
+
* encryptKey: "user-encryption-key",
|
|
152
|
+
* externalUserId: "user-123"
|
|
153
|
+
* },
|
|
154
|
+
* bearerToken: userToken
|
|
155
|
+
* });
|
|
156
|
+
*
|
|
157
|
+
* const userWallet = await chipiBrowser.getWallet({ externalUserId: "user-123" }, userToken);
|
|
158
|
+
* const txHash = await chipiBrowser.transfer({ params: {...}, bearerToken: userToken });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
declare class ChipiBrowserSDK extends ChipiSDK {
|
|
162
|
+
constructor(config: ChipiBrowserSDKConfig);
|
|
73
163
|
}
|
|
74
164
|
|
|
75
165
|
declare const encryptPrivateKey: (privateKey: string, password: string) => string;
|
|
76
166
|
declare const decryptPrivateKey: (encryptedPrivateKey: string, password: string) => string;
|
|
77
167
|
|
|
78
|
-
export { ChipiSDK, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
|
|
168
|
+
export { ChipiBrowserSDK, ChipiSDK, ChipiServerSDK, ChipiSkuTransactions, ChipiSkus, ChipiTransactions, ChipiWallets, decryptPrivateKey, encryptPrivateKey };
|