lombongo-api-client 0.0.39 → 0.0.41

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/esm/base.js CHANGED
@@ -1 +1 @@
1
- import t from"axios";class s{constructor(t){this.client=t,this.endpoint="/accounts"}async getAccounts(){return await this.client.request("get",this.endpoint)}async createAoaAccount(){return await this.client.request("post",this.endpoint,{currency:"aoa"},{})}async createEurAccount(){return await this.client.request("post",this.endpoint,{currency:"eur"},{})}}class i{constructor(t){this.observers=[],this.authState={authenticated:!1},this.client=t}notifyObservers(){for(const t of this.observers)t(this.authState)}listObservers(){for(const t of this.observers)console.log(t)}onAuthStateChange(t){this.observers.push(t)}isAuthenticated(){return Boolean(this.client.token)}async signOut(){const t=this.client.lombongoIdBaseUrl;await this.client.request("get","/users/logout",void 0,{},t),delete this.client.token,this.authState.authenticated=!1,this.authState.user=void 0,this.authState.token=void 0,this.notifyObservers()}async createUser(t){const s=this.client.lombongoIdBaseUrl,i=await this.client.request("post","/users",t,{},s);return delete t.password,this.authState={authenticated:!0,user:t,token:i.data.token},this.notifyObservers(),i}async login(t){const s=this._loginFactory(t);return await s(t)}async _verifyToken(t){const s=this.client.lombongoIdBaseUrl;return await this.client.request("post","/token",{token:t},{},s)}async _loginWithEmailAndPassword(t,s){const i=this.client.lombongoIdBaseUrl;return await this.client.request("post","/users/login",{email:t,password:s},{},i)}async _loginWithUsernameAndPassword(t,s){const i=this.client.lombongoIdBaseUrl;return await this.client.request("post","/users/login",{username:t,password:s},{},i)}_loginFactory(t){if(!("email"in t)&&!("username"in t))throw new Error("Login credentials must include either an email or a username.");return async t=>{if(t.email)return this._loginWithEmailAndPassword(t.email,t.password);if(t.username)return this._loginWithUsernameAndPassword(t.username,t.password);throw new Error("Invalid login credentials provided.")}}}class n{constructor(t){this.client=t,this.endpoint="/current-commission"}async getCurrentCommission(){return await this.client.request("get",this.endpoint)}}class e{constructor(t){this.client=t,this.endpoint="/currencies"}async getCurrencies(){return await this.client.request("get",this.endpoint)}}class r{constructor(t){this.client=t,this.endpoint="/fx-rates"}async getFxRates(){return await this.client.request("get",this.endpoint)}async getFxRate(t,s){return await this.client.request("post",this.endpoint,{originalCurrencyId:t,finalCurrencyId:s})}}class a{constructor(t){this.client=t,this.endpoint="/transactions"}async doCrossCurrency(t){const s=`${this.endpoint}/cross-currency`;return await this.client.request("post",s,t)}async getFXConfig(t,s,i){const n=`${this.endpoint}/sepa/config`;return await this.client.request("post",n,{originalCurrencyId:t,finalCurrencyId:s,amount:i})}}class o{constructor(t){this.client=t,this.endpoint="/payment-methods"}async getPaymentMethods(){return await this.client.request("get",this.endpoint)}async getPaymentMethodsByCurrency(t){const s=`${this.endpoint}/currency/${t}`;return await this.client.request("get",s)}}class c{constructor(t){this.client=t,this.endpoint="/api/plaid/"}async createPaymentInitiationLinkToken(t){const s=this.endpoint+"create_link_token";return await this.client.request("post",s,{payment_id:t})}async createPaymentInitiation(t){const s=this.endpoint+"payment_initiation/payment/create";return await this.client.request("post",s,{amount:t})}}class h{constructor({baseUrl:t,token:h,lombongoIdBaseUrl:u}){this.baseUrl=t,this.token=h,this.lombongoIdBaseUrl=u,this.auth=new i(this),this.accounts=new s(this),this.currencies=new e(this),this.currentCommision=new n(this),this.fxRates=new r(this),this.paymentMethods=new o(this),this.transactions=new a(this),this.plaid=new c(this)}static init(t){return h.instance?(t?.token&&(h.instance.token=t.token),t?.baseUrl&&(h.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(h.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),h.instance):(h.instance=new h(t),h.instance)}async request(s,i,n={},e={},r){const a=`${r||this.baseUrl}${i}`,o={...e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,...e.headers},method:s,url:a};return"GET"!==s.toUpperCase()&&Object.keys(n).length>0&&(o.data=n),t(o)}setToken(t){this.token=t}}export{h as default};
1
+ import t from"axios";class s{constructor(t){this.client=t,this.endpoint="/accounts"}async getAccounts(){return await this.client.request("get",this.endpoint)}async createAoaAccount(){return await this.client.request("post",this.endpoint,{currency:"aoa"},{})}async createEurAccount(){return await this.client.request("post",this.endpoint,{currency:"eur"},{})}}class i{constructor(t){this.observers=[],this.authState={authenticated:!1},this.client=t}_notifyObservers(){for(const t of this.observers)t(this.authState)}listObservers(){for(const t of this.observers)console.log(t)}onAuthStateChange(t){this.observers.push(t)}isAuthenticated(){return Boolean(this.client.token)}async signOut(){const t=this.client.lombongoIdBaseUrl;await this.client.request("get","/users/logout",void 0,{},t),delete this.client.token,this.authState.authenticated=!1,this.authState.user=void 0,this.authState.token=void 0,this._notifyObservers()}async createUser(t){const s=this.client.lombongoIdBaseUrl,i=await this.client.request("post","/users",t,{},s);return delete t.password,this.authState={authenticated:!0,user:t,token:i.data.token},this._notifyObservers(),i}async login(t){const s=this._loginFactory(t),i=await s(t);return this._notifyObservers(),i}async verifyToken(t){const s=this.client.lombongoIdBaseUrl;return await this.client.request("post","/token",{token:t},{},s)}async _loginWithEmailAndPassword(t,s){const i=this.client.lombongoIdBaseUrl;return await this.client.request("post","/users/login",{email:t,password:s},{},i)}async _loginWithUsernameAndPassword(t,s){const i=this.client.lombongoIdBaseUrl;return await this.client.request("post","/users/login",{username:t,password:s},{},i)}_loginFactory(t){if(!("email"in t)&&!("username"in t))throw new Error("Login credentials must include either an email or a username.");return async t=>{if(t.email)return this._loginWithEmailAndPassword(t.email,t.password);if(t.username)return this._loginWithUsernameAndPassword(t.username,t.password);throw new Error("Invalid login credentials provided.")}}}class n{constructor(t){this.client=t,this.endpoint="/current-commission"}async getCurrentCommission(){return await this.client.request("get",this.endpoint)}}class e{constructor(t){this.client=t,this.endpoint="/currencies"}async getCurrencies(){return await this.client.request("get",this.endpoint)}}class r{constructor(t){this.client=t,this.endpoint="/fx-rates"}async getFxRates(){return await this.client.request("get",this.endpoint)}async getFxRate(t,s){return await this.client.request("post",this.endpoint,{originalCurrencyId:t,finalCurrencyId:s})}}class a{constructor(t){this.client=t,this.endpoint="/transactions"}async doCrossCurrency(t){const s=`${this.endpoint}/cross-currency`;return await this.client.request("post",s,t)}async getFXConfig(t,s,i){const n=`${this.endpoint}/sepa/config`;return await this.client.request("post",n,{originalCurrencyId:t,finalCurrencyId:s,amount:i})}}class o{constructor(t){this.client=t,this.endpoint="/payment-methods"}async getPaymentMethods(){return await this.client.request("get",this.endpoint)}async getPaymentMethodsByCurrency(t){const s=`${this.endpoint}/currency/${t}`;return await this.client.request("get",s)}}class c{constructor(t){this.client=t,this.endpoint="/api/plaid/"}async createPaymentInitiationLinkToken(t){const s=this.endpoint+"create_link_token";return await this.client.request("post",s,{payment_id:t})}async createPaymentInitiation(t){const s=this.endpoint+"payment_initiation/payment/create";return await this.client.request("post",s,{amount:t})}}class h{constructor({baseUrl:t,token:h,lombongoIdBaseUrl:u}){this.baseUrl=t,this.token=h,this.lombongoIdBaseUrl=u,this.auth=new i(this),this.accounts=new s(this),this.currencies=new e(this),this.currentCommision=new n(this),this.fxRates=new r(this),this.paymentMethods=new o(this),this.transactions=new a(this),this.plaid=new c(this)}static init(t){return h.instance?(t?.token&&(h.instance.token=t.token),t?.baseUrl&&(h.instance.baseUrl=t.baseUrl),t?.lombongoIdBaseUrl&&(h.instance.lombongoIdBaseUrl=t.lombongoIdBaseUrl),h.instance):(h.instance=new h(t),h.instance)}async request(s,i,n={},e={},r){const a=`${r||this.baseUrl}${i}`,o={...e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,...e.headers},method:s,url:a};return"GET"!==s.toUpperCase()&&Object.keys(n).length>0&&(o.data=n),t(o)}setToken(t){this.token=t}}export{h as default};
package/dist/types.d.ts CHANGED
@@ -29,14 +29,14 @@ declare class Auth {
29
29
  private observers;
30
30
  private authState;
31
31
  constructor(client: ApiClient);
32
- private notifyObservers;
32
+ private _notifyObservers;
33
33
  listObservers(): void;
34
34
  onAuthStateChange(observer: (authState: AuthState) => void): void;
35
35
  isAuthenticated(): boolean;
36
36
  signOut(): Promise<void>;
37
37
  createUser(user: CreateUser): Promise<object>;
38
38
  login(credentials: LoginParameter): Promise<object>;
39
- _verifyToken(token: string): Promise<object>;
39
+ verifyToken(token: string): Promise<object>;
40
40
  _loginWithEmailAndPassword(email: string, password: string): Promise<object>;
41
41
  _loginWithUsernameAndPassword(username: string, password: string): Promise<object>;
42
42
  _loginFactory(credentials: LoginParameter): (credentials: LoginParameter) => Promise<object>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lombongo-api-client",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/esm/base.js",