mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Add types for libsodium-wrappers (#27447)
This commit is contained in:
parent
749ebd987f
commit
5090fabde6
1086
types/libsodium-wrappers/index.d.ts
vendored
Normal file
1086
types/libsodium-wrappers/index.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
22
types/libsodium-wrappers/libsodium-wrappers-tests.ts
Normal file
22
types/libsodium-wrappers/libsodium-wrappers-tests.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import * as _sodium from 'libsodium-wrappers';
|
||||
|
||||
_sodium.ready.then(() => {
|
||||
const sodium = _sodium;
|
||||
|
||||
const key = sodium.crypto_secretstream_xchacha20poly1305_keygen();
|
||||
|
||||
const res = sodium.crypto_secretstream_xchacha20poly1305_init_push(key);
|
||||
const [state_out, header] = [res.state, res.header];
|
||||
const c1 = sodium.crypto_secretstream_xchacha20poly1305_push(state_out,
|
||||
sodium.from_string('message 1'), null,
|
||||
sodium.crypto_secretstream_xchacha20poly1305_TAG_MESSAGE);
|
||||
const c2 = sodium.crypto_secretstream_xchacha20poly1305_push(state_out,
|
||||
sodium.from_string('message 2'), null,
|
||||
sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL);
|
||||
|
||||
const state_in = sodium.crypto_secretstream_xchacha20poly1305_init_pull(header, key);
|
||||
const r1 = sodium.crypto_secretstream_xchacha20poly1305_pull(state_in, c1);
|
||||
const [m1, tag1] = [sodium.to_string(r1.message), r1.tag];
|
||||
const r2 = sodium.crypto_secretstream_xchacha20poly1305_pull(state_in, c2);
|
||||
const [m2, tag2] = [sodium.to_string(r2.message), r2.tag];
|
||||
});
|
||||
23
types/libsodium-wrappers/tsconfig.json
Normal file
23
types/libsodium-wrappers/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"libsodium-wrappers-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/libsodium-wrappers/tslint.json
Normal file
1
types/libsodium-wrappers/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user