@tmlmobilidade/external 20260709.1326.35 → 20260710.2205.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,7 @@
1
1
  /* * */
2
2
  import { Logger } from '@tmlmobilidade/logger';
3
- import { SshTunnelService } from '@tmlmobilidade/ssh';
3
+ import { goSshTunnel } from '@tmlmobilidade/ssh';
4
4
  import { asyncSingletonProxy } from '@tmlmobilidade/utils';
5
- import { readFileSync } from 'node:fs';
6
5
  import https from 'node:https';
7
6
  /* * */
8
7
  export class CPAuthClient {
@@ -122,41 +121,8 @@ export class CPAuthClient {
122
121
  if (!process.env.CP_AUTH_CLIENT_ID || !process.env.CP_AUTH_CLIENT_SECRET) {
123
122
  throw new Error('Missing CP_AUTH_CLIENT_ID or CP_AUTH_CLIENT_SECRET environment variables.');
124
123
  }
125
- if (!process.env.CP_TUNNEL_LOCAL_PORT) {
126
- throw new Error('Missing CP_TUNNEL_LOCAL_PORT environment variable.');
127
- }
128
- if (!process.env.CP_TUNNEL_SSH_HOST || !process.env.CP_TUNNEL_SSH_USERNAME) {
129
- throw new Error('Missing CP_TUNNEL_SSH_HOST or CP_TUNNEL_SSH_USERNAME environment variables.');
130
- }
131
- const sshConfig = {
132
- forwardOptions: {
133
- dstAddr: process.env.CP_AUTH_HOST,
134
- dstPort: 443,
135
- srcAddr: 'localhost',
136
- srcPort: Number(process.env.CP_TUNNEL_LOCAL_PORT),
137
- },
138
- serverOptions: {
139
- port: Number(process.env.CP_TUNNEL_LOCAL_PORT),
140
- },
141
- sshOptions: {
142
- agent: process.env.CP_TUNNEL_SSH_KEY_PATH ? undefined : process.env.SSH_AUTH_SOCK,
143
- host: process.env.CP_TUNNEL_SSH_HOST,
144
- keepaliveCountMax: 20,
145
- keepaliveInterval: 10_000,
146
- port: 22,
147
- privateKey: process.env.CP_TUNNEL_SSH_KEY_PATH ? readFileSync(process.env.CP_TUNNEL_SSH_KEY_PATH) : process.env.CP_TUNNEL_SSH_KEY,
148
- username: process.env.CP_TUNNEL_SSH_USERNAME,
149
- },
150
- tunnelOptions: {
151
- autoClose: false,
152
- reconnectOnError: true,
153
- },
154
- };
155
- const sshOptions = {
156
- maxRetries: 3,
157
- };
158
124
  if (!this.tunnel) {
159
- this.tunnel = new SshTunnelService(sshConfig, sshOptions);
125
+ this.tunnel = goSshTunnel({ dstAddr: process.env.CP_AUTH_HOST, dstPort: 443 });
160
126
  await this.tunnel.connect();
161
127
  }
162
128
  Logger.info({ message: '[CPAuthClient] Setting up SSH Tunnel...' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/external",
3
- "version": "20260709.1326.35",
3
+ "version": "20260710.2205.51",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"