@structured-id/ui-core 1.2.0 → 1.3.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.
Files changed (101) hide show
  1. package/README.md +9 -5
  2. package/dist/browser-vp/index.d.cts +0 -11
  3. package/dist/browser-vp/index.d.ts +0 -11
  4. package/dist/index.cjs +13721 -9514
  5. package/dist/index.d.cts +4362 -2375
  6. package/dist/index.d.ts +4362 -2375
  7. package/dist/index.js +13937 -9730
  8. package/package.json +3 -3
  9. package/src/browser-vp/crypto.ts +0 -1
  10. package/src/browser-vp/index.ts +0 -2
  11. package/src/browser-vp/prf.ts +0 -2
  12. package/src/browser-vp/storage.ts +0 -2
  13. package/src/browser-vp/types.ts +0 -2
  14. package/src/browser-vp/vp.ts +0 -2
  15. package/src/composables/index.ts +6 -1
  16. package/src/composables/useAccountTransport.test.ts +121 -0
  17. package/src/composables/useAccountTransport.ts +69 -0
  18. package/src/composables/useBffAuth.ts +44 -34
  19. package/src/generated/google/api/httpbody.ts +159 -0
  20. package/src/generated/google/protobuf/any.ts +326 -0
  21. package/src/generated/google/rpc/error_details.ts +1386 -0
  22. package/src/generated/google/rpc/status.ts +127 -0
  23. package/src/generated/sid/v1/account/account.ts +1 -1
  24. package/src/generated/sid/v1/admin/admin.client.ts +15 -12
  25. package/src/generated/sid/v1/admin/admin.ts +24 -89
  26. package/src/generated/sid/v1/admin/enrollment.client.ts +24 -12
  27. package/src/generated/sid/v1/admin/enrollment.ts +65 -3
  28. package/src/generated/sid/v1/admin/events.client.ts +8 -8
  29. package/src/generated/sid/v1/admin/flow.ts +1 -1
  30. package/src/generated/sid/v1/admin/keys.ts +1 -1
  31. package/src/generated/sid/v1/admin/notifications.client.ts +12 -6
  32. package/src/generated/sid/v1/admin/notifications.ts +11 -70
  33. package/src/generated/sid/v1/admin/operations.ts +20 -35
  34. package/src/generated/sid/v1/admin/organizations.client.ts +2 -2
  35. package/src/generated/sid/v1/admin/organizations.ts +15 -32
  36. package/src/generated/sid/v1/admin/provisioning.client.ts +232 -0
  37. package/src/generated/sid/v1/admin/provisioning.ts +1383 -0
  38. package/src/generated/sid/v1/admin/scopes.ts +1 -1
  39. package/src/generated/sid/v1/admin/security.client.ts +22 -24
  40. package/src/generated/sid/v1/admin/security.ts +13 -22
  41. package/src/generated/sid/v1/admin/settings.client.ts +29 -18
  42. package/src/generated/sid/v1/admin/settings.ts +2 -82
  43. package/src/generated/sid/v1/attestation/attestation.client.ts +6 -6
  44. package/src/generated/sid/v1/attestation/attestation.ts +8 -8
  45. package/src/generated/sid/v1/authn/auth.client.ts +101 -58
  46. package/src/generated/sid/v1/authn/auth.ts +842 -414
  47. package/src/generated/sid/v1/authn/flows.ts +0 -12
  48. package/src/generated/sid/v1/authn/issuer.client.ts +489 -0
  49. package/src/generated/sid/v1/authn/issuer.ts +1600 -0
  50. package/src/generated/sid/v1/authn/password_history.client.ts +57 -0
  51. package/src/generated/sid/v1/authn/password_history.ts +578 -0
  52. package/src/generated/sid/v1/authn/system_integration.client.ts +73 -0
  53. package/src/generated/sid/v1/authn/system_integration.ts +218 -0
  54. package/src/generated/sid/v1/authz/authz.ts +1498 -317
  55. package/src/generated/sid/v1/authz/forward_auth.client.ts +97 -0
  56. package/src/generated/sid/v1/authz/forward_auth.ts +79 -0
  57. package/src/generated/sid/v1/authz/governance.client.ts +2 -2
  58. package/src/generated/sid/v1/authz/governance.ts +61 -4
  59. package/src/generated/sid/v1/common/errors.ts +532 -6
  60. package/src/generated/sid/v1/events/event_stream.client.ts +2 -2
  61. package/src/generated/sid/v1/events/event_stream.ts +2 -1
  62. package/src/generated/sid/v1/identity/identity.ts +98 -58
  63. package/src/generated/sid/v1/ids/ids.ts +395 -0
  64. package/src/generated/sid/v1/machine/machine_user.ts +0 -36
  65. package/src/generated/sid/v1/machine/pat.client.ts +2 -19
  66. package/src/generated/sid/v1/machine/pat.ts +1 -186
  67. package/src/generated/sid/v1/projects/projects.client.ts +137 -19
  68. package/src/generated/sid/v1/projects/projects.ts +2105 -405
  69. package/src/generated/sid/v1/scim/scim.client.ts +248 -2
  70. package/src/generated/sid/v1/scim/scim.ts +153 -14
  71. package/src/generated/sid/v1/test/test.ts +1 -1
  72. package/src/i18n/index.ts +0 -11
  73. package/src/index.ts +36 -2
  74. package/src/package-exports.test.ts +18 -0
  75. package/src/profile/components/SidLoginForm.vue +5 -2
  76. package/src/profile/components/SidRegistrationForm.test.ts +58 -1
  77. package/src/profile/components/SidRegistrationForm.vue +110 -12
  78. package/src/profile/components/index.ts +4 -0
  79. package/src/profile/composables/index.ts +2 -1
  80. package/src/profile/composables/useAccountApi.ts +20 -7
  81. package/src/profile/composables/useAuth.test.ts +453 -0
  82. package/src/profile/composables/useAuth.ts +414 -0
  83. package/src/profile/composables/useAuthApi.opaque.test.ts +18 -0
  84. package/src/profile/composables/useAuthApi.ts +188 -20
  85. package/src/profile/composables/useEnrollmentApi.test.ts +33 -0
  86. package/src/profile/composables/useEnrollmentApi.ts +26 -0
  87. package/src/profile/composables/useIdentityApi.ts +17 -7
  88. package/src/profile/composables/useLoginSuccess.test.ts +97 -3
  89. package/src/profile/composables/useLoginSuccess.ts +80 -22
  90. package/src/profile/composables/useSecurityLevel.test.ts +10 -3
  91. package/src/profile/composables/useSecurityLevel.ts +12 -3
  92. package/src/quasar/SidPrincipalInput.vue +4 -7
  93. package/src/utils/normalizePrincipal.test.ts +19 -5
  94. package/src/utils/normalizePrincipal.ts +7 -9
  95. package/src/utils/rpcRefusal.test.ts +151 -0
  96. package/src/utils/rpcRefusal.ts +252 -0
  97. package/src/utils/validators.test.ts +9 -0
  98. package/src/utils/validators.ts +14 -2
  99. package/src/composables/useAuth.ts +0 -40
  100. package/src/profile/composables/useOpaqueAuth.test.ts +0 -290
  101. package/src/profile/composables/useOpaqueAuth.ts +0 -191
@@ -1,191 +0,0 @@
1
- /**
2
- * OPAQUE auth flow orchestration (shared between all profile UIs).
3
- *
4
- * Uses dependency injection for client-side crypto: apps provide an
5
- * OpaqueClientApi implementation (from @structured-id/opaque), keeping
6
- * the WASM dependency at the app layer.
7
- *
8
- * gRPC calls go through useAuthApi wrappers.
9
- */
10
- import {
11
- opaqueLoginStart,
12
- opaqueLoginFinish,
13
- opaqueRegistrationStart,
14
- opaqueRegistrationFinish,
15
- } from "./useAuthApi";
16
-
17
- // ── Types ──
18
-
19
- export interface LoginResult {
20
- sessionId: string;
21
- accessToken: string;
22
- expiresIn: number;
23
- }
24
-
25
- export interface RegisterResult {
26
- profileId: string;
27
- credentialId: string;
28
- }
29
-
30
- /**
31
- * Interface for OPAQUE client-side crypto operations.
32
- * Implemented by @structured-id/opaque OpaqueClient.
33
- */
34
- export interface OpaqueClientApi {
35
- loginStart(password: string): Promise<{ ke1: Uint8Array; state: unknown }>;
36
- loginFinish(
37
- password: string,
38
- ke2: Uint8Array,
39
- state: unknown,
40
- ): Promise<{ ke3: Uint8Array }>;
41
- registrationStart(
42
- password: string,
43
- ): Promise<{ request: Uint8Array; state: unknown }>;
44
- registrationFinish(
45
- password: string,
46
- response: Uint8Array,
47
- state: unknown,
48
- ): Promise<{ record: Uint8Array }>;
49
- }
50
-
51
- export type OpaqueClientFactory = (
52
- serverId: string,
53
- clientId: string,
54
- ) => OpaqueClientApi;
55
-
56
- /**
57
- * Create an OPAQUE auth composable with injected crypto client.
58
- *
59
- * @param createClient - Factory that creates an OpaqueClientApi instance
60
- * @param serverId - OPAQUE server identifier (default: "structured.id")
61
- *
62
- * @example
63
- * ```ts
64
- * import { OpaqueClient } from "@structured-id/opaque";
65
- * import { createOpaqueAuth } from "@structured-id/ui-core/profile";
66
- *
67
- * const { login, register } = createOpaqueAuth(
68
- * (serverId, clientId) => new OpaqueClient({ serverId, clientId }),
69
- * );
70
- * ```
71
- */
72
- export function createOpaqueAuth(
73
- createClient: OpaqueClientFactory,
74
- serverId = "structured.id",
75
- ) {
76
- /**
77
- * Perform full OPAQUE login flow (2 round-trips via gRPC-web).
78
- *
79
- * 1. loginStart: send credentialRequest → receive credentialResponse + serverLoginState
80
- * 2. loginFinish: send credentialFinalization → receive session tokens
81
- */
82
- async function login(
83
- identifier: string,
84
- password: string,
85
- onStep?: (step: number) => void,
86
- ): Promise<LoginResult> {
87
- const opaque = createClient(serverId, identifier);
88
-
89
- // Step 1: Generate credential request (client-side only, password never sent)
90
- onStep?.(1);
91
- const start = await opaque.loginStart(password);
92
-
93
- // Step 2: Send credential request to server
94
- onStep?.(2);
95
- const startResp = await opaqueLoginStart(identifier, start.ke1);
96
-
97
- // Step 3: Process server response, generate finalization (client-side crypto)
98
- onStep?.(3);
99
- const finish = await opaque.loginFinish(
100
- password,
101
- startResp.credentialResponse,
102
- start.state,
103
- );
104
-
105
- // Step 4: Send finalization, receive session tokens
106
- const finishResp = await opaqueLoginFinish(
107
- identifier,
108
- finish.ke3,
109
- startResp.serverLoginState,
110
- );
111
-
112
- return {
113
- sessionId: finishResp.sessionId,
114
- accessToken: finishResp.accessToken,
115
- expiresIn: Number(finishResp.expiresIn),
116
- };
117
- }
118
-
119
- /**
120
- * Perform full OPAQUE registration flow (2 round-trips via gRPC-web).
121
- *
122
- * 1. registrationStart: send registrationRequest → receive registrationResponse + serverSetup
123
- * 2. registrationFinish: send registrationRecord → receive profileId + credentialId
124
- */
125
- async function register(
126
- identifier: string,
127
- password: string,
128
- ): Promise<RegisterResult> {
129
- const opaque = createClient(serverId, identifier);
130
-
131
- // Step 1: Generate registration request
132
- const start = await opaque.registrationStart(password);
133
-
134
- const startResp = await opaqueRegistrationStart(
135
- identifier,
136
- start.request,
137
- );
138
-
139
- // Step 2: Process server response, generate registration record
140
- const finish = await opaque.registrationFinish(
141
- password,
142
- startResp.registrationResponse,
143
- start.state,
144
- );
145
-
146
- const finishResp = await opaqueRegistrationFinish(
147
- identifier,
148
- finish.record,
149
- startResp.serverSetup,
150
- );
151
-
152
- return {
153
- profileId: finishResp.profileId,
154
- credentialId: finishResp.credentialId,
155
- };
156
- }
157
-
158
- /**
159
- * Compute OPAQUE registration record WITHOUT storing the credential.
160
- *
161
- * Used by password reset: the registration_record is passed to
162
- * CompletePasswordReset RPC which stores the credential in the
163
- * context of the reset session (replacing the old one).
164
- *
165
- * 1. registrationStart: send registrationRequest → receive registrationResponse
166
- * 2. Client-side finish: compute registrationRecord (NOT sent to server yet)
167
- */
168
- async function computeRegistrationRecord(
169
- identifier: string,
170
- password: string,
171
- ): Promise<Uint8Array> {
172
- const opaque = createClient(serverId, identifier);
173
-
174
- const start = await opaque.registrationStart(password);
175
-
176
- const startResp = await opaqueRegistrationStart(
177
- identifier,
178
- start.request,
179
- );
180
-
181
- const finish = await opaque.registrationFinish(
182
- password,
183
- startResp.registrationResponse,
184
- start.state,
185
- );
186
-
187
- return finish.record;
188
- }
189
-
190
- return { login, register, computeRegistrationRecord };
191
- }