GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update all dependencies, add build (#128) · firebase/quickstart-nodejs@9c760ab

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • node.yml
  • .gitignore
  • auth-sessions
    • .gitignore
    • README.md
    • app.js
    • config.js
    • package-lock.json
    • package.json
    • script.js
    • webpack.config.js
  • config
    • index.js
    • package-lock.json
    • package.json
  • database
    • index.js
    • package-lock.json
    • package.json
  • lerna.json
  • machine-learning
    • manage-ml.js
    • package-lock.json
    • package.json
  • messaging
    • .gitignore
    • README.md
    • index.js
    • package-lock.json
    • package.json
  • package-lock.json
  • package.json
  • placeholders
    • service-account.json
  • scripts
    • test.sh
  • tsconfig.json.template
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/node.yml‎

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI Tests
2+
3+
on:
4+
- pull_request
5+
- push
6+
7+
env:
8+
CI: true
9+
10+
jobs:
11+
unit:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version:
16+
- 8.x
17+
- 10.x
18+
steps:
19+
- uses: actions/checkout@v1
20+
- uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
24+
- name: Cache npm
25+
uses: actions/cache@v1
26+
with:
27+
path: ~/.npm
28+
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
29+
30+
- run: npm install
31+
32+
- name: "Lint and Test"
33+
run: ./scripts/test.sh
Collapse file

‎.gitignore‎

Copy file name to clipboard
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
**/secrets.json
2-
**/firebase-debug.log
3-
**/firestore-debug.log
4-
**/package-lock.json
2+
*-debug.log
53
**/node_modules
6-
**/bower_components
74
**/*.bak
85
.idea
96

10-
database-debug.log
11-
firestore-debug.log
7+
*/tsconfig.json
Collapse file

‎auth-sessions/.gitignore‎

Copy file name to clipboardExpand all lines: auth-sessions/.gitignore
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ public/bundle.js
1212
# Local config.
1313
**/.firebaserc
1414
serviceAccountKeys.json
15-
config.js
Collapse file

‎auth-sessions/README.md‎

Copy file name to clipboardExpand all lines: auth-sessions/README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Enable the **Google** and **Email/Password** sign-in providers in the
3737
In the root folder `./auth-sessions`, create a `config.js` file:
3838

3939
```javascript
40-
var config = {
40+
const config = {
4141
apiKey: "...",
4242
authDomain: "...",
4343
databaseURL: "...",
Collapse file

‎auth-sessions/app.js‎

Copy file name to clipboardExpand all lines: auth-sessions/app.js
+15-17Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,25 @@
1212
* limitations under the License.
1313
*/
1414

15-
var express = require('express');
16-
var cookieParser = require('cookie-parser')
17-
var http = require('http');
18-
var https = require('https');
19-
var app = express();
20-
var admin = require('firebase-admin');
21-
var bodyParser = require('body-parser');
15+
const express = require('express');
16+
const cookieParser = require('cookie-parser')
17+
const app = express();
18+
const admin = require('firebase-admin');
19+
const bodyParser = require('body-parser');
2220

2321
/**
2422
* Renders the profile page and serves it in the response.
2523
* @param {string} endpoint The get profile endpoint.
2624
* @param {!Object} req The expressjs request.
2725
* @param {!Object} res The expressjs response.
28-
* @param {!firebase.auth.DecodedIdToken} decodedClaims The decoded claims from verified
26+
* @param {!admin.auth.DecodedIdToken} decodedClaims The decoded claims from verified
2927
* session cookies.
3028
* @return {!Promise} A promise that resolves on success.
3129
*/
3230
function serveContentForUser(endpoint, req, res, decodedClaims) {
3331
// Lookup the user information corresponding to cookie and return the profile data for the user.
3432
return admin.auth().getUser(decodedClaims.sub).then(function(userRecord) {
35-
var html = '<!DOCTYPE html>' +
33+
const html = '<!DOCTYPE html>' +
3634
'<html>' +
3735
'<meta charset="UTF-8">' +
3836
'<link href="style.css" rel="stylesheet" type="text/css" media="screen" />' +
@@ -96,7 +94,7 @@ function attachCsrfToken(url, cookie, value) {
9694
function checkIfSignedIn(url) {
9795
return function(req, res, next) {
9896
if (req.url == url) {
99-
var sessionCookie = req.cookies.session || '';
97+
const sessionCookie = req.cookies.session || '';
10098
// User already logged in. Redirect to profile page.
10199
admin.auth().verifySessionCookie(sessionCookie).then(function(decodedClaims) {
102100
res.redirect('/profile');
@@ -131,7 +129,7 @@ app.use('/', express.static('public'));
131129
/** Get profile endpoint. */
132130
app.get('/profile', function (req, res) {
133131
// Get session cookie.
134-
var sessionCookie = req.cookies.session || '';
132+
const sessionCookie = req.cookies.session || '';
135133
// Get the session cookie and verify it. In this case, we are verifying if the
136134
// Firebase session was revoked, user deleted/disabled, etc.
137135
admin.auth().verifySessionCookie(sessionCookie, true /** check if revoked. */)
@@ -147,16 +145,16 @@ app.get('/profile', function (req, res) {
147145
/** Session login endpoint. */
148146
app.post('/sessionLogin', function (req, res) {
149147
// Get ID token and CSRF token.
150-
var idToken = req.body.idToken.toString();
151-
var csrfToken = req.body.csrfToken.toString();
148+
const idToken = req.body.idToken.toString();
149+
const csrfToken = req.body.csrfToken.toString();
152150

153151
// Guard against CSRF attacks.
154152
if (!req.cookies || csrfToken !== req.cookies.csrfToken) {
155153
res.status(401).send('UNAUTHORIZED REQUEST!');
156154
return;
157155
}
158156
// Set session expiration to 5 days.
159-
var expiresIn = 60 * 60 * 24 * 5 * 1000;
157+
const expiresIn = 60 * 60 * 24 * 5 * 1000;
160158
// Create the session cookie. This will also verify the ID token in the process.
161159
// The session cookie will have the same claims as the ID token.
162160
// We could also choose to enforce that the ID token auth_time is recent.
@@ -170,7 +168,7 @@ app.post('/sessionLogin', function (req, res) {
170168
.then(function(sessionCookie) {
171169
// Note httpOnly cookie will not be accessible from javascript.
172170
// secure flag should be set to true in production.
173-
var options = {maxAge: expiresIn, httpOnly: true, secure: false /** to test in localhost */};
171+
const options = {maxAge: expiresIn, httpOnly: true, secure: false /** to test in localhost */};
174172
res.cookie('session', sessionCookie, options);
175173
res.end(JSON.stringify({status: 'success'}));
176174
})
@@ -182,7 +180,7 @@ app.post('/sessionLogin', function (req, res) {
182180
/** User signout endpoint. */
183181
app.get('/logout', function (req, res) {
184182
// Clear cookie.
185-
var sessionCookie = req.cookies.session || '';
183+
const sessionCookie = req.cookies.session || '';
186184
res.clearCookie('session');
187185
// Revoke session too. Note this will revoke all user sessions.
188186
if (sessionCookie) {
@@ -205,7 +203,7 @@ app.get('/logout', function (req, res) {
205203

206204
/** User delete endpoint. */
207205
app.get('/delete', function (req, res) {
208-
var sessionCookie = req.cookies.session || '';
206+
const sessionCookie = req.cookies.session || '';
209207
res.clearCookie('session');
210208
if (sessionCookie) {
211209
// Verify user and then delete the user.
Collapse file

‎auth-sessions/config.js‎

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const config = {
2+
apiKey: "REPLACE ME",
3+
authDomain: "REPLACE ME",
4+
databaseURL: "REPLACE ME",
5+
storageBucket: "REPLACE ME",
6+
messagingSenderId: "REPLACE ME"
7+
};
8+
module.exports = config;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.