Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3503459
D5887.id19688.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5887.id19688.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 5:24 AM (18 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2683949
Default Alt Text
D5887.id19688.diff (1 KB)
Attached To
Mode
D5887: [keyserver] Introduce `createSIWENonceEntry` to persist nonce in DB
Attached
Detach File
Event Timeline
Log In to Comment