@dfns/sdk
Advanced tools
Comparing version 0.5.6-alpha.6 to 0.5.6-alpha.7
@@ -1,2 +0,2 @@ | ||
import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
import { DfnsApiClientOptions } from '../../types/generic'; | ||
import * as T from './types'; | ||
@@ -3,0 +3,0 @@ export declare class AuthClient { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const fetch_1 = require("../../utils/fetch"); | ||
const userActionFetch_1 = require("../../utils/userActionFetch"); | ||
const url_1 = require("../../utils/url"); | ||
@@ -16,3 +17,3 @@ class AuthClient { | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -29,3 +30,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -42,3 +43,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -55,3 +56,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -68,3 +69,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -81,3 +82,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -94,3 +95,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -107,3 +108,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -120,3 +121,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -133,3 +134,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -146,3 +147,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -191,3 +192,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -216,3 +217,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -233,3 +234,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -262,3 +263,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -299,3 +300,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -324,3 +325,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -365,3 +366,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -378,3 +379,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -391,3 +392,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -404,3 +405,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -417,3 +418,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -430,3 +431,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -589,3 +590,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -634,3 +635,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -683,3 +684,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -696,3 +697,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -709,3 +710,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -712,0 +713,0 @@ body: request.body, |
@@ -1,2 +0,2 @@ | ||
import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
import { DfnsApiClientOptions } from '../../types/generic'; | ||
import * as T from './types'; | ||
@@ -3,0 +3,0 @@ export declare class ExchangesClient { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const fetch_1 = require("../../utils/fetch"); | ||
const userActionFetch_1 = require("../../utils/userActionFetch"); | ||
const url_1 = require("../../utils/url"); | ||
@@ -16,3 +17,3 @@ class ExchangesClient { | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -29,3 +30,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -42,3 +43,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -55,3 +56,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -58,0 +59,0 @@ body: {}, |
@@ -59,4 +59,8 @@ export type CreateDepositBody = { | ||
id: string; | ||
exchangeId: string; | ||
accountId: string; | ||
externalId?: string | undefined; | ||
transferId?: string | undefined; | ||
kind: "Withdrawal" | "Deposit"; | ||
walletId: string; | ||
network: "Algorand" | "AlgorandTestnet" | "ArbitrumOne" | "ArbitrumGoerli" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseGoerli" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Cardano" | "CardanoPreprod" | "Celo" | "CeloAlfajores" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "EthereumHolesky" | "FantomOpera" | "FantomTestnet" | "InternetComputer" | "Kusama" | "Litecoin" | "LitecoinTestnet" | "Optimism" | "OptimismGoerli" | "OptimismSepolia" | "Origyn" | "Polkadot" | "Westend" | "Polygon" | "PolygonAmoy" | "PolygonMumbai" | "Solana" | "SolanaDevnet" | "Stellar" | "StellarTestnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "Ton" | "TonTestnet" | "XrpLedger" | "XrpLedgerTestnet" | "KeyECDSA" | "KeyECDSAStark" | "KeyEdDSA"; | ||
requester: { | ||
@@ -69,38 +73,31 @@ userId: string; | ||
kind: "Native"; | ||
to: string | string | string | string | string | string | string | string | string | string | string | string | string; | ||
amount: string; | ||
memo?: string | undefined; | ||
priority?: ("Slow" | "Standard" | "Fast") | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Erc20"; | ||
contract: string; | ||
to: string; | ||
amount: string; | ||
priority?: ("Slow" | "Standard" | "Fast") | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Erc721"; | ||
contract: string; | ||
to: string; | ||
tokenId: string; | ||
priority?: ("Slow" | "Standard" | "Fast") | undefined; | ||
} | { | ||
kind: "Trc10"; | ||
tokenId: string; | ||
to: string; | ||
amount: string; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Trc20"; | ||
contract: string; | ||
to: string; | ||
amount: string; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Trc721"; | ||
contract: string; | ||
to: string; | ||
tokenId: string; | ||
} | { | ||
kind: "Asa"; | ||
assetId: string; | ||
to: string; | ||
amount: string; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
@@ -110,37 +107,20 @@ kind: "Sep41"; | ||
assetCode: string; | ||
to: string; | ||
amount: string; | ||
memo?: string | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Spl" | "Spl2022"; | ||
to: string; | ||
amount: string; | ||
mint: string; | ||
createDestinationAccount?: boolean | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Tep74"; | ||
to: string; | ||
master: string; | ||
amount: string; | ||
memo?: string | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
}; | ||
metadata: { | ||
asset: { | ||
symbol?: string | undefined; | ||
decimals?: number | undefined; | ||
verified?: boolean | undefined; | ||
quotes?: { | ||
[x: string]: number; | ||
} | undefined; | ||
}; | ||
}; | ||
status: "Pending" | "Executing" | "Broadcasted" | "Confirmed" | "Failed" | "Rejected"; | ||
reason?: string | undefined; | ||
txHash?: string | undefined; | ||
fee?: string | undefined; | ||
dateRequested: string; | ||
datePolicyResolved?: string | undefined; | ||
dateBroadcasted?: string | undefined; | ||
dateConfirmed?: string | undefined; | ||
approvalId?: string | undefined; | ||
dateCreated: string; | ||
}; | ||
@@ -233,4 +213,8 @@ export type CreateDepositRequest = CreateDepositParams & { | ||
id: string; | ||
exchangeId: string; | ||
accountId: string; | ||
externalId?: string | undefined; | ||
transferId?: string | undefined; | ||
kind: "Withdrawal" | "Deposit"; | ||
walletId: string; | ||
network: "Algorand" | "AlgorandTestnet" | "ArbitrumOne" | "ArbitrumGoerli" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseGoerli" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Cardano" | "CardanoPreprod" | "Celo" | "CeloAlfajores" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "EthereumHolesky" | "FantomOpera" | "FantomTestnet" | "InternetComputer" | "Kusama" | "Litecoin" | "LitecoinTestnet" | "Optimism" | "OptimismGoerli" | "OptimismSepolia" | "Origyn" | "Polkadot" | "Westend" | "Polygon" | "PolygonAmoy" | "PolygonMumbai" | "Solana" | "SolanaDevnet" | "Stellar" | "StellarTestnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "Ton" | "TonTestnet" | "XrpLedger" | "XrpLedgerTestnet" | "KeyECDSA" | "KeyECDSAStark" | "KeyEdDSA"; | ||
requester: { | ||
@@ -243,38 +227,31 @@ userId: string; | ||
kind: "Native"; | ||
to: string | string | string | string | string | string | string | string | string | string | string | string | string; | ||
amount: string; | ||
memo?: string | undefined; | ||
priority?: ("Slow" | "Standard" | "Fast") | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Erc20"; | ||
contract: string; | ||
to: string; | ||
amount: string; | ||
priority?: ("Slow" | "Standard" | "Fast") | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Erc721"; | ||
contract: string; | ||
to: string; | ||
tokenId: string; | ||
priority?: ("Slow" | "Standard" | "Fast") | undefined; | ||
} | { | ||
kind: "Trc10"; | ||
tokenId: string; | ||
to: string; | ||
amount: string; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Trc20"; | ||
contract: string; | ||
to: string; | ||
amount: string; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Trc721"; | ||
contract: string; | ||
to: string; | ||
tokenId: string; | ||
} | { | ||
kind: "Asa"; | ||
assetId: string; | ||
to: string; | ||
amount: string; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
@@ -284,37 +261,20 @@ kind: "Sep41"; | ||
assetCode: string; | ||
to: string; | ||
amount: string; | ||
memo?: string | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Spl" | "Spl2022"; | ||
to: string; | ||
amount: string; | ||
mint: string; | ||
createDestinationAccount?: boolean | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
} | { | ||
kind: "Tep74"; | ||
to: string; | ||
master: string; | ||
amount: string; | ||
memo?: string | undefined; | ||
walletId: string; | ||
otp?: string | undefined; | ||
}; | ||
metadata: { | ||
asset: { | ||
symbol?: string | undefined; | ||
decimals?: number | undefined; | ||
verified?: boolean | undefined; | ||
quotes?: { | ||
[x: string]: number; | ||
} | undefined; | ||
}; | ||
}; | ||
status: "Pending" | "Executing" | "Broadcasted" | "Confirmed" | "Failed" | "Rejected"; | ||
reason?: string | undefined; | ||
txHash?: string | undefined; | ||
fee?: string | undefined; | ||
dateRequested: string; | ||
datePolicyResolved?: string | undefined; | ||
dateBroadcasted?: string | undefined; | ||
dateConfirmed?: string | undefined; | ||
approvalId?: string | undefined; | ||
dateCreated: string; | ||
}; | ||
@@ -321,0 +281,0 @@ export type CreateWithdrawalRequest = CreateWithdrawalParams & { |
@@ -1,2 +0,2 @@ | ||
import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
import { DfnsApiClientOptions } from '../../types/generic'; | ||
import * as T from './types'; | ||
@@ -3,0 +3,0 @@ export declare class NetworksClient { |
@@ -1,2 +0,2 @@ | ||
import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
import { DfnsApiClientOptions } from '../../types/generic'; | ||
import * as T from './types'; | ||
@@ -3,0 +3,0 @@ export declare class PermissionsClient { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const fetch_1 = require("../../utils/fetch"); | ||
const userActionFetch_1 = require("../../utils/userActionFetch"); | ||
const url_1 = require("../../utils/url"); | ||
@@ -16,3 +17,3 @@ class PermissionsClient { | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -29,3 +30,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -42,3 +43,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -55,3 +56,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -101,3 +102,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -104,0 +105,0 @@ body: request.body, |
@@ -1,2 +0,2 @@ | ||
import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
import { DfnsApiClientOptions } from '../../types/generic'; | ||
import * as T from './types'; | ||
@@ -3,0 +3,0 @@ export declare class PoliciesClient { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const fetch_1 = require("../../utils/fetch"); | ||
const userActionFetch_1 = require("../../utils/userActionFetch"); | ||
const url_1 = require("../../utils/url"); | ||
@@ -16,3 +17,3 @@ class PoliciesClient { | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -29,3 +30,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -42,3 +43,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -99,3 +100,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -102,0 +103,0 @@ body: request.body, |
@@ -1,2 +0,2 @@ | ||
import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
import { DfnsApiClientOptions } from '../../types/generic'; | ||
import * as T from './types'; | ||
@@ -3,0 +3,0 @@ export declare class SignersClient { |
@@ -1,2 +0,2 @@ | ||
import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
import { DfnsApiClientOptions } from '../../types/generic'; | ||
import * as T from './types'; | ||
@@ -3,0 +3,0 @@ export declare class WalletsClient { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const fetch_1 = require("../../utils/fetch"); | ||
const userActionFetch_1 = require("../../utils/userActionFetch"); | ||
const url_1 = require("../../utils/url"); | ||
@@ -16,3 +17,3 @@ class WalletsClient { | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -29,3 +30,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -42,3 +43,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -55,3 +56,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -68,3 +69,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -158,3 +159,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -215,3 +216,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -228,3 +229,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -241,3 +242,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -254,3 +255,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -257,0 +258,0 @@ body: request.body, |
@@ -1,2 +0,2 @@ | ||
import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
import { DfnsApiClientOptions } from '../../types/generic'; | ||
import * as T from './types'; | ||
@@ -3,0 +3,0 @@ export declare class WebhooksClient { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const fetch_1 = require("../../utils/fetch"); | ||
const userActionFetch_1 = require("../../utils/userActionFetch"); | ||
const url_1 = require("../../utils/url"); | ||
@@ -16,3 +17,3 @@ class WebhooksClient { | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -29,3 +30,3 @@ body: request.body, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'DELETE', | ||
@@ -86,3 +87,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
@@ -99,3 +100,3 @@ body: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
const response = await (0, userActionFetch_1.userActionFetch)(path, { | ||
method: 'PUT', | ||
@@ -102,0 +103,0 @@ body: request.body, |
{ | ||
"name": "@dfns/sdk", | ||
"version": "0.5.6-alpha.6", | ||
"version": "0.5.6-alpha.7", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "buffer": "6.0.3", |
@@ -1,3 +0,2 @@ | ||
import { DfnsBaseApiOptions } from '../baseAuthApi'; | ||
import { DfnsApiClientOptions } from '../dfnsApiClient'; | ||
import { DfnsBaseApiOptions } from '../types/generic'; | ||
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
@@ -11,3 +10,7 @@ export type FetchOptions<T> = { | ||
export type Fetch<T> = (resource: string | URL, options: FetchOptions<T>) => Promise<Response>; | ||
export declare const fullUrl: <T extends DfnsBaseApiOptions>(fetch: Fetch<T>) => Fetch<T>; | ||
export declare const jsonSerializer: <T>(fetch: Fetch<T>) => Fetch<T>; | ||
export declare const errorHandler: <T>(fetch: Fetch<T>) => Fetch<T>; | ||
export declare const catchPolicyPending: <T>(fetch: Fetch<T>) => Fetch<T>; | ||
export declare const dfnsAuth: <T extends DfnsBaseApiOptions>(fetch: Fetch<T>) => Fetch<T>; | ||
export declare const simpleFetch: Fetch<DfnsBaseApiOptions>; | ||
export declare const userActionFetch: Fetch<DfnsApiClientOptions>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.userActionFetch = exports.simpleFetch = void 0; | ||
exports.simpleFetch = exports.dfnsAuth = exports.catchPolicyPending = exports.errorHandler = exports.jsonSerializer = exports.fullUrl = void 0; | ||
const cross_fetch_1 = require("cross-fetch"); | ||
const nonce_1 = require("./nonce"); | ||
const dfnsError_1 = require("../dfnsError"); | ||
const baseAuthApi_1 = require("../baseAuthApi"); | ||
const nonce_1 = require("./nonce"); | ||
const DEFAULT_DFNS_BASE_URL = 'https://api.dfns.io'; | ||
@@ -16,2 +15,3 @@ const fullUrl = (fetch) => { | ||
}; | ||
exports.fullUrl = fullUrl; | ||
const jsonSerializer = (fetch) => { | ||
@@ -29,2 +29,3 @@ return async (resource, options) => { | ||
}; | ||
exports.jsonSerializer = jsonSerializer; | ||
const errorHandler = (fetch) => { | ||
@@ -47,2 +48,3 @@ return async (resource, options) => { | ||
}; | ||
exports.errorHandler = errorHandler; | ||
// raise a 202 response by policy execution as error | ||
@@ -60,2 +62,3 @@ const catchPolicyPending = (fetch) => { | ||
}; | ||
exports.catchPolicyPending = catchPolicyPending; | ||
const dfnsAuth = (fetch) => { | ||
@@ -84,36 +87,3 @@ return async (resource, options) => { | ||
}; | ||
const userAction = (fetch) => { | ||
return async (resource, options) => { | ||
if (options.method !== 'GET') { | ||
const apiOptions = { | ||
...options.apiOptions, | ||
baseUrl: options.apiOptions.baseAuthUrl || options.apiOptions.baseUrl, | ||
}; | ||
if (!apiOptions.signer) { | ||
throw new dfnsError_1.DfnsError(-1, 'A "signer" needs to be passed to Dfns client.', { | ||
detail: `Most non-readonly endpoints require "User Action Signing" flow.` + | ||
` During that flow, the credential "signer" that you passed will handle signing` + | ||
` the user action challenge, using your credential.`, | ||
}); | ||
} | ||
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({ | ||
userActionPayload: options.body ?? '', | ||
userActionHttpMethod: options.method, | ||
userActionHttpPath: resource.pathname, | ||
userActionServerKind: apiOptions?.userActionServerKind || 'Api', | ||
}, apiOptions); | ||
const assertion = await apiOptions.signer.sign(challenge); | ||
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge({ | ||
challengeIdentifier: challenge.challengeIdentifier, | ||
firstFactor: assertion, | ||
}, apiOptions); | ||
options.headers = { | ||
'x-dfns-useraction': userAction, | ||
...(options.headers ?? {}), | ||
}; | ||
} | ||
return fetch(resource, options); | ||
}; | ||
}; | ||
exports.simpleFetch = fullUrl(jsonSerializer(dfnsAuth(catchPolicyPending(errorHandler(cross_fetch_1.fetch))))); | ||
exports.userActionFetch = fullUrl(jsonSerializer(dfnsAuth(userAction(catchPolicyPending(errorHandler(cross_fetch_1.fetch)))))); | ||
exports.dfnsAuth = dfnsAuth; | ||
exports.simpleFetch = (0, exports.fullUrl)((0, exports.jsonSerializer)((0, exports.dfnsAuth)((0, exports.catchPolicyPending)((0, exports.errorHandler)(cross_fetch_1.fetch))))); |
117
570618
14509