@camstack/addon-auth 1.2.137 → 1.2.140

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,188 @@ 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
+ columns: 2,
708
+ fields: [{
709
+ type: "text",
710
+ key: "displayName",
711
+ label: "Display name",
712
+ description: "Shown on the login button.",
713
+ default: "OpenID Connect"
714
+ }, {
715
+ type: "icon",
716
+ key: "icon",
717
+ label: "Icon",
718
+ description: "Shown on the login button.",
719
+ default: DEFAULT_OIDC_ICON
720
+ }]
721
+ }, {
722
+ id: "idp",
723
+ title: "Identity provider",
724
+ columns: 2,
725
+ fields: [
726
+ {
727
+ type: "text",
728
+ key: "issuerUrl",
729
+ label: "Issuer URL",
730
+ description: "IdP base URL — discovery doc lives at <issuer>/.well-known/openid-configuration.",
731
+ default: ""
732
+ },
733
+ {
734
+ type: "text",
735
+ key: "clientId",
736
+ label: "Client ID",
737
+ default: ""
738
+ },
739
+ {
740
+ type: "password",
741
+ key: "clientSecret",
742
+ label: "Client Secret",
743
+ showToggle: true,
744
+ default: ""
745
+ },
746
+ {
747
+ type: "text",
748
+ key: "redirectUri",
749
+ label: "Redirect URI override",
750
+ 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.",
751
+ default: ""
752
+ },
753
+ {
754
+ type: "text",
755
+ key: "scopes",
756
+ label: "Scopes",
757
+ description: "Space-separated.",
758
+ default: "openid profile email"
759
+ },
760
+ {
761
+ type: "select",
762
+ key: "usernameClaim",
763
+ label: "Username claim",
764
+ default: "preferred_username",
765
+ options: [
766
+ {
767
+ value: "preferred_username",
768
+ label: "preferred_username"
769
+ },
770
+ {
771
+ value: "email",
772
+ label: "email"
773
+ },
774
+ {
775
+ value: "sub",
776
+ label: "sub (user id)"
777
+ }
778
+ ]
779
+ }
780
+ ]
781
+ }] };
782
+ //#endregion
783
+ //#region src/oidc/oidc-connections.ts
784
+ /**
785
+ * Pure helpers for OIDC connection rows in `config.providers`.
786
+ */
787
+ var INSTANCE_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
788
+ var DEFAULT_OIDC_PROVIDER = {
789
+ id: "default",
790
+ displayName: "OpenID Connect",
791
+ icon: "shield-check",
792
+ issuerUrl: "",
793
+ clientId: "",
794
+ clientSecret: "",
795
+ redirectUri: "",
796
+ scopes: "openid profile email",
797
+ usernameClaim: "preferred_username"
798
+ };
799
+ function findOidcProvider(config, id) {
800
+ return config.providers.find((p) => p.id === id) ?? null;
801
+ }
802
+ function connectionConfigured(row) {
803
+ const secret = typeof row.clientSecret === "string" ? row.clientSecret.trim() : "";
804
+ return row.clientId.trim() !== "" && secret !== "";
805
+ }
806
+ function clientSecretView(clientSecret, secrets, connectionId) {
807
+ if (isSecretMarker(clientSecret)) return toSecretFieldView(clientSecret);
808
+ const plain = typeof clientSecret === "string" ? clientSecret.trim() : "";
809
+ if (plain === "") return null;
810
+ if (secrets === void 0) return toSecretFieldView(plain);
811
+ return {
812
+ $secret: secrets.ref(globalSecretScope(), arrayItemFieldPath("providers", connectionId, "clientSecret")),
813
+ v: 1,
814
+ set: true
815
+ };
816
+ }
817
+ function createOidcConnection(config, input) {
818
+ const id = input.id.trim();
819
+ if (!INSTANCE_ID_PATTERN.test(id)) return {
820
+ ok: false,
821
+ reason: "invalid-id"
822
+ };
823
+ if (config.providers.some((p) => p.id === id)) return {
824
+ ok: false,
825
+ reason: "duplicate-id"
826
+ };
827
+ const row = {
828
+ ...DEFAULT_OIDC_PROVIDER,
829
+ id,
830
+ displayName: input.displayName.trim() || DEFAULT_OIDC_PROVIDER.displayName
831
+ };
832
+ return {
833
+ ok: true,
834
+ id,
835
+ config: { providers: [...config.providers, row] }
836
+ };
837
+ }
838
+ function updateOidcConnection(config, id, patch) {
839
+ const idx = config.providers.findIndex((p) => p.id === id);
840
+ if (idx < 0) return {
841
+ ok: false,
842
+ reason: "not-found"
843
+ };
844
+ const prev = config.providers[idx];
845
+ if (prev === void 0) return {
846
+ ok: false,
847
+ reason: "not-found"
848
+ };
849
+ const next = {
850
+ ...prev,
851
+ displayName: patch.displayName.trim() || prev.displayName,
852
+ ...patch.icon !== void 0 ? { icon: patch.icon } : {},
853
+ ...patch.issuerUrl !== void 0 ? { issuerUrl: patch.issuerUrl } : {},
854
+ ...patch.clientId !== void 0 ? { clientId: patch.clientId } : {},
855
+ ...patch.clientSecret !== void 0 ? { clientSecret: patch.clientSecret } : {},
856
+ ...patch.redirectUri !== void 0 ? { redirectUri: patch.redirectUri } : {},
857
+ ...patch.scopes !== void 0 ? { scopes: patch.scopes } : {},
858
+ ...patch.usernameClaim !== void 0 ? { usernameClaim: patch.usernameClaim } : {}
859
+ };
860
+ return {
861
+ ok: true,
862
+ config: { providers: config.providers.map((p, i) => i === idx ? next : p) },
863
+ clearClientSecret: patch.clearClientSecret === true
864
+ };
865
+ }
866
+ function deleteOidcConnection(config, id) {
867
+ if (!config.providers.some((p) => p.id === id)) return {
868
+ ok: false,
869
+ reason: "not-found"
870
+ };
871
+ return {
872
+ ok: true,
873
+ config: { providers: config.providers.filter((p) => p.id !== id) }
874
+ };
875
+ }
876
+ /** Map a wire `clientSecret` field into an update patch fragment. */
877
+ function clientSecretPatchOf(value) {
878
+ if (value === void 0) return {};
879
+ if (isSecretClear(value)) return { clearClientSecret: true };
880
+ if (value === "") return {};
881
+ return { clientSecret: value };
882
+ }
883
+ //#endregion
702
884
  //#region src/oidc/request-origin.ts
703
885
  /** host[:port] — a DNS name, IPv4 or bracketed IPv6. No userinfo, path or spaces. */
704
886
  var AUTHORITY_RE = /^(?:[a-z0-9.-]+|\[[0-9a-f:.]+\])(?::\d{1,5})?$/i;
@@ -792,6 +974,8 @@ function pickRequestOrigin(headers, allowed) {
792
974
  * `/<providerId>/callback` per configured provider. The handler
793
975
  * reads `:providerId` from the route params, picks the matching
794
976
  * config entry, and runs the OIDC flow against THAT IdP.
977
+ * - `oidc-connections` (singleton) — list / create / update / delete for
978
+ * IdP rows; Settings UI is DataTable + dialog (no editable-array).
795
979
  *
796
980
  * Each provider entry independently performs:
797
981
  * - PKCE S256 + nonce
@@ -814,17 +998,7 @@ function pickRequestOrigin(headers, allowed) {
814
998
  * - Refresh token rotation (offline_access).
815
999
  * - Persist state + nonce + PKCE across restart (multi-replica).
816
1000
  */
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
- };
1001
+ var DEFAULT_PROVIDER = DEFAULT_OIDC_PROVIDER;
828
1002
  var DEFAULT_CONFIG = { providers: [] };
829
1003
  var STATE_TTL_MS = 5 * 6e4;
830
1004
  /**
@@ -833,12 +1007,6 @@ var STATE_TTL_MS = 5 * 6e4;
833
1007
  * so a junk value is refused here rather than carried into a signed bridge.
834
1008
  */
835
1009
  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
1010
  /** Bound on in-flight logins: `/start` is public, so a flood must not grow the map. */
843
1011
  var MAX_PENDING_STATES = 1e3;
844
1012
  /**
@@ -860,9 +1028,14 @@ var AuthOidcAddon = class extends BaseAddon {
860
1028
  /** Pending OAuth states across ALL providers. The pending entry
861
1029
  * carries `providerId` so the /callback handler picks the right config. */
862
1030
  pendingStates = /* @__PURE__ */ new Map();
1031
+ /** Keychain path for each IdP's client secret (D787 / D828 sibling). */
1032
+ secretStatePaths = ["providers[id].clientSecret"];
863
1033
  constructor() {
864
1034
  super({ ...DEFAULT_CONFIG });
865
1035
  }
1036
+ async onConfigChanged() {
1037
+ this.rebuildInstances();
1038
+ }
866
1039
  async onInitialize() {
867
1040
  this.rebuildInstances();
868
1041
  const authProvider = {
@@ -909,9 +1082,84 @@ var AuthOidcAddon = class extends BaseAddon {
909
1082
  {
910
1083
  capability: loginMethodCapability,
911
1084
  provider: loginMethodProvider
1085
+ },
1086
+ {
1087
+ capability: oidcConnectionsCapability,
1088
+ provider: this.connectionsProvider()
912
1089
  }
913
1090
  ];
914
1091
  }
1092
+ connectionsProvider() {
1093
+ return {
1094
+ connectionFormSchema: async () => OIDC_CONNECTION_FORM_SCHEMA,
1095
+ listConnections: async () => {
1096
+ const secrets = this.ctx.secrets;
1097
+ return this.config.providers.map((row) => {
1098
+ const merged = {
1099
+ ...DEFAULT_PROVIDER,
1100
+ ...row
1101
+ };
1102
+ return {
1103
+ id: merged.id,
1104
+ displayName: merged.displayName,
1105
+ icon: isDisplayIconKey(merged.icon) ? merged.icon : DEFAULT_OIDC_ICON,
1106
+ issuerUrl: merged.issuerUrl,
1107
+ clientId: merged.clientId,
1108
+ configured: connectionConfigured(merged),
1109
+ formValues: {
1110
+ displayName: merged.displayName,
1111
+ icon: merged.icon,
1112
+ issuerUrl: merged.issuerUrl,
1113
+ clientId: merged.clientId,
1114
+ clientSecret: clientSecretView(merged.clientSecret, secrets, merged.id) ?? "",
1115
+ redirectUri: merged.redirectUri,
1116
+ scopes: merged.scopes,
1117
+ usernameClaim: merged.usernameClaim
1118
+ }
1119
+ };
1120
+ });
1121
+ },
1122
+ createConnection: async (input) => {
1123
+ const result = createOidcConnection(this.config, input);
1124
+ 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`);
1125
+ await this.updateGlobalSettings(result.config);
1126
+ this.rebuildInstances();
1127
+ return { id: result.id };
1128
+ },
1129
+ updateConnection: async (input) => {
1130
+ const secretPatch = clientSecretPatchOf(input.clientSecret);
1131
+ const result = updateOidcConnection(this.config, input.id, {
1132
+ displayName: input.displayName,
1133
+ ...input.icon !== void 0 ? { icon: input.icon } : {},
1134
+ ...input.issuerUrl !== void 0 ? { issuerUrl: input.issuerUrl } : {},
1135
+ ...input.clientId !== void 0 ? { clientId: input.clientId } : {},
1136
+ ...secretPatch,
1137
+ ...input.redirectUri !== void 0 ? { redirectUri: input.redirectUri } : {},
1138
+ ...input.scopes !== void 0 ? { scopes: input.scopes } : {},
1139
+ ...input.usernameClaim !== void 0 ? { usernameClaim: input.usernameClaim } : {}
1140
+ });
1141
+ if (!result.ok) throw new Error(`Unknown OIDC connection "${input.id}"`);
1142
+ if (result.clearClientSecret) {
1143
+ const cleared = result.config.providers.map((p) => p.id === input.id ? {
1144
+ ...p,
1145
+ clientSecret: SECRET_CLEAR
1146
+ } : p);
1147
+ await this.updateGlobalSettings({ providers: cleared });
1148
+ } else await this.updateGlobalSettings(result.config);
1149
+ this.rebuildInstances();
1150
+ return { ok: true };
1151
+ },
1152
+ deleteConnection: async (input) => {
1153
+ if (findOidcProvider(this.config, input.id) === null) throw new Error(`Unknown OIDC connection "${input.id}"`);
1154
+ const result = deleteOidcConnection(this.config, input.id);
1155
+ if (!result.ok) throw new Error(`Unknown OIDC connection "${input.id}"`);
1156
+ await this.updateGlobalSettings(result.config);
1157
+ await this.clearSecrets([`providers[${input.id}].clientSecret`]);
1158
+ this.rebuildInstances();
1159
+ return { ok: true };
1160
+ }
1161
+ };
1162
+ }
915
1163
  /**
916
1164
  * Build one `redirect` login-method per configured provider instance.
917
1165
  * `startUrl` is the addon's public `/start` route for that instance;
@@ -936,92 +1184,9 @@ var AuthOidcAddon = class extends BaseAddon {
936
1184
  globalSettingsSchema() {
937
1185
  return this.schema({ sections: [{
938
1186
  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
- })]
1187
+ title: "OpenID Connect",
1188
+ 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.",
1189
+ fields: []
1025
1190
  }] });
1026
1191
  }
1027
1192
  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.278",
37
37
  scope: ["default"],
38
38
  loaded: !1,
39
39
  from: "addon_auth_webauthn_widgets",