Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
amrani
jio
Commits
0b8bd163
Commit
0b8bd163
authored
May 07, 2018
by
amrani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding friedly user password to cryptostorage
parent
d963b0a5
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
244 additions
and
108 deletions
+244
-108
Gruntfile.js
Gruntfile.js
+1
-0
src/jio.storage/cryptstorage.js
src/jio.storage/cryptstorage.js
+216
-92
src/jio.storage/dropboxstorage.js
src/jio.storage/dropboxstorage.js
+7
-4
test/jio.storage/cryptstorage.tests.js
test/jio.storage/cryptstorage.tests.js
+20
-12
No files found.
Gruntfile.js
View file @
0b8bd163
...
@@ -75,6 +75,7 @@ module.exports = function (grunt) {
...
@@ -75,6 +75,7 @@ module.exports = function (grunt) {
indent
:
2
,
indent
:
2
,
maxerr
:
3
,
maxerr
:
3
,
predef
:
[
predef
:
[
'
DataView
'
,
'
define
'
,
'
define
'
,
'
exports
'
,
'
exports
'
,
'
require
'
,
'
require
'
,
...
...
src/jio.storage/cryptstorage.js
View file @
0b8bd163
This diff is collapsed.
Click to expand it.
src/jio.storage/dropboxstorage.js
View file @
0b8bd163
...
@@ -255,12 +255,15 @@
...
@@ -255,12 +255,15 @@
})
})
.
push
(
function
(
evt
)
{
.
push
(
function
(
evt
)
{
if
(
evt
.
target
.
response
instanceof
Blob
)
{
if
(
evt
.
target
.
response
instanceof
Blob
)
{
return
evt
.
target
.
response
;
//create a new blob with type AES-GCM to decrypt back
var
cryptblob
=
new
Blob
([
evt
.
target
.
response
],
{
type
:
"
application/x-jio-aes-gcm-encryption
"
});
return
cryptblob
;
}
}
return
new
Blob
(
return
new
Blob
(
[
evt
.
target
.
responseText
],
[
evt
.
target
.
responseText
],
{
"
type
"
:
evt
.
target
.
getResponseHeader
(
'
Content-Type
'
)
||
{
"
type
"
:
"
application/x-jio-aes-gcm-encryption
"
}
"
application/octet-stream
"
}
// evt.target.getResponseHeader('Content-Type') ||
);
);
},
function
(
error
)
{
},
function
(
error
)
{
if
(
error
.
target
!==
undefined
&&
error
.
target
.
status
===
409
)
{
if
(
error
.
target
!==
undefined
&&
error
.
target
.
status
===
409
)
{
...
@@ -325,4 +328,4 @@
...
@@ -325,4 +328,4 @@
jIO
.
addStorage
(
'
dropbox
'
,
DropboxStorage
);
jIO
.
addStorage
(
'
dropbox
'
,
DropboxStorage
);
}(
jIO
,
RSVP
,
Blob
,
JSON
));
}(
jIO
,
RSVP
,
Blob
,
JSON
));
\ No newline at end of file
test/jio.storage/cryptstorage.tests.js
View file @
0b8bd163
...
@@ -11,9 +11,15 @@
...
@@ -11,9 +11,15 @@
equal
=
QUnit
.
equal
,
equal
=
QUnit
.
equal
,
throws
=
QUnit
.
throws
,
throws
=
QUnit
.
throws
,
module
=
QUnit
.
module
,
module
=
QUnit
.
module
,
key
=
{
"
alg
"
:
"
A256GCM
"
,
"
ext
"
:
true
,
key
=
"
password
"
,
"
k
"
:
"
seeaLzpu8dHG07bO2ANH2GywbTqs_zrs4Vq8zmtYeE4
"
,
key_generated_by_password
=
{
"
key_ops
"
:
[
"
encrypt
"
,
"
decrypt
"
],
"
kty
"
:
"
oct
"
};
"
alg
"
:
"
A256GCM
"
,
"
ext
"
:
true
,
"
k
"
:
"
wBHHU4Es8IqMCnH03Jxhc1ZTQN7hzo6GkCNnbA_0kjI
"
,
"
key_ops
"
:
[
"
encrypt
"
,
"
decrypt
"
],
"
kty
"
:
"
oct
"
};
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Custom test substorage definition
// Custom test substorage definition
...
@@ -362,8 +368,7 @@
...
@@ -362,8 +368,7 @@
test
(
"
return substorage getattachment if not data url
"
,
function
()
{
test
(
"
return substorage getattachment if not data url
"
,
function
()
{
var
id
=
"
/
"
,
var
id
=
"
/
"
,
attachment
=
"
stringattachment
"
,
attachment
=
"
stringattachment
"
,
blob
=
new
Blob
([
'
foo
'
],
blob
=
new
Blob
([
'
foo
'
],
{
type
:
'
application/x-jio-aes-gcm-encryption
'
});
{
type
:
'
application/x-jio-aes-gcm-encryption
'
});
Storage200
.
prototype
.
getAttachment
=
function
(
arg1
,
arg2
)
{
Storage200
.
prototype
.
getAttachment
=
function
(
arg1
,
arg2
)
{
equal
(
arg1
,
id
,
"
getAttachment 200 called
"
);
equal
(
arg1
,
id
,
"
getAttachment 200 called
"
);
...
@@ -390,10 +395,12 @@
...
@@ -390,10 +395,12 @@
var
id
=
"
/
"
,
var
id
=
"
/
"
,
attachment
=
"
stringattachment
"
,
attachment
=
"
stringattachment
"
,
value
=
"
azertyuio
\n
pàç_è-('é&
"
,
value
=
"
azertyuio
\n
pàç_è-('é&
"
,
tocheck
=
"
data:application/x-jio-aes-gcm-encryption;base64
"
+
tocheck
=
"
data:application/x-jio-aes-gcm-encryption
"
+
"
,+p/Ho+KgGHZC2zDLMbQQS2tXcsy0g+Ho41VZnlPEkXdmG9zm36c8iLCkv
"
+
"
;base64,2lHQ9xpJJ9qd81DxZEyd1LICtaV3XD+I2d5cp137L4NQC
"
+
"
lanyWCN510NK4hj1EgWQ6WrLS5pCmA/yeAWh+HyfPkYKDRHVBl6+Hxd53I
"
+
"
vdkasBaFkPUE5XiY88g5z0oN9dcDASfChmvgqrkDExKS+zVglvVVs
"
+
"
TmiWQ6Vix2jaIQg==
"
,
"
CyECYorZ5fwgMCWAL5vUNCCaqhFVFyng==
"
,
blob
=
jIO
.
util
.
dataURItoBlob
(
tocheck
);
blob
=
jIO
.
util
.
dataURItoBlob
(
tocheck
);
...
@@ -427,6 +434,7 @@
...
@@ -427,6 +434,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// CryptStorage.putAttachment
// CryptStorage.putAttachment
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
@@ -445,7 +453,7 @@
...
@@ -445,7 +453,7 @@
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
crypto
.
subtle
.
importKey
(
"
jwk
"
,
key
,
return
crypto
.
subtle
.
importKey
(
"
jwk
"
,
key
_generated_by_password
,
"
AES-GCM
"
,
false
,
[
"
decrypt
"
]);
"
AES-GCM
"
,
false
,
[
"
decrypt
"
]);
})
})
.
push
(
function
(
res
)
{
.
push
(
function
(
res
)
{
...
@@ -460,11 +468,10 @@
...
@@ -460,11 +468,10 @@
coded
=
coded
.
target
.
result
;
coded
=
coded
.
target
.
result
;
iv
=
new
Uint8Array
(
coded
.
slice
(
0
,
12
));
iv
=
new
Uint8Array
(
coded
.
slice
(
0
,
12
));
return
crypto
.
subtle
.
decrypt
({
name
:
"
AES-GCM
"
,
iv
:
iv
},
return
crypto
.
subtle
.
decrypt
({
name
:
"
AES-GCM
"
,
iv
:
iv
},
decryptKey
,
coded
.
slice
(
12
));
decryptKey
,
coded
.
slice
(
12
));
})
})
.
push
(
function
(
arr
)
{
.
push
(
function
(
arr
)
{
arr
=
String
.
fromCharCode
.
apply
(
null
,
new
Uint8Array
(
arr
));
arr
=
String
.
fromCharCode
.
apply
(
null
,
new
Uint8Array
(
arr
));
equal
(
equal
(
arr
,
arr
,
...
@@ -492,6 +499,7 @@
...
@@ -492,6 +499,7 @@
return
decodeAES
(
arg3
);
return
decodeAES
(
arg3
);
};
};
stop
();
stop
();
expect
(
7
);
expect
(
7
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment