@camstack/addon-auth 1.2.137 → 1.2.139

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,4 +1,4 @@
1
- import { a as buildAddonRouteProvider, i as authProviderCapability, l as errMsg, n as addonRoutesCapability, o as isDisplayIconKey, s as loginMethodCapability, t as SSO_STATE_COOKIE, u as BaseAddon } from "../dist-Q8DExvTl.mjs";
1
+ import { _ as toSecretFieldView, a as buildAddonRouteProvider, c as oidcConnectionsCapability, d as BaseAddon, f as SECRET_CLEAR, g as isSecretMarker, h as isSecretClear, i as authProviderCapability, m as globalSecretScope, n as addonRoutesCapability, o as isDisplayIconKey, p as arrayItemFieldPath, s as loginMethodCapability, t as SSO_STATE_COOKIE, u as errMsg } from "../dist-BOK-Ox5c.mjs";
2
2
  import * as crypto$1 from "node:crypto";
3
3
  //#region ../../node_modules/jose/dist/webapi/lib/buffer_utils.js
4
4
  var encoder = new TextEncoder(), decoder = new TextDecoder(), strictDecoder = new TextDecoder("utf-8", { fatal: !0 });
@@ -699,6 +699,186 @@ function createRemoteJWKSet(url, options) {
699
699
  });
700
700
  }
701
701
  //#endregion
702
+ //#region src/oidc/oidc-connection-schema.ts
703
+ var DEFAULT_OIDC_ICON = "shield-check";
704
+ var OIDC_CONNECTION_FORM_SCHEMA = { sections: [{
705
+ id: "identity",
706
+ title: "Identity",
707
+ fields: [{
708
+ type: "text",
709
+ key: "displayName",
710
+ label: "Display name",
711
+ description: "Shown on the login button.",
712
+ default: "OpenID Connect"
713
+ }, {
714
+ type: "icon",
715
+ key: "icon",
716
+ label: "Icon",
717
+ description: "Shown on the login button.",
718
+ default: DEFAULT_OIDC_ICON
719
+ }]
720
+ }, {
721
+ id: "idp",
722
+ title: "Identity provider",
723
+ fields: [
724
+ {
725
+ type: "text",
726
+ key: "issuerUrl",
727
+ label: "Issuer URL",
728
+ description: "IdP base URL — discovery doc lives at <issuer>/.well-known/openid-configuration.",
729
+ default: ""
730
+ },
731
+ {
732
+ type: "text",
733
+ key: "clientId",
734
+ label: "Client ID",
735
+ default: ""
736
+ },
737
+ {
738
+ type: "password",
739
+ key: "clientSecret",
740
+ label: "Client Secret",
741
+ showToggle: true,
742
+ default: ""
743
+ },
744
+ {
745
+ type: "text",
746
+ key: "redirectUri",
747
+ label: "Redirect URI override",
748
+ description: "Optional — leave empty. Empty: a sign-in returns to the hub address it was started from (LAN, mesh or public, as listed on the Network page). Set: pins that one callback.",
749
+ default: ""
750
+ },
751
+ {
752
+ type: "text",
753
+ key: "scopes",
754
+ label: "Scopes",
755
+ description: "Space-separated.",
756
+ default: "openid profile email"
757
+ },
758
+ {
759
+ type: "select",
760
+ key: "usernameClaim",
761
+ label: "Username claim",
762
+ default: "preferred_username",
763
+ options: [
764
+ {
765
+ value: "preferred_username",
766
+ label: "preferred_username"
767
+ },
768
+ {
769
+ value: "email",
770
+ label: "email"
771
+ },
772
+ {
773
+ value: "sub",
774
+ label: "sub (user id)"
775
+ }
776
+ ]
777
+ }
778
+ ]
779
+ }] };
780
+ //#endregion
781
+ //#region src/oidc/oidc-connections.ts
782
+ /**
783
+ * Pure helpers for OIDC connection rows in `config.providers`.
784
+ */
785
+ var INSTANCE_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
786
+ var DEFAULT_OIDC_PROVIDER = {
787
+ id: "default",
788
+ displayName: "OpenID Connect",
789
+ icon: "shield-check",
790
+ issuerUrl: "",
791
+ clientId: "",
792
+ clientSecret: "",
793
+ redirectUri: "",
794
+ scopes: "openid profile email",
795
+ usernameClaim: "preferred_username"
796
+ };
797
+ function findOidcProvider(config, id) {
798
+ return config.providers.find((p) => p.id === id) ?? null;
799
+ }
800
+ function connectionConfigured(row) {
801
+ const secret = typeof row.clientSecret === "string" ? row.clientSecret.trim() : "";
802
+ return row.clientId.trim() !== "" && secret !== "";
803
+ }
804
+ function clientSecretView(clientSecret, secrets, connectionId) {
805
+ if (isSecretMarker(clientSecret)) return toSecretFieldView(clientSecret);
806
+ const plain = typeof clientSecret === "string" ? clientSecret.trim() : "";
807
+ if (plain === "") return null;
808
+ if (secrets === void 0) return toSecretFieldView(plain);
809
+ return {
810
+ $secret: secrets.ref(globalSecretScope(), arrayItemFieldPath("providers", connectionId, "clientSecret")),
811
+ v: 1,
812
+ set: true
813
+ };
814
+ }
815
+ function createOidcConnection(config, input) {
816
+ const id = input.id.trim();
817
+ if (!INSTANCE_ID_PATTERN.test(id)) return {
818
+ ok: false,
819
+ reason: "invalid-id"
820
+ };
821
+ if (config.providers.some((p) => p.id === id)) return {
822
+ ok: false,
823
+ reason: "duplicate-id"
824
+ };
825
+ const row = {
826
+ ...DEFAULT_OIDC_PROVIDER,
827
+ id,
828
+ displayName: input.displayName.trim() || DEFAULT_OIDC_PROVIDER.displayName
829
+ };
830
+ return {
831
+ ok: true,
832
+ id,
833
+ config: { providers: [...config.providers, row] }
834
+ };
835
+ }
836
+ function updateOidcConnection(config, id, patch) {
837
+ const idx = config.providers.findIndex((p) => p.id === id);
838
+ if (idx < 0) return {
839
+ ok: false,
840
+ reason: "not-found"
841
+ };
842
+ const prev = config.providers[idx];
843
+ if (prev === void 0) return {
844
+ ok: false,
845
+ reason: "not-found"
846
+ };
847
+ const next = {
848
+ ...prev,
849
+ displayName: patch.displayName.trim() || prev.displayName,
850
+ ...patch.icon !== void 0 ? { icon: patch.icon } : {},
851
+ ...patch.issuerUrl !== void 0 ? { issuerUrl: patch.issuerUrl } : {},
852
+ ...patch.clientId !== void 0 ? { clientId: patch.clientId } : {},
853
+ ...patch.clientSecret !== void 0 ? { clientSecret: patch.clientSecret } : {},
854
+ ...patch.redirectUri !== void 0 ? { redirectUri: patch.redirectUri } : {},
855
+ ...patch.scopes !== void 0 ? { scopes: patch.scopes } : {},
856
+ ...patch.usernameClaim !== void 0 ? { usernameClaim: patch.usernameClaim } : {}
857
+ };
858
+ return {
859
+ ok: true,
860
+ config: { providers: config.providers.map((p, i) => i === idx ? next : p) },
861
+ clearClientSecret: patch.clearClientSecret === true
862
+ };
863
+ }
864
+ function deleteOidcConnection(config, id) {
865
+ if (!config.providers.some((p) => p.id === id)) return {
866
+ ok: false,
867
+ reason: "not-found"
868
+ };
869
+ return {
870
+ ok: true,
871
+ config: { providers: config.providers.filter((p) => p.id !== id) }
872
+ };
873
+ }
874
+ /** Map a wire `clientSecret` field into an update patch fragment. */
875
+ function clientSecretPatchOf(value) {
876
+ if (value === void 0) return {};
877
+ if (isSecretClear(value)) return { clearClientSecret: true };
878
+ if (value === "") return {};
879
+ return { clientSecret: value };
880
+ }
881
+ //#endregion
702
882
  //#region src/oidc/request-origin.ts
703
883
  /** host[:port] — a DNS name, IPv4 or bracketed IPv6. No userinfo, path or spaces. */
704
884
  var AUTHORITY_RE = /^(?:[a-z0-9.-]+|\[[0-9a-f:.]+\])(?::\d{1,5})?$/i;
@@ -792,6 +972,8 @@ function pickRequestOrigin(headers, allowed) {
792
972
  * `/<providerId>/callback` per configured provider. The handler
793
973
  * reads `:providerId` from the route params, picks the matching
794
974
  * config entry, and runs the OIDC flow against THAT IdP.
975
+ * - `oidc-connections` (singleton) — list / create / update / delete for
976
+ * IdP rows; Settings UI is DataTable + dialog (no editable-array).
795
977
  *
796
978
  * Each provider entry independently performs:
797
979
  * - PKCE S256 + nonce
@@ -814,17 +996,7 @@ function pickRequestOrigin(headers, allowed) {
814
996
  * - Refresh token rotation (offline_access).
815
997
  * - Persist state + nonce + PKCE across restart (multi-replica).
816
998
  */
817
- var DEFAULT_PROVIDER = {
818
- id: "default",
819
- displayName: "OpenID Connect",
820
- icon: "shield-check",
821
- issuerUrl: "",
822
- clientId: "",
823
- clientSecret: "",
824
- redirectUri: "",
825
- scopes: "openid profile email",
826
- usernameClaim: "preferred_username"
827
- };
999
+ var DEFAULT_PROVIDER = DEFAULT_OIDC_PROVIDER;
828
1000
  var DEFAULT_CONFIG = { providers: [] };
829
1001
  var STATE_TTL_MS = 5 * 6e4;
830
1002
  /**
@@ -833,12 +1005,6 @@ var STATE_TTL_MS = 5 * 6e4;
833
1005
  * so a junk value is refused here rather than carried into a signed bridge.
834
1006
  */
835
1007
  var LINK_INTENT_PATTERN = /^[A-Za-z0-9_-]{16,128}$/;
836
- /**
837
- * An instance id appears in URLs and in the identity `oidc:<id>:<sub>`; a `:`
838
- * would make two identities read the same, so ids are slugs. A configured row
839
- * whose id is not one is skipped.
840
- */
841
- var INSTANCE_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
842
1008
  /** Bound on in-flight logins: `/start` is public, so a flood must not grow the map. */
843
1009
  var MAX_PENDING_STATES = 1e3;
844
1010
  /**
@@ -860,9 +1026,14 @@ var AuthOidcAddon = class extends BaseAddon {
860
1026
  /** Pending OAuth states across ALL providers. The pending entry
861
1027
  * carries `providerId` so the /callback handler picks the right config. */
862
1028
  pendingStates = /* @__PURE__ */ new Map();
1029
+ /** Keychain path for each IdP's client secret (D787 / D828 sibling). */
1030
+ secretStatePaths = ["providers[id].clientSecret"];
863
1031
  constructor() {
864
1032
  super({ ...DEFAULT_CONFIG });
865
1033
  }
1034
+ async onConfigChanged() {
1035
+ this.rebuildInstances();
1036
+ }
866
1037
  async onInitialize() {
867
1038
  this.rebuildInstances();
868
1039
  const authProvider = {
@@ -909,9 +1080,84 @@ var AuthOidcAddon = class extends BaseAddon {
909
1080
  {
910
1081
  capability: loginMethodCapability,
911
1082
  provider: loginMethodProvider
1083
+ },
1084
+ {
1085
+ capability: oidcConnectionsCapability,
1086
+ provider: this.connectionsProvider()
912
1087
  }
913
1088
  ];
914
1089
  }
1090
+ connectionsProvider() {
1091
+ return {
1092
+ connectionFormSchema: async () => OIDC_CONNECTION_FORM_SCHEMA,
1093
+ listConnections: async () => {
1094
+ const secrets = this.ctx.secrets;
1095
+ return this.config.providers.map((row) => {
1096
+ const merged = {
1097
+ ...DEFAULT_PROVIDER,
1098
+ ...row
1099
+ };
1100
+ return {
1101
+ id: merged.id,
1102
+ displayName: merged.displayName,
1103
+ icon: isDisplayIconKey(merged.icon) ? merged.icon : DEFAULT_OIDC_ICON,
1104
+ issuerUrl: merged.issuerUrl,
1105
+ clientId: merged.clientId,
1106
+ configured: connectionConfigured(merged),
1107
+ formValues: {
1108
+ displayName: merged.displayName,
1109
+ icon: merged.icon,
1110
+ issuerUrl: merged.issuerUrl,
1111
+ clientId: merged.clientId,
1112
+ clientSecret: clientSecretView(merged.clientSecret, secrets, merged.id) ?? "",
1113
+ redirectUri: merged.redirectUri,
1114
+ scopes: merged.scopes,
1115
+ usernameClaim: merged.usernameClaim
1116
+ }
1117
+ };
1118
+ });
1119
+ },
1120
+ createConnection: async (input) => {
1121
+ const result = createOidcConnection(this.config, input);
1122
+ if (!result.ok) throw new Error(result.reason === "duplicate-id" ? `An OIDC connection with id "${input.id}" already exists` : `Invalid connection id "${input.id}" — use a lowercase slug`);
1123
+ await this.updateGlobalSettings(result.config);
1124
+ this.rebuildInstances();
1125
+ return { id: result.id };
1126
+ },
1127
+ updateConnection: async (input) => {
1128
+ const secretPatch = clientSecretPatchOf(input.clientSecret);
1129
+ const result = updateOidcConnection(this.config, input.id, {
1130
+ displayName: input.displayName,
1131
+ ...input.icon !== void 0 ? { icon: input.icon } : {},
1132
+ ...input.issuerUrl !== void 0 ? { issuerUrl: input.issuerUrl } : {},
1133
+ ...input.clientId !== void 0 ? { clientId: input.clientId } : {},
1134
+ ...secretPatch,
1135
+ ...input.redirectUri !== void 0 ? { redirectUri: input.redirectUri } : {},
1136
+ ...input.scopes !== void 0 ? { scopes: input.scopes } : {},
1137
+ ...input.usernameClaim !== void 0 ? { usernameClaim: input.usernameClaim } : {}
1138
+ });
1139
+ if (!result.ok) throw new Error(`Unknown OIDC connection "${input.id}"`);
1140
+ if (result.clearClientSecret) {
1141
+ const cleared = result.config.providers.map((p) => p.id === input.id ? {
1142
+ ...p,
1143
+ clientSecret: SECRET_CLEAR
1144
+ } : p);
1145
+ await this.updateGlobalSettings({ providers: cleared });
1146
+ } else await this.updateGlobalSettings(result.config);
1147
+ this.rebuildInstances();
1148
+ return { ok: true };
1149
+ },
1150
+ deleteConnection: async (input) => {
1151
+ if (findOidcProvider(this.config, input.id) === null) throw new Error(`Unknown OIDC connection "${input.id}"`);
1152
+ const result = deleteOidcConnection(this.config, input.id);
1153
+ if (!result.ok) throw new Error(`Unknown OIDC connection "${input.id}"`);
1154
+ await this.updateGlobalSettings(result.config);
1155
+ await this.clearSecrets([`providers[${input.id}].clientSecret`]);
1156
+ this.rebuildInstances();
1157
+ return { ok: true };
1158
+ }
1159
+ };
1160
+ }
915
1161
  /**
916
1162
  * Build one `redirect` login-method per configured provider instance.
917
1163
  * `startUrl` is the addon's public `/start` route for that instance;
@@ -936,92 +1182,9 @@ var AuthOidcAddon = class extends BaseAddon {
936
1182
  globalSettingsSchema() {
937
1183
  return this.schema({ sections: [{
938
1184
  id: "oidc",
939
- title: "OIDC Providers",
940
- description: "Configure one or more IdPs (Google, Microsoft, Okta, Keycloak, …). Each entry produces an independent login button. The redirect URI shown on the IdP-side must include the provider id in the path: `<origin>/addon/auth-oidc/<id>/callback`.",
941
- columns: 1,
942
- fields: [this.field({
943
- type: "editable-array",
944
- key: "providers",
945
- label: "Providers",
946
- description: "Each row is a distinct OIDC IdP. Click + to add.",
947
- default: [],
948
- itemFields: [
949
- {
950
- type: "text",
951
- key: "id",
952
- label: "Instance id",
953
- description: "URL-friendly slug — appears in the redirect URI as /addon/auth-oidc/<id>/callback. Stable; renaming breaks any IdP-side registrations.",
954
- default: ""
955
- },
956
- {
957
- type: "text",
958
- key: "displayName",
959
- label: "Display name",
960
- description: "Shown on the login button.",
961
- default: "OpenID Connect"
962
- },
963
- {
964
- type: "icon",
965
- key: "icon",
966
- label: "Icon",
967
- description: "Shown on the login button.",
968
- default: DEFAULT_PROVIDER.icon
969
- },
970
- {
971
- type: "text",
972
- key: "issuerUrl",
973
- label: "Issuer URL",
974
- description: "IdP base URL — discovery doc lives at <issuer>/.well-known/openid-configuration.",
975
- default: ""
976
- },
977
- {
978
- type: "text",
979
- key: "clientId",
980
- label: "Client ID",
981
- default: ""
982
- },
983
- {
984
- type: "password",
985
- key: "clientSecret",
986
- label: "Client Secret",
987
- default: ""
988
- },
989
- {
990
- type: "text",
991
- key: "redirectUri",
992
- label: "Redirect URI override",
993
- description: "Optional — leave empty. Empty: a sign-in returns to the hub address it was started from (LAN, mesh or public, as listed on the Network page), so register one callback per address you sign in from at the IdP. Set: it PINS that one callback — every sign-in returns to its address, wherever it started.",
994
- default: ""
995
- },
996
- {
997
- type: "text",
998
- key: "scopes",
999
- label: "Scopes",
1000
- description: "Space-separated.",
1001
- default: "openid profile email"
1002
- },
1003
- {
1004
- type: "select",
1005
- key: "usernameClaim",
1006
- label: "Username claim",
1007
- default: "preferred_username",
1008
- options: [
1009
- {
1010
- value: "preferred_username",
1011
- label: "preferred_username"
1012
- },
1013
- {
1014
- value: "email",
1015
- label: "email"
1016
- },
1017
- {
1018
- value: "sub",
1019
- label: "sub (user id)"
1020
- }
1021
- ]
1022
- }
1023
- ]
1024
- })]
1185
+ title: "OpenID Connect",
1186
+ description: "Manage IdP connections in this page’s Settings table (Add / Edit). Each connection’s redirect URI is `<origin>/addon/auth-oidc/<id>/callback`. Credentials stay in the CamStack keychain.",
1187
+ fields: []
1025
1188
  }] });
1026
1189
  }
1027
1190
  rebuildInstances() {
@@ -1,6 +1,6 @@
1
1
  import { n as e, r as t, t as n } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare__react__loadShare__.js-BIIa6vDX.mjs";
2
2
  import { n as r, t as i } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CQ-aEQ9b.mjs";
3
- import { t as a } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CqD_DCcZ.mjs";
3
+ import { t as a } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-D5ZLhXzm.mjs";
4
4
  import { n as o, r as s, t as c } from "./_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-BL2etuqg.mjs";
5
5
  //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.js
6
6
  var l = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), u = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), d = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), f = (e) => {
@@ -3,7 +3,7 @@ import "./dist-CYZr2fwk.mjs";
3
3
  var e = {
4
4
  "@camstack/sdk": {
5
5
  name: "@camstack/sdk",
6
- version: "1.2.129",
6
+ version: "1.2.131",
7
7
  scope: ["default"],
8
8
  loaded: !1,
9
9
  from: "addon_auth_webauthn_widgets",
@@ -18,7 +18,7 @@ var e = {
18
18
  },
19
19
  "@camstack/types": {
20
20
  name: "@camstack/types",
21
- version: "1.2.348",
21
+ version: "1.2.350",
22
22
  scope: ["default"],
23
23
  loaded: !1,
24
24
  from: "addon_auth_webauthn_widgets",
@@ -33,7 +33,7 @@ var e = {
33
33
  },
34
34
  "@camstack/ui-library": {
35
35
  name: "@camstack/ui-library",
36
- version: "1.2.275",
36
+ version: "1.2.277",
37
37
  scope: ["default"],
38
38
  loaded: !1,
39
39
  from: "addon_auth_webauthn_widgets",