@salesforce/pwa-kit-runtime 3.9.0-nightly-20241209080219 → 4.0.0-extensibility-preview.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.
Files changed (82) hide show
  1. package/package.json +9 -7
  2. package/ssr/server/build-remote-server.d.ts +211 -0
  3. package/ssr/server/build-remote-server.d.ts.map +1 -0
  4. package/ssr/server/build-remote-server.js +11 -78
  5. package/ssr/server/build-remote-server.test.js +139 -72
  6. package/ssr/server/constants.d.ts +18 -0
  7. package/ssr/server/constants.d.ts.map +1 -0
  8. package/ssr/server/constants.js +1 -2
  9. package/ssr/server/express.d.ts +17 -0
  10. package/ssr/server/express.d.ts.map +1 -0
  11. package/ssr/server/express.test.js +7 -91
  12. package/ssr/server/test_fixtures/extensions/another-extension/setup-server.d.ts +5 -0
  13. package/ssr/server/test_fixtures/extensions/another-extension/setup-server.d.ts.map +1 -0
  14. package/ssr/server/test_fixtures/extensions/another-extension/setup-server.js +19 -0
  15. package/ssr/server/test_fixtures/extensions/extension-with-bad-setup-server/setup-server.d.ts +5 -0
  16. package/ssr/server/test_fixtures/extensions/extension-with-bad-setup-server/setup-server.d.ts.map +1 -0
  17. package/ssr/server/test_fixtures/extensions/extension-with-bad-setup-server/setup-server.js +16 -0
  18. package/ssr/server/test_fixtures/extensions/extension-with-setup-server-no-default-export/setup-server.d.ts +2 -0
  19. package/ssr/server/test_fixtures/extensions/extension-with-setup-server-no-default-export/setup-server.d.ts.map +1 -0
  20. package/ssr/server/test_fixtures/extensions/extension-with-setup-server-no-default-export/setup-server.js +17 -0
  21. package/ssr/server/test_fixtures/extensions/extension-without-setup-server/random-file.d.ts +1 -0
  22. package/ssr/server/test_fixtures/extensions/extension-without-setup-server/random-file.d.ts.map +1 -0
  23. package/ssr/server/test_fixtures/extensions/extension-without-setup-server/random-file.js +7 -0
  24. package/ssr/server/test_fixtures/extensions/test-extension/setup-server.d.ts +5 -0
  25. package/ssr/server/test_fixtures/extensions/test-extension/setup-server.d.ts.map +1 -0
  26. package/ssr/server/test_fixtures/extensions/test-extension/setup-server.js +28 -0
  27. package/ssr/server/test_fixtures/main.d.ts +1 -0
  28. package/ssr/server/test_fixtures/main.d.ts.map +1 -0
  29. package/ssr/server/test_fixtures/server-renderer.d.ts +6 -0
  30. package/ssr/server/test_fixtures/server-renderer.d.ts.map +1 -0
  31. package/ssr/server/test_fixtures/worker.d.ts +1 -0
  32. package/ssr/server/test_fixtures/worker.d.ts.map +1 -0
  33. package/utils/logger-factory.d.ts +58 -0
  34. package/utils/logger-factory.d.ts.map +1 -0
  35. package/utils/logger-instance.d.ts +3 -0
  36. package/utils/logger-instance.d.ts.map +1 -0
  37. package/utils/middleware/index.d.ts +2 -0
  38. package/utils/middleware/index.d.ts.map +1 -0
  39. package/utils/middleware/security.d.ts +2 -0
  40. package/utils/middleware/security.d.ts.map +1 -0
  41. package/utils/morgan-stream.d.ts +11 -0
  42. package/utils/morgan-stream.d.ts.map +1 -0
  43. package/utils/ssr-cache.d.ts +112 -0
  44. package/utils/ssr-cache.d.ts.map +1 -0
  45. package/utils/ssr-config.client.d.ts +2 -0
  46. package/utils/ssr-config.client.d.ts.map +1 -0
  47. package/utils/ssr-config.client.test.js +4 -0
  48. package/utils/ssr-config.d.ts +3 -0
  49. package/utils/ssr-config.d.ts.map +1 -0
  50. package/utils/ssr-config.server.d.ts +2 -0
  51. package/utils/ssr-config.server.d.ts.map +1 -0
  52. package/utils/ssr-namespace-paths.d.ts +7 -0
  53. package/utils/ssr-namespace-paths.d.ts.map +1 -0
  54. package/utils/ssr-proxying.d.ts +173 -0
  55. package/utils/ssr-proxying.d.ts.map +1 -0
  56. package/utils/ssr-request-processing.d.ts +90 -0
  57. package/utils/ssr-request-processing.d.ts.map +1 -0
  58. package/utils/ssr-server/cached-response.d.ts +62 -0
  59. package/utils/ssr-server/cached-response.d.ts.map +1 -0
  60. package/utils/ssr-server/configure-proxy.d.ts +5 -0
  61. package/utils/ssr-server/configure-proxy.d.ts.map +1 -0
  62. package/utils/ssr-server/metrics-sender.d.ts +83 -0
  63. package/utils/ssr-server/metrics-sender.d.ts.map +1 -0
  64. package/utils/ssr-server/metrics-sender.js +1 -1
  65. package/utils/ssr-server/outgoing-request-hook.d.ts +2 -0
  66. package/utils/ssr-server/outgoing-request-hook.d.ts.map +1 -0
  67. package/utils/ssr-server/parse-end-parameters.d.ts +2 -0
  68. package/utils/ssr-server/parse-end-parameters.d.ts.map +1 -0
  69. package/utils/ssr-server/process-express-response.d.ts +3 -0
  70. package/utils/ssr-server/process-express-response.d.ts.map +1 -0
  71. package/utils/ssr-server/process-lambda-response.d.ts +2 -0
  72. package/utils/ssr-server/process-lambda-response.d.ts.map +1 -0
  73. package/utils/ssr-server/update-global-agent-options.d.ts +3 -0
  74. package/utils/ssr-server/update-global-agent-options.d.ts.map +1 -0
  75. package/utils/ssr-server/utils.d.ts +13 -0
  76. package/utils/ssr-server/utils.d.ts.map +1 -0
  77. package/utils/ssr-server/wrap-response-write.d.ts +2 -0
  78. package/utils/ssr-server/wrap-response-write.d.ts.map +1 -0
  79. package/utils/ssr-server.d.ts +11 -0
  80. package/utils/ssr-server.d.ts.map +1 -0
  81. package/utils/ssr-shared.d.ts +42 -0
  82. package/utils/ssr-shared.d.ts.map +1 -0
@@ -0,0 +1,18 @@
1
+ export const APPLICATION_OCTET_STREAM: "application/octet-stream";
2
+ export const BUILD: "build";
3
+ export const STATIC_ASSETS: "static_assets";
4
+ /** * @deprecated Use ssr-namespace-paths proxyBasePath instead */
5
+ export const PROXY_PATH_PREFIX: "/mobify/proxy";
6
+ export const CONTENT_TYPE: "content-type";
7
+ export const CONTENT_ENCODING: "content-encoding";
8
+ export const X_ORIGINAL_CONTENT_TYPE: "x-original-content-type";
9
+ export const X_MOBIFY_QUERYSTRING: "x-mobify-querystring";
10
+ export const X_MOBIFY_FROM_CACHE: "x-mobify-from-cache";
11
+ export const SET_COOKIE: "set-cookie";
12
+ export const CACHE_CONTROL: "cache-control";
13
+ export const NO_CACHE: "max-age=0, nocache, nostore, must-revalidate";
14
+ export const CONTENT_SECURITY_POLICY: "content-security-policy";
15
+ export const STRICT_TRANSPORT_SECURITY: "strict-transport-security";
16
+ /** * @deprecated Use ssr-namespace-paths.slasPrivateProxyPath instead */
17
+ export const SLAS_CUSTOM_PROXY_PATH: "/mobify/slas/private";
18
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/ssr/server/constants.js"],"names":[],"mappings":"AAMA,kEAAkE;AAClE,4BAA4B;AAC5B,4CAA4C;AAE5C,oEAAoE;AACpE,gDAAgD;AAGhD,0CAA0C;AAC1C,kDAAkD;AAClD,gEAAgE;AAChE,0DAA0D;AAC1D,wDAAwD;AACxD,sCAAsC;AACtC,4CAA4C;AAC5C,sEAAsE;AACtE,gEAAgE;AAChE,oEAAoE;AAEpE,2EAA2E;AAC3E,4DAA4D"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.X_ORIGINAL_CONTENT_TYPE = exports.X_MOBIFY_QUERYSTRING = exports.X_MOBIFY_FROM_CACHE = exports.X_ENCODED_HEADERS = exports.STRICT_TRANSPORT_SECURITY = exports.STATIC_ASSETS = exports.SLAS_CUSTOM_PROXY_PATH = exports.SET_COOKIE = exports.PROXY_PATH_PREFIX = exports.NO_CACHE = exports.CONTENT_TYPE = exports.CONTENT_SECURITY_POLICY = exports.CONTENT_ENCODING = exports.CACHE_CONTROL = exports.BUILD = exports.APPLICATION_OCTET_STREAM = void 0;
6
+ exports.X_ORIGINAL_CONTENT_TYPE = exports.X_MOBIFY_QUERYSTRING = exports.X_MOBIFY_FROM_CACHE = exports.STRICT_TRANSPORT_SECURITY = exports.STATIC_ASSETS = exports.SLAS_CUSTOM_PROXY_PATH = exports.SET_COOKIE = exports.PROXY_PATH_PREFIX = exports.NO_CACHE = exports.CONTENT_TYPE = exports.CONTENT_SECURITY_POLICY = exports.CONTENT_ENCODING = exports.CACHE_CONTROL = exports.BUILD = exports.APPLICATION_OCTET_STREAM = void 0;
7
7
  /*
8
8
  * Copyright (c) 2021, salesforce.com, inc.
9
9
  * All rights reserved.
@@ -23,7 +23,6 @@ const CONTENT_ENCODING = exports.CONTENT_ENCODING = 'content-encoding';
23
23
  const X_ORIGINAL_CONTENT_TYPE = exports.X_ORIGINAL_CONTENT_TYPE = 'x-original-content-type';
24
24
  const X_MOBIFY_QUERYSTRING = exports.X_MOBIFY_QUERYSTRING = 'x-mobify-querystring';
25
25
  const X_MOBIFY_FROM_CACHE = exports.X_MOBIFY_FROM_CACHE = 'x-mobify-from-cache';
26
- const X_ENCODED_HEADERS = exports.X_ENCODED_HEADERS = 'x-encoded-headers';
27
26
  const SET_COOKIE = exports.SET_COOKIE = 'set-cookie';
28
27
  const CACHE_CONTROL = exports.CACHE_CONTROL = 'cache-control';
29
28
  const NO_CACHE = exports.NO_CACHE = 'max-age=0, nocache, nostore, must-revalidate';
@@ -0,0 +1,17 @@
1
+ export const RESOLVED_PROMISE: Promise<void>;
2
+ export function generateCacheKey(req: IncomingMessage, options?: {
3
+ extras?: (string | undefined)[] | undefined;
4
+ ignoreRequestClass?: boolean | undefined;
5
+ } | undefined): string;
6
+ export function cacheResponseWhenDone({ req, res, expiration, key, namespace, shouldCacheResponse }: express.request): void;
7
+ export function sendCachedResponse(cached: CachedResponse): void;
8
+ export function getResponseFromCache({ req, res, namespace, key }: express.request): Promise<CachedResponse>;
9
+ export function respondFromBundle({ req, res, path, redirect }: {
10
+ req: Request;
11
+ res: Response;
12
+ path?: string | undefined;
13
+ redirect?: number | undefined;
14
+ }): void;
15
+ export function getRuntime(): any;
16
+ import { CachedResponse } from "../../utils/ssr-server/cached-response";
17
+ //# sourceMappingURL=express.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../src/ssr/server/express.js"],"names":[],"mappings":"AA0BA,6CAAiD;AA4C1C;;;uBA6BN;AA+GM,4HA2FN;AAYM,2CAHW,cAAc,QAS/B;AA4CM,qFAJM,QAAQ,cAAc,CAAC,CA8BnC;AAwBM;IAVqB,GAAG,EAApB,OAAO;IACW,GAAG,EAArB,QAAQ;IACS,IAAI;IAIJ,QAAQ;SA2BnC;AAMM,kCAsBN"}
@@ -19,8 +19,6 @@ var _crypto = require("crypto");
19
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
23
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
24
22
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
25
23
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
26
24
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -479,40 +477,6 @@ describe('SSRServer operation', () => {
479
477
  expect(response.headers['set-cookie']).toBeUndefined();
480
478
  });
481
479
  });
482
- test('should set xForwardedOrigin based on defined x-forwarded-host and x-forwarded-proto headers', () => {
483
- process.env = {
484
- MRT_ALLOW_COOKIES: 'true'
485
- };
486
- const forwardedHost = 'www.example.com';
487
- const forwardedProto = 'https';
488
- const app = _buildRemoteServer.RemoteServerFactory._createApp(opts());
489
- const route = (req, res) => {
490
- expect(req.headers['x-forwarded-host']).toBe(forwardedHost);
491
- expect(res.locals.xForwardedOrigin).toBe(`${forwardedProto}://${forwardedHost}`);
492
- res.sendStatus(200);
493
- };
494
- app.get('/*', route);
495
- return (0, _supertest.default)(app).get('/').set('x-forwarded-host', forwardedHost).set('x-forwarded-proto', 'https').then(response => {
496
- expect(response.status).toBe(200);
497
- });
498
- });
499
- test('should set xForwardedOrigin based on defined x-forwarded-host and undefined x-forwarded-proto headers', () => {
500
- process.env = {
501
- MRT_ALLOW_COOKIES: 'true'
502
- };
503
- const options = opts();
504
- const forwardedHost = 'www.example.com';
505
- const app = _buildRemoteServer.RemoteServerFactory._createApp(options);
506
- const route = (req, res) => {
507
- expect(req.headers['x-forwarded-host']).toBe(forwardedHost);
508
- expect(res.locals.xForwardedOrigin).toBe(`${options.protocol}://${forwardedHost}`);
509
- res.sendStatus(200);
510
- };
511
- app.get('/*', route);
512
- return (0, _supertest.default)(app).get('/').set('x-forwarded-host', forwardedHost).then(response => {
513
- expect(response.status).toBe(200);
514
- });
515
- });
516
480
  test(`should reject POST requests to /`, () => {
517
481
  const app = _buildRemoteServer.RemoteServerFactory._createApp(opts());
518
482
  const route = (req, res) => {
@@ -909,7 +873,7 @@ describe('DevServer middleware', () => {
909
873
  _buildRemoteServer.RemoteServerFactory._validateConfiguration(opts({
910
874
  strictSSL: false
911
875
  }));
912
- expect(warn.mock.calls).toEqual([['The SSR Server has _strictSSL turned off for https requests']]);
876
+ expect(warn.mock.calls).toEqual([['pwa-kit-runtime WARN The SSR Server has _strictSSL turned off for https requests']]);
913
877
  });
914
878
  });
915
879
  describe('SLAS private client proxy', () => {
@@ -930,9 +894,6 @@ describe('SLAS private client proxy', () => {
930
894
  afterEach(() => {
931
895
  process.env = savedEnvironment;
932
896
  });
933
- afterAll(() => {
934
- proxyApp.close();
935
- });
936
897
  test('should not create proxy by default', () => {
937
898
  const app = _buildRemoteServer.RemoteServerFactory._createApp(opts());
938
899
  return (0, _supertest.default)(app).get('/mobify/slas/private').expect(404);
@@ -943,7 +904,7 @@ describe('SLAS private client proxy', () => {
943
904
  }));
944
905
  return (0, _supertest.default)(app).get('/mobify/slas/private').expect(501);
945
906
  });
946
- test('does not insert client secret if request not for /oauth2/token', /*#__PURE__*/_asyncToGenerator(function* () {
907
+ test('does not insert client secret if request not for /oauth2/token', () => {
947
908
  process.env.PWA_KIT_SLAS_CLIENT_SECRET = 'a secret';
948
909
  const app = _buildRemoteServer.RemoteServerFactory._createApp(opts({
949
910
  mobify: {
@@ -959,13 +920,13 @@ describe('SLAS private client proxy', () => {
959
920
  useSLASPrivateClient: true,
960
921
  slasTarget: slasTarget
961
922
  }));
962
- return yield (0, _supertest.default)(app).get('/mobify/slas/private/somePath').then(response => {
923
+ return (0, _supertest.default)(app).get('/mobify/slas/private/somePath').then(response => {
963
924
  expect(response.body.authorization).toBeUndefined();
964
925
  expect(response.body.host).toBe('shortCode.api.commercecloud.salesforce.com');
965
926
  expect(response.body['x-mobify']).toBe('true');
966
927
  });
967
- }), 15000);
968
- test('inserts client secret if request is for /oauth2/token', /*#__PURE__*/_asyncToGenerator(function* () {
928
+ });
929
+ test('inserts client secret if request is for /oauth2/token', () => {
969
930
  process.env.PWA_KIT_SLAS_CLIENT_SECRET = 'a secret';
970
931
  const encodedCredentials = Buffer.from('clientId:a secret').toString('base64');
971
932
  const app = _buildRemoteServer.RemoteServerFactory._createApp(opts({
@@ -982,55 +943,10 @@ describe('SLAS private client proxy', () => {
982
943
  useSLASPrivateClient: true,
983
944
  slasTarget: slasTarget
984
945
  }));
985
- return yield (0, _supertest.default)(app).get('/mobify/slas/private/oauth2/token').then(response => {
946
+ return (0, _supertest.default)(app).get('/mobify/slas/private/oauth2/token').then(response => {
986
947
  expect(response.body.authorization).toBe(`Basic ${encodedCredentials}`);
987
948
  expect(response.body.host).toBe('shortCode.api.commercecloud.salesforce.com');
988
949
  expect(response.body['x-mobify']).toBe('true');
989
950
  });
990
- }), 15000);
991
- test('does not add _sfdc_client_auth header if request not for /oauth2/trusted-agent/token', /*#__PURE__*/_asyncToGenerator(function* () {
992
- process.env.PWA_KIT_SLAS_CLIENT_SECRET = 'a secret';
993
- const encodedCredentials = Buffer.from('clientId:a secret').toString('base64');
994
- const app = _buildRemoteServer.RemoteServerFactory._createApp(opts({
995
- mobify: {
996
- app: {
997
- commerceAPI: {
998
- parameters: {
999
- clientId: 'clientId',
1000
- shortCode: 'shortCode'
1001
- }
1002
- }
1003
- }
1004
- },
1005
- useSLASPrivateClient: true,
1006
- slasTarget: slasTarget
1007
- }));
1008
- return yield (0, _supertest.default)(app).get('/mobify/slas/oauth2/other-path').then(response => {
1009
- expect(response.body._sfdc_client_auth).toBeUndefined();
1010
- });
1011
- }), 15000);
1012
- test('adds _sfdc_client_auth header if request is for /oauth2/trusted-agent/token', /*#__PURE__*/_asyncToGenerator(function* () {
1013
- process.env.PWA_KIT_SLAS_CLIENT_SECRET = 'a secret';
1014
- const encodedCredentials = Buffer.from('clientId:a secret').toString('base64');
1015
- const app = _buildRemoteServer.RemoteServerFactory._createApp(opts({
1016
- mobify: {
1017
- app: {
1018
- commerceAPI: {
1019
- parameters: {
1020
- clientId: 'clientId',
1021
- shortCode: 'shortCode'
1022
- }
1023
- }
1024
- }
1025
- },
1026
- useSLASPrivateClient: true,
1027
- slasTarget: slasTarget,
1028
- trustedAgentAuthPathMatch: /\/oauth2\/trusted-agent\/token/
1029
- }));
1030
- return yield (0, _supertest.default)(app).get('/mobify/slas/private/oauth2/trusted-agent/token').then(response => {
1031
- expect(response.body['_sfdc_client_auth']).toBe(encodedCredentials);
1032
- expect(response.body.host).toBe('shortCode.api.commercecloud.salesforce.com');
1033
- expect(response.body['x-mobify']).toBe('true');
1034
- });
1035
- }), 15000);
951
+ });
1036
952
  });
@@ -0,0 +1,5 @@
1
+ export default AnotherExtension;
2
+ declare class AnotherExtension {
3
+ extendApp(app: any): any;
4
+ }
5
+ //# sourceMappingURL=setup-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-server.d.ts","sourceRoot":"","sources":["../../../../../../src/ssr/server/test_fixtures/extensions/another-extension/setup-server.js"],"names":[],"mappings":";AAQA;IACI,yBAMC;CACJ"}
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright (c) 2024, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+ import {ApplicationExtension} from '../../../extensibility'
8
+
9
+ class AnotherExtension extends ApplicationExtension {
10
+ extendApp(app) {
11
+ app.get('/another-extension', (req, res) => {
12
+ res.send('test')
13
+ })
14
+
15
+ return app
16
+ }
17
+ }
18
+
19
+ export default AnotherExtension
@@ -0,0 +1,5 @@
1
+ export default Extension;
2
+ declare class Extension {
3
+ extendApp(app: any): void;
4
+ }
5
+ //# sourceMappingURL=setup-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-server.d.ts","sourceRoot":"","sources":["../../../../../../src/ssr/server/test_fixtures/extensions/extension-with-bad-setup-server/setup-server.js"],"names":[],"mappings":";AASA;IACI,0BAEC;CACJ"}
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright (c) 2024, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+
8
+ import {ApplicationExtension} from '../../../extensibility'
9
+
10
+ class Extension extends ApplicationExtension {
11
+ extendApp(app) {
12
+ throw new Error('extension will fail to initialize because of me')
13
+ }
14
+ }
15
+
16
+ export default Extension
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=setup-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-server.d.ts","sourceRoot":"","sources":["../../../../../../src/ssr/server/test_fixtures/extensions/extension-with-setup-server-no-default-export/setup-server.js"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright (c) 2024, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+
8
+ import {ApplicationExtension} from '../../../extensibility'
9
+ class AnotherExtension extends ApplicationExtension {
10
+ extendApp(app) {
11
+ app.get('/another-extension', (req, res) => {
12
+ res.send('test')
13
+ })
14
+
15
+ return app
16
+ }
17
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=random-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-file.d.ts","sourceRoot":"","sources":["../../../../../../src/ssr/server/test_fixtures/extensions/extension-without-setup-server/random-file.js"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Copyright (c) 2024, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+ // intentionally empty
@@ -0,0 +1,5 @@
1
+ export default TestExtension;
2
+ declare class TestExtension {
3
+ extendApp(app: any): any;
4
+ }
5
+ //# sourceMappingURL=setup-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-server.d.ts","sourceRoot":"","sources":["../../../../../../src/ssr/server/test_fixtures/extensions/test-extension/setup-server.js"],"names":[],"mappings":";AAQA;IACI,yBAeC;CACJ"}
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) 2024, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+
8
+ import {ApplicationExtension} from '../../../extensibility'
9
+ class TestExtension extends ApplicationExtension {
10
+ extendApp(app) {
11
+ console.log(
12
+ 'ApplicationExtensionApplicationExtensionApplicationExtensionApplicationExtensionApplicationExtensionApplicationExtension: ',
13
+ ApplicationExtension
14
+ )
15
+
16
+ app.get('/test-extension', (req, res) => {
17
+ res.send('test')
18
+ })
19
+ app.get('/test-extension-config', (req, res) => {
20
+ const config = JSON.stringify(this.getConfig())
21
+ res.send(config)
22
+ })
23
+
24
+ return app
25
+ }
26
+ }
27
+
28
+ export default TestExtension
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/ssr/server/test_fixtures/main.js"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ declare function _default({ clientStats, serverStats }: {
2
+ clientStats: any;
3
+ serverStats: any;
4
+ }): (req: any, res: any, next: any) => any;
5
+ export default _default;
6
+ //# sourceMappingURL=server-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-renderer.d.ts","sourceRoot":"","sources":["../../../../src/ssr/server/test_fixtures/server-renderer.js"],"names":[],"mappings":"AAQkB;;;2CAGjB"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../src/ssr/server/test_fixtures/worker.js"],"names":[],"mappings":""}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The PWAKitLogger provides structured logging with different log levels.
3
+ * @private
4
+ */
5
+ export class PWAKitLogger {
6
+ /**
7
+ * Creates an instance of PWAKitLogger.
8
+ * @param {Object} options - Configuration options for the logger.
9
+ * @param {string} options.packageName - The name of the package where the logger is used.
10
+ */
11
+ constructor(options?: {
12
+ packageName: string;
13
+ });
14
+ packageName: string;
15
+ /**
16
+ * Logs a debug message.
17
+ * @param {string} message - The debug message.
18
+ * @param {Object} [details={}] - Optional message details.
19
+ */
20
+ debug(message: string, details?: Object | undefined): void;
21
+ /**
22
+ * Logs an info message.
23
+ * @param {string} message - The info message.
24
+ * @param {Object} [details={}] - Optional message details.
25
+ */
26
+ log(message: string, details?: Object | undefined): void;
27
+ /**
28
+ * Logs an info message.
29
+ * @param {string} message - The info message.
30
+ * @param {Object} [details={}] - Optional message details.
31
+ */
32
+ info(message: string, details?: Object | undefined): void;
33
+ /**
34
+ * Logs a warning message.
35
+ * @param {string} message - The warning message.
36
+ * @param {Object} [details={}] - Optional message details.
37
+ */
38
+ warn(message: string, details?: Object | undefined): void;
39
+ /**
40
+ * Logs an error message.
41
+ * @param {string} message - The error message.
42
+ * @param {Object} [details={}] - Optional message details.
43
+ */
44
+ error(message: string, details?: Object | undefined): void;
45
+ #private;
46
+ }
47
+ export default createLogger;
48
+ /**
49
+ * Create a logger instance for each package.
50
+ *
51
+ * @param {Object} config - Configuration object for the logger.
52
+ * @param {string} config.packageName - The name of the package where the logger is used.
53
+ * @returns {PWAKitLogger} - An instance of PWAKitLogger configured for the specified package.
54
+ */
55
+ declare function createLogger(config?: {
56
+ packageName: string;
57
+ }): PWAKitLogger;
58
+ //# sourceMappingURL=logger-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-factory.d.ts","sourceRoot":"","sources":["../../src/utils/logger-factory.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACI;;;;OAIG;IACH;QAF2B,WAAW,EAA3B,MAAM;OAIhB;IADG,oBAA4C;IAwDhD;;;;OAIG;IACH,eAHW,MAAM,sCAKhB;IAED;;;;OAIG;IACH,aAHW,MAAM,sCAKhB;IAED;;;;OAIG;IACH,cAHW,MAAM,sCAKhB;IAED;;;;OAIG;IACH,cAHW,MAAM,sCAKhB;IAED;;;;OAIG;IACH,eAHW,MAAM,sCAKhB;;CACJ;;AAED;;;;;;GAMG;AACH;IAH0B,WAAW,EAA1B,MAAM;IACJ,YAAY,CAIxB"}
@@ -0,0 +1,3 @@
1
+ export default logger;
2
+ declare const logger: Readonly<import("./logger-factory").PWAKitLogger>;
3
+ //# sourceMappingURL=logger-instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-instance.d.ts","sourceRoot":"","sources":["../../src/utils/logger-instance.js"],"names":[],"mappings":";AAQA,wEAA4E"}
@@ -0,0 +1,2 @@
1
+ export * from "./security";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/middleware/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export function defaultPwaKitSecurityHeaders(req: express.Request, res: express.Response, next: express.NextFunction): void;
2
+ //# sourceMappingURL=security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/utils/middleware/security.js"],"names":[],"mappings":"AAkBO,4HAkDN"}
@@ -0,0 +1,11 @@
1
+ export let morganStream: ConsoleLogStream;
2
+ /**
3
+ * @private
4
+ * A stream that uses logger to write log lines
5
+ */
6
+ declare class ConsoleLogStream extends Writable {
7
+ write(line: any): void;
8
+ }
9
+ import { Writable } from "stream";
10
+ export {};
11
+ //# sourceMappingURL=morgan-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morgan-stream.d.ts","sourceRoot":"","sources":["../../src/utils/morgan-stream.js"],"names":[],"mappings":"AAoBA,0CAAyC;AAVzC;;;GAGG;AACH;IACI,uBAEC;CACJ"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @module progressive-web-sdk/utils/ssr-cache
3
+ */
4
+ /**
5
+ * A cache implementation.
6
+ *
7
+ * See the get, put and delete methods for more details.
8
+ */
9
+ export class PersistentCache {
10
+ _cacheDeletePromise: Promise<void>;
11
+ /**
12
+ * Provided for testing purposes. Calling close() will
13
+ * clean up any locally cached data.
14
+ * @private
15
+ */
16
+ private close;
17
+ /**
18
+ * Return an object that represents an entry not found in the cache
19
+ * @param key
20
+ * @param namespace {String|string[]}
21
+ * @returns {Object}
22
+ * @private
23
+ */
24
+ private _notFound;
25
+ /**
26
+ * Get a JavaScript object from the cache.
27
+ *
28
+ * The returned Promise will resolve either to null if there is no
29
+ * match in the cache, or to an object with the following
30
+ * properties: 'found' is a boolean that is true if the item was found
31
+ * in the cache, 'false' if not, 'data' is the data for the object
32
+ * (or undefined if the object was not found), 'metadata' is the metadata
33
+ * object passed to put() (or undefined if the object was not found),
34
+ * 'expiration' is a JS date/timestamp representing the time at which the
35
+ * item will expire from the cache, 'key' is the item's cache
36
+ * key, and 'namespace' is the item's cache namespace.
37
+ *
38
+ * If the value passed to 'put' was a Buffer, then 'data' will
39
+ * be a Buffer. If the value passed to 'put' was anything else,
40
+ * it will have been deserialized from JSON, and will be whatever
41
+ * type was originally passed in.
42
+ *
43
+ * If an object is in the cache under the given key, each call to this
44
+ * method will return a separate copy of the object.
45
+ *
46
+ * If the object is NOT in the cache, this method will return an object
47
+ * with 'found' set to false. This allows a then() handler to use object
48
+ * deconstruction on the result.
49
+ *
50
+ * Within the cache, items under the same key but in different namespaces
51
+ * are distinct. The default namespace is undefined.
52
+ *
53
+ * @param [namespace] {String|string[]} the cache namespace
54
+ * @param key {String} the cache key
55
+ * @returns {Promise<*>} A Promise that will resolve to the
56
+ * cache result, or null if there is no match in the cache.
57
+ */
58
+ get({ key, namespace }?: string | string[] | undefined): Promise<any>;
59
+ /**
60
+ * Store a JavaScript object in the cache.
61
+ *
62
+ * If the data to be stored is a Buffer, it's stored as-is. If
63
+ * it's any other type, it's serialized to JSON and the JSON is
64
+ * stored. If the data is not JSON-serializable, then this method
65
+ * will throw an error.
66
+ *
67
+ * A primary use-case for this cache is storing HTTP responses,
68
+ * which include a status code, headers and a body. The body is
69
+ * typically most efficiently stored as a Buffer. Passing an object
70
+ * to 'data' that has a Buffer value will result in the Buffer being
71
+ * JSON-encoded, which is slow and takes up much more space than the
72
+ * origin data. The recommended way to store a response is to include
73
+ * the status and headers in the item's metadata, and to pass the body
74
+ * as a Buffer.
75
+ *
76
+ * If an expiration date/timestamp is given, the data will expire
77
+ * from the cache at that time. If no date/timestamp is given,
78
+ * the default expiration is one year from the time that the data is
79
+ * stored.
80
+ *
81
+ * Within the cache, items under the same key but in different namespaces
82
+ * are distinct. The default namespace is undefined.
83
+ *
84
+ * If put() is called to store metdata but no data, you should pass
85
+ * undefined for 'data'.
86
+ *
87
+ * @param key {String} the cache key.
88
+ * @param [namespace] {String|string[]} the cache namespace
89
+ * @param data {Buffer|*} the data to be stored.
90
+ * @param [metadata] {Object} a simple JS object with keys and values
91
+ * for metadata. This object MUST be JSON-seralizable.
92
+ * @param [expiration] {Number} the expiration date/time for the data,
93
+ * as a JS date/timestamp (the result of Date.getTime). If the expiration
94
+ * is less than PersistentCache.DELTA_THRESHOLD (midnight on January 1st, 1980)
95
+ * it is interpreted as a delta number of mS to be added to the current time.
96
+ * This allows for deltas up to ten years.
97
+ * @returns {Promise<*>} resolves when data has been stored, or rejects
98
+ * on an error
99
+ */
100
+ put(): Promise<any>;
101
+ /**
102
+ * Remove a single entry from the cache.
103
+ * @param key {String} the cache key
104
+ * @param [namespace] {String|string[]} the cache namespace
105
+ * @returns {Promise.<*>} resolves when delete is complete
106
+ */
107
+ delete(): Promise<any>;
108
+ }
109
+ export namespace PersistentCache {
110
+ const DELTA_THRESHOLD: number;
111
+ }
112
+ //# sourceMappingURL=ssr-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-cache.d.ts","sourceRoot":"","sources":["../../src/utils/ssr-cache.js"],"names":[],"mappings":"AAMA;;GAEG;AAEH;;;;GAIG;AACH;IA4BQ,mCAA4C;IAGhD;;;;OAIG;IACH,cAEC;IAED;;;;;;OAMG;IACH,kBAQC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,yDAHa,YAAU,CAKtB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,OAHa,YAAU,CAKtB;IAED;;;;;OAKG;IACH,UAFa,YAAW,CAIvB;CACJ"}
@@ -0,0 +1,2 @@
1
+ export function getConfig(): any;
2
+ //# sourceMappingURL=ssr-config.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-config.client.d.ts","sourceRoot":"","sources":["../../src/utils/ssr-config.client.js"],"names":[],"mappings":"AAaO,iCAEN"}
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _ssrConfig = require("./ssr-config.client");
4
+ /**
5
+ * @jest-environment jsdom
6
+ */
4
7
  /*
5
8
  * Copyright (c) 2023, Salesforce, Inc.
6
9
  * All rights reserved.
7
10
  * SPDX-License-Identifier: BSD-3-Clause
8
11
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
12
  */
13
+ /* eslint-disable header/header */
10
14
 
11
15
  let windowSpy;
12
16
  beforeEach(() => {
@@ -0,0 +1,3 @@
1
+ declare const _exports: typeof import("./ssr-config.client.js") | typeof import("./ssr-config.server.js");
2
+ export = _exports;
3
+ //# sourceMappingURL=ssr-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-config.d.ts","sourceRoot":"","sources":["../../src/utils/ssr-config.js"],"names":[],"mappings":""}