Page MenuHomePhabricator

D5885.id19440.diff
No OneTemporary

D5885.id19440.diff

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
@@ -1,7 +1,27 @@
// @flow
-async function siweNonceResponder(): Promise<string> {
- return 'UNIMPLEMENTED';
+import { generateNonce } from 'siwe';
+import t from 'tcomb';
+
+import type {
+ SIWENonceRequest,
+ SIWENonceResponse,
+} from 'lib/types/siwe-types.js';
+import { tShape } from 'lib/utils/validation-utils';
+
+import type { Viewer } from '../session/viewer.js';
+import { validateInput } from '../utils/validation-utils.js';
+
+const siweNonceRequestInputValidator = tShape({
+ walletAddress: t.String,
+});
+async function siweNonceResponder(
+ viewer: Viewer,
+ input: any,
+): Promise<SIWENonceResponse> {
+ const request: SIWENonceRequest = input;
+ await validateInput(viewer, siweNonceRequestInputValidator, request);
+ return { nonce: generateNonce() };
}
export { siweNonceResponder };
diff --git a/lib/types/siwe-types.js b/lib/types/siwe-types.js
new file mode 100644
--- /dev/null
+++ b/lib/types/siwe-types.js
@@ -0,0 +1,9 @@
+// @flow
+
+export type SIWENonceRequest = {
+ +walletAddress: string,
+};
+
+export type SIWENonceResponse = {
+ +nonce: string,
+};

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 5:53 AM (18 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2686525
Default Alt Text
D5885.id19440.diff (1 KB)

Event Timeline