-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Merge branch 'release/v9.7.0'
- Loading branch information
Showing
31 changed files
with
40,856 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ node_modules/ | |
site/*.js | ||
dist/ | ||
pgdata/ | ||
package-lock.json | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,89 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>CloudproofJS in browser</title> | ||
<link rel="icon" href="data:,"> | ||
</head> | ||
<body> | ||
<link rel="icon" href="data:," /> | ||
</head> | ||
<body> | ||
<p>This demo should work without any JS build.</p> | ||
|
||
<script src="node_modules/cloudproof_js/dist/umd/index.js"></script> | ||
<script> | ||
const { CoverCrypt } = window.cloudproof_js; | ||
const { CoverCrypt } = window.cloudproof_js | ||
|
||
(async () => { | ||
const { Policy, PolicyAxis, generateMasterKeys, generateUserSecretKey, encrypt, decrypt } = await CoverCrypt(); | ||
|
||
const policy = new Policy([ | ||
new PolicyAxis( | ||
"Security Level", | ||
[ | ||
{ name: "Low", isHybridized: false }, | ||
{ name: "Medium", isHybridized: false }, | ||
{ name: "High", isHybridized: true }, | ||
], | ||
true, | ||
), | ||
new PolicyAxis( | ||
"Department", | ||
[ | ||
{ name: "R&D", isHybridized: false }, | ||
{ name: "HR", isHybridized: false }, | ||
], | ||
false, | ||
), | ||
]); | ||
;(async () => { | ||
const { | ||
Policy, | ||
PolicyAxis, | ||
generateMasterKeys, | ||
generateUserSecretKey, | ||
encrypt, | ||
decrypt, | ||
} = await CoverCrypt() | ||
|
||
const masterKeys = generateMasterKeys(policy); | ||
console.log(masterKeys); | ||
const policy = new Policy([ | ||
new PolicyAxis( | ||
"Security Level", | ||
[ | ||
{ name: "Low", isHybridized: false }, | ||
{ name: "Medium", isHybridized: false }, | ||
{ name: "High", isHybridized: true }, | ||
], | ||
true, | ||
), | ||
new PolicyAxis( | ||
"Department", | ||
[ | ||
{ name: "R&D", isHybridized: false }, | ||
{ name: "HR", isHybridized: false }, | ||
], | ||
false, | ||
), | ||
]) | ||
|
||
const highSecretAllDepartmentsDecryptionKey = generateUserSecretKey(masterKeys.secretKey, "Security Level::High && Department::R&D && Department::HR", policy) | ||
const lowSecretHRDepartmentDecryptionKey = generateUserSecretKey(masterKeys.secretKey, "Security Level::Low && Department::HR", policy) | ||
const masterKeys = generateMasterKeys(policy) | ||
console.log(masterKeys) | ||
|
||
const secret = encrypt(policy, masterKeys.publicKey, "Security Level::High && Department::HR", new TextEncoder().encode("My secret!")); | ||
console.log(secret); | ||
const decrypted = decrypt(highSecretAllDepartmentsDecryptionKey, secret); | ||
const decryptedMessage = new TextDecoder().decode(decrypted.plaintext); | ||
console.log(decryptedMessage); | ||
if (decryptedMessage !== "My secret!") { | ||
throw new Error("Incorrect decrypted message"); | ||
} | ||
const highSecretAllDepartmentsDecryptionKey = generateUserSecretKey( | ||
masterKeys.secretKey, | ||
"Security Level::High && Department::R&D && Department::HR", | ||
policy, | ||
) | ||
const lowSecretHRDepartmentDecryptionKey = generateUserSecretKey( | ||
masterKeys.secretKey, | ||
"Security Level::Low && Department::HR", | ||
policy, | ||
) | ||
|
||
try { | ||
decrypt(lowSecretHRDepartmentDecryptionKey, secret); | ||
} catch { | ||
// should fail | ||
} | ||
const secret = encrypt( | ||
policy, | ||
masterKeys.publicKey, | ||
"Security Level::High && Department::HR", | ||
new TextEncoder().encode("My secret!"), | ||
) | ||
console.log(secret) | ||
|
||
const element = document.createElement('div') | ||
element.id = "done" | ||
document.body.appendChild(element) | ||
})(); | ||
const decrypted = decrypt(highSecretAllDepartmentsDecryptionKey, secret) | ||
const decryptedMessage = new TextDecoder().decode(decrypted.plaintext) | ||
console.log(decryptedMessage) | ||
|
||
if (decryptedMessage !== "My secret!") { | ||
throw new Error("Incorrect decrypted message") | ||
} | ||
|
||
try { | ||
decrypt(lowSecretHRDepartmentDecryptionKey, secret) | ||
} catch { | ||
// should fail | ||
} | ||
|
||
const element = document.createElement("div") | ||
element.id = "done" | ||
document.body.appendChild(element) | ||
})() | ||
</script> | ||
</body> | ||
</html> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ node_modules/ | |
*.sqlite | ||
*.sqlite-journal | ||
*.csv | ||
*.tsv | ||
*.tsv |
Oops, something went wrong.