@blakearoberts/visage 0.0.2-rc.1 → 0.0.3-rc.0

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 +1 @@
1
- {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,WAAW,GAAG,MAAM,IAAI,CAAC;AAK9B,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAgD9D"}
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,WAAW,GAAG,MAAM,IAAI,CAAC;AAK9B,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAmD9D"}
package/dist/config.d.ts CHANGED
@@ -81,6 +81,7 @@ export type VisageConfig = {
81
81
  readonly host: string;
82
82
  readonly port: number;
83
83
  readonly cookie: ResolvedCookiePolicy;
84
+ readonly edgeKey?: string;
84
85
  readonly idp: ResolvedIdpConfig;
85
86
  readonly oauth2: ResolvedOAuth2Client;
86
87
  readonly cache: string;
@@ -89,11 +90,13 @@ export type VisageConfig = {
89
90
  readonly compose: string;
90
91
  readonly dex: Volume;
91
92
  readonly nginx: Volume;
93
+ readonly nginxEdgeKeyJS: Volume;
92
94
  readonly oauth2Proxy: Volume;
93
95
  };
94
96
  readonly secrets: {
95
97
  readonly cookieSecret: string;
96
98
  readonly clientSecret: string;
99
+ readonly edgeKey: string;
97
100
  };
98
101
  readonly network: {
99
102
  readonly name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,wBAA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MAAM,CAAC;KAC9B,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;KAC7C,CAAC;IAEF,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IAC7D,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAiHvD,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,qBAAqB,CAyD5E;AAsLD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,qBAAqB,EAC9B,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,GACf,YAAY,CAsFd"}
package/dist/index.js CHANGED
@@ -321,14 +321,12 @@ function resolveConfig(options, cache, edgeKey) {
321
321
  }),
322
322
  ...idp.upstream,
323
323
  ...options.upstreams,
324
- ...(edgeKey && options.upstreams.vite
325
- ? { vite: resolveViteEdgeKeyConfig(options.upstreams.vite, edgeKey) }
326
- : {}),
327
324
  };
328
325
  return {
329
326
  host: options.host,
330
327
  port: options.port,
331
328
  cookie: options.cookie,
329
+ edgeKey,
332
330
  idp,
333
331
  oauth2: options.oauth2,
334
332
  cache,
@@ -337,11 +335,13 @@ function resolveConfig(options, cache, edgeKey) {
337
335
  compose: './compose.yaml',
338
336
  dex: ['./dex.yaml', '/etc/dex/dex.yaml'],
339
337
  nginx: ['./nginx.conf', '/etc/nginx/nginx.conf'],
338
+ nginxEdgeKeyJS: ['./nginx-edge-key.js', '/etc/nginx/edge-key.js'],
340
339
  oauth2Proxy: ['./oauth2-proxy.yml', '/etc/oauth2-proxy/config.yml'],
341
340
  },
342
341
  secrets: {
343
342
  cookieSecret: 'OAUTH2_PROXY_COOKIE_SECRET',
344
343
  clientSecret: 'OAUTH2_CLIENT_SECRET',
344
+ edgeKey: 'VISAGE_EDGE_KEY',
345
345
  },
346
346
  network: {
347
347
  name: process.env.COMPOSE_PROJECT_NAME ?? 'visage',
@@ -370,21 +370,6 @@ function resolveConfig(options, cache, edgeKey) {
370
370
  })),
371
371
  };
372
372
  }
373
- function resolveViteEdgeKeyConfig(upstream, edgeKey) {
374
- return {
375
- ...upstream,
376
- locations: Object.fromEntries(Object.entries(upstream.locations).map(([path, policy]) => [
377
- path,
378
- {
379
- ...policy,
380
- headers: {
381
- [VisageEdgeKeyHeader$1]: edgeKey,
382
- ...policy.headers,
383
- },
384
- },
385
- ])),
386
- };
387
- }
388
373
  function resolveIdpConfig({ host, port, idp, }) {
389
374
  if ('dex' in idp) {
390
375
  return {
@@ -596,6 +581,9 @@ function startCompose(config) {
596
581
  ? {}
597
582
  : { [config.secrets.clientSecret]: config.oauth2.secret }),
598
583
  ...process.env,
584
+ ...(config.edgeKey === undefined
585
+ ? {}
586
+ : { [config.secrets.edgeKey]: config.edgeKey }),
599
587
  [config.secrets.cookieSecret]: (cookieSecret ??=
600
588
  randomBytes(32).toString('base64url')),
601
589
  };
@@ -740,6 +728,13 @@ function renderComposeConfig(config) {
740
728
  [config.secrets.cookieSecret]: {
741
729
  environment: config.secrets.cookieSecret,
742
730
  },
731
+ ...(config.edgeKey === undefined
732
+ ? {}
733
+ : {
734
+ [config.secrets.edgeKey]: {
735
+ environment: config.secrets.edgeKey,
736
+ },
737
+ }),
743
738
  ...(config.oauth2.public
744
739
  ? {}
745
740
  : {
@@ -762,8 +757,17 @@ function renderComposeConfig(config) {
762
757
  : {}),
763
758
  nginx: {
764
759
  ...config.services.nginx,
760
+ ...(config.edgeKey === undefined
761
+ ? {}
762
+ : { secrets: [config.secrets.edgeKey] }),
765
763
  ports: [`127.0.0.1:${config.port}:${config.port}`],
766
- volumes: [config.files.certs, config.files.nginx].map(([from, to]) => `${from}:${to}:ro`),
764
+ volumes: [
765
+ config.files.certs,
766
+ config.files.nginx,
767
+ ...(config.edgeKey === undefined
768
+ ? []
769
+ : [config.files.nginxEdgeKeyJS]),
770
+ ].map(([from, to]) => `${from}:${to}:ro`),
767
771
  },
768
772
  oauth2_proxy: {
769
773
  ...config.services.oauth2_proxy,
@@ -816,9 +820,19 @@ function renderDexConfig(config) {
816
820
  }
817
821
 
818
822
  const template = `
823
+ <%_ if (it.edgeKey) { %>
824
+ load_module modules/ngx_http_js_module.so;
825
+
826
+ <%_ } %>
819
827
  events {}
820
828
 
821
829
  http {
830
+ <%_ if (it.edgeKey) { %>
831
+ js_import edge_key from <%~ it.edgeKey.script %>;
832
+ js_shared_dict_zone zone=edge_key:32k;
833
+ js_set $edge_key edge_key;
834
+
835
+ <%_ } %>
822
836
  # Disable IPv6 DNS lookups that may fail to resolve upstream hostnames.
823
837
  resolver 127.0.0.11 ipv6=off;
824
838
 
@@ -905,6 +919,9 @@ http {
905
919
  error_page 401 =302 /oauth2/start?rd=$scheme://$http_host$request_uri;
906
920
  <%_ } %>
907
921
  <%_ } %>
922
+ <%_ if (it.edgeKey && name === 'vite') { %>
923
+ proxy_set_header <%~ it.edgeKey.header %> $edge_key;
924
+ <%_ } %>
908
925
  <%_ for (const [header, value] of Object.entries(location.headers ?? {})) { %>
909
926
  proxy_set_header <%~ header %> <%~ value %>;
910
927
  <%_ } %>
@@ -925,10 +942,25 @@ http {
925
942
  }
926
943
  }
927
944
  `;
945
+ const renderEdgeKeyJS = (file) => `import fs from 'fs';
946
+ export default function value() {
947
+ let key = ngx.shared.edge_key.get('edge_key');
948
+ if (key === undefined) {
949
+ key = fs.readFileSync('/run/secrets/${file}', 'utf8').trim();
950
+ ngx.shared.edge_key.set('edge_key', key);
951
+ }
952
+ return key;
953
+ }
954
+ `;
928
955
  function writeNginxConfig(config) {
929
956
  const file = join(config.cache, config.files.nginx[0]);
930
957
  const render = renderNginxConfig(config);
931
958
  writeFileSync(file, render, 'utf-8');
959
+ if (config.edgeKey !== undefined) {
960
+ const file = join(config.cache, config.files.nginxEdgeKeyJS[0]);
961
+ const render = renderEdgeKeyJS(config.secrets.edgeKey);
962
+ writeFileSync(file, render, 'utf-8');
963
+ }
932
964
  }
933
965
  function renderNginxConfig(config) {
934
966
  const data = {
@@ -938,6 +970,14 @@ function renderNginxConfig(config) {
938
970
  cert: join(config.files.certs[1], 'tls.crt'),
939
971
  key: join(config.files.certs[1], 'tls.key'),
940
972
  },
973
+ ...(config.edgeKey === undefined
974
+ ? {}
975
+ : {
976
+ edgeKey: {
977
+ header: VisageEdgeKeyHeader$1,
978
+ script: config.files.nginxEdgeKeyJS[1],
979
+ },
980
+ }),
941
981
  upstreams: Object.fromEntries(Object.entries(config.upstreams).map(([name, upstream]) => [
942
982
  name,
943
983
  {
@@ -1,3 +1,3 @@
1
- import type { VisageConfig } from '../config';
1
+ import { type VisageConfig } from '../config';
2
2
  export declare function writeNginxConfig(config: VisageConfig): void;
3
3
  //# sourceMappingURL=nginx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nginx.d.ts","sourceRoot":"","sources":["../../src/render/nginx.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAiH9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAI3D"}
1
+ {"version":3,"file":"nginx.d.ts","sourceRoot":"","sources":["../../src/render/nginx.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAyInE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAU3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blakearoberts/visage",
3
- "version": "0.0.2-rc.1",
3
+ "version": "0.0.3-rc.0",
4
4
  "description": "Vite plugin for local development with HMR and OIDC session cookie lifecycle semantics.",
5
5
  "type": "module",
6
6
  "author": "Blake Roberts",
@@ -57,7 +57,7 @@
57
57
  "test:e2e": "playwright test test/e2e",
58
58
  "test:e2e:setup": "npm run build && npm run test:e2e:setup:examples && playwright install chromium",
59
59
  "test:e2e:setup:examples": "npm --prefix examples/simple install --no-audit --no-fund && npm --prefix examples/ssr install --no-audit --no-fund && npm --prefix examples/external-idp install --no-audit --no-fund",
60
- "test:unit": "node --experimental-strip-types --test test/unit/*.test.ts",
60
+ "test:unit": "tsx --test test/unit/*.test.ts",
61
61
  "typecheck": "tsc --noEmit"
62
62
  },
63
63
  "dependencies": {
@@ -75,6 +75,7 @@
75
75
  "prettier": "^3.8.3",
76
76
  "rollup": "^4.60.4",
77
77
  "tslib": "^2.8.1",
78
+ "tsx": "^4.22.3",
78
79
  "typescript": "^6.0.3",
79
80
  "vite": "^8.0.13"
80
81
  }