fixed some old TODOs

This commit is contained in:
Danny Coates 2018-12-18 13:55:46 -08:00
parent ac87fdff97
commit 6cc12528b3
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
9 changed files with 15 additions and 8 deletions

View File

@ -58,7 +58,6 @@ export default function(state, emitter) {
emitter.on('changeLimit', async ({ file, value }) => { emitter.on('changeLimit', async ({ file, value }) => {
const ok = await file.changeLimit(value, state.user); const ok = await file.changeLimit(value, state.user);
if (!ok) { if (!ok) {
// TODO
return; return;
} }
state.storage.writeFile(file); state.storage.writeFile(file);

View File

@ -1,3 +1,4 @@
/* global AUTH_CONFIG */
import { arrayToB64, b64ToArray } from './utils'; import { arrayToB64, b64ToArray } from './utils';
const encoder = new TextEncoder(); const encoder = new TextEncoder();
@ -175,6 +176,6 @@ export async function deriveFileListKey(ikm) {
export async function getFileListKey(storage, bundle) { export async function getFileListKey(storage, bundle) {
const jwks = await decryptBundle(storage, bundle); const jwks = await decryptBundle(storage, bundle);
const jwk = jwks['https://identity.mozilla.com/apps/send']; const jwk = jwks[AUTH_CONFIG.key_scope];
return deriveFileListKey(jwk.k); return deriveFileListKey(jwk.k);
} }

View File

@ -27,7 +27,6 @@ export default function initialize(state, emitter) {
cm6: storage.files.length, cm6: storage.files.length,
cm7: storage.totalDownloads cm7: storage.totalDownloads
}); });
//TODO restart handlers... somewhere
}); });
emitter.on('exit', exitEvent); emitter.on('exit', exitEvent);
emitter.on('experiment', experimentEvent); emitter.on('experiment', experimentEvent);

View File

@ -112,7 +112,7 @@ self.onfetch = event => {
const req = event.request; const req = event.request;
if (req.method !== 'GET') return; if (req.method !== 'GET') return;
const url = new URL(req.url); const url = new URL(req.url);
const dlmatch = DOWNLOAD_URL.exec(url.pathname); // TODO use #hashkey const dlmatch = DOWNLOAD_URL.exec(url.pathname);
if (dlmatch) { if (dlmatch) {
event.respondWith(decryptStream(dlmatch[1])); event.respondWith(decryptStream(dlmatch[1]));
} else if (VERSIONED_ASSET.test(url.pathname)) { } else if (VERSIONED_ASSET.test(url.pathname)) {

View File

@ -73,7 +73,7 @@ export default class User {
code_challenge, code_challenge,
code_challenge_method: 'S256', code_challenge_method: 'S256',
response_type: 'code', response_type: 'code',
scope: 'profile https://identity.mozilla.com/apps/send', //TODO param scope: `profile ${AUTH_CONFIG.key_scope}`,
state, state,
keys_jwk keys_jwk
}; };

View File

@ -134,6 +134,11 @@ const conf = convict({
format: String, format: String,
default: '', // disabled default: '', // disabled
env: 'FXA_CLIENT_ID' env: 'FXA_CLIENT_ID'
},
fxa_key_scope: {
format: String,
default: 'https://identity.mozilla.com/apps/send',
env: 'FXA_KEY_SCOPE'
} }
}); });

View File

@ -1,7 +1,7 @@
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const config = require('./config'); const config = require('./config');
const KEY_SCOPE = 'https://identity.mozilla.com/apps/send'; const KEY_SCOPE = config.fxa_key_scope;
let fxaConfig = null; let fxaConfig = null;
let lastConfigRefresh = 0; let lastConfigRefresh = 0;
@ -14,6 +14,7 @@ async function getFxaConfig() {
{ timeout: 3000 } { timeout: 3000 }
); );
fxaConfig = await res.json(); fxaConfig = await res.json();
fxaConfig.key_scope = KEY_SCOPE;
lastConfigRefresh = Date.now(); lastConfigRefresh = Date.now();
return fxaConfig; return fxaConfig;
} }

View File

@ -35,7 +35,7 @@ module.exports = {
await storage.set( await storage.set(
id(req.user), id(req.user),
fileStream, fileStream,
{ n: 'a' }, //TODO null,
config.max_expire_seconds config.max_expire_seconds
); );
res.sendStatus(200); res.sendStatus(200);

View File

@ -52,7 +52,9 @@ class DB {
const filePath = `${prefix}-${id}`; const filePath = `${prefix}-${id}`;
await this.storage.set(filePath, file); await this.storage.set(filePath, file);
this.redis.hset(id, 'prefix', prefix); this.redis.hset(id, 'prefix', prefix);
if (meta) {
this.redis.hmset(id, meta); this.redis.hmset(id, meta);
}
this.redis.expire(id, expireSeconds); this.redis.expire(id, expireSeconds);
} }