mirror of
https://github.com/valitydev/wallet-utils.git
synced 2024-11-06 08:55:19 +00:00
FE-600: Wallet utils API definition. (#2)
This commit is contained in:
parent
de2f99ae56
commit
c228bb131e
96
README.md
96
README.md
@ -1 +1,95 @@
|
||||
# wallet-utils
|
||||
# wallet-utils
|
||||
|
||||
## API
|
||||
### Type definition
|
||||
```typescript
|
||||
declare class RbkmoneyWalletUtils {
|
||||
|
||||
constructor(token: string);
|
||||
|
||||
startIdentityChallenge(params: StartIdentityChallengeParams): void;
|
||||
|
||||
createOutput(params: CreateOutputParams): void;
|
||||
|
||||
abort(): void;
|
||||
|
||||
onCompleteIdentityChallenge(event: IdentityChallengeEvent) => void;
|
||||
|
||||
onFailIdentityChallenge(event: IdentityChallengeEvent) => void;
|
||||
|
||||
onCancelIdentityChallenge(event: IdentityChallengeEvent) => void;
|
||||
|
||||
onCreateOutput(event: CreateOutputEvent) => void;
|
||||
|
||||
onCancel(event: CancelEvent) => void;
|
||||
}
|
||||
|
||||
declare interface StartIdentityChallengeParams {
|
||||
identityID: string;
|
||||
level?: IdentityLevel;
|
||||
}
|
||||
|
||||
declare enum IdentityLevel {
|
||||
partial = 'partial'
|
||||
}
|
||||
|
||||
declare interface CreateOutputParams {
|
||||
identityID: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
declare interface WalletUtilsEvent {
|
||||
target: RbkmoneyWalletUtils;
|
||||
}
|
||||
|
||||
declare interface IdentityChallengeEvent extends WalletUtilsEvent {
|
||||
identityChallenge: IdentityChallenge;
|
||||
}
|
||||
|
||||
declare interface CreateOutputEvent extends WalletUtilsEvent {
|
||||
output: Output;
|
||||
}
|
||||
|
||||
declare interface CancelEvent extends WalletUtilsEvent {
|
||||
type: CancelEventType;
|
||||
}
|
||||
|
||||
declare enum CancelEventType {
|
||||
uiDismissing: 'uiDismissing',
|
||||
error: 'error'
|
||||
}
|
||||
|
||||
declare interface ErrorCancelEvent extends CancelEvent {
|
||||
error: LogicError;
|
||||
}
|
||||
|
||||
declare interface LogicError {
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
declare type IdentityChallenge = any; // see swagger definition
|
||||
|
||||
declare type Output = any; // see swagger definition
|
||||
```
|
||||
|
||||
### Usage
|
||||
```javascript
|
||||
const walletUtils = new RbkmoneyWalletUtils('<jwt token>');
|
||||
|
||||
walletUtils.startIdentityChallenge({
|
||||
identityID: '<string>'
|
||||
});
|
||||
|
||||
walletUtils.onCompleteIdentityChallenge = (event) => {
|
||||
// handle user complete identity challenge
|
||||
};
|
||||
|
||||
walletUtils.onFailIdentityChallenge = (event) => {
|
||||
// handle user failed identity challenge
|
||||
};
|
||||
|
||||
walletUtils.onCancel = (event) => {
|
||||
// handle UI dismissing
|
||||
};
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user