@monerium/sdk 3.4.4 → 3.4.8

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.ts CHANGED
@@ -401,6 +401,8 @@ interface Token {
401
401
  }
402
402
  type NewOrder = NewOrderByAddress | NewOrderByAccountId;
403
403
  interface NewOrderCommon {
404
+ /** The unique identifier of the order */
405
+ id?: string;
404
406
  amount: string;
405
407
  signature: string;
406
408
  currency: Currency;
@@ -537,6 +539,61 @@ type ResponseStatus = {
537
539
  status: number;
538
540
  statusText: string;
539
541
  };
542
+ /**
543
+ * Type of pending signature
544
+ */
545
+ type PendingSignatureKind = 'linkAddress' | 'order';
546
+ /**
547
+ * Base interface for pending signatures
548
+ */
549
+ interface PendingSignatureBase {
550
+ kind: PendingSignatureKind;
551
+ chain: Chain;
552
+ address: string;
553
+ createdAt: string;
554
+ }
555
+ /**
556
+ * Pending signature for an order
557
+ */
558
+ interface PendingOrderSignature extends PendingSignatureBase {
559
+ id: string;
560
+ kind: 'order';
561
+ amount: string;
562
+ counterpart: Counterpart;
563
+ currency: Currency;
564
+ }
565
+ /**
566
+ * Pending signature for linking an address
567
+ */
568
+ interface PendingLinkAddressSignature extends PendingSignatureBase {
569
+ kind: 'linkAddress';
570
+ }
571
+ /**
572
+ * Union type for all pending signature types
573
+ */
574
+ type PendingSignature = PendingOrderSignature | PendingLinkAddressSignature;
575
+ /**
576
+ * Query parameters for fetching pending signatures
577
+ */
578
+ interface SignaturesQueryParams {
579
+ /** Filter by blockchain address */
580
+ address?: string;
581
+ /** Filter by blockchain network */
582
+ chain?: Chain | ChainId;
583
+ /** Filter by signature request kind */
584
+ kind?: PendingSignatureKind;
585
+ /** UUID of the profile (defaults to authenticated user's default profile) */
586
+ profile?: string;
587
+ }
588
+ /**
589
+ * Response from the signatures endpoint
590
+ */
591
+ interface SignaturesResponse {
592
+ /** Array of pending signatures */
593
+ pending: PendingSignature[];
594
+ /** Total number of pending signatures */
595
+ total: number;
596
+ }
540
597
 
541
598
  /**
542
599
  * In the [Monerium UI](https://monerium.app/), create an application to get the `clientId` and register your `redirectUri`.
@@ -709,6 +766,34 @@ declare class MoneriumClient {
709
766
  * @see {@link https://monerium.dev/api-docs-v2#tag/tokens | API Documentation}
710
767
  */
711
768
  getTokens(): Promise<Token[]>;
769
+ /**
770
+ * Get pending signatures for the authenticated user.
771
+ *
772
+ * Returns pending signatures that require user action, such as order signatures
773
+ * or link address signatures. Accepts filtering by address, chain, kind, and profile.
774
+ *
775
+ * @group Signatures
776
+ * @param {SignaturesQueryParams} [params] - Optional query parameters to filter signatures
777
+ * @see {@link https://monerium.dev/api-docs-v2#tag/signatures/operation/get-signatures | API Documentation}
778
+ *
779
+ * @example
780
+ * ```ts
781
+ * // Get all pending signatures
782
+ * const signatures = await monerium.getSignatures();
783
+ *
784
+ * // Get pending order signatures for a specific address
785
+ * const orderSignatures = await monerium.getSignatures({
786
+ * address: '0x1234...',
787
+ * kind: 'order'
788
+ * });
789
+ *
790
+ * // Get pending signatures on a specific chain
791
+ * const polygonSignatures = await monerium.getSignatures({
792
+ * chain: 'polygon'
793
+ * });
794
+ * ```
795
+ */
796
+ getSignatures(params?: SignaturesQueryParams): Promise<SignaturesResponse>;
712
797
  /**
713
798
  * Add a new address to the profile
714
799
  * @group Addresses
@@ -716,11 +801,20 @@ declare class MoneriumClient {
716
801
  */
717
802
  linkAddress(payload: LinkAddress): Promise<LinkedAddress>;
718
803
  /**
804
+ * Place a new order.
805
+ *
806
+ * **Note:** For multi-signature orders, the API returns a 202 Accepted response
807
+ * with `{status: 202, statusText: "Accepted"}` instead of the full Order object.
808
+ *
809
+ * @returns Promise that resolves to either:
810
+ * - `Order` - Full order object for regular orders
811
+ * - `ResponseStatus` - Status object with `{status: 202, statusText: "Accepted"}` for multi-sig orders
812
+ *
719
813
  * @see {@link https://monerium.dev/api-docs-v2#tag/orders/operation/post-orders | API Documentation}
720
814
  *
721
815
  * @group Orders
722
816
  */
723
- placeOrder(order: NewOrder): Promise<Order>;
817
+ placeOrder(order: NewOrder): Promise<Order | ResponseStatus>;
724
818
  /**
725
819
  * @group IBANs
726
820
  * @param {string} iban - the IBAN to move.
@@ -908,4 +1002,4 @@ declare const shortenAddress: (address?: string) => string | undefined;
908
1002
  * ```
909
1003
  */
910
1004
 
911
- export { AccountState, type Address, type AddressesQueryParams, type AddressesResponse, type AuthArgs, type AuthCodePayload, type AuthContext, type AuthFlowOptions, type AuthFlowOptionsShared, type AuthFlowSIWEOptions, type AuthorizationCodeCredentials, type Balances, type BankAccountIdentifier, type BearerProfile, type BearerTokenCredentials, type Beneficiary, type Chain, type ChainId, type ClassOptions, type ClientCredentials, type ClientCredentialsPayload, type Config, type CorporateProfileDetails, type CorporateProfileDetailsRequest, type Corporation, type CosmosChainId, type Counterpart, type CounterpartBank, type CounterpartDetails, type CrossChainIdentifier, Currency, type CurrencyBalance, type CurrencyCode, type Director, type ENV, type Environment, type EvmChainId, type Fee, type IBAN, type IBANIdentifier, type IBANsResponse, type IbansQueryParams, IdDocumentKind, type Identifier, type Individual, type Issuer, type KYC, KYCOutcome, KYCState, type LinkAddress, type LinkedAddress, Method, MoneriumClient, type MoveIbanPayload, type NewOrder, type NewOrderByAccountId, type NewOrderByAddress, type NewOrderCommon, type Order, type OrderFilter, OrderKind, type OrderMetadata, type OrderNotificationQueryParams, OrderState, type OrdersResponse, type PKCERSIWERequestArgs, type PKCERequest, type PKCERequestArgs, type PKCERequestShared, type PKCESIWERequest, PaymentStandard, Permission, type PersonalProfileDetails, type PersonalProfileDetailsRequest, type ProductionChain, type Profile, type ProfilePermissions, ProfileState, ProfileType, type ProfilesQueryParams, type ProfilesResponse, type RefreshTokenPayload, type Representative, type RequestIbanPayload, type ResponseStatus, type SCANIdentifier, type SandboxChain, type SubmitProfileDetailsPayload, type SupportingDoc, type SupportingDocMetadata, type Ticker, type Token, type TokenSymbol, _default as constants, MoneriumClient as default, getChain, parseChain, placeOrderMessage, rfc3339, shortenAddress, shortenIban, siweMessage };
1005
+ export { AccountState, type Address, type AddressesQueryParams, type AddressesResponse, type AuthArgs, type AuthCodePayload, type AuthContext, type AuthFlowOptions, type AuthFlowOptionsShared, type AuthFlowSIWEOptions, type AuthorizationCodeCredentials, type Balances, type BankAccountIdentifier, type BearerProfile, type BearerTokenCredentials, type Beneficiary, type Chain, type ChainId, type ClassOptions, type ClientCredentials, type ClientCredentialsPayload, type Config, type CorporateProfileDetails, type CorporateProfileDetailsRequest, type Corporation, type CosmosChainId, type Counterpart, type CounterpartBank, type CounterpartDetails, type CrossChainIdentifier, Currency, type CurrencyBalance, type CurrencyCode, type Director, type ENV, type Environment, type EvmChainId, type Fee, type IBAN, type IBANIdentifier, type IBANsResponse, type IbansQueryParams, IdDocumentKind, type Identifier, type Individual, type Issuer, type KYC, KYCOutcome, KYCState, type LinkAddress, type LinkedAddress, Method, MoneriumClient, type MoveIbanPayload, type NewOrder, type NewOrderByAccountId, type NewOrderByAddress, type NewOrderCommon, type Order, type OrderFilter, OrderKind, type OrderMetadata, type OrderNotificationQueryParams, OrderState, type OrdersResponse, type PKCERSIWERequestArgs, type PKCERequest, type PKCERequestArgs, type PKCERequestShared, type PKCESIWERequest, PaymentStandard, type PendingLinkAddressSignature, type PendingOrderSignature, type PendingSignature, type PendingSignatureKind, Permission, type PersonalProfileDetails, type PersonalProfileDetailsRequest, type ProductionChain, type Profile, type ProfilePermissions, ProfileState, ProfileType, type ProfilesQueryParams, type ProfilesResponse, type RefreshTokenPayload, type Representative, type RequestIbanPayload, type ResponseStatus, type SCANIdentifier, type SandboxChain, type SignaturesQueryParams, type SignaturesResponse, type SubmitProfileDetailsPayload, type SupportingDoc, type SupportingDocMetadata, type Ticker, type Token, type TokenSymbol, _default as constants, MoneriumClient as default, getChain, parseChain, placeOrderMessage, rfc3339, shortenAddress, shortenIban, siweMessage };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var z=require('crypto-js/enc-base64url.js'),q=require('crypto-js/sha256.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var z__default=/*#__PURE__*/_interopDefault(z);var q__default=/*#__PURE__*/_interopDefault(q);var x={environments:{production:{name:"production",api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{name:"sandbox",api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}};var h={LINK_MESSAGE:"I hereby declare that I am the address owner.",STORAGE_CODE_VERIFIER:"monerium.sdk.code_verifier",STORAGE_ACCESS_TOKEN:"monerium.sdk.access_token",STORAGE_ACCESS_EXPIRY:"monerium.sdk.access_expiry"};var A=()=>{let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=e.length,n=0;for(;n<128;)t+=e.charAt(Math.floor(Math.random()*r)),n+=1;return t},j=t=>z__default.default.stringify(q__default.default(t)),S=()=>{let t=A(),e=j(t);return localStorage.setItem(h.STORAGE_CODE_VERIFIER,t||""),e},k=()=>{let t=window.location.href;if(!t||!t?.includes("?"))return;let[e,r]=t.split("?");r&&window.history.replaceState(null,"",e);},R=t=>t.code!=null,v=t=>t.refresh_token!=null,N=t=>t.client_secret!=null;var _=async(t,e,r,n)=>{let i=await fetch(`${t}`,{method:e,headers:n,body:r}),s,a=await i.text();try{if(s=JSON.parse(a),Object.keys(s).length===0&&s.constructor===Object)switch(i.status){case 201:case 202:return {status:i.status,statusText:i.statusText}}}catch{throw a}if(!i.ok)throw s;return s};var m=t=>{if(!t)return "";let e=Object.entries(t).filter(([r,n])=>n!==""&&n!==undefined&&n!==null).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&");return e?"?"+e:""};var $=t=>t?e=>{console.log("%c [MONERIUM:DEBUG]:","color:orange;",e);}:()=>{};var E=t=>Object.entries(t).filter(([r,n])=>n!=null).map(([r,n])=>`${r}-${n}`).join("-");var B=(i=>(i.eur="eur",i.usd="usd",i.gbp="gbp",i.isk="isk",i))(B||{}),M=(s=>(s.password="password",s.resource="resource",s.jwt="jwt",s.apiKey="apiKey",s.bearer="bearer",s))(M||{}),F=(r=>(r.corporate="corporate",r.personal="personal",r))(F||{}),K=(r=>(r.read="read",r.write="write",r))(K||{}),L=(s=>(s.created="created",s.pending="pending",s.approved="approved",s.rejected="rejected",s.blocked="blocked",s))(L||{}),W=(i=>(i.absent="absent",i.submitted="submitted",i.pending="pending",i.confirmed="confirmed",i))(W||{}),Q=(n=>(n.approved="approved",n.rejected="rejected",n.unknown="unknown",n))(Q||{}),V=(s=>(s.requested="requested",s.approved="approved",s.pending="pending",s.rejected="rejected",s.closed="closed",s))(V||{}),G=(i=>(i.iban="iban",i.scan="scan",i.chain="chain",i.account="account",i))(G||{}),J=(n=>(n.passport="passport",n.nationalIdentityCard="nationalIdentityCard",n.drivingLicense="drivingLicense",n))(J||{}),H=(r=>(r.redeem="redeem",r.issue="issue",r))(H||{}),X=(i=>(i.placed="placed",i.pending="pending",i.processed="processed",i.rejected="rejected",i))(X||{});var b=t=>{if(t.toString()==="Invalid Date")throw t;let e=n=>n<10?"0"+n:n,r=n=>{if(n===0)return "Z";let i=n>0?"-":"+";return n=Math.abs(n),i+e(Math.floor(n/60))+":"+e(n%60)};return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+"T"+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+r(t.getTimezoneOffset())},Z=t=>{switch(t){case "noble":case "noble-1":case "grand":case "grand-1":return true;default:return false}},Y=t=>{switch(t){case "ethereum":case "sepolia":case "polygon":case "amoy":case "gnosis":case "chiado":case "arbitrum":case "arbitrumsepolia":case "linea":case "lineasepolia":case "scroll":case "scrollsepolia":case "camino":case "columbus":return true;default:return false}},P=t=>{if(typeof t=="number")return O(t);if(Z(t))return t.split("-")[0];if(Y(t))return t;try{return O(parseInt(t))}catch{throw new Error(`Chain not supported: ${t}`)}},u=(t,e)=>P(T(e,t)),ee=(t,e,r,n)=>{let i=`${e?.toUpperCase()||"EUR"}`;return n?`Send ${i} ${t} to ${r} on ${P(n)} at ${b(new Date)}`:i==="EUR"?`Send ${i} ${t} to ${D(r)} at ${b(new Date)}`:`Send ${i} ${t} to ${r} at ${b(new Date)}`},te=({domain:t,address:e,appName:r,redirectUri:n,chainId:i,issuedAt:s=new Date().toISOString(),expiryAt:a=new Date(Date.now()+1e3*60*5).toISOString(),privacyPolicyUrl:o,termsOfServiceUrl:l})=>`${t} wants you to sign in with your Ethereum account:
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var z=require('crypto-js/enc-base64url.js'),q=require('crypto-js/sha256.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var z__default=/*#__PURE__*/_interopDefault(z);var q__default=/*#__PURE__*/_interopDefault(q);var x={environments:{production:{name:"production",api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{name:"sandbox",api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}};var f={LINK_MESSAGE:"I hereby declare that I am the address owner.",STORAGE_CODE_VERIFIER:"monerium.sdk.code_verifier",STORAGE_ACCESS_TOKEN:"monerium.sdk.access_token",STORAGE_ACCESS_EXPIRY:"monerium.sdk.access_expiry"};var A=()=>{let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=e.length,n=0;for(;n<128;)t+=e.charAt(Math.floor(Math.random()*r)),n+=1;return t},j=t=>z__default.default.stringify(q__default.default(t)),S=()=>{let t=A(),e=j(t);return localStorage.setItem(f.STORAGE_CODE_VERIFIER,t||""),e},k=()=>{let t=window.location.href;if(!t||!t?.includes("?"))return;let[e,r]=t.split("?");r&&window.history.replaceState(null,"",e);},R=t=>t.code!=null,$=t=>t.refresh_token!=null,v=t=>t.client_secret!=null;var _=async(t,e,r,n)=>{let i=await fetch(`${t}`,{method:e,headers:n,body:r}),s,a=await i.text();try{if(s=JSON.parse(a),Object.keys(s).length===0&&s.constructor===Object)switch(i.status){case 201:case 202:return {status:i.status,statusText:i.statusText}}}catch{throw a}if(!i.ok)throw s;return s};var u=t=>{if(!t)return "";let e=Object.entries(t).filter(([r,n])=>n!==""&&n!==undefined&&n!==null).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&");return e?"?"+e:""};var N=t=>t?e=>{console.log("%c [MONERIUM:DEBUG]:","color:orange;",e);}:()=>{};var E=t=>Object.entries(t).filter(([r,n])=>n!=null).map(([r,n])=>`${r}-${n}`).join("-");var B=(i=>(i.eur="eur",i.usd="usd",i.gbp="gbp",i.isk="isk",i))(B||{}),K=(s=>(s.password="password",s.resource="resource",s.jwt="jwt",s.apiKey="apiKey",s.bearer="bearer",s))(K||{}),M=(r=>(r.corporate="corporate",r.personal="personal",r))(M||{}),F=(r=>(r.read="read",r.write="write",r))(F||{}),L=(s=>(s.created="created",s.pending="pending",s.approved="approved",s.rejected="rejected",s.blocked="blocked",s))(L||{}),Q=(i=>(i.absent="absent",i.submitted="submitted",i.pending="pending",i.confirmed="confirmed",i))(Q||{}),W=(n=>(n.approved="approved",n.rejected="rejected",n.unknown="unknown",n))(W||{}),V=(s=>(s.requested="requested",s.approved="approved",s.pending="pending",s.rejected="rejected",s.closed="closed",s))(V||{}),G=(i=>(i.iban="iban",i.scan="scan",i.chain="chain",i.account="account",i))(G||{}),J=(n=>(n.passport="passport",n.nationalIdentityCard="nationalIdentityCard",n.drivingLicense="drivingLicense",n))(J||{}),H=(r=>(r.redeem="redeem",r.issue="issue",r))(H||{}),X=(i=>(i.placed="placed",i.pending="pending",i.processed="processed",i.rejected="rejected",i))(X||{});var P=t=>{if(t.toString()==="Invalid Date")throw t;let e=n=>n<10?"0"+n:n,r=n=>{if(n===0)return "Z";let i=n>0?"-":"+";return n=Math.abs(n),i+e(Math.floor(n/60))+":"+e(n%60)};return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+"T"+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+r(t.getTimezoneOffset())},Z=t=>{switch(t){case "noble":case "noble-1":case "grand":case "grand-1":return true;default:return false}},Y=t=>{switch(t){case "ethereum":case "sepolia":case "polygon":case "amoy":case "gnosis":case "chiado":case "arbitrum":case "arbitrumsepolia":case "linea":case "lineasepolia":case "scroll":case "scrollsepolia":case "camino":case "columbus":return true;default:return false}},b=t=>{if(typeof t=="number")return O(t);if(Z(t))return t.split("-")[0];if(Y(t))return t;try{return O(parseInt(t))}catch{throw new Error(`Chain not supported: ${t}`)}},g=(t,e)=>b(T(e,t)),ee=(t,e,r,n)=>{let i=`${e?.toUpperCase()||"EUR"}`;return n?`Send ${i} ${t} to ${r} on ${b(n)} at ${P(new Date)}`:i==="EUR"?`Send ${i} ${t} to ${D(r)} at ${P(new Date)}`:`Send ${i} ${t} to ${r} at ${P(new Date)}`},te=({domain:t,address:e,appName:r,redirectUri:n,chainId:i,issuedAt:s=new Date().toISOString(),expiryAt:a=new Date(Date.now()+1e3*60*5).toISOString(),privacyPolicyUrl:o,termsOfServiceUrl:l})=>`${t} wants you to sign in with your Ethereum account:
2
2
  ${e}
3
3
 
4
4
  Allow ${r} to access my data on Monerium
@@ -12,4 +12,4 @@ Expiration Time: ${a}
12
12
  Resources:
13
13
  - https://monerium.com/siwe
14
14
  - ${o}
15
- - ${l}`,f=t=>t&&Object.entries(t)?.length>0?Object.entries(t).filter(([e,r])=>r!==undefined).map(([e,r])=>`${encodeURIComponent(e)}=${encodeURIComponent(r)}`).join("&"):"",O=t=>{switch(t){case 1:return "ethereum";case 11155111:return "sepolia";case 100:return "gnosis";case 10200:return "chiado";case 137:return "polygon";case 80002:return "amoy";case 42161:return "arbitrum";case 421614:return "arbitrumsepolia";case 59144:return "linea";case 59141:return "lineasepolia";case 534352:return "scroll";case 534351:return "scrollsepolia";case 501:return "columbus";case 500:return "camino";default:throw new Error(`Chain not supported: ${t}`)}},D=t=>{if(typeof t!="string"||!t?.length)return t;let e=t.replace(/\s/g,"");return t?.length>11?`${e.substring(0,4)}...${e.substring(e.length-4)}`:t},re=t=>typeof t!="string"||!t?.length?t:t?.length>11?`${t.substring(0,7)}...${t.substring(t.length-5)}`:t;var T=(t,e)=>{if(e==="sandbox")switch(t){case "ethereum":return "sepolia";case "polygon":return "amoy";case "gnosis":return "chiado";case "arbitrum":return "arbitrumsepolia";case "linea":return "lineasepolia";case "scroll":return "scrollsepolia";case "camino":return "columbus";case "noble":return "noble";default:return t}return t},C=(t,e)=>{if(e?.chain){let{chain:r,...n}=e;return {...n,chain:P(T(r,t))}}return e};var {STORAGE_CODE_VERIFIER:w,STORAGE_ACCESS_TOKEN:p,STORAGE_ACCESS_EXPIRY:g}=h,d=typeof window>"u",I=class{#e;#s;bearerProfile;#i=new Map;isAuthorized=!!this.bearerProfile;#r=()=>{};#n;state;constructor(e){if(!e){this.#e=x.environments.sandbox;return}if(typeof e=="string")this.#e=x.environments[e];else if(this.#r=$(e.debug??false),this.#e=x.environments[e.environment||"sandbox"],!d&&!e?.clientSecret){let{clientId:r,redirectUri:n}=e;this.#n={clientId:r,redirectUri:n};}else if(d&&e?.clientSecret){this.#r("Client credentials detected");let{clientId:r,clientSecret:n}=e;this.#n={clientId:r,clientSecret:n};}}async authorize(e){let r=S(),n=e?.address?{address:e?.address,signature:e?.signature,chain:e?.chain?u(this.#e.name,e?.chain):undefined}:{},i=f({client_id:this.#n?.clientId,redirect_uri:this.#n?.redirectUri,code_challenge:r,code_challenge_method:"S256",response_type:"code",state:e?.state,skip_create_account:e?.skipCreateAccount,skip_kyc:e?.skipKyc,email:e?.email,...n}),s=`${this.#e.api}/auth?${i}`;this.#r(`Auth flow URL: ${s}`),window.location.assign(s);}async siwe(e){let r=S(),n=f({client_id:this.#n?.clientId,redirect_uri:this.#n?.redirectUri,message:e.message,signature:e.signature,code_challenge:r,code_challenge_method:"S256",authentication_method:"siwe",state:e?.state}),i=`${this.#e.api}/auth?${n}`;this.#r(`Auth flow SIWE URL: ${i}`),window.location.assign(i);}async getAccess(e){let r=this.#n?.clientId;if(this.#n?.clientSecret){if(d)return await this.#c(this.#n),!!this?.bearerProfile;console.error("\x1B[31m%s\x1B[0m","Use client credentials only on the server where the secret is secure!");}let i=this.#n?.redirectUri;if(!r)throw new Error("Missing ClientId");if(d)throw new Error("This only works client side");let s=new URLSearchParams(window.location.search).get("error")||undefined,a=new URLSearchParams(window.location.search).get("error_description")||undefined;if(s||a)throw new Error(a);let o=new URLSearchParams(window.location.search).get("code")||undefined,l=new URLSearchParams(window.location.search).get("state")||undefined,c=window.localStorage.getItem(p),y=window.localStorage.getItem(g);if(o)return this.#r("Using auth code from auth flow to authorize"),await this.#a(r,i,o,l),this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile;if(e)return this.#r("Using refresh token to authorize"),await this.#d(r,e),this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile;if(c&&y){let U=new Date;if(parseInt(y)<U.getTime())throw window.localStorage.removeItem(p),window.localStorage.removeItem(g),this.isAuthorized=false,this.bearerProfile=undefined,new Error("Access token has expired");this.#r("Access token should still be valid, checking if it is authorized...");try{return this.#s=`Bearer ${c}`,this.isAuthorized=!0,await this.getTokens(),this.#r("Authorized"),!0}catch{throw this.#r("Access token is invalid."),window.localStorage.removeItem(p),window.localStorage.removeItem(g),this.isAuthorized=false,this.bearerProfile=undefined,new Error("Access token is invalid.")}}return this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile}async#o(e){let r;if(R(e))r={...e,grant_type:"authorization_code"};else if(v(e))r={...e,grant_type:"refresh_token"};else if(N(e))r={...e,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await this.#t("post","auth/token",r,true).then(n=>{if(this.bearerProfile=n,this.isAuthorized=!!n,this.#s=`Bearer ${n?.access_token}`,!d){let s=new Date().getTime()+n?.expires_in*1e3;window.localStorage.setItem(p,n?.access_token||""),window.localStorage.setItem(g,s?.toString());}}).catch(n=>{throw d||(localStorage.removeItem(w),localStorage.removeItem(p),localStorage.removeItem(g),k()),new Error(n?.message)}),R(e)&&k(),this.bearerProfile}getAuthContext(){return this.#t("get","auth/context")}getProfile(e){return this.#t("get",`profiles/${e}`)}getProfiles(e){return this.#t("get",`profiles${m(e)}`)}getAddress(e){return this.#t("get",`addresses/${e}`)}getAddresses(e){e=C(this.#e.name,e);let r=e?f(e):undefined,n=r?`addresses?${r}`:"addresses";return this.#t("get",n)}getBalances(e,r,n){let i=Array.isArray(n)?n.map(a=>`currency=${a}`).join("&"):n?`currency=${n}`:"",s=u(this.#e.name,r);return this.#t("get",`balances/${s}/${e}${i?`?${i}`:""}`)}getIban(e){return this.#t("get",`ibans/${encodeURI(e)}`)}getIbans(e){let{profile:r,chain:n}=e||{},i=m({profile:r,chain:n?u(this.#e.name,n):""});return this.#t("get",`ibans${i}`)}getOrders(e){return this.#t("get",`orders${m(e)}`)}getOrder(e){return this.#t("get",`orders/${e}`)}getTokens(){return this.#t("get","tokens")}linkAddress(e){return e=C(this.#e.name,e),this.#t("post","addresses",JSON.stringify(e))}placeOrder(e){let r={kind:"redeem",...C(this.#e.name,e),counterpart:{...e.counterpart,identifier:C(this.#e.name,e.counterpart.identifier)}};return this.#t("post","orders",JSON.stringify(r))}moveIban(e,{address:r,chain:n}){return this.#t("patch",`ibans/${e}`,JSON.stringify({address:r,chain:u(this.#e.name,n)}))}requestIban({address:e,chain:r,emailNotifications:n=true}){return this.#t("post","ibans",JSON.stringify({address:e,chain:u(this.#e.name,r),emailNotifications:n}))}submitProfileDetails(e,r){return this.#t("put",`profiles/${e}/details`,JSON.stringify(r))}uploadSupportingDocument(e){let r=new FormData;return r.append("file",e),_(`${this.#e.api}/files`,"post",r,{Authorization:this.#s||""})}async#t(e,r,n,i){let s={Authorization:this.#s||"",Accept:"application/vnd.monerium.api-v2+json","Content-Type":`application/${i?"x-www-form-urlencoded":"json"}`};return _(`${this.#e.api}/${r}`,e.toUpperCase(),i?f(n):n,s)}#a=async(e,r,n,i)=>{let s=localStorage.getItem(w)||"";if(!s)throw new Error("Code verifier not found");return this.#r("Use code verifier to authorize"),this.state=i,localStorage.removeItem(w),await this.#o({code:n,redirect_uri:r,client_id:e,code_verifier:s})};#c=async({clientId:e,clientSecret:r})=>await this.#o({client_id:e,client_secret:r});#d=async(e,r)=>await this.#o({refresh_token:r,client_id:e});subscribeOrderNotifications({filter:e,onMessage:r,onError:n}={}){if(!this.bearerProfile?.access_token)return;let{profile:i,state:s}=e||{},a=m({access_token:this.bearerProfile?.access_token,profile:i,state:s}),o,l=E({profile:i,state:s});if(this.#i?.has(l))o=this.#i.get(l);else {let c=`${this.#e.wss}/orders${a}`;o=new WebSocket(c),this.#i?.set(l,o);}return o.onopen=()=>{console.log("Connected to WebSocket server");},o.onmessage=c=>{let y=JSON.parse(c.data);r&&r(y);},o.onclose=()=>{console.log("WebSocket connection closed"),this.#i?.delete(a);},o.onerror=c=>{n&&n(c),console.error("WebSocket error:",c);},o}unsubscribeOrderNotifications(e){if(e){let r=E({profile:e?.profile,state:e?.state}),n=this.#i?.get(r);n&&(n.close(),this.#i?.delete(r));}else this.#i?.forEach(r=>{r?.close();}),this.#i?.clear(),this.#i=undefined;}async disconnect(){d||localStorage.removeItem(w),this.unsubscribeOrderNotifications(),this.#s=undefined,this.bearerProfile=undefined;}async revokeAccess(){d||(localStorage.removeItem(p),localStorage.removeItem(g)),this.disconnect();}getEnvironment=()=>this.#e};var Te=I;exports.AccountState=V;exports.Currency=B;exports.IdDocumentKind=J;exports.KYCOutcome=Q;exports.KYCState=W;exports.Method=M;exports.MoneriumClient=I;exports.OrderKind=H;exports.OrderState=X;exports.PaymentStandard=G;exports.Permission=K;exports.ProfileState=L;exports.ProfileType=F;exports.constants=h;exports.default=Te;exports.getChain=O;exports.parseChain=P;exports.placeOrderMessage=ee;exports.rfc3339=b;exports.shortenAddress=re;exports.shortenIban=D;exports.siweMessage=te;
15
+ - ${l}`,C=t=>t&&Object.entries(t)?.length>0?Object.entries(t).filter(([e,r])=>r!==undefined).map(([e,r])=>`${encodeURIComponent(e)}=${encodeURIComponent(r)}`).join("&"):"",O=t=>{switch(t){case 1:return "ethereum";case 11155111:return "sepolia";case 100:return "gnosis";case 10200:return "chiado";case 137:return "polygon";case 80002:return "amoy";case 42161:return "arbitrum";case 421614:return "arbitrumsepolia";case 59144:return "linea";case 59141:return "lineasepolia";case 534352:return "scroll";case 534351:return "scrollsepolia";case 501:return "columbus";case 500:return "camino";default:throw new Error(`Chain not supported: ${t}`)}},D=t=>{if(typeof t!="string"||!t?.length)return t;let e=t.replace(/\s/g,"");return t?.length>11?`${e.substring(0,4)}...${e.substring(e.length-4)}`:t},re=t=>typeof t!="string"||!t?.length?t:t?.length>11?`${t.substring(0,7)}...${t.substring(t.length-5)}`:t;var T=(t,e)=>{if(e==="sandbox")switch(t){case "ethereum":return "sepolia";case "polygon":return "amoy";case "gnosis":return "chiado";case "arbitrum":return "arbitrumsepolia";case "linea":return "lineasepolia";case "scroll":return "scrollsepolia";case "camino":return "columbus";case "noble":return "noble";default:return t}return t},p=(t,e)=>{if(e?.chain){let{chain:r,...n}=e;return {...n,chain:b(T(r,t))}}return e};var {STORAGE_CODE_VERIFIER:w,STORAGE_ACCESS_TOKEN:h,STORAGE_ACCESS_EXPIRY:m}=f,d=typeof window>"u",I=class{#e;#s;bearerProfile;#i=new Map;isAuthorized=!!this.bearerProfile;#r=()=>{};#n;state;constructor(e){if(!e){this.#e=x.environments.sandbox;return}if(typeof e=="string")this.#e=x.environments[e];else if(this.#r=N(e.debug??false),this.#e=x.environments[e.environment||"sandbox"],!d&&!e?.clientSecret){let{clientId:r,redirectUri:n}=e;this.#n={clientId:r,redirectUri:n};}else if(d&&e?.clientSecret){this.#r("Client credentials detected");let{clientId:r,clientSecret:n}=e;this.#n={clientId:r,clientSecret:n};}}async authorize(e){let r=S(),n=e?.address?{address:e?.address,signature:e?.signature,chain:e?.chain?g(this.#e.name,e?.chain):undefined}:{},i=C({client_id:this.#n?.clientId,redirect_uri:this.#n?.redirectUri,code_challenge:r,code_challenge_method:"S256",response_type:"code",state:e?.state,skip_create_account:e?.skipCreateAccount,skip_kyc:e?.skipKyc,email:e?.email,...n}),s=`${this.#e.api}/auth?${i}`;this.#r(`Auth flow URL: ${s}`),window.location.assign(s);}async siwe(e){let r=S(),n=C({client_id:this.#n?.clientId,redirect_uri:this.#n?.redirectUri,message:e.message,signature:e.signature,code_challenge:r,code_challenge_method:"S256",authentication_method:"siwe",state:e?.state}),i=`${this.#e.api}/auth?${n}`;this.#r(`Auth flow SIWE URL: ${i}`),window.location.assign(i);}async getAccess(e){let r=this.#n?.clientId;if(this.#n?.clientSecret){if(d)return await this.#c(this.#n),!!this?.bearerProfile;console.error("\x1B[31m%s\x1B[0m","Use client credentials only on the server where the secret is secure!");}let i=this.#n?.redirectUri;if(!r)throw new Error("Missing ClientId");if(d)throw new Error("This only works client side");let s=new URLSearchParams(window.location.search).get("error")||undefined,a=new URLSearchParams(window.location.search).get("error_description")||undefined;if(s||a)throw new Error(a);let o=new URLSearchParams(window.location.search).get("code")||undefined,l=new URLSearchParams(window.location.search).get("state")||undefined,c=window.localStorage.getItem(h),y=window.localStorage.getItem(m);if(o)return this.#r("Using auth code from auth flow to authorize"),await this.#a(r,i,o,l),this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile;if(e)return this.#r("Using refresh token to authorize"),await this.#d(r,e),this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile;if(c&&y){let U=new Date;if(parseInt(y)<U.getTime())throw window.localStorage.removeItem(h),window.localStorage.removeItem(m),this.isAuthorized=false,this.bearerProfile=undefined,new Error("Access token has expired");this.#r("Access token should still be valid, checking if it is authorized...");try{return this.#s=`Bearer ${c}`,this.isAuthorized=!0,await this.getTokens(),this.#r("Authorized"),!0}catch{throw this.#r("Access token is invalid."),window.localStorage.removeItem(h),window.localStorage.removeItem(m),this.isAuthorized=false,this.bearerProfile=undefined,new Error("Access token is invalid.")}}return this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile}async#o(e){let r;if(R(e))r={...e,grant_type:"authorization_code"};else if($(e))r={...e,grant_type:"refresh_token"};else if(v(e))r={...e,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await this.#t("post","auth/token",r,true).then(n=>{if(this.bearerProfile=n,this.isAuthorized=!!n,this.#s=`Bearer ${n?.access_token}`,!d){let s=new Date().getTime()+n?.expires_in*1e3;window.localStorage.setItem(h,n?.access_token||""),window.localStorage.setItem(m,s?.toString());}}).catch(n=>{throw d||(localStorage.removeItem(w),localStorage.removeItem(h),localStorage.removeItem(m),k()),new Error(n?.message)}),R(e)&&k(),this.bearerProfile}getAuthContext(){return this.#t("get","auth/context")}getProfile(e){return this.#t("get",`profiles/${e}`)}getProfiles(e){return this.#t("get",`profiles${u(e)}`)}getAddress(e){return this.#t("get",`addresses/${e}`)}getAddresses(e){e=p(this.#e.name,e);let r=e?C(e):undefined,n=r?`addresses?${r}`:"addresses";return this.#t("get",n)}getBalances(e,r,n){let i=Array.isArray(n)?n.map(a=>`currency=${a}`).join("&"):n?`currency=${n}`:"",s=g(this.#e.name,r);return this.#t("get",`balances/${s}/${e}${i?`?${i}`:""}`)}getIban(e){return this.#t("get",`ibans/${encodeURI(e)}`)}getIbans(e){let{profile:r,chain:n}=e||{},i=u({profile:r,chain:n?g(this.#e.name,n):""});return this.#t("get",`ibans${i}`)}getOrders(e){return this.#t("get",`orders${u(e)}`)}getOrder(e){return this.#t("get",`orders/${e}`)}getTokens(){return this.#t("get","tokens")}getSignatures(e){let r=e?p(this.#e.name,e):undefined;return this.#t("get",`signatures${u(r)}`)}linkAddress(e){return e=p(this.#e.name,e),this.#t("post","addresses",JSON.stringify(e))}placeOrder(e){let r={kind:"redeem",...p(this.#e.name,e),counterpart:{...e.counterpart,identifier:p(this.#e.name,e.counterpart.identifier)}};return this.#t("post","orders",JSON.stringify(r))}moveIban(e,{address:r,chain:n}){return this.#t("patch",`ibans/${e}`,JSON.stringify({address:r,chain:g(this.#e.name,n)}))}requestIban({address:e,chain:r,emailNotifications:n=true}){return this.#t("post","ibans",JSON.stringify({address:e,chain:g(this.#e.name,r),emailNotifications:n}))}submitProfileDetails(e,r){return this.#t("put",`profiles/${e}/details`,JSON.stringify(r))}uploadSupportingDocument(e){let r=new FormData;return r.append("file",e),_(`${this.#e.api}/files`,"post",r,{Authorization:this.#s||""})}async#t(e,r,n,i){let s={Authorization:this.#s||"",Accept:"application/vnd.monerium.api-v2+json","Content-Type":`application/${i?"x-www-form-urlencoded":"json"}`};return _(`${this.#e.api}/${r}`,e.toUpperCase(),i?C(n):n,s)}#a=async(e,r,n,i)=>{let s=localStorage.getItem(w)||"";if(!s)throw new Error("Code verifier not found");return this.#r("Use code verifier to authorize"),this.state=i,localStorage.removeItem(w),await this.#o({code:n,redirect_uri:r,client_id:e,code_verifier:s})};#c=async({clientId:e,clientSecret:r})=>await this.#o({client_id:e,client_secret:r});#d=async(e,r)=>await this.#o({refresh_token:r,client_id:e});subscribeOrderNotifications({filter:e,onMessage:r,onError:n}={}){if(!this.bearerProfile?.access_token)return;let{profile:i,state:s}=e||{},a=u({access_token:this.bearerProfile?.access_token,profile:i,state:s}),o,l=E({profile:i,state:s});if(this.#i?.has(l))o=this.#i.get(l);else {let c=`${this.#e.wss}/orders${a}`;o=new WebSocket(c),this.#i?.set(l,o);}return o.onopen=()=>{console.log("Connected to WebSocket server");},o.onmessage=c=>{let y=JSON.parse(c.data);r&&r(y);},o.onclose=()=>{console.log("WebSocket connection closed"),this.#i?.delete(a);},o.onerror=c=>{n&&n(c),console.error("WebSocket error:",c);},o}unsubscribeOrderNotifications(e){if(e){let r=E({profile:e?.profile,state:e?.state}),n=this.#i?.get(r);n&&(n.close(),this.#i?.delete(r));}else this.#i?.forEach(r=>{r?.close();}),this.#i?.clear(),this.#i=undefined;}async disconnect(){d||localStorage.removeItem(w),this.unsubscribeOrderNotifications(),this.#s=undefined,this.bearerProfile=undefined;}async revokeAccess(){d||(localStorage.removeItem(h),localStorage.removeItem(m)),this.disconnect();}getEnvironment=()=>this.#e};var Te=I;exports.AccountState=V;exports.Currency=B;exports.IdDocumentKind=J;exports.KYCOutcome=W;exports.KYCState=Q;exports.Method=K;exports.MoneriumClient=I;exports.OrderKind=H;exports.OrderState=X;exports.PaymentStandard=G;exports.Permission=F;exports.ProfileState=L;exports.ProfileType=M;exports.constants=f;exports.default=Te;exports.getChain=O;exports.parseChain=b;exports.placeOrderMessage=ee;exports.rfc3339=P;exports.shortenAddress=re;exports.shortenIban=D;exports.siweMessage=te;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import z from'crypto-js/enc-base64url.js';import q from'crypto-js/sha256.js';var x={environments:{production:{name:"production",api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{name:"sandbox",api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}};var h={LINK_MESSAGE:"I hereby declare that I am the address owner.",STORAGE_CODE_VERIFIER:"monerium.sdk.code_verifier",STORAGE_ACCESS_TOKEN:"monerium.sdk.access_token",STORAGE_ACCESS_EXPIRY:"monerium.sdk.access_expiry"};var A=()=>{let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=e.length,n=0;for(;n<128;)t+=e.charAt(Math.floor(Math.random()*r)),n+=1;return t},j=t=>z.stringify(q(t)),S=()=>{let t=A(),e=j(t);return localStorage.setItem(h.STORAGE_CODE_VERIFIER,t||""),e},k=()=>{let t=window.location.href;if(!t||!t?.includes("?"))return;let[e,r]=t.split("?");r&&window.history.replaceState(null,"",e);},R=t=>t.code!=null,v=t=>t.refresh_token!=null,N=t=>t.client_secret!=null;var _=async(t,e,r,n)=>{let i=await fetch(`${t}`,{method:e,headers:n,body:r}),s,a=await i.text();try{if(s=JSON.parse(a),Object.keys(s).length===0&&s.constructor===Object)switch(i.status){case 201:case 202:return {status:i.status,statusText:i.statusText}}}catch{throw a}if(!i.ok)throw s;return s};var m=t=>{if(!t)return "";let e=Object.entries(t).filter(([r,n])=>n!==""&&n!==undefined&&n!==null).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&");return e?"?"+e:""};var $=t=>t?e=>{console.log("%c [MONERIUM:DEBUG]:","color:orange;",e);}:()=>{};var E=t=>Object.entries(t).filter(([r,n])=>n!=null).map(([r,n])=>`${r}-${n}`).join("-");var B=(i=>(i.eur="eur",i.usd="usd",i.gbp="gbp",i.isk="isk",i))(B||{}),M=(s=>(s.password="password",s.resource="resource",s.jwt="jwt",s.apiKey="apiKey",s.bearer="bearer",s))(M||{}),F=(r=>(r.corporate="corporate",r.personal="personal",r))(F||{}),K=(r=>(r.read="read",r.write="write",r))(K||{}),L=(s=>(s.created="created",s.pending="pending",s.approved="approved",s.rejected="rejected",s.blocked="blocked",s))(L||{}),W=(i=>(i.absent="absent",i.submitted="submitted",i.pending="pending",i.confirmed="confirmed",i))(W||{}),Q=(n=>(n.approved="approved",n.rejected="rejected",n.unknown="unknown",n))(Q||{}),V=(s=>(s.requested="requested",s.approved="approved",s.pending="pending",s.rejected="rejected",s.closed="closed",s))(V||{}),G=(i=>(i.iban="iban",i.scan="scan",i.chain="chain",i.account="account",i))(G||{}),J=(n=>(n.passport="passport",n.nationalIdentityCard="nationalIdentityCard",n.drivingLicense="drivingLicense",n))(J||{}),H=(r=>(r.redeem="redeem",r.issue="issue",r))(H||{}),X=(i=>(i.placed="placed",i.pending="pending",i.processed="processed",i.rejected="rejected",i))(X||{});var b=t=>{if(t.toString()==="Invalid Date")throw t;let e=n=>n<10?"0"+n:n,r=n=>{if(n===0)return "Z";let i=n>0?"-":"+";return n=Math.abs(n),i+e(Math.floor(n/60))+":"+e(n%60)};return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+"T"+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+r(t.getTimezoneOffset())},Z=t=>{switch(t){case "noble":case "noble-1":case "grand":case "grand-1":return true;default:return false}},Y=t=>{switch(t){case "ethereum":case "sepolia":case "polygon":case "amoy":case "gnosis":case "chiado":case "arbitrum":case "arbitrumsepolia":case "linea":case "lineasepolia":case "scroll":case "scrollsepolia":case "camino":case "columbus":return true;default:return false}},P=t=>{if(typeof t=="number")return O(t);if(Z(t))return t.split("-")[0];if(Y(t))return t;try{return O(parseInt(t))}catch{throw new Error(`Chain not supported: ${t}`)}},u=(t,e)=>P(T(e,t)),ee=(t,e,r,n)=>{let i=`${e?.toUpperCase()||"EUR"}`;return n?`Send ${i} ${t} to ${r} on ${P(n)} at ${b(new Date)}`:i==="EUR"?`Send ${i} ${t} to ${D(r)} at ${b(new Date)}`:`Send ${i} ${t} to ${r} at ${b(new Date)}`},te=({domain:t,address:e,appName:r,redirectUri:n,chainId:i,issuedAt:s=new Date().toISOString(),expiryAt:a=new Date(Date.now()+1e3*60*5).toISOString(),privacyPolicyUrl:o,termsOfServiceUrl:l})=>`${t} wants you to sign in with your Ethereum account:
1
+ import z from'crypto-js/enc-base64url.js';import q from'crypto-js/sha256.js';var x={environments:{production:{name:"production",api:"https://api.monerium.app",web:"https://monerium.app",wss:"wss://api.monerium.app"},sandbox:{name:"sandbox",api:"https://api.monerium.dev",web:"https://sandbox.monerium.dev",wss:"wss://api.monerium.dev"}}};var f={LINK_MESSAGE:"I hereby declare that I am the address owner.",STORAGE_CODE_VERIFIER:"monerium.sdk.code_verifier",STORAGE_ACCESS_TOKEN:"monerium.sdk.access_token",STORAGE_ACCESS_EXPIRY:"monerium.sdk.access_expiry"};var A=()=>{let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=e.length,n=0;for(;n<128;)t+=e.charAt(Math.floor(Math.random()*r)),n+=1;return t},j=t=>z.stringify(q(t)),S=()=>{let t=A(),e=j(t);return localStorage.setItem(f.STORAGE_CODE_VERIFIER,t||""),e},k=()=>{let t=window.location.href;if(!t||!t?.includes("?"))return;let[e,r]=t.split("?");r&&window.history.replaceState(null,"",e);},R=t=>t.code!=null,$=t=>t.refresh_token!=null,v=t=>t.client_secret!=null;var _=async(t,e,r,n)=>{let i=await fetch(`${t}`,{method:e,headers:n,body:r}),s,a=await i.text();try{if(s=JSON.parse(a),Object.keys(s).length===0&&s.constructor===Object)switch(i.status){case 201:case 202:return {status:i.status,statusText:i.statusText}}}catch{throw a}if(!i.ok)throw s;return s};var u=t=>{if(!t)return "";let e=Object.entries(t).filter(([r,n])=>n!==""&&n!==undefined&&n!==null).map(([r,n])=>`${encodeURIComponent(r)}=${encodeURIComponent(n)}`).join("&");return e?"?"+e:""};var N=t=>t?e=>{console.log("%c [MONERIUM:DEBUG]:","color:orange;",e);}:()=>{};var E=t=>Object.entries(t).filter(([r,n])=>n!=null).map(([r,n])=>`${r}-${n}`).join("-");var B=(i=>(i.eur="eur",i.usd="usd",i.gbp="gbp",i.isk="isk",i))(B||{}),K=(s=>(s.password="password",s.resource="resource",s.jwt="jwt",s.apiKey="apiKey",s.bearer="bearer",s))(K||{}),M=(r=>(r.corporate="corporate",r.personal="personal",r))(M||{}),F=(r=>(r.read="read",r.write="write",r))(F||{}),L=(s=>(s.created="created",s.pending="pending",s.approved="approved",s.rejected="rejected",s.blocked="blocked",s))(L||{}),Q=(i=>(i.absent="absent",i.submitted="submitted",i.pending="pending",i.confirmed="confirmed",i))(Q||{}),W=(n=>(n.approved="approved",n.rejected="rejected",n.unknown="unknown",n))(W||{}),V=(s=>(s.requested="requested",s.approved="approved",s.pending="pending",s.rejected="rejected",s.closed="closed",s))(V||{}),G=(i=>(i.iban="iban",i.scan="scan",i.chain="chain",i.account="account",i))(G||{}),J=(n=>(n.passport="passport",n.nationalIdentityCard="nationalIdentityCard",n.drivingLicense="drivingLicense",n))(J||{}),H=(r=>(r.redeem="redeem",r.issue="issue",r))(H||{}),X=(i=>(i.placed="placed",i.pending="pending",i.processed="processed",i.rejected="rejected",i))(X||{});var P=t=>{if(t.toString()==="Invalid Date")throw t;let e=n=>n<10?"0"+n:n,r=n=>{if(n===0)return "Z";let i=n>0?"-":"+";return n=Math.abs(n),i+e(Math.floor(n/60))+":"+e(n%60)};return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+"T"+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+r(t.getTimezoneOffset())},Z=t=>{switch(t){case "noble":case "noble-1":case "grand":case "grand-1":return true;default:return false}},Y=t=>{switch(t){case "ethereum":case "sepolia":case "polygon":case "amoy":case "gnosis":case "chiado":case "arbitrum":case "arbitrumsepolia":case "linea":case "lineasepolia":case "scroll":case "scrollsepolia":case "camino":case "columbus":return true;default:return false}},b=t=>{if(typeof t=="number")return O(t);if(Z(t))return t.split("-")[0];if(Y(t))return t;try{return O(parseInt(t))}catch{throw new Error(`Chain not supported: ${t}`)}},g=(t,e)=>b(T(e,t)),ee=(t,e,r,n)=>{let i=`${e?.toUpperCase()||"EUR"}`;return n?`Send ${i} ${t} to ${r} on ${b(n)} at ${P(new Date)}`:i==="EUR"?`Send ${i} ${t} to ${D(r)} at ${P(new Date)}`:`Send ${i} ${t} to ${r} at ${P(new Date)}`},te=({domain:t,address:e,appName:r,redirectUri:n,chainId:i,issuedAt:s=new Date().toISOString(),expiryAt:a=new Date(Date.now()+1e3*60*5).toISOString(),privacyPolicyUrl:o,termsOfServiceUrl:l})=>`${t} wants you to sign in with your Ethereum account:
2
2
  ${e}
3
3
 
4
4
  Allow ${r} to access my data on Monerium
@@ -12,4 +12,4 @@ Expiration Time: ${a}
12
12
  Resources:
13
13
  - https://monerium.com/siwe
14
14
  - ${o}
15
- - ${l}`,f=t=>t&&Object.entries(t)?.length>0?Object.entries(t).filter(([e,r])=>r!==undefined).map(([e,r])=>`${encodeURIComponent(e)}=${encodeURIComponent(r)}`).join("&"):"",O=t=>{switch(t){case 1:return "ethereum";case 11155111:return "sepolia";case 100:return "gnosis";case 10200:return "chiado";case 137:return "polygon";case 80002:return "amoy";case 42161:return "arbitrum";case 421614:return "arbitrumsepolia";case 59144:return "linea";case 59141:return "lineasepolia";case 534352:return "scroll";case 534351:return "scrollsepolia";case 501:return "columbus";case 500:return "camino";default:throw new Error(`Chain not supported: ${t}`)}},D=t=>{if(typeof t!="string"||!t?.length)return t;let e=t.replace(/\s/g,"");return t?.length>11?`${e.substring(0,4)}...${e.substring(e.length-4)}`:t},re=t=>typeof t!="string"||!t?.length?t:t?.length>11?`${t.substring(0,7)}...${t.substring(t.length-5)}`:t;var T=(t,e)=>{if(e==="sandbox")switch(t){case "ethereum":return "sepolia";case "polygon":return "amoy";case "gnosis":return "chiado";case "arbitrum":return "arbitrumsepolia";case "linea":return "lineasepolia";case "scroll":return "scrollsepolia";case "camino":return "columbus";case "noble":return "noble";default:return t}return t},C=(t,e)=>{if(e?.chain){let{chain:r,...n}=e;return {...n,chain:P(T(r,t))}}return e};var {STORAGE_CODE_VERIFIER:w,STORAGE_ACCESS_TOKEN:p,STORAGE_ACCESS_EXPIRY:g}=h,d=typeof window>"u",I=class{#e;#s;bearerProfile;#i=new Map;isAuthorized=!!this.bearerProfile;#r=()=>{};#n;state;constructor(e){if(!e){this.#e=x.environments.sandbox;return}if(typeof e=="string")this.#e=x.environments[e];else if(this.#r=$(e.debug??false),this.#e=x.environments[e.environment||"sandbox"],!d&&!e?.clientSecret){let{clientId:r,redirectUri:n}=e;this.#n={clientId:r,redirectUri:n};}else if(d&&e?.clientSecret){this.#r("Client credentials detected");let{clientId:r,clientSecret:n}=e;this.#n={clientId:r,clientSecret:n};}}async authorize(e){let r=S(),n=e?.address?{address:e?.address,signature:e?.signature,chain:e?.chain?u(this.#e.name,e?.chain):undefined}:{},i=f({client_id:this.#n?.clientId,redirect_uri:this.#n?.redirectUri,code_challenge:r,code_challenge_method:"S256",response_type:"code",state:e?.state,skip_create_account:e?.skipCreateAccount,skip_kyc:e?.skipKyc,email:e?.email,...n}),s=`${this.#e.api}/auth?${i}`;this.#r(`Auth flow URL: ${s}`),window.location.assign(s);}async siwe(e){let r=S(),n=f({client_id:this.#n?.clientId,redirect_uri:this.#n?.redirectUri,message:e.message,signature:e.signature,code_challenge:r,code_challenge_method:"S256",authentication_method:"siwe",state:e?.state}),i=`${this.#e.api}/auth?${n}`;this.#r(`Auth flow SIWE URL: ${i}`),window.location.assign(i);}async getAccess(e){let r=this.#n?.clientId;if(this.#n?.clientSecret){if(d)return await this.#c(this.#n),!!this?.bearerProfile;console.error("\x1B[31m%s\x1B[0m","Use client credentials only on the server where the secret is secure!");}let i=this.#n?.redirectUri;if(!r)throw new Error("Missing ClientId");if(d)throw new Error("This only works client side");let s=new URLSearchParams(window.location.search).get("error")||undefined,a=new URLSearchParams(window.location.search).get("error_description")||undefined;if(s||a)throw new Error(a);let o=new URLSearchParams(window.location.search).get("code")||undefined,l=new URLSearchParams(window.location.search).get("state")||undefined,c=window.localStorage.getItem(p),y=window.localStorage.getItem(g);if(o)return this.#r("Using auth code from auth flow to authorize"),await this.#a(r,i,o,l),this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile;if(e)return this.#r("Using refresh token to authorize"),await this.#d(r,e),this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile;if(c&&y){let U=new Date;if(parseInt(y)<U.getTime())throw window.localStorage.removeItem(p),window.localStorage.removeItem(g),this.isAuthorized=false,this.bearerProfile=undefined,new Error("Access token has expired");this.#r("Access token should still be valid, checking if it is authorized...");try{return this.#s=`Bearer ${c}`,this.isAuthorized=!0,await this.getTokens(),this.#r("Authorized"),!0}catch{throw this.#r("Access token is invalid."),window.localStorage.removeItem(p),window.localStorage.removeItem(g),this.isAuthorized=false,this.bearerProfile=undefined,new Error("Access token is invalid.")}}return this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile}async#o(e){let r;if(R(e))r={...e,grant_type:"authorization_code"};else if(v(e))r={...e,grant_type:"refresh_token"};else if(N(e))r={...e,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await this.#t("post","auth/token",r,true).then(n=>{if(this.bearerProfile=n,this.isAuthorized=!!n,this.#s=`Bearer ${n?.access_token}`,!d){let s=new Date().getTime()+n?.expires_in*1e3;window.localStorage.setItem(p,n?.access_token||""),window.localStorage.setItem(g,s?.toString());}}).catch(n=>{throw d||(localStorage.removeItem(w),localStorage.removeItem(p),localStorage.removeItem(g),k()),new Error(n?.message)}),R(e)&&k(),this.bearerProfile}getAuthContext(){return this.#t("get","auth/context")}getProfile(e){return this.#t("get",`profiles/${e}`)}getProfiles(e){return this.#t("get",`profiles${m(e)}`)}getAddress(e){return this.#t("get",`addresses/${e}`)}getAddresses(e){e=C(this.#e.name,e);let r=e?f(e):undefined,n=r?`addresses?${r}`:"addresses";return this.#t("get",n)}getBalances(e,r,n){let i=Array.isArray(n)?n.map(a=>`currency=${a}`).join("&"):n?`currency=${n}`:"",s=u(this.#e.name,r);return this.#t("get",`balances/${s}/${e}${i?`?${i}`:""}`)}getIban(e){return this.#t("get",`ibans/${encodeURI(e)}`)}getIbans(e){let{profile:r,chain:n}=e||{},i=m({profile:r,chain:n?u(this.#e.name,n):""});return this.#t("get",`ibans${i}`)}getOrders(e){return this.#t("get",`orders${m(e)}`)}getOrder(e){return this.#t("get",`orders/${e}`)}getTokens(){return this.#t("get","tokens")}linkAddress(e){return e=C(this.#e.name,e),this.#t("post","addresses",JSON.stringify(e))}placeOrder(e){let r={kind:"redeem",...C(this.#e.name,e),counterpart:{...e.counterpart,identifier:C(this.#e.name,e.counterpart.identifier)}};return this.#t("post","orders",JSON.stringify(r))}moveIban(e,{address:r,chain:n}){return this.#t("patch",`ibans/${e}`,JSON.stringify({address:r,chain:u(this.#e.name,n)}))}requestIban({address:e,chain:r,emailNotifications:n=true}){return this.#t("post","ibans",JSON.stringify({address:e,chain:u(this.#e.name,r),emailNotifications:n}))}submitProfileDetails(e,r){return this.#t("put",`profiles/${e}/details`,JSON.stringify(r))}uploadSupportingDocument(e){let r=new FormData;return r.append("file",e),_(`${this.#e.api}/files`,"post",r,{Authorization:this.#s||""})}async#t(e,r,n,i){let s={Authorization:this.#s||"",Accept:"application/vnd.monerium.api-v2+json","Content-Type":`application/${i?"x-www-form-urlencoded":"json"}`};return _(`${this.#e.api}/${r}`,e.toUpperCase(),i?f(n):n,s)}#a=async(e,r,n,i)=>{let s=localStorage.getItem(w)||"";if(!s)throw new Error("Code verifier not found");return this.#r("Use code verifier to authorize"),this.state=i,localStorage.removeItem(w),await this.#o({code:n,redirect_uri:r,client_id:e,code_verifier:s})};#c=async({clientId:e,clientSecret:r})=>await this.#o({client_id:e,client_secret:r});#d=async(e,r)=>await this.#o({refresh_token:r,client_id:e});subscribeOrderNotifications({filter:e,onMessage:r,onError:n}={}){if(!this.bearerProfile?.access_token)return;let{profile:i,state:s}=e||{},a=m({access_token:this.bearerProfile?.access_token,profile:i,state:s}),o,l=E({profile:i,state:s});if(this.#i?.has(l))o=this.#i.get(l);else {let c=`${this.#e.wss}/orders${a}`;o=new WebSocket(c),this.#i?.set(l,o);}return o.onopen=()=>{console.log("Connected to WebSocket server");},o.onmessage=c=>{let y=JSON.parse(c.data);r&&r(y);},o.onclose=()=>{console.log("WebSocket connection closed"),this.#i?.delete(a);},o.onerror=c=>{n&&n(c),console.error("WebSocket error:",c);},o}unsubscribeOrderNotifications(e){if(e){let r=E({profile:e?.profile,state:e?.state}),n=this.#i?.get(r);n&&(n.close(),this.#i?.delete(r));}else this.#i?.forEach(r=>{r?.close();}),this.#i?.clear(),this.#i=undefined;}async disconnect(){d||localStorage.removeItem(w),this.unsubscribeOrderNotifications(),this.#s=undefined,this.bearerProfile=undefined;}async revokeAccess(){d||(localStorage.removeItem(p),localStorage.removeItem(g)),this.disconnect();}getEnvironment=()=>this.#e};var Te=I;export{V as AccountState,B as Currency,J as IdDocumentKind,Q as KYCOutcome,W as KYCState,M as Method,I as MoneriumClient,H as OrderKind,X as OrderState,G as PaymentStandard,K as Permission,L as ProfileState,F as ProfileType,h as constants,Te as default,O as getChain,P as parseChain,ee as placeOrderMessage,b as rfc3339,re as shortenAddress,D as shortenIban,te as siweMessage};
15
+ - ${l}`,C=t=>t&&Object.entries(t)?.length>0?Object.entries(t).filter(([e,r])=>r!==undefined).map(([e,r])=>`${encodeURIComponent(e)}=${encodeURIComponent(r)}`).join("&"):"",O=t=>{switch(t){case 1:return "ethereum";case 11155111:return "sepolia";case 100:return "gnosis";case 10200:return "chiado";case 137:return "polygon";case 80002:return "amoy";case 42161:return "arbitrum";case 421614:return "arbitrumsepolia";case 59144:return "linea";case 59141:return "lineasepolia";case 534352:return "scroll";case 534351:return "scrollsepolia";case 501:return "columbus";case 500:return "camino";default:throw new Error(`Chain not supported: ${t}`)}},D=t=>{if(typeof t!="string"||!t?.length)return t;let e=t.replace(/\s/g,"");return t?.length>11?`${e.substring(0,4)}...${e.substring(e.length-4)}`:t},re=t=>typeof t!="string"||!t?.length?t:t?.length>11?`${t.substring(0,7)}...${t.substring(t.length-5)}`:t;var T=(t,e)=>{if(e==="sandbox")switch(t){case "ethereum":return "sepolia";case "polygon":return "amoy";case "gnosis":return "chiado";case "arbitrum":return "arbitrumsepolia";case "linea":return "lineasepolia";case "scroll":return "scrollsepolia";case "camino":return "columbus";case "noble":return "noble";default:return t}return t},p=(t,e)=>{if(e?.chain){let{chain:r,...n}=e;return {...n,chain:b(T(r,t))}}return e};var {STORAGE_CODE_VERIFIER:w,STORAGE_ACCESS_TOKEN:h,STORAGE_ACCESS_EXPIRY:m}=f,d=typeof window>"u",I=class{#e;#s;bearerProfile;#i=new Map;isAuthorized=!!this.bearerProfile;#r=()=>{};#n;state;constructor(e){if(!e){this.#e=x.environments.sandbox;return}if(typeof e=="string")this.#e=x.environments[e];else if(this.#r=N(e.debug??false),this.#e=x.environments[e.environment||"sandbox"],!d&&!e?.clientSecret){let{clientId:r,redirectUri:n}=e;this.#n={clientId:r,redirectUri:n};}else if(d&&e?.clientSecret){this.#r("Client credentials detected");let{clientId:r,clientSecret:n}=e;this.#n={clientId:r,clientSecret:n};}}async authorize(e){let r=S(),n=e?.address?{address:e?.address,signature:e?.signature,chain:e?.chain?g(this.#e.name,e?.chain):undefined}:{},i=C({client_id:this.#n?.clientId,redirect_uri:this.#n?.redirectUri,code_challenge:r,code_challenge_method:"S256",response_type:"code",state:e?.state,skip_create_account:e?.skipCreateAccount,skip_kyc:e?.skipKyc,email:e?.email,...n}),s=`${this.#e.api}/auth?${i}`;this.#r(`Auth flow URL: ${s}`),window.location.assign(s);}async siwe(e){let r=S(),n=C({client_id:this.#n?.clientId,redirect_uri:this.#n?.redirectUri,message:e.message,signature:e.signature,code_challenge:r,code_challenge_method:"S256",authentication_method:"siwe",state:e?.state}),i=`${this.#e.api}/auth?${n}`;this.#r(`Auth flow SIWE URL: ${i}`),window.location.assign(i);}async getAccess(e){let r=this.#n?.clientId;if(this.#n?.clientSecret){if(d)return await this.#c(this.#n),!!this?.bearerProfile;console.error("\x1B[31m%s\x1B[0m","Use client credentials only on the server where the secret is secure!");}let i=this.#n?.redirectUri;if(!r)throw new Error("Missing ClientId");if(d)throw new Error("This only works client side");let s=new URLSearchParams(window.location.search).get("error")||undefined,a=new URLSearchParams(window.location.search).get("error_description")||undefined;if(s||a)throw new Error(a);let o=new URLSearchParams(window.location.search).get("code")||undefined,l=new URLSearchParams(window.location.search).get("state")||undefined,c=window.localStorage.getItem(h),y=window.localStorage.getItem(m);if(o)return this.#r("Using auth code from auth flow to authorize"),await this.#a(r,i,o,l),this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile;if(e)return this.#r("Using refresh token to authorize"),await this.#d(r,e),this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile;if(c&&y){let U=new Date;if(parseInt(y)<U.getTime())throw window.localStorage.removeItem(h),window.localStorage.removeItem(m),this.isAuthorized=false,this.bearerProfile=undefined,new Error("Access token has expired");this.#r("Access token should still be valid, checking if it is authorized...");try{return this.#s=`Bearer ${c}`,this.isAuthorized=!0,await this.getTokens(),this.#r("Authorized"),!0}catch{throw this.#r("Access token is invalid."),window.localStorage.removeItem(h),window.localStorage.removeItem(m),this.isAuthorized=false,this.bearerProfile=undefined,new Error("Access token is invalid.")}}return this.#r(this.bearerProfile?"Authorized":"Not authorized"),!!this.bearerProfile}async#o(e){let r;if(R(e))r={...e,grant_type:"authorization_code"};else if($(e))r={...e,grant_type:"refresh_token"};else if(v(e))r={...e,grant_type:"client_credentials"};else throw new Error("Authorization grant type could not be detected.");return await this.#t("post","auth/token",r,true).then(n=>{if(this.bearerProfile=n,this.isAuthorized=!!n,this.#s=`Bearer ${n?.access_token}`,!d){let s=new Date().getTime()+n?.expires_in*1e3;window.localStorage.setItem(h,n?.access_token||""),window.localStorage.setItem(m,s?.toString());}}).catch(n=>{throw d||(localStorage.removeItem(w),localStorage.removeItem(h),localStorage.removeItem(m),k()),new Error(n?.message)}),R(e)&&k(),this.bearerProfile}getAuthContext(){return this.#t("get","auth/context")}getProfile(e){return this.#t("get",`profiles/${e}`)}getProfiles(e){return this.#t("get",`profiles${u(e)}`)}getAddress(e){return this.#t("get",`addresses/${e}`)}getAddresses(e){e=p(this.#e.name,e);let r=e?C(e):undefined,n=r?`addresses?${r}`:"addresses";return this.#t("get",n)}getBalances(e,r,n){let i=Array.isArray(n)?n.map(a=>`currency=${a}`).join("&"):n?`currency=${n}`:"",s=g(this.#e.name,r);return this.#t("get",`balances/${s}/${e}${i?`?${i}`:""}`)}getIban(e){return this.#t("get",`ibans/${encodeURI(e)}`)}getIbans(e){let{profile:r,chain:n}=e||{},i=u({profile:r,chain:n?g(this.#e.name,n):""});return this.#t("get",`ibans${i}`)}getOrders(e){return this.#t("get",`orders${u(e)}`)}getOrder(e){return this.#t("get",`orders/${e}`)}getTokens(){return this.#t("get","tokens")}getSignatures(e){let r=e?p(this.#e.name,e):undefined;return this.#t("get",`signatures${u(r)}`)}linkAddress(e){return e=p(this.#e.name,e),this.#t("post","addresses",JSON.stringify(e))}placeOrder(e){let r={kind:"redeem",...p(this.#e.name,e),counterpart:{...e.counterpart,identifier:p(this.#e.name,e.counterpart.identifier)}};return this.#t("post","orders",JSON.stringify(r))}moveIban(e,{address:r,chain:n}){return this.#t("patch",`ibans/${e}`,JSON.stringify({address:r,chain:g(this.#e.name,n)}))}requestIban({address:e,chain:r,emailNotifications:n=true}){return this.#t("post","ibans",JSON.stringify({address:e,chain:g(this.#e.name,r),emailNotifications:n}))}submitProfileDetails(e,r){return this.#t("put",`profiles/${e}/details`,JSON.stringify(r))}uploadSupportingDocument(e){let r=new FormData;return r.append("file",e),_(`${this.#e.api}/files`,"post",r,{Authorization:this.#s||""})}async#t(e,r,n,i){let s={Authorization:this.#s||"",Accept:"application/vnd.monerium.api-v2+json","Content-Type":`application/${i?"x-www-form-urlencoded":"json"}`};return _(`${this.#e.api}/${r}`,e.toUpperCase(),i?C(n):n,s)}#a=async(e,r,n,i)=>{let s=localStorage.getItem(w)||"";if(!s)throw new Error("Code verifier not found");return this.#r("Use code verifier to authorize"),this.state=i,localStorage.removeItem(w),await this.#o({code:n,redirect_uri:r,client_id:e,code_verifier:s})};#c=async({clientId:e,clientSecret:r})=>await this.#o({client_id:e,client_secret:r});#d=async(e,r)=>await this.#o({refresh_token:r,client_id:e});subscribeOrderNotifications({filter:e,onMessage:r,onError:n}={}){if(!this.bearerProfile?.access_token)return;let{profile:i,state:s}=e||{},a=u({access_token:this.bearerProfile?.access_token,profile:i,state:s}),o,l=E({profile:i,state:s});if(this.#i?.has(l))o=this.#i.get(l);else {let c=`${this.#e.wss}/orders${a}`;o=new WebSocket(c),this.#i?.set(l,o);}return o.onopen=()=>{console.log("Connected to WebSocket server");},o.onmessage=c=>{let y=JSON.parse(c.data);r&&r(y);},o.onclose=()=>{console.log("WebSocket connection closed"),this.#i?.delete(a);},o.onerror=c=>{n&&n(c),console.error("WebSocket error:",c);},o}unsubscribeOrderNotifications(e){if(e){let r=E({profile:e?.profile,state:e?.state}),n=this.#i?.get(r);n&&(n.close(),this.#i?.delete(r));}else this.#i?.forEach(r=>{r?.close();}),this.#i?.clear(),this.#i=undefined;}async disconnect(){d||localStorage.removeItem(w),this.unsubscribeOrderNotifications(),this.#s=undefined,this.bearerProfile=undefined;}async revokeAccess(){d||(localStorage.removeItem(h),localStorage.removeItem(m)),this.disconnect();}getEnvironment=()=>this.#e};var Te=I;export{V as AccountState,B as Currency,J as IdDocumentKind,W as KYCOutcome,Q as KYCState,K as Method,I as MoneriumClient,H as OrderKind,X as OrderState,G as PaymentStandard,F as Permission,L as ProfileState,M as ProfileType,f as constants,Te as default,O as getChain,b as parseChain,ee as placeOrderMessage,P as rfc3339,re as shortenAddress,D as shortenIban,te as siweMessage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monerium/sdk",
3
- "version": "3.4.4",
3
+ "version": "3.4.8",
4
4
  "description": "Essential tools to interact with the Monerium API, an electronic money issuer.",
5
5
  "repository": {
6
6
  "type": "git",