File tree Expand file tree Collapse file tree 3 files changed +16
-32
lines changed Expand file tree Collapse file tree 3 files changed +16
-32
lines changed Original file line number Diff line number Diff line change 55</ head >
66< style >
77 body {
8- color : white;
98 padding : 0 16px ;
109 }
11- li : before {
12- content : '• ' ;
13- width : 3em ;
14- }
15-
16- # action {
17- display : flex;
18- padding : 16px 16px 0px 16px ;
19- }
20- # display {
21- padding : 0px 16px ;
22- }
23- div {
24- font-size : 12px ;
10+ sp-field-label {
11+ margin-top : 16px ;
12+ font-size : 14px ;
2513 }
2614 sp-button {
2715 font-size : 12px ;
3523< body >
3624 < sp-heading > Secure Storage Sample</ sp-heading >
3725 < sp-body id ="action ">
38- < div > Enter Secure Key</ div >
39- < div > < input type ="text " id ="secure "> </ div >
26+ < sp-textfield id ="secure ">
27+ < sp-label slot ="label "> Enter Secure Key</ sp-label >
28+ </ sp-textfield >
4029 </ sp-body >
4130 < sp-body id ="display ">
4231 </ sp-body >
Original file line number Diff line number Diff line change 11const secureStorage = require ( "uxp" ) . storage . secureStorage ;
2- const app = window . require ( "photoshop" ) . app ;
3-
42
53async function saveSecureKey ( ) {
6- const value = document . getElementById ( "secure" ) . value ;
7- await secureStorage . setItem ( "secure" , value ) ;
8- document . getElementById ( "secure" ) . value = ""
4+ const userInput = document . getElementById ( "secure" ) . value ;
5+ await secureStorage . setItem ( "secure" , userInput ) ;
6+ document . getElementById ( "secure" ) . value = "" ;
97}
108
119async function fetchSecureKey ( ) {
12- const value = await secureStorage . getItem ( "secure" ) ;
13- let string = "" ;
14- for ( let i of value ) string += String . fromCharCode ( i ) ;
15- document . getElementById ( "display" ) . innerHTML = `
16- <div>Secure Key entered is ${ string } </div>` ;
10+ // We get the stored value from the secureStorage in the form of a uint8Array.
11+ const uintArray = await secureStorage . getItem ( "secure" ) ;
12+ // We convert the uint8Array to a string to present it to the user.
13+ let secureKey = "" ;
14+ for ( let i of uintArray ) secureKey += String . fromCharCode ( i ) ;
15+ document . getElementById ( "display" ) . textContent = `
16+ Secure Key entered is ${ secureKey } ` ;
1717}
1818
1919document . getElementById ( "btnPopulate" ) . addEventListener ( "click" , saveSecureKey ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments