@stigmer/react 0.0.89 → 0.0.91

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 (128) hide show
  1. package/identity-provider/CreateIdentityProviderForm.d.ts.map +1 -1
  2. package/identity-provider/CreateIdentityProviderForm.js +60 -2
  3. package/identity-provider/CreateIdentityProviderForm.js.map +1 -1
  4. package/identity-provider/IdentityProviderDetailPanel.d.ts.map +1 -1
  5. package/identity-provider/IdentityProviderDetailPanel.js +87 -4
  6. package/identity-provider/IdentityProviderDetailPanel.js.map +1 -1
  7. package/identity-provider/IdentityProviderListPanel.js +5 -3
  8. package/identity-provider/IdentityProviderListPanel.js.map +1 -1
  9. package/identity-provider/IdentityProviderWizard.d.ts.map +1 -1
  10. package/identity-provider/IdentityProviderWizard.js +59 -4
  11. package/identity-provider/IdentityProviderWizard.js.map +1 -1
  12. package/index.d.ts +2 -0
  13. package/index.d.ts.map +1 -1
  14. package/index.js +2 -0
  15. package/index.js.map +1 -1
  16. package/package.json +7 -7
  17. package/platform-client/CreatePlatformClientForm.d.ts +42 -0
  18. package/platform-client/CreatePlatformClientForm.d.ts.map +1 -0
  19. package/platform-client/CreatePlatformClientForm.js +148 -0
  20. package/platform-client/CreatePlatformClientForm.js.map +1 -0
  21. package/platform-client/PlatformClientDetailPanel.d.ts +51 -0
  22. package/platform-client/PlatformClientDetailPanel.d.ts.map +1 -0
  23. package/platform-client/PlatformClientDetailPanel.js +247 -0
  24. package/platform-client/PlatformClientDetailPanel.js.map +1 -0
  25. package/platform-client/PlatformClientListPanel.d.ts +41 -0
  26. package/platform-client/PlatformClientListPanel.d.ts.map +1 -0
  27. package/platform-client/PlatformClientListPanel.js +123 -0
  28. package/platform-client/PlatformClientListPanel.js.map +1 -0
  29. package/platform-client/PlatformClientSecretAlert.d.ts +39 -0
  30. package/platform-client/PlatformClientSecretAlert.d.ts.map +1 -0
  31. package/platform-client/PlatformClientSecretAlert.js +74 -0
  32. package/platform-client/PlatformClientSecretAlert.js.map +1 -0
  33. package/platform-client/index.d.ts +11 -0
  34. package/platform-client/index.d.ts.map +1 -0
  35. package/platform-client/index.js +11 -0
  36. package/platform-client/index.js.map +1 -0
  37. package/platform-client/useCreatePlatformClient.d.ts +42 -0
  38. package/platform-client/useCreatePlatformClient.d.ts.map +1 -0
  39. package/platform-client/useCreatePlatformClient.js +49 -0
  40. package/platform-client/useCreatePlatformClient.js.map +1 -0
  41. package/platform-client/useDeletePlatformClient.d.ts +31 -0
  42. package/platform-client/useDeletePlatformClient.d.ts.map +1 -0
  43. package/platform-client/useDeletePlatformClient.js +42 -0
  44. package/platform-client/useDeletePlatformClient.js.map +1 -0
  45. package/platform-client/usePlatformClient.d.ts +37 -0
  46. package/platform-client/usePlatformClient.d.ts.map +1 -0
  47. package/platform-client/usePlatformClient.js +62 -0
  48. package/platform-client/usePlatformClient.js.map +1 -0
  49. package/platform-client/usePlatformClientList.d.ts +42 -0
  50. package/platform-client/usePlatformClientList.d.ts.map +1 -0
  51. package/platform-client/usePlatformClientList.js +71 -0
  52. package/platform-client/usePlatformClientList.js.map +1 -0
  53. package/platform-client/useRotatePlatformClientSecret.d.ts +35 -0
  54. package/platform-client/useRotatePlatformClientSecret.d.ts.map +1 -0
  55. package/platform-client/useRotatePlatformClientSecret.js +43 -0
  56. package/platform-client/useRotatePlatformClientSecret.js.map +1 -0
  57. package/platform-client/useUpdatePlatformClient.d.ts +39 -0
  58. package/platform-client/useUpdatePlatformClient.d.ts.map +1 -0
  59. package/platform-client/useUpdatePlatformClient.js +50 -0
  60. package/platform-client/useUpdatePlatformClient.js.map +1 -0
  61. package/src/identity-provider/CreateIdentityProviderForm.tsx +220 -0
  62. package/src/identity-provider/IdentityProviderDetailPanel.tsx +288 -6
  63. package/src/identity-provider/IdentityProviderListPanel.tsx +9 -2
  64. package/src/identity-provider/IdentityProviderWizard.tsx +231 -25
  65. package/src/index.ts +26 -0
  66. package/src/platform-client/CreatePlatformClientForm.tsx +519 -0
  67. package/src/platform-client/PlatformClientDetailPanel.tsx +898 -0
  68. package/src/platform-client/PlatformClientListPanel.tsx +413 -0
  69. package/src/platform-client/PlatformClientSecretAlert.tsx +252 -0
  70. package/src/platform-client/index.ts +49 -0
  71. package/src/platform-client/useCreatePlatformClient.ts +77 -0
  72. package/src/platform-client/useDeletePlatformClient.ts +64 -0
  73. package/src/platform-client/usePlatformClient.ts +86 -0
  74. package/src/platform-client/usePlatformClientList.ts +96 -0
  75. package/src/platform-client/useRotatePlatformClientSecret.ts +68 -0
  76. package/src/platform-client/useUpdatePlatformClient.ts +70 -0
  77. package/src/test/index.ts +6 -0
  78. package/src/{demo → test}/samples.ts +1 -1
  79. package/styles.css +1 -1
  80. package/test/__tests__/samples.test.d.ts.map +1 -0
  81. package/{demo → test}/__tests__/samples.test.js.map +1 -1
  82. package/test/index.d.ts +2 -0
  83. package/test/index.d.ts.map +1 -0
  84. package/test/index.js +6 -0
  85. package/test/index.js.map +1 -0
  86. package/{demo → test}/samples.d.ts +1 -1
  87. package/{demo → test}/samples.d.ts.map +1 -1
  88. package/{demo → test}/samples.js +1 -1
  89. package/{demo → test}/samples.js.map +1 -1
  90. package/demo/__tests__/demo-client.test.d.ts +0 -2
  91. package/demo/__tests__/demo-client.test.d.ts.map +0 -1
  92. package/demo/__tests__/demo-client.test.js +0 -133
  93. package/demo/__tests__/demo-client.test.js.map +0 -1
  94. package/demo/__tests__/fixtures.test.d.ts +0 -2
  95. package/demo/__tests__/fixtures.test.d.ts.map +0 -1
  96. package/demo/__tests__/fixtures.test.js +0 -135
  97. package/demo/__tests__/fixtures.test.js.map +0 -1
  98. package/demo/__tests__/samples.test.d.ts.map +0 -1
  99. package/demo/client.d.ts +0 -29
  100. package/demo/client.d.ts.map +0 -1
  101. package/demo/client.js +0 -52
  102. package/demo/client.js.map +0 -1
  103. package/demo/fixtures.d.ts +0 -194
  104. package/demo/fixtures.d.ts.map +0 -1
  105. package/demo/fixtures.js +0 -267
  106. package/demo/fixtures.js.map +0 -1
  107. package/demo/index.d.ts +0 -6
  108. package/demo/index.d.ts.map +0 -1
  109. package/demo/index.js +0 -6
  110. package/demo/index.js.map +0 -1
  111. package/demo/transport.d.ts +0 -59
  112. package/demo/transport.d.ts.map +0 -1
  113. package/demo/transport.js +0 -75
  114. package/demo/transport.js.map +0 -1
  115. package/demo/types.d.ts +0 -62
  116. package/demo/types.d.ts.map +0 -1
  117. package/demo/types.js +0 -16
  118. package/demo/types.js.map +0 -1
  119. package/src/demo/__tests__/demo-client.test.tsx +0 -213
  120. package/src/demo/__tests__/fixtures.test.ts +0 -214
  121. package/src/demo/client.ts +0 -78
  122. package/src/demo/fixtures.ts +0 -409
  123. package/src/demo/index.ts +0 -12
  124. package/src/demo/transport.ts +0 -116
  125. package/src/demo/types.ts +0 -69
  126. /package/src/{demo → test}/__tests__/samples.test.ts +0 -0
  127. /package/{demo → test}/__tests__/samples.test.d.ts +0 -0
  128. /package/{demo → test}/__tests__/samples.test.js +0 -0
@@ -8,6 +8,7 @@ import {
8
8
  import { cn } from "@stigmer/theme";
9
9
  import { getUserMessage } from "@stigmer/sdk";
10
10
  import type { IdentityProvider } from "@stigmer/protos/ai/stigmer/iam/identityprovider/v1/api_pb";
11
+ import { IamRole } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
11
12
  import { ProviderPicker } from "./ProviderPicker";
12
13
  import { useCreateIdentityProvider } from "./useCreateIdentityProvider";
13
14
  import { useOidcDiscovery } from "./useOidcDiscovery";
@@ -81,6 +82,12 @@ export function IdentityProviderWizard({
81
82
  const [oidcClientId, setOidcClientId] = useState("");
82
83
  const [discoveryFailed, setDiscoveryFailed] = useState(false);
83
84
 
85
+ // JIT provisioning
86
+ const [autoProvision, setAutoProvision] = useState(false);
87
+ const [autoGrant, setAutoGrant] = useState(false);
88
+ const [autoGrantRole, setAutoGrantRole] = useState<IamRole>(IamRole.iam_role_unspecified);
89
+ const [tenantOrgClaim, setTenantOrgClaim] = useState("");
90
+
84
91
  // -- Step transitions ------------------------------------------------
85
92
 
86
93
  const handlePickProvider = useCallback((selected: ProviderPreset) => {
@@ -130,6 +137,24 @@ export function IdentityProviderWizard({
130
137
 
131
138
  // -- Submit ----------------------------------------------------------
132
139
 
140
+ const handleAutoProvisionChange = useCallback((v: boolean) => {
141
+ setAutoProvision(v);
142
+ if (!v) {
143
+ setAutoGrant(false);
144
+ setAutoGrantRole(IamRole.iam_role_unspecified);
145
+ setTenantOrgClaim("");
146
+ }
147
+ }, []);
148
+
149
+ const handleAutoGrantChange = useCallback((v: boolean) => {
150
+ setAutoGrant(v);
151
+ if (v) setAutoProvision(true);
152
+ if (!v) {
153
+ setAutoGrantRole(IamRole.iam_role_unspecified);
154
+ setTenantOrgClaim("");
155
+ }
156
+ }, []);
157
+
133
158
  const handleSubmit = useCallback(
134
159
  async (e: FormEvent) => {
135
160
  e.preventDefault();
@@ -150,6 +175,16 @@ export function IdentityProviderWizard({
150
175
  isSsoProvider: true,
151
176
  oidcClientId: oidcClientId.trim(),
152
177
  }),
178
+ ...(!isSso && {
179
+ autoProvisionAccounts: autoProvision,
180
+ autoGrantOnOrg: autoGrant,
181
+ ...(autoGrant && autoGrantRole !== IamRole.iam_role_unspecified && {
182
+ autoGrantRole,
183
+ }),
184
+ ...(autoGrant && tenantOrgClaim.trim() && {
185
+ tenantOrgClaim: tenantOrgClaim.trim(),
186
+ }),
187
+ }),
153
188
  });
154
189
  onCreated?.(idp);
155
190
  } catch {
@@ -158,7 +193,8 @@ export function IdentityProviderWizard({
158
193
  },
159
194
  [
160
195
  name, org, jwksUri, issuers, audience, userinfoEndpoint,
161
- isSso, oidcClientId, create, clearError, onCreated,
196
+ isSso, oidcClientId, autoProvision, autoGrant, autoGrantRole,
197
+ tenantOrgClaim, create, clearError, onCreated,
162
198
  ],
163
199
  );
164
200
 
@@ -216,6 +252,14 @@ export function IdentityProviderWizard({
216
252
  onIsSsoChange={setIsSso}
217
253
  oidcClientId={oidcClientId}
218
254
  onOidcClientIdChange={setOidcClientId}
255
+ autoProvision={autoProvision}
256
+ onAutoProvisionChange={handleAutoProvisionChange}
257
+ autoGrant={autoGrant}
258
+ onAutoGrantChange={handleAutoGrantChange}
259
+ autoGrantRole={autoGrantRole}
260
+ onAutoGrantRoleChange={setAutoGrantRole}
261
+ tenantOrgClaim={tenantOrgClaim}
262
+ onTenantOrgClaimChange={setTenantOrgClaim}
219
263
  isCreating={isCreating}
220
264
  createError={createError}
221
265
  onBack={handleBackToConfigure}
@@ -407,6 +451,14 @@ function ReviewStep({
407
451
  onIsSsoChange,
408
452
  oidcClientId,
409
453
  onOidcClientIdChange,
454
+ autoProvision,
455
+ onAutoProvisionChange,
456
+ autoGrant,
457
+ onAutoGrantChange,
458
+ autoGrantRole,
459
+ onAutoGrantRoleChange,
460
+ tenantOrgClaim,
461
+ onTenantOrgClaimChange,
410
462
  isCreating,
411
463
  createError,
412
464
  onBack,
@@ -424,6 +476,14 @@ function ReviewStep({
424
476
  onIsSsoChange: (v: boolean) => void;
425
477
  oidcClientId: string;
426
478
  onOidcClientIdChange: (v: string) => void;
479
+ autoProvision: boolean;
480
+ onAutoProvisionChange: (v: boolean) => void;
481
+ autoGrant: boolean;
482
+ onAutoGrantChange: (v: boolean) => void;
483
+ autoGrantRole: IamRole;
484
+ onAutoGrantRoleChange: (v: IamRole) => void;
485
+ tenantOrgClaim: string;
486
+ onTenantOrgClaimChange: (v: string) => void;
427
487
  isCreating: boolean;
428
488
  createError: Error | null;
429
489
  onBack: () => void;
@@ -484,30 +544,12 @@ function ReviewStep({
484
544
  />
485
545
 
486
546
  {/* SSO toggle */}
487
- <div className="flex items-center gap-2">
488
- <button
489
- type="button"
490
- role="switch"
491
- aria-checked={isSso}
492
- onClick={() => onIsSsoChange(!isSso)}
493
- disabled={isCreating}
494
- className={cn(
495
- "relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",
496
- isSso ? "bg-primary" : "bg-muted",
497
- "disabled:pointer-events-none disabled:opacity-50",
498
- )}
499
- >
500
- <span
501
- className={cn(
502
- "pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform",
503
- isSso ? "translate-x-4" : "translate-x-0",
504
- )}
505
- />
506
- </button>
507
- <span className="text-xs font-medium text-foreground">
508
- SSO provider
509
- </span>
510
- </div>
547
+ <ToggleSwitch
548
+ checked={isSso}
549
+ onChange={onIsSsoChange}
550
+ label="SSO provider"
551
+ disabled={isCreating}
552
+ />
511
553
 
512
554
  {isSso && (
513
555
  <FieldInput
@@ -522,6 +564,20 @@ function ReviewStep({
522
564
  />
523
565
  )}
524
566
 
567
+ {/* JIT provisioning */}
568
+ <JitProvisioningSection
569
+ isSso={isSso}
570
+ autoProvision={autoProvision}
571
+ onAutoProvisionChange={onAutoProvisionChange}
572
+ autoGrant={autoGrant}
573
+ onAutoGrantChange={onAutoGrantChange}
574
+ autoGrantRole={autoGrantRole}
575
+ onAutoGrantRoleChange={onAutoGrantRoleChange}
576
+ tenantOrgClaim={tenantOrgClaim}
577
+ onTenantOrgClaimChange={onTenantOrgClaimChange}
578
+ disabled={isCreating}
579
+ />
580
+
525
581
  {createError && (
526
582
  <p className="text-destructive text-[0.65rem]" role="alert">
527
583
  {getUserMessage(createError)}
@@ -626,6 +682,156 @@ function FieldInput({
626
682
  );
627
683
  }
628
684
 
685
+ // ---------------------------------------------------------------------------
686
+ // JIT provisioning section
687
+ // ---------------------------------------------------------------------------
688
+
689
+ const JIT_ROLE_OPTIONS: readonly { readonly value: string; readonly label: string }[] = [
690
+ { value: String(IamRole.iam_role_unspecified), label: "Default (viewer)" },
691
+ { value: String(IamRole.viewer), label: "Viewer" },
692
+ { value: String(IamRole.member), label: "Member" },
693
+ { value: String(IamRole.admin), label: "Admin" },
694
+ ];
695
+
696
+ function JitProvisioningSection({
697
+ isSso,
698
+ autoProvision,
699
+ onAutoProvisionChange,
700
+ autoGrant,
701
+ onAutoGrantChange,
702
+ autoGrantRole,
703
+ onAutoGrantRoleChange,
704
+ tenantOrgClaim,
705
+ onTenantOrgClaimChange,
706
+ disabled,
707
+ }: {
708
+ isSso: boolean;
709
+ autoProvision: boolean;
710
+ onAutoProvisionChange: (v: boolean) => void;
711
+ autoGrant: boolean;
712
+ onAutoGrantChange: (v: boolean) => void;
713
+ autoGrantRole: IamRole;
714
+ onAutoGrantRoleChange: (v: IamRole) => void;
715
+ tenantOrgClaim: string;
716
+ onTenantOrgClaimChange: (v: string) => void;
717
+ disabled?: boolean;
718
+ }) {
719
+ if (isSso) {
720
+ return (
721
+ <div className="rounded-md border border-border/60 bg-muted/30 px-3 py-2">
722
+ <p className="text-[0.65rem] text-muted-foreground">
723
+ SSO providers automatically provision accounts and grant the{" "}
724
+ <span className="font-medium text-foreground">viewer</span> role on
725
+ the owning organization. JIT provisioning settings are not applicable.
726
+ </p>
727
+ </div>
728
+ );
729
+ }
730
+
731
+ return (
732
+ <fieldset className="space-y-2.5" disabled={disabled}>
733
+ <hr className="border-border/40" />
734
+ <legend className="text-xs font-medium text-foreground">
735
+ JIT provisioning
736
+ </legend>
737
+ <p className="text-[0.65rem] text-muted-foreground">
738
+ Configure automatic account creation and role assignment for users
739
+ authenticating with this provider.
740
+ </p>
741
+
742
+ <ToggleSwitch
743
+ checked={autoProvision}
744
+ onChange={onAutoProvisionChange}
745
+ label="Auto-provision accounts"
746
+ hint="Create a federated account automatically on first authentication"
747
+ disabled={disabled}
748
+ />
749
+
750
+ <ToggleSwitch
751
+ checked={autoGrant}
752
+ onChange={onAutoGrantChange}
753
+ label="Auto-grant on organization"
754
+ hint="Grant a role on the owning organization when an account is provisioned"
755
+ disabled={disabled || !autoProvision}
756
+ />
757
+
758
+ {autoGrant && (
759
+ <>
760
+ <FieldInput
761
+ id="stgm-idp-wiz-grant-role"
762
+ label="Auto-grant role"
763
+ value={String(autoGrantRole)}
764
+ onChange={(v) => onAutoGrantRoleChange(Number(v) as IamRole)}
765
+ placeholder=""
766
+ hint="Role granted automatically — org admins can upgrade later"
767
+ disabled={disabled}
768
+ type="select"
769
+ options={JIT_ROLE_OPTIONS}
770
+ />
771
+
772
+ <FieldInput
773
+ id="stgm-idp-wiz-tenant-claim"
774
+ label="Tenant org claim"
775
+ value={tenantOrgClaim}
776
+ onChange={onTenantOrgClaimChange}
777
+ placeholder="e.g., org_id"
778
+ hint="JWT claim name that maps to a platform-managed organization (max 256 chars)"
779
+ disabled={disabled}
780
+ />
781
+ </>
782
+ )}
783
+ </fieldset>
784
+ );
785
+ }
786
+
787
+ // ---------------------------------------------------------------------------
788
+ // Toggle switch
789
+ // ---------------------------------------------------------------------------
790
+
791
+ function ToggleSwitch({
792
+ checked,
793
+ onChange,
794
+ label,
795
+ hint,
796
+ disabled,
797
+ }: {
798
+ checked: boolean;
799
+ onChange: (v: boolean) => void;
800
+ label: string;
801
+ hint?: string;
802
+ disabled?: boolean;
803
+ }) {
804
+ return (
805
+ <div className="space-y-0.5">
806
+ <div className="flex items-center gap-2">
807
+ <button
808
+ type="button"
809
+ role="switch"
810
+ aria-checked={checked}
811
+ onClick={() => onChange(!checked)}
812
+ disabled={disabled}
813
+ className={cn(
814
+ "relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors",
815
+ checked ? "bg-primary" : "bg-muted",
816
+ "disabled:pointer-events-none disabled:opacity-50",
817
+ )}
818
+ >
819
+ <span
820
+ className={cn(
821
+ "pointer-events-none inline-block h-4 w-4 rounded-full bg-background shadow-sm ring-0 transition-transform",
822
+ checked ? "translate-x-4" : "translate-x-0",
823
+ )}
824
+ />
825
+ </button>
826
+ <span className="text-xs font-medium text-foreground">{label}</span>
827
+ </div>
828
+ {hint && (
829
+ <p className="pl-11 text-[0.65rem] text-muted-foreground">{hint}</p>
830
+ )}
831
+ </div>
832
+ );
833
+ }
834
+
629
835
  function TextButton({
630
836
  onClick,
631
837
  disabled,
package/src/index.ts CHANGED
@@ -454,6 +454,32 @@ export type {
454
454
  ApiKeyCreatedAlertProps,
455
455
  } from "./api-key";
456
456
 
457
+ // Platform Client — data hooks, mutation hooks, and styled components for platform client lifecycle
458
+ export {
459
+ usePlatformClientList,
460
+ usePlatformClient,
461
+ useCreatePlatformClient,
462
+ useUpdatePlatformClient,
463
+ useDeletePlatformClient,
464
+ useRotatePlatformClientSecret,
465
+ PlatformClientListPanel,
466
+ CreatePlatformClientForm,
467
+ PlatformClientDetailPanel,
468
+ PlatformClientSecretAlert,
469
+ } from "./platform-client";
470
+ export type {
471
+ UsePlatformClientListReturn,
472
+ UsePlatformClientReturn,
473
+ UseCreatePlatformClientReturn,
474
+ UseUpdatePlatformClientReturn,
475
+ UseDeletePlatformClientReturn,
476
+ UseRotatePlatformClientSecretReturn,
477
+ PlatformClientListPanelProps,
478
+ CreatePlatformClientFormProps,
479
+ PlatformClientDetailPanelProps,
480
+ PlatformClientSecretAlertProps,
481
+ } from "./platform-client";
482
+
457
483
  // OAuth App — data hooks, mutation hooks, and styled components for OAuth app management
458
484
  export {
459
485
  useOAuthAppList,