Merge pull request #76 from gcsolaroli/master

Password generator and tentative fix for login errors
master-GE
Giulio Cesare Solaroli 2015-08-13 10:56:32 +02:00
commit 5a8fe67f88
12 changed files with 1116 additions and 239 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,252 @@
{
"IcoMoonType": "selection",
"icons": [
{
"icon": {
"paths": [
"M972.8 512l-307.2-256v153.6h-358.4v204.8h358.4v153.6l307.2-256zM153.6 153.6h409.6v-102.4h-409.6c-56.32 0-102.4 46.080-102.4 102.4v716.8c0 56.32 46.080 102.4 102.4 102.4h409.6v-102.4h-409.6v-716.8z"
],
"attrs": [
{}
],
"isMulticolor": false,
"tags": [
"log-out"
],
"grid": 20
},
"attrs": [
{}
],
"properties": {
"order": 1,
"id": 0,
"prevSize": 24,
"code": 58889,
"name": "log-out",
"ligatures": "logout"
},
"setIdx": 0,
"setId": 10,
"iconIdx": 0
},
{
"icon": {
"paths": [
"M81.613 270.643c24.986 13.466 371.149 199.373 384.051 206.285 12.851 6.912 29.542 10.24 46.336 10.24 16.845 0 33.536-3.328 46.387-10.291 12.902-6.912 359.014-192.819 384-206.285 25.037-13.414 48.691-55.552 2.765-55.552h-866.253c-45.926 0-22.323 42.138 2.714 55.603zM952.986 373.043c-28.416 14.848-377.19 197.171-394.598 206.285s-29.542 10.291-46.387 10.291c-16.794 0-28.928-1.178-46.336-10.291s-366.234-191.488-394.598-206.285c-20.019-10.445-19.866 1.792-19.866 11.213 0 9.421 0 375.552 0 375.552 0 21.504 28.621 49.152 50.79 49.152h820.070c22.221 0 50.739-27.648 50.739-49.101 0 0 0-366.131 0-375.552 0-9.472 0.205-21.709-19.814-11.264z"
],
"tags": [
"mail",
"email",
"message",
"letter",
"envelope",
"contact"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 4,
"order": 19,
"prevSize": 24,
"code": 58894,
"name": "mail",
"ligatures": "email"
},
"setIdx": 8,
"setId": 0,
"iconIdx": 4
},
{
"icon": {
"paths": [
"M819.2 102.4h-410.624c-56.32 0-101.376 45.056-101.376 101.376v410.624c0 56.32 46.080 102.4 102.4 102.4h409.6c56.32 0 102.4-46.080 102.4-102.4v-409.6c0-56.32-46.080-102.4-102.4-102.4zM819.2 614.4h-409.6v-409.6h409.6v409.6zM204.8 512h-102.4v307.2c0 56.32 46.080 102.4 102.4 102.4h307.2v-102.4h-307.2v-307.2z"
],
"tags": [
"popup",
"popout",
"new window"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 35,
"order": 9,
"prevSize": 24,
"code": 58890,
"name": "popup",
"ligatures": "url, direct login"
},
"setIdx": 8,
"setId": 0,
"iconIdx": 35
},
{
"icon": {
"paths": [
"M512 81.92c-237.568 0-430.080 192.614-430.080 430.080 0 237.568 192.563 430.080 430.080 430.080 237.517 0 430.080-192.563 430.080-430.080 0-237.517-192.563-430.080-430.080-430.080zM564.326 564.326v206.182h-104.653v-206.182h-206.234v-104.653h206.182v-206.234h104.704v206.182h206.182v104.704h-206.182z"
],
"tags": [
"plus",
"add",
"sum"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 125,
"order": 14,
"prevSize": 24,
"code": 58895,
"name": "plus",
"ligatures": "add new field, create new OTP"
},
"setIdx": 8,
"setId": 0,
"iconIdx": 125
},
{
"icon": {
"paths": [
"M512 81.92c-237.568 0-430.080 192.614-430.080 430.080 0 237.568 192.563 430.080 430.080 430.080 237.517 0 430.080-192.563 430.080-430.080 0-237.517-192.563-430.080-430.080-430.080zM600.525 512l156.723 156.723-88.525 88.525-156.723-156.723-156.723 156.723-88.474-88.525 156.672-156.723-156.672-156.672 88.474-88.525 156.723 156.672 156.723-156.672 88.525 88.474-156.723 156.723z"
],
"tags": [
"cross",
"cancel",
"close",
"remove",
"delete"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 126,
"order": 17,
"prevSize": 24,
"code": 58898,
"name": "cross",
"ligatures": "remove field, remove tag, remove OTP"
},
"setIdx": 8,
"setId": 0,
"iconIdx": 126
},
{
"icon": {
"paths": [
"M778.189 460.8h-215.040v-215.040c0-28.262-22.886-30.72-51.2-30.72-28.262 0-51.2 2.406-51.2 30.72l-0 215.040h-214.989c-28.314 0-30.72 22.938-30.72 51.2s2.406 51.2 30.72 51.2h214.989v215.040c0 28.262 22.938 30.72 51.2 30.72 28.314 0 51.2-2.458 51.2-30.72v-215.040h215.040c28.314 0 30.771-22.938 30.771-51.2s-2.458-51.2-30.771-51.2z"
],
"tags": [
"plus",
"add",
"sum"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 128,
"order": 20,
"prevSize": 24,
"code": 58888,
"name": "plus3",
"ligatures": "add card"
},
"setIdx": 8,
"setId": 0,
"iconIdx": 128
},
{
"icon": {
"paths": [
"M585.574 231.219c-21.402 20.89-230.502 240.435-230.502 240.435-11.418 11.162-17.101 25.754-17.101 40.346s5.683 29.184 17.101 40.346c0 0 209.101 219.546 230.502 240.384 21.402 20.89 59.904 22.323 82.739 0 22.784-22.272 24.576-53.35-0.051-80.64l-191.846-200.090 191.846-200.090c24.627-27.341 22.835-58.419 0.051-80.691-22.886-22.272-61.389-20.89-82.739-0z"
],
"tags": [
"arrow-left",
"left",
"previous"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 205,
"order": 11,
"prevSize": 24,
"code": 58892,
"name": "arrow-left",
"ligatures": "back"
},
"setIdx": 8,
"setId": 0,
"iconIdx": 205
},
{
"icon": {
"paths": [
"M438.426 231.219c21.402 20.89 230.502 240.435 230.502 240.435 11.469 11.162 17.152 25.754 17.152 40.346s-5.683 29.184-17.152 40.346c0 0-209.101 219.546-230.502 240.384-21.402 20.89-59.853 22.323-82.739 0-22.835-22.272-24.627-53.35 0-80.64l191.898-200.090-191.846-200.090c-24.627-27.341-22.835-58.419 0-80.691 22.835-22.272 61.338-20.89 82.688-0z"
],
"tags": [
"arrow-right",
"right",
"next"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 208,
"order": 12,
"prevSize": 24,
"code": 58893,
"name": "arrow-right",
"ligatures": "show detail"
},
"setIdx": 8,
"setId": 0,
"iconIdx": 208
},
{
"icon": {
"paths": [
"M512 42l384 172v256q0 178-110 325t-274 187q-164-40-274-187t-110-325v-256zM512 512v382q118-38 200-143t98-239h-298zM512 512v-376l-298 132v244h298z"
],
"attrs": [
{}
],
"isMulticolor": false,
"tags": [
"security"
],
"defaultCode": 57637,
"grid": 24
},
"attrs": [
{}
],
"properties": {
"order": 28,
"id": 293,
"prevSize": 24,
"code": 57637,
"name": "security",
"ligatures": "lock"
},
"setIdx": 1,
"setId": 9,
"iconIdx": 293
},
{
"icon": {
"paths": [
@ -27,10 +273,37 @@
"name": "label",
"ligatures": "label"
},
"setIdx": 0,
"setIdx": 1,
"setId": 9,
"iconIdx": 678
},
{
"icon": {
"paths": [
"M447.938 350c-89.407 0-161.938 72.531-161.938 162 0 89.375 72.531 162.062 161.938 162.062 89.438 0 161.438-72.688 161.438-162.062-0.001-89.469-72.001-162-161.438-162zM772.625 605.062l-29.188 70.312 58.937 115.75-72.188 72.188-118.436-55.937-70.312 28.875-35.688 109.25-4.562 14.5h-102.032l-44.156-123.312-70.312-29-115.904 58.688-72.156-72.125 55.875-118.5-28.969-70.25-123.534-40.313v-101.969l123.406-44.219 28.969-70.188-51.906-102.469-6.844-13.438 72.062-72.062 118.594 55.844 70.219-29.031 35.656-109.188 4.594-14.468h102l44.188 123.469 70.125 29.031 116.062-58.813 72.125 72.062-55.875 118.406 28.875 70.345 123.75 40.25v101.938l-123.375 44.374z"
],
"width": 896,
"attrs": [],
"isMulticolor": false,
"tags": [
"gear"
],
"defaultCode": 61487,
"grid": 16
},
"attrs": [],
"properties": {
"id": 64,
"order": 30,
"prevSize": 32,
"code": 61487,
"name": "gear",
"ligatures": "options"
},
"setIdx": 2,
"setId": 8,
"iconIdx": 64
},
{
"icon": {
"paths": [
@ -53,10 +326,10 @@
"order": 26,
"prevSize": 32,
"code": 59789,
"ligatures": "generate password",
"ligatures": "password generator",
"name": "key"
},
"setIdx": 2,
"setIdx": 3,
"setId": 7,
"iconIdx": 141
},
@ -85,10 +358,73 @@
"ligatures": "view password",
"name": "eye"
},
"setIdx": 2,
"setIdx": 3,
"setId": 7,
"iconIdx": 206
},
{
"icon": {
"paths": [
"M889.68 166.32c-93.608-102.216-228.154-166.32-377.68-166.32-282.77 0-512 229.23-512 512h96c0-229.75 186.25-416 416-416 123.020 0 233.542 53.418 309.696 138.306l-149.696 149.694h352v-352l-134.32 134.32z",
"M928 512c0 229.75-186.25 416-416 416-123.020 0-233.542-53.418-309.694-138.306l149.694-149.694h-352v352l134.32-134.32c93.608 102.216 228.154 166.32 377.68 166.32 282.77 0 512-229.23 512-512h-96z"
],
"attrs": [],
"isMulticolor": false,
"tags": [
"loop",
"repeat",
"player",
"reload",
"refresh",
"update",
"synchronize",
"arrows"
],
"defaultCode": 60839,
"grid": 16
},
"attrs": [],
"properties": {
"order": 31,
"id": 1550,
"prevSize": 32,
"code": 59950,
"ligatures": "generate password",
"name": "loop2"
},
"setIdx": 3,
"setId": 7,
"iconIdx": 302
},
{
"icon": {
"paths": [
"M512 992l480-480h-288v-512h-384v512h-288z"
],
"attrs": [],
"isMulticolor": false,
"tags": [
"arrow-down",
"down",
"download",
"bottom"
],
"defaultCode": 60877,
"grid": 16
},
"attrs": [],
"properties": {
"id": 1069,
"order": 32,
"prevSize": 32,
"code": 59958,
"ligatures": "set password",
"name": "arrow-down"
},
"setIdx": 3,
"setId": 7,
"iconIdx": 310
},
{
"icon": {
"paths": [
@ -111,7 +447,7 @@
"name": "tag",
"ligatures": "tag"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 0
},
@ -138,7 +474,7 @@
"name": "tags",
"ligatures": "tags"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 1
},
@ -165,7 +501,7 @@
"name": "clock",
"ligatures": "recent"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 2
},
@ -194,7 +530,7 @@
"name": "spinner",
"ligatures": "loading"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 3
},
@ -222,7 +558,7 @@
"name": "search",
"ligatures": "search"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 4
},
@ -250,7 +586,7 @@
"name": "locked",
"ligatures": "locked"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 6
},
@ -276,7 +612,7 @@
"name": "unlocked",
"ligatures": "unlocked"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 7
},
@ -305,7 +641,7 @@
"name": "menu",
"ligatures": "menu"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 8
},
@ -334,7 +670,7 @@
"name": "close",
"ligatures": "failure, failed, delete, clear, cancel, close"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 9
},
@ -363,7 +699,7 @@
"name": "checkmark",
"ligatures": "done, ok, save"
},
"setIdx": 3,
"setIdx": 4,
"setId": 6,
"iconIdx": 10
},
@ -385,12 +721,12 @@
"properties": {
"order": 18,
"id": 1,
"prevSize": 32,
"prevSize": 24,
"code": 58899,
"name": "commands",
"ligatures": "commands"
},
"setIdx": 4,
"setIdx": 5,
"setId": 4,
"iconIdx": 0
},
@ -410,201 +746,14 @@
"properties": {
"order": 4,
"id": 0,
"prevSize": 32,
"prevSize": 24,
"code": 58884,
"name": "logo",
"ligatures": "clipperz"
},
"setIdx": 4,
"setIdx": 5,
"setId": 4,
"iconIdx": 1
},
{
"icon": {
"paths": [
"M81.613 270.643c24.986 13.466 371.149 199.373 384.051 206.285 12.851 6.912 29.542 10.24 46.336 10.24 16.845 0 33.536-3.328 46.387-10.291 12.902-6.912 359.014-192.819 384-206.285 25.037-13.414 48.691-55.552 2.765-55.552h-866.253c-45.926 0-22.323 42.138 2.714 55.603zM952.986 373.043c-28.416 14.848-377.19 197.171-394.598 206.285s-29.542 10.291-46.387 10.291c-16.794 0-28.928-1.178-46.336-10.291s-366.234-191.488-394.598-206.285c-20.019-10.445-19.866 1.792-19.866 11.213 0 9.421 0 375.552 0 375.552 0 21.504 28.621 49.152 50.79 49.152h820.070c22.221 0 50.739-27.648 50.739-49.101 0 0 0-366.131 0-375.552 0-9.472 0.205-21.709-19.814-11.264z"
],
"tags": [
"mail",
"email",
"message",
"letter",
"envelope",
"contact"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 4,
"order": 19,
"prevSize": 32,
"code": 58894,
"name": "mail",
"ligatures": "email"
},
"setIdx": 7,
"setId": 0,
"iconIdx": 4
},
{
"icon": {
"paths": [
"M819.2 102.4h-410.624c-56.32 0-101.376 45.056-101.376 101.376v410.624c0 56.32 46.080 102.4 102.4 102.4h409.6c56.32 0 102.4-46.080 102.4-102.4v-409.6c0-56.32-46.080-102.4-102.4-102.4zM819.2 614.4h-409.6v-409.6h409.6v409.6zM204.8 512h-102.4v307.2c0 56.32 46.080 102.4 102.4 102.4h307.2v-102.4h-307.2v-307.2z"
],
"tags": [
"popup",
"popout",
"new window"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 35,
"order": 9,
"prevSize": 32,
"code": 58890,
"name": "popup",
"ligatures": "url, direct login"
},
"setIdx": 7,
"setId": 0,
"iconIdx": 35
},
{
"icon": {
"paths": [
"M512 81.92c-237.568 0-430.080 192.614-430.080 430.080 0 237.568 192.563 430.080 430.080 430.080 237.517 0 430.080-192.563 430.080-430.080 0-237.517-192.563-430.080-430.080-430.080zM564.326 564.326v206.182h-104.653v-206.182h-206.234v-104.653h206.182v-206.234h104.704v206.182h206.182v104.704h-206.182z"
],
"tags": [
"plus",
"add",
"sum"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 125,
"order": 14,
"prevSize": 32,
"code": 58895,
"name": "plus",
"ligatures": "add new field, create new OTP"
},
"setIdx": 7,
"setId": 0,
"iconIdx": 125
},
{
"icon": {
"paths": [
"M512 81.92c-237.568 0-430.080 192.614-430.080 430.080 0 237.568 192.563 430.080 430.080 430.080 237.517 0 430.080-192.563 430.080-430.080 0-237.517-192.563-430.080-430.080-430.080zM600.525 512l156.723 156.723-88.525 88.525-156.723-156.723-156.723 156.723-88.474-88.525 156.672-156.723-156.672-156.672 88.474-88.525 156.723 156.672 156.723-156.672 88.525 88.474-156.723 156.723z"
],
"tags": [
"cross",
"cancel",
"close",
"remove",
"delete"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 126,
"order": 17,
"prevSize": 32,
"code": 58898,
"name": "cross",
"ligatures": "remove field, remove tag, remove OTP"
},
"setIdx": 7,
"setId": 0,
"iconIdx": 126
},
{
"icon": {
"paths": [
"M778.189 460.8h-215.040v-215.040c0-28.262-22.886-30.72-51.2-30.72-28.262 0-51.2 2.406-51.2 30.72l-0 215.040h-214.989c-28.314 0-30.72 22.938-30.72 51.2s2.406 51.2 30.72 51.2h214.989v215.040c0 28.262 22.938 30.72 51.2 30.72 28.314 0 51.2-2.458 51.2-30.72v-215.040h215.040c28.314 0 30.771-22.938 30.771-51.2s-2.458-51.2-30.771-51.2z"
],
"tags": [
"plus",
"add",
"sum"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 128,
"order": 20,
"prevSize": 32,
"code": 58888,
"name": "plus3",
"ligatures": "add card"
},
"setIdx": 7,
"setId": 0,
"iconIdx": 128
},
{
"icon": {
"paths": [
"M585.574 231.219c-21.402 20.89-230.502 240.435-230.502 240.435-11.418 11.162-17.101 25.754-17.101 40.346s5.683 29.184 17.101 40.346c0 0 209.101 219.546 230.502 240.384 21.402 20.89 59.904 22.323 82.739 0 22.784-22.272 24.576-53.35-0.051-80.64l-191.846-200.090 191.846-200.090c24.627-27.341 22.835-58.419 0.051-80.691-22.886-22.272-61.389-20.89-82.739-0z"
],
"tags": [
"arrow-left",
"left",
"previous"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 205,
"order": 11,
"prevSize": 32,
"code": 58892,
"name": "arrow-left",
"ligatures": "back"
},
"setIdx": 7,
"setId": 0,
"iconIdx": 205
},
{
"icon": {
"paths": [
"M438.426 231.219c21.402 20.89 230.502 240.435 230.502 240.435 11.469 11.162 17.152 25.754 17.152 40.346s-5.683 29.184-17.152 40.346c0 0-209.101 219.546-230.502 240.384-21.402 20.89-59.853 22.323-82.739 0-22.835-22.272-24.627-53.35 0-80.64l191.898-200.090-191.846-200.090c-24.627-27.341-22.835-58.419 0-80.691 22.835-22.272 61.338-20.89 82.688-0z"
],
"tags": [
"arrow-right",
"right",
"next"
],
"grid": 20,
"attrs": []
},
"attrs": [],
"properties": {
"id": 208,
"order": 12,
"prevSize": 32,
"code": 58893,
"name": "arrow-right",
"ligatures": "show detail"
},
"setIdx": 7,
"setId": 0,
"iconIdx": 208
}
],
"height": 1024,
@ -631,7 +780,7 @@
"showMetrics": true,
"showMetadata": false,
"autoHost": false,
"embed": true,
"embed": false,
"showVersion": true,
"ligaReset": "tags"
},

View File

@ -21,6 +21,8 @@ refer to http://www.clipperz.com.
*/
"use strict";
try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) {
throw "Clipperz.Crypto.AES depends on Clipperz.ByteArray!";
}

View File

@ -21,6 +21,8 @@ refer to http://www.clipperz.com.
*/
"use strict";
try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) {
throw "Clipperz.Crypto.AES_2 depends on Clipperz.ByteArray!";
}
@ -804,10 +806,11 @@ MochiKit.Base.update(Clipperz.Crypto.AES_2, {
//-----------------------------------------------------------------------------
'deferredDecrypt': function(aKey, someData) {
var deferredResult
var nonce;
var message;
var key;
var deferredResult
var nonce;
var message;
var key;
var executionContext;
key = new Clipperz.Crypto.AES_2.Key({key:aKey});
nonce = someData.split(0, (128/8));

View File

@ -320,7 +320,6 @@ MochiKit.Base.update(Clipperz.PM.Crypto, {
deferredResult.addCallback(MochiKit.Async.wait, 0.1);
deferredResult.addCallback(Clipperz.Base.evalJSON);
deferredResult.addErrback(function(anError) {
console.log("PIPPO_1", anError)
Clipperz.logError("Error while decrypting data [4]");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
})
@ -403,7 +402,6 @@ console.log("PIPPO_1", anError)
try {
result = Clipperz.Base.evalJSON(value);
} catch (exception) {
console.log("PIPPO_2", anError)
Clipperz.logError("Error while decrypting data [4]");
throw Clipperz.Crypto.Base.exception.CorruptedMessage;
}

View File

@ -37,6 +37,7 @@ Clipperz.PM.UI.Components.Cards.EditClass = React.createClass({
getInitialState: function() {
return {
'draggedFieldReference': null,
'passwordGeneratorFieldReference': null,
'fromFieldPosition': -1,
'toFieldPosition': -1,
'dropPosition': -1,
@ -216,6 +217,19 @@ console.log("DROP"); //, anEvent);
//============================================================================
setValueFromPasswordGenerator: function (aField, aTextAreaRef) {
var reference = this.props['_reference'];
var self = this;
return function (aValue) {
aField.setValue(aValue);
React.findDOMNode(self.refs[aTextAreaRef]).value = aValue;
self.setState({'passwordGeneratorFieldReference':null});
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'refreshCardEditDetail', reference);
};
},
handleChange: function (anObject , aMethodName) {
var reference = this.props['_reference'];
var method = MochiKit.Base.method(anObject, aMethodName);
@ -270,6 +284,23 @@ console.log("DROP"); //, anEvent);
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'refreshCardEditDetail', reference);
},
showPasswordGenerator: function (aField) {
var result;
if (aField['actionType'] == 'PASSWORD') {
var reference = this.props['_reference'];
var self = this;
result = function (anEvent) {
self.setState({'passwordGeneratorFieldReference':aField['_reference']});
};
} else {
result = null;
}
return result;
},
toggleLock: function (aField) {
var reference = this.props['_reference'];
@ -290,6 +321,10 @@ console.log("DROP"); //, anEvent);
};
},
closePasswordGenerator: function () {
this.setState({'passwordGeneratorFieldReference': null});
},
//============================================================================
renderLabel: function (aLabel) {
@ -320,6 +355,7 @@ console.log("DROP"); //, anEvent);
var cardFieldClasses = {};
var cardFieldValueClasses = {};
var field = aField['_field'];
var fieldValueRef = ref + '_textarea';
//console.log("RENDER FIELD", aField);
cardFieldClasses['cardField'] = true;
@ -355,12 +391,12 @@ console.log("DROP"); //, anEvent);
React.DOM.input({'_className_':'_fieldLabel_', 'onChange':this.handleChange(field, 'setLabel'), 'defaultValue':aField['label'], 'placeholder': "label"}),
]),
React.DOM.div({'className':'fieldValue'}, [
// React.DOM.textarea({'className':Clipperz.PM.UI.Components.classNames(cardFieldValueClasses), 'onChange':this.handleChange(field, 'setValue'), 'defaultValue':aField['value'], 'placeholder': "value"}),
Clipperz.PM.UI.Components.Cards.TextArea({'className':Clipperz.PM.UI.Components.classNames(cardFieldValueClasses), 'onChange':this.handleChange(field, 'setValue'), 'onKeyDown':this.handleKeyDown(field), 'defaultValue':aField['value'], 'placeholder': "value"}),
(ref == this.state['passwordGeneratorFieldReference']) ? Clipperz.PM.UI.Components.Cards.PasswordGenerator({'field':aField, 'setValueCallback':this.setValueFromPasswordGenerator(field, fieldValueRef), 'closeClallback':this.closePasswordGenerator}) : null,
Clipperz.PM.UI.Components.Cards.TextArea({'className':Clipperz.PM.UI.Components.classNames(cardFieldValueClasses), 'onChange':this.handleChange(field, 'setValue'), 'onKeyDown':this.handleKeyDown(field), 'defaultValue':aField['value'], 'placeholder':(aField['actionType'].toLowerCase() == 'password')?'':"value", 'ref':fieldValueRef}),
])
]),
React.DOM.div({'className':'fieldAction'}, [
React.DOM.span({'className':'action'}, aField['actionType'].toLowerCase() == 'password' ? 'generate password' : aField['actionType'].toLowerCase()),
React.DOM.span({'className':'action ' + aField['actionType'], 'onClick':this.showPasswordGenerator(aField)}, aField['actionType'].toLowerCase() == 'password' ? 'password generator' : aField['actionType'].toLowerCase()),
React.DOM.span({'className':'toggleLock', 'onClick':this.toggleLock(field)}, aField['isHidden'] ? "locked" : "unlocked")
])
]);

View File

@ -0,0 +1,221 @@
/*
Copyright 2008-2015 Clipperz Srl
This file is part of Clipperz, the online password manager.
For further information about its features and functionalities please
refer to http://www.clipperz.com.
* Clipperz is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
* Clipperz is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
*/
'use strict';
Clipperz.Base.module('Clipperz.PM.UI.Components.Cards');
Clipperz.PM.UI.Components.Cards.PasswordGeneratorClass = React.createClass({
charsetBlocks: {
'chars_AZ': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'chars_az': 'abcdefghijklmnopqrstuvwxyz',
'chars_09': '0123456789',
'chars_space': ' ',
'chars_other': '~`!@#$%^&*()-_=+,.<>/?[]{}\\|:;\'"'
},
gradientColors: ['#ff3236', '#e74030', '#cf4e2a', '#b75c24', '#9f6a1e', '#877818', '#6f8612', '#57940c', '#3fa206', '#25ad00', '#25ad00'],
getInitialState: function () {
return {
'length': 32,
'options': 'closed',
'chars_AZ': true,
'chars_az': true,
'chars_09': true,
'chars_space': false,
'chars_other': true,
'charset': '',
'password': '',
'entropy': 0,
};
},
setPasswordValue: function () {
this.props['setValueCallback'](this.state['password']);
},
toggleOptions: function () {
var options;
options = (this.state['options'] == 'closed') ? 'open' : 'closed';
this.setState({'options':options});
},
updateCharset: function () {
var charsetKeys = ['chars_AZ', 'chars_az', 'chars_09', 'chars_space', 'chars_other'];
var self = this;
var charset;
charset = MochiKit.Iter.reduce(function (acc, key) { return acc + self.charsetBlocks[key]}, MochiKit.Base.filter(function (key) { return self.state[key] == true;}, charsetKeys), '');
this.setState({'charset': charset});
MochiKit.Async.callLater(0.1, this.refreshPasswordValue);
},
refreshPasswordValue: function () {
var charsetBitSize;
var passwordString;
var charset;
var passwordLength;
var randomBytes;
var blockIndex;
charset = this.state['charset'];
passwordLength = this.state['length'];
charsetBitSize = 0;
randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(50);
blockIndex = 0;
passwordString = "";
while (Math.pow(2, charsetBitSize) < charset.length) {
charsetBitSize ++;
}
if (charsetBitSize > 0) {
// while (Clipperz.PM.Crypto.passwordEntropy(passwordString) < 128) {
while (passwordString.length < passwordLength) {
var randomValue;
if (((blockIndex + 1)*charsetBitSize) > (randomBytes.length() * 8)) {
randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(50);
blockIndex = 0;
}
randomValue = randomBytes.bitBlockAtIndexWithSize(blockIndex*charsetBitSize, charsetBitSize);
if (randomValue < charset.length) {
passwordString += charset.charAt(randomValue);
}
blockIndex ++;
}
} else {
passwordString = "";
}
this.setState({
'password': passwordString,
'entropy': Clipperz.PM.Crypto.passwordEntropy(passwordString)
});
},
refreshEntropyValue: function () {
this.setState({
'entropy': Clipperz.PM.Crypto.passwordEntropy(this.state['password'])
});
},
changeStateWithTargetValue: function (aKey, shouldUpdatePasswordValue) {
var self = this;
return function (anEvent) {
var newState = {};
newState[aKey] = anEvent.target.value;
self.setState(newState);
if (shouldUpdatePasswordValue) {
MochiKit.Async.callLater(0.1, self.refreshPasswordValue);
} else {
MochiKit.Async.callLater(0.1, self.refreshEntropyValue);
}
}
},
changeStateWithCheckbox: function (aKey) {
var self = this;
return function (anEvent) {
var newState = {};
newState[aKey] = anEvent.target.checked;
self.setState(newState);
MochiKit.Async.callLater(0.1, self.updateCharset);
}
},
// isPasswordField: function () {
// return this.props['field']['actionType'] == 'PASSWORD';
// },
componentDidMount: function () {
this.updateCharset();
this.refreshPasswordValue();
},
render: function () {
var goodEntropy = 128;
var entropyPercentage;
var entropyWidth;
var entropyColor;
var result;
entropyPercentage = Math.min(this.state['entropy'] / goodEntropy * 100, 100);
entropyWidth = (100 - entropyPercentage)+ '%';
entropyColor = this.gradientColors[Math.floor(entropyPercentage / 10)];
result = React.DOM.div({'className':'passwordGenerator'}, [
React.DOM.div({'className':'passwordGeneratorMask', 'onClick':this.props['closeClallback']}),
React.DOM.div({'className':'passwordGeneratorBaloon'}, [
React.DOM.form({}, [
React.DOM.div({'className':'optionsWrapper'}, [
React.DOM.header({}, [
React.DOM.div({'className':'button', 'onClick':this.toggleOptions}, "options")
]),
React.DOM.div({'className':'options ' + this.state['options']}, [
React.DOM.div({'className':'length'}, [
React.DOM.span({}, "length"),
React.DOM.input({'type':'number', 'placehoder':"", 'value':this.state['length'], 'min':"1", 'max':"99", 'onChange':this.changeStateWithTargetValue('length', true), 'ref':'length'}),
]),
React.DOM.div({'className':'charList'}, [
React.DOM.span({}, "characters"),
React.DOM.div({'className':'charsetSets'}, [
React.DOM.label({}, [ React.DOM.input({'type':'checkbox', 'checked':this.state['chars_AZ'], 'onChange':this.changeStateWithCheckbox('chars_AZ')}), "A-Z"]),
React.DOM.label({}, [ React.DOM.input({'type':'checkbox', 'checked':this.state['chars_az'], 'onChange':this.changeStateWithCheckbox('chars_az')}), "a-z"]),
React.DOM.label({}, [ React.DOM.input({'type':'checkbox', 'checked':this.state['chars_09'], 'onChange':this.changeStateWithCheckbox('chars_09')}), "0-9"]),
React.DOM.label({}, [ React.DOM.input({'type':'checkbox', 'checked':this.state['chars_space'], 'onChange':this.changeStateWithCheckbox('chars_space')}), "space"]),
React.DOM.label({}, [ React.DOM.input({'type':'checkbox', 'checked':this.state['chars_other'], 'onChange':this.changeStateWithCheckbox('chars_other')}), "!#?"]),
]),
Clipperz.PM.UI.Components.Cards.TextArea({'rows':'1', 'value':this.state['charset'], 'onChange':this.changeStateWithTargetValue('charset', true)})
]),
])
]),
React.DOM.div({'className':'passwordValue'}, [
React.DOM.div({'className':'passwordWrapper'}, [
Clipperz.PM.UI.Components.Cards.TextArea({'rows':'1', 'value':this.state['password'], 'onChange':this.changeStateWithTargetValue('password', false)}),
React.DOM.div({'className':'entropyWrapper', 'style':{'backgroundColor':entropyColor}}, [ React.DOM.div({'className':'entropy', 'style':{'width': entropyWidth}})])
]),
React.DOM.div({'className':'button setPasswordValue', 'onClick':this.setPasswordValue}, "set password"),
React.DOM.div({'className':'button generatePassword', 'onClick':this.refreshPasswordValue}, "generate password"),
]),
// React.DOM.div({'className':'button setValue', 'onClick':this.setPasswordValue})
])
])
]);
return result;
},
//=========================================================================
});
Clipperz.PM.UI.Components.Cards.PasswordGenerator = React.createFactory(Clipperz.PM.UI.Components.Cards.PasswordGeneratorClass);

View File

@ -1533,7 +1533,11 @@ console.log("THE BROWSER IS OFFLINE");
newRecord = aValue;
return newRecord;
},
MochiKit.Base.methodcaller('addField', {'label':"", 'value':"", 'isHidden':false}),
// MochiKit.Base.methodcaller('addField', {'label':"", 'value':"", 'isHidden':false}),
// function () { return newRecord; },
MochiKit.Base.methodcaller('addField', {'label':"username", 'value':"", 'hidden':false}),
function () { return newRecord; },
MochiKit.Base.methodcaller('addField', {'label':"password", 'value':"", 'hidden':true}),
function () { return newRecord; },
MochiKit.Base.methodcaller('reference'),
MochiKit.Base.method(this, 'refreshUI'),

View File

@ -211,6 +211,7 @@
"Clipperz/PM/UI/Components/Cards/CommandToolbar.js",
"Clipperz/PM/UI/Components/Cards/EditToolbar.js",
"Clipperz/PM/UI/Components/Cards/TagEditor.js",
"Clipperz/PM/UI/Components/Cards/PasswordGenerator.js",
"Clipperz/PM/UI/Components/AccountStatus.js",

File diff suppressed because one or more lines are too long

View File

@ -437,7 +437,9 @@ $cardViewBasePadding: 10px;
};
}
.dragHandler {
.dragHandler3 {
// @include dotted-background();
@include cursor-grab();
@ -453,19 +455,62 @@ $cardViewBasePadding: 10px;
height: 20px;
margin-left: 6px;
display: block;
/*
@include icon-font();
color: #aaa;
font-size: 15pt;
margin: $iconMargin;
margin-left: 10px;
*/
&:active {
@include cursor-grabbing();
};
}
$dragHandlerHeight: 24px;
$dragHandlerWidth: 4px;
.dragHandler {
display: block;
box-sizing: border-box;
width: $dragHandlerWidth;
height: $dragHandlerHeight;
margin-left: 15px;
border:1px solid #E8E8E8;
// border:1px solid red;
border-top:0;
border-bottom:0;
@include cursor-grab();
&:active {
@include cursor-grabbing();
}
&:before {
display: block;
box-sizing: border-box;
content:'';
position: relative;
left:-1px;
// right:-2px;
height: 100%;
width: $dragHandlerWidth;
border:2px dotted #FFF;
// border:2px dotted blue;
border-top:0;
border-bottom:0;
z-index:2;
}
&:after {
display: block;
box-sizing: border-box;
content:'';
position: relative;
top: -$dragHandlerHeight;
left:0px;
right:0px;
height:100%;
border:1px solid #EEE;
// border:1px solid green;
border-top:0;
border-bottom:0;
}
}
}
.fieldValues {
@ -495,7 +540,8 @@ $cardViewBasePadding: 10px;
// height: 1.3em;
// outline: none;
@include user-select(text);
resize: none;
white-space: pre-wrap;
word-wrap: break-word;
@ -545,7 +591,11 @@ $cardViewBasePadding: 10px;
&.PASSWORD {
cursor: pointer;
&:hover {
color: #888;
};
&.active {
color: #333;
}
@ -601,3 +651,216 @@ $cardViewBasePadding: 10px;
}
}
//=============================================================================
.passwordGenerator {
.passwordGeneratorMask {
position: fixed;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
background-color: rgba(0, 0, 0, 0);
z-index: 100;
}
.passwordGeneratorBaloon {
position: relative;
$passwordBaloonColor: #333;
$passwordBaloonBorder: 10px;
$borderRadius: 6px;
z-index: 101;
form {
position: absolute;
bottom: calc(100% + 4px);
left: 0;
min-width: 220px;
width: 80%;
max-width: 400px;
// padding: 10px;
background-color: $passwordBaloonColor;
color: #fff;
@include border-radius($borderRadius);
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .2);
font-size: 9pt;
span {
font-size: 8pt;
color: #ccc;
}
textarea {
resize: none;
white-space: pre-wrap;
word-wrap: break-word;
width: 100%;
}
.optionsWrapper {
header {
height: 12px;
border-bottom: 1px solid #666;
div {
content: "options";
@include icon-font();
// text-align: right;
font-size: 8pt;
line-height: 14px;
color: #999;
padding-left: 5px;
&:hover {
color: white;
}
};
}
.options {
// height: inherit;
background-color: #888;
padding-left: $passwordBaloonBorder;
padding-right: $passwordBaloonBorder /* + 30px */;
padding-bottom: 3px;
border-bottom: 1px solid #aaa;
// @include transition(height, 0.5s, ease-in);
&.closed {
height: 0px;
padding-bottom: 0px;
border-bottom: 0px;
div {
visibility: hidden;
}
}
.length {
padding-top: 2px;
span {
margin-right: 3px;
&:after {
content: ':';
}
}
input {
// background-color: #888;
// color: white;
font-weight: bold;
font-size: 10pt;
// border: 0px;
text-align: right;
max-width: 50px;
&::-webkit-outer-spin-button {
opacity: 1;
}
}
}
.charList {
padding-top: 2px;
span {
display: inline-block;
line-height: 10px;
&:after {
content: ':';
}
}
.charsetSets {
display: inline-block;
align: right;
label {
span {
font-size: 10pt;
color: #eee;
&:after {
content: '';
}
}
padding-right: 5px;
cursor: pointer;
}
}
textarea {
color: gray;
min-height: 34px;
&:focus {
outline: 0;
}
}
}
}
}
.passwordValue {
@include flexbox();
@include flex-direction(row);
@include align-content(stretch);
padding: $passwordBaloonBorder;
padding-top: 3px;
padding-right: 0px;
.passwordWrapper {
@include flex(auto);
textarea {
font-size: 12pt;
font-weight: bold;
border: 0px;
&:focus {
outline: 0;
}
}
.entropyWrapper {
width: 100%;
height: 2px;
.entropy {
height: 100%;
background-color: white;
float: right;
}
}
}
.button {
@include flex(none);
@include icon-font();
font-size: 14pt;
font-weight: bold;
text-align: center;
color: #999;
width: 40px;
height: inherit;
&.setPasswordValue {
background-color: lighten($passwordBaloonColor, 5%);
}
&:hover {
color: white;
};
}
}
}
}
}