• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FieldDB / AuthenticationWebService / 19936671137

04 Dec 2025 04:45PM UTC coverage: 24.852% (-51.5%) from 76.331%
19936671137

Pull #100

github

web-flow
Merge a4ec967ff into c246fc2cb
Pull Request #100: upgrade couchdb to 3.1.2

119 of 963 branches covered (12.36%)

Branch coverage included in aggregate %.

595 of 1910 relevant lines covered (31.15%)

0.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.11
/lib/token.js
1
const fs = require('fs');
1✔
2
const path = require('path');
1✔
3
// install jsonwebtoken if this is used
4
// eslint-disable-next-line  import/no-extraneous-dependencies
5
const jsonwebtoken = require('jsonwebtoken');
1✔
6

7
const publicKey = require('../config/jwt_debug.pub');
1✔
8
// Include a smaple debugging key for tests
9
const testPrivateKey = fs.readFileSync(path.join(__dirname, '/../config/jwt_debug.pem'), 'utf8');
1✔
10
const testPublicKey = require('../config/jwt_debug.pub');
1✔
11

12
const AsToken = {
1✔
13
  config: {
14
    jwt: {
15
      algorithm: 'RS256',
16
      prefix: 'v1/',
17
      public: publicKey,
18
      private: testPrivateKey,
19
    },
20
    test: {
21
      private: testPrivateKey,
22
      public: testPublicKey,
23
    },
24
  },
25
  jsonwebtoken,
26
  sign: function sign(json, expiresIn) {
27
    if (!json) {
×
28
      throw new Error('Cannot sign empty value');
×
29
    }
30

31
    return this.config.jwt.prefix + jsonwebtoken.sign(json, this.config.jwt.private, {
×
32
      algorithm: this.config.jwt.algorithm,
33
      expiresIn: expiresIn === undefined ? 60 : expiresIn, // minutes
×
34
    });
35
  },
36
  verify: function verify(tokenString) {
37
    const token = tokenString
×
38
      .replace(/bearer +/i, '')
39
      .replace(this.config.jwt.prefix, '');
40

41
    return jsonwebtoken.verify(token, this.config.test.public, {
×
42
      algorithm: this.config.jwt.algorithm,
43
    });
44
  },
45
  decode: function decode(tokenString) {
46
    const token = tokenString
×
47
      .replace(/bearer +/i, '')
48
      .replace(this.config.jwt.prefix, '');
49

50
    return jsonwebtoken.decode(token, this.config.test.public, {
×
51
      algorithm: this.config.jwt.algorithm,
52
    });
53
  },
54
};
55

56
module.exports = AsToken;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc