Page MenuHomePhabricator

D5887.id19687.diff
No OneTemporary

D5887.id19687.diff

diff --git a/keyserver/src/creators/siwe-nonce-creator.js b/keyserver/src/creators/siwe-nonce-creator.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/creators/siwe-nonce-creator.js
@@ -0,0 +1,14 @@
+// @flow
+
+import { dbQuery, SQL } from '../database/database.js';
+
+async function createSIWENonceEntry(nonce: string): Promise<void> {
+ const time = Date.now();
+ const query = SQL`
+ INSERT INTO siwe_nonces(nonce, creation_time)
+ VALUES ${[[nonce, time]]}
+ `;
+ await dbQuery(query);
+}
+
+export { createSIWENonceEntry };
diff --git a/keyserver/src/responders/siwe-nonce-responders.js b/keyserver/src/responders/siwe-nonce-responders.js
--- a/keyserver/src/responders/siwe-nonce-responders.js
+++ b/keyserver/src/responders/siwe-nonce-responders.js
@@ -2,10 +2,14 @@
import { generateNonce } from 'siwe';
-import type { SIWENonceResponse } from 'lib/types/siwe-types.js';
+import type { SIWENonceResponse } from 'lib/types/siwe-types';
+
+import { createSIWENonceEntry } from '../creators/siwe-nonce-creator';
async function siweNonceResponder(): Promise<SIWENonceResponse> {
- return { nonce: generateNonce() };
+ const generatedNonce = generateNonce();
+ await createSIWENonceEntry(generatedNonce);
+ return { nonce: generatedNonce };
}
export { siweNonceResponder };

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 5:26 AM (18 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2683949
Default Alt Text
D5887.id19687.diff (1 KB)

Event Timeline