Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3753347
D6129.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
D6129.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D6129: [lib] Introduce `getSIWEStatementForPublicKey(...)`
Attached
Detach File
Event Timeline
Log In to Comment