@dfns/sdk
Advanced tools
Comparing version 0.1.0-beta.7 to 0.1.0-beta.8
@@ -98,2 +98,6 @@ import { FirstFactorAttestation, RecoveryFactorAttestation, SecondFactorAttestation, UserRegistrationChallenge } from './store'; | ||
/** | ||
* Completes user logout by sending the user auth token. | ||
*/ | ||
static userLogout(options: DfnsBaseApiOptions): Promise<void>; | ||
/** | ||
* Initiates Registration by creating a challenge that will need to be signed by a new set of Credentials. | ||
@@ -100,0 +104,0 @@ */ |
@@ -51,2 +51,15 @@ "use strict"; | ||
/** | ||
* Completes user logout by sending the user auth token. | ||
*/ | ||
static async userLogout(options) { | ||
if (!options.authToken) { | ||
throw new Error('authToken is required'); | ||
} | ||
const response = await (0, fetch_1.simpleFetch)('/auth/logout', { | ||
method: 'PUT', | ||
apiOptions: options, | ||
}); | ||
return response.json(); | ||
} | ||
/** | ||
* Initiates Registration by creating a challenge that will need to be signed by a new set of Credentials. | ||
@@ -53,0 +66,0 @@ */ |
@@ -8,1 +8,21 @@ import { BadRequestError, ForbiddenError, UnauthorizedError } from '../Foundations'; | ||
export type ListSignersResponse = ListSignersSuccess | ListSignersError; | ||
export type GetLatestClusterHealthSuccess = String; | ||
export type GetLatestClusterHealthError = { | ||
error: ForbiddenError; | ||
}; | ||
export type GetLatestClusterHealthResponse = GetLatestClusterHealthSuccess | GetLatestClusterHealthError; | ||
export type ListClustersHealthSuccess = String; | ||
export type ListClustersHealthError = { | ||
error: ForbiddenError; | ||
}; | ||
export type ListClustersHealthResponse = ListClustersHealthSuccess | ListClustersHealthError; | ||
export type SetKeyMaxPresigsSuccess = String; | ||
export type SetKeyMaxPresigsError = { | ||
error: ForbiddenError; | ||
}; | ||
export type SetKeyMaxPresigsResponse = SetKeyMaxPresigsSuccess | SetKeyMaxPresigsError; | ||
export type TriggerClusterProvisioningSuccess = String; | ||
export type TriggerClusterProvisioningError = { | ||
error: ForbiddenError; | ||
}; | ||
export type TriggerClusterProvisioningResponse = TriggerClusterProvisioningSuccess | TriggerClusterProvisioningError; |
import { BadRequestError, EntityNotFoundError, ForbiddenError, UnauthorizedError } from '../Foundations'; | ||
import { PaginatedEventHistory, PaginatedSignatureList, PaginatedTransactionList, PaginatedTransferList, PaginatedWalletList, SignatureRequest, TransactionRequest, TransferRequest, Wallet, WalletAssets, WalletNfts } from './types'; | ||
import { ExportedSigningKey, PaginatedEventHistory, PaginatedSignatureList, PaginatedTransactionList, PaginatedTransferList, PaginatedWalletList, SignatureRequest, TransactionRequest, TransferRequest, Wallet, WalletAssets, WalletNfts } from './types'; | ||
export type CreateWalletSuccess = Wallet; | ||
@@ -83,1 +83,6 @@ export type CreateWalletError = { | ||
export type ImportWalletResponse = ImportWalletSuccess | ImportWalletError; | ||
export type ExportWalletSuccess = ExportedSigningKey; | ||
export type ExportWalletError = { | ||
error: BadRequestError | ForbiddenError | UnauthorizedError | ForbiddenError | BadRequestError | EntityNotFoundError; | ||
}; | ||
export type ExportWalletResponse = ExportWalletSuccess | ExportWalletError; |
@@ -19,2 +19,6 @@ import { Amount, BlockchainAddress, EntityId, IntegerPositiveStrict, IsoDatetime, Tag } from '../Foundations'; | ||
}; | ||
export type BroadcastTransaction = { | ||
kind: TransactionKind.Transaction; | ||
transaction: string; | ||
}; | ||
export type BroadcastEvmTransaction = { | ||
@@ -46,2 +50,6 @@ kind: TransactionKind.Evm; | ||
}; | ||
export type BroadcastPsbt = { | ||
kind: TransactionKind.Psbt; | ||
psbt: string; | ||
}; | ||
export type SignHash = { | ||
@@ -55,2 +63,6 @@ kind: SignatureKind.Hash; | ||
}; | ||
export type SignTransaction = { | ||
kind: SignatureKind.Transaction; | ||
transaction: string; | ||
}; | ||
export type Eip712Domain = { | ||
@@ -69,6 +81,26 @@ name?: string; | ||
}; | ||
export type SignPsbt = { | ||
kind: SignatureKind.Psbt; | ||
psbt: string; | ||
}; | ||
export type EncryptedKeyShare = { | ||
/** | ||
* Base64-encoded ID of the signer where the encrypted key share comes from. | ||
*/ | ||
signerId: string; | ||
/** | ||
* Base64-encoded key share. | ||
*/ | ||
encryptedKeyShare: string; | ||
}; | ||
export type SupportedExportScheme = { | ||
/** | ||
* Base64-encoded ID of the signer where the encrypted key share comes from. | ||
*/ | ||
curve: KeyCurve; | ||
/** | ||
* Base64-encoded key share. | ||
*/ | ||
protocol: KeyProtocol; | ||
}; | ||
export type Wallet = { | ||
@@ -85,5 +117,13 @@ id: EntityId; | ||
/** | ||
* If present, represents the moment when the wallet was exported for the first time. | ||
*/ | ||
dateExported?: IsoDatetime; | ||
/** | ||
* Whether the wallet was imported, or if it was generated on Dfns side. | ||
*/ | ||
imported?: boolean; | ||
/** | ||
* Whether the wallet was ever exported. | ||
*/ | ||
exported?: boolean; | ||
}; | ||
@@ -195,2 +235,3 @@ export type SigningKey = { | ||
reason?: string; | ||
metadata: TransferRequestMetadata; | ||
}; | ||
@@ -235,2 +276,4 @@ export type PaginatedTransferList = { | ||
signature?: Signature; | ||
signatures?: Signature[]; | ||
signedData?: string; | ||
status: SignatureStatus; | ||
@@ -255,2 +298,23 @@ txHash?: string; | ||
}; | ||
export type TransferRequestMetadata = { | ||
asset: AssetMetadata; | ||
}; | ||
export type AssetMetadata = { | ||
symbol?: string; | ||
decimals?: number; | ||
verified?: boolean; | ||
}; | ||
export type ExportedSigningKey = { | ||
publicKey: string; | ||
/** | ||
* The TSS threshold parameter of this wallet private signing key shares. | ||
*/ | ||
minSigners: IntegerPositiveStrict; | ||
curve: KeyCurve; | ||
protocol: KeyProtocol; | ||
/** | ||
* Key shares of the exported wallet. These key shares are encrypted with the provided encryption key. The wallet private key must then be re-constructed from them. | ||
*/ | ||
encryptedKeyShares: EncryptedKeyShare[]; | ||
}; | ||
export type CreateWalletBody = { | ||
@@ -272,5 +336,15 @@ network: BlockchainNetwork; | ||
}; | ||
export type ExportWalletBody = { | ||
/** | ||
* Encryption public key that will be used by signers to encrypt the exported wallet key shares. The purpose of encrypting key shares is to have them extra-safe and not usable in any place in the system until they are safely returned back to the client issuing the export command. | ||
*/ | ||
encryptionKey: string; | ||
/** | ||
* The schemes supported by the client issuing the export request, for private key reconstruction. | ||
*/ | ||
supportedSchemes: SupportedExportScheme[]; | ||
}; | ||
export type TransferAssetBody = TransferNativeAsset | TransferErc20Asset | TransferErc721Asset; | ||
export type BroadcastTransactionBody = BroadcastEvmTransaction | BroadcastEip1559Transaction | BroadcastEvmLegacyTransaction; | ||
export type GenerateSignatureBody = SignHash | SignMessage | SignEip712TypedData; | ||
export type BroadcastTransactionBody = BroadcastTransaction | BroadcastEvmTransaction | BroadcastEip1559Transaction | BroadcastEvmLegacyTransaction | BroadcastPsbt; | ||
export type GenerateSignatureBody = SignHash | SignMessage | SignTransaction | SignEip712TypedData | SignPsbt; | ||
export type BlockchainEvent = NativeTransferEvent | Erc20TransferEvent | Erc721TransferEvent; | ||
@@ -283,5 +357,7 @@ export declare enum TransferKind { | ||
export declare enum TransactionKind { | ||
Transaction = "Transaction", | ||
Evm = "Evm", | ||
Eip1559 = "Eip1559", | ||
EvmLegacy = "EvmLegacy" | ||
EvmLegacy = "EvmLegacy", | ||
Psbt = "Psbt" | ||
} | ||
@@ -291,3 +367,5 @@ export declare enum SignatureKind { | ||
Message = "Message", | ||
Eip712 = "Eip712" | ||
Transaction = "Transaction", | ||
Eip712 = "Eip712", | ||
Psbt = "Psbt" | ||
} | ||
@@ -297,3 +375,4 @@ export declare enum WalletStatus { | ||
Creating = "Creating", | ||
Failed = "Failed" | ||
Failed = "Failed", | ||
Archived = "Archived" | ||
} | ||
@@ -351,3 +430,3 @@ export declare enum KeyScheme { | ||
Bitcoin = "Bitcoin", | ||
BitcoinTestnet = "BitcoinTestnet", | ||
BitcoinTestnet3 = "BitcoinTestnet3", | ||
Bsc = "Bsc", | ||
@@ -354,0 +433,0 @@ BscTestnet = "BscTestnet", |
@@ -17,2 +17,4 @@ "use strict"; | ||
(function (TransactionKind) { | ||
// FIXME: Missing documentation for Transaction | ||
TransactionKind["Transaction"] = "Transaction"; | ||
// FIXME: Missing documentation for Evm | ||
@@ -24,2 +26,4 @@ TransactionKind["Evm"] = "Evm"; | ||
TransactionKind["EvmLegacy"] = "EvmLegacy"; | ||
// FIXME: Missing documentation for Psbt | ||
TransactionKind["Psbt"] = "Psbt"; | ||
})(TransactionKind = exports.TransactionKind || (exports.TransactionKind = {})); | ||
@@ -33,4 +37,8 @@ // FIXME: Missing documentation for SignatureKind | ||
SignatureKind["Message"] = "Message"; | ||
// FIXME: Missing documentation for Transaction | ||
SignatureKind["Transaction"] = "Transaction"; | ||
// FIXME: Missing documentation for Eip712 | ||
SignatureKind["Eip712"] = "Eip712"; | ||
// FIXME: Missing documentation for Psbt | ||
SignatureKind["Psbt"] = "Psbt"; | ||
})(SignatureKind = exports.SignatureKind || (exports.SignatureKind = {})); | ||
@@ -46,2 +54,4 @@ // FIXME: Missing documentation for WalletStatus | ||
WalletStatus["Failed"] = "Failed"; | ||
// FIXME: Missing documentation for Archived | ||
WalletStatus["Archived"] = "Archived"; | ||
})(WalletStatus = exports.WalletStatus || (exports.WalletStatus = {})); | ||
@@ -151,4 +161,4 @@ // FIXME: Missing documentation for KeyScheme | ||
BlockchainNetwork["Bitcoin"] = "Bitcoin"; | ||
// FIXME: Missing documentation for BitcoinTestnet | ||
BlockchainNetwork["BitcoinTestnet"] = "BitcoinTestnet"; | ||
// FIXME: Missing documentation for BitcoinTestnet3 | ||
BlockchainNetwork["BitcoinTestnet3"] = "BitcoinTestnet3"; | ||
// FIXME: Missing documentation for Bsc | ||
@@ -155,0 +165,0 @@ BlockchainNetwork["Bsc"] = "Bsc"; |
@@ -28,2 +28,4 @@ import { SignUserActionChallengeRequest, UserActionChallengeResponse } from '../../baseAuthApi'; | ||
importWalletComplete(request: T.ImportWalletRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.ImportWalletResponse>; | ||
exportWalletInit(request: T.ExportWalletRequest): Promise<UserActionChallengeResponse>; | ||
exportWalletComplete(request: T.ExportWalletRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.ExportWalletResponse>; | ||
} |
@@ -275,3 +275,30 @@ "use strict"; | ||
} | ||
async exportWalletInit(request) { | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/export', { | ||
path: { walletId: request.walletId }, | ||
query: {}, | ||
}); | ||
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({ | ||
userActionHttpMethod: 'POST', | ||
userActionHttpPath: path, | ||
userActionPayload: JSON.stringify(request.body), | ||
userActionServerKind: 'Api', | ||
}, this.apiOptions); | ||
return challenge; | ||
} | ||
async exportWalletComplete(request, signedChallenge) { | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/export', { | ||
path: { walletId: request.walletId }, | ||
query: {}, | ||
}); | ||
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions); | ||
const response = await (0, fetch_1.simpleFetch)(path, { | ||
method: 'POST', | ||
body: request.body, | ||
headers: { 'x-dfns-useraction': userAction }, | ||
apiOptions: this.apiOptions, | ||
}); | ||
return response.json(); | ||
} | ||
} | ||
exports.DelegatedWalletsClient = DelegatedWalletsClient; |
@@ -92,1 +92,6 @@ import * as Foundations from '../datamodel/Foundations'; | ||
export type ImportWalletResponse = Wallets.Wallet; | ||
export type ExportWalletRequest = { | ||
walletId: Foundations.EntityId; | ||
body: Wallets.ExportWalletBody; | ||
}; | ||
export type ExportWalletResponse = Wallets.ExportedSigningKey; |
@@ -22,2 +22,3 @@ import { DfnsApiClientOptions } from '../../dfnsApiClient'; | ||
importWallet(request: T.ImportWalletRequest): Promise<T.ImportWalletResponse>; | ||
exportWallet(request: T.ExportWalletRequest): Promise<T.ExportWalletResponse>; | ||
} |
@@ -199,3 +199,15 @@ "use strict"; | ||
} | ||
async exportWallet(request) { | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/export', { | ||
path: { walletId: request.walletId }, | ||
query: {}, | ||
}); | ||
const response = await (0, fetch_1.userActionFetch)(path, { | ||
method: 'POST', | ||
body: request.body, | ||
apiOptions: this.apiOptions, | ||
}); | ||
return response.json(); | ||
} | ||
} | ||
exports.WalletsClient = WalletsClient; |
{ | ||
"name": "@dfns/sdk", | ||
"version": "0.1.0-beta.7", | ||
"dependencies": { | ||
"buffer": "6.0.3", | ||
"cross-fetch": "3.1.6", | ||
"uuid": "9.0.0" | ||
}, | ||
"version": "0.1.0-beta.8", | ||
"main": "./index.js", | ||
"types": "./index.d.ts" | ||
"type": "commonjs" | ||
} |
2253985
0
78024
- Removedbuffer@6.0.3
- Removedcross-fetch@3.1.6
- Removeduuid@9.0.0
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedcross-fetch@3.1.6(transitive)
- Removedieee754@1.2.1(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removeduuid@9.0.0(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)