Skip to content

Commit

Permalink
feat: improve security by moving from anonymous tls to mutual tls
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhermeasper committed Aug 23, 2024
1 parent 3103f69 commit cd944a4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/services/marquinhosApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import axios from 'axios';
import { readFileSync } from 'fs';
import { Agent } from 'https';
import { join } from 'path';
import { LastfmTopListenedPeriod, PlaybackData } from '@marquinhos/types';

const httpsAgent = new Agent({
cert:
process.env.NODE_ENV === 'production'
? readFileSync(join(__dirname, '/etc/ssl/certificate.pem'))
: undefined,
key:
process.env.NODE_ENV === 'production'
? readFileSync(join(__dirname, '/etc/ssl/private.pem'))
: undefined,
rejectUnauthorized: process.env.NODE_ENV === 'production',
});

axios.defaults.httpsAgent = httpsAgent;

export class MarquinhosApiService {
async addToScrobbleQueue(playbackData: PlaybackData) {
const options = {
Expand Down

0 comments on commit cd944a4

Please sign in to comment.