Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fiatconnect/fiatconnect-sdk

Package Overview
Dependencies
Maintainers
6
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fiatconnect/fiatconnect-sdk - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

dist/example.d.ts

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Changelog

### [0.3.2](https://github.com/fiatconnect/fiatconnect-sdk/compare/v0.3.1...v0.3.2) (2022-06-27)
### Features
* **createQuoteIn/Out:** renamed getQuoteIn/Out to createQuoteIn/Out and switched to POST to keep in sync with spec ([733e8fd](https://github.com/fiatconnect/fiatconnect-sdk/commit/733e8fd874dc805a88d96d07472bfdf999ca4c6b))
### Bug Fixes
* **kyc status:** should be GET /kyc/:kycSchema/status (was: GET /kyc/:kycSchema) ([733e8fd](https://github.com/fiatconnect/fiatconnect-sdk/commit/733e8fd874dc805a88d96d07472bfdf999ca4c6b))
### [0.3.1](https://github.com/fiatconnect/fiatconnect-sdk/compare/v0.3.0...v0.3.1) (2022-06-21)

@@ -7,0 +18,0 @@

28

dist/fiat-connect-client.d.ts

@@ -1,2 +0,2 @@

import { DeleteFiatAccountRequestParams, GetFiatAccountsResponse, KycRequestParams, KycStatusResponse, PostFiatAccountRequestBody, PostFiatAccountResponse, QuoteRequestQuery, QuoteResponse, TransferResponse, TransferStatusRequestParams, TransferStatusResponse, ClockResponse, FiatAccountSchema, KycSchema } from '@fiatconnect/fiatconnect-types';
import { DeleteFiatAccountRequestParams, GetFiatAccountsResponse, KycRequestParams, KycStatusResponse, PostFiatAccountRequestBody, PostFiatAccountResponse, QuoteRequestBody, QuoteResponse, TransferResponse, TransferStatusRequestParams, TransferStatusResponse, ClockResponse, FiatAccountSchema, KycSchema } from '@fiatconnect/fiatconnect-types';
import { Result } from '@badrap/result';

@@ -27,3 +27,3 @@ import { AddKycParams, ResponseError, FiatConnectApiClient, FiatConnectClientConfig, TransferRequestParams, ClockDiffParams, ClockDiffResult, LoginParams } from './types';

login(params?: LoginParams): Promise<Result<'success', ResponseError>>;
_getQuote(params: QuoteRequestQuery, inOrOut: 'in' | 'out'): Promise<Result<QuoteResponse, ResponseError>>;
_createQuote(body: QuoteRequestBody, inOrOut: 'in' | 'out'): Promise<Result<QuoteResponse, ResponseError>>;
/**

@@ -53,39 +53,39 @@ * https://en.wikipedia.org/wiki/Network_Time_Protocol#Clock_synchronization_algorithm

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3311-get-quotein
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3411-post-quotein
*/
getQuoteIn(params: QuoteRequestQuery): Promise<Result<QuoteResponse, ResponseError>>;
createQuoteIn(params: QuoteRequestBody): Promise<Result<QuoteResponse, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3312-get-quoteout
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3412-post-quoteout
*/
getQuoteOut(params: QuoteRequestQuery): Promise<Result<QuoteResponse, ResponseError>>;
createQuoteOut(params: QuoteRequestBody): Promise<Result<QuoteResponse, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3321-post-kyckycschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3421-post-kyckycschema
*/
addKyc<T extends KycSchema>(params: AddKycParams<T>): Promise<Result<KycStatusResponse, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3323-delete-kyckycschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3423-delete-kyckycschema
*/
deleteKyc(params: KycRequestParams): Promise<Result<void, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3322-get-kyckycschemastatus
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3422-get-kyckycschemastatus
*/
getKycStatus(params: KycRequestParams): Promise<Result<KycStatusResponse, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3331-post-accountsfiataccountschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3431-post-accounts
*/
addFiatAccount<T extends FiatAccountSchema>(params: PostFiatAccountRequestBody<T>): Promise<Result<PostFiatAccountResponse, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3332-get-accounts
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3432-get-accounts
*/
getFiatAccounts(): Promise<Result<GetFiatAccountsResponse, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3333-delete-accountfiataccountid
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3433-delete-accountsfiataccountid
*/
deleteFiatAccount(params: DeleteFiatAccountRequestParams): Promise<Result<void, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3341-post-transferin
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3441-post-transferin
*/
transferIn(params: TransferRequestParams): Promise<Result<TransferResponse, ResponseError>>;
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3342-post-transferout
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3442-post-transferout
*/

@@ -92,0 +92,0 @@ transferOut(params: TransferRequestParams): Promise<Result<TransferResponse, ResponseError>>;

@@ -103,8 +103,8 @@ "use strict";

}
async _getQuote(params, inOrOut) {
async _createQuote(body, inOrOut) {
try {
const queryParams = new URLSearchParams(params).toString();
const response = await fetch(`${this.config.baseUrl}/quote/${inOrOut}?${queryParams}`, {
method: 'GET',
const response = await fetch(`${this.config.baseUrl}/quote/${inOrOut}`, {
method: 'POST',
headers: this._getAuthHeader(),
body: JSON.stringify(body),
});

@@ -184,15 +184,15 @@ const data = await response.json();

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3311-get-quotein
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3411-post-quotein
*/
async getQuoteIn(params) {
return this._getQuote(params, 'in');
async createQuoteIn(params) {
return this._createQuote(params, 'in');
}
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3312-get-quoteout
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3412-post-quoteout
*/
async getQuoteOut(params) {
return this._getQuote(params, 'out');
async createQuoteOut(params) {
return this._createQuote(params, 'out');
}
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3321-post-kyckycschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3421-post-kyckycschema
*/

@@ -218,3 +218,3 @@ async addKyc(params) {

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3323-delete-kyckycschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3423-delete-kyckycschema
*/

@@ -239,3 +239,3 @@ async deleteKyc(params) {

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3322-get-kyckycschemastatus
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3422-get-kyckycschemastatus
*/

@@ -245,3 +245,3 @@ async getKycStatus(params) {

await this._ensureLogin();
const response = await fetch(`${this.config.baseUrl}/kyc/${params.kycSchema}`, {
const response = await fetch(`${this.config.baseUrl}/kyc/${params.kycSchema}/status`, {
method: 'GET',

@@ -261,3 +261,3 @@ headers: this._getAuthHeader(),

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3331-post-accountsfiataccountschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3431-post-accounts
*/

@@ -283,3 +283,3 @@ async addFiatAccount(params) {

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3332-get-accounts
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3432-get-accounts
*/

@@ -304,3 +304,3 @@ async getFiatAccounts() {

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3333-delete-accountfiataccountid
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3433-delete-accountsfiataccountid
*/

@@ -325,3 +325,3 @@ async deleteFiatAccount(params) {

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3341-post-transferin
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3441-post-transferin
*/

@@ -347,3 +347,3 @@ async transferIn(params) {

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3342-post-transferout
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3442-post-transferout
*/

@@ -350,0 +350,0 @@ async transferOut(params) {

@@ -1,2 +0,2 @@

import { DeleteFiatAccountRequestParams, FiatConnectError, GetFiatAccountsResponse, KycRequestParams, KycSchema, KycSchemas, KycStatusResponse, Network, PostFiatAccountRequestBody, PostFiatAccountResponse, QuoteErrorResponse, QuoteRequestQuery, QuoteResponse, TransferRequestBody, TransferResponse, TransferStatusRequestParams, TransferStatusResponse, ClockResponse, FiatAccountSchema } from '@fiatconnect/fiatconnect-types';
import { DeleteFiatAccountRequestParams, FiatConnectError, GetFiatAccountsResponse, KycRequestParams, KycSchema, KycSchemas, KycStatusResponse, Network, PostFiatAccountRequestBody, PostFiatAccountResponse, QuoteErrorResponse, QuoteRequestBody, QuoteResponse, TransferRequestBody, TransferResponse, TransferStatusRequestParams, TransferStatusResponse, ClockResponse, FiatAccountSchema } from '@fiatconnect/fiatconnect-types';
import { Result } from '@badrap/result';

@@ -9,4 +9,4 @@ export interface FiatConnectApiClient {

isLoggedIn(): boolean;
getQuoteIn(params: QuoteRequestQuery): Promise<Result<QuoteResponse, ResponseError>>;
getQuoteOut(params: QuoteRequestQuery): Promise<Result<QuoteResponse, ResponseError>>;
createQuoteIn(params: QuoteRequestBody): Promise<Result<QuoteResponse, ResponseError>>;
createQuoteOut(params: QuoteRequestBody): Promise<Result<QuoteResponse, ResponseError>>;
addKyc<T extends KycSchema>(params: AddKycParams<T>): Promise<Result<KycStatusResponse, ResponseError>>;

@@ -13,0 +13,0 @@ deleteKyc(params: KycRequestParams): Promise<Result<void, ResponseError>>;

{
"name": "@fiatconnect/fiatconnect-sdk",
"version": "0.3.1",
"version": "0.3.2",
"description": "A helper libary for wallets to integrate with FiatConnect APIs",

@@ -52,3 +52,3 @@ "scripts": {

"@badrap/result": "^0.2.12",
"@fiatconnect/fiatconnect-types": "^5.0.0",
"@fiatconnect/fiatconnect-types": "^6.0.0",
"ethers": "^5.6.4",

@@ -55,0 +55,0 @@ "fetch-cookie": "^2.0.3",

@@ -11,3 +11,3 @@ import {

QuoteErrorResponse,
QuoteRequestQuery,
QuoteRequestBody,
QuoteResponse,

@@ -148,15 +148,12 @@ TransferResponse,

async _getQuote(
params: QuoteRequestQuery,
async _createQuote(
body: QuoteRequestBody,
inOrOut: 'in' | 'out',
): Promise<Result<QuoteResponse, ResponseError>> {
try {
const queryParams = new URLSearchParams(params).toString()
const response = await fetch(
`${this.config.baseUrl}/quote/${inOrOut}?${queryParams}`,
{
method: 'GET',
headers: this._getAuthHeader(),
},
)
const response = await fetch(`${this.config.baseUrl}/quote/${inOrOut}`, {
method: 'POST',
headers: this._getAuthHeader(),
body: JSON.stringify(body),
})
const data = await response.json()

@@ -244,21 +241,21 @@ if (!response.ok) {

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3311-get-quotein
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3411-post-quotein
*/
async getQuoteIn(
params: QuoteRequestQuery,
async createQuoteIn(
params: QuoteRequestBody,
): Promise<Result<QuoteResponse, ResponseError>> {
return this._getQuote(params, 'in')
return this._createQuote(params, 'in')
}
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3312-get-quoteout
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3412-post-quoteout
*/
async getQuoteOut(
params: QuoteRequestQuery,
async createQuoteOut(
params: QuoteRequestBody,
): Promise<Result<QuoteResponse, ResponseError>> {
return this._getQuote(params, 'out')
return this._createQuote(params, 'out')
}
/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3321-post-kyckycschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3421-post-kyckycschema
*/

@@ -292,3 +289,3 @@ async addKyc<T extends KycSchema>(

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3323-delete-kyckycschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3423-delete-kyckycschema
*/

@@ -318,3 +315,3 @@ async deleteKyc(

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3322-get-kyckycschemastatus
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3422-get-kyckycschemastatus
*/

@@ -327,3 +324,3 @@ async getKycStatus(

const response = await fetch(
`${this.config.baseUrl}/kyc/${params.kycSchema}`,
`${this.config.baseUrl}/kyc/${params.kycSchema}/status`,
{

@@ -345,3 +342,3 @@ method: 'GET',

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3331-post-accountsfiataccountschema
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3431-post-accounts
*/

@@ -372,3 +369,3 @@ async addFiatAccount<T extends FiatAccountSchema>(

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3332-get-accounts
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3432-get-accounts
*/

@@ -395,3 +392,3 @@ async getFiatAccounts(): Promise<

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3333-delete-accountfiataccountid
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3433-delete-accountsfiataccountid
*/

@@ -421,3 +418,3 @@ async deleteFiatAccount(

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3341-post-transferin
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3441-post-transferin
*/

@@ -449,3 +446,3 @@ async transferIn(

/**
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3342-post-transferout
* https://github.com/fiatconnect/specification/blob/main/fiatconnect-api.md#3442-post-transferout
*/

@@ -452,0 +449,0 @@ async transferOut(

@@ -13,3 +13,3 @@ import {

QuoteErrorResponse,
QuoteRequestQuery,
QuoteRequestBody,
QuoteResponse,

@@ -31,7 +31,7 @@ TransferRequestBody,

isLoggedIn(): boolean
getQuoteIn(
params: QuoteRequestQuery,
createQuoteIn(
params: QuoteRequestBody,
): Promise<Result<QuoteResponse, ResponseError>>
getQuoteOut(
params: QuoteRequestQuery,
createQuoteOut(
params: QuoteRequestBody,
): Promise<Result<QuoteResponse, ResponseError>>

@@ -38,0 +38,0 @@ addKyc<T extends KycSchema>(

@@ -1,2 +0,2 @@

import { FiatConnectClient, ResponseError } from '../src/index'
import { FiatConnectClient, ResponseError } from '../src'
import {

@@ -396,6 +396,10 @@ mockAddFiatAccountResponse,

fetchMock.mockResponseOnce(JSON.stringify(mockQuoteResponse))
const response = await client.getQuoteIn(mockQuoteRequestQuery)
const response = await client.createQuoteIn(mockQuoteRequestQuery)
expect(fetchMock).toHaveBeenCalledWith(
'https://fiat-connect-api.com/quote/in?fiatType=USD&cryptoType=cUSD&country=DE',
expect.objectContaining({ method: 'GET', headers: undefined }),
'https://fiat-connect-api.com/quote/in',
expect.objectContaining({
method: 'POST',
headers: undefined,
body: JSON.stringify(mockQuoteRequestQuery),
}),
)

@@ -410,3 +414,3 @@ expect(response.isOk).toBeTruthy()

})
const response = await client.getQuoteIn(mockQuoteRequestQuery)
const response = await client.createQuoteIn(mockQuoteRequestQuery)

@@ -420,3 +424,3 @@ expect(response.isOk).toBeFalsy()

fetchMock.mockRejectOnce(new Error('fake error message'))
const response = await client.getQuoteIn(mockQuoteRequestQuery)
const response = await client.createQuoteIn(mockQuoteRequestQuery)

@@ -432,6 +436,10 @@ expect(response.isOk).toBeFalsy()

fetchMock.mockResponseOnce(JSON.stringify(mockQuoteResponse))
const response = await client.getQuoteOut(mockQuoteRequestQuery)
const response = await client.createQuoteOut(mockQuoteRequestQuery)
expect(fetchMock).toHaveBeenCalledWith(
'https://fiat-connect-api.com/quote/out?fiatType=USD&cryptoType=cUSD&country=DE',
expect.objectContaining({ method: 'GET', headers: undefined }),
'https://fiat-connect-api.com/quote/out', // ?fiatType=USD&cryptoType=cUSD&country=DE
expect.objectContaining({
method: 'POST',
headers: undefined,
body: JSON.stringify(mockQuoteRequestQuery),
}),
)

@@ -446,3 +454,3 @@ expect(response.isOk).toBeTruthy()

})
const response = await client.getQuoteOut(mockQuoteRequestQuery)
const response = await client.createQuoteOut(mockQuoteRequestQuery)

@@ -456,3 +464,3 @@ expect(response.isOk).toBeFalsy()

fetchMock.mockRejectOnce(new Error('fake error message'))
const response = await client.getQuoteOut(mockQuoteRequestQuery)
const response = await client.createQuoteOut(mockQuoteRequestQuery)

@@ -587,3 +595,3 @@ expect(response.isOk).toBeFalsy()

expect(fetchMock).toHaveBeenCalledWith(
'https://fiat-connect-api.com/kyc/PersonalDataAndDocuments',
'https://fiat-connect-api.com/kyc/PersonalDataAndDocuments/status',
expect.objectContaining({ method: 'GET', headers: undefined }),

@@ -590,0 +598,0 @@ )

@@ -16,3 +16,3 @@ import {

QuoteErrorResponse,
QuoteRequestQuery,
QuoteRequestBody,
QuoteResponse,

@@ -29,3 +29,3 @@ TransferResponse,

export const mockQuoteRequestQuery: QuoteRequestQuery = {
export const mockQuoteRequestQuery: QuoteRequestBody = {
fiatType: FiatType.USD,

@@ -32,0 +32,0 @@ cryptoType: CryptoType.cUSD,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc