@@ -49,8 +49,6 @@ export class MoneriumClient {
4949 #env: Environment ;
5050
5151 #authorizationHeader?: string ;
52-
53- #version?: string ;
5452 /**
5553 * The PKCE code verifier
5654 * @deprecated , use localStorage, will be removed in v3
@@ -93,7 +91,6 @@ export class MoneriumClient {
9391 // No arguments, default to sandbox
9492 if ( ! envOrOptions ) {
9593 this . #env = MONERIUM_CONFIG . environments [ 'sandbox' ] ;
96- this . #version = 'v2' ;
9794 return ;
9895 }
9996 // String argument
@@ -102,7 +99,6 @@ export class MoneriumClient {
10299 } else {
103100 this . #env =
104101 MONERIUM_CONFIG . environments [ envOrOptions . environment || 'sandbox' ] ;
105- this . #version = envOrOptions ?. version || 'v2' ;
106102
107103 if ( ! isServer ) {
108104 const { clientId, redirectUri } =
@@ -352,42 +348,15 @@ export class MoneriumClient {
352348 * {@link https://monerium.dev/api-docs#operation/profile-addresses }
353349 * @category Accounts
354350 */
355- linkAddress (
356- body : Omit < LinkAddress , 'accounts' > & { profile : string }
357- ) : Promise < LinkedAddress > ;
358- /** @deprecated this function should only take one parameter, body with profile id included */
359- linkAddress ( profileId : string , body : LinkAddress ) : Promise < LinkedAddress > ;
360-
361- linkAddress (
362- profileIdOrBody :
363- | string
364- | ( Omit < LinkAddress , 'accounts' > & { profile : string } ) ,
365- /** @deprecated this function should only take one parameter, body with profile id included */
366- body ?: LinkAddress
367- ) : Promise < LinkedAddress > {
368- if ( typeof profileIdOrBody === 'string' && body && this . #version === 'v1' ) {
369- body = mapChainIdToChain ( body ) ;
370- if ( body ?. accounts ) {
371- body . accounts = body ?. accounts . map ( ( account ) =>
372- mapChainIdToChain ( account )
373- ) ;
374- }
351+ linkAddress ( profileId : string , body : LinkAddress ) : Promise < LinkedAddress > {
352+ body = mapChainIdToChain ( body ) ;
353+ body . accounts = body . accounts . map ( ( account ) => mapChainIdToChain ( account ) ) ;
375354
376- return this . #api< LinkedAddress > (
377- 'post' ,
378- `profiles/${ profileIdOrBody } /addresses` ,
379- JSON . stringify ( body )
380- ) ;
381- } else if ( typeof profileIdOrBody === 'object' && this . #version === 'v2' ) {
382- profileIdOrBody = mapChainIdToChain ( profileIdOrBody ) ;
383- return this . #api< LinkedAddress > (
384- 'post' ,
385- `addresses` ,
386- JSON . stringify ( profileIdOrBody )
387- ) ;
388- } else {
389- throw new Error ( 'Invalid arguments' ) ;
390- }
355+ return this . #api(
356+ 'post' ,
357+ `profiles/${ profileId } /addresses` ,
358+ JSON . stringify ( body )
359+ ) ;
391360 }
392361
393362 /**
@@ -428,32 +397,16 @@ export class MoneriumClient {
428397 body ?: BodyInit | Record < string , string > ,
429398 isFormEncoded ?: boolean
430399 ) : Promise < T > {
431- const headers : Record < string , string > = {
432- Authorization : this . #authorizationHeader || '' ,
433- 'Content-Type' : `application/${
434- isFormEncoded ? 'x-www-form-urlencoded' : 'json'
435- } `,
436- } ;
437- if ( this . #version === 'v2' ) {
438- headers [ 'Accept' ] = 'application/vnd.monerium.api-v2+json' ;
439- }
440- console . log (
441- '%c headers' ,
442- 'color:white; padding: 30px; background-color: darkgreen' ,
443- headers
444- ) ;
445-
446- console . log (
447- '%c ${this.#env.api}/${resource}' ,
448- 'color:white; padding: 30px; background-color: darkgreen' ,
449- `${ this . #env. api } /${ resource } `
450- ) ;
451-
452400 return rest < T > (
453401 `${ this . #env. api } /${ resource } ` ,
454402 method ,
455403 isFormEncoded ? urlEncoded ( body as Record < string , string > ) : body ,
456- headers
404+ {
405+ Authorization : this . #authorizationHeader || '' ,
406+ 'Content-Type' : `application/${
407+ isFormEncoded ? 'x-www-form-urlencoded' : 'json'
408+ } `,
409+ }
457410 ) ;
458411 }
459412
0 commit comments