|
|
@ -1,5 +1,5 @@
|
|
|
|
(function () {
|
|
|
|
(function () {
|
|
|
|
var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|
|
|
var factory = function (Hash, Util, Crypt, Nacl, Scrypt/*, Cred, nThen */) {
|
|
|
|
var Invite = {};
|
|
|
|
var Invite = {};
|
|
|
|
|
|
|
|
|
|
|
|
Invite.deriveSeeds = function (safeSeed) {
|
|
|
|
Invite.deriveSeeds = function (safeSeed) {
|
|
|
@ -44,8 +44,9 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|
|
|
'base64'); // format, could be 'base64'
|
|
|
|
'base64'); // format, could be 'base64'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Invite.getPreviewContent = function (seeds, cryptgetOpts, cb) {
|
|
|
|
Invite.getPreviewContent = function (seeds, cryptgetOpts, _cb) {
|
|
|
|
setTimeout(function () {
|
|
|
|
var cb = Util.once(Util.mkAsync(_cb));
|
|
|
|
|
|
|
|
// XXX test data
|
|
|
|
cb(void 0, {
|
|
|
|
cb(void 0, {
|
|
|
|
author: {
|
|
|
|
author: {
|
|
|
|
displayName: 'Bob',
|
|
|
|
displayName: 'Bob',
|
|
|
@ -54,7 +55,6 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|
|
|
team: 'CryptPad',
|
|
|
|
team: 'CryptPad',
|
|
|
|
message: 'Hello bob'
|
|
|
|
message: 'Hello bob'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
var secrets = Invite.derivePreviewSecrets(seeds);
|
|
|
|
var secrets = Invite.derivePreviewSecrets(seeds);
|
|
|
|
secrets = secrets;
|
|
|
|
secrets = secrets;
|
|
|
@ -62,6 +62,7 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|
|
|
var hash = Invite.derivePreviewHash(seeds);
|
|
|
|
var hash = Invite.derivePreviewHash(seeds);
|
|
|
|
Crypt.get(hash, function (err, val) {
|
|
|
|
Crypt.get(hash, function (err, val) {
|
|
|
|
if (err) { return void cb(err); }
|
|
|
|
if (err) { return void cb(err); }
|
|
|
|
|
|
|
|
if (!val) { return void cb('DELETED'); }
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
cb(void 0, JSON.parse(val));
|
|
|
|
cb(void 0, JSON.parse(val));
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
@ -86,6 +87,7 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|
|
|
if (typeof(module) !== 'undefined' && module.exports) {
|
|
|
|
if (typeof(module) !== 'undefined' && module.exports) {
|
|
|
|
module.exports = factory(
|
|
|
|
module.exports = factory(
|
|
|
|
require("../common-hash"),
|
|
|
|
require("../common-hash"),
|
|
|
|
|
|
|
|
require("../common-util"),
|
|
|
|
require("../cryptget"), // XXX npm cryptget?
|
|
|
|
require("../cryptget"), // XXX npm cryptget?
|
|
|
|
require("tweetnacl/nacl-fast"),
|
|
|
|
require("tweetnacl/nacl-fast"),
|
|
|
|
require("scrypt-async")
|
|
|
|
require("scrypt-async")
|
|
|
@ -93,11 +95,12 @@ var factory = function (Hash, Crypt, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
|
|
|
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
|
|
|
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
|
|
|
define([
|
|
|
|
define([
|
|
|
|
'/common/common-hash.js',
|
|
|
|
'/common/common-hash.js',
|
|
|
|
|
|
|
|
'/common/common-util.js',
|
|
|
|
'/common/cryptget.js',
|
|
|
|
'/common/cryptget.js',
|
|
|
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
|
|
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
|
|
|
'/bower_components/scrypt-async/scrypt-async.min.js',
|
|
|
|
'/bower_components/scrypt-async/scrypt-async.min.js',
|
|
|
|
], function (Hash, Crypt /*, Nacl, Scrypt */) {
|
|
|
|
], function (Hash, Util, Crypt /*, Nacl, Scrypt */) {
|
|
|
|
return factory(Hash, Crypt, window.nacl, window.scrypt);
|
|
|
|
return factory(Hash, Util, Crypt, window.nacl, window.scrypt);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}());
|
|
|
|
}());
|
|
|
|