@lighthouse/common 4.37.0-canary-13 → 4.37.0-canary-14

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.
@@ -15,15 +15,9 @@ function buildFetchUrl(url, options) {
15
15
  width,
16
16
  quality
17
17
  } = options;
18
- console.info('Building fetch URL', {
19
- url,
20
- cloudfrontBaseUrl,
21
- cloudinaryBaseUrl
22
- });
23
18
  const shouldUseCloudfront = cloudfrontBaseUrl && cloudfrontBaseUrl.includes('.cloudfront.net');
24
19
 
25
20
  if (shouldUseCloudfront) {
26
- console.info('Using CloudFront base URL', cloudfrontBaseUrl);
27
21
  const transformations = [];
28
22
  if (width) transformations.push(`width=${width.toString()}`);
29
23
  if (height) transformations.push(`height=${height.toString()}`);
@@ -9,9 +9,10 @@ exports.generateCloudFrontJWT = generateCloudFrontJWT;
9
9
 
10
10
  var _awsSdk = _interopRequireDefault(require("aws-sdk"));
11
11
 
12
- const region = process.env.AWS_REGION || 'us-east-1';
12
+ const JWT_GENERATION_LAMBDA_ARN = process.env.JWT_GENERATION_LAMBDA_ARN;
13
+ const REGION = process.env.AWS_REGION;
13
14
  const lambda = new _awsSdk.default.Lambda({
14
- region
15
+ region: REGION
15
16
  });
16
17
 
17
18
  async function generateCloudFrontJWT(applicationId) {
@@ -20,7 +21,7 @@ async function generateCloudFrontJWT(applicationId) {
20
21
  }
21
22
 
22
23
  const params = {
23
- FunctionName: `arn:aws:lambda:${region}:649076221710:function:image-optimisation-jwt-generation`,
24
+ FunctionName: JWT_GENERATION_LAMBDA_ARN,
24
25
  InvocationType: 'RequestResponse',
25
26
  Payload: JSON.stringify({
26
27
  applicationId
@@ -29,12 +30,7 @@ async function generateCloudFrontJWT(applicationId) {
29
30
 
30
31
  try {
31
32
  const result = await lambda.invoke(params).promise();
32
- console.dir(result, {
33
- depth: null
34
- });
35
- console.info('GenerateCloudFrontJWT: Raw Lambda result:', result);
36
33
  const response = JSON.parse(result.Payload);
37
- console.info('GenerateCloudFrontJWT: Parsed Lambda response:', response);
38
34
  return {
39
35
  expiration: response.expiration,
40
36
  token: response.token
@@ -7,15 +7,9 @@ export function buildFetchUrl(url, options) {
7
7
  height = options.height,
8
8
  width = options.width,
9
9
  quality = options.quality;
10
- console.info('Building fetch URL', {
11
- url: url,
12
- cloudfrontBaseUrl: cloudfrontBaseUrl,
13
- cloudinaryBaseUrl: cloudinaryBaseUrl
14
- });
15
10
  var shouldUseCloudfront = cloudfrontBaseUrl && cloudfrontBaseUrl.includes('.cloudfront.net');
16
11
 
17
12
  if (shouldUseCloudfront) {
18
- console.info('Using CloudFront base URL', cloudfrontBaseUrl);
19
13
  var _transformations = [];
20
14
  if (width) _transformations.push("width=".concat(width.toString()));
21
15
  if (height) _transformations.push("height=".concat(height.toString()));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/helpers/build-fetch-url/index.js"],"names":["buildFetchUrl","url","options","awsS3BaseUrl","cloudfrontBaseUrl","cloudinaryBaseUrl","fit","height","width","quality","console","info","shouldUseCloudfront","includes","transformations","push","toString","transformationsString","join","fetchUrl"],"mappings":"AAAA,OAAO,SAASA,aAAT,CAAuBC,GAAvB,EAA4BC,OAA5B,EAAqC;AAAA,MAExCC,YAFwC,GAStCD,OATsC,CAExCC,YAFwC;AAAA,8BAStCD,OATsC,CAGxCE,iBAHwC;AAAA,MAGxCA,iBAHwC,sCAGpB,EAHoB;AAAA,MAIxCC,iBAJwC,GAStCH,OATsC,CAIxCG,iBAJwC;AAAA,MAKxCC,GALwC,GAStCJ,OATsC,CAKxCI,GALwC;AAAA,MAMxCC,MANwC,GAStCL,OATsC,CAMxCK,MANwC;AAAA,MAOxCC,KAPwC,GAStCN,OATsC,CAOxCM,KAPwC;AAAA,MAQxCC,OARwC,GAStCP,OATsC,CAQxCO,OARwC;AAW1CC,EAAAA,OAAO,CAACC,IAAR,CAAa,oBAAb,EAAmC;AACjCV,IAAAA,GAAG,EAAHA,GADiC;AAEjCG,IAAAA,iBAAi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AAnD,cAAmEF,GAAnE,CAAd;AAEA,SAAOkB,QAAP;AACD","sourcesContent":["export function buildFetchUrl(url, options) {\n const {\n awsS3BaseUrl,\n cloudfrontBaseUrl = '',\n cloudinaryBaseUrl,\n fit,\n height,\n width,\n quality,\n } = options\n\n console.info('Building fetch URL', {\n url,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n })\n\n const shouldUseCloudfront =\n cloudfrontBaseUrl && cloudfrontBaseUrl.includes('.cloudfront.net')\n\n if (shouldUseCloudfront) {\n console.info('Using CloudFront base URL', cloudfrontBaseUrl)\n const transformations = []\n\n if (width) transformations.push(`width=${width.toString()}`)\n if (height) transformations.push(`height=${height.toString()}`)\n if (quality) transformations.push(`quality=${quality.toString()}`)\n transformations.push(`fit=contain`)\n\n const transformationsString = transformations.join(',')\n\n const fetchUrl = `${cloudfrontBaseUrl}/${url}?${transformationsString}`\n return fetchUrl\n }\n\n const transformations = []\n let transformationsString = ''\n\n if (width) transformations.push(`w_${width.toString()}`)\n if (height) transformations.push(`h_${height.toString()}`)\n if (quality) transformations.push(`q_${quality.toString()}`)\n if (fit) transformations.push('c_fit')\n\n transformationsString = `${transformations.join(',')}/`\n\n const fetchUrl = `${cloudinaryBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`\n\n return fetchUrl\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/helpers/build-fetch-url/index.js"],"names":["buildFetchUrl","url","options","awsS3BaseUrl","cloudfrontBaseUrl","cloudinaryBaseUrl","fit","height","width","quality","shouldUseCloudfront","includes","transformations","push","toString","transformationsString","join","fetchUrl"],"mappings":"AAAA,OAAO,SAASA,aAAT,CAAuBC,GAAvB,EAA4BC,OAA5B,EAAqC;AAAA,MAExCC,YAFwC,GAStCD,OATsC,CAExCC,YAFwC;AAAA,8BAStCD,OATsC,CAGxCE,iBAHwC;AAAA,MAGxCA,iBAHwC,sCAGpB,EAHoB;AAAA,MAIxCC,iBAJwC,GAStCH,OATsC,CAIxC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AArB,CAAN,MAArB;AAEA,MAAMC,QAAQ,aAAMZ,iBAAN,cAA2BU,qBAA3B,SAAmDZ,YAAnD,cAAmEF,GAAnE,CAAd;AAEA,SAAOgB,QAAP;AACD","sourcesContent":["export function buildFetchUrl(url, options) {\n const {\n awsS3BaseUrl,\n cloudfrontBaseUrl = '',\n cloudinaryBaseUrl,\n fit,\n height,\n width,\n quality,\n } = options\n\n const shouldUseCloudfront =\n cloudfrontBaseUrl && cloudfrontBaseUrl.includes('.cloudfront.net')\n\n if (shouldUseCloudfront) {\n const transformations = []\n\n if (width) transformations.push(`width=${width.toString()}`)\n if (height) transformations.push(`height=${height.toString()}`)\n if (quality) transformations.push(`quality=${quality.toString()}`)\n transformations.push(`fit=contain`)\n\n const transformationsString = transformations.join(',')\n\n const fetchUrl = `${cloudfrontBaseUrl}/${url}?${transformationsString}`\n return fetchUrl\n }\n\n const transformations = []\n let transformationsString = ''\n\n if (width) transformations.push(`w_${width.toString()}`)\n if (height) transformations.push(`h_${height.toString()}`)\n if (quality) transformations.push(`q_${quality.toString()}`)\n if (fit) transformations.push('c_fit')\n\n transformationsString = `${transformations.join(',')}/`\n\n const fetchUrl = `${cloudinaryBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`\n\n return fetchUrl\n}\n"],"file":"index.js"}
@@ -1,9 +1,10 @@
1
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import AWS from 'aws-sdk';
4
- var region = process.env.AWS_REGION || 'us-east-1';
4
+ var JWT_GENERATION_LAMBDA_ARN = process.env.JWT_GENERATION_LAMBDA_ARN;
5
+ var REGION = process.env.AWS_REGION;
5
6
  var lambda = new AWS.Lambda({
6
- region: region
7
+ region: REGION
7
8
  });
8
9
  export function generateCloudFrontJWT(_x) {
9
10
  return _generateCloudFrontJWT.apply(this, arguments);
@@ -25,7 +26,7 @@ function _generateCloudFrontJWT() {
25
26
 
26
27
  case 2:
27
28
  params = {
28
- FunctionName: "arn:aws:lambda:".concat(region, ":649076221710:function:image-optimisation-jwt-generation"),
29
+ FunctionName: JWT_GENERATION_LAMBDA_ARN,
29
30
  InvocationType: 'RequestResponse',
30
31
  Payload: JSON.stringify({
31
32
  applicationId: applicationId
@@ -37,29 +38,24 @@ function _generateCloudFrontJWT() {
37
38
 
38
39
  case 6:
39
40
  result = _context.sent;
40
- console.dir(result, {
41
- depth: null
42
- });
43
- console.info('GenerateCloudFrontJWT: Raw Lambda result:', result);
44
41
  response = JSON.parse(result.Payload);
45
- console.info('GenerateCloudFrontJWT: Parsed Lambda response:', response);
46
42
  return _context.abrupt("return", {
47
43
  expiration: response.expiration,
48
44
  token: response.token
49
45
  });
50
46
 
51
- case 14:
52
- _context.prev = 14;
47
+ case 11:
48
+ _context.prev = 11;
53
49
  _context.t0 = _context["catch"](3);
54
50
  console.error('Error invoking JWT Lambda:', _context.t0);
55
51
  throw new Error('Failed to generate CloudFront JWT');
56
52
 
57
- case 18:
53
+ case 15:
58
54
  case "end":
59
55
  return _context.stop();
60
56
  }
61
57
  }
62
- }, _callee, null, [[3, 14]]);
58
+ }, _callee, null, [[3, 11]]);
63
59
  }));
64
60
  return _generateCloudFrontJWT.apply(this, arguments);
65
61
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/helpers/generate-cloudfront-jwt/index.js"],"names":["AWS","region","process","env","AWS_REGION","lambda","Lambda","generateCloudFrontJWT","applicationId","Error","params","FunctionName","InvocationType","Payload","JSON","stringify","invoke","promise","result","console","dir","depth","info","response","parse","expiration","token","error"],"mappings":";;AAAA,OAAOA,GAAP,MAAgB,SAAhB;AAEA,IAAMC,MAAM,GAAGC,OAAO,CAACC,GAAR,CAAYC,UAAZ,IAA0B,WAAzC;AACA,IAAMC,MAAM,GAAG,IAAIL,GAAG,CAACM,MAAR,CAAe;AAC5BL,EAAAA,MAAM,EAANA;AAD4B,CAAf,CAAf;AAIA,gBAAsBM,qBAAtB;AAAA;AAAA;;;oFAAO,iBAAqCC,aAArC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBACAA,aADA;AAAA;AAAA;AAAA;;AAAA,kBAEG,IAAIC,KAAJ,CAAU,yDAAV,CAFH;;AAAA;AAKCC,YAAAA,MALD,GAKU;AACbC,cAAAA,YAAY,2BAAoBV,MAApB,6DADC;AAEbW,cAAAA,cAAc,EAAE,iBAFH;AAGbC,cAAAA,OAAO,EAAEC,IAAI,CAACC,SAAL,CAAe;AAAEP,gBAAAA,aAAa,EAAbA;AAAF,eAAf;AAHI,aALV;AAAA;AAAA;AAAA,mBAYkBH,MAAM,CAACW,MAAP,CAAcN,MAAd,EAAsBO,OAAtB,EAZlB;;AAAA;AAYGC,YAAAA,MAZH;AAcHC,YAAAA,OAAO,CAACC,GAAR,CAAYF,MAAZ,EAAoB;AAAEG,cAAAA,KAAK,EAAE;AAAT,aAApB;AACAF,YAAAA,OAAO,CAACG,IAAR,CAAa,2CAAb,EAA0DJ,MAA1D;AAEMK,YAAAA,QAjBH,GAiBcT,IAAI,CAACU,KAAL,CAAWN,MAAM,CAACL,OAAlB,CAjBd;AAkBHM,YAAAA,OAAO,CAACG,IAAR,CAAa,gDAAb,EAA+DC,QAA/D;AAlBG,6CAoBI;AACLE,cAAAA,UAAU,EAAEF,QAAQ,CAACE,UADhB;AAELC,cAAAA,KAAK,EAAEH,QAAQ,CAACG;AAFX,aApBJ;;AAAA;AAAA;AAAA;AAyBHP,YAAAA,OAAO,CAACQ,KAAR,CAAc,4BAAd;AAzBG,kBA0BG,IAAIlB,KAAJ,CAAU,mCAAV,CA1BH;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import AWS from 'aws-sdk'\n\nconst region = process.env.AWS_REGION || 'us-east-1'\nconst lambda = new AWS.Lambda({\n region,\n})\n\nexport async function generateCloudFrontJWT(applicationId) {\n if (!applicationId) {\n throw new Error('applicationId is required for CloudFront JWT generation')\n }\n\n const params = {\n FunctionName: `arn:aws:lambda:${region}:649076221710:function:image-optimisation-jwt-generation`,\n InvocationType: 'RequestResponse',\n Payload: JSON.stringify({ applicationId }),\n }\n\n try {\n const result = await lambda.invoke(params).promise()\n\n console.dir(result, { depth: null })\n console.info('GenerateCloudFrontJWT: Raw Lambda result:', result)\n\n const response = JSON.parse(result.Payload)\n console.info('GenerateCloudFrontJWT: Parsed Lambda response:', response)\n\n return {\n expiration: response.expiration,\n token: response.token,\n }\n } catch (error) {\n console.error('Error invoking JWT Lambda:', error)\n throw new Error('Failed to generate CloudFront JWT')\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/helpers/generate-cloudfront-jwt/index.js"],"names":["AWS","JWT_GENERATION_LAMBDA_ARN","process","env","REGION","AWS_REGION","lambda","Lambda","region","generateCloudFrontJWT","applicationId","Error","params","FunctionName","InvocationType","Payload","JSON","stringify","invoke","promise","result","response","parse","expiration","token","console","error"],"mappings":";;AAAA,OAAOA,GAAP,MAAgB,SAAhB;AAEA,IAAMC,yBAAyB,GAAGC,OAAO,CAACC,GAAR,CAAYF,yBAA9C;AACA,IAAMG,MAAM,GAAGF,OAAO,CAACC,GAAR,CAAYE,UAA3B;AACA,IAAMC,MAAM,GAAG,IAAIN,GAAG,CAACO,MAAR,CAAe;AAC5BC,EAAAA,MAAM,EAAEJ;AADoB,CAAf,CAAf;AAIA,gBAAsBK,qBAAtB;AAAA;AAAA;;;oFAAO,iBAAqCC,aAArC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBACAA,aADA;AAAA;AAAA;AAAA;;AAAA,kBAEG,IAAIC,KAAJ,CAAU,yDAAV,CAFH;;AAAA;AAKCC,YAAAA,MALD,GAKU;AACbC,cAAAA,YAAY,EAAEZ,yBADD;AAEba,cAAAA,cAAc,EAAE,iBAFH;AAGbC,cAAAA,OAAO,EAAEC,IAAI,CAACC,SAAL,CAAe;AAAEP,gBAAAA,aAAa,EAAbA;AAAF,eAAf;AAHI,aALV;AAAA;AAAA;AAAA,mBAYkBJ,MAAM,CAACY,MAAP,CAAcN,MAAd,EAAsBO,OAAtB,EAZlB;;AAAA;AAYGC,YAAAA,MAZH;AAcGC,YAAAA,QAdH,GAccL,IAAI,CAACM,KAAL,CAAWF,MAAM,CAACL,OAAlB,CAdd;AAAA,6CAgBI;AACLQ,cAAAA,UAAU,EAAEF,QAAQ,CAACE,UADhB;AAELC,cAAAA,KAAK,EAAEH,QAAQ,CAACG;AAFX,aAhBJ;;AAAA;AAAA;AAAA;AAqBHC,YAAAA,OAAO,CAACC,KAAR,CAAc,4BAAd;AArBG,kBAsBG,IAAIf,KAAJ,CAAU,mCAAV,CAtBH;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import AWS from 'aws-sdk'\n\nconst JWT_GENERATION_LAMBDA_ARN = process.env.JWT_GENERATION_LAMBDA_ARN\nconst REGION = process.env.AWS_REGION\nconst lambda = new AWS.Lambda({\n region: REGION,\n})\n\nexport async function generateCloudFrontJWT(applicationId) {\n if (!applicationId) {\n throw new Error('applicationId is required for CloudFront JWT generation')\n }\n\n const params = {\n FunctionName: JWT_GENERATION_LAMBDA_ARN,\n InvocationType: 'RequestResponse',\n Payload: JSON.stringify({ applicationId }),\n }\n\n try {\n const result = await lambda.invoke(params).promise()\n\n const response = JSON.parse(result.Payload)\n\n return {\n expiration: response.expiration,\n token: response.token,\n }\n } catch (error) {\n console.error('Error invoking JWT Lambda:', error)\n throw new Error('Failed to generate CloudFront JWT')\n }\n}\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lighthouse/common",
3
- "version": "4.37.0-canary-13",
3
+ "version": "4.37.0-canary-14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib/index.js",