reduct-js
Version:
ReductStore Client SDK for Javascript/NodeJS/Typescript
87 lines (86 loc) • 2.04 kB
JavaScript
/**
* Token Permissions with server-side names
*/
export class OriginalTokenPermission {
constructor() {
this.full_access = false;
this.read = [];
this.write = [];
}
}
/**
* Token Permissions
*/
export class TokenPermissions {
constructor() {
/**
* Full access
* The token allows to create, remove and update settings of buckets, manage tokens and read and write data.
*/
this.fullAccess = false;
/**
* Read access
* List of buckets allowed to read
*/
this.read = [];
/**
* Write access
* List of buckets allowed to write
*/
this.write = [];
}
static parse(data) {
return {
fullAccess: data.full_access,
read: data.read,
write: data.write,
};
}
static serialize(data) {
return {
full_access: data.fullAccess,
read: data.read,
write: data.write,
};
}
}
/**
* Token Info with server-side names
*/
export class OriginalTokenInfo {
constructor() {
this.name = "";
this.created_at = "";
this.is_provisioned = false;
this.permissions = undefined;
}
}
/**
* Information about an access token
*/
export class Token {
constructor() {
/**
* Name of the token
*/
this.name = "";
/**
* Creation time of the token as unix timestamp in milliseconds
*/
this.createdAt = 0;
/**
* Is the token provisioned, and you can't remove it or change it
*/
this.isProvisioned = false;
}
static parse(data) {
return {
name: data.name,
createdAt: Date.parse(data.created_at),
isProvisioned: data.is_provisioned ?? false,
permissions: data.permissions
? TokenPermissions.parse(data.permissions)
: undefined,
};
}
}