@pakt/psilo 0.0.2 → 0.0.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/main.d.ts CHANGED
@@ -56,16 +56,22 @@ interface EscrowModuleType {
56
56
  getChains(): Promise<ResponseDto<GetEscrowChainsResponseDto>>;
57
57
  getAssets(chainId: string): Promise<ResponseDto<GetEscrowAssetsResponseDto>>;
58
58
  }
59
+ interface EscrowWebhookConfigDto {
60
+ webhookUrl: string;
61
+ webHookType: "a2a" | "json";
62
+ }
59
63
  interface CreateEscrowDto {
60
64
  chainId: string;
61
65
  buyer: string;
62
66
  seller: string;
67
+ creator?: string;
63
68
  title: string;
64
69
  description?: string;
65
70
  amount: string;
66
71
  asset: string;
67
72
  expiration?: string;
68
73
  releaseType?: string;
74
+ webhookUrls?: EscrowWebhookConfigDto;
69
75
  }
70
76
  interface CreateEscrowResponse {
71
77
  buyerWallet: string;
@@ -137,7 +143,8 @@ interface ReleaseResponse {
137
143
  interface UpdateEscrowStatusDto {
138
144
  chainId: string;
139
145
  escrow: string;
140
- address: string;
146
+ address?: string;
147
+ webhookUrl?: string;
141
148
  }
142
149
  interface PrepareTransactionResponse {
143
150
  to: string;
@@ -191,11 +198,55 @@ declare class EscrowService implements EscrowModuleType {
191
198
  getAssets(chainId: string): Promise<ResponseDto<GetEscrowAssetsResponseDto>>;
192
199
  }
193
200
 
201
+ interface AuthModuleType {
202
+ register(data: RegisterDto): Promise<ResponseDto<RegisterResponse>>;
203
+ nonce(data: NonceDto): Promise<ResponseDto<NonceResponse>>;
204
+ verify(data: VerifyDto): Promise<ResponseDto<VerifyResponse>>;
205
+ }
206
+ interface NonceDto {
207
+ address: string;
208
+ agentId: string;
209
+ agentRegistry?: string;
210
+ }
211
+ interface NonceResponse {
212
+ nonce: string;
213
+ [key: string]: unknown;
214
+ }
215
+ interface VerifyDto {
216
+ message: string;
217
+ signature: string;
218
+ }
219
+ interface VerifyResponse {
220
+ token: string;
221
+ [key: string]: unknown;
222
+ }
223
+ interface RegisterDto {
224
+ address: string;
225
+ agentId: string;
226
+ agentRegistry?: string;
227
+ chainId?: string;
228
+ name?: string;
229
+ webhookUrl?: string;
230
+ }
231
+ interface RegisterResponse {
232
+ [key: string]: unknown;
233
+ }
234
+
235
+ declare class AuthService implements AuthModuleType {
236
+ private id;
237
+ private connector;
238
+ constructor(id: string);
239
+ register(data: RegisterDto): Promise<ResponseDto<RegisterResponse>>;
240
+ nonce(data: NonceDto): Promise<ResponseDto<NonceResponse>>;
241
+ verify(data: VerifyDto): Promise<ResponseDto<VerifyResponse>>;
242
+ }
243
+
194
244
  interface PsiloSDKConfig {
195
245
  baseUrl?: string;
196
246
  verbose?: boolean;
197
247
  }
198
248
  declare class PsiloSDK {
249
+ readonly auth: AuthService;
199
250
  readonly escrow: EscrowService;
200
251
  readonly connector: Connector;
201
252
  constructor(id: string);
@@ -210,4 +261,4 @@ declare class SDKError extends Error {
210
261
  constructor(message: string, code?: string, details?: any);
211
262
  }
212
263
 
213
- export { Connector, CreateEscrowDto, CreateEscrowResponse, DepositDto, DepositResponse, ErrorUtils, EscrowAssetDto, EscrowChainDto, EscrowModuleType, EscrowNativeCurrencyDto, EscrowService, EscrowStatusResponse, GetEscrowAssetsResponseDto, GetEscrowChainsResponseDto, IAny, PrepareTransactionResponse, PsiloSDK, PsiloSDKConfig, ReleaseDto, ReleaseResponse, ResponseDto, SDKError, SignReleaseDto, SignReleaseResponse, StandardResponse, Status, UpdateEscrowStatusDto, parseUrlWithQuery };
264
+ export { AuthModuleType, AuthService, Connector, CreateEscrowDto, CreateEscrowResponse, DepositDto, DepositResponse, ErrorUtils, EscrowAssetDto, EscrowChainDto, EscrowModuleType, EscrowNativeCurrencyDto, EscrowService, EscrowStatusResponse, EscrowWebhookConfigDto, GetEscrowAssetsResponseDto, GetEscrowChainsResponseDto, IAny, NonceDto, NonceResponse, PrepareTransactionResponse, PsiloSDK, PsiloSDKConfig, RegisterDto, RegisterResponse, ReleaseDto, ReleaseResponse, ResponseDto, SDKError, SignReleaseDto, SignReleaseResponse, StandardResponse, Status, UpdateEscrowStatusDto, VerifyDto, VerifyResponse, parseUrlWithQuery };
package/dist/main.js CHANGED
@@ -1,2 +1,2 @@
1
- var Q=Object.create;var d=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames,v=Object.getOwnPropertySymbols,_=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var E=(r,t,e)=>t in r?d(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,h=(r,t)=>{for(var e in t||(t={}))C.call(t,e)&&E(r,e,t[e]);if(v)for(var e of v(t))G.call(t,e)&&E(r,e,t[e]);return r};var o=(r,t)=>d(r,"name",{value:t,configurable:!0});var V=(r,t)=>{for(var e in t)d(r,e,{get:t[e],enumerable:!0})},z=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of K(t))!C.call(r,s)&&s!==e&&d(r,s,{get:()=>t[s],enumerable:!(n=B(t,s))||n.enumerable});return r};var X=(r,t,e)=>(e=r!=null?Q(_(r)):{},z(t||!r||!r.__esModule?d(e,"default",{value:r,enumerable:!0}):e,r)),Y=r=>z(d({},"__esModule",{value:!0}),r);var i=(r,t,e)=>(E(r,typeof t!="symbol"?t+"":t,e),e);var st={};V(st,{Connector:()=>l,ErrorUtils:()=>p,EscrowService:()=>m,PsiloSDK:()=>R,SDKError:()=>u,Status:()=>et,parseUrlWithQuery:()=>N});module.exports=Y(st);var oe=require("reflect-metadata");var g=require("typedi");var D=X(require("axios"));var j=class j extends Error{constructor(e,n,s){super(e);i(this,"code");i(this,"details");this.name="SDKError",this.code=n,this.details=s}};o(j,"SDKError");var u=j;var F=class F{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 n,s,a;let e=t.data;if(e&&e.success===!1)throw new u(((n=e.error)==null?void 0:n.message)||"Unknown error",((s=e.error)==null?void 0:s.code)||"API_ERROR",(a=e.error)==null?void 0:a.details);return e}handleError(t){var e,n;if(D.default.isAxiosError(t)){let s=(e=t.response)==null?void 0:e.data;throw s&&s.error?new u(s.error.message||t.message,s.error.code||"REQUEST_ERROR",s.error.details):new u(t.message,t.code,(n=t.response)==null?void 0:n.data)}throw new u(t.message||"An unexpected error occurred","INTERNAL_ERROR")}async get(t,e){try{let n=await this.client.get(t,e);return this.handleResponse(n)}catch(n){this.handleError(n)}}async post(t,e,n){try{let s=await this.client.post(t,e,n);return this.handleResponse(s)}catch(s){this.handleError(s)}}async put(t,e,n){try{let s=await this.client.put(t,e,n);return this.handleResponse(s)}catch(s){this.handleError(s)}}async delete(t,e){try{let n=await this.client.delete(t,e);return this.handleResponse(n)}catch(n){this.handleError(n)}}};o(F,"Connector");var l=F;var b=require("typedi");var Z={delayFirstAttempt:!1,jitter:"none",maxDelay:1/0,numOfAttempts:10,retry:()=>!0,startingDelay:100,timeMultiple:2};function J(r){let t=h(h({},Z),r);return t.numOfAttempts<1&&(t.numOfAttempts=1),t}o(J,"getSanitizedOptions");function P(r){let t=Math.random()*r;return Math.round(t)}o(P,"fullJitter");function W(r){return r}o(W,"noJitter");function $(r){switch(r.jitter){case"full":return P;case"none":default:return W}}o($,"JitterFactory");var S=class S{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 $(this.options)(this.delay)}get delay(){let t=this.options.startingDelay,e=this.options.timeMultiple,n=this.numOfDelayedAttempts,s=t*Math.pow(e,n);return Math.min(s,this.options.maxDelay)}get numOfDelayedAttempts(){return this.attempt}};o(S,"Delay");var y=S;var M=class M extends y{async apply(){return this.isFirstAttempt?!0:super.apply()}get isFirstAttempt(){return this.attempt===0}get numOfDelayedAttempts(){return this.attempt-1}};o(M,"SkipFirstDelay");var O=M;var U=class U extends y{};o(U,"AlwaysDelay");var A=U;function q(r,t){let e=k(r);return e.setAttemptNumber(t),e}o(q,"DelayFactory");function k(r){return r.delayFirstAttempt?new A(r):new O(r)}o(k,"initDelayClass");async function I(r,t={}){let e=J(t);return await new tt(r,e).execute()}o(I,"backOff");var w,tt=(w=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 q(this.options,this.attemptNumber).apply()}},o(w,"BackOff"),w);var et=function(r){return r.SUCCESS="success",r.ERROR="error",r}({}),p={newTryFail:async r=>{try{let t=await I(async()=>await r(),{startingDelay:50,timeMultiple:10,numOfAttempts:10,maxDelay:3550,delayFirstAttempt:!1});return h({},t)}catch(t){let e=p.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(n=>p.formatErrorMsg(n)),code:e.errorCode}:{message:[(t=e.message)!=null?t:r],code:e.errorCode}}catch(e){}if(p.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"}},N=o((r,t)=>{let e="?",n=Object.keys(t||{});return n.length===0?r:(n.map((s,a)=>{let c="&";(s===void 0||s==="undefined"||s===null||s==="null"||s.length===0)&&(e=e),a+1===n.length&&(c=""),e=e+`${s}=${t[s]}${c}`}),r+e)},"parseUrlWithQuery");function rt(r,t,e,n){var s=arguments.length,a=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,n);else for(var f=r.length-1;f>=0;f--)(c=r[f])&&(a=(s<3?c(a):s>3?c(t,e,a):c(t,e))||a);return s>3&&a&&Object.defineProperty(t,e,a),a}o(rt,"_ts_decorate");function H(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}o(H,"_ts_metadata");var T=class T{constructor(t){i(this,"id");i(this,"connector");this.id=t,this.connector=b.Container.of(this.id).get(l)}async create(t){return p.newTryFail(async()=>await this.connector.post("/api/escrow/create",t))}async getStatus(t,e){return p.newTryFail(async()=>{let n=N("/api/escrow/status",{chainId:t,escrow:e});return await this.connector.get(n)})}async updateStatus(t){return p.newTryFail(async()=>await this.connector.post("/api/escrow/update",t))}async release(t,e,n){return p.newTryFail(async()=>{let s=h({chainId:t,escrowAddress:e},n||{});return await this.connector.post("/api/escrow/release",s)})}async getChains(){return p.newTryFail(async()=>await this.connector.get("/api/escrow/chains"))}async getAssets(t){return p.newTryFail(async()=>await this.connector.get(`/api/escrow/assets/${t}`))}};o(T,"EscrowService");var m=T;m=rt([(0,b.Service)({factory:r=>new m(r.id),transient:!0}),H("design:type",Function),H("design:paramtypes",[String])],m);function nt(r,t,e,n){var s=arguments.length,a=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,n);else for(var f=r.length-1;f>=0;f--)(c=r[f])&&(a=(s<3?c(a):s>3?c(t,e,a):c(t,e))||a);return s>3&&a&&Object.defineProperty(t,e,a),a}o(nt,"_ts_decorate");function L(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}o(L,"_ts_metadata");var x=class x{constructor(t){i(this,"escrow");i(this,"connector");this.connector=g.Container.of(t).get(l),this.escrow=g.Container.of(t).get(m)}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(),n=new l(t.baseUrl);return g.Container.of(e).set(l,n),new x(e)}setAuthorizationHeader(t){this.connector.setHeader("Authorization",`Bearer ${t}`)}static generateRandomString(){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let n=0;n<60;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}};o(x,"PsiloSDK");var R=x;R=nt([(0,g.Service)({transient:!0}),L("design:type",Function),L("design:paramtypes",[String])],R);0&&(module.exports={Connector,ErrorUtils,EscrowService,PsiloSDK,SDKError,Status,parseUrlWithQuery});
1
+ var G=Object.create;var g=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames,J=Object.getOwnPropertySymbols,Y=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var F=(r,t,e)=>t in r?g(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d=(r,t)=>{for(var e in t||(t={}))P.call(t,e)&&F(r,e,t[e]);if(J)for(var e of J(t))Z.call(t,e)&&F(r,e,t[e]);return r};var s=(r,t)=>g(r,"name",{value:t,configurable:!0});var k=(r,t)=>{for(var e in t)g(r,e,{get:t[e],enumerable:!0})},W=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X(t))!P.call(r,o)&&o!==e&&g(r,o,{get:()=>t[o],enumerable:!(n=V(t,o))||n.enumerable});return r};var tt=(r,t,e)=>(e=r!=null?G(Y(r)):{},W(t||!r||!r.__esModule?g(e,"default",{value:r,enumerable:!0}):e,r)),et=r=>W(g({},"__esModule",{value:!0}),r);var i=(r,t,e)=>(F(r,typeof t!="symbol"?t+"":t,e),e);var pt={};k(pt,{AuthService:()=>h,Connector:()=>u,ErrorUtils:()=>p,EscrowService:()=>m,PsiloSDK:()=>O,SDKError:()=>f,Status:()=>st,parseUrlWithQuery:()=>C});module.exports=et(pt);var xe=require("reflect-metadata");var y=require("typedi");var S=tt(require("axios"));var D=class D extends Error{constructor(e,n,o){super(e);i(this,"code");i(this,"details");this.name="SDKError",this.code=n,this.details=o}};s(D,"SDKError");var f=D;var M=class M{constructor(t){i(this,"client");this.client=S.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 n,o,a;let e=t.data;if(e&&e.success===!1)throw new f(((n=e.error)==null?void 0:n.message)||"Unknown error",((o=e.error)==null?void 0:o.code)||"API_ERROR",(a=e.error)==null?void 0:a.details);return e}handleError(t){var e,n;if(S.default.isAxiosError(t)){let o=(e=t.response)==null?void 0:e.data;throw o&&o.error?new f(o.error.message||t.message,o.error.code||"REQUEST_ERROR",o.error.details):new f(t.message,t.code,(n=t.response)==null?void 0:n.data)}throw new f(t.message||"An unexpected error occurred","INTERNAL_ERROR")}async get(t,e){try{let n=await this.client.get(t,e);return this.handleResponse(n)}catch(n){this.handleError(n)}}async post(t,e,n){try{let o=await this.client.post(t,e,n);return this.handleResponse(o)}catch(o){this.handleError(o)}}async put(t,e,n){try{let o=await this.client.put(t,e,n);return this.handleResponse(o)}catch(o){this.handleError(o)}}async delete(t,e){try{let n=await this.client.delete(t,e);return this.handleResponse(n)}catch(n){this.handleError(n)}}};s(M,"Connector");var u=M;var A=require("typedi");var rt={delayFirstAttempt:!1,jitter:"none",maxDelay:1/0,numOfAttempts:10,retry:()=>!0,startingDelay:100,timeMultiple:2};function $(r){let t=d(d({},rt),r);return t.numOfAttempts<1&&(t.numOfAttempts=1),t}s($,"getSanitizedOptions");function q(r){let t=Math.random()*r;return Math.round(t)}s(q,"fullJitter");function I(r){return r}s(I,"noJitter");function H(r){switch(r.jitter){case"full":return q;case"none":default:return I}}s(H,"JitterFactory");var v=class v{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 H(this.options)(this.delay)}get delay(){let t=this.options.startingDelay,e=this.options.timeMultiple,n=this.numOfDelayedAttempts,o=t*Math.pow(e,n);return Math.min(o,this.options.maxDelay)}get numOfDelayedAttempts(){return this.attempt}};s(v,"Delay");var w=v;var T=class T extends w{async apply(){return this.isFirstAttempt?!0:super.apply()}get isFirstAttempt(){return this.attempt===0}get numOfDelayedAttempts(){return this.attempt-1}};s(T,"SkipFirstDelay");var b=T;var U=class U extends w{};s(U,"AlwaysDelay");var j=U;function L(r,t){let e=nt(r);return e.setAttemptNumber(t),e}s(L,"DelayFactory");function nt(r){return r.delayFirstAttempt?new j(r):new b(r)}s(nt,"initDelayClass");async function _(r,t={}){let e=$(t);return await new ot(r,e).execute()}s(_,"backOff");var x,ot=(x=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 L(this.options,this.attemptNumber).apply()}},s(x,"BackOff"),x);var st=function(r){return r.SUCCESS="success",r.ERROR="error",r}({}),p={newTryFail:async r=>{try{let t=await _(async()=>await r(),{startingDelay:50,timeMultiple:10,numOfAttempts:10,maxDelay:3550,delayFirstAttempt:!1});return d({},t)}catch(t){let e=p.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(n=>p.formatErrorMsg(n)),code:e.errorCode}:{message:[(t=e.message)!=null?t:r],code:e.errorCode}}catch(e){}if(p.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"}},C=s((r,t)=>{let e="?",n=Object.keys(t||{});return n.length===0?r:(n.map((o,a)=>{let c="&";(o===void 0||o==="undefined"||o===null||o==="null"||o.length===0)&&(e=e),a+1===n.length&&(c=""),e=e+`${o}=${t[o]}${c}`}),r+e)},"parseUrlWithQuery");function at(r,t,e,n){var o=arguments.length,a=o<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,n);else for(var l=r.length-1;l>=0;l--)(c=r[l])&&(a=(o<3?c(a):o>3?c(t,e,a):c(t,e))||a);return o>3&&a&&Object.defineProperty(t,e,a),a}s(at,"_ts_decorate");function Q(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}s(Q,"_ts_metadata");var N=class N{constructor(t){i(this,"id");i(this,"connector");this.id=t,this.connector=A.Container.of(this.id).get(u)}async create(t){return p.newTryFail(async()=>await this.connector.post("/api/escrow/create",t))}async getStatus(t,e){return p.newTryFail(async()=>{let n=C("/api/escrow/status",{chainId:t,escrow:e});return await this.connector.get(n)})}async updateStatus(t){return p.newTryFail(async()=>await this.connector.post("/api/escrow/update",t))}async release(t,e,n){return p.newTryFail(async()=>{let o=d({chainId:t,escrowAddress:e},n||{});return await this.connector.post("/api/escrow/release",o)})}async getChains(){return p.newTryFail(async()=>await this.connector.get("/api/escrow/chains"))}async getAssets(t){return p.newTryFail(async()=>await this.connector.get(`/api/escrow/assets/${t}`))}};s(N,"EscrowService");var m=N;m=at([(0,A.Service)({factory:r=>new m(r.id),transient:!0}),Q("design:type",Function),Q("design:paramtypes",[String])],m);var E=require("typedi");function it(r,t,e,n){var o=arguments.length,a=o<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,n);else for(var l=r.length-1;l>=0;l--)(c=r[l])&&(a=(o<3?c(a):o>3?c(t,e,a):c(t,e))||a);return o>3&&a&&Object.defineProperty(t,e,a),a}s(it,"_ts_decorate");function B(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}s(B,"_ts_metadata");var z=class z{constructor(t){i(this,"id");i(this,"connector");this.id=t,this.connector=E.Container.of(this.id).get(u)}async register(t){return p.newTryFail(async()=>await this.connector.post("/api/auth/register",t))}async nonce(t){return p.newTryFail(async()=>await this.connector.post("/api/auth/nonce",t))}async verify(t){return p.newTryFail(async()=>await this.connector.post("/api/auth/verify",t))}};s(z,"AuthService");var h=z;h=it([(0,E.Service)({factory:r=>new h(r.id),transient:!0}),B("design:type",Function),B("design:paramtypes",[String])],h);function ct(r,t,e,n){var o=arguments.length,a=o<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,t,e,n);else for(var l=r.length-1;l>=0;l--)(c=r[l])&&(a=(o<3?c(a):o>3?c(t,e,a):c(t,e))||a);return o>3&&a&&Object.defineProperty(t,e,a),a}s(ct,"_ts_decorate");function K(r,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,t)}s(K,"_ts_metadata");var R=class R{constructor(t){i(this,"auth");i(this,"escrow");i(this,"connector");this.connector=y.Container.of(t).get(u),this.auth=y.Container.of(t).get(h),this.escrow=y.Container.of(t).get(m)}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=R.generateRandomString(),n=new u(t.baseUrl);return y.Container.of(e).set(u,n),new R(e)}setAuthorizationHeader(t){this.connector.setHeader("Authorization",`Bearer ${t}`)}static generateRandomString(){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let n=0;n<60;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}};s(R,"PsiloSDK");var O=R;O=ct([(0,y.Service)({transient:!0}),K("design:type",Function),K("design:paramtypes",[String])],O);0&&(module.exports={AuthService,Connector,ErrorUtils,EscrowService,PsiloSDK,SDKError,Status,parseUrlWithQuery});
2
2
  //# sourceMappingURL=main.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pakt/psilo",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "SDK for interacting with Pakt Psilo Escrow Contracts via MCP",
5
5
  "files": [
6
6
  "./dist/main.js",