@verdaccio/signature 7.0.0-next.0 → 7.0.0-next.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @verdaccio/signature
2
2
 
3
+ ## 7.0.0-next.1
4
+
5
+ ### Major Changes
6
+
7
+ - e7ebccb61: update major dependencies, remove old nodejs support
8
+
9
+ ### Minor Changes
10
+
11
+ - daceb6d87: restore legacy support
12
+
3
13
  ## 7.0.0-next.0
4
14
 
5
15
  ### Major Changes
@@ -1,4 +1,6 @@
1
- import { JWTSignOptions, RemoteUser } from '@verdaccio/types';
1
+ import { SignOptions } from 'jsonwebtoken';
2
+ import { RemoteUser } from '@verdaccio/types';
3
+ export type SignOptionsSignature = Pick<SignOptions, 'algorithm' | 'expiresIn' | 'notBefore'>;
2
4
  /**
3
5
  * Sign the payload and return JWT
4
6
  * https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback
@@ -6,5 +8,5 @@ import { JWTSignOptions, RemoteUser } from '@verdaccio/types';
6
8
  * @param secretOrPrivateKey
7
9
  * @param options
8
10
  */
9
- export declare function signPayload(payload: RemoteUser, secretOrPrivateKey: string, options?: JWTSignOptions): Promise<string>;
11
+ export declare function signPayload(payload: RemoteUser, secretOrPrivateKey: string, options?: SignOptionsSignature): Promise<string>;
10
12
  export declare function verifyPayload(token: string, secretOrPrivateKey: string): RemoteUser;
@@ -19,17 +19,20 @@ const debug = (0, _debug.default)('verdaccio:auth:token:jwt');
19
19
  async function signPayload(payload, secretOrPrivateKey, options = {}) {
20
20
  return new Promise(function (resolve, reject) {
21
21
  debug('sign jwt token');
22
- return _jsonwebtoken.default.sign(payload, secretOrPrivateKey,
22
+ _jsonwebtoken.default.sign(payload, secretOrPrivateKey,
23
23
  // FIXME: upgrade to the latest library and types
24
- // @ts-ignore
25
24
  {
26
25
  // 1 === 1ms (one millisecond)
27
26
  notBefore: '1',
28
27
  // Make sure the time will not rollback :)
29
28
  ...options
30
29
  }, (error, token) => {
31
- debug('error on sign jwt token');
32
- return error ? reject(error) : resolve(token);
30
+ if (error) {
31
+ debug('error on sign jwt token %s', error.message);
32
+ return reject(error);
33
+ }
34
+ debug('signed jwt token successfully');
35
+ return resolve(token);
33
36
  });
34
37
  });
35
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jwt-token.js","names":["_debug","_interopRequireDefault","require","_jsonwebtoken","obj","__esModule","default","debug","buildDebug","signPayload","payload","secretOrPrivateKey","options","Promise","resolve","reject","jwt","sign","notBefore","error","token","verifyPayload","verify"],"sources":["../src/jwt-token.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport jwt from 'jsonwebtoken';\n\nimport { JWTSignOptions, RemoteUser } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:auth:token:jwt');\n/**\n * Sign the payload and return JWT\n * https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback\n * @param payload\n * @param secretOrPrivateKey\n * @param options\n */\nexport async function signPayload(\n payload: RemoteUser,\n secretOrPrivateKey: string,\n options: JWTSignOptions = {}\n): Promise<string> {\n return new Promise(function (resolve, reject): Promise<string> {\n debug('sign jwt token');\n return jwt.sign(\n payload,\n secretOrPrivateKey,\n // FIXME: upgrade to the latest library and types\n // @ts-ignore\n {\n // 1 === 1ms (one millisecond)\n notBefore: '1', // Make sure the time will not rollback :)\n ...options,\n },\n (error, token: string) => {\n debug('error on sign jwt token');\n return error ? reject(error) : resolve(token);\n }\n );\n });\n}\n\nexport function verifyPayload(token: string, secretOrPrivateKey: string): RemoteUser {\n debug('verify jwt token');\n return jwt.verify(token, secretOrPrivateKey) as RemoteUser;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA+B,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAI/B,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,0BAA0B,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,WAAWA,CAC/BC,OAAmB,EACnBC,kBAA0B,EAC1BC,OAAuB,GAAG,CAAC,CAAC,EACX;EACjB,OAAO,IAAIC,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAmB;IAC7DR,KAAK,CAAC,gBAAgB,CAAC;IACvB,OAAOS,qBAAG,CAACC,IAAI,CACbP,OAAO,EACPC,kBAAkB;IAClB;IACA;IACA;MACE;MACAO,SAAS,EAAE,GAAG;MAAE;MAChB,GAAGN;IACL,CAAC,EACD,CAACO,KAAK,EAAEC,KAAa,KAAK;MACxBb,KAAK,CAAC,yBAAyB,CAAC;MAChC,OAAOY,KAAK,GAAGJ,MAAM,CAACI,KAAK,CAAC,GAAGL,OAAO,CAACM,KAAK,CAAC;IAC/C,CACF,CAAC;EACH,CAAC,CAAC;AACJ;AAEO,SAASC,aAAaA,CAACD,KAAa,EAAET,kBAA0B,EAAc;EACnFJ,KAAK,CAAC,kBAAkB,CAAC;EACzB,OAAOS,qBAAG,CAACM,MAAM,CAACF,KAAK,EAAET,kBAAkB,CAAC;AAC9C"}
1
+ {"version":3,"file":"jwt-token.js","names":["_debug","_interopRequireDefault","require","_jsonwebtoken","obj","__esModule","default","debug","buildDebug","signPayload","payload","secretOrPrivateKey","options","Promise","resolve","reject","jwt","sign","notBefore","error","token","message","verifyPayload","verify"],"sources":["../src/jwt-token.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport jwt, { SignOptions } from 'jsonwebtoken';\n\nimport { RemoteUser } from '@verdaccio/types';\n\nexport type SignOptionsSignature = Pick<SignOptions, 'algorithm' | 'expiresIn' | 'notBefore'>;\n\nconst debug = buildDebug('verdaccio:auth:token:jwt');\n/**\n * Sign the payload and return JWT\n * https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback\n * @param payload\n * @param secretOrPrivateKey\n * @param options\n */\nexport async function signPayload(\n payload: RemoteUser,\n secretOrPrivateKey: string,\n options: SignOptionsSignature = {}\n): Promise<string> {\n return new Promise(function (resolve, reject) {\n debug('sign jwt token');\n jwt.sign(\n payload,\n secretOrPrivateKey, // FIXME: upgrade to the latest library and types\n {\n // 1 === 1ms (one millisecond)\n notBefore: '1', // Make sure the time will not rollback :)\n ...options,\n },\n (error, token) => {\n if (error) {\n debug('error on sign jwt token %s', error.message);\n return reject(error);\n }\n debug('signed jwt token successfully');\n return resolve(token as string);\n }\n );\n });\n}\n\nexport function verifyPayload(token: string, secretOrPrivateKey: string): RemoteUser {\n debug('verify jwt token');\n return jwt.verify(token, secretOrPrivateKey) as RemoteUser;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAgD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAMhD,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,0BAA0B,CAAC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,WAAWA,CAC/BC,OAAmB,EACnBC,kBAA0B,EAC1BC,OAA6B,GAAG,CAAC,CAAC,EACjB;EACjB,OAAO,IAAIC,OAAO,CAAC,UAAUC,OAAO,EAAEC,MAAM,EAAE;IAC5CR,KAAK,CAAC,gBAAgB,CAAC;IACvBS,qBAAG,CAACC,IAAI,CACNP,OAAO,EACPC,kBAAkB;IAAE;IACpB;MACE;MACAO,SAAS,EAAE,GAAG;MAAE;MAChB,GAAGN;IACL,CAAC,EACD,CAACO,KAAK,EAAEC,KAAK,KAAK;MAChB,IAAID,KAAK,EAAE;QACTZ,KAAK,CAAC,4BAA4B,EAAEY,KAAK,CAACE,OAAO,CAAC;QAClD,OAAON,MAAM,CAACI,KAAK,CAAC;MACtB;MACAZ,KAAK,CAAC,+BAA+B,CAAC;MACtC,OAAOO,OAAO,CAACM,KAAe,CAAC;IACjC,CACF,CAAC;EACH,CAAC,CAAC;AACJ;AAEO,SAASE,aAAaA,CAACF,KAAa,EAAET,kBAA0B,EAAc;EACnFJ,KAAK,CAAC,kBAAkB,CAAC;EACzB,OAAOS,qBAAG,CAACO,MAAM,CAACH,KAAK,EAAET,kBAAkB,CAAC;AAC9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/signature",
3
- "version": "7.0.0-next.0",
3
+ "version": "7.0.0-next.1",
4
4
  "description": "verdaccio signature utils",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -29,13 +29,13 @@
29
29
  "node": ">=12"
30
30
  },
31
31
  "dependencies": {
32
- "jsonwebtoken": "9.0.0",
32
+ "jsonwebtoken": "9.0.2",
33
33
  "debug": "4.3.4",
34
34
  "lodash": "4.17.21"
35
35
  },
36
36
  "devDependencies": {
37
- "@verdaccio/config": "7.0.0-next.0",
38
- "@verdaccio/types": "12.0.0-next.0"
37
+ "@verdaccio/config": "7.0.0-next.3",
38
+ "@verdaccio/types": "12.0.0-next.1"
39
39
  },
40
40
  "funding": {
41
41
  "type": "opencollective",
package/src/jwt-token.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import buildDebug from 'debug';
2
- import jwt from 'jsonwebtoken';
2
+ import jwt, { SignOptions } from 'jsonwebtoken';
3
3
 
4
- import { JWTSignOptions, RemoteUser } from '@verdaccio/types';
4
+ import { RemoteUser } from '@verdaccio/types';
5
+
6
+ export type SignOptionsSignature = Pick<SignOptions, 'algorithm' | 'expiresIn' | 'notBefore'>;
5
7
 
6
8
  const debug = buildDebug('verdaccio:auth:token:jwt');
7
9
  /**
@@ -14,23 +16,25 @@ const debug = buildDebug('verdaccio:auth:token:jwt');
14
16
  export async function signPayload(
15
17
  payload: RemoteUser,
16
18
  secretOrPrivateKey: string,
17
- options: JWTSignOptions = {}
19
+ options: SignOptionsSignature = {}
18
20
  ): Promise<string> {
19
- return new Promise(function (resolve, reject): Promise<string> {
21
+ return new Promise(function (resolve, reject) {
20
22
  debug('sign jwt token');
21
- return jwt.sign(
23
+ jwt.sign(
22
24
  payload,
23
- secretOrPrivateKey,
24
- // FIXME: upgrade to the latest library and types
25
- // @ts-ignore
25
+ secretOrPrivateKey, // FIXME: upgrade to the latest library and types
26
26
  {
27
27
  // 1 === 1ms (one millisecond)
28
28
  notBefore: '1', // Make sure the time will not rollback :)
29
29
  ...options,
30
30
  },
31
- (error, token: string) => {
32
- debug('error on sign jwt token');
33
- return error ? reject(error) : resolve(token);
31
+ (error, token) => {
32
+ if (error) {
33
+ debug('error on sign jwt token %s', error.message);
34
+ return reject(error);
35
+ }
36
+ debug('signed jwt token successfully');
37
+ return resolve(token as string);
34
38
  }
35
39
  );
36
40
  });