@pakt/psilo 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Pakt
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # PsiloSDK
2
+
3
+ PsiloSDK is the official TypeScript SDK for interacting computationally with Pakt's production-ready EVM single-use, non-custodial, MPC-protected escrow wallets via the Model Context Protocol (MCP) compatible backend.
4
+
5
+ It is designed to be fully AI-native and provide seamless interoperability for creating, managing, and releasing Escrow objects that leverage Pakt's `Psilo-Contracts`.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @pakt/psilo-sdk
11
+ # OR
12
+ yarn add @pakt/psilo-sdk
13
+ ```
14
+
15
+ ## Setup & Initialization
16
+
17
+ You must initialize the SDK by pointing it to the deployed MCP-compatible endpoint hosting the Psilo backend server.
18
+
19
+ ```typescript
20
+ import { PsiloSDK } from "@pakt/psilo-sdk";
21
+
22
+ const sdk = await PsiloSDK.init({
23
+ baseUrl: "http://localhost:3000", // Example backend or MCP deployment URL
24
+ verbose: true // Optional logging
25
+ });
26
+ ```
27
+
28
+ ## Features: Escrow Management
29
+
30
+ The SDK maps all features designed within the `Psilo-Contracts/MCP_INTEGRATION.md`.
31
+
32
+ ### 1. Compute Address
33
+ Compute an expected escrow address deterministically before deploying it.
34
+
35
+ ```typescript
36
+ const computed = await sdk.escrow.computeAddress({
37
+ sender: "0xSenderAddress...",
38
+ receiver: "0xReceiverAddress...",
39
+ asset: "0x0000000000000000000000000000000000000000", // ETH
40
+ amount: "1000000000000000000",
41
+ originator: "0xOriginator...",
42
+ salt: "0x123..."
43
+ });
44
+ console.log("Predicted address:", computed.data.predictedAddress);
45
+ ```
46
+
47
+ ### 2. Create Escrow
48
+ Create a new escrow on the blockchain.
49
+
50
+ ```typescript
51
+ const escrowResponse = await sdk.escrow.create({
52
+ sender: "0xSenderAddress...",
53
+ receiver: "0xReceiverAddress...",
54
+ asset: "0x0000000000000000000000000000000000000000",
55
+ amount: "1000000000000000000",
56
+ originator: "0xOriginator...",
57
+ salt: "0xSomeDeterministicSalt...",
58
+ metadataHash: "0xOptionalMetadata..."
59
+ });
60
+ const escrowAddress = escrowResponse.data.escrowAddress;
61
+ ```
62
+
63
+ ### 3. Deposit
64
+ Fund a created escrow.
65
+
66
+ ```typescript
67
+ await sdk.escrow.deposit(escrowAddress, {
68
+ from: "0xSenderAddress..."
69
+ });
70
+ ```
71
+
72
+ ### 4. Status and Listing
73
+ Query statuses and lists of active escrows.
74
+
75
+ ```typescript
76
+ // Query one
77
+ const status = await sdk.escrow.getStatus(escrowAddress);
78
+ console.log("Status:", status.data.deposited, status.data.released);
79
+
80
+ // Query all
81
+ const escrows = await sdk.escrow.list({
82
+ sender: "0xSenderAddress...",
83
+ status: "deposited"
84
+ });
85
+ ```
86
+
87
+ ### 5. Multi-Party Approval & Release
88
+ The MPC-shard functionality is exposed through signing a release using 2-of-3 configured authority.
89
+
90
+ ```typescript
91
+ // Ask the sender to sign
92
+ const senderSignature = await sdk.escrow.signRelease(escrowAddress, {
93
+ signerAddress: "0xSenderAddress...",
94
+ privateKey: "0x..." // Optional if managed by the MCP server environment
95
+ });
96
+
97
+ // Ask the receiver to sign
98
+ const receiverSignature = await sdk.escrow.signRelease(escrowAddress, {
99
+ signerAddress: "0xReceiverAddress..."
100
+ });
101
+
102
+ // Release funds
103
+ await sdk.escrow.release(escrowAddress, {
104
+ signatures: [senderSignature.data.signature, receiverSignature.data.signature],
105
+ executor: "0xExecutorAddress..."
106
+ });
107
+ ```
package/dist/main.d.ts ADDED
@@ -0,0 +1,258 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+
3
+ declare class Connector {
4
+ private readonly client;
5
+ constructor(baseURL: string);
6
+ setHeader(key: string, value: string): void;
7
+ removeHeader(key: string): void;
8
+ private handleResponse;
9
+ private handleError;
10
+ get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
11
+ post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
12
+ put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
13
+ delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
14
+ }
15
+
16
+ interface StandardResponse<T> {
17
+ success: boolean;
18
+ data: T;
19
+ error?: {
20
+ code: string;
21
+ message: string;
22
+ details?: any;
23
+ };
24
+ }
25
+
26
+ declare enum Status {
27
+ SUCCESS = "success",
28
+ ERROR = "error"
29
+ }
30
+ interface ResponseDto<T> {
31
+ data: T;
32
+ status: Status;
33
+ message?: string;
34
+ code?: number;
35
+ statusCode?: number;
36
+ validation?: Record<string, any>;
37
+ }
38
+ type IAny = any;
39
+ type ErrorWithMessage = {
40
+ message: string[] | object[] | any;
41
+ code?: string;
42
+ };
43
+ declare const ErrorUtils: {
44
+ newTryFail: <T>(f: (() => Promise<T>) | (() => T)) => Promise<T>;
45
+ formatErrorMsg: (message: string) => string;
46
+ toErrorWithMessage: (maybeError: unknown) => ErrorWithMessage;
47
+ isErrorWithMessage(e: unknown): e is ErrorWithMessage;
48
+ };
49
+ declare const parseUrlWithQuery: (url: string, filter: object | any) => string;
50
+
51
+ interface EscrowModuleType {
52
+ create(data: CreateEscrowDto): Promise<ResponseDto<CreateEscrowResponse>>;
53
+ getStatus(chainId: string, escrowAddress: string): Promise<ResponseDto<EscrowStatusResponse>>;
54
+ release(escrowAddress: string, data?: ReleaseDto): Promise<ResponseDto<ReleaseResponse>>;
55
+ updateStatus(escrowAddress: string, data: UpdateEscrowStatusDto): Promise<ResponseDto<PrepareTransactionResponse>>;
56
+ prepareRelease(escrowAddress: string, recipient?: string): Promise<ResponseDto<PrepareTransactionResponse>>;
57
+ list(params?: ListEscrowsParams): Promise<ResponseDto<ListEscrowsResponse>>;
58
+ getChains(): Promise<ResponseDto<GetEscrowChainsResponseDto>>;
59
+ getAssets(chainId: string): Promise<ResponseDto<GetEscrowAssetsResponseDto>>;
60
+ }
61
+ interface CreateEscrowDto {
62
+ chainId: string;
63
+ buyer: string;
64
+ seller: string;
65
+ title: string;
66
+ description?: string;
67
+ amount: string;
68
+ asset: string;
69
+ expiration?: string;
70
+ releaseType?: string;
71
+ }
72
+ interface CreateEscrowResponse {
73
+ buyerWallet: string;
74
+ sellerWallet: string;
75
+ arbiterWallet: string;
76
+ title: string;
77
+ description: string | null;
78
+ amount: number | string;
79
+ expiration: string;
80
+ releaseType: number | string;
81
+ metadataHash: string;
82
+ chainId: string | null;
83
+ onChain: {
84
+ txHash: string;
85
+ escrowAddress: string;
86
+ approve: {
87
+ to: string;
88
+ data: string;
89
+ value: string;
90
+ } | null;
91
+ deposit: {
92
+ to: string;
93
+ data: string;
94
+ value: string;
95
+ };
96
+ };
97
+ }
98
+ interface ComputeAddressParams {
99
+ sender: string;
100
+ receiver: string;
101
+ asset: string;
102
+ amount: string;
103
+ originator: string;
104
+ salt: string;
105
+ metadataHash?: string;
106
+ }
107
+ interface ComputeAddressResponse {
108
+ predictedAddress: string;
109
+ exists: boolean;
110
+ }
111
+ interface EscrowStatusResponse {
112
+ chainId: string;
113
+ escrow: string;
114
+ buyer: string;
115
+ seller: string;
116
+ arbiter: string;
117
+ deposited: boolean;
118
+ released: boolean;
119
+ readyForRelease: boolean;
120
+ buyerReleaseReady: boolean;
121
+ balance: string;
122
+ }
123
+ interface DepositDto {
124
+ from: string;
125
+ }
126
+ interface DepositResponse {
127
+ transactionHash: string;
128
+ blockNumber: number;
129
+ deposited: boolean;
130
+ balance: string;
131
+ }
132
+ interface SignReleaseDto {
133
+ signerAddress: string;
134
+ privateKey?: string;
135
+ }
136
+ interface SignReleaseResponse {
137
+ signature: string;
138
+ messageHash: string;
139
+ signer: string;
140
+ isShardholder: boolean;
141
+ shardRole: string;
142
+ }
143
+ interface ReleaseDto {
144
+ recipient?: string;
145
+ }
146
+ interface ReleaseResponse {
147
+ success: boolean;
148
+ txHash: string;
149
+ escrowAddress: string;
150
+ arbiter: string;
151
+ }
152
+ interface UpdateEscrowStatusDto {
153
+ chainId: string;
154
+ escrow: string;
155
+ address: string;
156
+ }
157
+ interface PrepareTransactionResponse {
158
+ to: string;
159
+ data: string;
160
+ value: string;
161
+ chainId: string;
162
+ gas: string;
163
+ maxFeePerGas: string;
164
+ maxPriorityFeePerGas: string;
165
+ type: string;
166
+ instructions: string;
167
+ seller?: string;
168
+ buyer?: string;
169
+ nonce?: string;
170
+ }
171
+ interface ListEscrowsParams {
172
+ sender?: string;
173
+ receiver?: string;
174
+ status?: "pending" | "deposited" | "released";
175
+ page?: number;
176
+ limit?: number;
177
+ }
178
+ interface EscrowListItem {
179
+ address: string;
180
+ sender: string;
181
+ receiver: string;
182
+ asset: string;
183
+ amount: string;
184
+ deposited: boolean;
185
+ released: boolean;
186
+ createdAt: string;
187
+ }
188
+ interface ListEscrowsResponse {
189
+ total: number;
190
+ page: number;
191
+ limit: number;
192
+ escrows: EscrowListItem[];
193
+ }
194
+ interface EscrowNativeCurrencyDto {
195
+ name: string;
196
+ symbol: string;
197
+ decimals: number;
198
+ }
199
+ interface EscrowChainDto {
200
+ chainId: string;
201
+ name: string;
202
+ network: string;
203
+ nativeCurrency: EscrowNativeCurrencyDto;
204
+ }
205
+ interface GetEscrowChainsResponseDto {
206
+ chains: EscrowChainDto[];
207
+ }
208
+ interface EscrowAssetDto {
209
+ address: string;
210
+ symbol: string;
211
+ name: string;
212
+ decimals: number;
213
+ isNative: boolean;
214
+ }
215
+ interface GetEscrowAssetsResponseDto {
216
+ chainId: string;
217
+ assets: EscrowAssetDto[];
218
+ }
219
+
220
+ declare class EscrowService implements EscrowModuleType {
221
+ private id;
222
+ private connector;
223
+ constructor(id: string);
224
+ create(data: CreateEscrowDto): Promise<ResponseDto<CreateEscrowResponse>>;
225
+ getStatus(chainId: string, escrowAddress: string): Promise<ResponseDto<EscrowStatusResponse>>;
226
+ updateStatus(escrowAddress: string, data: {
227
+ chainId: string;
228
+ address: string;
229
+ }): Promise<ResponseDto<PrepareTransactionResponse>>;
230
+ prepareRelease(escrowAddress: string, recipient?: string): Promise<ResponseDto<PrepareTransactionResponse>>;
231
+ release(escrowAddress: string, data?: {
232
+ recipient?: string;
233
+ }): Promise<ResponseDto<ReleaseResponse>>;
234
+ list(params?: ListEscrowsParams): Promise<ResponseDto<ListEscrowsResponse>>;
235
+ getChains(): Promise<ResponseDto<GetEscrowChainsResponseDto>>;
236
+ getAssets(chainId: string): Promise<ResponseDto<GetEscrowAssetsResponseDto>>;
237
+ }
238
+
239
+ interface PsiloSDKConfig {
240
+ baseUrl: string;
241
+ verbose?: boolean;
242
+ }
243
+ declare class PsiloSDK {
244
+ readonly escrow: EscrowService;
245
+ readonly connector: Connector;
246
+ constructor(id: string);
247
+ static init(config: PsiloSDKConfig): Promise<PsiloSDK>;
248
+ setAuthorizationHeader(token: string): void;
249
+ private static generateRandomString;
250
+ }
251
+
252
+ declare class SDKError extends Error {
253
+ readonly code?: string;
254
+ readonly details?: any;
255
+ constructor(message: string, code?: string, details?: any);
256
+ }
257
+
258
+ export { ComputeAddressParams, ComputeAddressResponse, Connector, CreateEscrowDto, CreateEscrowResponse, DepositDto, DepositResponse, ErrorUtils, EscrowAssetDto, EscrowChainDto, EscrowListItem, EscrowModuleType, EscrowNativeCurrencyDto, EscrowService, EscrowStatusResponse, GetEscrowAssetsResponseDto, GetEscrowChainsResponseDto, IAny, ListEscrowsParams, ListEscrowsResponse, PrepareTransactionResponse, PsiloSDK, PsiloSDKConfig, ReleaseDto, ReleaseResponse, ResponseDto, SDKError, SignReleaseDto, SignReleaseResponse, StandardResponse, Status, UpdateEscrowStatusDto, parseUrlWithQuery };
package/dist/main.js ADDED
@@ -0,0 +1,2 @@
1
+ var B=Object.create;var d=Object.defineProperty,K=Object.defineProperties,_=Object.getOwnPropertyDescriptor,G=Object.getOwnPropertyDescriptors,V=Object.getOwnPropertyNames,v=Object.getOwnPropertySymbols,X=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var j=(r,t,e)=>t in r?d(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,u=(r,t)=>{for(var e in t||(t={}))C.call(t,e)&&j(r,e,t[e]);if(v)for(var e of v(t))Y.call(t,e)&&j(r,e,t[e]);return r},z=(r,t)=>K(r,G(t)),o=(r,t)=>d(r,"name",{value:t,configurable:!0});var Z=(r,t)=>{for(var e in t)d(r,e,{get:t[e],enumerable:!0})},J=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of V(t))!C.call(r,n)&&n!==e&&d(r,n,{get:()=>t[n],enumerable:!(s=_(t,n))||s.enumerable});return r};var k=(r,t,e)=>(e=r!=null?B(X(r)):{},J(t||!r||!r.__esModule?d(e,"default",{value:r,enumerable:!0}):e,r)),tt=r=>J(d({},"__esModule",{value:!0}),r);var i=(r,t,e)=>(j(r,typeof t!="symbol"?t+"":t,e),e);var it={};Z(it,{Connector:()=>l,ErrorUtils:()=>c,EscrowService:()=>f,PsiloSDK:()=>R,SDKError:()=>m,Status:()=>nt,parseUrlWithQuery:()=>A});module.exports=tt(it);var ce=require("reflect-metadata");var w=require("typedi");var D=k(require("axios"));var F=class F extends Error{constructor(e,s,n){super(e);i(this,"code");i(this,"details");this.name="SDKError",this.code=s,this.details=n}};o(F,"SDKError");var m=F;var S=class S{constructor(t){i(this,"client");this.client=D.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}setHeader(t,e){this.client.defaults.headers.common[t]=e}removeHeader(t){delete this.client.defaults.headers.common[t]}handleResponse(t){var s,n,a;let e=t.data;if(e&&e.success===!1)throw new m(((s=e.error)==null?void 0:s.message)||"Unknown error",((n=e.error)==null?void 0:n.code)||"API_ERROR",(a=e.error)==null?void 0:a.details);return e}handleError(t){var e,s;if(D.default.isAxiosError(t)){let n=(e=t.response)==null?void 0:e.data;throw n&&n.error?new m(n.error.message||t.message,n.error.code||"REQUEST_ERROR",n.error.details):new m(t.message,t.code,(s=t.response)==null?void 0:s.data)}throw new m(t.message||"An unexpected error occurred","INTERNAL_ERROR")}async get(t,e){try{let s=await this.client.get(t,e);return this.handleResponse(s)}catch(s){this.handleError(s)}}async post(t,e,s){try{let n=await this.client.post(t,e,s);return this.handleResponse(n)}catch(n){this.handleError(n)}}async put(t,e,s){try{let n=await this.client.put(t,e,s);return this.handleResponse(n)}catch(n){this.handleError(n)}}async delete(t,e){try{let s=await this.client.delete(t,e);return this.handleResponse(s)}catch(s){this.handleError(s)}}};o(S,"Connector");var l=S;var E=require("typedi");var et={delayFirstAttempt:!1,jitter:"none",maxDelay:1/0,numOfAttempts:10,retry:()=>!0,startingDelay:100,timeMultiple:2};function P(r){let t=u(u({},et),r);return t.numOfAttempts<1&&(t.numOfAttempts=1),t}o(P,"getSanitizedOptions");function W(r){let t=Math.random()*r;return Math.round(t)}o(W,"fullJitter");function $(r){return r}o($,"noJitter");function q(r){switch(r.jitter){case"full":return W;case"none":default:return $}}o(q,"JitterFactory");var M=class M{constructor(t){i(this,"options");i(this,"attempt",0);this.options=t}apply(){return new Promise(t=>setTimeout(t,this.jitteredDelay))}setAttemptNumber(t){this.attempt=t}get jitteredDelay(){return q(this.options)(this.delay)}get delay(){let t=this.options.startingDelay,e=this.options.timeMultiple,s=this.numOfDelayedAttempts,n=t*Math.pow(e,s);return Math.min(n,this.options.maxDelay)}get numOfDelayedAttempts(){return this.attempt}};o(M,"Delay");var y=M;var T=class T extends y{async apply(){return this.isFirstAttempt?!0:super.apply()}get isFirstAttempt(){return this.attempt===0}get numOfDelayedAttempts(){return this.attempt-1}};o(T,"SkipFirstDelay");var O=T;var U=class U extends y{};o(U,"AlwaysDelay");var b=U;function I(r,t){let e=rt(r);return e.setAttemptNumber(t),e}o(I,"DelayFactory");function rt(r){return r.delayFirstAttempt?new b(r):new O(r)}o(rt,"initDelayClass");async function H(r,t={}){let e=P(t);return await new st(r,e).execute()}o(H,"backOff");var g,st=(g=class{constructor(t,e){i(this,"request");i(this,"options");i(this,"attemptNumber",0);this.request=t,this.options=e}async execute(){for(;!this.attemptLimitReached;)try{return await this.applyDelay(),await this.request()}catch(t){if(this.attemptNumber++,!await this.options.retry(t,this.attemptNumber)||this.attemptLimitReached)throw t}throw new Error("Something went wrong.")}get attemptLimitReached(){return this.attemptNumber>=this.options.numOfAttempts}async applyDelay(){await I(this.options,this.attemptNumber).apply()}},o(g,"BackOff"),g);var nt=function(r){return r.SUCCESS="success",r.ERROR="error",r}({}),c={newTryFail:async r=>{try{let t=await H(async()=>await r(),{startingDelay:50,timeMultiple:10,numOfAttempts:10,maxDelay:3550,delayFirstAttempt:!1});return u({},t)}catch(t){let e=c.toErrorWithMessage(t);return{data:null,status:"error",message:e?e.message:["Internal Server Error"],code:e.code}}},formatErrorMsg:r=>r.replace("attr.",""),toErrorWithMessage:r=>{var t;if(typeof r=="string")try{let e=JSON.parse(r);return e.data instanceof Array&&e.data.length>0?{message:e.data.map(s=>c.formatErrorMsg(s)),code:e.errorCode}:{message:[(t=e.message)!=null?t:r],code:e.errorCode}}catch(e){}if(c.isErrorWithMessage(r))return{message:[r.message]};try{return{message:[JSON.stringify(r,null,2)]}}catch(e){return{message:[String(r)]}}},isErrorWithMessage(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}},A=o((r,t)=>{let e="?",s=Object.keys(t||{});return s.length===0?r:(s.map((n,a)=>{let p="&";(n===void 0||n==="undefined"||n===null||n==="null"||n.length===0)&&(e=e),a+1===s.length&&(p=""),e=e+`${n}=${t[n]}${p}`}),r+e)},"parseUrlWithQuery");function ot(r,t,e,s){var n=arguments.length,a=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,s);else for(var h=r.length-1;h>=0;h--)(p=r[h])&&(a=(n<3?p(a):n>3?p(t,e,a):p(t,e))||a);return n>3&&a&&Object.defineProperty(t,e,a),a}o(ot,"_ts_decorate");function L(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}o(L,"_ts_metadata");var N=class N{constructor(t){i(this,"id");i(this,"connector");this.id=t,this.connector=E.Container.of(this.id).get(l)}async create(t){return c.newTryFail(async()=>await this.connector.post("/api/escrow/create",t))}async getStatus(t,e){return c.newTryFail(async()=>{let s=A("/api/escrow/status",{chainId:t,escrow:e});return await this.connector.get(s)})}async updateStatus(t,e){return c.newTryFail(async()=>{let s=z(u({},e),{escrow:t});return await this.connector.post("/api/escrow/update",s)})}async prepareRelease(t,e){return c.newTryFail(async()=>{let s=e?{escrowAddress:t,recipient:e}:{escrowAddress:t};return await this.connector.post("/api/escrow/prepare-release",s)})}async release(t,e){return c.newTryFail(async()=>{let s=u({escrowAddress:t},e||{});return await this.connector.post("/api/escrow/release",s)})}async list(t){return c.newTryFail(async()=>{let e=t?A("/api/escrows",t):"/api/escrows";return await this.connector.get(e)})}async getChains(){return c.newTryFail(async()=>await this.connector.get("/api/escrow/chains"))}async getAssets(t){return c.newTryFail(async()=>await this.connector.get(`/api/escrow/assets/${t}`))}};o(N,"EscrowService");var f=N;f=ot([(0,E.Service)({factory:r=>new f(r.id),transient:!0}),L("design:type",Function),L("design:paramtypes",[String])],f);function at(r,t,e,s){var n=arguments.length,a=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,s);else for(var h=r.length-1;h>=0;h--)(p=r[h])&&(a=(n<3?p(a):n>3?p(t,e,a):p(t,e))||a);return n>3&&a&&Object.defineProperty(t,e,a),a}o(at,"_ts_decorate");function Q(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}o(Q,"_ts_metadata");var x=class x{constructor(t){i(this,"escrow");i(this,"connector");this.connector=w.Container.of(t).get(l),this.escrow=w.Container.of(t).get(f)}static async init(t){if(!t.baseUrl)throw new Error("PsiloSDK initialization requires a valid baseUrl");t.verbose&&console.log(`[PsiloSDK] Initializing SDK pointed to ${t.baseUrl}`);let e=x.generateRandomString(),s=new l(t.baseUrl);return w.Container.of(e).set(l,s),new x(e)}setAuthorizationHeader(t){this.connector.setHeader("Authorization",`Bearer ${t}`)}static generateRandomString(){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let s=0;s<60;s++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}};o(x,"PsiloSDK");var R=x;R=at([(0,w.Service)({transient:!0}),Q("design:type",Function),Q("design:paramtypes",[String])],R);0&&(module.exports={Connector,ErrorUtils,EscrowService,PsiloSDK,SDKError,Status,parseUrlWithQuery});
2
+ //# sourceMappingURL=main.js.map
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@pakt/psilo",
3
+ "version": "0.0.1",
4
+ "description": "SDK for interacting with Pakt Psilo Escrow Contracts via MCP",
5
+ "files": [
6
+ "./dist/main.js",
7
+ "./dist/main.d.ts"
8
+ ],
9
+ "exports": {
10
+ ".": "./dist/main.js",
11
+ "./main.d.ts": "./dist/main.d.ts"
12
+ },
13
+ "main": "./dist/main.js",
14
+ "types": "./dist/main.d.ts",
15
+ "scripts": {
16
+ "test": "echo \"Error: no test specified\" && exit 1",
17
+ "dev": "npx ts-node ./examples/src/index.ts",
18
+ "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
19
+ "lint": "tslint -p tsconfig.json",
20
+ "build": "rimraf ./dist && tsup",
21
+ "sd": "tsc --experimentalDecorators --resolveJsonModule ./src/services/index.ts"
22
+ },
23
+ "devDependencies": {
24
+ "@swc/core": "^1.15.13",
25
+ "@types/crypto-js": "^4.1.1",
26
+ "@types/jest": "^27.4.1",
27
+ "@types/node": "^18.15.11",
28
+ "@types/uuid": "^9.0.8",
29
+ "@typescript-eslint/eslint-plugin": "^5.43.0",
30
+ "@typescript-eslint/parser": "^5.20.0",
31
+ "dotenv": "^16.0.3",
32
+ "eslint": "^8.0.1",
33
+ "eslint-config-standard-with-typescript": "^34.0.1",
34
+ "eslint-plugin-import": "^2.25.2",
35
+ "eslint-plugin-n": "^15.0.0",
36
+ "eslint-plugin-promise": "^6.0.0",
37
+ "prettier": "^2.8.8",
38
+ "ts-node": "^10.7.0",
39
+ "tslint": "^6.1.3",
40
+ "tslint-config-prettier": "^1.18.0",
41
+ "tsup": "^7.1.0",
42
+ "typescript": "^4.9.5",
43
+ "typescript-transform-paths": "^3.4.6",
44
+ "undici": "^5.29.0"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "dependencies": {
50
+ "axios": "^1.11.0",
51
+ "crypto-js": "^4.1.1",
52
+ "reflect-metadata": "^0.1.13",
53
+ "typedi": "^0.10.0"
54
+ }
55
+ }