98fed4bc30
Add getSalt to projects api. Add action, GET_SALT, on Store Projects module to make the api request and return the salt string everywhere in the web app that generates an access grant. The Wasm code which is used to create the access grant has been changed to decode the salt as a base64 encoded string. The names of the function calls in the changed Wasm code have also been changed to ensure that access grant creation fails if JS access grant worker code and Wasm code are not the same version. https://github.com/storj/storj-private/issues/64 Change-Id: Ia2bc4cbadad84b066ca1882b042a3f0bb13c783a
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
import {
|
|
Project,
|
|
ProjectFields,
|
|
ProjectLimits,
|
|
ProjectsApi,
|
|
ProjectsCursor,
|
|
ProjectsPage,
|
|
ProjectsStorageBandwidthDaily,
|
|
} from '@/types/projects';
|
|
|
|
/**
|
|
* Mock for ProjectsApi
|
|
*/
|
|
export class ProjectsApiMock implements ProjectsApi {
|
|
private mockProjects: Project[] = [];
|
|
private mockLimits: ProjectLimits;
|
|
private mockProjectsPage: ProjectsPage;
|
|
|
|
public setMockProjects(mockProjects: Project[]): void {
|
|
this.mockProjects = mockProjects;
|
|
}
|
|
|
|
public setMockLimits(mockLimits: ProjectLimits): void {
|
|
this.mockLimits = mockLimits;
|
|
}
|
|
|
|
create(_createProjectFields: ProjectFields): Promise<Project> {
|
|
throw new Error('not implemented');
|
|
}
|
|
|
|
delete(_projectId: string): Promise<void> {
|
|
throw new Error('not implemented');
|
|
}
|
|
|
|
get(): Promise<Project[]> {
|
|
return Promise.resolve(this.mockProjects);
|
|
}
|
|
|
|
getOwnedProjects(_cursor: ProjectsCursor): Promise<ProjectsPage> {
|
|
return Promise.resolve(this.mockProjectsPage);
|
|
}
|
|
|
|
update(_projectId: string, _projectFields: ProjectFields, _projectLimits: ProjectLimits): Promise<void> {
|
|
return Promise.resolve();
|
|
}
|
|
|
|
getLimits(_projectId: string): Promise<ProjectLimits> {
|
|
return Promise.resolve(this.mockLimits);
|
|
}
|
|
|
|
getTotalLimits(): Promise<ProjectLimits> {
|
|
return Promise.resolve(this.mockLimits);
|
|
}
|
|
|
|
getSalt(): Promise<string> {
|
|
throw new Error('not implemented');
|
|
}
|
|
|
|
getDailyUsage(_projectId: string, _start: Date, _end: Date): Promise<ProjectsStorageBandwidthDaily> {
|
|
throw new Error('not implemented');
|
|
}
|
|
}
|