Add types for libsodium-wrappers (#27447)

This commit is contained in:
Florian Keller 2018-07-23 17:44:28 +02:00 committed by Andy
parent 749ebd987f
commit 5090fabde6
4 changed files with 1132 additions and 0 deletions

1086
types/libsodium-wrappers/index.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View 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];
});

View 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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }