@@ -3,13 +3,15 @@ const { Expo } = require("expo-server-sdk");
33const bodyParser = require ( 'body-parser' ) ;
44const cors = require ( 'cors' ) ;
55
6- let savedPushTokens = [ ] ;
76const expo = new Expo ( ) ;
87const app = express ( ) ;
98
109const path = require ( 'path' )
1110require ( 'dotenv' ) . config ( { path : path . resolve ( __dirname , '/.env' ) } )
1211
12+ let savedPushTokens = [ ] ;
13+ let notification_array = [ ] ;
14+
1315var port = process . env . port || 8080 ;
1416var username = process . env . username || 'xss' ;
1517var password = process . env . password || 'bomb' ;
@@ -64,7 +66,6 @@ app.listen(port, function() {
6466app . post ( "/token" , ( req , res ) => {
6567 if ( req . body . token == undefined || req . body . username == undefined ||
6668 req . body . password == undefined ) {
67- console . log ( "here" ) ;
6869 res . send ( { data : "ko" } ) ;
6970 return
7071 }
@@ -73,20 +74,36 @@ app.post("/token", (req, res) => {
7374 res . send ( { data : "ok" } ) ;
7475} ) ;
7576
77+ app . post ( "/notifications" , ( req , res ) => {
78+ if ( req . body . username == undefined || req . body . password == undefined ) {
79+ res . send ( { data : "ko" } ) ;
80+ return
81+ }
82+ res . send ( notification_array ) ;
83+ } ) ;
84+
7685app . post ( "/message" , ( req , res ) => {
7786 handlePushTokens ( req . body ) ;
87+ notification_array . push ( {
88+ 'route' : '/message' ,
89+ 'content' : req . body ,
90+ 'user-agent' : req . headers [ 'user-agent' ]
91+ } ) ;
7892 console . log ( `Received message, with title: ${ req . body . title } ` ) ;
7993 res . send ( `Received message, with title: ${ req . body . title } ` ) ;
8094} ) ;
8195
8296app . get ( "/stager" , ( req , res ) => {
83- console . log ( req . headers [ 'user-agent' ] ) ;
84- handlePushTokens ( { title : "xss - stager" , body : req . headers [ 'user-agent' ] } ) ;
97+ console . log ( req . headers ) ;
8598 res . sendFile ( __dirname + "/public/stager.js" ) ;
8699} ) ;
87100
88101app . get ( "/pic" , ( req , res ) => {
89- console . log ( req . headers [ 'user-agent' ] ) ;
102+ notification_array . push ( {
103+ 'route' : '/pic' ,
104+ 'content' : undefined ,
105+ 'user-agent' : req . headers [ 'user-agent' ]
106+ } ) ;
90107 handlePushTokens ( { title : "xss - picture" , body : req . headers [ 'user-agent' ] } ) ;
91108 res . sendFile ( __dirname + "/public/1px.png" ) ;
92109} ) ;
0 commit comments