aid-js-sdk
v0.1.16
Published
client SDK for aid wallet
Downloads
25
Readme
aidjs
the user client SDK for aid system
installation
yarn add aid-js-sdk
Core Components
AidType
An enumeration defining the types of assistance:
enum AidType {
P2p = "p2p",
Server = "server",
Blockchain = "blockchain",
Full = "full"
}
Interfaces
ContractInfo
- ContractAddress: string
- BlockChainUrl: string
ServerInfo
- ServerAddress: string
AidCert (extends ContractInfo and ServerInfo)
- Aid: string (UUID)
- CertType: AidType
- Claims: Record<string, any>
- Setting: Record<string, any>
- VerifyOptions: Record<string, any>
Classes
Aid
Represents a complete assistance instance.
Properties:
- aid: string
- certs: Map<string, AidCert>
- privateMsg: Map<string, string>
- data: Map<string, string>
Methods:
- constructor(aid: string, certs: Map<string, AidCert>, privateMsg: Map<string, string>, data: Map<string, string>)
- static fromStr(str: string): Aid
- toStr(): string
- addCert(cert: AidCert, privateMsg: string)
- removeCert(timestamp: string)
- listCerts(): { timestamp: string, cert: AidCert, privateMsg: string }[]
- getData(key: string): string
- setData(key: string, value: string)
AidPreview
Provides a preview of an Aid instance.
Properties:
- aid: string
- descriptions: Map<string, string>
Methods:
- constructor(aid: string, descriptions: Map<string, string>)
- static fromStr(str: string): AidPreview
- toStr(): string
AidList
Manages a collection of AidPreviews and default user information.
Properties:
- defaultUserInfos: Map<string, string>
- aids: AidPreview[]
Methods:
- Constructor(defaultUserInfosZip: string, aidsZip: string)
- newAidList() : AidList
- export(): { defaultUserInfosZip: string, aidsZip: string }
- addAid(aid: AidPreview)
- removeAid(aid: string)
- listAids(): AidPreview[]
- findAid(aid: string): AidPreview
Notes and Considerations
The system uses string timestamps as keys for certificates and their associated private messages within an Aid instance.
The
AidCert
interface combines blockchain and server information, suggesting it can be used in various contexts.The
Aid
class allows for storing and retrieving arbitrary string data through itsdata
property.The system provides serialization and deserialization methods (
toStr
andfromStr
) for Aid and AidPreview instances, facilitating data persistence and transfer.The AidList class uses compressed JSON strings for initialization, which may be useful for efficient data transfer or storage.
Error handling is not explicitly implemented in the provided code. Consider adding appropriate error checks and exception handling in a production environment.
The system doesn't include any authentication or authorization mechanisms. Implement these as needed for your specific use case.
Be cautious when using
Record<string, any>
for Claims, Setting, and VerifyOptions in AidCert. Consider using more specific types if the structure of these objects is known.