Page MenuHomePhabricator

D6129.diff
No OneTemporary

D6129.diff

diff --git a/lib/utils/siwe-utils.js b/lib/utils/siwe-utils.js
--- a/lib/utils/siwe-utils.js
+++ b/lib/utils/siwe-utils.js
@@ -1,5 +1,7 @@
// @flow
+import invariant from 'invariant';
+
import type { SIWEMessage } from '../types/siwe-types.js';
import { isDev } from './dev-utils.js';
@@ -37,10 +39,19 @@
);
}
+function getSIWEStatementForPublicKey(publicKey: string): string {
+ invariant(
+ isValidPrimaryIdentityPublicKey(publicKey),
+ 'publicKey must be well formed in getSIWEStatementForPublicKey',
+ );
+ return `Device IdPubKey: ${publicKey} ${siweStatement}`;
+}
+
export {
siweStatement,
isValidSIWENonce,
isValidEthereumAddress,
isValidPrimaryIdentityPublicKey,
isValidSIWEMessage,
+ getSIWEStatementForPublicKey,
};
diff --git a/lib/utils/siwe-utils.test.js b/lib/utils/siwe-utils.test.js
--- a/lib/utils/siwe-utils.test.js
+++ b/lib/utils/siwe-utils.test.js
@@ -1,6 +1,7 @@
// @flow
import {
+ getSIWEStatementForPublicKey,
isValidEthereumAddress,
isValidPrimaryIdentityPublicKey,
isValidSIWENonce,
@@ -175,4 +176,14 @@
const longPublicKey = '98+/eB2MUVvYCpkESOSWttsYWDKeDXl8TAAAAAAAAAA3o8LY';
expect(isValidPrimaryIdentityPublicKey(longPublicKey)).toBe(false);
});
+
+ it(`getSIWEStatementForPublicKey should generate expected statement`, () => {
+ const validPublicKey = 'rPFzRtV7E6v1b60zjTvghqb2xgnggmn6j4UaYccJYdo';
+ const expectedString =
+ `Device IdPubKey: rPFzRtV7E6v1b60zjTvghqb2xgnggmn6j4UaYccJYdo ` +
+ `By continuing, I accept the Comm Terms of Service: https://comm.app/terms`;
+ expect(
+ getSIWEStatementForPublicKey(validPublicKey) === expectedString,
+ ).toBe(true);
+ });
});

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 11, 1:51 AM (19 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2858241
Default Alt Text
D6129.diff (1 KB)

Event Timeline