Skip to content
This repository was archived by the owner on Jan 7, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions web_hosting_manager/app/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Downloader from './Downloader';
import { I18n } from 'react-redux-i18n';
import safeApp from 'safe-app';
import pkg from '../package.json';
import { hashString, strToPtrBuf, parseUrl } from './utils';
import { parseUrl } from './utils';

const SERVICE = 'WEB_HOST_MANAGER';
const ACCOUNT = 'SAFE_USER';
Expand Down Expand Up @@ -43,7 +43,7 @@ export const accessContainers = {
publicNames: '_publicNames'
};

export const typetag = 1500;
export const typetag = 15001;

let publicIds = {};
let uploader;
Expand Down Expand Up @@ -159,10 +159,10 @@ export const createPublicId = (publicId) => {
const err = new Error(I18n.t('messages.cannotBeEmpty', { name: 'Public Id' }));
return Promise.reject(err);
}
let hashedPubId = hashString(publicId);
let publicIdName = null;

return safe.mutableData.newPublic(hashedPubId, typetag)
return safe.crypto.sha3Hash(publicId)
.then((hashVal) => safe.mutableData.newPublic(hashVal, typetag))
.then((mdata) => {
let permissionSet = null;
let permissions = null;
Expand Down Expand Up @@ -213,7 +213,8 @@ export const createService = (publicId, service, container) => {
};

export const deleteService = (publicId, service) => {
return safe.mutableData.newPublic(hashString(publicId), typetag)
return safe.crypto.sha3Hash(publicId)
.then((hashVal) => safe.mutableData.newPublic(hashVal, typetag))
.then((mdata) => mdata.getEntries()
.then((entries) => entries.get(service)
.then((val) => entries.mutate()
Expand Down
4 changes: 0 additions & 4 deletions web_hosting_manager/app/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ export const generateUploadTaskQueue = (localPath, networkPath, callback) => {
return taskQueue;
};

export const hashString = (str) => (
crypto.createHash('sha256').update(str).digest()
);

export const strToPtrBuf = (str) => {
const buf = new Buffer(str);
return { ptr: buf, len: buf.length };
Expand Down