@structured-id/ui-core 0.1.5
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.
- package/LICENSE +661 -0
- package/README.md +47 -0
- package/dist/browser-vp/index.cjs +349 -0
- package/dist/browser-vp/index.d.cts +287 -0
- package/dist/browser-vp/index.d.ts +287 -0
- package/dist/browser-vp/index.js +349 -0
- package/dist/chunk-C3Q766CY.cjs +125 -0
- package/dist/chunk-J5YXRXB5.js +125 -0
- package/dist/index.cjs +19360 -0
- package/dist/index.d.cts +9536 -0
- package/dist/index.d.ts +9536 -0
- package/dist/index.js +19360 -0
- package/dist/storage-4CB2JTLW.cjs +22 -0
- package/dist/storage-THRWREZP.js +22 -0
- package/package.json +93 -0
- package/src/browser-vp/crypto.ts +254 -0
- package/src/browser-vp/index.test.ts +10 -0
- package/src/browser-vp/index.ts +118 -0
- package/src/browser-vp/prf.ts +181 -0
- package/src/browser-vp/storage.test.ts +9 -0
- package/src/browser-vp/storage.ts +165 -0
- package/src/browser-vp/types.ts +97 -0
- package/src/browser-vp/vp.test.ts +43 -0
- package/src/browser-vp/vp.ts +113 -0
- package/src/components/SidAvatar.vue +106 -0
- package/src/components/SidConfirmDialog.vue +125 -0
- package/src/components/SidStatusBadge.vue +71 -0
- package/src/components/index.ts +5 -0
- package/src/composables/index.ts +10 -0
- package/src/composables/useAuth.ts +40 -0
- package/src/composables/useBffAuth.ts +147 -0
- package/src/composables/useGrpc.test.ts +196 -0
- package/src/composables/useGrpc.ts +120 -0
- package/src/composables/useSession.ts +80 -0
- package/src/generated/google/api/http.ts +687 -0
- package/src/generated/google/protobuf/descriptor.ts +4865 -0
- package/src/generated/google/protobuf/duration.ts +230 -0
- package/src/generated/google/protobuf/empty.ts +94 -0
- package/src/generated/google/protobuf/struct.ts +484 -0
- package/src/generated/google/protobuf/timestamp.ts +287 -0
- package/src/generated/sid/v1/account/account.client.ts +527 -0
- package/src/generated/sid/v1/account/account.ts +3261 -0
- package/src/generated/sid/v1/admin/admin.client.ts +136 -0
- package/src/generated/sid/v1/admin/admin.ts +846 -0
- package/src/generated/sid/v1/admin/admin_roles.client.ts +181 -0
- package/src/generated/sid/v1/admin/admin_roles.ts +1606 -0
- package/src/generated/sid/v1/admin/analytics.client.ts +106 -0
- package/src/generated/sid/v1/admin/analytics.ts +1017 -0
- package/src/generated/sid/v1/admin/branding.client.ts +166 -0
- package/src/generated/sid/v1/admin/branding.ts +1906 -0
- package/src/generated/sid/v1/admin/enrollment.client.ts +165 -0
- package/src/generated/sid/v1/admin/enrollment.ts +1704 -0
- package/src/generated/sid/v1/admin/events.client.ts +195 -0
- package/src/generated/sid/v1/admin/events.ts +1900 -0
- package/src/generated/sid/v1/admin/flow.client.ts +183 -0
- package/src/generated/sid/v1/admin/flow.ts +1552 -0
- package/src/generated/sid/v1/admin/keys.client.ts +107 -0
- package/src/generated/sid/v1/admin/keys.ts +931 -0
- package/src/generated/sid/v1/admin/login_experience.client.ts +160 -0
- package/src/generated/sid/v1/admin/login_experience.ts +1061 -0
- package/src/generated/sid/v1/admin/migration.client.ts +127 -0
- package/src/generated/sid/v1/admin/migration.ts +1948 -0
- package/src/generated/sid/v1/admin/notifications.client.ts +128 -0
- package/src/generated/sid/v1/admin/notifications.ts +1332 -0
- package/src/generated/sid/v1/admin/operations.client.ts +241 -0
- package/src/generated/sid/v1/admin/operations.ts +2648 -0
- package/src/generated/sid/v1/admin/organizations.client.ts +57 -0
- package/src/generated/sid/v1/admin/organizations.ts +349 -0
- package/src/generated/sid/v1/admin/scopes.client.ts +171 -0
- package/src/generated/sid/v1/admin/scopes.ts +1324 -0
- package/src/generated/sid/v1/admin/security.client.ts +412 -0
- package/src/generated/sid/v1/admin/security.ts +4086 -0
- package/src/generated/sid/v1/admin/sessions.client.ts +114 -0
- package/src/generated/sid/v1/admin/sessions.ts +923 -0
- package/src/generated/sid/v1/admin/settings.client.ts +340 -0
- package/src/generated/sid/v1/admin/settings.ts +2395 -0
- package/src/generated/sid/v1/admin/user_profile.client.ts +57 -0
- package/src/generated/sid/v1/admin/user_profile.ts +730 -0
- package/src/generated/sid/v1/admin/webhooks.client.ts +269 -0
- package/src/generated/sid/v1/admin/webhooks.ts +2804 -0
- package/src/generated/sid/v1/attestation/attestation.client.ts +115 -0
- package/src/generated/sid/v1/attestation/attestation.ts +813 -0
- package/src/generated/sid/v1/authn/auth.client.ts +900 -0
- package/src/generated/sid/v1/authn/auth.ts +9287 -0
- package/src/generated/sid/v1/authn/flows.client.ts +413 -0
- package/src/generated/sid/v1/authn/flows.ts +3217 -0
- package/src/generated/sid/v1/authz/authz.client.ts +459 -0
- package/src/generated/sid/v1/authz/authz.ts +5343 -0
- package/src/generated/sid/v1/authz/governance.client.ts +102 -0
- package/src/generated/sid/v1/authz/governance.ts +818 -0
- package/src/generated/sid/v1/common/errors.ts +184 -0
- package/src/generated/sid/v1/common/pagination.ts +152 -0
- package/src/generated/sid/v1/common/transport.ts +227 -0
- package/src/generated/sid/v1/common/types.ts +151 -0
- package/src/generated/sid/v1/events/event_stream.client.ts +67 -0
- package/src/generated/sid/v1/events/event_stream.ts +374 -0
- package/src/generated/sid/v1/federation/upstream.client.ts +142 -0
- package/src/generated/sid/v1/federation/upstream.ts +1736 -0
- package/src/generated/sid/v1/identity/identity.client.ts +467 -0
- package/src/generated/sid/v1/identity/identity.ts +5613 -0
- package/src/generated/sid/v1/machine/machine_user.client.ts +219 -0
- package/src/generated/sid/v1/machine/machine_user.ts +2400 -0
- package/src/generated/sid/v1/machine/pat.client.ts +147 -0
- package/src/generated/sid/v1/machine/pat.ts +1268 -0
- package/src/generated/sid/v1/projects/projects.client.ts +286 -0
- package/src/generated/sid/v1/projects/projects.ts +2714 -0
- package/src/generated/sid/v1/scim/scim.client.ts +274 -0
- package/src/generated/sid/v1/scim/scim.ts +3043 -0
- package/src/generated/sid/v1/test/test.client.ts +232 -0
- package/src/generated/sid/v1/test/test.ts +1136 -0
- package/src/i18n/index.ts +40 -0
- package/src/index.ts +157 -0
- package/src/profile/auth.ts +15 -0
- package/src/profile/components/ConsentManager.vue +88 -0
- package/src/profile/components/ProfileEditor.vue +146 -0
- package/src/profile/components/SecuritySettings.vue +170 -0
- package/src/profile/components/SessionList.vue +100 -0
- package/src/profile/components/SidLoginForm.test.ts +80 -0
- package/src/profile/components/SidLoginForm.vue +230 -0
- package/src/profile/components/SidMfaChallenge.test.ts +127 -0
- package/src/profile/components/SidMfaChallenge.vue +243 -0
- package/src/profile/components/SidRegistrationForm.test.ts +79 -0
- package/src/profile/components/SidRegistrationForm.vue +317 -0
- package/src/profile/components/index.ts +11 -0
- package/src/profile/composables/index.ts +6 -0
- package/src/profile/composables/useAccountApi.ts +203 -0
- package/src/profile/composables/useAuthApi.opaque.test.ts +140 -0
- package/src/profile/composables/useAuthApi.ts +617 -0
- package/src/profile/composables/useIdentityApi.ts +123 -0
- package/src/profile/composables/useLoginSuccess.test.ts +112 -0
- package/src/profile/composables/useLoginSuccess.ts +65 -0
- package/src/profile/composables/useOpaqueAuth.test.ts +290 -0
- package/src/profile/composables/useOpaqueAuth.ts +191 -0
- package/src/profile/composables/useSecurityLevel.test.ts +198 -0
- package/src/profile/composables/useSecurityLevel.ts +324 -0
- package/src/profile/index.ts +18 -0
- package/src/quasar/SidPrincipalInput.vue +209 -0
- package/src/quasar/index.ts +8 -0
- package/src/stores/auth.test.ts +83 -0
- package/src/stores/auth.ts +92 -0
- package/src/stores/index.ts +1 -0
- package/src/transport/adaptive.test.ts +728 -0
- package/src/transport/adaptive.ts +308 -0
- package/src/transport/framing.test.ts +227 -0
- package/src/transport/framing.ts +98 -0
- package/src/transport/webtransport.test.ts +728 -0
- package/src/transport/webtransport.ts +323 -0
- package/src/types/auth.ts +58 -0
- package/src/types/index.ts +1 -0
- package/src/utils/formatters.test.ts +26 -0
- package/src/utils/formatters.ts +69 -0
- package/src/utils/index.ts +16 -0
- package/src/utils/normalizePrincipal.test.ts +188 -0
- package/src/utils/normalizePrincipal.ts +159 -0
- package/src/utils/validators.test.ts +75 -0
- package/src/utils/validators.ts +36 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile auth API composable.
|
|
3
|
+
*
|
|
4
|
+
* Wraps AuthServiceClient proto calls with Bearer auth.
|
|
5
|
+
* Covers: OPAQUE, MFA, step-up, WebAuthn, magic link, OAuth2, CIBA, captcha, terms.
|
|
6
|
+
*
|
|
7
|
+
* OPAQUE gRPC calls are here (like all other auth RPCs).
|
|
8
|
+
* OPAQUE client-side crypto orchestration lives in useOpaqueAuth.ts
|
|
9
|
+
* (accepts OpaqueClientApi interface — no dependency on @structured-id/opaque).
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
getTransport,
|
|
13
|
+
AuthServiceClient,
|
|
14
|
+
StepUpMethod,
|
|
15
|
+
type OpaqueLoginStartResponse,
|
|
16
|
+
type OpaqueLoginFinishResponse,
|
|
17
|
+
type OpaqueRegistrationStartResponse,
|
|
18
|
+
type OpaqueRegistrationFinishResponse,
|
|
19
|
+
type MfaVerifyResponse,
|
|
20
|
+
type TotpEnrollmentChallenge,
|
|
21
|
+
type FinishTotpEnrollmentResponse,
|
|
22
|
+
type ResendSmsMfaResponse,
|
|
23
|
+
type GenerateRecoveryCodesResponse,
|
|
24
|
+
type VerifyOtpResponse,
|
|
25
|
+
type ResendOtpResponse,
|
|
26
|
+
type VerifyPhoneResponse,
|
|
27
|
+
type ConfirmIdpLinkResponse,
|
|
28
|
+
type ListUserOrganizationsResponse,
|
|
29
|
+
type SelectOrganizationResponse,
|
|
30
|
+
type GetTermsResponse,
|
|
31
|
+
type AcceptTermsResponse,
|
|
32
|
+
type CibaConsentResponse,
|
|
33
|
+
type VerifyCaptchaResponse,
|
|
34
|
+
type DynamicPrompt,
|
|
35
|
+
type SubmitDynamicPromptResponse,
|
|
36
|
+
type StepUpChallenge,
|
|
37
|
+
type CompleteStepUpResponse,
|
|
38
|
+
type DeleteMfaCredentialResponse,
|
|
39
|
+
type ConfirmAccountDeletionResponse,
|
|
40
|
+
type SubmitDeviceUserCodeResponse,
|
|
41
|
+
type WebAuthnAuthenticationStartResponse,
|
|
42
|
+
type WebAuthnAuthenticationFinishResponse,
|
|
43
|
+
type WebAuthnRegistrationStartResponse,
|
|
44
|
+
type WebAuthnRegistrationFinishResponse,
|
|
45
|
+
type RequestMagicLinkResponse,
|
|
46
|
+
type VerifyMagicLinkResponse,
|
|
47
|
+
type UserOrganization,
|
|
48
|
+
type RequestPasswordResetResponse,
|
|
49
|
+
type VerifyPasswordResetResponse,
|
|
50
|
+
type CompletePasswordResetResponse,
|
|
51
|
+
} from "../../index";
|
|
52
|
+
import { authMeta } from "../auth";
|
|
53
|
+
|
|
54
|
+
function client(): AuthServiceClient {
|
|
55
|
+
return new AuthServiceClient(getTransport());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ── MFA TOTP ──
|
|
59
|
+
|
|
60
|
+
export async function startTotpEnrollment(): Promise<TotpEnrollmentChallenge> {
|
|
61
|
+
const { response } = await client().startTotpEnrollment(
|
|
62
|
+
{},
|
|
63
|
+
{ meta: authMeta() },
|
|
64
|
+
);
|
|
65
|
+
return response;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function finishTotpEnrollment(
|
|
69
|
+
code: string,
|
|
70
|
+
): Promise<FinishTotpEnrollmentResponse> {
|
|
71
|
+
const { response } = await client().finishTotpEnrollment(
|
|
72
|
+
{ code },
|
|
73
|
+
{ meta: authMeta() },
|
|
74
|
+
);
|
|
75
|
+
return response;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function verifyTotp(code: string): Promise<MfaVerifyResponse> {
|
|
79
|
+
const { response } = await client().verifyTotp(
|
|
80
|
+
{ code },
|
|
81
|
+
{ meta: authMeta() },
|
|
82
|
+
);
|
|
83
|
+
return response;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ── MFA SMS ──
|
|
87
|
+
|
|
88
|
+
export async function verifySmsMfa(code: string): Promise<MfaVerifyResponse> {
|
|
89
|
+
const { response } = await client().verifySmsMfa(
|
|
90
|
+
{ code },
|
|
91
|
+
{ meta: authMeta() },
|
|
92
|
+
);
|
|
93
|
+
return response;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function resendSmsMfa(): Promise<ResendSmsMfaResponse> {
|
|
97
|
+
const { response } = await client().resendSmsMfa({}, { meta: authMeta() });
|
|
98
|
+
return response;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ── MFA Recovery ──
|
|
102
|
+
|
|
103
|
+
export async function generateRecoveryCodes(): Promise<GenerateRecoveryCodesResponse> {
|
|
104
|
+
const { response } = await client().generateRecoveryCodes(
|
|
105
|
+
{},
|
|
106
|
+
{ meta: authMeta() },
|
|
107
|
+
);
|
|
108
|
+
return response;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export async function verifyRecoveryCode(
|
|
112
|
+
code: string,
|
|
113
|
+
): Promise<MfaVerifyResponse> {
|
|
114
|
+
const { response } = await client().verifyRecoveryCode(
|
|
115
|
+
{ code },
|
|
116
|
+
{ meta: authMeta() },
|
|
117
|
+
);
|
|
118
|
+
return response;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ── OTP ──
|
|
122
|
+
|
|
123
|
+
export async function verifyOtp(
|
|
124
|
+
code: string,
|
|
125
|
+
sessionId?: string,
|
|
126
|
+
): Promise<VerifyOtpResponse> {
|
|
127
|
+
const { response } = await client().verifyOtp(
|
|
128
|
+
{ code, sessionId },
|
|
129
|
+
{ meta: authMeta() },
|
|
130
|
+
);
|
|
131
|
+
return response;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function resendOtp(
|
|
135
|
+
sessionId?: string,
|
|
136
|
+
): Promise<ResendOtpResponse> {
|
|
137
|
+
const { response } = await client().resendOtp(
|
|
138
|
+
{ sessionId },
|
|
139
|
+
{ meta: authMeta() },
|
|
140
|
+
);
|
|
141
|
+
return response;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ── Email/Phone verification ──
|
|
145
|
+
|
|
146
|
+
export async function resendEmailVerification(
|
|
147
|
+
email?: string,
|
|
148
|
+
): Promise<{ maskedEmail: string; expiresIn: number }> {
|
|
149
|
+
const { response } = await client().resendEmailVerification(
|
|
150
|
+
{ email },
|
|
151
|
+
{ meta: authMeta() },
|
|
152
|
+
);
|
|
153
|
+
return response;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export async function verifyPhone(code: string): Promise<VerifyPhoneResponse> {
|
|
157
|
+
const { response } = await client().verifyPhone(
|
|
158
|
+
{ code },
|
|
159
|
+
{ meta: authMeta() },
|
|
160
|
+
);
|
|
161
|
+
return response;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export async function resendPhoneVerification(): Promise<{
|
|
165
|
+
maskedPhone: string;
|
|
166
|
+
expiresIn: number;
|
|
167
|
+
}> {
|
|
168
|
+
const { response } = await client().resendPhoneVerification(
|
|
169
|
+
{},
|
|
170
|
+
{ meta: authMeta() },
|
|
171
|
+
);
|
|
172
|
+
return response;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ── WebAuthn ──
|
|
176
|
+
|
|
177
|
+
export async function webAuthnAuthenticationStart(
|
|
178
|
+
principal?: string,
|
|
179
|
+
): Promise<WebAuthnAuthenticationStartResponse> {
|
|
180
|
+
const { response } = await client().webAuthnAuthenticationStart(
|
|
181
|
+
{ principal: principal ?? "" },
|
|
182
|
+
{ meta: authMeta() },
|
|
183
|
+
);
|
|
184
|
+
return response;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export async function webAuthnAuthenticationFinish(
|
|
188
|
+
credential: Uint8Array,
|
|
189
|
+
principal?: string,
|
|
190
|
+
stateKey?: string,
|
|
191
|
+
): Promise<WebAuthnAuthenticationFinishResponse> {
|
|
192
|
+
const { response } = await client().webAuthnAuthenticationFinish(
|
|
193
|
+
{ credential, principal: principal ?? "", stateKey },
|
|
194
|
+
{ meta: authMeta() },
|
|
195
|
+
);
|
|
196
|
+
return response;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export async function webAuthnRegistrationStart(
|
|
200
|
+
label?: string,
|
|
201
|
+
): Promise<WebAuthnRegistrationStartResponse> {
|
|
202
|
+
const { response } = await client().webAuthnRegistrationStart(
|
|
203
|
+
{ label },
|
|
204
|
+
{ meta: authMeta() },
|
|
205
|
+
);
|
|
206
|
+
return response;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export async function webAuthnRegistrationFinish(
|
|
210
|
+
credential: Uint8Array,
|
|
211
|
+
label?: string,
|
|
212
|
+
): Promise<WebAuthnRegistrationFinishResponse> {
|
|
213
|
+
const { response } = await client().webAuthnRegistrationFinish(
|
|
214
|
+
{ credential, label },
|
|
215
|
+
{ meta: authMeta() },
|
|
216
|
+
);
|
|
217
|
+
return response;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ── Device Authorization (RFC 8628) ──
|
|
221
|
+
|
|
222
|
+
export async function submitDeviceUserCode(
|
|
223
|
+
userCode: string,
|
|
224
|
+
approve: boolean,
|
|
225
|
+
): Promise<SubmitDeviceUserCodeResponse> {
|
|
226
|
+
const { response } = await client().submitDeviceUserCode(
|
|
227
|
+
{ userCode, approve },
|
|
228
|
+
{ meta: authMeta() },
|
|
229
|
+
);
|
|
230
|
+
return response;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ── OAuth2 Consent ──
|
|
234
|
+
|
|
235
|
+
export async function oauth2Authorize(params: {
|
|
236
|
+
clientId: string;
|
|
237
|
+
redirectUri: string;
|
|
238
|
+
responseType: string;
|
|
239
|
+
scope?: string;
|
|
240
|
+
state?: string;
|
|
241
|
+
codeChallenge?: string;
|
|
242
|
+
codeChallengeMethod?: string;
|
|
243
|
+
nonce?: string;
|
|
244
|
+
}): Promise<{ authorizationCode?: string; error?: string; state?: string }> {
|
|
245
|
+
const { response } = await client().oAuth2Authorize(
|
|
246
|
+
{
|
|
247
|
+
clientId: params.clientId,
|
|
248
|
+
redirectUri: params.redirectUri,
|
|
249
|
+
responseType: params.responseType,
|
|
250
|
+
scope: params.scope,
|
|
251
|
+
state: params.state,
|
|
252
|
+
codeChallenge: params.codeChallenge,
|
|
253
|
+
codeChallengeMethod: params.codeChallengeMethod,
|
|
254
|
+
nonce: params.nonce,
|
|
255
|
+
},
|
|
256
|
+
{ meta: authMeta() },
|
|
257
|
+
);
|
|
258
|
+
const result = response.result;
|
|
259
|
+
return {
|
|
260
|
+
authorizationCode:
|
|
261
|
+
result.oneofKind === "authorizationCode"
|
|
262
|
+
? result.authorizationCode
|
|
263
|
+
: undefined,
|
|
264
|
+
error: result.oneofKind === "error" ? result.error : undefined,
|
|
265
|
+
state: response.state,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ── Magic Link ──
|
|
270
|
+
|
|
271
|
+
export async function requestMagicLink(
|
|
272
|
+
principal: string,
|
|
273
|
+
clientId: string,
|
|
274
|
+
redirectUri: string,
|
|
275
|
+
): Promise<RequestMagicLinkResponse> {
|
|
276
|
+
const { response } = await client().requestMagicLink(
|
|
277
|
+
{ principal, clientId, redirectUri },
|
|
278
|
+
{ meta: authMeta() },
|
|
279
|
+
);
|
|
280
|
+
return response;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export async function verifyMagicLink(
|
|
284
|
+
sessionId: string,
|
|
285
|
+
token: string,
|
|
286
|
+
): Promise<VerifyMagicLinkResponse> {
|
|
287
|
+
const { response } = await client().verifyMagicLink(
|
|
288
|
+
{ sessionId, token },
|
|
289
|
+
{ meta: authMeta() },
|
|
290
|
+
);
|
|
291
|
+
return response;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// ── IdP Link ──
|
|
295
|
+
|
|
296
|
+
export async function confirmIdpLink(
|
|
297
|
+
linkToken: string,
|
|
298
|
+
confirm: boolean,
|
|
299
|
+
): Promise<ConfirmIdpLinkResponse> {
|
|
300
|
+
const { response } = await client().confirmIdpLink(
|
|
301
|
+
{ linkToken, confirm },
|
|
302
|
+
{ meta: authMeta() },
|
|
303
|
+
);
|
|
304
|
+
return response;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// ── Organization Selector ──
|
|
308
|
+
|
|
309
|
+
export async function listUserOrganizations(): Promise<ListUserOrganizationsResponse> {
|
|
310
|
+
const { response } = await client().listUserOrganizations(
|
|
311
|
+
{},
|
|
312
|
+
{ meta: authMeta() },
|
|
313
|
+
);
|
|
314
|
+
return response;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export async function selectOrganization(
|
|
318
|
+
organizationId: string,
|
|
319
|
+
): Promise<SelectOrganizationResponse> {
|
|
320
|
+
const { response } = await client().selectOrganization(
|
|
321
|
+
{ organizationId },
|
|
322
|
+
{ meta: authMeta() },
|
|
323
|
+
);
|
|
324
|
+
return response;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// ── Terms ──
|
|
328
|
+
|
|
329
|
+
export async function getTerms(
|
|
330
|
+
version?: string,
|
|
331
|
+
locale?: string,
|
|
332
|
+
): Promise<GetTermsResponse> {
|
|
333
|
+
const { response } = await client().getTerms(
|
|
334
|
+
{ version, locale },
|
|
335
|
+
{ meta: authMeta() },
|
|
336
|
+
);
|
|
337
|
+
return response;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export async function acceptTerms(
|
|
341
|
+
version: string,
|
|
342
|
+
): Promise<AcceptTermsResponse> {
|
|
343
|
+
const { response } = await client().acceptTerms(
|
|
344
|
+
{ version },
|
|
345
|
+
{ meta: authMeta() },
|
|
346
|
+
);
|
|
347
|
+
return response;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// ── CIBA ──
|
|
351
|
+
|
|
352
|
+
export async function approveCiba(
|
|
353
|
+
authReqId: string,
|
|
354
|
+
): Promise<CibaConsentResponse> {
|
|
355
|
+
const { response } = await client().approveCiba(
|
|
356
|
+
{ authReqId },
|
|
357
|
+
{ meta: authMeta() },
|
|
358
|
+
);
|
|
359
|
+
return response;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export async function denyCiba(
|
|
363
|
+
authReqId: string,
|
|
364
|
+
reason?: string,
|
|
365
|
+
): Promise<CibaConsentResponse> {
|
|
366
|
+
const { response } = await client().denyCiba(
|
|
367
|
+
{ authReqId, reason },
|
|
368
|
+
{ meta: authMeta() },
|
|
369
|
+
);
|
|
370
|
+
return response;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// ── Captcha ──
|
|
374
|
+
|
|
375
|
+
export async function verifyCaptcha(
|
|
376
|
+
challengeId: string,
|
|
377
|
+
token: string,
|
|
378
|
+
): Promise<VerifyCaptchaResponse> {
|
|
379
|
+
const { response } = await client().verifyCaptcha(
|
|
380
|
+
{ challengeId, token },
|
|
381
|
+
{ meta: authMeta() },
|
|
382
|
+
);
|
|
383
|
+
return response;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// ── Dynamic Prompt ──
|
|
387
|
+
|
|
388
|
+
export async function getDynamicPrompt(
|
|
389
|
+
promptId: string,
|
|
390
|
+
): Promise<DynamicPrompt> {
|
|
391
|
+
const { response } = await client().getDynamicPrompt(
|
|
392
|
+
{ promptId },
|
|
393
|
+
{ meta: authMeta() },
|
|
394
|
+
);
|
|
395
|
+
return response;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export async function submitDynamicPrompt(
|
|
399
|
+
promptId: string,
|
|
400
|
+
values: Record<string, string>,
|
|
401
|
+
): Promise<SubmitDynamicPromptResponse> {
|
|
402
|
+
const { response } = await client().submitDynamicPrompt(
|
|
403
|
+
{ promptId, values },
|
|
404
|
+
{ meta: authMeta() },
|
|
405
|
+
);
|
|
406
|
+
return response;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// ── Step-Up Auth ──
|
|
410
|
+
|
|
411
|
+
export async function requestStepUp(
|
|
412
|
+
sessionId: string,
|
|
413
|
+
method: StepUpMethod,
|
|
414
|
+
): Promise<StepUpChallenge> {
|
|
415
|
+
const { response } = await client().requestStepUp(
|
|
416
|
+
{ sessionId, method },
|
|
417
|
+
{ meta: authMeta() },
|
|
418
|
+
);
|
|
419
|
+
return response;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export async function completeStepUp(
|
|
423
|
+
sessionId: string,
|
|
424
|
+
method: StepUpMethod,
|
|
425
|
+
challengeId: string,
|
|
426
|
+
proof: {
|
|
427
|
+
totpCode?: string;
|
|
428
|
+
webauthnAssertion?: Uint8Array;
|
|
429
|
+
recoveryCode?: string;
|
|
430
|
+
},
|
|
431
|
+
): Promise<CompleteStepUpResponse> {
|
|
432
|
+
const { response } = await client().completeStepUp(
|
|
433
|
+
{
|
|
434
|
+
sessionId,
|
|
435
|
+
method,
|
|
436
|
+
challengeId,
|
|
437
|
+
proof: proof.totpCode
|
|
438
|
+
? { oneofKind: "totpCode", totpCode: proof.totpCode }
|
|
439
|
+
: proof.webauthnAssertion
|
|
440
|
+
? {
|
|
441
|
+
oneofKind: "webauthnAssertion",
|
|
442
|
+
webauthnAssertion: proof.webauthnAssertion,
|
|
443
|
+
}
|
|
444
|
+
: proof.recoveryCode
|
|
445
|
+
? { oneofKind: "recoveryCode", recoveryCode: proof.recoveryCode }
|
|
446
|
+
: { oneofKind: undefined },
|
|
447
|
+
},
|
|
448
|
+
{ meta: authMeta() },
|
|
449
|
+
);
|
|
450
|
+
return response;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// ── MFA Credential Management ──
|
|
454
|
+
|
|
455
|
+
export async function deleteMfaCredential(
|
|
456
|
+
credentialId: string,
|
|
457
|
+
): Promise<DeleteMfaCredentialResponse> {
|
|
458
|
+
const { response } = await client().deleteMfaCredential(
|
|
459
|
+
{ credentialId },
|
|
460
|
+
{ meta: authMeta() },
|
|
461
|
+
);
|
|
462
|
+
return response;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// ── Account Deletion ──
|
|
466
|
+
|
|
467
|
+
export async function confirmAccountDeletion(
|
|
468
|
+
confirmationText: string,
|
|
469
|
+
): Promise<ConfirmAccountDeletionResponse> {
|
|
470
|
+
const { response } = await client().confirmAccountDeletion(
|
|
471
|
+
{ confirmationText },
|
|
472
|
+
{ meta: authMeta() },
|
|
473
|
+
);
|
|
474
|
+
return response;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// ── Password Reset ──
|
|
478
|
+
|
|
479
|
+
export async function requestPasswordReset(
|
|
480
|
+
principal: string,
|
|
481
|
+
clientId: string,
|
|
482
|
+
redirectUri: string,
|
|
483
|
+
captchaToken?: string,
|
|
484
|
+
): Promise<RequestPasswordResetResponse> {
|
|
485
|
+
const { response } = await client().requestPasswordReset({
|
|
486
|
+
principal,
|
|
487
|
+
clientId,
|
|
488
|
+
redirectUri,
|
|
489
|
+
captchaToken: captchaToken ?? "",
|
|
490
|
+
});
|
|
491
|
+
return response;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export async function verifyPasswordReset(
|
|
495
|
+
sessionId: string,
|
|
496
|
+
token: string,
|
|
497
|
+
): Promise<VerifyPasswordResetResponse> {
|
|
498
|
+
const { response } = await client().verifyPasswordReset({
|
|
499
|
+
sessionId,
|
|
500
|
+
token,
|
|
501
|
+
});
|
|
502
|
+
return response;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export async function completePasswordReset(
|
|
506
|
+
resetSessionId: string,
|
|
507
|
+
registrationRecord: Uint8Array,
|
|
508
|
+
opts?: {
|
|
509
|
+
zkppProof?: Uint8Array;
|
|
510
|
+
zkppInstances?: Uint8Array[];
|
|
511
|
+
historyCommitment?: Uint8Array;
|
|
512
|
+
commitmentSalt?: Uint8Array;
|
|
513
|
+
},
|
|
514
|
+
): Promise<CompletePasswordResetResponse> {
|
|
515
|
+
const { response } = await client().completePasswordReset({
|
|
516
|
+
resetSessionId,
|
|
517
|
+
registrationRecord,
|
|
518
|
+
zkppProof: opts?.zkppProof ?? new Uint8Array(),
|
|
519
|
+
zkppInstances: opts?.zkppInstances ?? [],
|
|
520
|
+
historyCommitment: opts?.historyCommitment ?? new Uint8Array(),
|
|
521
|
+
commitmentSalt: opts?.commitmentSalt ?? new Uint8Array(),
|
|
522
|
+
});
|
|
523
|
+
return response;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// Recovery shard RPCs (downloadRecoveryShard, uploadRecoveryShard, getRecoveryInfo)
|
|
527
|
+
// are EE/SaaS-only — defined in proto-ee, not in CE proto.
|
|
528
|
+
|
|
529
|
+
// ── OPAQUE ──
|
|
530
|
+
|
|
531
|
+
export async function opaqueLoginStart(
|
|
532
|
+
principal: string,
|
|
533
|
+
credentialRequest: Uint8Array,
|
|
534
|
+
): Promise<OpaqueLoginStartResponse> {
|
|
535
|
+
const { response } = await client().opaqueLoginStart({
|
|
536
|
+
principal,
|
|
537
|
+
credentialRequest,
|
|
538
|
+
});
|
|
539
|
+
return response;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export async function opaqueLoginFinish(
|
|
543
|
+
principal: string,
|
|
544
|
+
credentialFinalization: Uint8Array,
|
|
545
|
+
serverLoginState: string,
|
|
546
|
+
): Promise<OpaqueLoginFinishResponse> {
|
|
547
|
+
const { response } = await client().opaqueLoginFinish({
|
|
548
|
+
principal,
|
|
549
|
+
credentialFinalization,
|
|
550
|
+
serverLoginState,
|
|
551
|
+
});
|
|
552
|
+
return response;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export async function opaqueRegistrationStart(
|
|
556
|
+
principal: string,
|
|
557
|
+
registrationRequest: Uint8Array,
|
|
558
|
+
): Promise<OpaqueRegistrationStartResponse> {
|
|
559
|
+
const { response } = await client().opaqueRegistrationStart({
|
|
560
|
+
principal,
|
|
561
|
+
registrationRequest,
|
|
562
|
+
});
|
|
563
|
+
return response;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export async function opaqueRegistrationFinish(
|
|
567
|
+
principal: string,
|
|
568
|
+
registrationRecord: Uint8Array,
|
|
569
|
+
serverSetup: string,
|
|
570
|
+
): Promise<OpaqueRegistrationFinishResponse> {
|
|
571
|
+
const { response } = await client().opaqueRegistrationFinish({
|
|
572
|
+
principal,
|
|
573
|
+
registrationRecord,
|
|
574
|
+
serverSetup,
|
|
575
|
+
});
|
|
576
|
+
return response;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Re-export types for convenience
|
|
580
|
+
export { StepUpMethod };
|
|
581
|
+
export type {
|
|
582
|
+
OpaqueLoginStartResponse,
|
|
583
|
+
OpaqueLoginFinishResponse,
|
|
584
|
+
OpaqueRegistrationStartResponse,
|
|
585
|
+
OpaqueRegistrationFinishResponse,
|
|
586
|
+
UserOrganization,
|
|
587
|
+
MfaVerifyResponse,
|
|
588
|
+
TotpEnrollmentChallenge,
|
|
589
|
+
FinishTotpEnrollmentResponse,
|
|
590
|
+
ResendSmsMfaResponse,
|
|
591
|
+
GenerateRecoveryCodesResponse,
|
|
592
|
+
VerifyOtpResponse,
|
|
593
|
+
VerifyPhoneResponse,
|
|
594
|
+
ConfirmIdpLinkResponse,
|
|
595
|
+
ListUserOrganizationsResponse,
|
|
596
|
+
SelectOrganizationResponse,
|
|
597
|
+
GetTermsResponse,
|
|
598
|
+
AcceptTermsResponse,
|
|
599
|
+
CibaConsentResponse,
|
|
600
|
+
VerifyCaptchaResponse,
|
|
601
|
+
DynamicPrompt,
|
|
602
|
+
SubmitDynamicPromptResponse,
|
|
603
|
+
StepUpChallenge,
|
|
604
|
+
CompleteStepUpResponse,
|
|
605
|
+
DeleteMfaCredentialResponse,
|
|
606
|
+
ConfirmAccountDeletionResponse,
|
|
607
|
+
SubmitDeviceUserCodeResponse,
|
|
608
|
+
WebAuthnAuthenticationStartResponse,
|
|
609
|
+
WebAuthnAuthenticationFinishResponse,
|
|
610
|
+
WebAuthnRegistrationStartResponse,
|
|
611
|
+
WebAuthnRegistrationFinishResponse,
|
|
612
|
+
RequestMagicLinkResponse,
|
|
613
|
+
VerifyMagicLinkResponse,
|
|
614
|
+
RequestPasswordResetResponse,
|
|
615
|
+
VerifyPasswordResetResponse,
|
|
616
|
+
CompletePasswordResetResponse,
|
|
617
|
+
};
|