File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import * as functions from 'firebase-functions';
33import * as blake2 from 'blake2' ;
44import bs58check from 'bs58check' ;
55import Client from 'mina-signer' ;
6+ import { submitterAllowed } from './submitterValidator' ;
67
78interface SignatureJson {
89 field : string ;
@@ -19,10 +20,6 @@ const minaClient = new Client({ network: 'testnet' });
1920
2021admin . initializeApp ( ) ;
2122
22- // base58 encoded public keys that are allowed to submit data
23- const allowedPublicKeys : Set < string > = new Set ( [
24- ] ) ;
25-
2623function validateSignature (
2724 data : string ,
2825 signature : SignatureJson ,
@@ -71,7 +68,7 @@ export const handleValidationAndStore = functions
7168 console . log ( 'Received data:' , data ) ;
7269 const { publicKey, data : inputData , signature } = data ;
7370
74- if ( ! allowedPublicKeys . has ( publicKey ) ) {
71+ if ( ! submitterAllowed ( publicKey ) ) {
7572 throw new functions . https . HttpsError (
7673 'permission-denied' ,
7774 'Public key not authorized'
Original file line number Diff line number Diff line change 1+ // base58 encoded public keys that are allowed to submit data
2+ const allowedPublicKeys : Set < string > = new Set ( [
3+ ] ) ;
4+
5+ export function submitterAllowed ( publicKeyBase58 : string ) : boolean {
6+ if ( allowedPublicKeys . size === 0 ) {
7+ return true ;
8+ }
9+ return allowedPublicKeys . has ( publicKeyBase58 ) ;
10+ }
You can’t perform that action at this time.
0 commit comments