Skip to content

Commit

Permalink
Fix sticker creator uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-signal committed Mar 25, 2021
1 parent de5943a commit 67892d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions sticker-creator/app/stages/UploadStage.tsx
Expand Up @@ -42,6 +42,7 @@ export const UploadStage: React.ComponentType = () => {
actions.setPackMeta(packMeta);
history.push('/share');
} catch (e) {
window.log.error('Error uploading image:', e);
actions.addToast({
key: 'StickerCreator--Toasts--errorUploading',
subs: [e.message],
Expand Down
18 changes: 18 additions & 0 deletions sticker-creator/preload.js
Expand Up @@ -9,6 +9,7 @@ const { readFile } = require('fs');
const config = require('url').parse(window.location.toString(), true).query;
const { noop, uniqBy } = require('lodash');
const pMap = require('p-map');
const client = require('libsignal-client');
const { deriveStickerPackKey } = require('../ts/Crypto');
const {
getEnvironment,
Expand All @@ -28,6 +29,8 @@ const MAX_ANIMATED_STICKER_BYTE_LENGTH = 300 * 1024;

setEnvironment(parseEnvironment(config.environment));

window.sqlInitializer = require('../ts/sql/initialize');

window.ROOT_PATH = window.location.href.startsWith('file') ? '../../' : '/';
window.PROTO_ROOT = '../../protos';
window.getEnvironment = getEnvironment;
Expand All @@ -49,6 +52,20 @@ const Signal = require('../js/modules/signal');
window.Signal = Signal.setup({});
window.textsecure = require('../ts/textsecure').default;

window.libsignal = window.libsignal || {};
window.libsignal.HKDF = {};
window.libsignal.HKDF.deriveSecrets = (input, salt, info) => {
const hkdf = client.HKDF.new(3);
const output = hkdf.deriveSecrets(
3 * 32,
Buffer.from(input),
Buffer.from(info),
Buffer.from(salt)
);
return [output.slice(0, 32), output.slice(32, 64), output.slice(64, 96)];
};
window.synchronousCrypto = require('../ts/util/synchronousCrypto');

const { initialize: initializeWebAPI } = require('../ts/textsecure/WebAPI');
const {
getAnimatedPngDataIfExists,
Expand Down Expand Up @@ -163,6 +180,7 @@ window.encryptAndUpload = async (
cover,
onProgress = noop
) => {
window.sqlInitializer.goBackToMainProcess();
const usernameItem = await window.Signal.Data.getItemById('uuid_id');
const oldUsernameItem = await window.Signal.Data.getItemById('number_id');
const passwordItem = await window.Signal.Data.getItemById('password');
Expand Down

0 comments on commit 67892d8

Please sign in to comment.